stdins - standard input string or buffer
process's standard input "stdin" with a string or a buffer.
Prepare
$ npm install stdins --save or$ npm i stdins -S
;// and use global variable "stdins" or "stdinbuf".
Usage
$ echo abc | node -r stdins -e "stdins(str => console.log(str))" or$ echo abc | node -r stdins -e "stdins.then(str => console.log(str), err => console.error(err))"$ echo abc | node -r stdins -e "stdins((err, str) => console.log(str, err))"$ echo abc | node -r stdins -e "stdinbuf(buf => console.log(buf + ''))"$ echo abc | node -r stdins -e "stdinbuf.then(buf => console.log(buf + ''), err => console.error(err))"$ echo abc | node -r stdins -e "stdinbuf((err, buf) => console.log(buf + '', err))"
; ;// or;
Quick Examples
stdins()
async thunk with string
stdins
is function, thunk, callable with callback.
callback's first argument receives a string.
;
callback's first argument receives an error, and second argument receives a string.
;
stdins.then()
async promise with string
stdins
is promise, thenable.
resolved with a string.
stdins;
stdinbuf()
async thunk with buffer
stdins
is function, thunk, callable with callback.
callback's first argument receives a buffer.
stdins;
;
callback's first argument receives an error, and second argument receives a buffer.
stdins;
;
stdinbuf.then()
async promise with buffer
stdins
is promise, thenable.
resolved with a buffer.
stdinsbuf;
stdinbuf;
License
MIT