{"name":"get-stdin","version":"10.0.0","description":"Get stdin as a string or Uint8Array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stdin.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && node --test"},"keywords":["std","stdin","stdio","concat","buffer","stream","process","read"],"devDependencies":{"@types/node":"^25.2.0","delay":"^7.0.0","xo":"^1.2.3"},"gitHead":"14e9437c7de3764dae4d1a76b1987542fe1e2ee6","types":"./index.d.ts","_id":"get-stdin@10.0.0","bugs":{"url":"https://github.com/sindresorhus/get-stdin/issues"},"homepage":"https://github.com/sindresorhus/get-stdin#readme","_nodeVersion":"25.3.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-eWSePJ4zXFdqz+/Lyfopob4rIcoF/U2XfE8nJc7iZV6lnebWc9k7DoQQpX+2a9jc0AOvBsXvbe5YkjXl/MHbpg==","shasum":"438ea93d028ae5f312e3a3af88c11d30dbcfc195","tarball":"http://registry-npm.ywwl.com/get-stdin/download/get-stdin-10.0.0.tgz","fileCount":5,"unpackedSize":8256,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFICu2XF+xKbsKip51MZCY/OsD7/zm1QgFfF6XxEVLhTAiEA7RLcXelLMp941ZI10dm7dfSlonzpsDSXxsscJi9nCEE="}],"size":2889,"noattachment":false,"key":"/get-stdin/-/get-stdin-10.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/get-stdin_10.0.0_1770282680708_0.7252205690744893"},"_hasShrinkwrap":false,"readme":"# get-stdin\n\n> Get [stdin](https://nodejs.org/api/process.html#process_process_stdin) as a string or `Uint8Array`\n\n## Install\n\n```sh\nnpm install get-stdin\n```\n\n## Usage\n\n```js\n// example.js\nimport getStdin from 'get-stdin';\n\nconsole.log(await getStdin());\n//=> 'unicorns'\n```\n\nRun the script with piped input:\n\n```\n$ echo unicorns | node example.js\nunicorns\n```\n\nOr run interactively by allowing TTY input and type input, then press Ctrl+D (Unix) or Ctrl+Z (Windows) to signal end of input:\n\n```js\n// example.js\nimport getStdin from 'get-stdin';\n\nconsole.log(await getStdin({allowTTY: true}));\n//=> 'unicorns'\n```\n\n```\n$ node example.js\nunicorns\n<Ctrl+D>\nunicorns\n```\n\n## API\n\nBoth methods return a promise that is resolved when the `end` event fires on the `stdin` stream, indicating that there is no more data to be read.\n\nBy default, in a TTY context the promise resolves with an empty string or `Uint8Array`. This avoids hanging CLIs that only want piped input and lets them fall back to other input methods. An empty string or `Uint8Array` means no input was read. To read from a TTY, set `allowTTY: true` and explicitly close `stdin` (Ctrl+D on Unix, Ctrl+Z on Windows).\n\n### getStdin(options?)\n\nGet `stdin` as a `string`.\n\n#### options\n\nType: `object`\n\n##### allowTTY\n\nType: `boolean`\\\nDefault: `false`\n\nAllow reading from a TTY.\n\nUse this when you want interactive behavior like `cat` or other Unix filters that wait for EOF even without piped input. The default resolves immediately in a TTY to avoid hanging CLIs that only want piped input and lets them fall back to other input methods.\n\n##### stdin\n\nType: `Readable stream`\\\nDefault: `process.stdin`\n\nStream to read from.\n\nUseful for tests or to read from a custom stream.\n\n### getStdin.buffer(options?)\n\nGet `stdin` as a `Uint8Array`.\n\n#### options\n\nType: `object`\n\n##### allowTTY\n\nType: `boolean`\\\nDefault: `false`\n\nAllow reading from a TTY.\n\nUse this when you want interactive behavior like `cat` or other Unix filters that wait for EOF even without piped input. The default resolves immediately in a TTY to avoid hanging CLIs that only want piped input and lets them fall back to other input methods.\n\n##### stdin\n\nType: `Readable stream`\\\nDefault: `process.stdin`\n\nStream to read from.\n\nUseful for tests or to read from a custom stream.\n\n## Tip\n\nYou can now accomplish this natively in Node.js using [`streamConsumers.text()`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) or [`streamConsumers.buffer()`](https://nodejs.org/api/webstreams.html#streamconsumersbufferstream):\n\n```js\n// example.js\nimport {text} from 'node:stream/consumers';\n\nconsole.log(await text(process.stdin))\n//=> 'unicorns'\n````\n\n```\n$ echo unicorns | node example.js\nunicorns\n```\n\n## Related\n\n- [get-stream](https://github.com/sindresorhus/get-stream) - Get a stream as a string or buffer\n","publish_time":1770282680861,"_cnpm_publish_time":1770282680861,"dist-tags":{"latest":"10.0.0"}}