{"_id":"p-try-each","_rev":"4652692","name":"p-try-each","description":"Runs promise-returning functions in series but stops whenever any of the functions were successful","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"pedromiguelss","email":""}],"time":{"modified":"2026-04-10T20:48:24.000Z","created":"2019-10-13T23:16:46.578Z","1.0.1":"2019-10-14T09:24:24.473Z","1.0.0":"2019-10-13T23:16:46.578Z"},"users":{},"author":"","repository":{"type":"git","url":"git+https://github.com/PedroMiguelSS/p-try-each.git"},"versions":{"1.0.1":{"name":"p-try-each","version":"1.0.1","description":"Runs promise-returning functions in series but stops whenever any of the functions were successful","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","preversion":"npm run lint","version":"npm run format && git add -A src","postversion":"git push && git push --tags"},"repository":{"type":"git","url":"git+https://github.com/PedroMiguelSS/p-try-each.git"},"keywords":["sequential","promises","promise","series","async","await","array","tasks"],"author":"","license":"MIT","bugs":{"url":"https://github.com/PedroMiguelSS/p-try-each/issues"},"homepage":"https://github.com/PedroMiguelSS/p-try-each#readme","devDependencies":{"@types/jest":"^24.0.18","jest":"^24.9.0","prettier":"^1.18.2","ts-jest":"^24.1.0","tslint":"^5.20.0","tslint-config-prettier":"^1.18.0","typescript":"^3.6.4"},"gitHead":"9dc1bb6fc3f137bb8e3d4f7040388e8fe4fecb2b","_id":"p-try-each@1.0.1","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"shasum":"24b4b830a134cb71a934d03b76e702bed439c3c1","size":2366,"noattachment":false,"key":"/p-try-each/-/p-try-each-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-try-each/download/p-try-each-1.0.1.tgz"},"maintainers":[{"name":"pedromiguelss","email":""}],"_npmUser":{"name":"pedromiguelss","email":"pedromiguelsousasantos@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-try-each_1.0.1_1571045064312_0.9597276808129374"},"_hasShrinkwrap":false,"publish_time":1571045064473,"_cnpm_publish_time":1571045064473,"_cnpmcore_publish_time":"2021-12-16T20:52:30.016Z"},"1.0.0":{"name":"p-try-each","version":"1.0.0","description":"Runs promise-returning functions in series but stops whenever any of the functions were successful","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json","test":"jest --config jestconfig.json","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","preversion":"npm run lint","version":"npm run format && git add -A src","postversion":"git push && git push --tags"},"repository":{"type":"git","url":"git+https://github.com/PedroMiguelSS/p-try-each.git"},"keywords":["sequential","promises","promise","series","async","await","array","tasks"],"author":"","license":"MIT","bugs":{"url":"https://github.com/PedroMiguelSS/p-try-each/issues"},"homepage":"https://github.com/PedroMiguelSS/p-try-each#readme","devDependencies":{"@types/jest":"^24.0.18","jest":"^24.9.0","prettier":"^1.18.2","ts-jest":"^24.1.0","tslint":"^5.20.0","tslint-config-prettier":"^1.18.0","typescript":"^3.6.4"},"gitHead":"ab5b0cc465d3c25a745cda54c1b1eb7e6d524446","_id":"p-try-each@1.0.0","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"shasum":"068a4440cff2e7fb6539575b72b643cc091c02b1","size":2406,"noattachment":false,"key":"/p-try-each/-/p-try-each-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-try-each/download/p-try-each-1.0.0.tgz"},"maintainers":[{"name":"pedromiguelss","email":""}],"_npmUser":{"name":"pedromiguelss","email":"pedromiguelsousasantos@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-try-each_1.0.0_1571008606482_0.05672400065654459"},"_hasShrinkwrap":false,"publish_time":1571008606578,"_cnpm_publish_time":1571008606578,"_cnpmcore_publish_time":"2021-12-16T20:52:30.233Z"}},"readme":"# p-try-each [![Build Status](https://travis-ci.org/PedroMiguelSS/p-try-each.svg?branch=master)](https://travis-ci.org/PedroMiguelSS/p-try-each)\n\n> Runs promise-returning functions in series but stops whenever any of the functions were successful. If all functions reject, the promise will be rejected with the error of the final task\n\nSimilar to [`async/tryEach`](https://caolan.github.io/async/v3/docs.html#tryEach).\n\n## Install\n\n```\nnpm install --save p-try-each\n```\n\n## Usage\n\n```js\nconst pTryEach = require('p-try-each');\n\nconst tasks = [\n  () => Promise.resolve('foo'),\n  () => Promise.resolve('bar'),\n  () => Promise.resolve('baz')\n]\n\n(async () => {\n  const res = await pTryEach(tasks);\n  console.log(res);\n  // Logs:\n  // 'foo'\n})();\n```\n\n## API\n\n### pTryEach(tasks)\n\nReturns a `Promise` that is fulfilled with the value of the first fulfilled promise returned from calling the functions in `tasks`. If none is fulfilled, the promise will be rejected with the error of the final task.\n\n#### tasks\n\nType: `Iterable<Function>`\n\nFunctions must return a value. In case of a returned promise, it will be awaited before starting with the next task.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/PedroMiguelSS/p-try-each#readme","bugs":{"url":"https://github.com/PedroMiguelSS/p-try-each/issues"},"license":"MIT"}