Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function TimingStream(opts) {
this.options = defaults(opts, {
emitAt: TimingStream.END,
delay: 0,
allowHalfOpen: true, // keep the readable side open after the source closes
writableObjectMode: true
});
Transform.call(this, opts);
this.startTime = Date.now();
// to support stopping mid-stream
this.stopped = false;
this.timeout = null;
}
util.inherits(TimingStream, Transform);
opts = copy( DEFAULTS );
if ( arguments.length ) {
err = validate( opts, options );
if ( err ) {
throw err;
}
}
// The stream's readable state should always be in object mode to prevent split data from being buffered (concatenated) and no longer being separated...
opts.readableObjectMode = true;
// The stream converts each chunk into a string so no need to encode strings written to the split stream as Buffer objects:
opts.decodeStrings = false;
// Make the stream a Transform stream:
debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );
Transform.call( this, opts );
// Cache the separator:
setNonEnumerableReadOnly( this, '_sep', ( opts.sep === null ) ? RE : opts.sep );
// The destruction state:
setNonEnumerable( this, '_destroyed', false );
// Cache the encoding:
setNonEnumerableReadOnly( this, '_encoding', opts.encoding );
// Buffer for storing partial splits:
setNonEnumerable( this, '_buffer', '' );
// Chunk counter:
setNonEnumerable( this, '_idx', -1 );
function Deps (opts) {
var self = this;
if (!(this instanceof Deps)) return new Deps(opts);
Transform.call(this, { objectMode: true });
if (!opts) opts = {};
this.basedir = opts.basedir || process.cwd();
this.cache = opts.cache;
this.fileCache = opts.fileCache;
this.pkgCache = opts.packageCache || {};
this.pkgFileCache = {};
this.pkgFileCachePending = {};
this._emittedPkg = {};
this.visited = {};
this.walking = {};
this.entries = [];
this._input = [];
this.paths = opts.paths || process.env.NODE_PATH || '';
function FilterStream(options) {
if (!(this instanceof FilterStream)) {
return new FilterStream(options);
}
options.objectMode = true;
Transform.call(this, options);
var that = this;
this.filter = options.filter;
this.offset = options.offset;
this._offsetCounter = 0;
this._destroyed = false;
if (this.filter && this.filter.length === 2) {
this._transform = filterTwoArguments;
}
}
function Deps (opts) {
var self = this;
if (!(this instanceof Deps)) return new Deps(opts);
Transform.call(this, { objectMode: true });
if (!opts) opts = {};
this.basedir = opts.basedir || process.cwd();
this.persistentCache = opts.persistentCache || function (file, id, pkg, fallback, cb) {
process.nextTick(function () {
fallback(null, cb);
});
};
this.cache = opts.cache;
this.fileCache = opts.fileCache;
this.pkgCache = opts.packageCache || {};
this.pkgFileCache = {};
this.pkgFileCachePending = {};
this._emittedPkg = {};
this.visited = {};
function Deps (opts) {
var self = this;
if (!(this instanceof Deps)) return new Deps(opts);
Transform.call(this, { objectMode: true });
if (!opts) opts = {};
this.basedir = opts.basedir || process.cwd();
this.persistentCache = opts.persistentCache || function (file, id, pkg, fallback, cb) {
process.nextTick(function () {
fallback(null, cb);
});
};
this.cache = opts.cache;
this.fileCache = opts.fileCache;
this.pkgCache = opts.packageCache || {};
this.pkgFileCache = {};
this.pkgFileCachePending = {};
this._emittedPkg = {};
this._transformDeps = {};
var Json = function(options) {
if (!(this instanceof Json)) {
return new Json(options);
}
options = this.options = util.defaults(options, {});
Transform.call(this, options);
this.supports = {
directory: true,
symlink: true
};
this.files = [];
};
function Channel(session, id) {
Transform.call(this, { objectMode: true, highWaterMark: 16 });
this._session = session;
this.id = id;
}
var Archiver = module.exports = function(options) {
options = this.options = util.defaults(options, {
highWaterMark: 1024 * 1024
});
Transform.call(this, options);
this._entries = [];
this._module = false;
this._pointer = 0;
this._queue = async.queue(this._onQueueTask.bind(this), 1);
this._queue.drain = this._onQueueDrain.bind(this);
this._state = {
finalize: false,
finalized: false,
modulePiped: false
};
};