How to use duplexer2 - 3 common examples

To help you get started, we’ve selected a few duplexer2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / js-ipfs / legacy-submodules / ipfs-network-pipe / wire.js View on Github external
function wireSegment() {
  // setup integrity checks (later signatures)
  var wire = msgproto.WireProtocol(Message)
  var intg = integrity.Protocol()
  connect(wire.buffers, intg.payloads)

  var enc = scope(wire.messages, intg.frames, '/payload')
  var dec = scope(intg.frames, wire.messages, '/payload')

  var o = {objectMode: true, highWaterMark: 16}
  return segment({
    // scoped because we need to convert only the payload
    messages: duplexer2(o, enc, dec),
    buffers: duplexer2(o, dec, enc),
    wire: wire,
    // messages: scope(wire.messages, intg.frames, '/payload'),
    // buffers: scope(intg.frames, wire.messages, '/payload'),
  })
}
github ipfs / js-ipfs / legacy-submodules / ipfs-network-pipe / wire.js View on Github external
function wireSegment() {
  // setup integrity checks (later signatures)
  var wire = msgproto.WireProtocol(Message)
  var intg = integrity.Protocol()
  connect(wire.buffers, intg.payloads)

  var enc = scope(wire.messages, intg.frames, '/payload')
  var dec = scope(intg.frames, wire.messages, '/payload')

  var o = {objectMode: true, highWaterMark: 16}
  return segment({
    // scoped because we need to convert only the payload
    messages: duplexer2(o, enc, dec),
    buffers: duplexer2(o, dec, enc),
    wire: wire,
    // messages: scope(wire.messages, intg.frames, '/payload'),
    // buffers: scope(intg.frames, wire.messages, '/payload'),
  })
}
github jamesramsay / hercule / src / inflate-stream.js View on Github external
function separator(match) {
      return _.merge(
        defaultSeparator(match),
        {
          indent: chunk.indent,
        }
      );
    }

    const tokenizerOptions = { leaveBehind: `${WHITESPACE_GROUP}`, source, token, separator };
    const linkRegExp = _.get(options, 'linkRegExp') || defaultTokenRegExp;
    const tokenizer = regexpTokenizer(tokenizerOptions, linkRegExp);

    trimmer.pipe(tokenizer).pipe(resolver).pipe(inflater);

    return duplexer({ objectMode: true }, trimmer, inflater);
  }

duplexer2

Like duplexer but using streams3

BSD-3-Clause
Latest version published 9 years ago

Package Health Score

71 / 100
Full package analysis

Popular duplexer2 functions