index.d.ts 905 B

123456789101112131415161718192021222324252627282930313233
  1. /// <reference types="node"/>
  2. declare const getStdin: {
  3. /**
  4. Get [`stdin`](https://nodejs.org/api/process.html#process_process_stdin) as a `string`.
  5. @returns A promise that is resolved when the `end` event fires on the `stdin` stream, indicating that there is no more data to be read. In a TTY context, an empty `string` is returned.
  6. @example
  7. ```
  8. // example.ts
  9. import getStdin = require('get-stdin');
  10. (async () => {
  11. console.log(await getStdin());
  12. //=> 'unicorns'
  13. })
  14. // $ echo unicorns | ts-node example.ts
  15. // unicorns
  16. ```
  17. */
  18. (): Promise<string>;
  19. /**
  20. Get [`stdin`](https://nodejs.org/api/process.html#process_process_stdin) as a `Buffer`.
  21. @returns A promise that is resolved when the `end` event fires on the `stdin` stream, indicating that there is no more data to be read. In a TTY context, an empty `Buffer` is returned.
  22. */
  23. buffer(): Promise<Buffer>;
  24. };
  25. export = getStdin;