jstdin

    0.11.2 • Public • Published

    jstdin NPM version Build Status Dependency Status Coverage percentage Greenkeeper badge

    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

    Install

    npm i jstdin

    DownloadsWeekly Downloads

    9

    Version

    0.11.2

    License

    ISC

    Unpacked Size

    10.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar