Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var isStream = require('is-stream');
function assertType(type) {
if (type !== 'readable' && type !== 'writable') {
throw new Error(type + ' is not a known stream type');
}
}
function assertObjectMode(stream, state, errStr) {
if (!stream[state] || !stream[state].objectMode) {
throw new TypeError(errStr);
}
}
isStream.stdio = function isStdio(stream) {
return stream === process.stdin ||
stream === process.stdout ||
stream === process.stderr;
};
isStream.assertStream = function assertStream(stream, type, errStr) {
assertType(type);
// When redirecting to a file, for some reason, this is not
// detected as a writable stream, even though it is.
//
// `grandma run testname -d 2ms -c 1 > file.log`
//
// So we are just going to manually make this pass...
//
// https://github.com/nodejs/node/issues/8828