From b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Mon, 24 Nov 2025 20:54:57 +0100 Subject: Docs --- node_modules/get-stdin/index.d.ts | 29 +++++++++++++++++++ node_modules/get-stdin/index.js | 33 ++++++++++++++++++++++ node_modules/get-stdin/license | 9 ++++++ node_modules/get-stdin/package.json | 42 ++++++++++++++++++++++++++++ node_modules/get-stdin/readme.md | 56 +++++++++++++++++++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 node_modules/get-stdin/index.d.ts create mode 100644 node_modules/get-stdin/index.js create mode 100644 node_modules/get-stdin/license create mode 100644 node_modules/get-stdin/package.json create mode 100644 node_modules/get-stdin/readme.md (limited to 'node_modules/get-stdin') diff --git a/node_modules/get-stdin/index.d.ts b/node_modules/get-stdin/index.d.ts new file mode 100644 index 0000000..c2a0605 --- /dev/null +++ b/node_modules/get-stdin/index.d.ts @@ -0,0 +1,29 @@ +declare const getStdin: { + /** + Get [`stdin`](https://nodejs.org/api/process.html#process_process_stdin) as a `string`. + + @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. + + @example + ``` + // example.ts + import getStdin from 'get-stdin'; + + console.log(await getStdin()); + //=> 'unicorns' + + // $ echo unicorns | ts-node example.ts + // unicorns + ``` + */ + (): Promise; + + /** + Get [`stdin`](https://nodejs.org/api/process.html#process_process_stdin) as a `Buffer`. + + @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. + */ + buffer(): Promise; +}; + +export default getStdin; diff --git a/node_modules/get-stdin/index.js b/node_modules/get-stdin/index.js new file mode 100644 index 0000000..e8182da --- /dev/null +++ b/node_modules/get-stdin/index.js @@ -0,0 +1,33 @@ +const {stdin} = process; + +export default async function getStdin() { + let result = ''; + + if (stdin.isTTY) { + return result; + } + + stdin.setEncoding('utf8'); + + for await (const chunk of stdin) { + result += chunk; + } + + return result; +} + +getStdin.buffer = async () => { + const result = []; + let length = 0; + + if (stdin.isTTY) { + return Buffer.concat([]); + } + + for await (const chunk of stdin) { + result.push(chunk); + length += chunk.length; + } + + return Buffer.concat(result, length); +}; diff --git a/node_modules/get-stdin/license b/node_modules/get-stdin/license new file mode 100644 index 0000000..fa7ceba --- /dev/null +++ b/node_modules/get-stdin/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/get-stdin/package.json b/node_modules/get-stdin/package.json new file mode 100644 index 0000000..bd758aa --- /dev/null +++ b/node_modules/get-stdin/package.json @@ -0,0 +1,42 @@ +{ + "name": "get-stdin", + "version": "9.0.0", + "description": "Get stdin as a string or buffer", + "license": "MIT", + "repository": "sindresorhus/get-stdin", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "type": "module", + "exports": "./index.js", + "engines": { + "node": ">=12" + }, + "scripts": { + "test": "xo && ava test.js test-buffer.js && echo unicorns | node test-real.js && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "std", + "stdin", + "stdio", + "concat", + "buffer", + "stream", + "process", + "read" + ], + "devDependencies": { + "@types/node": "^14.14.41", + "ava": "^3.15.0", + "delay": "^5.0.0", + "tsd": "^0.14.0", + "xo": "^0.38.2" + } +} diff --git a/node_modules/get-stdin/readme.md b/node_modules/get-stdin/readme.md new file mode 100644 index 0000000..ede347a --- /dev/null +++ b/node_modules/get-stdin/readme.md @@ -0,0 +1,56 @@ +# get-stdin + +> Get [stdin](https://nodejs.org/api/process.html#process_process_stdin) as a string or buffer + +## Install + +``` +$ npm install get-stdin +``` + +## Usage + +```js +// example.js +import getStdin from 'get-stdin'; + +console.log(await getStdin()); +//=> 'unicorns' +``` + +``` +$ echo unicorns | node example.js +unicorns +``` + +## API + +Both methods 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. + +### getStdin() + +Get `stdin` as a `string`. + +In a TTY context, a promise that resolves to an empty `string` is returned. + +### getStdin.buffer() + +Get `stdin` as a `Buffer`. + +In a TTY context, a promise that resolves to an empty `Buffer` is returned. + +## Related + +- [get-stream](https://github.com/sindresorhus/get-stream) - Get a stream as a string or buffer + +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
-- cgit v1.2.3