JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3057
  • Score
    100M100P100Q108582F
  • License ISC

Scan algorithm for pull streams

Package Exports

  • pull-scan

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-scan) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pull scan Build Status

Scan algorithm for pull streams. It's like reduce, but emits intermediate values. So it's more like map but with an accumulator argument.

example

var test = require('tape')
var S = require('pull-stream')
var scan = require('../')

test('works given initial state', function (t) {
    t.plan(1)
    S(
        S.values([1,2,3]),

        scan(function (acc, n) {
            return acc + n
        }, 10),

        S.collect(function (err, data) {
            t.deepEqual(data, [11,13,16], 'should use init state argument')
        })
    )
})

test('use default init state', function (t) {
    t.plan(1)
    S(
        S.values([1,2,3]),

        scan(function (acc, n) {
            return acc + n
        }),

        S.collect(function (err, data) {
            t.deepEqual(data, [1,3,6],
                'should use first val as default state')
        })
    )
})