Skip to content

Commit

Permalink
Merge pull request #23 from LinusU/prefer-const
Browse files Browse the repository at this point in the history
Prefer const over let
  • Loading branch information
zensh committed Oct 13, 2018
2 parents bfc1dba + da27972 commit 8b4b829
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -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)
Expand Down
110 changes: 55 additions & 55 deletions test/index.js
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 8b4b829

Please sign in to comment.