How to use stream-splicer - 10 common examples

To help you get started, we’ve selected a few stream-splicer 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 datproject / dat / lib / transformations.js View on Github external
proc.stderr.resume() // drain it!
  proc.unref()
  proc.stderr.unref()
  proc.stdout.unref()
  proc.stdin.unref()
  
  var serializer = ldjson.serialize()
  var parser = ldjson.parse()
  
  if (process.env.DEBUG) {
    serializer.pipe(debugStream('transform input: '))
    dup.pipe(debugStream('transform output: '))
  }
  
  return splicer.obj([serializer, dup, parser])
}
github datproject / dat / lib / transformations.js View on Github external
module.exports = function(transforms) {
  transforms = transforms
    .map(normalize)
    .map(function(t, i) {
      debug('Registering transform #' + i, t)
      // TODO: support more formats
      if (typeof t === 'function') return t()
      if (typeof t.pipe === 'function') return t
      if (t.format !== 'json') throw new Error('Transform #'+i+' not a non supported format')
      if (t.command) return command(t)
      if (t.module)  return mod(t)

      throw new Error('Transform #'+i+' is not currently support')
    })

  return splicer.obj(transforms)
}
github cloudflare / ipfs-ext / node_modules / labeled-stream-splicer / index.js View on Github external
function Labeled (streams, opts) {
    if (!(this instanceof Labeled)) return new Labeled(streams, opts);
    Splicer.call(this, [], opts);
    
    var reps = [];
    for (var i = 0; i < streams.length; i++) {
        var s = streams[i];
        if (typeof s === 'string') continue;
        if (Array.isArray(s)) {
            s = new Labeled(s, opts);
        }
        if (i >= 0 && typeof streams[i-1] === 'string') {
            s.label = streams[i-1];
        }
        reps.push(s);
    }
    if (typeof streams[i-1] === 'string') {
        reps.push(new Labeled([], opts));
    }
github cloudflare / ipfs-ext / node_modules / labeled-stream-splicer / index.js View on Github external
Labeled.prototype.indexOf = function (stream) {
    if (typeof stream === 'string') {
        for (var i = 0; i < this._streams.length; i++) {
            if (this._streams[i].label === stream) return i;
        }
        return -1;
    }
    else {
        return Splicer.prototype.indexOf.call(this, stream);
    }
};
github cloudflare / ipfs-ext / node_modules / labeled-stream-splicer / index.js View on Github external
Labeled.prototype.splice = function (key) {
    var ix;
    if (typeof key === 'string') {
        ix = this.indexOf(key);
    }
    else ix = key;
    var args = [ ix ].concat([].slice.call(arguments, 1));
    return Splicer.prototype.splice.apply(this, args);
};
github cloudflare / ipfs-ext / node_modules / labeled-stream-splicer / index.js View on Github external
Labeled.prototype.get = function (key) {
    if (typeof key === 'string') {
        var ix = this.indexOf(key);
        if (ix < 0) return undefined;
        return this._streams[ix];
    }
    else return Splicer.prototype.get.call(this, key);
};

stream-splicer

streaming pipeline with a mutable configuration

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis