Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pfrazee/pull-serializer
de/serialize pull streams
https://github.com/pfrazee/pull-serializer
Last synced: 11 days ago
JSON representation
de/serialize pull streams
- Host: GitHub
- URL: https://github.com/pfrazee/pull-serializer
- Owner: pfrazee
- Created: 2014-10-17T17:20:52.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-16T17:00:24.000Z (almost 10 years ago)
- Last Synced: 2024-12-10T15:41:33.158Z (19 days ago)
- Language: JavaScript
- Size: 160 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pull-serializer
Serializes and parses pull-streams, eg for sending over a channel.
Takes a duplex pull-stream and returns a wrapped version which will emit/consume the serialized format. The second parameter optionally takes an object with `{stringify: Function, parse: Function}` defined (the `JSON` signature). The third parameter optionally takes flags `{ignoreErrors: Boolean, separator: String}`.
- `ignoreErrors`: if true, bad JSON is filtered out and not emitted. If false (default) parse errors are emitted as `Error` objects
- `separator`: sets the string to separate messages with (default '\n')```js
var serializer = require('pull-serializer')var theduplex = serializer({
source: pull.values([5, "foo", [1,2,3], {hello: 'world'}]),
sink: pull.collect(console.log) // => false [5, "foo", [1,2,3], {hello: 'world'}]
})pull(
theduplex,
pull.map(function(chunk) {
assert(typeof chunk == 'string')
return chunk
}),
theduplex
)
```