Initial commit
This commit is contained in:
37
node_modules/is-stream/index.js
generated
vendored
Normal file
37
node_modules/is-stream/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
export function isStream(stream, {checkOpen = true} = {}) {
|
||||
return stream !== null
|
||||
&& typeof stream === 'object'
|
||||
&& (stream.writable || stream.readable || !checkOpen || (stream.writable === undefined && stream.readable === undefined))
|
||||
&& typeof stream.pipe === 'function';
|
||||
}
|
||||
|
||||
export function isWritableStream(stream, {checkOpen = true} = {}) {
|
||||
return isStream(stream, {checkOpen})
|
||||
&& (stream.writable || !checkOpen)
|
||||
&& typeof stream.write === 'function'
|
||||
&& typeof stream.end === 'function'
|
||||
&& typeof stream.writable === 'boolean'
|
||||
&& typeof stream.writableObjectMode === 'boolean'
|
||||
&& typeof stream.destroy === 'function'
|
||||
&& typeof stream.destroyed === 'boolean';
|
||||
}
|
||||
|
||||
export function isReadableStream(stream, {checkOpen = true} = {}) {
|
||||
return isStream(stream, {checkOpen})
|
||||
&& (stream.readable || !checkOpen)
|
||||
&& typeof stream.read === 'function'
|
||||
&& typeof stream.readable === 'boolean'
|
||||
&& typeof stream.readableObjectMode === 'boolean'
|
||||
&& typeof stream.destroy === 'function'
|
||||
&& typeof stream.destroyed === 'boolean';
|
||||
}
|
||||
|
||||
export function isDuplexStream(stream, options) {
|
||||
return isWritableStream(stream, options)
|
||||
&& isReadableStream(stream, options);
|
||||
}
|
||||
|
||||
export function isTransformStream(stream, options) {
|
||||
return isDuplexStream(stream, options)
|
||||
&& typeof stream._transform === 'function';
|
||||
}
|
||||
Reference in New Issue
Block a user