index.js 677 B

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