{"name":"fx","version":"0.0.1","keywords":["fx","utility"],"author":{"name":"Anton Medvedev","email":"anton@medv.io"},"license":"MIT","_id":"fx@0.0.1","maintainers":[{"name":"medv","email":"anton@medv.io"}],"homepage":"https://github.com/elfet/fx#readme","bugs":{"url":"https://github.com/elfet/fx/issues"},"dist":{"shasum":"ca38eb669b89d5824059e7a545a8bec0abd1760a","tarball":"http://registry-npm.ywwl.com/fx/download/fx-0.0.1.tgz","integrity":"sha512-Sdi688zdUmpGkj0IA571SP44Pc2Oo550jV+yVW3D2GeWbQaXeRH4pnahGu+zGljyBUh28NmS3IMIZ7dcwPEZTw==","signatures":[{"sig":"MEUCIQCzABYyJ8oKTEq24rfb51RZT/b1lKMlGFq/9ZoO1UrPcAIgEwWxFMmHmcQD6YGWAvmAelMDiKigcPVxdUK2BNZQrB4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":12510,"noattachment":false,"key":"/fx/-/fx-0.0.1.tgz"},"main":"fx.js","_from":".","babel":{"presets":["es2015"]},"_shasum":"ca38eb669b89d5824059e7a545a8bec0abd1760a","engines":{"node":">=6.0"},"gitHead":"a07d2108439d56edf0f2f18a44260e1e961343c0","scripts":{"test":"rollup test.js | node","build":"bin/build.sh"},"_npmUser":{"name":"medv","email":"anton@medv.io"},"repository":{"url":"git+https://github.com/elfet/fx.git","type":"git"},"_npmVersion":"3.10.3","description":"Fx is a JavaScript utility library for ES6","directories":{},"_nodeVersion":"6.4.0","devDependencies":{"rollup":"^0.34.13","webpack":"^1.13.2","babel-cli":"^6.14.0","uglify-js":"^2.7.3","babel-preset-es2015":"^6.14.0","regenerator-runtime":"^0.9.5"},"_npmOperationalInternal":{"tmp":"tmp/fx-0.0.1.tgz_1472967280557_0.3088591939304024","host":"packages-12-west.internal.npmjs.com"},"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":1472967280808,"_cnpm_publish_time":1472967280808,"dist-tags":{"latest":"40.0.1"}}