{"id":37518943,"url":"https://github.com/obrassard/functions-delegate","last_synced_at":"2026-01-16T08:11:54.238Z","repository":{"id":57243076,"uuid":"309873481","full_name":"obrassard/functions-delegate","owner":"obrassard","description":"This package, inspired by C# multicast delegation system, allow dynamic mapping of several functions/methods inside a single \"delegate\" object which can later be invoked or passed as a function.","archived":false,"fork":false,"pushed_at":"2020-11-04T04:33:27.000Z","size":137,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-05T20:42:32.812Z","etag":null,"topics":["delegates","delegation","js","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obrassard.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-04T03:33:31.000Z","updated_at":"2023-12-20T07:42:27.000Z","dependencies_parsed_at":"2022-09-15T01:20:08.143Z","dependency_job_id":null,"html_url":"https://github.com/obrassard/functions-delegate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/obrassard/functions-delegate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrassard%2Ffunctions-delegate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrassard%2Ffunctions-delegate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrassard%2Ffunctions-delegate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrassard%2Ffunctions-delegate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obrassard","download_url":"https://codeload.github.com/obrassard/functions-delegate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrassard%2Ffunctions-delegate/sbom","scorecard":{"id":701125,"data":{"date":"2025-08-11","repo":{"name":"github.com/obrassard/functions-delegate","commit":"531062efa13584efa315503503006cc67cb14180"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/node-ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node-ci.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/obrassard/functions-delegate/node-ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node-ci.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/obrassard/functions-delegate/node-ci.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/node-ci.yml:13","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"28 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T05:14:16.223Z","repository_id":57243076,"created_at":"2025-08-22T05:14:16.223Z","updated_at":"2025-08-22T05:14:16.223Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["delegates","delegation","js","typescript"],"created_at":"2026-01-16T08:11:53.649Z","updated_at":"2026-01-16T08:11:54.219Z","avatar_url":"https://github.com/obrassard.png","language":"TypeScript","readme":"# functions-delegate\n\nThis package, inspired by C# multicast delegation system, allow dynamic mapping of several functions/methods inside a single 'delegate' object which can later be invoked or passed as a function.\n\n## Getting started\n\n```\nnpm i functions-delegate\n```\n\n```js\nimport { ActionDelegate } from \"functions-delegate\";\nimport { FunctionDelegate } from \"functions-delegate\";\n```\n\n## `ActionDelegate` vs `FunctionDelegate`\n\nBoth `ActionDelegate` and `FunctionDelegate` share the same interface.\nHowever, the main difference between the two classes is the return type of the invocation method.\n\n`ActionDelegate` ignores the return value of the registered functions. In other words `actionDelegate.invoke(..)` is void.\n`FunctionDelegate`, however, will return an array containing every return value of the called functions.\n\nSee bellow for further details.\n\n## Usage\n\n### ActionDelegate\n\n```ts\nimport { ActionDelegate } from \"functions-delegate\";\n\nlet delegate = new ActionDelegate();\n\nlet f1 = (a:string) =\u003e {\n    console.log(`Hello ${a} from 1`);\n}\n\nfunction f2(a:string) {\n    console.log(`Hello ${a} from 2`);\n}\n\nlet f3 = function (a:string) {\n    console.log(`Hello ${a} from 3`);\n}\n\nlet action = delegate.add(f1).add(f3).add(f2).asFunction();\naction('Bob');\n\nconsole.log('Removing f1');\ndelegate.remove(f1);\ndelegate.invoke('Roger') //or action('Roger');\n```\n\nWould prints :\n```\nHello Bob from 1\nHello Bob from 3\nHello Bob from 2\nRemoving f1\nHello Roger from 3\nHello Roger from 2\n```\n\n### FunctionDelegate\n\n```ts\nimport { FunctionDelegate } from \"functions-delegate\";\n\nlet delegate = new FunctionDelegate();\n\nlet f1 = (a:string) =\u003e {\n    return `Hello ${a} from 1`;\n}\n\nlet f2 = (a:string) =\u003e {\n    return `Hello ${a} from 2`;\n}\n\nlet action = delegate.add(f2).add(f1).asFunction();\nlet results = action('Bob'); //or delegate.invoke('Bob')\n\nconsole.log(results)\n```\n\nWould prints :\n```\n['Hello Bob from 2', 'Hello Bob from 1']\n```\n\n***\n\n## Interface details\n\n### `add(f:DelegateFunction): Delegate`\n\nAdds (register) a given function / method to this delegate\n\n### `remove(f:DelegateFunction): Delegate`\n\nRemove (unregister) a given function / method of this delegate\n\n### `invoke(...args: any[]): void | any[]`\n\nInvoke this delegate with the given arguments\n\n\u003e Calls all registered functions with the given arguments\n\nThis method is `void` for `ActionDelegate`, and returns an array of result (`any[]`) for `FunctionDelegate`\n\n### `asFunction(): DelegateFunction`\n\nReturns a function that can be called later to `invoke` the delegate\n\nExample : \n\n```ts\nlet action = new ActionDelegate().add(f1).add(f3).add(f2).asFunction();\naction(`Bob`);\n\n// Has the same result than\nnew ActionDelegate().add(f1).add(f3).add(f2).invoke('Bob');\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobrassard%2Ffunctions-delegate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobrassard%2Ffunctions-delegate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobrassard%2Ffunctions-delegate/lists"}