From da279721fafc6b8de10f3c993c3332547450848a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 10 Oct 2018 20:47:23 +0200 Subject: [PATCH] Prefer const over let --- index.js | 4 +- test/index.js | 110 +++++++++++++++++++++++++------------------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/index.js b/index.js index 112654a..660a8d9 100644 --- a/index.js +++ b/index.js @@ -15,13 +15,13 @@ module.exports = merge2 function merge2 () { const streamsQueue = [] let merging = false - let args = slice.call(arguments) + const args = slice.call(arguments) let options = args[args.length - 1] if (options && !Array.isArray(options) && options.pipe == null) args.pop() else options = {} - let doEnd = options.end !== false + const doEnd = options.end !== false if (options.objectMode == null) options.objectMode = true if (options.highWaterMark == null) options.highWaterMark = 64 * 1024 const mergedStream = PassThrough(options) diff --git a/test/index.js b/test/index.js index 5d23b71..12ac5c2 100644 --- a/test/index.js +++ b/test/index.js @@ -13,13 +13,13 @@ test(require('@std/esm')(module)('../index.mjs').default) function test (merge2) { tman.suite('merge2', function () { tman.it('merge2(read1, read2, through3)', function (done) { - let options = {objectMode: true} - let result = [] - let read1 = fakeReadStream(options) - let read2 = fakeReadStream(options) - let through3 = through.obj() + const options = {objectMode: true} + const result = [] + const read1 = fakeReadStream(options) + const read2 = fakeReadStream(options) + const through3 = through.obj() - let mergeStream = merge2(read1, read2, through3) + const mergeStream = merge2(read1, read2, through3) read1.push(1) thunk.delay(100)(function () { @@ -49,10 +49,10 @@ function test (merge2) { }) tman.it('merge2(TransformStream)', function (done) { - let result = [] - let ts = through.obj() + const result = [] + const ts = through.obj() - let mergeStream = merge2(toThrough(ts)) + const mergeStream = merge2(toThrough(ts)) ts.push(1) thunk.delay(100)(function () { @@ -72,14 +72,14 @@ function test (merge2) { }) tman.it('merge2(read1, [read2, through3], through4, [through5, read6])', function (done) { - let options = {objectMode: true} - let result = [] - let read1 = fakeReadStream(options) - let read2 = fakeReadStream(options) - let through3 = through.obj() - let through4 = through.obj() - let through5 = through.obj() - let read6 = fakeReadStream(options) + const options = {objectMode: true} + const result = [] + const read1 = fakeReadStream(options) + const read2 = fakeReadStream(options) + const through3 = through.obj() + const through4 = through.obj() + const through5 = through.obj() + const read6 = fakeReadStream(options) read1.push(1) read1.push(null) @@ -98,7 +98,7 @@ function test (merge2) { read6.push(null) }) - let mergeStream = merge2(read1, [read2, through3], through4, [through5, read6]) + const mergeStream = merge2(read1, [read2, through3], through4, [through5, read6]) mergeStream .on('data', function (chunk) { @@ -112,15 +112,15 @@ function test (merge2) { }) tman.it('merge2().add(read1, [read2, through3], through4, [through5, read6])', function (done) { - let options = {objectMode: true} - let result = [] - let read1 = fakeReadStream(options) - let read2 = fakeReadStream(options) - let through3 = through.obj() - let through4 = through.obj() - let through5 = through.obj() - let read6 = fakeReadStream(options) - let mergeStream = merge2() + const options = {objectMode: true} + const result = [] + const read1 = fakeReadStream(options) + const read2 = fakeReadStream(options) + const through3 = through.obj() + const through4 = through.obj() + const through5 = through.obj() + const read6 = fakeReadStream(options) + const mergeStream = merge2() read1.push(1) read1.push(null) @@ -153,13 +153,13 @@ function test (merge2) { }) tman.it('merge2(read1, read2, through3, {objectMode: false})', function (done) { - let options = {objectMode: false} + const options = {objectMode: false} let result = '' - let read1 = fakeReadStream(options) - let read2 = fakeReadStream(options) - let through3 = through(options) + const read1 = fakeReadStream(options) + const read2 = fakeReadStream(options) + const through3 = through(options) - let mergeStream = merge2(read1, read2, through3, options) + const mergeStream = merge2(read1, read2, through3, options) read1.push('1') thunk.delay(100)(function () { @@ -189,11 +189,11 @@ function test (merge2) { }) tman.it('merge2([read1, read2]) with classic style streams', function (done) { - let result = [] - let read1 = fakeReadClassicStream() - let read2 = fakeReadClassicStream() + const result = [] + const read1 = fakeReadClassicStream() + const read2 = fakeReadClassicStream() - let mergeStream = merge2([read1, read2]) + const mergeStream = merge2([read1, read2]) read1.push(1) read1.push(null) @@ -214,13 +214,13 @@ function test (merge2) { }) tman.it('merge2(read1, read2, {end: false})', function (done) { - let options = {objectMode: true} - let result = [] - let read1 = fakeReadStream(options) - let read2 = fakeReadStream(options) - let through3 = through.obj() + const options = {objectMode: true} + const result = [] + const read1 = fakeReadStream(options) + const read2 = fakeReadStream(options) + const through3 = through.obj() - let mergeStream = merge2(read1, read2, {end: false}) + const mergeStream = merge2(read1, read2, {end: false}) read1.push(1) read1.push(2) @@ -252,15 +252,15 @@ function test (merge2) { }) tman.it('merge2(merge2(through4, [through5, read6]), read1, [read2, through3])', function (done) { - let options = {objectMode: true} - let result1 = [] - let result2 = [] - let read1 = fakeReadStream(options) - let read2 = fakeReadStream(options) - let through3 = through.obj() - let through4 = through.obj() - let through5 = through.obj() - let read6 = fakeReadStream(options) + const options = {objectMode: true} + const result1 = [] + const result2 = [] + const read1 = fakeReadStream(options) + const read2 = fakeReadStream(options) + const through3 = through.obj() + const through4 = through.obj() + const through5 = through.obj() + const read6 = fakeReadStream(options) read1.push(1) read1.push(null) @@ -279,13 +279,13 @@ function test (merge2) { read6.push(null) }) - let mergeStream1 = merge2(through4, [through5, read6]) + const mergeStream1 = merge2(through4, [through5, read6]) mergeStream1.on('data', function (chunk) { result1.push(chunk) }) - let mergeStream = merge2(mergeStream1, read1, [read2, through3]) + const mergeStream = merge2(mergeStream1, read1, [read2, through3]) mergeStream .on('data', function (chunk) { @@ -303,13 +303,13 @@ function test (merge2) { } function fakeReadStream (options) { - let readStream = new Stream.Readable(options) + const readStream = new Stream.Readable(options) readStream._read = function () {} return readStream } function fakeReadClassicStream () { - let readStream = new Stream() + const readStream = new Stream() readStream.readable = true readStream.push = function (data) { if (data === null) {