{"id":16628880,"url":"https://github.com/critocrito/curry","last_synced_at":"2025-10-24T20:16:01.588Z","repository":{"id":57104481,"uuid":"132747615","full_name":"critocrito/curry","owner":"critocrito","description":"Named curry functions for fixed arities.","archived":false,"fork":false,"pushed_at":"2019-11-07T22:13:16.000Z","size":894,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-08T14:58:01.904Z","etag":null,"topics":["curry","currying","fp","functional-programming","javascript","utility"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/critocrito.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-09T11:35:20.000Z","updated_at":"2020-06-04T00:06:30.000Z","dependencies_parsed_at":"2022-08-20T22:10:36.181Z","dependency_job_id":null,"html_url":"https://github.com/critocrito/curry","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/critocrito/curry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/critocrito%2Fcurry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/critocrito%2Fcurry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/critocrito%2Fcurry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/critocrito%2Fcurry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/critocrito","download_url":"https://codeload.github.com/critocrito/curry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/critocrito%2Fcurry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280858250,"owners_count":26403280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curry","currying","fp","functional-programming","javascript","utility"],"created_at":"2024-10-12T04:37:55.565Z","updated_at":"2025-10-24T20:16:01.562Z","avatar_url":"https://github.com/critocrito.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `curry`\n\nCurry functions with a name.\n\n## Synopsis\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![npm version](https://img.shields.io/npm/v/@critocrito/curry.svg?style=flat)](https://www.npmjs.com/package/@critocrito/curry) [![Build Status](https://travis-ci.org/critocrito/curry.svg?branch=master)](https://travis-ci.org/critocrito/curry) [![Coverage Status](https://coveralls.io/repos/github/critocrito/curry/badge.svg)](https://coveralls.io/github/critocrito/curry) [![Greenkeeper badge](https://badges.greenkeeper.io/critocrito/curry.svg)](https://greenkeeper.io/)\n\nThese are curry functions that also set the name of the curried\nfunctions. This improves the usability of using those curried functions in the\nREPL.\n\n## Installation\n\n```sh\nnpm install @critocrito/curry\n```\n\n## Usage\n\n```js\nimport {curry2} from \"@critocrito/curry\";\n\nconst sum2 = curry2(\"sum2\", (a, b) =\u003e a + b);\nconsole.log(sum2); // [Function: sum2-2]\nconsole.log(sum2(1)); // [Function: sum2-1]\nconsole.log(sum2(1, 1)); // 2\nconsole.log(sum2(1)(1)); // 2\n```\n\n## API\n\nThe module exports curry functions for an arity up to 10.\n\n- `curry2`\n- `curry3`\n- `curry4`\n- `curry5`\n- `curry6`\n- `curry7`\n- `curry8`\n- `curry9`\n- `curry10`\n\n```js\nimport {curry5, curry10} from \"@critocrito/curry\";\n\nconst sum = xs =\u003e xs.reduce((memo, i) =\u003e memo + i, 0);\n\nconst sum5 = curry5(\"sum5\", sum);\nconst sum10 = curry10(\"sum10\", sum);\n\nsum5(1, 2, 3, 4, 5); // 15\nsum10(1, 2, 3)(4, 5)(6, 7, 8, 9, 10); // 45\n```\n\nAll curry functions are created using the `ncurry` factory. If the provided\narities are not sufficient, create a new one.\n\n```js\nimport {ncurry} from \"@critocrito/ncurry\"\n\nconst sum = xs =\u003e xs.reduce((memo, i) =\u003e memo + i, 0);\nconst curry15 = ncurry(15);\n\nconst sum15 = curry15(\"sum15\", sum);\n```\n\n## Performance\n\nWhen applying all arguments to the curried function at once,\ne.g. `curriedSum(1, 2, 3, 4, 5)` the implementation of\n[Lodash](https://lodash.com/) is faster.\n\n```\nlodash full application with 2 arguments x 3,713,955 ops/sec ±2.23% (82 runs sampled)\nthis curry full application with 2 arguments x 1,246,646 ops/sec ±2.42% (79 runs sampled)\nlodash full application with 3 arguments x 2,635,956 ops/sec ±1.84% (81 runs sampled)\nthis curry full application with 3 arguments x 1,141,811 ops/sec ±2.34% (82 runs sampled)\nlodash full application with 4 arguments x 2,290,952 ops/sec ±2.61% (83 runs sampled)\nthis curry full application with 4 arguments x 1,037,962 ops/sec ±2.84% (84 runs sampled)\nlodash full application with 5 arguments x 2,015,086 ops/sec ±1.91% (81 runs sampled)\nthis curry full application with 5 arguments x 946,800 ops/sec ±2.24% (85 runs sampled)\nlodash full application with 6 arguments x 1,800,830 ops/sec ±2.30% (83 runs sampled)\nthis curry full application with 6 arguments x 896,425 ops/sec ±1.84% (85 runs sampled)\nlodash full application with 7 arguments x 1,670,538 ops/sec ±2.36% (83 runs sampled)\nthis curry full application with 7 arguments x 818,076 ops/sec ±2.06% (84 runs sampled)\nlodash full application with 8 arguments x 1,525,016 ops/sec ±3.06% (83 runs sampled)\nthis curry full application with 8 arguments x 773,187 ops/sec ±1.54% (85 runs sampled)\nlodash full application with 9 arguments x 1,390,510 ops/sec ±2.88% (78 runs sampled)\nthis curry full application with 9 arguments x 731,658 ops/sec ±1.77% (85 runs sampled)\nlodash full application with 10 arguments x 1,376,320 ops/sec ±2.33% (84 runs sampled)\nthis curry full application with 10 arguments x 693,727 ops/sec ±2.54% (83 runs sampled)\n```\n\nBut when actually applying arguments incrementally (which is the point of a\ncurried function), e.g. `curriedSum(1)(2)(3)(4)(5)`, this implementation\nperforms better than Lodash.\n\n```\nlodash piecemeal application with 2 arguments x 269,906 ops/sec ±1.22% (84 runs sampled)\nthis curry piecemeal application with 2 arguments x 293,983 ops/sec ±5.06% (77 runs sampled)\nlodash piecemeal application with 3 arguments x 141,272 ops/sec ±1.32% (86 runs sampled)\nthis curry piecemeal application with 3 arguments x 172,166 ops/sec ±4.27% (80 runs sampled)\nlodash piecemeal application with 4 arguments x 93,988 ops/sec ±2.19% (83 runs sampled)\nthis curry piecemeal application with 4 arguments x 118,644 ops/sec ±4.62% (79 runs sampled)\nlodash piecemeal application with 5 arguments x 69,943 ops/sec ±5.81% (88 runs sampled)\nthis curry piecemeal application with 5 arguments x 89,667 ops/sec ±4.71% (77 runs sampled)\nlodash piecemeal application with 6 arguments x 57,978 ops/sec ±0.99% (86 runs sampled)\nthis curry piecemeal application with 6 arguments x 72,254 ops/sec ±4.49% (77 runs sampled)\nlodash piecemeal application with 7 arguments x 47,702 ops/sec ±1.32% (83 runs sampled)\nthis curry piecemeal application with 7 arguments x 61,147 ops/sec ±4.31% (79 runs sampled)\nlodash piecemeal application with 8 arguments x 40,564 ops/sec ±2.14% (90 runs sampled)\nthis curry piecemeal application with 8 arguments x 52,434 ops/sec ±4.35% (82 runs sampled)\nlodash piecemeal application with 9 arguments x 34,938 ops/sec ±3.82% (85 runs sampled)\nthis curry piecemeal application with 9 arguments x 45,527 ops/sec ±4.91% (80 runs sampled)\nlodash piecemeal application with 10 arguments x 30,946 ops/sec ±1.21% (85 runs sampled)\nthis curry piecemeal application with 10 arguments x 40,001 ops/sec ±4.57% (79 runs sampled)\n```\n\nTo run the benchmarks locally execute in the project repository:\n\n```sh\nnpm install\nnpm run benchmark\n```\n\n## License\n\n[GPL 3.0 licensed](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcritocrito%2Fcurry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcritocrito%2Fcurry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcritocrito%2Fcurry/lists"}