https://github.com/regular/pull-generate
pull-stream source that produces data on state transitions
https://github.com/regular/pull-generate
Last synced: about 2 months ago
JSON representation
pull-stream source that produces data on state transitions
- Host: GitHub
- URL: https://github.com/regular/pull-generate
- Owner: regular
- License: mit
- Created: 2015-09-05T14:44:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-09T14:18:23.000Z (over 10 years ago)
- Last Synced: 2025-02-01T12:48:10.452Z (about 1 year ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pull-generate
A [pull-stream](https://github.com/dominictarr/pull-stream) source that produces data on state transitions
## Simple Example
``` js
var generate = require('pull-generate')
var pull = require('pull-stream')
pull(
generate(0, function(state, cb) {
cb(state>3 ? true : null, 1< 1 2 4 8
```
## Usage
### `generate(initialState, expand [, onAbort])`
- `expand`: function that is called with `initialstate` and a callback.
- the callback has the following signature: `callback(err, data, newState)`
- `err`
- `null` to pass `data` downstream (normal operation)
- `true` indicates the end of the stream
- everything else is treated as an error
- `data` is send downstream (only if err === null)
- `newState` is used as `state` in the next call to `expand`.
- onAbort: optional function that is called after the stream ended
- is called with `null` or an error object
## License
MIT