{"id":15816409,"url":"https://github.com/cachecontrol/promise-series","last_synced_at":"2025-06-13T05:32:43.524Z","repository":{"id":29366362,"uuid":"32900990","full_name":"CacheControl/promise-series","owner":"CacheControl","description":"Execute methods that return promises in series","archived":false,"fork":false,"pushed_at":"2016-03-26T14:52:32.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-15T05:16:34.692Z","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/CacheControl.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":"2015-03-26T01:32:42.000Z","updated_at":"2017-10-26T21:06:35.000Z","dependencies_parsed_at":"2022-08-03T12:00:31.444Z","dependency_job_id":null,"html_url":"https://github.com/CacheControl/promise-series","commit_stats":null,"previous_names":["cdhamm/promise-series"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CacheControl/promise-series","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CacheControl%2Fpromise-series","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CacheControl%2Fpromise-series/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CacheControl%2Fpromise-series/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CacheControl%2Fpromise-series/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CacheControl","download_url":"https://codeload.github.com/CacheControl/promise-series/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CacheControl%2Fpromise-series/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259589260,"owners_count":22880937,"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-10-05T05:03:21.597Z","updated_at":"2025-06-13T05:32:43.498Z","avatar_url":"https://github.com/CacheControl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Promise Series\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n\nExecute array of methods that return promises, in series.\n\n## Installation\n```$ npm install promise-series-node```\n\n## Basic Usage\n\n```javascript\nimport promiseSeries from 'promise-series-node';\n\nfunction func1() {\n  return new Promise((resolve, reject) =\u003e {\n    resolve('hello');\n  });\n};\n\nfunction func2() {\n  return new Promise((resolve, reject) =\u003e {\n    resolve('world');\n  });\n};\n\npromiseSeries([func1, func2]).then(results =\u003e {\n  console.log(results);\n});\n```\n\nThis will print:\n```javascript\n['hello', 'world']  //results are returned in the order they were executed\n```\n\n## Halt condition\nOptionally, you make choose to provide a callback that is run against each result.  If the test fails, the subsequent functions in the series will not be executed, and the series will resolve immediately.\n\n```javascript\nlet func1 = function() {\n  return new Promise((resolve, reject) =\u003e {\n    resolve(true);\n  });\n};\n\nlet func2 = function() {\n  return new Promise((resolve, reject) =\u003e {\n    resolve(false);\n  });\n};\n\nlet func3 = function() {\n  return new Promise((resolve, reject) =\u003e {\n    resolve(true);\n  });\n};\n\n//only promises that resolve(true) pass the test\npromiseSeries([func1, func2, func3], res =\u003e res === true).then(results =\u003e {\n  console.log(results);\n});\n```\nThis will print:\n```javascript\n//note that func3 is not included, because func2 failed before it ran\n//also note that results include the failed result\n[true, false]\n```\n\n## Non-standard inputs\nIf a function does not return a promise, the return value will be passed through to the results:\n```javascript\nlet nonPromiseFunc = function() {\n  return 'cruel';\n};\n\npromiseSeries([func1, nonPromiseFunc, func2]).then(results =\u003e {\n  console.log(results);\n});\n```\nThis will print:\n```javascript\n['hello', 'cruel', 'world']\n```\n\nIf one of the inputs is not a function, the input will be passed through to the results:\n```javascript\npromiseSeries([func1, 'foo', 42, func2]).then(results =\u003e {\n  console.log(results);\n});\n```\n\nThis will print:\n```javascript\n['hello', 'foo', 42, 'world']\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachecontrol%2Fpromise-series","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcachecontrol%2Fpromise-series","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachecontrol%2Fpromise-series/lists"}