Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (proxyRequest) {
proxyRequests.delete(id)
proxyRequest.reject(message.data)
}
break
}
case MessageType.REPLY_STREAM: {
const stream = this.stream
const { id, service } = message
const proxyRequest = proxyRequests.get(id)
if (proxyRequest) {
proxyRequests.delete(id)
const proxyStream = new Duplex({
final: (callback: Callback) => {
/* istanbul ignore else */
if (this.stream === stream) {
this.send({
data: null,
id,
name: null,
service,
type: MessageType.STREAM_INPUT_END,
})
}
callback(null)
},
objectMode: true,
read: () => undefined,
write: (
it('should work on a core Duplex Stream', function(done) {
var testStream = new Stream.Duplex();
inspectStream(testStream).should.equal('');
done();
});
root.getDuplexStream = function() {
var duplex = new Stream.Duplex();
duplex.data = "";
duplex._write = function(chunk, enc, next) {
this.data += chunk.toString();
next();
};
duplex._read = function() {
return this.data;
};
return duplex;
};
return function(params, callback) {
var response;
var str = new Duplex();
str._read = function(size) {
if (response) {
str.push(response.body);
}
};
var bufs = [];
var sent = false;
str._write = function(chunk, encoding, callback) {
bufs.push(chunk.toString(encoding));
callback();
};
str.on('finish', function() {
if (!sent) {
send(bufs.join(''));
sent = true;
}
_encoding: string,
callback: (error: Error | null) => void,
) {
b.push(data)
callback(null)
},
final(callback: (error: Error | null) => void) {
b.push(null)
callback(null)
},
destroy(error: Error | null, callback: (error: Error | null) => void) {
b.destroy()
callback(error)
},
})
const b = new Duplex({
allowHalfOpen,
objectMode,
read() {
return
},
write(
data: any,
_encoding: string,
callback: (error: Error | null) => void,
) {
a.push(data)
callback(null)
},
final(callback: (error: Error | null) => void) {
a.push(null)
callback(null)
}
function resolveGlob(glob) {
var mod = '';
if (glob[0] === '!') {
mod = glob[0];
glob = glob.slice(1);
}
return mod + normalize(resolveFilepath(glob));
}
globs = globs.map(resolveGlob);
var baseForced = Boolean(opts.base);
var outputStream = new Duplex({objectMode: true, allowHalfOpen: true});
outputStream._write = function _write(file, enc, done) {
cb(file);
this.push(file);
done();
};
outputStream._read = function _read() { };
var watcher = chokidar.watch(globs, opts);
opts.events.forEach(function (ev) {
watcher.on(ev, processEvent.bind(undefined, ev));
});
['add', 'change', 'unlink', 'addDir', 'unlinkDir', 'error', 'ready', 'raw']
module.exports = function(params, callback) {
var xhr = new XMLHttpRequest();
xhr.open(params.method, params.url);
if (params.headers) {
for (var header in params.headers) {
xhr.setRequestHeader(header, params.headers[header]);
}
}
xhr.setRequestHeader("Accept", "*/*");
var response;
var str = new Duplex();
str._read = function(size) {
if (response) {
str.push(response.body);
}
};
var bufs = [];
var sent = false;
str._write = function(chunk, encoding, callback) {
bufs.push(chunk.toString(encoding === "buffer" ? "binary" : encoding));
callback();
};
str.on('finish', function() {
if (!sent) {
xhr.send(bufs.join(''));
sent = true;
}
export function invertedStreams({
allowHalfOpen = true,
objectMode = false,
} = {}): [Duplex, Duplex] {
const a = new Duplex({
allowHalfOpen,
objectMode,
read() {
return
},
write(
data: any,
_encoding: string,
callback: (error: Error | null) => void,
) {
b.push(data)
callback(null)
},
final(callback: (error: Error | null) => void) {
b.push(null)
callback(null)