.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / get-stdin / readme.md
1 # get-stdin [![Build Status](https://travis-ci.org/sindresorhus/get-stdin.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stdin)
2
3 > Get [stdin](https://nodejs.org/api/process.html#process_process_stdin) as a string or buffer
4
5
6 ## Install
7
8 ```
9 $ npm install --save get-stdin
10 ```
11
12
13 ## Usage
14
15 ```js
16 // example.js
17 const getStdin = require('get-stdin');
18
19 getStdin().then(str => {
20         console.log(str);
21         //=> 'unicorns'
22 });
23 ```
24
25 ```
26 $ echo unicorns | node example.js
27 unicorns
28 ```
29
30
31 ## API
32
33 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.
34
35 ### getStdin()
36
37 Get `stdin` as a string.
38
39 In a TTY context, a promise that resolves to an empty string is returned.
40
41 ### getStdin.buffer()
42
43 Get `stdin` as a buffer.
44
45 In a TTY context, a promise that resolves to an empty buffer is returned.
46
47
48 ## Related
49
50 - [get-stream](https://github.com/sindresorhus/get-stream) - Get a stream as a string or buffer
51
52
53 ## License
54
55 MIT © [Sindre Sorhus](http://sindresorhus.com)