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 f() { | |
var cache = [].join.call(arguments, ''); | |
return !cache ? '' : function sub() { | |
cache += [].join.call(arguments, ''); | |
return !arguments.length ? cache : sub; | |
} | |
}; | |
f('This ')('i')('s a sentence')() + f('123')() == 'This is a sentence123'; // true |
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
/** | |
* Eventiza el objeto, agregandole los | |
* metodos | |
* on | |
* emit | |
* removeListener | |
* | |
* @param {Object} | |
* @return {Object} | |
*/ |
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
/** | |
* Xetteriza el objeto | |
* | |
* @param {Object} obj | |
* @param {Array} props | |
* @return {Object} | |
*/ | |
var xetterize = (function() { | |
/** | |
* Formatea el string para que sea |
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 infiniteTimedLoop = (function() { | |
var | |
task, | |
interval = 100, | |
status = false, | |
i = 0; | |
function start() { | |
if(!status) { | |
return; |
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
// 149 chars :< | |
/* | |
function c(o) { | |
function t(o, s) { | |
return s.replace(/./g, function(c) { | |
return String.fromCharCode(c.charCodeAt(0) + o) | |
}) | |
} | |
return { | |
e: t.bind(c, o), |
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
({ | |
0: console.info, | |
1: console.log, | |
2: console.warn, | |
3: console.error | |
}[severity] || console.error)(message); |
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 Timer(interval) { | |
this.handlers = {}; | |
this.started = false; | |
this.interval = interval; | |
}; | |
Timer.prototype.tick = function () { | |
if (!this.started) { | |
return; | |
} |
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 list1 = list(1, 2, 3); | |
var list2 = list(4, 5, 6); | |
var list3 = list1('+')(list2); | |
list3('add')(7); | |
list3('debug')(); // "list (7) [1,2,3,4,5,6,7]" | |
*/ | |
var x = function(proto) { |
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
// create a number type | |
hug('type')('number'); | |
// set the constructor | |
hug('type')('number')('#set')('init', function($self, num) { | |
$self('#set')('#value', isNaN(Number(num)) ? 0 : Number(num)); | |
}); | |
// methods... | |
hug('type')('number')('#set')('+', function($self, $rest) { |
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
// see http://blog.aijoona.com/2012/05/16/splat-operator-en-javascript/ | |
function splat(fn) { | |
var _ = function(target) { | |
if(typeof target == 'undefined') { | |
return _.byIndex(-1); | |
} | |
if(typeof target == 'number') { | |
return _.byIndex(target); | |
} |