Skip to content

Instantly share code, notes, and snippets.

View briancavalier's full-sized avatar

Brian Cavalier briancavalier

  • Pittsburgh
View GitHub Profile
@briancavalier
briancavalier / semantic tiny Promise.js
Created February 11, 2011 17:00 — forked from unscriptable/tiny Promise.js
An attempt at a more sematic promise API
function Promise () {
this._resolve = [];
this._reject = [];
this._progress = [];
}
Promise.prototype = {
/* This is the "front end" API. */
// Promise implementation based on unscriptable's minimalist Promise:
// https://gist.github.com/814052/
function Promise () {
this._thens = [];
}
Promise.prototype = {
/* This is the "front end" API. */
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}