index.js 800 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var isStream = module.exports = function (stream) {
  3. return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
  4. };
  5. isStream.writable = function (stream) {
  6. return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
  7. };
  8. isStream.readable = function (stream) {
  9. return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
  10. };
  11. isStream.duplex = function (stream) {
  12. return isStream.writable(stream) && isStream.readable(stream);
  13. };
  14. isStream.transform = function (stream) {
  15. return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
  16. };