UNPKG

sugar

Version:

A Javascript library for working with native objects.

8 lines (7 loc) 2.8 kB
G(r,m,m,{keys:function(a){var b=[];if(!ka(a)&&!F(a)&&!C(a))throw new TypeError("Object required");I(a,function(c){b.push(c)});return b}});function ua(a,b,c,d){var e=a.length,g=d==-1,f=g?e-1:0;c=isNaN(c)?f:parseInt(c>>0);if(c<0)c=e+c;if(!g&&c<0||g&&c>=e)c=f;for(;g&&c>=0||!g&&c<e;){if(a[c]===b)return c;c+=d}return-1} function va(a,b,c,d){var e=a.length,g=0,f=K(c);wa(b);if(e==0&&!f)throw new TypeError("Reduce called on empty array with no initial value");else if(f)c=c;else{c=a[d?e-1:g];g++}for(;g<e;){f=d?e-g-1:g;if(f in a)c=b(c,a[f],f,a);g++}return c}function wa(a){if(!a||!a.call)throw new TypeError("Callback is not callable");}function xa(a){if(a.length===0)throw new TypeError("First argument must be defined");}G(s,m,m,{isArray:function(a){return fa(a,"Array")}}); G(s,j,m,{every:function(a,b){var c=this.length,d=0;for(xa(arguments);d<c;){if(d in this&&!a.call(b,this[d],d,this))return m;d++}return j},some:function(a,b){var c=this.length,d=0;for(xa(arguments);d<c;){if(d in this&&a.call(b,this[d],d,this))return j;d++}return m},map:function(a,b){var c=this.length,d=0,e=Array(c);for(xa(arguments);d<c;){if(d in this)e[d]=a.call(b,this[d],d,this);d++}return e},filter:function(a,b){var c=this.length,d=0,e=[];for(xa(arguments);d<c;){d in this&&a.call(b,this[d],d,this)&& e.push(this[d]);d++}return e},indexOf:function(a,b){if(E(this))return this.indexOf(a,b);return ua(this,a,b,1)},lastIndexOf:function(a,b){if(E(this))return this.lastIndexOf(a,b);return ua(this,a,b,-1)},forEach:function(a,b){var c=this.length,d=0;for(wa(a);d<c;){d in this&&a.call(b,this[d],d,this);d++}},reduce:function(a,b){return va(this,a,b)},reduceRight:function(a,b){return va(this,a,b,j)}}); (function(){var a=qa().match(/^\s+$/);try{v.prototype.trim.call([1])}catch(b){a=m}G(v,j,!a,{trim:function(){return this.toString().trimLeft().trimRight()},trimLeft:function(){return this.replace(t("^["+qa()+"]+"),"")},trimRight:function(){return this.replace(t("["+qa()+"]+$"),"")}})})(); (function(){var a=m;if(Function.prototype.va){a=function(){};var b=a.va();a=new b instanceof b&&!(new a instanceof b)}G(Function,j,!a,{bind:function(c){var d=this,e=H(arguments).slice(1),g,f;if(!C(this))throw new TypeError("Function.prototype.bind called on a non-function");f=function(){return d.apply(d.prototype&&this instanceof d?this:c,e.concat(H(arguments)))};g=function(){};g.prototype=this.prototype;f.prototype=new g;return f}})})(); (function(){var a=new u(u.UTC(1999,11,31));a=a.toISOString&&a.toISOString()==="1999-12-31T00:00:00.000Z";J(u,j,!a,"toISOString,toJSON",function(b,c){b[c]=function(){return Q(this.getUTCFullYear(),4)+"-"+Q(this.getUTCMonth()+1,2)+"-"+Q(this.getUTCDate(),2)+"T"+Q(this.getUTCHours(),2)+":"+Q(this.getUTCMinutes(),2)+":"+Q(this.getUTCSeconds(),2)+"."+Q(this.getUTCMilliseconds(),3)+"Z"}})})();