{"name":"fx","version":"1.1.1","keywords":["json","cli"],"author":{"name":"Anton Medvedev","email":"anton@medv.io"},"license":"MIT","_id":"fx@1.1.1","maintainers":[{"name":"medv","email":"anton@medv.io"}],"homepage":"https://github.com/antonmedv/fx#readme","bugs":{"url":"https://github.com/antonmedv/fx/issues"},"bin":{"fx":"index.js"},"dist":{"shasum":"6483255865f9bedb3a864f36d6843c064da36321","tarball":"http://registry-npm.ywwl.com/fx/download/fx-1.1.1.tgz","fileCount":4,"integrity":"sha512-QaPeaWeCLPRJmlon7xEAFXX5Tkn2AfK1afkNk/oNcrfZNasAdspiLJ1VtLUMz5WsTehQlAWBIfGNvPBBfv22tQ==","signatures":[{"sig":"MEYCIQDcI94YGpELJHE51kn2UnDe9Q6NIXZ0KpFYJekovoNIPQIhAM3p6ZHRYstCZYvFiBFJ3WzBPRIpdJbB0Y2kWjHbDG3B","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6192,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbMlWNCRA9TVsSAnZWagAA7QoP/1YjOaFPKX8Tkz3ToNcq\nauHYa5k6AEvUtmAN8VZHaIwrf1A6gYMrrN9MRnfoT3a2wgNr7pXy/eVMGqLf\nxfbfT3uWJx8Ium4bEsAwLCw5+Jd/ePElpB8JRTQLQ7CQ4qOtm5zaIOsilMkJ\nnHfCUY+etUfdsrCy4gqsKrcKpk7DSzDb+71SFNVXBUbcHn56tN9rESNrXsfW\nsUdK5V30JsMi2oCt5o8x+qJlbvdFsZ6LpOejmSCrYtO4hYmVVr5rBMmdPoVb\nwOej/QddShw58D2h6KZnTQAXEfkygl+ShkkBbjPddshQoLeOwlWcXxJWlMU1\nv2zCfut9BEfgB/pJ0SbUdOh12iqvaBIqfxhWXRzccZ6To8KW+W/pu5FP4uZv\nEldYe65vBdnRTDW+GnCIby3/WIhQcxIz9HxVtcMsskzjqQ3QTocjBTd3T6MC\ndW5VcY1tPpEqqpili/D8gM/7IP8Nmlm8vpA67XTKwKpSUlfTXb8SzvGmEKyr\nLkYD7U2UJfzSF6tWdByzHCKfTpCTp2i0p0kfI+9afKI3a5NQv6gP63TOig5A\nfgUpPgImsz+gEp2pfEy8GtIBOCKr+gMeY2ZwKkzsoTh0kdwqzaHy4Z6/Diw/\n/4QVxlO6au9NiRVZSRF7qgEvLS8syc5S9CZlvlH14H3Eq2SYJZ5f/qzqOhr2\nykIJ\r\n=JS2v\r\n-----END PGP SIGNATURE-----\r\n","size":3035,"noattachment":false,"key":"/fx/-/fx-1.1.1.tgz"},"files":["index.js"],"engines":{"node":">=8"},"gitHead":"17b30f2622cd51e29c8596334f29a9e343e32a6f","scripts":{"test":"ava","release":"pkg . --out-path dist && release-it --github.release --github.assets=dist/*"},"_npmUser":{"name":"medv","email":"anton@medv.io"},"repository":{"url":"git+https://github.com/antonmedv/fx.git","type":"git"},"_npmVersion":"6.1.0","description":"Command-line JSON processing tool","directories":{},"_nodeVersion":"10.2.1","dependencies":{"meow":"^5.0.0","get-stdin":"^6.0.0","@medv/prettyjson":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^0.25.0","pkg":"^4.3.3","release-it":"^7.4.7"},"_npmOperationalInternal":{"tmp":"tmp/fx_1.1.1_1530025357388_0.539870724099855","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":1530025357492,"_cnpm_publish_time":1530025357492,"dist-tags":{"latest":"40.0.1"}}