index.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /// <reference types="node"/>
  2. import {Readable as ReadableStream} from 'stream';
  3. declare namespace intoStream {
  4. type Input =
  5. | Buffer
  6. | NodeJS.TypedArray
  7. | ArrayBuffer
  8. | string
  9. | Iterable<Buffer | string>
  10. | AsyncIterable<Buffer | string>;
  11. /* eslint-disable @typescript-eslint/ban-types */
  12. type InputObject =
  13. | object
  14. | Iterable<object>
  15. | AsyncIterable<object>;
  16. /* eslint-enable @typescript-eslint/ban-types */
  17. }
  18. declare const intoStream: {
  19. /**
  20. Convert object `input` into a stream.
  21. @param input - The object input to convert to a stream.
  22. @returns A [readable object stream](https://nodejs.org/api/stream.html#stream_object_mode).
  23. */
  24. object: (
  25. input: intoStream.InputObject | Promise<intoStream.InputObject>
  26. ) => ReadableStream;
  27. /**
  28. Convert `input` into a stream. Adheres to the requested chunk size, except for `array` where each element will be a chunk.
  29. @param input - The input to convert to a stream.
  30. @returns A [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable).
  31. @example
  32. ```
  33. import intoStream = require('into-stream');
  34. intoStream('unicorn').pipe(process.stdout);
  35. //=> 'unicorn'
  36. ```
  37. */
  38. (input: intoStream.Input | Promise<intoStream.Input>): ReadableStream;
  39. };
  40. export = intoStream;