{"author":{"name":"tony_quetano@planttheidea.com"},"browser":"dist/curriable.js","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":"^24.0.15","benchee":"^1.1.0","cli-table":"^0.3.1","cli-table2":"^0.2.0","html-webpack-plugin":"^3.2.0","jest":"^24.8.0","lodash":"^4.17.10","ora":"^3.4.0","performance-now":"^2.1.0","ramda":"^0.26.1","rollup":"^1.16.6","rollup-plugin-terser":"^5.1.1","rollup-plugin-typescript2":"^0.21.2","ts-jest":"^24.0.2","ts-loader":"^6.0.4","tslint":"^5.18.0","tslint-config-airbnb":"^5.11.0","tslint-loader":"^3.5.4","typescript":"^3.5.2","webpack":"^4.35.2","webpack-cli":"^3.3.5","webpack-dev-server":"^3.7.2"},"keywords":["curry","functional"],"license":"MIT","homepage":"https://github.com/planttheidea/curriable#readme","main":"dist/curriable.cjs.js","module":"dist/curriable.esm.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","prepublishOnly":"npm run lint && npm run typecheck && npm run test:coverage && npm run clean && npm run build","release":"release-it","release:beta":"release-it --config=.release-it.beta.json","start":"npm run dev","test":"NODE_PATH=. jest","test:coverage":"npm run test -- --coverage","test:watch":"npm run test -- --watch","typecheck":"tsc --noEmit"},"sideEffects":false,"types":"index.d.ts","version":"1.3.0","gitHead":"ea3f01a19609131c75f9eb39c18e93278f2bb351","_id":"curriable@1.3.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.2","dist":{"integrity":"sha512-7kfjDPRSF+pguU0TlfSFBMCd8XlmF29ZAiXcq/zaN4LhZvWdvV0Y72AvaWFqInXZG9Yg1kA1UMkpE9lFBKMpQA==","shasum":"cb054bc7bbc1f440cbc613527b8a05b57e19e1ab","tarball":"http://registry-npm.ywwl.com/curriable/download/curriable-1.3.0.tgz","fileCount":15,"unpackedSize":38329,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdI1FlCRA9TVsSAnZWagAAjBAQAJwp1lt5azlE92hWm1Ef\n6FIlHVDeTniCURaQJ4nxfzW3DPsdOFQJvyLFSxnZl7wLJAVdh1RzL6HBrJzB\nQmshBakauRgHExtoiHCDwByypiS3wSCQxI4oIFE0CInqdBgT6BMZwMXqXIx+\nwgkmIcwp2tPBKcGDNMz8kmzrHtZKYNL3tlmuKCFGMmfcKLt3eObCprK+4gbg\n6iHlZ+SLs4KNMQKWKxmhMGZ8eNDrvRsgpGlyGug3oOV4eHZVbM2xqipfAtxt\nf6p6F37Ww8QHUBff2Xg6zj1prJwIBtPpQLNDY4aIN3VoSjMDsvaE1jt/oGce\ncS195MoYpOnSDM5mnLg7nSfTNxv0+Ng792eIDIdcsl9EWrZ20LOkhCi9OzNc\n8q088Y4RYDyDihqM+bYzIWS4OVLsI/trwI1Nd5NF8EI+FjWzi2GqSZNi7S6H\njvDDKMIer9qdzdg416ZTpgrEFPL0WfXtJ501D/Jmn6DNq9dbgwQ/O0eBH04l\nTKxty/AbnE77wfX0ELq3XwpKgJ1K3CEwMVls5bSSLPCetXS/lrjMkD9TMHh7\nN9um0e6cK2aITkguihQ6Hz8T5f+OozTwGOeDyTSl6wT7uHyzh8NqeG4SXx+M\no/6jf1St1okvtVTgDKs+rSiI3/hdhYta1PudShwtWq6u/Z6nzhzS8/zOwQG1\n6AIK\r\n=wrgv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID7z8H2PHSBmJuj9XKUBHPOpv4qNZUstEIyXYugi5iXJAiEA3Zbp4n4/5s8KBlzoLUcsOUgVun0Ks5GxDUD0ZERtdQs="}],"size":8577,"noattachment":false,"key":"/curriable/-/curriable-1.3.0.tgz"},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/curriable_1.3.0_1562595684255_0.0465029678390938"},"_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":1562595684402,"_cnpm_publish_time":1562595684402,"dist-tags":{"latest":"2.0.1","next":"1.2.3-0"}}