{"name":"fx","version":"20.0.2","keywords":["json","viewer","cli","terminal","term","console","ascii","unicode","blessed"],"author":{"name":"Anton Medvedev","email":"anton@medv.io"},"license":"MIT","_id":"fx@20.0.2","maintainers":[{"name":"medv","email":"anton@medv.io"}],"homepage":"https://fx.wtf","bugs":{"url":"https://github.com/antonmedv/fx/issues"},"bin":{"fx":"index.js"},"dist":{"shasum":"320407340bd711a1270425b16065bb4b78b61deb","tarball":"http://registry-npm.ywwl.com/fx/download/fx-20.0.2.tgz","fileCount":13,"integrity":"sha512-BgZNylpsDf5V0c4DwjWnre2dld9YbEbdNUnXzOC2WJv4R/AnJG8cu7mBERhkqxue3S3hgmJr3lqoqeKb2PedGQ==","signatures":[{"sig":"MEQCIHWJhIzGqs46/OkU82rIlTmlOL51fIkyHxId6pSBchvAAiBakLEXcOFb7xdKrf/6f8d+CkeXenFzZV1pXsdVcllvzg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37877,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfYIGfCRA9TVsSAnZWagAArXsP/33+BkJJrnSvm7SZi0pf\nVYhwsdaeaRH92mjJqLV5q77yXuutbHoJpAR84EUaOxFXI2pljjKdI2qaeHMk\nuwGEwmpwPeMaqjXY0M4OCSAIyQ0+7A8M0cpto58GQ+Y6WJe/6NPeMspYHAcq\nZJtvUGqtwoa9OhKgEy9xKJwknijxPbN4EjRMn+viz/WdVWjCv9CD4W54s/k8\nRIRa9D+tEvpfT8TeuucMl1ZvcmtwQ/hbOlr25irbzGQnJXgecQnlhcyAK6bj\nV8qzNpHEP0xSNbVD8IzPGp25vq6Ipps3tbimjYiIxGIHrV0z15EBA7T+Zfg9\n89FoIFWPkY6CAL+9lRJujCdv1udiyXRYfiTuA/ra9N+IPBzpgdH0ySmDLSH6\nCmxRdhV7vBxlKYPT2sCGZ2cAld7FPpKzo+GeOW5+9qfhtt27QglkHQev+jId\n8HtHNe8RkNwqoi+tMRZL0KUXascvwr56yVtfV3FocA05VYxA3DV7jEqxpy3y\n5khaDZHlyYojI3PiZ2nPCnYc3CZvu7Z+rQIOB86vnnU504UbcSirDgoyLq39\nUOwI/uTl23ttKIjDtvzOootDitL8rYnrfNbQCLfrNbXXDyxeKuqhV+t0kpjn\nzVO5z7J4zAcPzmRWcJpXGTses//5A1GC1F/yEpsBjkb33zMxOFgk0c2k54Qr\nHXup\r\n=ZHaa\r\n-----END PGP SIGNATURE-----\r\n","size":11648,"noattachment":false,"key":"/fx/-/fx-20.0.2.tgz"},"engines":{"node":">=8"},"gitHead":"043208a748608dad5532676c967e56f365294c4a","scripts":{"zip":"cd dist && find . -name 'fx-*' -exec zip '{}.zip' '{}' \\;","test":"ava","build":"pkg . --out-path dist","release":"release-it --github.release --github.assets=dist/*.zip","brew:release":"brew bump-formula-pr --url=https://registry.npmjs.org/fx/-/fx-`fx package.json .version`.tgz --no-audit fx"},"_npmUser":{"name":"medv","email":"anton@medv.io"},"release-it":{"hooks":{"after:bump":"rm -rf ./dist && npm run build && npm run zip"}},"repository":{"url":"git+https://github.com/antonmedv/fx.git","type":"git"},"_npmVersion":"6.14.8","description":"Command-line JSON viewer","directories":{},"_nodeVersion":"14.4.0","dependencies":{"chalk":"^4.1.0","string-width":"^4.2.0","@medv/blessed":"^2.0.1","indent-string":"^4.0.0","lossless-json":"^1.0.4"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.12.1","pkg":"^4.4.9","release-it":"^14.0.1"},"_npmOperationalInternal":{"tmp":"tmp/fx_20.0.2_1600160159381_0.6620582816979506","host":"s3://npm-registry-packages"},"readme":"# fx\n\nA non-interactive, JavaScript version of the [**fx**](https://fx.wtf). \nShort for _Function eXecution_ or _f(x)_.\n\n```sh\nnpm i -g fx\n```\n\nOr use **npx**:\n\n```sh\ncat file.json | npx fx .field\n```\n\nOr use **deno**:\n\n```sh\ncat file.json | deno run -A npm:fx .field\n```\n\n## Usage\n\nFx treats arguments as JavaScript functions. Fx passes the input data to the first\nfunction and then passes the result of the first function to the second function \nand so on.\n\n```sh\necho '{\"name\": \"world\"}' | fx 'x => x.name' 'x => `Hello, ${x}!`'\n```\n\nUse `this` to access the input data. Use `.` at the start of the expression to \naccess the input data without a `x => x` part.\n\n```sh\necho '{\"name\": \"world\"}' | fx '.name' '`Hello, ${this}!`'\n```\n\nUse other JS functions to process the data.\n\n```sh\necho '{\"name\": \"world\"}' | fx 'Object.keys'\n```\n\n### Stream processing\n\nFx can process a stream of json objects. Fx will apply arguments to each object.\n\n```sh\necho '{\"name\": \"hello\"}\\n{\"name\": \"world\"}' | fx '.name'\n```\n\nIf you want to process a stream of json objects as a single array, \nuse the **--slurp** or **-s** flag.\n\n```sh\necho '{\"name\": \"hello\"}\\n{\"name\": \"world\"}' | fx --slurp '.map(x => x.name)' '.join(\", \")'\n```\n\n### Raw input\n\nIf you want to process non-JSON data, use the **--raw** or **-r** flag.\n\n```sh\nls | fx -r '[this, this.includes(\".md\")]'\n```\n\nYou can use **--raw** and **--slurp** (or **-rs**) together to get a single array of strings.\n\n```sh\nls | fx -rs '.filter(x => x.includes(\".md\"))'\n```\n\nFx has a special symbol **skip** for skipping the printing of the result.\n\n```sh\nls | fx -r '.includes(\".md\") ? this : skip'\n```\n\n### Built-in functions\n\nFx comes with a set of useful functions: **uniq**, **sort**, **groupBy**, **chunk**, **zip**.\n\n```sh\ncat file.json | fx 'uniq' 'sort' 'groupBy(x => x.name)'\n```\n\n### Edit-in-place\n\nYou can use special function **save** to edit-in-place the input data.\n\n```sh\nfx file.json 'x.name = x.name.toUpperCase(), x' 'save'\n```\n\nThe edited data will be saved to the same `file.json` file.\n\n### Syntactic Sugar\n\nPrefix an expression with `@` to apply it to each item of an array. For example,\n`.map(x => x.commit.message)` can be written as `@.commit.message`.\n\n```sh\ncurl https://api.github.com/repos/antonmedv/fx/commits | fx '@.commit.message'\n```\n\n```sh\necho '[{\"name\": \"world\"}]' | fx '@`Hello, ${x.name}!`'\n```\n\nFx has a special syntax for the flatMap function. Fox example,\n`.issues.flatMap(x => x.labels.flatMap(x => x))` can be rewritten in the next way.\n\n```sh\ncurl https://fx.wtf/example.json | fx '.issues[].labels[]'\n```\n\n### .fxrc.js\n\nFx supports `.fxrc.js` file in the current directory, or in the home directory, or in XDG config directory.\n\nPut the next code in the `.fxrc.js` file to make `myFunction` available in the fx.\n\n```js\nfunction addOne(x) {\n  return x + 1\n}\n```\n\nNow you can use `addOne` in the fx.\n\n```sh\necho '1' | fx addOne\n```\n\nIf you would like to create global variables use `var` instead of `let` or `const`.\n\n## License\n\n[MIT](../LICENSE)\n","publish_time":1600160159498,"_cnpm_publish_time":1600160159498,"dist-tags":{"latest":"40.0.1"}}