{"name":"fx","version":"3.0.2","keywords":["json","cli"],"author":{"name":"Anton Medvedev","email":"anton@medv.io"},"license":"MIT","_id":"fx@3.0.2","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"},"pkg":{"scripts":"node_modules/neo-blessed/lib/**/*.js"},"dist":{"shasum":"27e32f273d5c14e4c633ed524186ad04e8408001","tarball":"http://registry-npm.ywwl.com/fx/download/fx-3.0.2.tgz","fileCount":5,"integrity":"sha512-lv7JeqLH6/iIzixtSTnbpjPpHkWQaq9dhHpSK/DI9FjizPqkdoP1Nl+NjXzSbdG6M+2v3FxeWTOiCaTahShXlA==","signatures":[{"sig":"MEUCIEsjJateAkwH8Ry6O9v7//W3fcDOjCYp8DzCUG7JuVGBAiEAw0r8Iyb4YvDOxANpQD5zSQ6FgHwyq3u4DI1YHGtbMok=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13262,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb3b9PCRA9TVsSAnZWagAAbXAP/2Kz2+fdr5MfUrn+casS\n7z09kMGFHuzk1I2JQqL+NQJQcC1ZHvH+XzXlt4eSQBTJbzY4nkSrkJj9a6Op\nDPSv/Z3JjnOe+YSzefLWgcUn8lllqUYdhSGqAOHq/Q1TdN0ds1uCYByuh1lM\nUBMbA8Wz9S0zpTuExlp7VGBhObp3S1U1aEFl1GBjn7UhtPFCFmHdHwp2BOuX\n5SIF6pY2Vcq57M+CGCaBN7J0S5yIzsyrI19Y+6G/qmt+k4akxX7HDDJiW2kJ\n8zDSuGHwfpADmCvtGqeuO3ew5Y8g01xbuSEoIQRskL5NiDgrN9asYLZUG6OC\ntqraaGGeoM8VjhPwhHxTJ6n2z/MyWyUen6/6RIlBA+TXUiuj53WC38A25ggB\nn30dVLR4PVD4HZPQG+CQ72xz5wxeeKBbtn4Gv/vJ2Yoo19koIoQ/4fna/g/v\n8YwCsJ7x7jHvIvzBtUcMIkm1ocfXYQHlcQ3Q4sF3LFEXbKgvxa3Q2GNZSvjR\n+FCGSLcIJbugjlUrEn3pLLLuplUubLldYHMwTx1ViPrp/75aTScjRmGr49dE\noKDOyAiADxtEjoypFCE9YlYgOe+tKeSkSSBz2zfpo04ew8a5eNvBF+s+2IGF\nj7/RX839T45L0PmfHKqO/4QF2eagWosufuH4ksu2Nl5eZ6HGoGEboKETgFC7\nS6mu\r\n=klWi\r\n-----END PGP SIGNATURE-----\r\n","size":5256,"noattachment":false,"key":"/fx/-/fx-3.0.2.tgz"},"engines":{"node":">=8"},"gitHead":"d77114d23cb9cf10c28ce9267fc3f9e7e45ed588","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.4.1","description":"Command-line JSON processing tool","directories":{},"_nodeVersion":"10.8.0","dependencies":{"chalk":"^2.4.1","neo-blessed":"^0.2.0","string-width":"^2.1.1","indent-string":"^3.2.0","@medv/prettyjson":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^0.25.0","pkg":"^4.3.4","release-it":"^7.6.2"},"_npmOperationalInternal":{"tmp":"tmp/fx_3.0.2_1541259087038_0.09596471810175067","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":1541259087222,"_cnpm_publish_time":1541259087222,"dist-tags":{"latest":"40.0.1"}}