{"name":"fx","version":"26.0.0","author":{"name":"Anton Medvedev","email":"anton@medv.io"},"license":"MIT","_id":"fx@26.0.0","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":"8972b65e99a52408f96be7abc3643920b9aef08b","tarball":"http://registry-npm.ywwl.com/fx/download/fx-26.0.0.tgz","fileCount":3,"integrity":"sha512-xdxZpc6OXcUoem0EDDvtWsnFeYroBYg6v97FuGESKM217sIxpCGnb/MQ+O8m1Jpd4TafWyU+7pT5tNX3TwT44w==","signatures":[{"sig":"MEYCIQDdNOufYLEU20UQiJmicf1S22V7EzCy5DVqdrcovr0ciQIhAK7l0a0APkpvHcc+ZcpdfuczeR88pHSodeRb2u6hSXmt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5312,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkNnPAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq81g/9EkK0f2tCJWA4LVH1EGNp+FIEDqqgcm7QkIBm7GNrtHyeT9Iz\r\n4XlUGY5Gyq7c1R4xE6N5mDkst3ODnvvT+dYYfdSdYfzebrOejdBhRMMG8b+f\r\nzWkTqs+LPA85eaTV/2Q/kKgKeBCi9vpkAt4r8cDS7MosuNfFETPRJd20cPa1\r\nPIu6GIcAgxZHfWlBTWalsXcRxPsmqtz5yasK6RLSuKPtmvXyGPV/DsUqETAf\r\nvaHUO/+w41Io+HwaEC2fUzJyJjtKCk7hvYlWWAK5fcyMR+4c7JYcoCOpB6yw\r\nkd0yi4RIFzyfM+j98tNjvJL1z7OIiMMthn9i6LQEE4k6ZNO8pstnZdWi22Kk\r\nMs3wyXvnHMpIPeJd1td9jh6ToeUY0fOtBl1Los6MT5/edk5Po8CAnUc8oO4n\r\n4rp80OAxWfzjqPeosigsiCmsSA9mgKzbmk4i2T+41vY38sVG86CbhAsP/yof\r\nfiMxMebaFSPQTm6UshsmUCdKV5mCsRI9yD1GIecWUTBsvb/rDfj1hdL/W28a\r\no5jubNOyrLBZEmr31LFpaFFr6J6mD+AQud/OAfBievBpPhJA3HOIpaRaUsMS\r\ngTkUIn6cSNjxY8WjqKyIE3UxTdAEfazx36zewvwpodFNLlItFV7IHGHBXuVQ\r\nmB+aPTRtT4vjvIbTHdsQ5pgKGee0ycJMXcc=\r\n=AOR7\r\n-----END PGP SIGNATURE-----\r\n","size":2275,"noattachment":false,"key":"/fx/-/fx-26.0.0.tgz"},"gitHead":"be7ac90e7a25b639a8f776949ec271aa94883b51","scripts":{"test":"node test.js"},"_npmUser":{"name":"medv","email":"anton@medv.io"},"repository":{"url":"git+https://github.com/antonmedv/fx.git","type":"git"},"_npmVersion":"9.6.2","description":"Command-line JSON viewer","directories":{},"_nodeVersion":"19.8.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/fx_26.0.0_1681290176337_0.5515327114679431","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":1681290176495,"_cnpm_publish_time":1681290176495,"dist-tags":{"latest":"40.0.1"}}