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

update README + tests #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ pull(

### merge(left, right, compare?)

return a stream that is the merge of left and right streams.
merge pulls a chunk from both `left` and `right` and then
compares them. `compare` has the same signature as `Array#sort(compare)`.
If the two chunks are compared the same, the chunk from the right stream
Return a stream that is the merge of left and right streams.

merge pulls a chunk from both `left` and `right` and then compares them.
`compare` has a similar signature as `Array#sort(compare)`
**but if the two chunks are compared the same**, the chunk from the right stream
is taken, but the left chunk is dropped.
Otherwise, the lowest chunk is passed to the stream.

Expand Down
19 changes: 8 additions & 11 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var tape = require('tape')
var pull = require('pull-stream')

Expand All @@ -9,7 +8,7 @@ tape('empty', function (t) {
pull(
merge(pull.values([]), pull.values([])),
pull.collect(function (err, ary) {
console.log(ary)
// console.log(ary)
t.deepEqual(ary, [])
t.end()
})
Expand All @@ -22,7 +21,7 @@ tape('equal', function (t) {
pull(
merge(pull.values([1]), pull.values([1])),
pull.collect(function (err, ary) {
console.log(ary)
// console.log(ary)
t.deepEqual(ary, [1])
t.end()
})
Expand All @@ -35,7 +34,7 @@ tape('different', function (t) {
pull(
merge(pull.values([1]), pull.values([2])),
pull.collect(function (err, ary) {
console.log(ary)
// console.log(ary)
t.deepEqual(ary, [1, 2])
t.end()
})
Expand All @@ -48,37 +47,35 @@ tape('different', function (t) {
pull(
merge(pull.values([2, 3]), pull.values([1])),
pull.collect(function (err, ary) {
console.log(ary)
// console.log(ary)
t.deepEqual(ary, [1, 2, 3])
t.end()
})
)

})

return


// return
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowed these tests below here to run

tape('simple', function (t) {

pull(
merge(pull.values([0, 2, 4, 6]), pull.values([1,3,5,7])),
pull.collect(function (err, ary) {
console.log(ary)
// console.log(ary)
t.deepEqual(ary, [0,1,2,3,4,5,6,7])
t.end()
})
)

})

return
// return
tape('overwrite', function (t) {
pull(
merge(pull.values([0, 2, 3, 5, 6]), pull.values([1,4,5,7])),
pull.collect(function (err, ary) {
t.deepEqual(ary, [0,1,2,3,4,5,6,7])
console.log(ary)
// console.log(ary)
t.end()
})
)
Expand Down
24 changes: 14 additions & 10 deletions test/merge.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
var async = require('interleavings')
var pull = require('pull-stream')
var assert = require('assert')
var tape = require('tape')
var merge = require('../')

async.test(strange, function (err, results, stats) {
console.log(results)
assert.equal(stats.failures, 0)
console.log('passed')
tape('merge.js', t => {
t.plan(101)
async.test(strange(t), function (err, results, stats) {
// console.log(results)
t.equal(stats.failures, 0, 'no failures')
})

function strange (async) {
})

function strange (t) {
return function (async) {

function p (read) {
return function (abort, cb) {
Expand All @@ -29,20 +33,20 @@ function strange (async) {
function (read) {
return function (abort, cb) {
read(abort, function (end, data) {
console.log(end, data)
// console.log(end, data)
cb(end, data)
})
}
},
pull.collect(function (err, ary) {
console.log(ary)
// console.log(ary)

assert.deepEqual(ary, [1,2,3,4,5,6,7,8,9,10,11,12])
t.deepEqual(ary, [1,2,3,4,5,6,7,8,9,10,11,12])
async.done()
})
)

}
}

//strange(async(17, function (err, result) {
// if(result.error)
Expand Down