{"id":13448024,"url":"https://github.com/sindresorhus/promise-fun","last_synced_at":"2025-09-27T10:31:08.545Z","repository":{"id":40477433,"uuid":"71446428","full_name":"sindresorhus/promise-fun","owner":"sindresorhus","description":"Promise packages, patterns, chat, and tutorials","archived":false,"fork":false,"pushed_at":"2024-04-25T09:36:15.000Z","size":46,"stargazers_count":5030,"open_issues_count":2,"forks_count":135,"subscribers_count":86,"default_branch":"main","last_synced_at":"2025-09-18T18:53:21.983Z","etag":null,"topics":["async","async-await","async-functions","awesome","awesome-list","concurrency","iteration","javascript","list","nodejs","polyfill","ponyfill","promise","promise-library","promise-modules","promise-patterns","promise-queue","promises","resources","unicorns"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","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":null,"license":"license","code_of_conduct":null,"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},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2016-10-20T09:23:43.000Z","updated_at":"2025-09-18T11:49:32.000Z","dependencies_parsed_at":"2025-04-27T11:15:17.254Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/promise-fun","commit_stats":{"total_commits":37,"total_committers":7,"mean_commits":5.285714285714286,"dds":0.2432432432432432,"last_synced_commit":"96222bb8e778a8d686375e8ee1595ec009544eb1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sindresorhus/promise-fun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpromise-fun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpromise-fun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpromise-fun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpromise-fun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/promise-fun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpromise-fun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275936049,"owners_count":25555745,"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","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","async-await","async-functions","awesome","awesome-list","concurrency","iteration","javascript","list","nodejs","polyfill","ponyfill","promise","promise-library","promise-modules","promise-patterns","promise-queue","promises","resources","unicorns"],"created_at":"2024-07-31T05:01:33.577Z","updated_at":"2025-09-27T10:31:08.508Z","avatar_url":"https://github.com/sindresorhus.png","language":null,"funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","miscellaneous","Others","包","📦 Legacy \u0026 Inactive Projects","Promises","Programming Language Lists","Control flow","JavaScript","目录","awesome-list","Resources, Blogs, and Books"],"sub_categories":["Control flow","流程控制","JavaScript Lists","Toolkit","控制流","Deep Dive"],"readme":"# promise-fun\n\nI intend to use this space to document my promise modules, useful promise patterns, and how to solve common problems. For now though, you can see all my promise modules below.\n\n## Contents\n\n- [Packages](#packages)\n- [FAQ](#faq)\n\n## Packages\n\n*Not accepting additions, but happy to take requests.*\n\n- **[pify](https://github.com/sindresorhus/pify)**: Promisify a callback-style function\n- **[delay](https://github.com/sindresorhus/delay)**: Delay a promise a specified amount of time\n- **[yoctodelay](https://github.com/sindresorhus/yoctodelay)**: Delay a promise a specified amount of time\n- **[p-map](https://github.com/sindresorhus/p-map)**: Map over promises concurrently\n- **[p-all](https://github.com/sindresorhus/p-all)**: Run promise-returning \u0026 async functions concurrently with optional limited concurrency\n- **[p-event](https://github.com/sindresorhus/p-event)**: Promisify an event by waiting for it to be emitted\n- **[p-debounce](https://github.com/sindresorhus/p-debounce)**: Debounce promise-returning \u0026 async functions\n- **[p-throttle](https://github.com/sindresorhus/p-throttle)**: Throttle promise-returning \u0026 async functions\n- **[p-timeout](https://github.com/sindresorhus/p-timeout)**: Timeout a promise after a specified amount of time\n- **[p-retry](https://github.com/sindresorhus/p-retry)**: Retry a promise-returning or async function\n- **[p-any](https://github.com/sindresorhus/p-any)**: Wait for any promise to be fulfilled\n- **[p-some](https://github.com/sindresorhus/p-some)**: Wait for a specified number of promises to be fulfilled\n- **[p-mutex](https://github.com/sindresorhus/p-mutex)**: Ensure that only one operation accesses a particular resource at a time\n- **[p-locate](https://github.com/sindresorhus/p-locate)**: Get the first fulfilled promise that satisfies the provided testing function\n- **[p-limit](https://github.com/sindresorhus/p-limit)**: Run multiple promise-returning \u0026 async functions with limited concurrency\n- **[p-series](https://github.com/sindresorhus/p-series)**: Run promise-returning \u0026 async functions in series\n- **[p-memoize](https://github.com/sindresorhus/p-memoize)**: Memoize promise-returning \u0026 async functions\n- **[p-pipe](https://github.com/sindresorhus/p-pipe)**: Compose promise-returning \u0026 async functions into a reusable pipeline\n- **[p-props](https://github.com/sindresorhus/p-props)**: Like `Promise.all()` but for `Map` and `Object`\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-cancelable](https://github.com/sindresorhus/p-cancelable)**: Create a promise that can be canceled\n- **[p-progress](https://github.com/sindresorhus/p-progress)**: Create a promise that reports progress\n- **[p-reflect](https://github.com/sindresorhus/p-reflect)**: Make a promise always fulfill with its actual fulfillment value or rejection reason\n- **[p-filter](https://github.com/sindresorhus/p-filter)**: Filter promises concurrently\n- **[p-reduce](https://github.com/sindresorhus/p-reduce)**: Reduce a list of values using promises into a promise for a value\n- **[p-settle](https://github.com/sindresorhus/p-settle)**: Settle promises concurrently and get their fulfillment value or rejection reason with optional limited concurrency\n- **[p-map-series](https://github.com/sindresorhus/p-map-series)**: Map over promises serially\n- **[p-each-series](https://github.com/sindresorhus/p-each-series)**: Iterate over promises serially\n- **[p-times](https://github.com/sindresorhus/p-times)**: Run promise-returning \u0026 async functions a specific number of times concurrently\n- **[p-lazy](https://github.com/sindresorhus/p-lazy)**: Create a lazy promise that defers execution until `.then()` or `.catch()` is called\n- **[p-whilst](https://github.com/sindresorhus/p-whilst)**: While a condition returns true, calls a function repeatedly, and then resolves the promise\n- **[p-do-whilst](https://github.com/sindresorhus/p-do-whilst)**: Calls a function repeatedly while a condition returns true and then resolves the promise\n- **[p-forever](https://github.com/sindresorhus/p-forever)**: Run promise-returning \u0026 async functions repeatedly until you end it\n- **[p-wait-for](https://github.com/sindresorhus/p-wait-for)**: Wait for a condition to be true\n- **[p-min-delay](https://github.com/sindresorhus/p-min-delay)**: Delay a promise a minimum amount of time\n- **[p-try](https://github.com/sindresorhus/p-try)**: `Promise.try()` ponyfill - Starts a promise chain\n- **[p-race](https://github.com/sindresorhus/p-race)**: A better `Promise.race()`\n- **[p-immediate](https://github.com/sindresorhus/p-immediate)**: Returns a promise resolved in the next event loop - think `setImmediate()`\n- **[p-time](https://github.com/sindresorhus/p-time)**: Measure the time a promise takes to resolve\n- **[p-defer](https://github.com/sindresorhus/p-defer)**: Create a deferred promise\n- **[p-is-promise](https://github.com/sindresorhus/p-is-promise)**: Check if something is a promise\n- **[p-state](https://github.com/sindresorhus/p-state)**: Inspect the state of a promise\n- **[p-queue](https://github.com/sindresorhus/p-queue)**: Promise queue with concurrency control\n- **[make-synchronous](https://github.com/sindresorhus/make-synchronous)**: Make an asynchronous function synchronous\n\n### `.then`/`.catch`-based packages\n\n*You should generally avoid using `.then` except in edge cases.*\n\n- **[p-catch-if](https://github.com/sindresorhus/p-catch-if)**: Conditional promise catch handler\n- **[p-if](https://github.com/sindresorhus/p-if)**: Conditional promise chains\n- **[p-tap](https://github.com/sindresorhus/p-tap)**: Tap into a promise chain without affecting its value or state\n- **[p-log](https://github.com/sindresorhus/p-log)**: Log the value/error of a promise\n- **[p-break](https://github.com/sindresorhus/p-break)**: Break out of a promise chain\n\n## FAQ\n\n### How can I run 100 async/promise-returning functions with only 5 running at once?\n\nThis is a good use-case for [`p-map`](https://github.com/sindresorhus/p-map). You might ask why you can't just specify an array of promises. Promises represent values of a computation and not the computation itself - they are eager. So by the time `p-map` starts reading the array, all the actions creating those promises have already started running. `p-map` works by executing a promise-returning function in a mapper function. This way the promises are created lazily and can be concurrency limited. Check out [`p-all`](https://github.com/sindresorhus/p-all) instead if you're using different functions to get each promise.\n\n```js\nimport pMap from 'p-map';\n\nconst urls = [\n\t'https://sindresorhus.com',\n\t'https://avajs.dev',\n\t'https://github.com',\n\t…\n];\n\nconsole.log(urls.length);\n//=\u003e 100\n\nconst mapper = url =\u003e fetchStats(url); //=\u003e Promise\n\nconst result = await pMap(urls, mapper, {concurrency: 5});\n\nconsole.log(result);\n//=\u003e [{url: 'https://sindresorhus.com', stats: {…}}, …]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fpromise-fun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fpromise-fun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fpromise-fun/lists"}