index.js
 1  'use strict';
 2  
 3  const isStream = stream =>
 4  	stream !== null &&
 5  	typeof stream === 'object' &&
 6  	typeof stream.pipe === 'function';
 7  
 8  isStream.writable = stream =>
 9  	isStream(stream) &&
10  	stream.writable !== false &&
11  	typeof stream._write === 'function' &&
12  	typeof stream._writableState === 'object';
13  
14  isStream.readable = stream =>
15  	isStream(stream) &&
16  	stream.readable !== false &&
17  	typeof stream._read === 'function' &&
18  	typeof stream._readableState === 'object';
19  
20  isStream.duplex = stream =>
21  	isStream.writable(stream) &&
22  	isStream.readable(stream);
23  
24  isStream.transform = stream =>
25  	isStream.duplex(stream) &&
26  	typeof stream._transform === 'function';
27  
28  module.exports = isStream;