{"id":13465137,"url":"https://github.com/blend/promise-utils","last_synced_at":"2025-05-16T14:07:06.679Z","repository":{"id":34262024,"uuid":"173827657","full_name":"blend/promise-utils","owner":"blend","description":"Lodash-like, dependency-free utilities for native ES6 promises.","archived":false,"fork":false,"pushed_at":"2024-08-21T19:44:15.000Z","size":608,"stargazers_count":282,"open_issues_count":18,"forks_count":15,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T10:57:50.438Z","etag":null,"topics":["blend","dependency-free","javascript","lodash","nodejs","promises","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/blend.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-04T21:55:39.000Z","updated_at":"2025-03-19T21:57:42.000Z","dependencies_parsed_at":"2024-10-19T08:53:46.339Z","dependency_job_id":null,"html_url":"https://github.com/blend/promise-utils","commit_stats":{"total_commits":75,"total_committers":21,"mean_commits":"3.5714285714285716","dds":0.8,"last_synced_commit":"1d8167b248de992a2889a2e654bc8068639b780e"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blend%2Fpromise-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blend%2Fpromise-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blend%2Fpromise-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blend%2Fpromise-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blend","download_url":"https://codeload.github.com/blend/promise-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"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":["blend","dependency-free","javascript","lodash","nodejs","promises","typescript"],"created_at":"2024-07-31T14:01:00.897Z","updated_at":"2025-05-16T14:07:06.661Z","avatar_url":"https://github.com/blend.png","language":"TypeScript","readme":"promise-utils\n=============\n\n[![Build Status](https://circleci.com/gh/blend/promise-utils.svg?style=shield)](https://circleci.com/gh/blend/promise-utils)\n[![Coverage Status](https://coveralls.io/repos/github/blend/promise-utils/badge.svg?branch=master)](https://coveralls.io/github/blend/promise-utils?branch=master)\n![Minzipped size](https://img.shields.io/bundlephobia/minzip/blend-promise-utils.svg)\n\nPromise-utils is a dependency-free JavaScript/TypeScript library that\nprovides Lodash-like utility functions for dealing with native ES6\npromises.\n\n## Installation\n\n```\n$ npm install blend-promise-utils\n```\n\n## Usage Example\n\n```js\nconst promiseUtils = require('blend-promise-utils')\nconst { promises: fs } = require('fs')\nconst request = require('request-promise-native');\nconst isEmpty = require('lodash.isempty');\n\nconst MS_IN_SECOND = 1000;\n\nasync function main() {\n  const cachedResponse = promiseUtils.memoize(\n    async (contents) =\u003e request(contents.url),\n    contents =\u003e contents.url,\n    15 * MS_IN_SECOND // contents could change\n  );\n\n  const fileContents = await promiseUtils.map(\n    ['file1', 'file2', 'file3'],\n    async fileName =\u003e {\n      const rawData = await fs.readFile(fileName);\n      return JSON.parse(rawData);\n    },\n  );\n\n  while (true) {\n    await promiseUtils.delay(150); // avoid slamming CPU\n\n    await promiseUtils.mapSeries(\n      fileContents,\n      async contents =\u003e {\n        const remoteData = await cachedResponse(contents);\n\n        const { results, errors } = await promiseUtils.settleAll([\n          asyncFunction1(),\n          asyncFunction2(),\n          asyncFunction3(),\n        ]);\n\n        if (!isEmpty(errors)) {\n          throw new Error(`Unable to settle all functions: ${JSON.stringify(errors)}`);\n        } else {\n          return results;\n        }\n      }\n    )\n  }\n\n  await promiseUtils.retry(flakyFunction, { maxAttempts: 3, delayMs: 150 })(flakyFunctionArgument);\n\n  await promiseUtils.timeout(longFunction, 60 * MS_IN_SECOND)(longFunctionArgument);\n}\n\nmain()\n```\n\n## API\n\n- [Documentation][2]\n- [Past versions][3]\n\n## Test\n\n```\n$ npm test\n```\n\n## Documentation\n\nBuild docs\n```\n$ make docs\n```\n\nPush docs to Github\n```\n$ make push-docs\n```\n\n## License\n\n[MIT](LICENSE)\n\n[1]: https://blend.github.io/promise-utils\n[2]: https://blend.github.io/promise-utils/latest/\n[3]: https://blend.github.io/promise-utils/versions.html\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblend%2Fpromise-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblend%2Fpromise-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblend%2Fpromise-utils/lists"}