Skip to content

Instantly share code, notes, and snippets.

@domenic
domenic / pipelining.txt
Last active December 26, 2015 00:08
Potential promise pipelining with subclassing
var p0 = Promise.cast(null);
var p1 = p0.then(() => remotePromise);
var p2 = p1.invoke("foo");
line 2 calls remotePromise's .then method, like so:
remotePromise.then(v => { set p1's [[Value]] to v }, r => { set p1's [[Reason]] to r })
it ALSO stores remotePromise in [[Following]]
Once remotePromise settles, i.e. once one of the two above callbacks gets called,
[[Following]] gets cleared.
anonymous
anonymous / gist:6399102
Created August 31, 2013 15:55
// This module uses AP2 as its starting point:
// https://github.com/domenic/promises-unwrapping
var hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
function mixin(a, b) {
Object.keys(b).forEach(function(key) {
a[key] = b[key];
});
return a;