You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
var pull = require('../') |
|
var test = require('tape') |
|
//test through streams compose on pipe! |
|
|
|
test('join through streams with pipe', function (t) { |
|
|
|
var map = pull.map |
|
|
|
var pipeline = |
|
pull( |
|
map(function (d) { |
|
//make exciting! |
|
return d + '!' |
|
}), |
|
map(function (d) { |
|
//make loud |
|
return d.toUpperCase() |
|
}), |
|
map(function (d) { |
|
//add sparkles |
|
return '*** ' + d + ' ***' |
|
}) |
|
) |
|
//the pipe line does not have a source stream. |
|
//so it should be a reader (function that accepts |
|
//a read function) |
|
|
|
t.equal('function', typeof pipeline) |
|
t.equal(1, pipeline.length) |
|
|
|
//if we pipe a read function to the pipeline, |
|
//the pipeline will become readable! |
|
|
|
var read = |
|
pull( |
|
pull.values(['billy', 'joe', 'zeke']), |
|
pipeline |
|
) |
|
|
|
t.equal('function', typeof read) |
|
//we will know it's a read function, |
|
//because read takes two args. |
|
t.equal(2, read.length) |
|
|
|
pull( |
|
read, |
|
pull.collect(function (err, array) { |
|
console.log(array) |
|
t.deepEqual( |
|
array, |
|
[ '*** BILLY! ***', '*** JOE! ***', '*** ZEKE! ***' ] |
|
) |
|
t.end() |
|
}) |
|
) |
|
|
|
})
|
|
|