All Projects → sindresorhus → Promise Fun

sindresorhus / Promise Fun

Licence: cc0-1.0
Promise packages, patterns, chat, and tutorials

Projects that are alternatives of or similar to Promise Fun

P Map
Map over promises concurrently
Stars: ✭ 639 (-83.09%)
Mutual labels:  async, promise, concurrency, async-await, promises
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (-96.19%)
Mutual labels:  async, promise, concurrency, promises
Tickedoff
Tiny library (<200B gzip) for deferring something by a "tick"
Stars: ✭ 213 (-94.36%)
Mutual labels:  async, promise, polyfill, ponyfill
Ava
Node.js test runner that lets you develop with confidence 🚀
Stars: ✭ 19,458 (+414.9%)
Mutual labels:  async, concurrency, unicorns, async-functions
Hydra
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift
Stars: ✭ 1,954 (-48.29%)
Mutual labels:  async, promises, promise-library
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-96.22%)
Mutual labels:  async, promise, async-await
Kitsu
🦊 A simple, lightweight & framework agnostic JSON:API client
Stars: ✭ 166 (-95.61%)
Mutual labels:  async, promise, async-await
Await Of
await wrapper for easier errors handling without try-catch
Stars: ✭ 240 (-93.65%)
Mutual labels:  async, promise, async-await
Jdeferred
Java Deferred/Promise library similar to JQuery.
Stars: ✭ 1,483 (-60.76%)
Mutual labels:  async, promise, promise-library
Redux Promise Middleware
Enables simple, yet robust handling of async action creators in Redux
Stars: ✭ 2,001 (-47.05%)
Mutual labels:  async, promises, async-functions
typescript-async
Creating Asynchronous Code with TypeScript
Stars: ✭ 44 (-98.84%)
Mutual labels:  promises, async-functions, async-await
Asynquence
Asynchronous flow control (promises, generators, observables, CSP, etc)
Stars: ✭ 1,737 (-54.04%)
Mutual labels:  async, async-await, promises
Functional Promises
Write code like a story w/ a powerful Fluent (function chaining) API
Stars: ✭ 141 (-96.27%)
Mutual labels:  async, promise, promises
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (-96.48%)
Mutual labels:  async, promise, async-await
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-99.47%)
Mutual labels:  promises, promise, concurrency
conquerant
lightweight async/await for Clojure
Stars: ✭ 31 (-99.18%)
Mutual labels:  promise, concurrency, async-await
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-99.44%)
Mutual labels:  promise, promise-library, async-await
awesome-oss-alternatives
Awesome list of open-source startup alternatives to well-known SaaS products 🚀
Stars: ✭ 3,579 (-5.29%)
Mutual labels:  list, unicorns, resources
Radon
Object oriented state management solution for front-end development.
Stars: ✭ 80 (-97.88%)
Mutual labels:  async, async-await, promises
Swimmer
🏊 Swimmer - An async task pooling and throttling utility for JS
Stars: ✭ 94 (-97.51%)
Mutual labels:  async, concurrency, promises

promise-fun

I 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.

Contents

Packages

Not accepting additions, but happy to take requests.

  • pify: Promisify a callback-style function
  • delay: Delay a promise a specified amount of time
  • yoctodelay: Delay a promise a specified amount of time
  • p-map: Map over promises concurrently
  • p-all: Run promise-returning & async functions concurrently with optional limited concurrency
  • p-queue: Promise queue with concurrency control
  • p-event: Promisify an event by waiting for it to be emitted
  • p-debounce: Debounce promise-returning & async functions
  • p-throttle: Throttle promise-returning & async functions
  • p-timeout: Timeout a promise after a specified amount of time
  • p-retry: Retry a promise-returning or async function
  • p-any: Wait for any promise to be fulfilled
  • p-some: Wait for a specified number of promises to be fulfilled
  • p-locate: Get the first fulfilled promise that satisfies the provided testing function
  • p-limit: Run multiple promise-returning & async functions with limited concurrency
  • p-series: Run promise-returning & async functions in series
  • p-memoize: Memoize promise-returning & async functions
  • p-pipe: Compose promise-returning & async functions into a reusable pipeline
  • p-props: Like Promise.all() but for Map and Object
  • p-waterfall: Run promise-returning & async functions in series, each passing its result to the next
  • p-cancelable: Create a promise that can be canceled
  • p-progress: Create a promise that reports progress
  • p-reflect: Make a promise always fulfill with its actual fulfillment value or rejection reason
  • p-filter: Filter promises concurrently
  • p-reduce: Reduce a list of values using promises into a promise for a value
  • p-settle: Settle promises concurrently and get their fulfillment value or rejection reason
  • p-every: Test whether all promises passes a testing function
  • p-one: Test whether some promise passes a testing function
  • p-map-series: Map over promises serially
  • p-each-series: Iterate over promises serially
  • p-times: Run promise-returning & async functions a specific number of times concurrently
  • p-lazy: Create a lazy promise that defers execution until .then() or .catch() is called
  • p-whilst: While a condition returns true, calls a function repeatedly, and then resolves the promise
  • p-do-whilst: Calls a function repeatedly while a condition returns true and then resolves the promise
  • p-forever: Run promise-returning & async functions repeatedly until you end it
  • p-wait-for: Wait for a condition to be true
  • p-min-delay: Delay a promise a minimum amount of time
  • p-try: Promise.try() ponyfill - Starts a promise chain
  • p-race: A better Promise.race()
  • p-immediate: Returns a promise resolved in the next event loop - think setImmediate()
  • p-time: Measure the time a promise takes to resolve
  • p-defer: Create a deferred promise
  • p-is-promise: Check if something is a promise
  • p-state: Inspect the state of a promise
  • make-synchronous: Make an asynchronous function synchronous

.then/.catch-based packages

You should generally avoid using .then except in edge cases.

  • p-catch-if: Conditional promise catch handler
  • p-if: Conditional promise chains
  • p-tap: Tap into a promise chain without affecting its value or state
  • p-log: Log the value/error of a promise
  • p-break: Break out of a promise chain

FAQ

How can I run 100 async/promise-returning functions with only 5 running at once?

This is a good use-case for 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 instead if you're using different functions to get each promise.

const pMap = require('p-map');

const urls = [
	'https://sindresorhus.com',
	'https://avajs.dev',
	'https://github.com',
	
];

console.log(urls.length);
//=> 100

const mapper = url => fetchStats(url); //=> Promise

const result = await pMap(urls, mapper, {concurrency: 5});

console.log(result);
//=> [{url: 'https://sindresorhus.com', stats: {…}}, …]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].