jstdin
v0.11.2
Published
a better `node -p` that accepts stdin and can format and highlight output
Downloads
5
Maintainers
Readme
jstdin
a better
node -p
that accepts stdin and can format and highlight output
FYI
jstdin
works really well in conjunction with lbl
(a line-by-line stdin parser, sort of like AWK, but 100% JS)
Installation
$ npm install jstdin --global
Usage
$ jstdin --help
Usage:
$ jstdin [code] [options]
Description:
executes javascript on the command line like `node -p`
but also accepts data via stdin so long as [code] is wrapped
with an anonymous function; it also formats output.
Options:
-r, --raw prevent formatting output
-h, --help show this usage information
Examples:
# eval and print js (like node -p)
$ jstdin '2*2'
4
# use stdin, process and pretty print
$ echo '[1,2,3]' | jstdin 'x => x.map(x => x*2)'
[
2,
4,
6
]
# use stdin, process and do not pretty print
$ echo '[1,2,3]' | jstdin 'x => x.map(x => x*2)' --raw
[2,4,6]
# use stdin and just pretty print
$ echo '[{"n":1,"a":{"b":"c"}},{"n":2,"a":{"d":{"e":"f"}}}]' | jstdin'
[
{
"n": 1,
"a": {
"b": "c"
}
},
{
"n": 2,
"a": {
"d": "e"
}
}
]
Inspiration:
License
ISC © Buster Collings