{"id":20655583,"url":"https://github.com/lizhengnacl/hold-on","last_synced_at":"2026-04-27T05:32:24.717Z","repository":{"id":79013152,"uuid":"146464815","full_name":"lizhengnacl/hold-on","owner":"lizhengnacl","description":"hold on,  waiting for long-running operations","archived":false,"fork":false,"pushed_at":"2018-08-28T15:59:34.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-09T22:39:52.807Z","etag":null,"topics":["await","concurrence","koa2"],"latest_commit_sha":null,"homepage":"https://github.com/lizhengnacl/hold-on","language":"JavaScript","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/lizhengnacl.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-28T15:04:33.000Z","updated_at":"2018-08-28T15:59:35.000Z","dependencies_parsed_at":"2023-03-12T06:27:31.916Z","dependency_job_id":null,"html_url":"https://github.com/lizhengnacl/hold-on","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lizhengnacl/hold-on","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fhold-on","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fhold-on/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fhold-on/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fhold-on/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lizhengnacl","download_url":"https://codeload.github.com/lizhengnacl/hold-on/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fhold-on/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32324544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"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":["await","concurrence","koa2"],"created_at":"2024-11-16T18:11:55.171Z","updated_at":"2026-04-27T05:32:24.678Z","avatar_url":"https://github.com/lizhengnacl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 背景\n并发场景下，避免相同耗时操作`action`被重复触发，第`1`个请求触发`action`后，后续`n`个同质请求被`await`住，直到`action`执行结束，`n`个同质请求再继续执行，并直接使用`action`的结果。\n\n## 示例\n```\nconst HoldOn = require('koa2-hold-on');\nconst holdOn = new HoldOn();\n\n// 判断是否进入耗时操作\nconst key = 'some key';\nlet status = holdOn.get(key);\nif(status !== 'hold') {\n    holdOn.hold(key);\n    \n    await action(); // 模拟耗时操作\n    \n    holdOn.release(key);\n}\nawait holdOn.wait(key);\n// 结束耗时操作，继续流程\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flizhengnacl%2Fhold-on","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flizhengnacl%2Fhold-on","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flizhengnacl%2Fhold-on/lists"}