{"id":16616343,"url":"https://github.com/stoeffel/compose-function","last_synced_at":"2025-04-07T14:13:54.913Z","repository":{"id":25342378,"uuid":"28769775","full_name":"stoeffel/compose-function","owner":"stoeffel","description":"Function composition","archived":false,"fork":false,"pushed_at":"2019-11-07T17:21:19.000Z","size":23,"stargazers_count":56,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T12:07:18.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stoeffel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-04T09:12:28.000Z","updated_at":"2024-11-09T20:30:17.000Z","dependencies_parsed_at":"2022-09-18T00:42:04.210Z","dependency_job_id":null,"html_url":"https://github.com/stoeffel/compose-function","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoeffel%2Fcompose-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoeffel%2Fcompose-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoeffel%2Fcompose-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoeffel%2Fcompose-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stoeffel","download_url":"https://codeload.github.com/stoeffel/compose-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666015,"owners_count":20975788,"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","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":[],"created_at":"2024-10-12T02:12:48.779Z","updated_at":"2025-04-07T14:13:54.888Z","avatar_url":"https://github.com/stoeffel.png","language":"JavaScript","readme":"[![Travis](https://img.shields.io/travis/stoeffel/compose-function.svg?style=flat-square)](https://travis-ci.org/stoeffel/compose-function)\n[![npm](https://img.shields.io/npm/v/compose-function.svg?style=flat-square)](https://www.npmjs.com/package/compose-function)\n[![Dependency Status](https://david-dm.org/stoeffel/compose-function.svg?style=flat-square)](https://david-dm.org/stoeffel/compose-function)\n[![Coveralls](https://img.shields.io/coveralls/stoeffel/compose-function.svg?style=flat-square)](https://coveralls.io/github/stoeffel/compose-function)\n\n\n\u003ch1 align=\"center\"\u003eCompose-Function\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e |\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e |\n  \u003ca href=\"#related\"\u003eRelated\u003c/a\u003e |\n  \u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003cimg align=\"center\" height=\"300\" src=\"http://33.media.tumblr.com/006dfad04f93ec5b3680ec7cdae3fafa/tumblr_n8kgl18uU41qcung4o1_1280.gif\"\u003e\n  \u003cbr\u003e\n  \u003csub\u003elogo by \u003ca href=\"http://justinmezzell.tumblr.com/\"\u003eJustin Mezzell\u003c/a\u003e\u003c/sub\u003e\n  \u003cblockquote align=\"center\"\u003eCompose a new function from smaller functions `f(g(x))`\u003c/blockquote\u003e\n\u003c/p\u003e\n\nInstallation\n------------\n\n`npm install compose-function --save`\n\nUsage\n-----\n\n## Basic usage\n\n```js\nimport compose from 'compose-function';\n\nconst composition = compose(sqr, add2); // sqr(add2(x))\n\ncomposition(2) // =\u003e 16\n\ncompose(sqr, inc)(2); // =\u003e 9\ncompose(inc, sqr)(2); // =\u003e 5\n```\n\n\n\n## with curry\n\n```js\nimport compose from 'compose-function';\nimport { curry, _ } from 'curry-this';\n\n\nconst add = (x, y) =\u003e x + y;\n\n// add(6, sqr(add(2, x)))\ncompose(\n  add::curry(6),\n  sqr,\n  add::curry(2),\n);\n\n// map(filter(list, even), sqr)\ncompose(\n  map::curry(_, sqr),\n  filter::curry(_, even),\n)([1,2,3,4,5,6,7,8]) // =\u003e [4, 16, 36, 64]\n```\n\n### `::` huh?\n\nIf you’re wondering what the `::` thing means, you’d better read this excellent [overview](https://github.com/jussi-kalliokoski/trine/blob/5b735cbfb6b28ae94bac0446d9ecd5ce51fb149b/README.md#why) by [@jussi-kalliokoski](https://github.com/jussi-kalliokoski) or have a look at the [function bind syntax proposal](https://github.com/zenparsing/es-function-bind).\nOr checkout the [curry-this docs][ct].\n\n\nRelated\n----\n\n* [curry-this][ct]\n\nLicense\n----\n\nMIT © [Christoph Hermann](http://stoeffel.github.io)\n\n[r]: http://ramdajs.com\n[ct]: https://github.com/stoeffel/curry-this\n","funding_links":[],"categories":["Modules","Libraries","模块"],"sub_categories":["Function","函数"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoeffel%2Fcompose-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoeffel%2Fcompose-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoeffel%2Fcompose-function/lists"}