psp-collect
v1.0.1
Published
A modern version of the [pull-stream collect sink](https://pull-stream.github.io/#collect) which returns a promise rather than calling a callback.
Downloads
44
Readme
Pull stream collect
A modern version of the pull-stream collect sink which returns a promise rather than calling a callback.
collect()
const {pull, values, map} = require('pull-stream')
const collect = require('psp-collect')
pull(values([1, 2, 3]), map(x => x * 2), collect()).then(console.log)
// [ 2, 4, 6 ]
Abort
Aborting without an error will end the stream and return the value so far.
abort([err])
const {pull, values} = require('pull-stream')
const collect = require('psp-collect')
const sink = collect()
sink.abort()
pull(values([1, 2, 3]), sink).then(console.log)
// []