This repository has been archived by the owner on Jan 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
array.min.js
5 lines (5 loc) · 1.62 KB
/
array.min.js
1
2
3
4
5
/*! js-methods (https://github.com/harrydeluxe/js-methods) */
(function(){function e(a,c){Array.prototype[a]||(Array.prototype[a]=c)}e("contains",function(a){return this.every(function(a){return 0<=this.indexOf(a)},a)});e("exfiltrate",function(a){return this.filter(function(a){return 0>this.indexOf(a)},a)});e("every",function(a,c){for(var b=0;b<this.length;b++)if(!a.call(c||window,this[b],b,this))return!1;return!0});e("filter",function(a,c){for(var b=[],d=0;d<this.length;d++)a.call(c||window,this[d],d,this)&&b.push(this[d]);return b});e("forEach",function(a,
c){for(var b=0;b<this.length;b++)a.call(c||window,this[b],b,this)});e("getRange",function(a,c){if(1>this.length)return[];var a=a||0,c=Math.min("undefined"==typeof c?this.length-1:c,this.length-1),b=[];if(a<=c)for(var d=a;d<=c;d++)b[b.length]=this[d];else for(d=a;d>=c;d--)b[b.length]=this[d];return b});e("indexOf",function(a,c){for(var b=c||0;b<this.length;b++)if(this[b]===a)return b;return-1});e("inArray",function(a){for(var c=0;c<this.length;c++)if(a==this[c])return!0;return!1});e("insertAt",function(a,
c){for(var b=this.length;b>a;b--)this[b]=this[b-1];this[a]=c;return this});e("map",function(a,c){for(var c=c||window,b=[],d=0;d<this.length;d++)b[b.length]=a.call(c,this[d],d,this);return b});e("removeAt",function(a){for(;a<this.length-1;a++)this[a]=this[a+1];this.length--;return this});e("randomize",function(){return this.sort(function(){return Math.round(Math.random())-0.5})});e("some",function(a,c){for(var b=0;b<this.length;b++)if(a.call(c||window,this[b],b,this))return!0;return!1});e("unique",
function(){return this.filter(function(a,c,b){return b.indexOf(a)>=c})})})();