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
module.exports = curry; | |
function curry (f) { | |
var arity = f.length; | |
var params = []; | |
var end = createEnd(f, arity); | |
return createCurried(params, arity, end); | |
} | |
function createEnd (f, arity) { |
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
module.exports = curry; | |
function curry (f) { | |
var arity = f.length; | |
var params = []; | |
var end = createEnd(f, arity); | |
return createCurried(params, arity, end); | |
} | |
function createEnd (f, arity) { |
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
// Use native or try any of these promise impls. | |
// They all behave the same. | |
//var Promise = require('when').Promise; | |
//var Promise = require('rsvp').Promise; | |
//var Promise = require('bluebird'); | |
// Here are 2 promises, p1 and p2. p2 always *actually* finishes | |
// first, since p1 finishes in 1 millisecond, and p2 is already | |
// finished when created |
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
/* | |
* Example #1 : usage example | |
* - Image paths are relative to the HTML file. | |
* - Support absolute paths as well. | |
* - Appending `!bust` to the end of the file name will avoid caching the image. | |
*/ | |
require(['image!lol_cat.gif', 'image!http://tinyurl.com/4ge98jz', 'image!dynamic_image.jpg!bust'], function(cat, awesome, dynamic){ | |
//add loaded images to the document! | |
document.body.appendChild(awesome); | |
document.body.appendChild(cat); |
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
Promise.prototype.then = function (onResolve, onReject, onProgress) { | |
if(isPromise(onResolve)) { | |
// Chain promise | |
this.then( | |
function(val) { onResolve.resolve(onReject ? onReject : val); }, | |
function(err) { onResolve.reject(err); }, | |
function(update) { onResolve.progress(update); } | |
); | |
} else { | |
// capture calls to then() |
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
/** | |
* Author: Ben Gerrissen | |
* Date: 9-3-11 | |
* License: MIT | |
*/ | |
(function( global ){ | |
var undefined | |
, preloads = false |
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(){ | |
function Klass(id){ this._id = id; } | |
Klass.prototype.id = function(){ console.log(this._id); } | |
var freeExports = typeof exports == 'object' && exports; | |
if (freeExports) { | |
for (var prop in Klass) freeExports[prop] = Klass[prop]; | |
} else if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { | |
define(function() { return Klass; }); |
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
// MyView.js when concatenated together using cram.js | |
// cram.js needs two new features to make this work: | |
// 1. an option to NOT normalize module ids | |
// 2. an option to more easily exclude modules from the build (wire plugins, for instance) | |
define('./myView/controller', { | |
_onClick: function (e) { | |
this.rootNode.classList.toggle(this.states.selected); | |
} | |
}); |
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
soon = (function() { | |
var enqueueTask; | |
if(typeof process != 'undefined' && typeof process.nextTick == 'function') { | |
// Node nextTick | |
enqueueTask = process.nextTick; | |
} else if (typeof setImmediate == 'function') { | |
// setImmediate for new IE |
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
define({ | |
myFunc: { | |
expr: { | |
body: 'alert(e.target.textContent);', | |
params: ['e'] | |
} | |
}, | |
body: { |
OlderNewer