Swap-Aggregator-Subgraph/node_modules/pull-stream/test/compose.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

58 lines
1.2 KiB
JavaScript

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()
})
)
})