2.2.0 • Published 10 years ago
pull-generate v2.2.0
pull-generate
A pull-stream source that produces data on state transitions
Simple Example
var generate = require('pull-generate')
var pull = require('pull-stream')
pull(
generate(0, function(state, cb) {
cb(state>3 ? true : null, 1<<state, state + 1)
}),
pull.log()
)
// ==> 1 2 4 8Usage
generate(initialState, expand [, onAbort])
expand: function that is called withinitialstateand a callback.- the callback has the following signature:
callback(err, data, newState)errnullto passdatadownstream (normal operation)trueindicates the end of the stream- everything else is treated as an error
datais send downstream (only if err === null)newStateis used asstatein the next call toexpand.
- the callback has the following signature:
- onAbort: optional function that is called after the stream ended
- is called with
nullor an error object
- is called with
License
MIT