{"id":18948795,"url":"https://github.com/creditkarma/async-scope","last_synced_at":"2026-05-14T23:05:27.064Z","repository":{"id":57104384,"uuid":"124928544","full_name":"creditkarma/async-scope","owner":"creditkarma","description":"A thread local approximation built on async hooks, written in TypeScript","archived":false,"fork":false,"pushed_at":"2023-03-23T14:20:40.000Z","size":121,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-01T06:22:06.262Z","etag":null,"topics":["async-hooks","nodejs","storage","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creditkarma.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,"zenodo":null}},"created_at":"2018-03-12T17:49:01.000Z","updated_at":"2018-07-16T23:14:27.000Z","dependencies_parsed_at":"2025-05-25T14:35:19.740Z","dependency_job_id":"828faf8b-c08b-4d4a-bbaf-e724e104820d","html_url":"https://github.com/creditkarma/async-scope","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/creditkarma/async-scope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditkarma%2Fasync-scope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditkarma%2Fasync-scope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditkarma%2Fasync-scope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditkarma%2Fasync-scope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creditkarma","download_url":"https://codeload.github.com/creditkarma/async-scope/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditkarma%2Fasync-scope/sbom","scorecard":{"id":308347,"data":{"date":"2025-08-11","repo":{"name":"github.com/creditkarma/async-scope","commit":"673ff8d2049105cee30c764d197186d3c24d8553"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/27 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":"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"41 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4","Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"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-17T22:38:43.766Z","repository_id":57104384,"created_at":"2025-08-17T22:38:43.766Z","updated_at":"2025-08-17T22:38:43.766Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278078062,"owners_count":25926032,"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-02T02:00:08.890Z","response_time":67,"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":["async-hooks","nodejs","storage","typescript"],"created_at":"2024-11-08T13:14:41.946Z","updated_at":"2025-10-05T18:05:22.462Z","avatar_url":"https://github.com/creditkarma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Async Scope\n\nAsync Scope is a library built on the relatively new Node feature Async Hooks. It provides a key-value store that follows simple scoping rules across async boundaries. What that means is if you have a function that spawns an async coputation that operates outside of the lexical scope of the invoking function you can share data between the two functions. The idea being that a child async context has access to all of the data defined in parent async contexts, but not to the data defined in child contexts.\n\nLet's look at a convoluted example:\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope()\n\nsetTimeout(() =\u003e {\n    function childFunction() {\n        asyncScope.get\u003cnumber\u003e('foo') // returns 6\n    }\n\n    function parentFunction() {\n        asyncScope.set('foo', 6)\n        setTimeout(() =\u003e {\n            childFunction()\n        }, 1000)\n    }\n\n    parentFunction()\n}, 500)\n\nsetTimeout(() =\u003e {\n    asyncScope.get\u003cnumber\u003e('foo') // returns null\n}, 3000)\n```\n\nThink about this in terms of building a service framework where you have a server receiving HTTP requests and clients sending out HTTP requests. There is data on incoming HTTP headers that needs to be propagated to all clients (tracing, authentication, other company/user specific data). A library could set the desired values to the Async Scope store and client libraries could read that data without the service/application developers having to take any responsibility for passing data from server to client.\n\n## Usage\n\n```sh\n$ npm install --save @creditkarma/async-scope\n```\n\n### Constructing an Instance\n\nWhen constructing a new instance there are three optional parameters `nodeExpiration`, `purgeInterval` and `maxSize`. The idea behind Async Scope is that data should be very short-lived. Depending on what you are storing memory foot print could be non-trivial if left running for a long period of time. These options configure expiration of data. `nodeExpiration` defines how long data in a particular context should be allowed to live, defaults to 5 seconds. The option `purgeInterval` is how often the store looks for and ejects expired data, defaults to 10 seconds. The final option `maxSize` configures how many objects to hold in the scope store, defaults to 10000 items. If the `maxSize` is reach older objects are ejected to make room for new ones.\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope({\n    nodeExpiration: 5000,\n    purgeInterval: 10000,\n    maxSize: 10000,\n})\n```\n\n### Basic KV Store API\n\nThe Async Scope store supports three operations: `get`, `set` and `delete`.\n\n#### `set`\n\nSets a value to be read by the current scope or any child scope.\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope()\nasyncScope.set('foo', 5)\n```\n\n#### `get`\n\nRead a value from the current scope or any parent scope. It works like the prototype chain. It will return the first value matching the given key it finds by searching the chain (closest parent with matching key).\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope()\nasyncScope.get('foo')\n```\n\n#### `delete`\n\nRemove the given key from the current scope. This is a recursive delete. If there is more than one matching key in the current scope chain then all will be deleted.\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope()\nasyncScope.delete('foo')\n```\n\n### Debugging API\n\nThese are methods for inspecting the async scope when things aren't behaving as expected.\n\n#### `lineage`\n\nReturn an array representing the lineage of the current scope. Each scope has a unique id. This lists, in order, the parents of the current scope. The current scope is the first element in the array, the next is the immediate parent and so on.\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope()\nconsole.log(asyncScope.lineage())\n```\n\n#### `size`\n\nReturns an object describing the size of the current store.\n\n```typescript\ninterface ISizeProfile {\n    size: number\n    maxSize: number\n}\n```\n\nThe object contains two properties. First `size` is the current number of scopes being tracked by the store. Second `maxSize` is the maximum number the store will hold before it starts ejecting old scopes.\n\n```typescript\nimport { AsyncScope } from '@creditkarma/async-scope'\n\nconst asyncScope: AsyncScope = new AsyncScope()\nconsole.log(asyncScope.size())\n```\n\n## Contributing\n\nFor more information about contributing new features and bug fixes, see our [Contribution Guidelines](https://github.com/creditkarma/CONTRIBUTING.md).\nExternal contributors must sign Contributor License Agreement (CLA)\n\n## License\n\nThis project is licensed under [Apache License Version 2.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreditkarma%2Fasync-scope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreditkarma%2Fasync-scope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreditkarma%2Fasync-scope/lists"}