{"id":18909029,"url":"https://github.com/chdh/async-named-mutex","last_synced_at":"2025-09-09T22:06:32.039Z","repository":{"id":57684964,"uuid":"483874142","full_name":"chdh/async-named-mutex","owner":"chdh","description":"Named mutex locks for async functions.","archived":false,"fork":false,"pushed_at":"2022-04-24T20:04:01.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T15:16:18.870Z","etag":null,"topics":["async","concurrency","critical-section","javascript","lock","mutex"],"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/chdh.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":"2022-04-21T02:03:25.000Z","updated_at":"2022-04-28T23:09:39.000Z","dependencies_parsed_at":"2022-09-17T05:40:28.226Z","dependency_job_id":null,"html_url":"https://github.com/chdh/async-named-mutex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fasync-named-mutex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fasync-named-mutex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fasync-named-mutex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fasync-named-mutex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chdh","download_url":"https://codeload.github.com/chdh/async-named-mutex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239896490,"owners_count":19715034,"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":["async","concurrency","critical-section","javascript","lock","mutex"],"created_at":"2024-11-08T09:30:14.716Z","updated_at":"2025-02-20T18:44:38.918Z","avatar_url":"https://github.com/chdh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async-named-mutex\n\nNamed [mutex](https://en.wikipedia.org/wiki/Lock_(computer_science)) locks for async functions.\n\nIn asynchronous JavaScript program code, multiple async functions can operate on the same data.\nNamed mutexes can be used to protect access to shared resources.\n\n## Usage\n\n\u003cb\u003eTypeScript:\u003c/b\u003e\n```typescript\nimport {MutexRealm} from \"async-named-mutex\";\n\nconst mutexRealm = new MutexRealm\u003cstring\u003e();\n\nasync function processResource (resourceId: string) {\n   const mutex = mutexRealm.createMutex(resourceId);\n   try {\n      await mutex.acquire();\n      // ... process resource ...\n   } finally {\n      mutex.release();\n   }\n}\n\n```\n\n\u003cb\u003eJavaScript:\u003c/b\u003e\n```javascript\nimport {MutexRealm} from \"async-named-mutex\";\n\nconst mutexRealm = new MutexRealm();\n\nasync function processResource (resourceId) {\n   const mutex = mutexRealm.createMutex(resourceId);\n   try {\n      await mutex.acquire();\n      // ... process resource ...\n   } finally {\n      mutex.release();\n   }\n}\n\n```\n\nAny value which is a valid [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) index\n(`string`, `number`, `object`, ...) can be used as a name (aka key) for a mutex.\n\nNPM package: [async-named-mutex](https://www.npmjs.com/package/async-named-mutex)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdh%2Fasync-named-mutex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchdh%2Fasync-named-mutex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdh%2Fasync-named-mutex/lists"}