JSPM

pull-serializer

0.3.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q20333F
  • License MIT

de/serialize pull streams

Package Exports

  • pull-serializer

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-serializer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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')
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
)