Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function send(options, data, encoding, contentType) {
options.headers = {'Content-Type' : contentType};
options.encoding = encoding;
return _send(options, data, new PassThrough()).pipe(request(options, handler));
}
function startDeserialize(source, sourceType, cb) {
var callback = once(cb);
if (!source) {
return callback(new Error("no source to deserialize"));
} else if (Buffer.isBuffer(source)) {
var temp = source;
source = new stream.PassThrough();
source.end(temp);
} else if (typeof source === 'string') {
source = fs.createReadStream(source);
}
source.on('error', callback);
deserialize(source, sourceType, callback);
}
startStream(offset) {
this.offset = this.hashes.findIndex(h => offset <= h.offset + h.size);
Log.debug('starting to download from offset: ', offset, `${this.offset}/${this.hashes.length - 1}`);
this.skipBytes = offset - this.hashes[this.offset].offset;
this.output = new PassThrough();
this.output.on('close', this.end.bind(this));
this.downloadNext();
return this.output;
}