Awesome Promises Overview
A curated list of useful resources for JavaScript Promises
🏠 Home · 🔥 Feed · 📮 Subscribe · ❤️ Sponsor · 😺 wbinnssmith/awesome-promises · ⭐ 1.5K · 🏷️ Programming Languages
Awesome Promises
A curated list of useful resources for JavaScript Promises
Inspired by the awesome (⭐223k) list thing. Not to be confused with other awesome promises like "I promise you a million dollars" or "I promise you'll stay fit and never have to go to the gym again".
Table of Contents
- Resources, Blogs, and Books
- Promises/A+ Implementations (ES6/ES2015 compatible)
- Convenience Utilities
Resources, Blogs, and Books
For beginners
- Promise Cookbook (⭐1.6k) - The why, what, and how. "A brief introduction [...] primarily aimed at frontend developers".
- Promises for Asynchronous Programming - Chapter from Exploring ES6
- You Don't Know JS: Promises (⭐160k) - Chapter from You Don't Know JS: Async & Performance (⭐160k)
- JavaScript Promises: an Introduction - Basics of JavaScript's native promise implementation.
- JavaScript with Promises - from O'Reilly. Short and to-the-point. Uses native and bluebird.
- Promise it won't hurt (⭐718) - An interactive nodeschool workshop
- ES6 Kata Promises - Promises Katas : Basics
- ES6 Promises in Depth
- An Incremental Tutorial on Promises - An FAQ styled tutorial for beginners.
Deep Dive
- Promise Fun (⭐4.1k) - @sindresorhus's notes, patterns, and solutions to common Promise problems
- You're Missing the Point of Promises - Promises are much more than callback aggregation, and that jQuery's implementation (prior to 3.0) isn't enough.
- We have a problem with promises - "Many of us are using promises without really understanding them."
- Promise anti-patterns (⭐20k) - Common misuses and how to avoid them.
- Promise anti-patterns (2) - Another set of promises anti-patterns
- Promise Ponderings, (Anti-)Patterns, and Apologies - Promise behaviour demonstrated and explained by common questions and their answers.
- Javascript Promises...In Wicked Detail - Recreate the promise implementation
- Writing Promise-Using Specifications - "This document gives guidance on how to write specifications that create, accept, or manipulate promises"
- Async functions - making promises friendly
References
- Promises/A+ specification
- caniuse promises
- Fates and States (⭐1.2k) - Quick definitions of possible states.
- Promisees - Promise visualization playground for the adventurous.
Promises/A+ Implementations (ES6/ES2015 compatible)
Strict Implementations
These implement no more or less than the es6 spec. They make great polyfills and are exceptionally compatible with native promises.
- pinkie (⭐138) - Ponyfill. Node-oriented, but browserifyable (⭐14k). Extremely small implementation.
- native-promise-only (⭐719) - Polyfill. Browser and node-compatible.
- es6-promise (⭐7.3k) - Opt-in polyfill. A strict-spec subset of rsvp.js.
- lie (⭐744) - Small, browserifyable with an opt-in polyfill.
Implementations with extras
All of these provide more features than the language yet remain compatible. Node + Browsers for all.
- bluebird (⭐20k) - Fully featured, extremely performant. Long stack traces & generator/coroutine support.
- creed (⭐270) - Hyper performant & full featured like Bluebird, but FP-oriented. Coroutines, generators, promises, ES2015 iterables, & fantasy-land spec.
- rsvp.js (⭐3.6k) - Lightweight with a few extras. Compatible down to IE6!
- Q (⭐15k) - One of the original implementations. Long stack traces and other goodies.
- then/promise (⭐2.5k) - Small with
nodeify
,denodify
anddone()
additions. - when.js (⭐3.4k) - Packed with control flow, functional, and utility methods.
Fallbacks
- native-or-bluebird - Helps transition to completely native.
- pinkie-promise (⭐120) - Use native, or fall back to
pinkie
. Great for node library authors. - any-promise (⭐179) - Loads the first available implementation. Safe for browserify.
Convenience Utilities
Native and strictly spec-compliant promises are awesome for compatibility, future-proofness, library authors, and browsers. However, libraries like bluebird patch goodies onto the Promise
constructor and prototype. Solution? tiny modules of course!
sindresorhus's many Promise utilities (see notes (⭐4.1k))
- delay (⭐516) - Delay a promise a specified amount of time.
- pify (⭐1.5k) - Promisify ("denodify") a callback-style function.
- loud-rejection (⭐282) - Make unhandled promise rejections fail loudly instead of the default silent fail.
- hard-rejection (⭐102) - Make unhandled promise rejections fail hard right away instead of the default silent fail
- p-queue (⭐2.3k) - Promise queue with concurrency control
- p-break (⭐19) - Break out of a promise chain
- p-lazy (⭐247) - Create a lazy promise that defers execution until
.then()
or.catch()
is called - p-defer (⭐58) - Create a deferred promise
- p-if (⭐62) - Conditional promise chains
- p-tap (⭐132) - Tap into a promise chain without affecting its value or state
- p-map (⭐910) - Map over promises concurrently
- p-all (⭐212) - Run promise-returning & async functions concurrently with optional limited concurrency
- p-limit (⭐1.1k) - Run multiple promise-returning & async functions with limited concurrency
- p-times (⭐35) - Run promise-returning & async functions a specific number of times concurrently
- p-catch-if (⭐38) - Conditional promise catch handler
- p-time (⭐65) - Measure the time a promise takes to resolve
- p-log (⭐25) - Log the value/error of a promise
- p-filter (⭐62) - Filter promises concurrently
- p-settle (⭐81) - Settle promises concurrently and get their fulfillment value or rejection reason
- p-memoize (⭐312) - Memoize promise-returning & async functions
- p-whilst (⭐45) - Calls a function repeatedly while a condition returns true and then resolves the promise
- p-throttle (⭐289) - Throttle promise-returning & async functions
- p-debounce (⭐152) - Debounce promise-returning & async functions
- p-retry (⭐569) - Retry a promise-returning or async function
- p-wait-for (⭐121) - Wait for a condition to be true
- p-timeout (⭐205) - Timeout a promise after a specified amount of time
- p-race (⭐36) - A better
Promise.race()
- p-try (⭐42) -
Promise#try()
ponyfill - Starts a promise chain - p-finally (⭐47) -
Promise#finally()
ponyfill - Invoked when the promise is settled regardless of outcome - p-any (⭐53) - Wait for any promise to be fulfilled
- p-some (⭐34) - Wait for a specified number of promises to be fulfilled
- p-pipe (⭐109) - Compose promise-returning & async functions into a reusable pipeline
- p-each-series (⭐46) - Iterate over promises serially
- p-map-series (⭐44) - Map over promises serially
- p-reduce (⭐64) - Reduce a list of values using promises into a promise for a value
- p-props (⭐168) - Like
Promise.all()
but forMap
andObject
Others
- promise-method (⭐2) - Standalone
bluebird.method
. Turn a synchronously-returning method into a promise-returning one. - is-promise (⭐275) - Determine if something looks like a Promise.
- sprom (⭐14) - Resolve when a stream ends. Optional buffering (be careful with this!)
- task.js (⭐1.6k) - Write async functions in a blocking style using promises and generators. Like
bluebird.coroutine
. - co (⭐12k) - Like
task.js
andbluebird.coroutine
, but supports thunks too. - lie-fs - Promise wrappers for Node's FS API.
- promise-do-until (⭐1) - Calls a function repeatedly until a condition returns true and then resolves the promise.
- promise-do-whilst (⭐3) - Calls a function repeatedly while a condition returns true and then resolves the promise.
- promise-semaphore (⭐29) - Push a set of work to be done in a configurable serial fashion
- promise-nodeify (⭐1) - Standalone
nodeify
method which calls a Node-style callback on resolution or rejection.
License
Licensed under the Creative Commons CC0 License.