stdins - standard input string or buffer
process's standard input "stdin" with a string or a buffer.
$ npm install stdins --save
or
$ npm i stdins -S
require('stdins');
// and use global variable "stdins" or "stdinbuf".
$ 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))"
require('stdins');
stdins(str => console.log(str));
// or
stdinbuf(buf => console.log(buf.toString()));
stdins
is function, thunk, callable with callback.
callback's first argument receives a string.
stdins(str => console.log(str));
callback's first argument receives an error, and second argument receives a string.
stdins((err, str) => err ?
console.error(err) :
console.log(str));
stdins
is promise, thenable.
resolved with a string.
stdins.then(
str => console.log(str),
err => console.error(err));
stdins
is function, thunk, callable with callback.
callback's first argument receives a buffer.
stdins.buf(buf => console.log(buf.toString()));
stdinbuf(buf => console.log(buf.toString()));
callback's first argument receives an error, and second argument receives a buffer.
stdins.buf((err, buf) => err ?
console.error(err) :
console.log(buf.toString()));
stdinbuf((err, buf) => err ?
console.error(err) :
console.log(buf.toString()));
stdins
is promise, thenable.
resolved with a buffer.
stdins.buf.then(
buf => console.log(buf.toString()),
err => console.error(err));
stdinbuf.then(
buf => console.log(buf.toString()),
err => console.error(err));
MIT