{"id":14984980,"url":"https://github.com/virtualstate/promise","last_synced_at":"2025-04-10T23:14:53.968Z","repository":{"id":38196641,"uuid":"462676845","full_name":"virtualstate/promise","owner":"virtualstate","description":"Async tools","archived":false,"fork":false,"pushed_at":"2024-06-14T09:44:11.000Z","size":516,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T23:14:30.367Z","etag":null,"topics":["async-await","async-iterables","deno","iterator-helpers","javascript","promise","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/virtualstate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-23T09:59:07.000Z","updated_at":"2022-07-29T10:03:52.000Z","dependencies_parsed_at":"2024-06-20T19:24:46.202Z","dependency_job_id":null,"html_url":"https://github.com/virtualstate/promise","commit_stats":null,"previous_names":[],"tags_count":109,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fpromise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fpromise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fpromise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fpromise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtualstate","download_url":"https://codeload.github.com/virtualstate/promise/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312135,"owners_count":21082638,"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":["async-await","async-iterables","deno","iterator-helpers","javascript","promise","typescript"],"created_at":"2024-09-24T14:10:01.652Z","updated_at":"2025-04-10T23:14:53.931Z","avatar_url":"https://github.com/virtualstate.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@virtualstate/promise`\n\n\u003e Psst... There is a blog post at [fabiancook.dev](https://fabiancook.dev/2022/02/26/an-async-thing) with details on how \n\u003e this project came to be, and the steps taken during implementation to define the included functionality. \n\n[//]: # (badges)\n\n### Support\n\n ![Node.js supported](https://img.shields.io/badge/node-%3E%3D16.0.0-blue) ![Deno supported](https://img.shields.io/badge/deno-%3E%3D1.17.0-blue) \n\n### Test Coverage\n\n ![96.23%25 lines covered](https://img.shields.io/badge/lines-96.23%25-brightgreen) ![96.23%25 statements covered](https://img.shields.io/badge/statements-96.23%25-brightgreen) ![92.81%25 functions covered](https://img.shields.io/badge/functions-92.81%25-brightgreen) ![93.06%25 branches covered](https://img.shields.io/badge/branches-93.06%25-brightgreen)\n\n[//]: # (badges)\n\n## `all`\n\n```typescript\nimport { all } from \"@virtualstate/promise\";\n\n// logs []\nconsole.log(await all());\n// logs [1, 2]\nconsole.log(await all(Promise.resolve(1), Promise.resolve(2)));\n// logs rejected\nconsole.log(\n    await all(Promise.resolve(1), Promise.reject(2))\n        .catch(() =\u003e \"rejected\")\n);\n```\n\n```typescript\n\nconst wait = (timeout = 1, arg = undefined) =\u003e new Promise(resolve =\u003e setTimeout(resolve, timeout, arg));\n\nfor await (const state of all(\n    wait(10, \"first index, second resolve\"),\n    wait(1, \"second index, first resolve\")\n)) {\n    /*\n    logs\n    { state: [undefined, \"second index, first resolve\"] }\n    { state: [\"first index, second resolve\", \"second index, first resolve\"] }\n     */\n    console.log({ state });\n}\n```\n\n\n## `allSettled`\n\n```typescript\nimport { allSettled } from \"@virtualstate/promise\";\n\n// logs []\nconsole.log(await allSettled());\n// logs [\n//   { value: 1, status: 'fulfilled' },\n//   { value: 2, status: 'fulfilled' }\n// ]\nconsole.log(await allSettled(Promise.resolve(1), Promise.resolve(2))); \n// logs [\n//   { value: 1, status: 'fulfilled' },\n//   { reason: 2, status: 'rejected' }\n// ]\nconsole.log(await allSettled(Promise.resolve(1), Promise.reject(2)));\n```\n\n```typescript\n\nconst wait = (timeout = 1, arg = undefined) =\u003e new Promise(resolve =\u003e setTimeout(resolve, timeout, arg));\n\nfor await (const state of allSettled(\n    wait(10, \"A\"), \n    wait(1, \"B\"),\n    wait(15).then(() =\u003e Promise.reject(\"C\"))\n)) {\n    /*\n    logs\n    {\n      state: [ undefined, { value: 'B', status: 'fulfilled' }, undefined ]\n    }\n    {\n      state: [\n        { value: 'A', status: 'fulfilled' },\n        { value: 'B', status: 'fulfilled' },\n        undefined\n      ]\n    }\n    {\n      state: [\n        { value: 'A', status: 'fulfilled' },\n        { value: 'B', status: 'fulfilled' },\n        { reason: 'C', status: 'rejected' }\n      ]\n    }\n     */\n    console.log({ state });\n}\n```\n\n## Contributing\n\nPlease see [Contributing](./CONTRIBUTING.md)\n\n## Code of Conduct\n\nThis project and everyone participating in it is governed by the [Code of Conduct listed here](./CODE-OF-CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [conduct@fabiancook.dev](mailto:conduct@fabiancook.dev).\n\n## Licence\n\nThis repository is licensed under the [MIT](https://choosealicense.com/licenses/mit/) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstate%2Fpromise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtualstate%2Fpromise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstate%2Fpromise/lists"}