Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created January 13, 2012 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwaldron/e4e0e349f9cf35ad3370 to your computer and use it in GitHub Desktop.
Save rwaldron/e4e0e349f9cf35ad3370 to your computer and use it in GitHub Desktop.
() vs. ||
Promise.prototype = {
get: function(key) {
return this.then({ (obj) obj[key]; });
},
put: function(key, val) {
return this.then({ (obj) obj[key] = val });
},
call: function(key, ...args ) {
// Can this Expression form have line breaks?
return this.then({ (obj)
obj[key].apply(obj, args)
});
},
addCallback: function(callback) {
return this.then(callback);
},
addErrback: function(errback) {
// This was previously a no-op function expression
return this.then({() }, errback);
}
....
};
Promise.prototype = {
get: function(key) {
return this.then({|obj| obj[key]; });
},
put: function(key, val) {
return this.then({|obj| obj[key] = val; });
},
call: function(key, ...args ) {
return this.then({|obj|
obj[key].apply(obj, args);
});
},
addCallback: function(callback) {
return this.then(callback);
},
addErrback: function(errback) {
// This was previously a no-op function expression
return this.then({||}, errback);
}
....
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment