This file contains hidden or 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
/* | |
http://twitter.com/#!/bga_/status/116861871423885312 | |
*/ | |
Object.prototype.thunk = function(name, calc) { | |
Object.defineProperty(this,name,{get: function() { | |
var ret = calc(); | |
delete this[name] // memo result | |
this[name] = ret; |
This file contains hidden or 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 esArray(array) { | |
return Object.prototype.toString.call(array) == '[object Array]'); | |
} | |
function desempaqueta(array,index) { | |
Array.prototype.splice.apply(array, [index, 1].concat(array[index])); | |
} | |
function flatten(arr) { | |
arr = arr.concat(); |
This file contains hidden or 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 aplaneitor2(arr,sep){ | |
return function step(a){return Array.isArray(a) ? a.map(step).join(sep) : a}(arr); | |
} | |
var test = ["hola", ["soy", ["juan", "fernandez"] ], "y", ["no", "tengo", ["dinero"] ] ]; | |
console.log(aplaneitor2(test,'**')) // -> hola**soy**juan**fernandez**y**no**tengo**dinero |
This file contains hidden or 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 Ajax = (function (){ | |
function AjaxXMLHTTPRequest(){} | |
AjaxXMLHTTPRequest.prototype = {...}; | |
function AjaxActiveX(){} | |
AjaxActiveX.prototype = {}; | |
return (typeof window.ActiveXObject === 'undefined') ? | |
AjaxXMLHTTPRequest: |