blob: 6f7ec91a4014bb54cffc6426a5bd97794ae567a4 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var isStream = module.exports = function (stream) {
4 return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
5};
6
7isStream.writable = function (stream) {
8 return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
9};
10
11isStream.readable = function (stream) {
12 return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
13};
14
15isStream.duplex = function (stream) {
16 return isStream.writable(stream) && isStream.readable(stream);
17};
18
19isStream.transform = function (stream) {
20 return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
21};