{"id":23127926,"url":"https://github.com/zengming00/promise-all-limit","last_synced_at":"2025-06-10T15:03:45.279Z","repository":{"id":57151170,"uuid":"185363771","full_name":"zengming00/promise-all-limit","owner":"zengming00","description":"nodejs, limit the maximum number of concurrent tasks","archived":false,"fork":false,"pushed_at":"2019-05-07T10:21:25.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T23:46:27.252Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/zengming00.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}},"created_at":"2019-05-07T09:03:04.000Z","updated_at":"2019-05-07T10:21:27.000Z","dependencies_parsed_at":"2022-08-24T10:20:29.002Z","dependency_job_id":null,"html_url":"https://github.com/zengming00/promise-all-limit","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/zengming00%2Fpromise-all-limit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fpromise-all-limit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fpromise-all-limit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fpromise-all-limit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zengming00","download_url":"https://codeload.github.com/zengming00/promise-all-limit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128739,"owners_count":20888234,"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":[],"created_at":"2024-12-17T09:15:44.327Z","updated_at":"2025-04-04T05:43:12.441Z","avatar_url":"https://github.com/zengming00.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://996.icu\"\u003e\u003cimg src=\"https://img.shields.io/badge/link-996.icu-red.svg\" alt=\"996.icu\" /\u003e\u003c/a\u003e\n# promise-all-limit\n\nnodejs, limit the maximum number of concurrent tasks\n\n```sh\nnpm install promise-all-limit\n```\n\n```js\nconst promiseAllLimit = require('promise-all-limit');\n\nfunction job_reject_b(name) {\n    const text = `job ${name}`\n    console.log('started', text)\n    return new Promise(function (resolve, reject) {\n        setTimeout(() =\u003e {\n            if (name === 'b') {\n                return reject(new Error('b reject'));\n            }\n            console.log('       ', text, 'finished')\n            resolve(text);\n        }, 100)\n    })\n}\n\nasync function test() {\n    try {\n        const jobs = ['a', 'b', 'c', 'd', 'e'];\n        const concurrency = 3;\n        const results = await promiseAllLimit(jobs, concurrency, function (item) {\n            return job_reject_b(item);\n        });\n        console.log('results:', results)\n    } catch (e) {\n        console.log('---\u003e err:', e.message);\n    }\n}\n\ntest();\n```\n\nwill output:\n\n```\nstarted job a\nstarted job b\nstarted job c\n        job a finished\nstarted job d\n        job c finished\nstarted job e\n---\u003e err: b reject\n        job d finished\n        job e finished\n```\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzengming00%2Fpromise-all-limit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzengming00%2Fpromise-all-limit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzengming00%2Fpromise-all-limit/lists"}