1.0.1 • Published 4 years ago

psp-reduce v1.0.1

Weekly downloads
11
License
-
Repository
github
Last release
4 years ago

Pull stream reduce

A modern version of the pull-stream reduce sink which returns a promise rather than calling a callback.

reduce(reducer[, initial])
const {pull, values, map} = require('pull-stream')
const reduce = require('psp-reduce')

pull(values([1, 2, 3]), reduce((a, b) => a + b)).then(console.log)
// 6

pull(values([1, 2, 3]), reduce((a, b) => a + b, 10)).then(console.log)
// 16

Abort

Aborting without an error will halt the process and return the value so far.

abort([err])
const {pull, values} = require('pull-stream')
const reduce = require('psp-reduce')

const sink = reduce((a, b) => a + b, 10)
sink.abort()
pull(values([1, 2, 3]), sink).then(console.log)
// 10
1.0.1

4 years ago

1.0.0

5 years ago