I wrote another async replacement for browsers, 4.1k minified. https://github.com/aynik/be
14 karma · joined October 3, 2011
self: var a = []; function b(){ var c = {}; c.d = function(){}; return c }; for (var e = 0, f = 100000; e < f; e++) a.push(new b)
prototype: var a = []; function b(){ return this }; b.prototype.c = function(){}; for (var d = 0, e = 100000; d < e; d++) a.push(new b)
function map_unless_nested(arr){
return arr.filter(function(it){ if (it instanceof Array) return it }).length?
function(){ return [] } : function(fn){ return arr.map(fn) };
}
console.log(map_unless_nested([1,2,3])(function(n){ return n + 1 }));
console.log(map_unless_nested([1,2,[1,2],3])(function(n){ return n + 1 }));
edit: also a translation for the last example function map_first_innermost(arr){
return function(fn){
return arr.map(function(v){
if (v instanceof Array)
return map_first_innermost(v)(fn);
return fn(v);
});
};
}
console.log(map_first_innermost([1,2,[1,2],3])(function(n){ return n + 1 }));EDIT: this reply actually looks more personal than I wanted it to be, and given your clarification, have my apologies...