{"id":13396591,"url":"https://github.com/sindresorhus/p-each-series","last_synced_at":"2025-04-06T03:09:54.181Z","repository":{"id":55420250,"uuid":"71530968","full_name":"sindresorhus/p-each-series","owner":"sindresorhus","description":"Iterate over promises serially","archived":false,"fork":false,"pushed_at":"2022-07-08T15:21:29.000Z","size":12,"stargazers_count":50,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T05:23:33.868Z","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/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2016-10-21T04:52:43.000Z","updated_at":"2024-10-13T15:15:36.000Z","dependencies_parsed_at":"2022-08-15T00:00:28.521Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/p-each-series","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fp-each-series","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fp-each-series/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fp-each-series/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fp-each-series/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/p-each-series/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325695,"owners_count":20920714,"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-07-30T18:00:57.595Z","updated_at":"2025-04-06T03:09:54.161Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Promise","Packages","Convenience Utilities","JavaScript"],"sub_categories":["sindresorhus's many Promise utilities (\u003cb\u003e\u003ccode\u003e\u0026nbsp;\u0026nbsp;5157⭐\u003c/code\u003e\u003c/b\u003e \u003cb\u003e\u003ccode\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;138🍴\u003c/code\u003e\u003c/b\u003e [see notes](https://github.com/sindresorhus/promise-fun)))","sindresorhus's many Promise utilities ([see notes](https://github.com/sindresorhus/promise-fun))"],"readme":"# p-each-series\n\n\u003e Iterate over promises serially\n\nUseful as a side-effect iterator. Prefer [`p-map`](https://github.com/sindresorhus/p-map) if you don't need side-effects, as it's concurrent.\n\n## Install\n\n```\n$ npm install p-each-series\n```\n\n## Usage\n\n```js\nimport pEachSeries from 'p-each-series';\n\nconst keywords = [\n\tgetTopKeyword(), //=\u003e Promise\n\t'rainbow',\n\t'pony'\n];\n\nconst iterator = async element =\u003e saveToDiskPromise(element);\n\nconsole.log(await pEachSeries(keywords, iterator));\n//=\u003e ['unicorn', 'rainbow', 'pony']\n```\n\n## API\n\n### pEachSeries(input, iterator)\n\nReturns a `Promise` that is fulfilled when all promises in `input` and ones returned from `iterator` are fulfilled, or rejects if any of the promises reject. The fulfillment value is the original `input`.\n\n#### input\n\nType: `Iterable\u003cPromise | unknown\u003e`\n\nIterated over serially in the `iterator` function.\n\n#### iterator(element, index)\n\nType: `Function`\n\nReturn value is ignored unless it's `Promise`, then it's awaited before continuing with the next iteration.\n\n### pEachSeries.stop\n\nStop iterating through items by returning `pEachSeries.stop` from the iterator function.\n\n```js\nimport pEachSeries from 'p-each-series';\n\n// Logs `a` and `b`.\nconst result = await pEachSeries(['a', 'b', 'c'], value =\u003e {\n\tconsole.log(value);\n\n\tif (value === 'b') {\n\t\treturn pEachSeries.stop;\n\t}\n});\n\nconsole.log(result);\n//=\u003e ['a', 'b', 'c']\n```\n\n## Related\n\n- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially\n- [p-series](https://github.com/sindresorhus/p-series) - Run promise-returning \u0026 async functions in series\n- [p-pipe](https://github.com/sindresorhus/p-pipe) - Compose promise-returning \u0026 async functions into a reusable pipeline\n- [p-waterfall](https://github.com/sindresorhus/p-waterfall) - Run promise-returning \u0026 async functions in series, each passing its result to the next\n- [p-reduce](https://github.com/sindresorhus/p-reduce) - Reduce a list of values using promises into a promise for a value\n- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently\n- [More…](https://github.com/sindresorhus/promise-fun)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fp-each-series","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fp-each-series","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fp-each-series/lists"}