302 lines
14 KiB
HTML
302 lines
14 KiB
HTML
<p><a href="https://promisesaplus.com/">
|
||
<img src="https://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo" align="right" />
|
||
</a></p>
|
||
<h1 id="awesome-promises-awesome">Awesome Promises <a
|
||
href="https://github.com/sindresorhus/awesome"><img
|
||
src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg"
|
||
alt="Awesome" /></a></h1>
|
||
<blockquote>
|
||
<p>A curated list of useful resources for JavaScript Promises</p>
|
||
</blockquote>
|
||
<p>Inspired by the <a
|
||
href="https://github.com/sindresorhus/awesome">awesome</a> 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”.</p>
|
||
<p><strong>Table of Contents</strong></p>
|
||
<ul>
|
||
<li><a href="#resources-blogs-and-books">Resources, Blogs, and
|
||
Books</a></li>
|
||
<li><a
|
||
href="#promisesa-implementations-es6es2015-compatible">Promises/A+
|
||
Implementations (ES6/ES2015 compatible)</a>
|
||
<ul>
|
||
<li><a href="#strict-implementations">Strict Implementations</a></li>
|
||
<li><a href="#implementations-with-extras">Implementations with
|
||
extras</a></li>
|
||
<li><a href="#fallbacks">Fallbacks</a></li>
|
||
</ul></li>
|
||
<li><a href="#convenience-utilities">Convenience Utilities</a></li>
|
||
</ul>
|
||
<h2 id="resources-blogs-and-books">Resources, Blogs, and Books</h2>
|
||
<h3 id="for-beginners">For beginners</h3>
|
||
<ul>
|
||
<li><a href="https://github.com/mattdesl/promise-cookbook">Promise
|
||
Cookbook</a> - The why, what, and how. “A brief introduction […]
|
||
primarily aimed at frontend developers”.</li>
|
||
<li><a href="http://exploringjs.com/es6/ch_promises.html">Promises for
|
||
Asynchronous Programming</a> - Chapter from <a
|
||
href="http://exploringjs.com/">Exploring ES6</a></li>
|
||
<li><a
|
||
href="https://github.com/getify/You-Dont-Know-JS/blob/master/async%20&%20performance/ch3.md">You
|
||
Don’t Know JS: Promises</a> - Chapter from <a
|
||
href="https://github.com/getify/You-Dont-Know-JS/tree/master/async%20%26%20performance">You
|
||
Don’t Know JS: Async & Performance</a></li>
|
||
<li><a
|
||
href="https://developers.google.com/web/fundamentals/getting-started/primers/promises">JavaScript
|
||
Promises: an Introduction</a> - Basics of JavaScript’s native promise
|
||
implementation.</li>
|
||
<li><a
|
||
href="http://shop.oreilly.com/product/0636920032151.do">JavaScript with
|
||
Promises</a> - from O’Reilly. Short and to-the-point. Uses native and
|
||
bluebird.</li>
|
||
<li><a href="https://github.com/stevekane/promise-it-wont-hurt">Promise
|
||
it won’t hurt</a> - An interactive <a
|
||
href="https://nodeschool.io/">nodeschool</a> workshop</li>
|
||
<li><a href="http://es6katas.org/">ES6 Kata Promises</a> - Promises
|
||
Katas : <a
|
||
href="http://tddbin.com/#?kata=es6/language/promise/basics">Basics</a></li>
|
||
<li><a href="https://ponyfoo.com/articles/es6-promises-in-depth">ES6
|
||
Promises in Depth</a></li>
|
||
<li><a
|
||
href="http://www.sohamkamani.com/blog/2016/08/28/incremenal-tutorial-to-promises/">An
|
||
Incremental Tutorial on Promises</a> - An FAQ styled tutorial for
|
||
beginners.</li>
|
||
</ul>
|
||
<h3 id="deep-dive">Deep Dive</h3>
|
||
<ul>
|
||
<li><a href="https://github.com/sindresorhus/promise-fun">Promise
|
||
Fun</a> - <span class="citation"
|
||
data-cites="sindresorhus">@sindresorhus</span>’s notes, patterns, and
|
||
solutions to common Promise problems</li>
|
||
<li><a
|
||
href="https://blog.domenic.me/youre-missing-the-point-of-promises/">You’re
|
||
Missing the Point of Promises</a> - Promises are much more than callback
|
||
aggregation, and that jQuery’s implementation (prior to 3.0) isn’t
|
||
enough.</li>
|
||
<li><a
|
||
href="https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html">We
|
||
have a problem with promises</a> - “Many of us are using promises
|
||
without really understanding them.”</li>
|
||
<li><a
|
||
href="https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns">Promise
|
||
anti-patterns</a> - Common misuses and how to avoid them.</li>
|
||
<li><a href="http://taoofcode.net/promise-anti-patterns/">Promise
|
||
anti-patterns (2)</a> - Another set of promises anti-patterns</li>
|
||
<li><a
|
||
href="https://sdgluck.github.io/2015/08/24/promise-ponderings-patterns-apologies/">Promise
|
||
Ponderings, (Anti-)Patterns, and Apologies</a> - Promise behaviour
|
||
demonstrated and explained by common questions and their answers.</li>
|
||
<li><a
|
||
href="http://www.mattgreer.org/articles/promises-in-wicked-detail/">Javascript
|
||
Promises…In Wicked Detail</a> - Recreate the promise implementation</li>
|
||
<li><a href="https://www.w3.org/2001/tag/doc/promises-guide">Writing
|
||
Promise-Using Specifications</a> - “This document gives guidance on how
|
||
to write specifications that create, accept, or manipulate
|
||
promises”</li>
|
||
<li><a
|
||
href="https://developers.google.com/web/fundamentals/getting-started/primers/async-functions">Async
|
||
functions - making promises friendly</a></li>
|
||
</ul>
|
||
<h3 id="references">References</h3>
|
||
<ul>
|
||
<li><a href="https://promisesaplus.com/">Promises/A+
|
||
specification</a></li>
|
||
<li><a href="http://caniuse.com/#feat=promises">caniuse
|
||
promises</a></li>
|
||
<li><a
|
||
href="https://github.com/domenic/promises-unwrapping/blob/master/docs/states-and-fates.md">Fates
|
||
and States</a> - Quick definitions of possible states.</li>
|
||
<li><a href="https://bevacqua.github.io/promisees/">Promisees</a> -
|
||
Promise visualization playground for the adventurous.</li>
|
||
</ul>
|
||
<h2 id="promisesa-implementations-es6es2015-compatible">Promises/A+
|
||
Implementations (ES6/ES2015 compatible)</h2>
|
||
<h3 id="strict-implementations">Strict Implementations</h3>
|
||
<p>These implement no more or less than the es6 spec. They make great
|
||
polyfills and are exceptionally compatible with native promises.</p>
|
||
<ul>
|
||
<li><a href="https://github.com/floatdrop/pinkie">pinkie</a> - Ponyfill.
|
||
Node-oriented, but <a
|
||
href="https://github.com/substack/node-browserify">browserifyable</a>.
|
||
<em>Extremely</em> small implementation.</li>
|
||
<li><a
|
||
href="https://github.com/getify/native-promise-only">native-promise-only</a>
|
||
- Polyfill. Browser and node-compatible.</li>
|
||
<li><a
|
||
href="https://github.com/stefanpenner/es6-promise">es6-promise</a> -
|
||
Opt-in polyfill. A strict-spec subset of rsvp.js.</li>
|
||
<li><a href="https://github.com/calvinmetcalf/lie">lie</a> - Small,
|
||
browserifyable with an opt-in polyfill.</li>
|
||
</ul>
|
||
<h3 id="implementations-with-extras">Implementations with extras</h3>
|
||
<p>All of these provide more features than the language yet remain
|
||
compatible. Node + Browsers for all.</p>
|
||
<ul>
|
||
<li><a href="https://github.com/petkaantonov/bluebird">bluebird</a> -
|
||
Fully featured, extremely performant. Long stack traces &
|
||
generator/coroutine support.</li>
|
||
<li><a href="https://github.com/briancavalier/creed">creed</a> - Hyper
|
||
performant & full featured like Bluebird, but FP-oriented.
|
||
Coroutines, generators, promises, ES2015 iterables, & fantasy-land
|
||
spec.</li>
|
||
<li><a href="https://github.com/tildeio/rsvp.js/">rsvp.js</a> -
|
||
Lightweight with a few extras. Compatible down to IE6!</li>
|
||
<li><a href="https://github.com/kriskowal/q">Q</a> - One of the original
|
||
implementations. Long stack traces and other goodies.</li>
|
||
<li><a href="https://github.com/then/promise">then/promise</a> - Small
|
||
with <code>nodeify</code>, <code>denodify</code> and <code>done()</code>
|
||
additions.</li>
|
||
<li><a href="https://github.com/cujojs/when">when.js</a> - Packed with
|
||
control flow, functional, and utility methods.</li>
|
||
</ul>
|
||
<h3 id="fallbacks">Fallbacks</h3>
|
||
<ul>
|
||
<li><a
|
||
href="https://www.npmjs.com/package/native-or-bluebird">native-or-bluebird</a>
|
||
- Helps transition to completely native.</li>
|
||
<li><a
|
||
href="https://github.com/floatdrop/pinkie-promise">pinkie-promise</a> -
|
||
Use native, or fall back to <code>pinkie</code>. Great for node library
|
||
authors.</li>
|
||
<li><a href="https://github.com/kevinbeaty/any-promise">any-promise</a>
|
||
- Loads the first available implementation. Safe for browserify.</li>
|
||
</ul>
|
||
<h2 id="convenience-utilities">Convenience Utilities</h2>
|
||
<p>Native and strictly spec-compliant promises are awesome for
|
||
compatibility, future-proofness, library authors, and browsers. However,
|
||
libraries like bluebird patch goodies onto the <code>Promise</code>
|
||
constructor and prototype. Solution? tiny modules of course!</p>
|
||
<h3 id="sindresorhuss-many-promise-utilities-see-notes">sindresorhus’s
|
||
many Promise utilities (<a
|
||
href="https://github.com/sindresorhus/promise-fun">see notes</a>)</h3>
|
||
<ul>
|
||
<li><a href="https://github.com/sindresorhus/delay">delay</a> - Delay a
|
||
promise a specified amount of time.</li>
|
||
<li><a href="https://github.com/sindresorhus/pify">pify</a> - Promisify
|
||
(“denodify”) a callback-style function.</li>
|
||
<li><a
|
||
href="https://github.com/sindresorhus/loud-rejection">loud-rejection</a>
|
||
- Make unhandled promise rejections fail loudly instead of the default
|
||
silent fail.</li>
|
||
<li><a
|
||
href="https://github.com/sindresorhus/hard-rejection">hard-rejection</a>
|
||
- Make unhandled promise rejections fail hard right away instead of the
|
||
default silent fail</li>
|
||
<li><a href="https://github.com/sindresorhus/p-queue">p-queue</a> -
|
||
Promise queue with concurrency control</li>
|
||
<li><a href="https://github.com/sindresorhus/p-break">p-break</a> -
|
||
Break out of a promise chain</li>
|
||
<li><a href="https://github.com/sindresorhus/p-lazy">p-lazy</a> - Create
|
||
a lazy promise that defers execution until <code>.then()</code> or
|
||
<code>.catch()</code> is called</li>
|
||
<li><a href="https://github.com/sindresorhus/p-defer">p-defer</a> -
|
||
Create a deferred promise</li>
|
||
<li><a href="https://github.com/sindresorhus/p-if">p-if</a> -
|
||
Conditional promise chains</li>
|
||
<li><a href="https://github.com/sindresorhus/p-tap">p-tap</a> - Tap into
|
||
a promise chain without affecting its value or state</li>
|
||
<li><a href="https://github.com/sindresorhus/p-map">p-map</a> - Map over
|
||
promises concurrently</li>
|
||
<li><a href="https://github.com/sindresorhus/p-all">p-all</a> - Run
|
||
promise-returning & async functions concurrently with optional
|
||
limited concurrency</li>
|
||
<li><a href="https://github.com/sindresorhus/p-limit">p-limit</a> - Run
|
||
multiple promise-returning & async functions with limited
|
||
concurrency</li>
|
||
<li><a href="https://github.com/sindresorhus/p-times">p-times</a> - Run
|
||
promise-returning & async functions a specific number of times
|
||
concurrently</li>
|
||
<li><a href="https://github.com/sindresorhus/p-catch-if">p-catch-if</a>
|
||
- Conditional promise catch handler</li>
|
||
<li><a href="https://github.com/sindresorhus/p-time">p-time</a> -
|
||
Measure the time a promise takes to resolve</li>
|
||
<li><a href="https://github.com/sindresorhus/p-log">p-log</a> - Log the
|
||
value/error of a promise</li>
|
||
<li><a href="https://github.com/sindresorhus/p-filter">p-filter</a> -
|
||
Filter promises concurrently</li>
|
||
<li><a href="https://github.com/sindresorhus/p-settle">p-settle</a> -
|
||
Settle promises concurrently and get their fulfillment value or
|
||
rejection reason</li>
|
||
<li><a href="https://github.com/sindresorhus/p-memoize">p-memoize</a> -
|
||
Memoize promise-returning & async functions</li>
|
||
<li><a href="https://github.com/sindresorhus/p-whilst">p-whilst</a> -
|
||
Calls a function repeatedly while a condition returns true and then
|
||
resolves the promise</li>
|
||
<li><a href="https://github.com/sindresorhus/p-throttle">p-throttle</a>
|
||
- Throttle promise-returning & async functions</li>
|
||
<li><a href="https://github.com/sindresorhus/p-debounce">p-debounce</a>
|
||
- Debounce promise-returning & async functions</li>
|
||
<li><a href="https://github.com/sindresorhus/p-retry">p-retry</a> -
|
||
Retry a promise-returning or async function</li>
|
||
<li><a href="https://github.com/sindresorhus/p-wait-for">p-wait-for</a>
|
||
- Wait for a condition to be true</li>
|
||
<li><a href="https://github.com/sindresorhus/p-timeout">p-timeout</a> -
|
||
Timeout a promise after a specified amount of time</li>
|
||
<li><a href="https://github.com/sindresorhus/p-race">p-race</a> - A
|
||
better <code>Promise.race()</code></li>
|
||
<li><a href="https://github.com/sindresorhus/p-try">p-try</a> -
|
||
<code>Promise#try()</code> ponyfill - Starts a promise chain</li>
|
||
<li><a href="https://github.com/sindresorhus/p-finally">p-finally</a> -
|
||
<code>Promise#finally()</code> ponyfill - Invoked when the promise is
|
||
settled regardless of outcome</li>
|
||
<li><a href="https://github.com/sindresorhus/p-any">p-any</a> - Wait for
|
||
any promise to be fulfilled</li>
|
||
<li><a href="https://github.com/sindresorhus/p-some">p-some</a> - Wait
|
||
for a specified number of promises to be fulfilled</li>
|
||
<li><a href="https://github.com/sindresorhus/p-pipe">p-pipe</a> -
|
||
Compose promise-returning & async functions into a reusable
|
||
pipeline</li>
|
||
<li><a
|
||
href="https://github.com/sindresorhus/p-each-series">p-each-series</a> -
|
||
Iterate over promises serially</li>
|
||
<li><a
|
||
href="https://github.com/sindresorhus/p-map-series">p-map-series</a> -
|
||
Map over promises serially</li>
|
||
<li><a href="https://github.com/sindresorhus/p-reduce">p-reduce</a> -
|
||
Reduce a list of values using promises into a promise for a value</li>
|
||
<li><a href="https://github.com/sindresorhus/p-props">p-props</a> - Like
|
||
<code>Promise.all()</code> but for <code>Map</code> and
|
||
<code>Object</code></li>
|
||
</ul>
|
||
<h3 id="others">Others</h3>
|
||
<ul>
|
||
<li><a
|
||
href="https://github.com/wbinnssmith/promise-method">promise-method</a>
|
||
- Standalone <code>bluebird.method</code>. Turn a
|
||
synchronously-returning method into a promise-returning one.</li>
|
||
<li><a href="https://github.com/then/is-promise">is-promise</a> -
|
||
Determine if something looks like a Promise.</li>
|
||
<li><a href="https://github.com/then/sprom">sprom</a> - Resolve when a
|
||
stream ends. Optional buffering (be careful with this!)</li>
|
||
<li><a href="https://github.com/mozilla/task.js">task.js</a> - Write
|
||
async functions in a blocking style using promises and generators. Like
|
||
<code>bluebird.coroutine</code>.</li>
|
||
<li><a href="https://github.com/tj/co">co</a> - Like
|
||
<code>task.js</code> and <code>bluebird.coroutine</code>, but supports
|
||
thunks too.</li>
|
||
<li><a href="https://www.npmjs.com/package/lie-fs">lie-fs</a> - Promise
|
||
wrappers for Node’s FS API.</li>
|
||
<li><a
|
||
href="https://github.com/busterc/promise-do-until">promise-do-until</a>
|
||
- Calls a function repeatedly until a condition returns true and then
|
||
resolves the promise.</li>
|
||
<li><a
|
||
href="https://github.com/busterc/promise-do-whilst">promise-do-whilst</a>
|
||
- Calls a function repeatedly while a condition returns true and then
|
||
resolves the promise.</li>
|
||
<li><a
|
||
href="https://github.com/samccone/promise-semaphore">promise-semaphore</a>
|
||
- Push a set of work to be done in a configurable serial fashion</li>
|
||
<li><a
|
||
href="https://github.com/kevinoid/promise-nodeify">promise-nodeify</a> -
|
||
Standalone <code>nodeify</code> method which calls a Node-style callback
|
||
on resolution or rejection.</li>
|
||
</ul>
|
||
<h2 id="license">License</h2>
|
||
<p>Licensed under the <a
|
||
href="https://creativecommons.org/publicdomain/zero/1.0/">Creative
|
||
Commons CC0 License</a>.</p>
|
||
<p><a href="https://github.com/wbinnssmith/awesome-promises">promises.md
|
||
Github</a></p>
|