This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------- | |
// | |
// Hypothesis: | |
// | |
// Promises/A is a Monad | |
// | |
// To be a Monad, it must provide at least: | |
// - A unit (aka return or mreturn) operation that creates a corresponding | |
// monadic value from a non-monadic value. | |
// - A bind operation that applies a function to a monadic value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend(obj) { | |
var args = [].slice.call(arguments, 1); | |
args.forEach(function (source) { | |
var prop; | |
for (prop in source) { | |
if (source.hasOwnProperty(prop)) { | |
obj[prop] = source[prop]; | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsonp = { | |
callbackCounter: 0, | |
fetch: function(url, callback) { | |
var fn = 'JSONPCallback_' + this.callbackCounter++; | |
window[fn] = this.evalJSONP(callback); | |
url = url.replace('=JSONPCallback', '=' + fn); | |
var scriptTag = document.createElement('SCRIPT'); | |
scriptTag.src = url; |