{"id":13535601,"url":"https://github.com/sindresorhus/each-async","last_synced_at":"2025-04-16T15:49:25.054Z","repository":{"id":55420137,"uuid":"14848028","full_name":"sindresorhus/each-async","owner":"sindresorhus","description":"Async concurrent iterator (async forEach)","archived":false,"fork":false,"pushed_at":"2023-10-30T15:46:06.000Z","size":18,"stargazers_count":110,"open_issues_count":0,"forks_count":9,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-11T06:29:30.769Z","etag":null,"topics":[],"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/sindresorhus.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":".github/security.md","support":null,"governance":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2013-12-01T23:05:38.000Z","updated_at":"2025-01-07T20:10:49.000Z","dependencies_parsed_at":"2022-08-15T00:00:26.689Z","dependency_job_id":"cafad013-bf81-46ea-beb2-6812139fd01c","html_url":"https://github.com/sindresorhus/each-async","commit_stats":{"total_commits":28,"total_committers":4,"mean_commits":7.0,"dds":0.1071428571428571,"last_synced_commit":"bfc704cc69b884efdbe38754912cae9efce8fe3e"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Feach-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Feach-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Feach-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Feach-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/each-async/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248529541,"owners_count":21119530,"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-08-01T08:01:01.220Z","updated_at":"2025-04-15T14:10:26.885Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# each-async\n\n\u003e Async concurrent iterator (async forEach)\n\nLike [async.each()](https://github.com/caolan/async#eacharr-iterator-callback), but tiny.\n\nI often use `async.each()` for doing async operations when iterating, but I almost never use the other gadzillion methods in `async`.\n\nAsync iteration is one of the most used async control flow patterns.\n\n**I would strongly recommend using promises instead. You could then use the built-in [`Promise.all()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise/all), or [`p-map`](https://github.com/sindresorhus/p-map) if you need concurrency control.**\n\n\n## Install\n\n```\n$ npm install --save each-async\n```\n\n\n## Usage\n\n```js\nconst eachAsync = require('each-async');\n\neachAsync(['foo','bar','baz'], (item, index, done) =\u003e {\n\tconsole.log(item, index);\n\tdone();\n}, error =\u003e {\n\tconsole.log('finished');\n});\n//=\u003e 'foo 0'\n//=\u003e 'bar 1'\n//=\u003e 'baz 2'\n//=\u003e 'finished'\n```\n\n\n## API\n\n### eachAsync(input, callback, [finishedCallback])\n\n#### input\n\nType: `Array`\n\nArray you want to iterate.\n\n#### callback(item, index, done)\n\nType: `Function`\n\nCalled for each item in the array with the following arguments:\n\n- `item`: the current item in the array\n- `index`: the current index\n- `done([error])`: call this when you're done with an optional error. Supplying anything other than `undefined`/`null` will stop the iteration.\n\nNote that order is not guaranteed since each item is handled concurrently.\n\n#### finishedCallback(error)\n\nType: `Function`\n\nCalled when the iteration is finished or on the first error. First argument is the error passed from `done()` in the `callback`.\n\n\n## License\n\nMIT © [Sindre Sorhus](https://sindresorhus.com)\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","包","Control flow","目录"],"sub_categories":["Control flow","流程控制","Control flow Callbacks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Feach-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Feach-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Feach-async/lists"}