Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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])
}
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)
}
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));
}
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);
}
};
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);
};
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);
};