https://github.com/busterc/jstdin
:heavy_dollar_sign: a better `node -p` that accepts stdin and can format and highlight output
https://github.com/busterc/jstdin
cli eval javascript jq js json json-parser node node-js node-repl nodejs npx pretty-print stdin
Last synced: 3 months ago
JSON representation
:heavy_dollar_sign: a better `node -p` that accepts stdin and can format and highlight output
- Host: GitHub
- URL: https://github.com/busterc/jstdin
- Owner: busterc
- License: isc
- Created: 2018-02-20T18:04:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T08:47:28.000Z (over 5 years ago)
- Last Synced: 2024-10-31T18:05:56.127Z (12 months ago)
- Topics: cli, eval, javascript, jq, js, json, json-parser, node, node-js, node-repl, nodejs, npx, pretty-print, stdin
- Language: JavaScript
- Size: 4.17 MB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jstdin [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
> a better `node -p` that accepts stdin and can format and highlight output
### FYI
`jstdin` works really well in conjunction with [`lbl`](https://github.com/busterc/lbl) (a line-by-line stdin parser, sort of like AWK, but 100% JS)
## Installation
```sh
$ npm install jstdin --global
```## Usage
```sh
$ jstdin --helpUsage:
$ 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 informationExamples:
# 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:
- [`js`](https://www.npmjs.com/package/js)
- [`jq`](https://www.npmjs.com/package/node-jq)
- [`jq.node`](https://www.npmjs.com/package/jq.node)
- [`fx`](https://www.npmjs.com/package/fx)## License
ISC © [Buster Collings](https://about.me/buster)
[npm-image]: https://badge.fury.io/js/jstdin.svg
[npm-url]: https://npmjs.org/package/jstdin
[travis-image]: https://travis-ci.org/busterc/jstdin.svg?branch=master
[travis-url]: https://travis-ci.org/busterc/jstdin
[daviddm-image]: https://david-dm.org/busterc/jstdin.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/busterc/jstdin
[coveralls-image]: https://coveralls.io/repos/busterc/jstdin/badge.svg
[coveralls-url]: https://coveralls.io/r/busterc/jstdin
[greenkeeper-image]: https://badges.greenkeeper.io/busterc/jstdin.svg
[greenkeeper-url]: https://greenkeeper.io/