{"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":"^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-babel-minify":"^6.2.0","rollup-plugin-typescript2":"^0.18.1","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.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","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.3-0","readme":"# curriable\n\nCurry any function with placeholder support\n\n## Table of contents\n\n- [Summary](#summary)\n- [Usage](#usage)\n  - [Signature](#signature)\n  - [Rest parameters](#rest-parameters)\n  - [Default parameters](#default-parameters)\n  - [uncurry](#uncurry)\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 (_473 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```javascript\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```javascript\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#### Signature\n\nThe `curry` method has the following signature:\n\n```javascript\nfunction curry(fn: function, arity: number = fn.length) => function;\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#### Rest parameters\n\n```javascript\nconsole.log(function(...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```javascript\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```javascript\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```javascript\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#### uncurry\n\nThe function `uncurry` is also available on both the default export and as a named export, and this function will return the original (uncurried) `fn` passed to `curry`.\n\n```javascript\nconst curried = curry((a, b, c) => [a, b, c]);\n\nconsole.log(curried(\"a\")); // function() {}\n\nconst uncurried = uncurry(fn);\n\nconsole.log(uncurried(\"a\")); // [\"a\", undefined, undefined]\n```\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 `8.9.4`.\n\n#### Passing each parameter in curried calls\n\n| Library       | Operations / second | Relative margin of error |\n| ------------- | ------------------- | ------------------------ |\n| **curriable** | **1,632,076**       | **1.43%**                |\n| ramda         | 1,041,570           | 1.15%                    |\n| lodash        | 138,685             | 0.88%                    |\n\n#### Passing all parameters in one call\n\n| Library       | Operations / second | Relative margin of error |\n| ------------- | ------------------- | ------------------------ |\n| **curriable** | **21,517,188**      | **1.36%**                |\n| ramda         | 10,064,677          | 0.97%                    |\n| lodash        | 8,031,747           | 1.18%                    |\n\n#### Using placeholder parameters in curried calls\n\n| Library       | Operations / second | Relative margin of error |\n| ------------- | ------------------- | ------------------------ |\n| **curriable** | **2,577,105**       | **1.02%**                |\n| ramda         | 1,309,428           | 1.02%                    |\n| lodash        | 204,268             | 0.77%                    |\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- `build:types` => create the `index.d.ts` types file\n- `clean` => run `rimraf` on the `lib` 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- `prepublish` => runs `prepublish:compile`\n- `prepublish:compile` => run `lint`, `flow`, `test:coverage`, `transpile:lib`, `transpile:es`, and `dist`\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","readmeFilename":"README.md","gitHead":"32e99b73c96e0e3f5c43220d6ea8d6fe67eded4f","_id":"curriable@1.2.3-0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"dist":{"integrity":"sha512-doNR6vZ2ZAHKe0VqABG5JSXyxJWP9shFqXdcB1Oab9nxJaOGRO8IZaGK4ix5M0+Enk7IUZfId0NsUce0jJtQmg==","shasum":"cbe32e3bda37161e2d61a691ac1ef59990cab439","tarball":"http://registry-npm.ywwl.com/curriable/download/curriable-1.2.3-0.tgz","fileCount":16,"unpackedSize":35051,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcKM2MCRA9TVsSAnZWagAAsxQQAIA6WVbp3TEDqTsNpH/F\ndHA2MV8NXFV0COYsfV3xlwktmzZAI2f/YCgQmlwmVCf2RPna1h0i6tlAkLc1\nefUzqIlHTBx7C6TtOthJm0D3u8WlwhrLa0ib2SoenD8GQ0kiprw/cnH3mGsr\ntt2ygyuBULkpmVshLIs89NYXlOmMa/x0oW+YrhfXzSDzrxBq8qmJfYsH7Z8i\nssvncCey4oKxUvsKJ7FFzrA3OaNnbsWCbUtbHQty3QLH89XfmnwqyBBSZsPD\ngPAwaxqwt4s23F/tDD3OqsxNYBHcTsS7gnclPRsqXMoDwXaiKlE4ffSQVYZZ\ndrdX3UTtp5iCMXNHpkVP4tiJFXAMaB58M1BmhztELPe4Z0YM96P4VolX2Uc9\nhTkVXTUFHan/GRjummJVuONkSUtxZCapLsbWGhzdqlo8APGplWX0Wgea1Ax0\nCYwhw/+V4cbdqVKuN6J4OGRZu7G2Mviqa6fKOJJ24RSWcoM6mOav92Q8xXlq\ntyaauSba8C8P6uYNjSvnDKMb/grynBNeaNAovyNgEd9sO2rkfOq4HkKdgU73\nj6V9cDAfCbpqNBkS4oFd5gSLN0SyD0KJlZWObDjwmxxZsWtrzQSrFP0lUMxq\nntiq8uux71W8r2W7rvLMSl0t0Aa7Yoei1st/9Lhduo5k/Ju2uq06agtbA+W9\nzNPZ\r\n=zfax\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCRnuB//AnNqF/McVSACn5vEQLdt7yCHUEjPi/RramuOwIhANHHrVIv1ywKFn7CI2iiB8QbhkzZbWtnK6Pxc9UKgyCp"}],"size":7785,"noattachment":false,"key":"/curriable/-/curriable-1.2.3-0.tgz"},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/curriable_1.2.3-0_1546177931933_0.17886001209969993"},"_hasShrinkwrap":false,"publish_time":1546177932117,"_cnpm_publish_time":1546177932117,"dist-tags":{"latest":"2.0.1","next":"1.2.3-0"}}