{"id":20000442,"url":"https://github.com/knpwrs/pass-context","last_synced_at":"2026-06-10T00:31:04.378Z","repository":{"id":57319842,"uuid":"87756190","full_name":"knpwrs/pass-context","owner":"knpwrs","description":"Higher-order function to create a function which receives its context as its first argument.","archived":false,"fork":false,"pushed_at":"2017-10-05T08:00:12.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-12T13:08:33.846Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/knpwrs.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}},"created_at":"2017-04-10T02:10:09.000Z","updated_at":"2017-04-10T02:10:27.000Z","dependencies_parsed_at":"2022-08-25T22:42:32.719Z","dependency_job_id":null,"html_url":"https://github.com/knpwrs/pass-context","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knpwrs%2Fpass-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knpwrs%2Fpass-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knpwrs%2Fpass-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knpwrs%2Fpass-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knpwrs","download_url":"https://codeload.github.com/knpwrs/pass-context/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241439492,"owners_count":19963097,"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-11-13T05:14:45.643Z","updated_at":"2026-06-10T00:31:04.365Z","avatar_url":"https://github.com/knpwrs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pass-context\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/knpwrs/pass-context.svg)](https://greenkeeper.io/)\n\n\u003e Higher-order function to create a function which receives its context as its\n\u003e first argument.\n\n## What?\n\nSometimes you want to use arrow functions with an API that was designed with\ncontext (`this`) in mind. This is a small library which will pass a function's\nexecution context as that function's first argument. The arguments which are passed to the function are passed in addition to the context argument.\n\n## Installation\n\n### npm\n\n```\nnpm i -S pass-context\n```\n\nThe library function is the default export of the package.\n\n### CDN (UMD)\n\n```\nhttps://unpkg.com/pass-context@1.0.0/dist/pass-context.min.js\n```\n\nThe library function is exported as `passContext`.\n\n## Usage\n\n```js\nimport pc from 'pass-context';\nconst input = document.querySelector('.my-fancy-input');\ninput.addEventListener('change', pc((ctx, event) =\u003e {\n  // `ctx` is what is normally accessible with `this` as if a normal function were passed as the event listener.\n  // `event` (and any additional arguments) are the normal arguments passed in-order after the context argument.\n  // Since this is an arrow function, `this` is inherited.\n}));\n```\n\n### Detailed Usage Example\n\n```js\nimport pc from 'pass-context';\nconst fn = pc(({ foo }, bar) =\u003e foo + bar);\nconsole.log(fn.call({ foo: 'Hello, '}, 'World!')); // Logs \"Hello, World!\"\n```\n\n## License\n\n**MIT**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknpwrs%2Fpass-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknpwrs%2Fpass-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknpwrs%2Fpass-context/lists"}