{"id":25636206,"url":"https://github.com/expo/await-lock","last_synced_at":"2025-04-06T09:09:43.481Z","repository":{"id":542257,"uuid":"30396418","full_name":"expo/await-lock","owner":"expo","description":"Mutex locks for async functions","archived":false,"fork":false,"pushed_at":"2025-02-24T07:46:55.000Z","size":997,"stargazers_count":93,"open_issues_count":0,"forks_count":12,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-30T08:09:33.628Z","etag":null,"topics":["async-await","concurrency","mutex-lock"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/expo.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":"2015-02-06T05:16:06.000Z","updated_at":"2025-03-05T10:33:51.000Z","dependencies_parsed_at":"2025-02-22T18:18:55.837Z","dependency_job_id":"6d67691c-6476-4a13-846e-efcfdf117df9","html_url":"https://github.com/expo/await-lock","commit_stats":null,"previous_names":["expo/await-lock"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Fawait-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Fawait-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Fawait-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Fawait-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/expo","download_url":"https://codeload.github.com/expo/await-lock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457803,"owners_count":20941906,"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-await","concurrency","mutex-lock"],"created_at":"2025-02-23T00:07:37.201Z","updated_at":"2025-04-06T09:09:43.460Z","avatar_url":"https://github.com/expo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AwaitLock ![tests](https://github.com/ide/await-lock/workflows/Tests/badge.svg) [![codecov](https://codecov.io/gh/ide/await-lock/branch/master/graph/badge.svg)](https://codecov.io/gh/ide/await-lock)\nMutex locks for async functions\n\n# API\n\n[API documentation](https://github.com/ide/await-lock/wiki/API-documentation)\n\n# Usage\n\nThis package is published only as an ES module. In addition to importing ES modules from ES modules, modern versions of Node.js support [requiring ES modules from CommonJS modules](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require).\n\n```javascript\nimport AwaitLock from 'await-lock';\n\nlet lock = new AwaitLock();\n\nasync function runSerialTaskAsync() {\n  await lock.acquireAsync();\n  try {\n    // IMPORTANT: Do not return a promise from here because the finally clause\n    // may run before the promise settles, and the catch clause will not run if\n    // the promise is rejected\n  } finally {\n    lock.release();\n  }\n}\n```\n\nYou can also use AwaitLock with [co](https://github.com/tj/co) and generator functions.\n\n```javascript\nimport AwaitLock from 'await-lock';\n\nlet runSerialTaskAsync = co.wrap(function*() {\n  yield lock.acquireAsync();\n  try {\n    // Run async code in the critical section\n  } finally {\n    lock.release();\n  }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpo%2Fawait-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpo%2Fawait-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpo%2Fawait-lock/lists"}