Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer const over let #23

Merged
merged 1 commit into from Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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