git ssb

2+

Dominic / pull-stream



Tree: 7d0c918beaee414a6b11f020b51dfb097122ede0

Files: 7d0c918beaee414a6b11f020b51dfb097122ede0 / docs / throughs / map.md

1069 bytesRaw

pull-stream/throughs/map

[].map for pull-streams

Background

Pull-streams are arrays of data in time rather than space.

As with a [].map, we may want to map a function over a stream.

Example

var map = require('pull-stream/throughs/map')
pull(
  values([0, 1, 2, 3]),
  map(function (x) {
    return x * x
  }),
  log()
)
// 0
// 1
// 4
// 9

Usage

map = require('pull-stream/throughs/map')

map((data) => data)

map(fn) returns a through stream that calls the given fn for each chunk of incoming data and outputs the return value, in the same order as before.

Install

With npm installed, run

$ npm install pull-stream

See Also

License

MIT

Built with git-ssb-web