Code:
(function(){
var AP= Array.prototype, SP= String.prototype, equalizer={
every: function(fun, scope){
var len= this.length;
if(typeof fun== 'function'){
for(var i= 0; i < len; i++){
if(i in this){
if(fun.call(scope, this[i], i, this)== false) return false;
}
}
return true;
}
},
filter: function(fun){
var A= [], i= 0, itm, L= this.length;
if(typeof fun== 'function'){
while(i< L){
itm= this[i];
if(!!fun(itm, i, this)) A[A.length]= itm;
++i;
}
}
return A;
},
forEach: function(fun, scope){
var L= this.length, i= 0;
if(typeof fun== 'function'){
while(i< L){
if(i in this){
fun.call(scope, this[i], i, this);
}
++i;
}
}
return this;
},
indexOf: function(what, i){
i= i || 0;
var L= this.length;
while(i< L){
if(this[i]=== what) return i;
++i;
}
return -1;
},
lastIndexOf: function(what, i){
var L= this.length;
i= i || L-1;
if(isNaN(i) || i>= L) i= L-1;
if(i< 0) i += L;
while(i> -1){
if(this[i]=== what) return i;
--i;
}
return -1;
},
map: function(fun, scope){
var L= this.length, A= Array(L), i= 0;
if(typeof fun== 'function'){
while(i< L){
if(i in this){
A[i]= fun.call(scope, this[i], i, this);
}
++i;
}
return A;
}
},
reduce: function(fun, temp, scope){
var i= 0, T= this, len= T.length, temp;
if(scope== undefined) scope= window;
if(typeof fun=== 'function'){
if(temp== undefined) temp= T[i++];
while(i < len){
if(i in T) temp= fun.call(scope, temp, T[i], i, T);
i++;
}
}
return temp;
},
reduceRight: function(fun, temp, scope){
var T= this.concat().reverse();
return T.reduce(fun, temp, scope);
},
some: function(fun, scope){
var t= this, L= t.length;
if(typeof fun== "function"){
for(var i= 0; i < L; i++){
if(i in t && fun.call(scope, t[i], i, t))
return true;
}
return false;
}
}
};
for(var p in equalizer){
if(!AP[p]) AP[p]= equalizer[p];
}
if(!SP.trim){
SP.trim=function(){
return this.replace(/^\s+|\s+$/g, '');
}
}
})();
Bookmarks