Skip to content

Pull-stream reduce function which returns a promise

Notifications You must be signed in to change notification settings

srcagency/psp-reduce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Pull-stream reduce function which returns a promise

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published