No Description

index.d.ts 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import * as stream from 'stream';
  2. declare const isStream: {
  3. /**
  4. @returns Whether `stream` is a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
  5. @example
  6. ```
  7. import * as fs from 'fs';
  8. import isStream = require('is-stream');
  9. isStream(fs.createReadStream('unicorn.png'));
  10. //=> true
  11. isStream({});
  12. //=> false
  13. ```
  14. */
  15. (stream: unknown): stream is stream.Stream;
  16. /**
  17. @returns Whether `stream` is a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable).
  18. @example
  19. ```
  20. import * as fs from 'fs';
  21. import isStream = require('is-stream');
  22. isStream.writable(fs.createWriteStrem('unicorn.txt'));
  23. //=> true
  24. ```
  25. */
  26. writable(stream: unknown): stream is stream.Writable;
  27. /**
  28. @returns Whether `stream` is a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable).
  29. @example
  30. ```
  31. import * as fs from 'fs';
  32. import isStream = require('is-stream');
  33. isStream.readable(fs.createReadStream('unicorn.png'));
  34. //=> true
  35. ```
  36. */
  37. readable(stream: unknown): stream is stream.Readable;
  38. /**
  39. @returns Whether `stream` is a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
  40. @example
  41. ```
  42. import {Duplex} from 'stream';
  43. import isStream = require('is-stream');
  44. isStream.duplex(new Duplex());
  45. //=> true
  46. ```
  47. */
  48. duplex(stream: unknown): stream is stream.Duplex;
  49. /**
  50. @returns Whether `stream` is a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform).
  51. @example
  52. ```
  53. import * as fs from 'fs';
  54. import Stringify = require('streaming-json-stringify');
  55. import isStream = require('is-stream');
  56. isStream.transform(Stringify());
  57. //=> true
  58. ```
  59. */
  60. transform(input: unknown): input is stream.Transform;
  61. };
  62. export = isStream;