{"id":20390672,"url":"https://github.com/dizmo/functions-partial","last_synced_at":"2025-03-05T00:12:43.790Z","repository":{"id":46987569,"uuid":"147217059","full_name":"dizmo/functions-partial","owner":"dizmo","description":"dizmoFun: partial functions","archived":false,"fork":false,"pushed_at":"2023-10-18T13:43:22.000Z","size":1284,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-15T23:47:01.227Z","etag":null,"topics":["dizmo","function","javascript","library","partial","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@dizmo/functions-partial","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dizmo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-03T14:36:04.000Z","updated_at":"2022-11-16T19:00:43.000Z","dependencies_parsed_at":"2023-02-08T12:31:40.842Z","dependency_job_id":"70d40abe-bd34-419d-b8f7-dc08b760f356","html_url":"https://github.com/dizmo/functions-partial","commit_stats":{"total_commits":56,"total_committers":1,"mean_commits":56.0,"dds":0.0,"last_synced_commit":"80ef257e94cd2389225d7ee795657860c89b0c62"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-partial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-partial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-partial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-partial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dizmo","download_url":"https://codeload.github.com/dizmo/functions-partial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940579,"owners_count":20045883,"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":["dizmo","function","javascript","library","partial","typescript"],"created_at":"2024-11-15T03:26:13.507Z","updated_at":"2025-03-05T00:12:43.741Z","avatar_url":"https://github.com/dizmo.png","language":"TypeScript","readme":"[![NPM version](https://badge.fury.io/js/%40dizmo%2Ffunctions-partial.svg)](https://npmjs.org/package/@dizmo/functions-partial)\n[![Build Status](https://travis-ci.com/dizmo/functions-partial.svg?branch=master)](https://travis-ci.com/dizmo/functions-partial)\n[![Coverage Status](https://coveralls.io/repos/github/dizmo/functions-partial/badge.svg?branch=master)](https://coveralls.io/github/dizmo/functions-partial?branch=master)\n\n# @dizmo/functions-partial\n\nAllows to bind *any* argument of a function using their names rather than their positions. This approach is more flexible if the initial arguments are to be left unbound. For example, from a function `fn`\n\n```javascript\nfn(arg_0, arg_1, .., arg_[n-3], arg_[n-2], arg_[n-1])\n```\n\nwe can create a new function `gn`, which requires all arguments but the last and the *third last* parameter by applying the\n\n```javascript\ngn = fn.partial({arg_[n-3]: val_[n-3}, arg_[n-1]: val_[n-1]})\n```\n\npartial operation. The invocation of `gn` would look like `gn(val_0, val_1, .., val_[n-2])`. Notice that the relative position of the *unbound* arguments is left intact.\n\n## Usage\n\n### Install\n\n```sh\nnpm install @dizmo/functions-partial --save\n```\n\n### Require\n\n```javascript\nconst { partial } = require('@dizmo/functions-partial');\n```\n\n### Examples\n\n```typescript\nimport { partial } from \"@dizmo/functions-partial\";\n```\n\n```typescript\nconst add = (lhs: number, rhs: number): number =\u003e {\n    return lhs + rhs;\n};\nconst expect_inc = partial(add, {lhs: +1})(0) === +1;\nconst expect_dec = partial(add, {rhs: -1})(0) === -1;\n```\n\n```typescript\nconst add = (lhs: number, rhs: number): number =\u003e {\n    return lhs + rhs;\n};\nconst inc = add.partial({lhs: +1});\nconst expect_inc = inc(0) === 1;\nconst nil = inc.partial({rhs: -1});\nconst expect_nil = nil( ) === 0;\n```\n\n## Development\n\n### Clean\n\n```sh\nnpm run clean\n```\n\n### Build\n\n```sh\nnpm run build\n```\n\n#### without linting and cleaning:\n\n```sh\nnpm run -- build --no-lint --no-clean\n```\n\n#### with UMD bundling (incl. minimization):\n\n```sh\nnpm run -- build --prepack\n```\n\n#### with UMD bundling (excl. minimization):\n\n```sh\nnpm run -- build --prepack --no-minify\n```\n\n### Lint\n\n```sh\nnpm run lint\n```\n\n#### with auto-fixing:\n\n```sh\nnpm run -- lint --fix\n```\n\n### Test\n\n```sh\nnpm run test\n```\n\n#### without linting, cleaning and (re-)building:\n\n```sh\nnpm run -- test --no-lint --no-clean --no-build\n```\n\n### Cover\n\n```sh\nnpm run cover\n```\n\n#### without linting, cleaning and (re-)building:\n\n```sh\nnpm run -- cover --no-lint --no-clean --no-build\n```\n\n## Documentation\n\n```sh\nnpm run docs\n```\n\n## Publish\n\n```sh\nnpm publish\n```\n\n#### initially (if public):\n\n```sh\nnpm publish --access=public\n```\n\n## Copyright\n\n © 2020 [dizmo AG](http://dizmo.com/), Switzerland\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizmo%2Ffunctions-partial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdizmo%2Ffunctions-partial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizmo%2Ffunctions-partial/lists"}