{"author":{"name":"tony_quetano@planttheidea.com"},"browserslist":["defaults","Explorer >= 9","Safari >= 6","Opera >= 15","iOS >= 8","Android >= 4"],"bugs":{"url":"https://github.com/planttheidea/curriable/issues"},"description":"Convert any method to be curriable with placeholder support","devDependencies":{"@types/jest":"^23.3.8","benchmark":"^2.1.4","cli-table":"^0.3.1","cli-table2":"^0.2.0","html-webpack-plugin":"^3.2.0","in-publish":"^2.0.0","jest":"^23.6.0","lodash":"^4.17.10","ora":"^3.0.0","performance-now":"^2.1.0","ramda":"^0.25.0","rollup":"^0.66.6","rollup-plugin-typescript":"^1.0.0","rollup-plugin-uglify":"^6.0.0","ts-jest":"^23.10.4","ts-loader":"^5.2.2","tslint":"^5.11.0","tslint-config-airbnb":"^5.11.0","tslint-loader":"^3.5.4","typescript":"^3.1.3","webpack":"^4.9.1","webpack-cli":"^3.1.2","webpack-dev-server":"^3.1.4"},"keywords":["curry","functional"],"license":"MIT","homepage":"https://github.com/planttheidea/curriable#readme","main":"dist/curriable.js","name":"curriable","repository":{"type":"git","url":"git+https://github.com/planttheidea/curriable.git"},"scripts":{"benchmark":"rimraf dist && npm run build && node ./benchmarks/index.js","build":"NODE_ENV=production rollup -c","clean":"rimraf dist","dev":"NODE_ENV=development webpack-dev-server --progress --colors --config=webpack/webpack.config.js","lint":"NODE_ENV=test tslint 'src/*.ts'","lint:fix":"npm run lint -- --fix","prepublish":"if in-publish; then npm run prepublish:compile; fi","prepublish:compile":"npm run lint && npm run test:coverage && npm run clean && npm run build","start":"npm run dev","test":"NODE_PATH=. jest","test:coverage":"npm run test -- --coverage","test:watch":"npm run test -- --watch"},"sideEffects":false,"types":"index.d.ts","version":"1.2.2","gitHead":"e0801bff5c148c7775ca06fcac74df78bce476f4","_id":"curriable@1.2.2","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"dist":{"integrity":"sha512-gCvU0Hl8EYScI0mPksUiI+kLEV5M9Cva357EWMQGwXI3vc9mBWv7VnqN90YfMhd8tyDuTxakzuZv7lAdPBozow==","shasum":"07529e2d82c7bdcc16469511a65682b0f02c1158","tarball":"http://registry-npm.ywwl.com/curriable/download/curriable-1.2.2.tgz","fileCount":9,"unpackedSize":18617,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb1nh+CRA9TVsSAnZWagAAZtsP/RspS921DBkLABdZUp28\nqFhIAm3D/gkuz+H8UmnmL/843+eRlilYpkPYMqtK0XBXAwzK2qyAKfOJxkOc\n2Fwr3f7uAg+l/zyESuwPVoLif7k6S3XTRvlXILflV6gT3MYrh6LMMrPpz5DT\nAl3pBEzuFqX2SgrcNaWC0n/bS6CipS67AdbGQlPL5rk8o3F/cKfPAbpsBCAU\nbKF63EIqUDXYE0zcAiX+kAox197q4fIlYqnCIrDcl2SUAyKp2jGKXbLby+B/\nO4a+4PAWPcOfhp+fhzgYoHjoJfGNeq3C/v/4+Vv21fmwmOdnleDYFTbjArOZ\nh/5gtwwxtbb9SXJ+n9MUn/rCN+yeMlkI5Ys1zcYOv59QCmykxLHxN6hatjlC\n9SLTnF/mPnBtfb2my1UTO0XI3tEENmnuRX+F5ZRzlyZbjJejxyYO1803GLOL\nnJsHlWRcPhSZXkjvHnq0t+NsXgiv06p9KMPYuVbph+Wme88qnyxxGiujMlm/\nxPYK86NHNURBCG3w3/5+3qvxqIcLbhWpUisSjXMhN3aAtDqmD6GpNhPmiPhX\n8o56IpF+gKtooKZwTYV5J1ucR3sUDRJCUvadEUBCLwbn0gcUsMT0UMgJk6v0\n9QEIxGvgpnQoEK/u0XlGInzKspAq7WhzbluxS6EcnuzLcVP1MuJSLHk0BsEA\n++h0\r\n=y+lU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICny/RJ60HsBIhOJHmukygbW/s3PQh5R0L1bsozcpvR0AiAVu63YPd+9ahlTDaKHHn0IIg2Hx/jjEXlncrkebOKR6A=="}],"size":6505,"noattachment":false,"key":"/curriable/-/curriable-1.2.2.tgz"},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/curriable_1.2.2_1540782205379_0.4397683774416221"},"_hasShrinkwrap":false,"readme":"# curriable\n\nCurry any function with placeholder support\n\n## Table of contents\n\n- [curriable](#curriable)\n  - [Table of contents](#Table-of-contents)\n  - [Summary](#Summary)\n  - [Usage](#Usage)\n    - [API](#API)\n      - [curry](#curry)\n      - [uncurry](#uncurry)\n      - [isPlaceholder](#isPlaceholder)\n    - [Rest parameters](#Rest-parameters)\n    - [Default parameters](#Default-parameters)\n  - [Benchmarks](#Benchmarks)\n    - [Passing each parameter in curried calls](#Passing-each-parameter-in-curried-calls)\n    - [Passing all parameters in one call](#Passing-all-parameters-in-one-call)\n    - [Using placeholder parameters in curried calls](#Using-placeholder-parameters-in-curried-calls)\n  - [Development](#Development)\n\n## Summary\n\n`curriable` provides a `curry` method that is [highly performant](#benchmarks) with a small footprint (_582 bytes minified+gzipped_). You can call the method with any combination of parameters (one at a time, all at once, or any number in between), and placeholders are supported.\n\nIf `fn` is the curried function and `_` is the placeholder value, the following are all equivalent:\n\n- `fn(1)(2)(3)`\n- `fn(1)(2, 3)`\n- `fn(1, 2)(3)`\n- `fn(1, 2, 3)`\n- `fn(_, 2, 3)(1)`\n- `fn(_, _, 3)(1)(2)`\n- `fn(_, _, 3)(1, 2)`\n- `fn(_, 2)(1)(3)`\n- `fn(_, 2)(1, 3)`\n- `fn(_, 2)(_, 3)(1)`\n\n## Usage\n\nYou can use the default import:\n\n```ts\nimport curry from \"curriable\";\n\nconst fn = curry((a, b, c) => [a, b, c]);\n\nconsole.log(fn(\"a\", curry.__, \"c\")(\"b\")); // [\"a\", \"b\", \"c\"]\n\nconst original = curry.uncurry(fn);\n\nconsole.log(original(\"a\")); // [\"a\", undefined, undefined]\n```\n\nOr the named imports:\n\n```ts\nimport { __, curry, uncurry } from \"curriable\";\n\nconst fn = curry((a, b, c) => [a, b, c]);\n\nconsole.log(fn(\"a\", __, \"c\")(\"b\")); // [\"a\", \"b\", \"c\"]\n\nconst original = uncurry(fn);\n\nconsole.log(original(\"a\")); // [\"a\", undefined, undefined]\n```\n\n### API\n\n#### curry\n\nCurry the `fn` provided for any combination of arguments passed, until all required arguments have been passed.\n\n```ts\nimport { curry } from 'curriable';\n\nfunction curry<Fn extends (...args: any[]) => any>(\n    fn: Fn, \n    arity: number = fn.length\n) => Curried<Fn>;\n```\n\n`arity` defaults to be the length provided by `fn.length`, but be aware this can cause unusual behavior with default parameters or use of rest parameters. [See the documentation on Function.length for more details](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length).\n\n#### uncurry\n\n```ts\nimport { uncurry } from 'curriable';\n\nGet the underlying standard method that was curried using `curry`.\n\nfunction uncurry<Fn extends (...args: any[]) => any>(\n    fn: Curried<Fn>\n) => Fn;\n```\n\n#### isPlaceholder\n\n```ts\nimport { isPlaceholder } from 'curriable';\n\nIs the value passed a `curriable` placeholder.\n\nfunction isPlaceholder(value: any): value is Placeholder\n```\n\n### Rest parameters\n\n```ts\nconsole.log((...args) =>{}.length); // 0 arity computed\n```\n\nWhen using rest with curried functions, you should pass a second parameter to explicitly declare the correct `arity`:\n\n```ts\nconst fn = (...args) => [a, b, c];\nconst curried = curry(fn, 3);\n\nconsole.log(curried(\"a\")(\"b\")(\"c\")); // [\"a\", \"b\", \"c\"]\n```\n\n### Default parameters\n\n```ts\nconsole.log(function(a, b = 1, c) {}.length); // 1 arity computed\n```\n\nDefault parameters are very rare use-case with curried functions, but it is possible to trigger them if you declare an explicit `arity` and explicitly pass `undefined` for that parameter:\n\n```ts\nconst fn = (a, b = 1, c) => [a, b, c];\nconst curried = curry(fn, 3);\n\nconsole.log(curried(\"a\")(undefined)(\"c\")); // [\"a\", 1, \"c\"]\n```\n\nYes, this is weird, but it is very difficult (impossible?) to distinguish between a parameter being undefined through not being called yet in the curry chain vs being undefined by not being provided an explicit value. Explicitly passing `undefined` provides that distinction.\n\n## Benchmarks\n\nAll values provided are the number of operations per second (ops/sec) calculated by the [Benchmark suite](https://benchmarkjs.com/). The same function was curried and tested passing each parameter individually, passing all at once, and using placeholders.\n\nBenchmarks were performed on an i7 8-core Arch Linux laptop with 16GB of memory using NodeJS version `10.15.0`.\n\n### Passing each parameter in curried calls\n\n| Library       | Operations / second |\n| ------------- | ------------------- |\n| **curriable** | **4,052,206**       |\n| ramda         | 2,423,105           |\n| lodash        | 241,736             |\n\n### Passing all parameters in one call\n\n| Library       | Operations / second |\n| ------------- | ------------------- |\n| **curriable** | **18,106,685**      |\n| ramda         | 10,718,796          |\n| lodash        | 9,052,257           |\n\n### Using placeholder parameters in curried calls\n\n| Library       | Operations / second |\n| ------------- | ------------------- |\n| **curriable** | **4,821,329**       |\n| ramda         | 2,963,699           |\n| lodash        | 336,687             |\n\n## Development\n\nStandard stuff, clone the repo and `npm install` dependencies. The npm scripts available:\n\n- `benchmark` => run the benchmark suite pitting `curriable` against other libraries in common use-cases\n- `build` => run `rollup` to build `dist` files\n- `clean` => run `rimraf` on the `dist` folder\n- `dev` => run webpack dev server to run example app (playground!)\n- `lint` => runs `tslint` against all files in the `src` folder\n- `lint:fix` => runs `lint`, fixing any errors if possible\n- `prepublishOnly` => run `lint`, `typecheck`, `test:coverage`, `clean`, and `dist`\n- `release` => run `release-it` for standard versions (requires global installation of `release-it`)\n- `release:beta` => run `release-it` for beta versions (requires global installation of `release-it`)\n- `test` => run `jest` test functions\n- `test:coverage` => run `test`, but with coverage checker\n- `test:watch` => run `test`, but with persistent watcher\n- `typecheck` => run `tsc` on all code in `src`\n","publish_time":1540782205619,"_cnpm_publish_time":1540782205619,"dist-tags":{"latest":"2.0.1","next":"1.2.3-0"}}