Comparing version 0.0.4 to 0.0.5
/** | ||
* Core.js v0.0.3 | ||
* Core.js v0.0.5 | ||
* http://core.zloirock.ru | ||
@@ -7,3 +7,3 @@ * © 2013 Denis Pushkarev | ||
*/ | ||
!function(f,x,c,i,h,E,u,N,$,k,cb,e){"use strict";function O(a){return null===a?"Null":a==e?"Undefined":q(a).slice(8,-1)}function V(a){return Tb.test(a)}function b(b,c,d){for(var a in c)try{j(c,a)&&(d||!j(b,a)||!V(b[a]))&&delete b[a]&&s(b,a,G(6,c[a]))}catch(e){}return b}function A(a){return h(a).split(",")}function G(a,b){return{enumerable:!!(1&a),configurable:!!(2&a),writable:!!(4&a),value:b}}function p(){for(var d=this,a=0,b=arguments.length,c=i(b);b>a;)c[a]=arguments[a++];return function(){for(var e=c.slice(),f=arguments.length,a=0;f>a;)e[b+a]=arguments[a++];return W.call(d,this,e)}}function kb(){return Lb.call(Vb,this)}function Mb(){var a=this;return function(){var b=0,d=arguments.length,c=i(d+1);for(c[0]=this;d>b;)c[b+1]=arguments[b++];return W.call(a,e,c)}}function Lb(a){var b=this;return function(){return b.apply(a,arguments)}}function Sb(a,b){if(b in a)do if(j(a,b))return T(a,b);while(a=J(a))}function Z(a){for(var b,c={},d=y(a),f=d.length,e=0;f>e;)c[b=d[e++]]=T(a,b);return c}function Jb(b){var a,c={};for(a in b)j(b,a)&&(c[b[a]]=a);return c}function Hb(a){return"[object String]"==q(a)}function n(a){return"[object Function]"==q(a)}function Fb(a){return"[object Date]"==q(a)}function hb(a){return"[object Arguments]"==q(a)}function K(a){return z.call(a,1)}function o(b,c){for(var a=0,d=g(b.length);d>a;a++)if(P(b[a],c))return a;return-1}function X(d,b){return b=c(b),zb.call(a(this),d,b),b}function g(b){var a=C(b);return a>0&&Q(a)?a:0}function rb(a){return 0==(a=+a)||Gb(a)?a:0>a?-1:1}function B(a,b){for(a+="";b>a.length;)a="0"+a;return a}function Eb(){return h(this).match(/[^\/]*$/)[0]}function tb(d,a,b){var c=g(this.length);if((a|=0)<0&&(a=c+a)<0)return this;for(b=b==e?c:0|b;b>a;)this[a++]=d;return this}function Nb(d){var b=R(this.prototype),c=this.apply(b,a(d||[]));return w(c)?c:b}function yb(a){return this[d]=R(a[d],Z(this[d])),this}function M(a){return this instanceof M?(this.value=a,e):new M(a)}f.global=f;var d="prototype",db=1/0,m=i[d],ab=x[d],mb=E[d],F=c[d],ob=h[d],s=c.defineProperty,sb=m.push,z=m.slice,W=ab.apply,Vb=ab.call,nb=k.abs,lb=k.ceil,t=k.exp,S=k.floor,L=k.log,qb=k.max,H=k.min,xb=k.pow,fb=k.random,gb=k.sqrt,wb=function(a){return a=x(),(new a).__proto__==a[d]},a=c,v=i.isArray||function(a){return"[object Array]"==q(a)},I=i.from||function(a){return z.call(a)},U="toString",Rb=F.hasOwnProperty,Pb=F[U],Ub=F.isPrototypeOf,Ob=F.propertyIsEnumerable,j=function(a,b){return Rb.call(a,b)},q=function(a){return Pb.call(a)},Qb=function(a,b){return Ub.call(a,b)},ub=function(a,b){return Ob.call(a,b)},r=!0,pb="Reduce of empty object with no initial value",Tb=/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/,bb="[ \n\f\r \u2028\u2029]",Db="^"+bb+bb+"*",vb=bb+bb+"*$";!function(){var o=x(),y=u(Db),C=u(vb),k=A(U+",toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,constructor"),p=k.concat(["length"]),q=k.length,E=z,B=m.join,f=wb()?function(){return{__proto__:null}}:function(){var b,a=document.createElement("iframe"),c=q,e=document.body||document.documentElement;for(a.style.display="none",e.appendChild(a),a.src="javascript:",b=a.contentWindow.document||a.contentDocument||a.document,b.open(),b.write("<script>document._=Object</script>"),b.close(),f=b._;c--;)delete f[d][k[c]];return f()},t=function(a,b){return function(e){var c,f=0,d=[];for(c in e)j(e,c)&&d.push(c);for(;b>f;)j(e,c=a[f++])&&!~d[D](c)&&d.push(c);return d}},J=!!c.getPrototypeOf||wb();try{s({},0,F),r=!0}catch(L){r=!1,c.getOwnPropertyDescriptor=function(a,b){return j(a,b)?G(6+ub(a,b),a[b]):e},c.defineProperty=s=function(a,b,c){return a[b]=c.value,a},c.defineProperties=function(a,b){for(var c,d=l(b),f=d.length,e=0;f>e;)a[c=d[e++]]=b[c].value;return a}}b(c,{getPrototypeOf:function(a){var b,c=a.__proto__||((b=a.constructor)?b[d]:F);return a!=c&&U in a?c:null},getOwnPropertyNames:t(p,p.length),create:function(a,b){if(null===a)return b?_(f(),b):f();if(!w(a))throw $("Object prototype may only be an Object or null");o[d]=a;var c=new o;return b&&_(c,b),J||c.constructor[d]==a||(c.__proto__=a),c},keys:t(k,q)}),0 in c("q")||(a=function(a){return Hb(a)?a.split(""):c(a)},m.slice=z=function(){return E.apply(a(this),arguments)},m.join=function(){return B.apply(a(this),arguments)}),b(ab,{bind:function(c){function b(){return W.call(a,a[d]&&this instanceof a?this:c,e.concat(I(arguments)))}var a=this,e=K(arguments);return b[d]=a[d],b}}),b(i,{isArray:v}),b(m,{indexOf:function(e,f){var c=a(this),d=g(c.length),b=0|f;for(0>b&&(b=g(d+b));d>b;b++)if(b in c&&c[b]===e)return b;return-1},lastIndexOf:function(e,f){var c=a(this),d=g(c.length),b=d-1;for(arguments.length>1&&(b=H(b,0|f)),0>b&&(b=g(d+b));b>=0;b--)if(b in c&&c[b]===e)return b;return-1},every:function(d,e){for(var c=a(this),f=g(c.length),b=0;f>b;b++)if(b in c&&!d.call(e,c[b],b,this))return!1;return!0},some:function(d,e){for(var c=a(this),f=g(c.length),b=0;f>b;b++)if(b in c&&d.call(e,c[b],b,this))return!0;return!1},forEach:function(d,e){for(var c=a(this),f=g(c.length),b=0;f>b;b++)b in c&&d.call(e,c[b],b,this)},map:function(f,h){for(var c=a(this),d=g(c.length),e=i(d),b=0;d>b;b++)b in c&&(e[b]=f.call(h,c[b],b,this));return e},filter:function(e,f){for(var c=a(this),h=g(c.length),b=0,d=[];h>b;b++)b in c&&e.call(f,c[b],b,this)&&d.push(c[b]);return d},reduce:function(f,d){var c=a(this),e=g(c.length),b=0;if(2>arguments.length)for(;;){if(b in c){d=c[b++];break}if(e<=++b)throw $(pb)}for(;e>b;b++)b in c&&(d=f(d,c[b],b,this));return d},reduceRight:function(e,d){var c=a(this),b=g(c.length)-1;if(2>arguments.length)for(;;){if(b in c){d=c[b--];break}if(0>--b)throw $(pb)}for(;b>=0;b--)b in c&&(d=e(d,c[b],b,this));return d}}),b(ob,{trim:function(){return h(this).replace(y,"").replace(C,"")}}),b(N,{now:function(){return+new N}}),hb(x("return arguments")())||(hb=function(a){return!(!a||!n(a.callee))})}();var R=c.create,_=c.defineProperties,J=c.getPrototypeOf,l=c.keys,y=c.getOwnPropertyNames,T=c.getOwnPropertyDescriptor,zb=m.forEach,Ab=m.map,D="indexOf",Bb=c.assign||function(a,b){for(var c,d=l(b),f=d.length,e=0;f>e;)a[c=d[e++]]=b[c];return a},Cb=c.mixin||function(a,b){return _(a,Z(b))},w=c.isObject||function(a){return a===c(a)},P=c.is||function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b},C=E.toInteger||function(a){return(a=+a)!=a?0:0!=a&&a!=db&&a!=-db?(a>0?S:lb)(a):a},Gb=E.isNaN||function(a){return"number"==typeof a&&a!==a},Q=E.isFinite||function(a){return"number"==typeof a&&cb(a)},Ib=E.isInteger||function(a){return Q(a)&&S(a)==a};b(c,{assign:Bb,is:P,mixin:Cb});var ib=9007199254740991;b(E,{EPSILON:2.220446049250313e-16,isFinite:Q,isInteger:Ib,isNaN:Gb,isSafeInteger:function(a){return Ib(a)&&nb(a)<=ib},MAX_SAFE_INTEGER:ib,MIN_SAFE_INTEGER:-ib,parseFloat:parseFloat,parseInt:parseInt}),b(mb,{clz:function(){var a=this>>>0;return a?32-a[U](2).length:32}}),b(k,{acosh:function(a){return L(a+gb(a*a-1))},asinh:function(a){return Q(a)&&0!==a?L(a+gb(a*a+1)):a},atanh:function(a){return 0===a?a:.5*L((1+a)/(1-a))},cbrt:function(a){return rb(a)*xb(nb(a),1/3)},cosh:function(a){return(a=+a)==-db||0===a?a:a(t(a)+t(-a))/2},expm1:function(a){return P(a,-0)?-0:a>-1e-6&&1e-6>a?a+a*a/2:t(a)-1},hypot:function(b,c,a){return a===e&&(a=0),cb(b)?cb(c)?cb(a)?gb(b*b+c*c+a*a):a:c:b},imul:function(a,b){var e=a>>>16&65535,c=65535&a,f=b>>>16&65535,d=65535&b;return c*d+(e*d+c*f<<16>>>0)|0},log1p:function(a){return a>-1e-8&&1e-8>a?a-a*a/2:L(1+a)},log10:function(a){return L(a)/k.LN10},log2:function(a){return L(a)/k.LN2},sign:rb,sinh:function(a){return(a=+a)==-db||0==a?a:(t(a)-t(-a))/2},tanh:function(a){return Q(a=+a)?0==a?a:(t(a)-t(-a))/(t(a)+t(-a)):rb(a)},trunc:function(a){return 0==(a=+a)?a:(a>0?S:lb)(a)}}),b(ob,{codePointAt:function(b){var c=h(this),d=c.length;if((b|=0)<0||b>=d)return 0/0;var a=c.charCodeAt(b);if(55296>a||a>56319||b+1==d)return a;var e=c.charCodeAt(b+1);return 56320>e||a>57343?a:(a-55296<<1024)+(e-56320)+65536},contains:function(a,b){return!!~h(this)[D](a,b)},endsWith:function(b,a){var c=this.length;return b+="",a=g(H(a===e?c:a,c)),h(this).slice(a-b.length,a)===b},repeat:function(a){return tb.call(i(C(a)),this).join("")},startsWith:function(b,a){return b+="",a=g(H(a,this.length)),h(this).slice(a,a+b.length)===b}}),b(i,{from:function(h,f,j){var c=a(h),b=0,d=g(c.length),e=new(n(this)?this:i)(d);if(f)for(;d>b;b++)b in c&&(e[b]=f.call(j,c[b],b,c));else for(;d>b;b++)b in c&&(e[b]=c[b]);return e},of:function(){for(var a=0,b=arguments.length,c=new(n(this)?this:i)(b);b>a;)c[a]=arguments[a++];return c}}),b(m,{fill:tb,find:function(h,i){for(var e,f=c(this),d=a(f),j=g(d.length),b=0;j>b;b++)if(b in d&&h.call(i,e=d[b],b,f))return e},findIndex:function(f,h){for(var e=c(this),d=a(e),i=g(d.length),b=0;i>b;b++)if(b in d&&f.call(h,d[b],b,e))return b;return-1}}),!function(){function g(a){a.size=a._values.length}var a=f.Map,c=f.Set,h={get:function(){return this._values.length}};V(a)&&j(a[d],"forEach")?function(){try{return 1==a([[1,2]]).size}catch(b){}}()||(f.Map=function(b){var c=new a;return v(b)&&b.forEach(function(a){c.set(a[0],a[1])}),c},f.Map[d]=a[d]):(f.Map=a=function(b){var c=this;return c instanceof a?(c.clear(),v(b)&&b.forEach(function(a){c.set(a[0],a[1])}),e):new a(b)},b(a[d],{clear:function(){_(this,{_keys:G(4,[]),_values:G(4,[])}),r||g(this)},"delete":function(c){var b=this._keys,d=this._values,a=o(b,c);return~a?(b.splice(a,1),d.splice(a,1),r||g(this),!0):!1},forEach:function(c,d){for(var e=this._keys,b=this._values,f=b.length,a=0;f>a;)c.call(d,b[a],e[a++],this)},get:function(a){return this._values[o(this._keys,a)]},has:function(a){return!!~o(this._keys,a)},set:function(a,b){var c=this._keys,d=this._values,e=o(c,a);return~e?d[e]=b:(c.push(a),d.push(b),r||g(this)),this}}),r&&s(a[d],"size",h)),V(c)&&j(c[d],"forEach")?function(){try{return 1==c([1]).size}catch(a){}}()||(f.Set=function(b){var a=new c;return v(b)&&b.forEach(a.add,a),a},f.Set[d]=c[d]):(f.Set=c=function(a){return this instanceof c?(this.clear(),v(a)&&a.forEach(this.add,this),e):new c(a)},b(c[d],{add:function(a){var b=this._values;return~o(b,a)||(b.push(a),r||g(this)),this},clear:function(){s(this,"_values",G(4,[])),r||g(this)},"delete":function(c){var a=this._values,b=o(a,c);return~b?(a.splice(b,1),r||g(this),!0):!1},forEach:function(d,e){for(var a,b=this._values,f=b.length,c=0;f>c;)d.call(e,a=b[c++],a,this)},has:function(a){return!!~o(this._values,a)}}),r&&s(c[d],"size",h))}(),!function(i,h,m,g,b,d,e){function c(a,b){return p.apply(n(a)?a:x(a),b)}if(i&&/MSIE .\./.test(i.userAgent)&&(f.setTimeout=function(a,b){return h(c(a,z.call(arguments,2)),b||1)},f.setInterval=function(a,b){return m(c(a,z.call(arguments,2)),b||1)}),!n(f[b])||!n(f[d]))if(n(g)){var j=b+fb(),k=0,a={},l=function(c){var b=c.data;b in a&&(a[b](),delete a[b])};f[b]=function(d){var b=++k+j;return a[b]=c(d,K(arguments)),g(b,f.location),k},f[d]=function(b){delete a[b+j]},e?e("message",l,!1):attachEvent("onmessage",l)}else f[b]=function(a){return h(c(a,K(arguments)),0)},f[d]=x("i","clearTimeout(i)")}(f.navigator,setTimeout,setInterval,f.postMessage,"setImmediate","clearImmediate",f.addEventListener),b(x,{isNative:V,inherits:kb.call(yb)}),b(ab,{unbind:kb,methodize:Mb,part:p,partial:function(a,b){var c=this,d=I(a),f=arguments.length>1;return function(){for(var a,g=I(d),i=arguments.length,h=a=0;i>a;){for(;g[h]!==e;)h++;g[h++]=arguments[a++]}return c.apply(f?b:this,g)}},only:function(a,b){a|=0;var c=this,d=arguments.length>1;return function(){return c.apply(d?b:this,z.call(arguments,0,H(a,arguments.length)))}},ctx:Lb,invoke:Nb,getInstance:function(){var a,b="getInstance";return j(this,b)?e:(this[b]=function(){return a},a=this.invoke(arguments))},once:function(){var a,c=this,b=1;return function(){return b&&(b=0,a=c.apply(this,arguments)),a}},error:function(a){var b=this;return function(){var c=I(arguments);try{return b.apply(this,c)}catch(d){return a.call(this,d,c)}}},before:function(a){var b=this;return function(){var c=I(arguments);return a.call(this,c),b.apply(this,c)}},after:function(a){var b=this;return function(){var c=I(arguments),d=b.apply(this,c),f=a.call(this,d,c);return f===e?d:f}},timeout:function(a){return p.call(clearTimeout,setTimeout(p.apply(this,K(arguments)),a))},interval:function(a){return p.call(clearInterval,setInterval(p.apply(this,K(arguments)),a))},immediate:function(){return p.call(clearImmediate,setImmediate(p.apply(this,arguments)))},inherits:yb}),!function(){function d(b,c,o,i,m,g,h){if(w(b)&&w(c))for(var a,k,e,r=n(i),p=(m?y:l)(c),t=p.length,q=0;t>q;)a=p[q++],j(b,a)&&(r?i(b[a],c[a]):i)?o&&d(b[a],c[a],1,i,m,g,h):m?(k=T(b,a)||F,k.configurable!==!1&&delete b[a]&&(e=T(c,a),!o||e.get||e.set||(e.value=d(f(e.value,1,1,g,h),k.value,1,1,1,g,h)),s(b,a,e))):b[a]=o?d(f(c[a],1,0,g,h),b[a],1,1,0,g,h):c[a];return b}function f(a,h,j,c,e){if(!w(a))return a;c||(c=[]),e||(e=[]);var b,f=c[D](a),g=a.constructor;if(~f)return e[f];switch(O(a)){case"Arguments":case"Array":b=i(a.length);break;case"Function":return a;case"RegExp":b=u(a.source,Eb.call(a));break;case"String":return new g(a);case"Boolean":case"Date":case"Number":b=new g(a.valueOf());break;default:b=R(J(a))}return c.push(a),e.push(b),d(b,a,h,0,j,c,e)}function g(a,b,c){return b?(c?Bb:Cb)(R(a),b):R(a)}function k(a,b,c,d){if(P(a,b))return!0;var e,g,f,i=O(a);if(!w(a)||!w(b)||i!=O(b)||J(a)!=J(b))return!1;switch(c=v(c)?c.concat([a]):[a],d=v(d)?d.concat([b]):[b],i){case"Boolean":case"String":case"Number":return a.valueOf()==b.valueOf();case"RegExp":return h(a)==h(b);case"Error":return a.message==b.message}if(g=y(a),e=g.length,e!=y(b).length)return!1;for(;e--;)if(!(~c[D](a[f=g[e]])&&~d[D](b[f])||k(a[f],b[f],c,d)))return!1;return!0}function p(b,d,a){return a=c(a),m(b,d,a),a}function m(b,g,h){for(var c,d=a(b),e=l(d),i=e.length,f=0;i>f;)g.call(h,d[c=e[f++]],c,b);return b}function o(c,g,h){for(var b,d=a(c),e=l(d),i=e.length,f=0;i>f;)if(g.call(h,d[b=e[f++]],b,c))return b}b(c,{has:j,isEnumerable:ub,isPrototype:Qb,classof:O,getPropertyDescriptor:Sb,getOwnPropertyDescriptors:Z,getPropertyDescriptors:function(a){for(var b,f,c,d,e=Z(a);a=J(a);)for(c=y(a),b=0,f=c.length;f>b;)j(e,d=c[b++])||(e[d]=T(a,d));return e},getPropertyNames:function(a){for(var b,e,c,f,d=y(a);a=J(a);)for(b=0,c=y(a),e=c.length;e>b;)~d[D](f=c[b++])||d.push(f);return d},make:g,plane:function(a,b){return g(null,a,b)},clone:f,merge:d,defaults:function(a,b){return d(a,b,1,1)},values:function(b){for(var c=l(b),d=c.length,e=i(d),a=0;d>a;)e[a]=b[c[a++]];return e},invert:Jb,every:function(b,g,h){for(var c,d=a(b),e=l(d),i=e.length,f=0;i>f;)if(!g.call(h,d[c=e[f++]],c,b))return!1;return!0},filter:function(d,h,i){for(var b,c=a(d),e={},f=l(c),j=f.length,g=0;j>g;)h.call(i,c[b=f[g++]],b,d)&&(e[b]=c[b]);return e},find:function(a,c,d){var b=o(a,c,d);return b===e?e:a[b]},findIndex:o,forEach:m,indexOf:function(f,g){for(var b,c=a(f),d=l(c),h=d.length,e=0;h>e;)if(P(c[b=d[e++]],g))return b},map:function(c,h,i){for(var b,d=a(c),e={},f=l(d),j=f.length,g=0;j>g;)e[b=f[g++]]=h.call(i,d[b],b,c);return e},reduce:function(e,i,b,j){var f,c=a(e),d=l(c),g=0,h=d.length;if(3>arguments.length){if(!h--)throw $(pb);b=c[d.shift()]}for(;h>g;)b=i.call(j,b,c[f=d[g++]],f,e);return b},some:function(b,g,h){for(var c,d=a(b),e=l(d),i=e.length,f=0;i>f;)if(g.call(h,d[c=e[f++]],c,b))return!0;return!1},props:function(b,i){b=a(b);for(var c,d,f=l(b),g={},j=f.length,h=0;j>h;)c=f[h++],d=b[c],g[c]=d==e?e:d[i];return g},reduceTo:p,deepEqual:k,isObject:w,isUndefined:function(a){return a===e},isNull:function(a){return null===a},isNumber:function(a){return"[object Number]"==q(a)},isString:Hb,isBoolean:function(a){return a===!!a||"[object Boolean]"==q(a)},isArray:v,isFunction:n,isRegExp:function(a){return"[object RegExp]"==q(a)},isDate:Fb,isError:function(a){return"[object Error]"==q(a)},isArguments:hb})}();var eb=M[d];b(c,{Wrap:M}),A("defineProperty,defineProperties,getPrototypeOf,create,assign,mixin,getOwnPropertyDescriptors,getPropertyDescriptors,make,plane,clone,merge,defaults,invert,filter,forEach,map,props,reduceTo").forEach(function(a){var b=c[a];n(b)&&s(eb,a,G(6,function(){var a,c=this.value,d=[c];return sb.apply(d,arguments),a=b.apply(this,d),c===a?this:new M(a)}))}),y(c).forEach(function(a){var b=c[a];n(b)&&!j(eb,a)&&s(eb,a,G(6,function(){var a=[this.value];return sb.apply(a,arguments),b.apply(this,a)}))}),b(eb,{get:function(a){var b=this.value;return j(b,a)?b[a]:e},set:function(a,b){return this.value[a]=b,this},"delete":function(a){return delete this.value[a],this}}),!function(){function d(e){for(var d=0,b=c(this,e),a=0,f=g(b.length);f>a;a++)a in b&&(d+=+b[a]);return d}function f(j){for(var c,d=a(this),f=g(d.length),h=i(f),b=0;f>b;b++)b in d&&(c=d[b],h[b]=c==e?e:c[j]);return h}function c(b,c){switch(O(c)){case"Function":return Ab.call(b,c);case"String":case"Number":return f.call(b,c)}return a(b)}b(m,{at:function(b){return a(this)[0>b?this.length+b:b]},props:f,reduceTo:X,indexSame:function(b){return o(a(this),b)},merge:function(b){return sb.apply(this,a(b)),this},sum:d,avg:function(a){return this.length?d.call(this,a)/this.length:0},min:function(a){return H.apply(e,c(this,a))},max:function(a){return qb.apply(e,c(this,a))},unique:function(f){for(var b,a=[],d=c(this,f),h=g(d.length),e=0;h>e;)~o(a,b=d[e++])||a.push(b);return a},cross:function(f){for(var b,c=[],d=a(this),h=g(d.length),i=a(f),e=0;h>e;)!~o(c,b=d[e++])&&~o(i,b)&&c.push(b);return c}})}(),b(i,X.call(A("concat,join,pop,push,reverse,shift,slice,sort,splice,unshift,"+D+",lastIndexOf,every,some,forEach,map,filter,reduce,reduceRight,find,findIndex,at,props,reduceTo,indexSame,merge,sum,avg,min,max,unique,cross"),function(a){a in m&&(this[a]=kb.call(m[a]))})),b(E,{toInteger:C}),b(mb,{div:function(b){var a=this/b;return(a>0?S:lb)(a)},times:function(b,e){var a=0,c=0|this,d=i(c);if(n(b))for(;c>a;)d[a]=b.call(e,a,a++,this);return d},random:function(d){var a=this||0,b=d||0,c=H(a,b);return fb()*(qb(a,b)-c)+c},rand:function(d){var a=C(this),b=C(d),c=H(a,b);return S(fb()*(qb(a,b)+1-c)+c)},odd:function(){return!(!(this%2)||this%1)},even:function(){return 0===this%2},format:function(b,c,f){var b=g(b),a=h(C(this)),d=B(C(nb(k.round((this-a)*xb(10,b)))),b);return c&&(a=a.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+c),d=d.replace(/(\d{3})(?=\d)/g,"$1"+c)),b?a+(f==e?".":f)+d:a}}),b(mb,X.call(A("round,floor,ceil,abs,sin,asin,cos,acos,tan,atan,exp,pow,sqrt,max,min,pow,atan2,acosh,asinh,atanh,cbrt,cosh,expm1,hypot,imul,log1p,log10,log2,sign,sinh,tanh,trunc"),function(a){a in k&&(this[a]=Mb.call(k[a]))})),!function(){var d=u(Db),e=u(vb),a={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},c=Jb(a),f=u("["+l(a).join("")+"]","g"),g=u("("+l(c).join("|")+")","g"),i=/([\\\/'*+?|()\[\]{}.^$])/g;b(ob,{trimLeft:function(){return h(this).replace(d,"")},trimRight:function(){return h(this).replace(e,"")},escapeHTML:function(){return h(this).replace(f,function(b){return a[b]})},unescapeHTML:function(){return h(this).replace(g,function(b,a){return c[a]})},escapeURL:function(a){return(a?encodeURIComponent:encodeURI)(this)},unescapeURL:function(a){return(a?decodeURIComponent:decodeURI)(this)},escapeRegExp:function(){return h(this).replace(i,"\\$1")},reverse:function(){return h(this).split("").reverse().join("")},at:function(a){var b=h(this);return b.charAt(0>a?b.length+a:a)}})}(),b(u[d],{fn:function(){var a=this;return function(b){return a.test(b)}},getFlag:Eb}),!function(){function i(i,g){var b=Fb(this)?this:new N,d=a[j(a,g)?g:f];return h(i).replace(o,function(a,f){switch(f){case"ms":return b.getMilliseconds();case"s":return b[k]();case"ss":return B(b[k](),2);case"m":return b[l]();case"mm":return B(b[l](),2);case"h":return b[e]()%12||12;case"hh":return B(b[e]()%12||12,2);case"H":return b[e]();case"HH":return B(b[e](),2);case"d":return b.getDate();case"dd":return B(b.getDate(),2);case"w":return d.w[b.getDay()];case"n":return b[c]()+1;case"nn":return B(b[c]()+1,2);case"M":return d.M[b[c]()];case"MM":return d.MM[b[c]()];case"yy":return B(b[n]()%100,2);case"yyyy":return b[n]()}return a})}function g(c,b){a[c]={w:A(b.w),M:A(b.M).map(m(0)),MM:A(b.M).map(m(1))}}function m(a){return function(b){return b.replace(/\+(.+)$/,function(c,b){return b.split("|")[a]})}}var o=/\b(\w\w*)\b/g,f="en",a={},k="getSeconds",l="getMinutes",e="getHours",c="getMonth",n="getFullYear";b(N,{locale:function(b){return j(a,b)&&(f=b),f},addLocale:g,format:i}),b(N[d],{format:i}),g("en",{w:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",M:"January,February,March,April,May,June,July,August,September,October,November,December"}),g("ru",{w:"Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота",M:"Январ+ь|я,Феврал+ь|я,Март+|а,Апрел+ь|я,Ма+й|я,Июн+ь|я,Июл+ь|я,Август+|а,Сентябр+ь|я,Октябр+ь|я,Ноябр+ь|я,Декабр+ь|я"})}();var Kb;b(x,{series:function(a,c){function h(j,k){j==b&&(f=b++in a,!g||!k&&f?f&&(d=z.call(arguments,i),d.push(p.call(h,b)),a[b].apply(e,d)):c.apply(e,K(arguments)))}var d,f,g=n(c),i=g?2:1,b=0;a.length?a[0](p.call(h,0)):g&&c()},parallel:Kb=function(c,d){var a=g(c.length),b=i(a);a?zb.call(c,function(e,c){e(function(e,f){!a||c in b||(e&&(a=1),b[c]=f,--a||d(e,b))})}):d(e,b)}}),b(m,{asyncMap:function(a,b){Kb(Ab.call(this,function(b){return p.call(a,b)}),b)}});var jb=f.console||{},Y=X.call(A("assert,count,clear,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,table,trace,warn,markTimeline,profile,profileEnd,time,timeEnd,timeStamp"),function(a){this[a]=function(){return jb[a]&&Y.enable&&W.call(jb[a],jb,arguments)}},{enable:!0});try{delete f.console}catch(Wb){}Y=f.console=b(Y.log,Y)}("undefined"!=typeof window?window:global,Function,Object,Array,String,Number,RegExp,Date,TypeError,Math,isFinite); | ||
!function(f,F,d,k,h,J,x,ab,t,l,V,e){"use strict";function P(a){return a===e?"Undefined":a==e?"Null":v(a).slice(8,-1)}function vb(a){var b=this;return function(){return b.apply(a,arguments)}}function qb(){return vb.call(Jb,this)}function L(){for(var d=this,a=0,b=arguments.length,c=k(b);b>a;)c[a]=arguments[a++];return function(){for(var e=c.slice(),f=arguments.length,a=0;f>a;)e[b+a]=arguments[a++];return $.call(d,this,e)}}function Fb(){var a=this;return function(b){return a.test(b)}}function b(b,c,d){for(var a in c)try{j(c,a)&&(d||!j(b,a)||!cb(b[a]))&&delete b[a]&&w(b,a,C(6,c[a]))}catch(e){}return b}function C(a,b){return{enumerable:!!(1&a),configurable:!!(2&a),writable:!!(4&a),value:b}}function r(a){return h(a).split(",")}function Hb(){var a=this;return function(){var b=0,d=arguments.length,c=k(d+1);for(c[0]=this;d>b;)c[b+1]=arguments[b++];return $.call(a,e,c)}}function Ib(a,b){if(b in a)do if(j(a,b))return Q(a,b);while(a=K(a))}function W(a){for(var b,c={},d=z(a),f=d.length,e=0;f>e;)c[b=d[e++]]=Q(a,b);return c}function Db(b){var a,c={};for(a in b)j(b,a)&&(c[b[a]]=a);return c}function s(a){return a===d(a)}function Cb(a){return"[object String]"==v(a)}function i(a){return"[object Function]"==v(a)}function M(a){return y.call(a,1)}function o(b,c){for(var a=0,d=g(b.length);d>a;a++)if(T(b[a],c))return a;return-1}function X(c,b){return b=d(b),xb.call(a(this),c,b),b}function g(b){var a=B(b);return a>0&&U(a)?a:0}function lb(a){return 0==(a=+a)||Eb(a)?a:0>a?-1:1}function A(a,b){for(a+="";b>a.length;)a="0"+a;return a}function Ab(){return h(this).match(/[^\/]*$/)[0]}function zb(a){return this[c]=O(a[c],W(this[c])),this}function S(a){return this instanceof S?(this.value=a,e):new S(a)}function wb(c,d){var a=g(c.length),b=k(a);a?xb.call(c,function(e,c){e(function(e,f){!a||c in b||(e&&(a=1),b[c]=f,--a||d(e,b))})}):d(e,b)}f.global=f;var c="prototype",_=1/0,n=k[c],N=F[c],pb=J[c],I=d[c],ib=h[c],w=d.defineProperty,kb=n.push,y=n.slice,$=N.apply,Jb=N.call,gb=l.abs,hb=l.ceil,R=l.floor,jb=l.max,G=l.min,ub=l.pow,mb=l.random,u=1,ob="Reduce of empty object with no initial value",a=d,p=k.isArray||function(a){return"[object Array]"==v(a)},H=k.from||function(a){return y.call(a)},Y="toString",E=qb.call(qb),q=E(L),j=E(I.hasOwnProperty),v=E(I[Y]),tb=E(I.propertyIsEnumerable),cb=Fb.call(/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/),db="[ \n\f\r \u2028\u2029]",Bb="^"+db+db+"*",sb=db+db+"*$";!function(){var i=F(),z=(new i).__proto__==i[c],J=x(Bb),E=x(sb),l=r(Y+",toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,constructor"),v=l.concat(["length"]),o=l.length,A=y,B=n.join,f=z?function(){return{__proto__:null}}:function(){var b,a=document.createElement("iframe"),d=o,e=document.body||document.documentElement;for(a.style.display="none",e.appendChild(a),a.src="javascript:",b=a.contentWindow.document||a.contentDocument||a.document,b.open(),b.write("<script>document._=Object</script>"),b.close(),f=b._;d--;)delete f[c][l[d]];return f()},q=function(a,b){return function(e){var c,f=0,d=[];for(c in e)j(e,c)&&d.push(c);for(;b>f;)j(e,c=a[f++])&&!~d[D](c)&&d.push(c);return d}},K=!!d.getPrototypeOf||z;try{w({},0,I)}catch(L){u=0,d.getOwnPropertyDescriptor=function(a,b){return j(a,b)?C(6+tb(a,b),a[b]):e},d.defineProperty=w=function(a,b,c){return a[b]=c.value,a},d.defineProperties=function(a,b){for(var c,d=m(b),f=d.length,e=0;f>e;)a[c=d[e++]]=b[c].value;return a}}b(d,{getPrototypeOf:function(a){var b,d=a.__proto__||((b=a.constructor)?b[c]:I);return a!=d&&Y in a?d:null},getOwnPropertyNames:q(v,v.length),create:function(a,b){if(null===a)return b?eb(f(),b):f();if(!s(a))throw t("Object prototype may only be an Object or null");i[c]=a;var d=new i;return b&&eb(d,b),K||d.constructor[c]==a||(d.__proto__=a),d},keys:q(l,o)}),0 in d("q")||(a=function(a){return Cb(a)?a.split(""):d(a)},n.slice=y=function(){return A.apply(a(this),arguments)},n.join=function(){return B.apply(a(this),arguments)}),b(N,{bind:function(d){function b(){return $.call(a,a[c]&&this instanceof a?this:d,e.concat(H(arguments)))}var a=this,e=M(arguments);return b[c]=a[c],b}}),b(k,{isArray:p}),b(n,{indexOf:function(e,f){var c=a(this),d=g(c.length),b=0|f;for(0>b&&(b=g(d+b));d>b;b++)if(b in c&&c[b]===e)return b;return-1},lastIndexOf:function(e,f){var c=a(this),d=g(c.length),b=d-1;for(arguments.length>1&&(b=G(b,0|f)),0>b&&(b=g(d+b));b>=0;b--)if(b in c&&c[b]===e)return b;return-1},every:function(d,e){for(var c=a(this),f=g(c.length),b=0;f>b;b++)if(b in c&&!d.call(e,c[b],b,this))return!1;return!0},some:function(d,e){for(var c=a(this),f=g(c.length),b=0;f>b;b++)if(b in c&&d.call(e,c[b],b,this))return!0;return!1},forEach:function(d,e){for(var c=a(this),f=g(c.length),b=0;f>b;b++)b in c&&d.call(e,c[b],b,this)},map:function(f,h){for(var c=a(this),d=g(c.length),e=k(d),b=0;d>b;b++)b in c&&(e[b]=f.call(h,c[b],b,this));return e},filter:function(e,f){for(var c=a(this),h=g(c.length),b=0,d=[];h>b;b++)b in c&&e.call(f,c[b],b,this)&&d.push(c[b]);return d},reduce:function(f,d){var c=a(this),e=g(c.length),b=0;if(2>arguments.length)for(;;){if(b in c){d=c[b++];break}if(e<=++b)throw t(ob)}for(;e>b;b++)b in c&&(d=f(d,c[b],b,this));return d},reduceRight:function(e,d){var c=a(this),b=g(c.length)-1;if(2>arguments.length)for(;;){if(b in c){d=c[b--];break}if(0>--b)throw t(ob)}for(;b>=0;b--)b in c&&(d=e(d,c[b],b,this));return d}}),b(ib,{trim:function(){return h(this).replace(J,"").replace(E,"")}}),b(ab,{now:function(){return+new ab}})}();var O=d.create,eb=d.defineProperties,K=d.getPrototypeOf,m=d.keys,z=d.getOwnPropertyNames,Q=d.getOwnPropertyDescriptor,xb=n.forEach,yb=n.map,D="indexOf",bb=d.assign||function(a,b){for(var c,d=m(b),f=d.length,e=0;f>e;)a[c=d[e++]]=b[c];return a},rb=d.mixin||function(a,b){return eb(a,W(b))},T=d.is||function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b},B=J.toInteger||function(a){return(a=+a)!=a?0:0!=a&&a!=_&&a!=-_?(a>0?R:hb)(a):a},Eb=J.isNaN||function(a){return"number"==typeof a&&a!==a},U=J.isFinite||function(a){return"number"==typeof a&&V(a)},Gb=J.isInteger||function(a){return U(a)&&R(a)==a};!function(){function o(d,a,b){var c=g(this.length);if((a|=0)<0&&(a=c+a)<0)return this;for(b=b==e?c:0|b;b>a;)this[a++]=d;return this}var j=9007199254740991,c=l.exp,f=l.log,m=l.sqrt;b(d,{assign:bb,is:T,mixin:rb}),b(J,{EPSILON:2.220446049250313e-16,isFinite:U,isInteger:Gb,isNaN:Eb,isSafeInteger:function(a){return Gb(a)&&gb(a)<=j},MAX_SAFE_INTEGER:j,MIN_SAFE_INTEGER:-j,parseFloat:parseFloat,parseInt:parseInt}),b(pb,{clz:function(){var a=this>>>0;return a?32-a[Y](2).length:32}}),b(l,{acosh:function(a){return f(a+m(a*a-1))},asinh:function(a){return U(a)&&0!==a?f(a+m(a*a+1)):a},atanh:function(a){return 0===a?a:.5*f((1+a)/(1-a))},cbrt:function(a){return lb(a)*ub(gb(a),1/3)},cosh:function(a){return(a=+a)==-_||0===a?a:a(c(a)+c(-a))/2},expm1:function(a){return T(a,-0)?-0:a>-1e-6&&1e-6>a?a+a*a/2:c(a)-1},hypot:function(b,c,a){return a===e&&(a=0),V(b)?V(c)?V(a)?m(b*b+c*c+a*a):a:c:b},imul:function(a,b){var e=a>>>16&65535,c=65535&a,f=b>>>16&65535,d=65535&b;return c*d+(e*d+c*f<<16>>>0)|0},log1p:function(a){return a>-1e-8&&1e-8>a?a-a*a/2:f(1+a)},log10:function(a){return f(a)/l.LN10},log2:function(a){return f(a)/l.LN2},sign:lb,sinh:function(a){return(a=+a)==-_||0==a?a:(c(a)-c(-a))/2},tanh:function(a){return U(a=+a)?0==a?a:(c(a)-c(-a))/(c(a)+c(-a)):lb(a)},trunc:function(a){return 0==(a=+a)?a:(a>0?R:hb)(a)}}),b(ib,{codePointAt:function(b){var c=h(this),d=c.length;if((b|=0)<0||b>=d)return 0/0;var a=c.charCodeAt(b);if(55296>a||a>56319||b+1==d)return a;var e=c.charCodeAt(b+1);return 56320>e||a>57343?a:(a-55296<<1024)+(e-56320)+65536},contains:function(a,b){return!!~h(this)[D](a,b)},endsWith:function(b,a){var c=this.length;return b+="",a=g(G(a===e?c:a,c)),h(this).slice(a-b.length,a)===b},repeat:function(a){return o.call(k(B(a)),this).join("")},startsWith:function(b,a){return b+="",a=g(G(a,this.length)),h(this).slice(a,a+b.length)===b}}),b(k,{from:function(h,f,j){var c=a(h),b=0,d=g(c.length),e=new(i(this)?this:k)(d);if(f)for(;d>b;b++)b in c&&(e[b]=f.call(j,c[b],b,c));else for(;d>b;b++)b in c&&(e[b]=c[b]);return e},of:function(){for(var a=0,b=arguments.length,c=new(i(this)?this:k)(b);b>a;)c[a]=arguments[a++];return c}}),b(n,{fill:o,find:function(h,i){for(var e,f=d(this),c=a(f),j=g(c.length),b=0;j>b;b++)if(b in c&&h.call(i,e=c[b],b,f))return e},findIndex:function(f,h){for(var e=d(this),c=a(e),i=g(c.length),b=0;i>b;b++)if(b in c&&f.call(h,c[b],b,e))return b;return-1}})}(),!function(a,d){function g(a){a.size=a._values.length}var h={get:function(){return this._values.length}};cb(a)&&j(a[c],"forEach")?function(){try{return 1==a([[1,2]]).size}catch(b){}}()||(f.Map=function(b){var c=new a;return p(b)&&b.forEach(function(a){c.set(a[0],a[1])}),c},f.Map[c]=a[c]):(f.Map=a=function(b){var c=this;return c instanceof a?(c.clear(),p(b)&&b.forEach(function(a){c.set(a[0],a[1])}),e):new a(b)},b(a[c],{clear:function(){eb(this,{_keys:C(4,[]),_values:C(4,[])}),u||g(this)},"delete":function(c){var b=this._keys,d=this._values,a=o(b,c);return~a?(b.splice(a,1),d.splice(a,1),u||g(this),!0):!1},forEach:function(c,d){for(var e=this._keys,b=this._values,f=b.length,a=0;f>a;)c.call(d,b[a],e[a++],this)},get:function(a){return this._values[o(this._keys,a)]},has:function(a){return!!~o(this._keys,a)},set:function(a,b){var c=this._keys,d=this._values,e=o(c,a);return~e?d[e]=b:(c.push(a),d.push(b),u||g(this)),this}}),u&&w(a[c],"size",h)),cb(d)&&j(d[c],"forEach")?function(){try{return 1==d([1]).size}catch(a){}}()||(f.Set=function(b){var a=new d;return p(b)&&b.forEach(a.add,a),a},f.Set[c]=d[c]):(f.Set=d=function(a){return this instanceof d?(this.clear(),p(a)&&a.forEach(this.add,this),e):new d(a)},b(d[c],{add:function(a){var b=this._values;return~o(b,a)||(b.push(a),u||g(this)),this},clear:function(){w(this,"_values",C(4,[])),u||g(this)},"delete":function(c){var a=this._values,b=o(a,c);return~b?(a.splice(b,1),u||g(this),!0):!1},forEach:function(d,e){for(var a,b=this._values,f=b.length,c=0;f>c;)d.call(e,a=b[c++],a,this)},has:function(a){return!!~o(this._values,a)}}),u&&w(d[c],"size",h))}(f.Map,f.Set),!function(j,h,n,g,b,d,e){function c(a,b){return L.apply(i(a)?a:F(a),b)}if(j&&/MSIE .\./.test(j.userAgent)&&(f.setTimeout=function(a,b){return h(c(a,y.call(arguments,2)),b||1)},f.setInterval=function(a,b){return n(c(a,y.call(arguments,2)),b||1)}),!i(f[b])||!i(f[d]))if(i(g)){var k=b+mb(),l=0,a={},m=function(c){var b=c.data;b in a&&(a[b](),delete a[b])};f[b]=function(d){var b=++l+k;return a[b]=c(d,M(arguments)),g(b,"*"),l},f[d]=function(b){delete a[b+k]},e?e("message",m,!1):attachEvent("onmessage",m)}else f[b]=function(a){return h(c(a,M(arguments)),1)},f[d]=F("i","clearTimeout(i)")}(f.navigator,setTimeout,setInterval,f.postMessage,"setImmediate","clearImmediate",f.addEventListener),!function(a){i(a)&&r("cast,resolve,reject,all,race").every(q(j,a))&&function(b){return new a(function(a){b=a}),i(b)}()&&0||!function(){function v(e,c,f,h){var a,j,d,m,n=i(f);if(n)try{a=f(h),d=1}catch(p){m=1,j=p}else a=h,d=1;o(c,a)||(n&&d?g(c,a):m?b(c,j):e===k?g(c,a):e===l&&b(c,a))}function u(b,d){for(var e,f,c=b[h],g=b[j],a=0;c.length>a;a+=3)e=c[a],f=c[a+d],v(d,e,f,g);b[h]=null}function o(a,c){var d;try{if(a===c)throw t("A promises callback cannot return that same promise.");if(s(c)&&i(c.then))return c.then(function(b){return d?!0:(d=!0,c!==b?g(a,b):n(a,b),e)},function(c){return d?!0:(d=!0,b(a,c),e)}),!0}catch(f){return d||b(a,f),!0}return!1}function g(a,b){a!==b&&o(a,b)||n(a,b)}function n(b,c){b[a]===r&&(b[a]=w,b[j]=c,m(function(){u(b,b[a]=k)}))}function b(b,c){b[a]===r&&(b[a]=w,b[j]=c,m(function(){u(b,b[a]=l)}))}var r,w=0,k=1,l=2,h="_subscribers",a="_state",j="_detail",m=f.setImmediate,d=f.Promise=function(c){var a=this,e=q(b,a);if(!i(c))throw t("First argument of Promise constructor must be an function");if(!(a instanceof d))throw t("Promise constructor cannot be called as a function.");a[h]=[];try{c(q(g,a),e)}catch(f){e(f)}};bb(d[c],{"catch":function(a){return this.then(null,a)},then:function(g,i){var b,e,c=this,f=new d(F());return c[a]?m(function(){v(c[a],f,arguments[c[a]-1],c[j])},g,i):(b=c[h],e=b.length,b[e]=f,b[e+k]=g,b[e+l]=i),f}}),bb(d,{all:function(a){if(!p(a))throw t("You must pass an array to all.");return new this(function(d,h){function e(a,b){f[a]=b,0===--g&&d(f)}var c,b,f=[],g=a.length;for(0===g&&d([]),b=0;a.length>b;b++)(c=a[b])&&i(c.then)?c.then(q(e,b),h):e(b,c)})},cast:function(a){return a&&a instanceof this?a:new this(function(b){b(a)})},race:function(a){if(!p(a))throw t("You must pass an array to race.");return new this(function(c,e){for(var b,d=0;a.length>d;)(b=a[d++])&&i(b.then)?b.then(c,e):c(b)})},reject:function(a){return new this(function(c,b){b(a)})},resolve:function(a){return new this(function(b){b(a)})}})}()}(f.Promise),b(F,{isNative:cb,inherits:E(zb)}),b(N,{unbind:qb,methodize:Hb,part:L,partial:function(a,b){var c=this,d=H(a),f=arguments.length>1;return function(){for(var a,g=H(d),i=arguments.length,h=a=0;i>a;){for(;g[h]!==e;)h++;g[h++]=arguments[a++]}return c.apply(f?b:this,g)}},only:function(a,b){a|=0;var c=this,d=arguments.length>1;return function(){return c.apply(d?b:this,y.call(arguments,0,G(a,arguments.length)))}},ctx:vb,invoke:function(e){var b=O(this[c]),d=this.apply(b,a(e||[]));return s(d)?d:b},once:function(){var a,c=this,b=1;return function(){return b&&(b=0,a=c.apply(this,arguments)),a}},error:function(a){var b=this;return function(){var c=H(arguments);try{return b.apply(this,c)}catch(d){return a.call(this,d,c)}}},before:function(a){var b=this;return function(){var c=H(arguments);return a.call(this,c),b.apply(this,c)}},after:function(a){var b=this;return function(){var c=H(arguments),d=b.apply(this,c),f=a.call(this,d,c);return f===e?d:f}},timeout:function(a){return q(clearTimeout,setTimeout(L.apply(this,M(arguments)),a))},interval:function(a){return q(clearInterval,setInterval(L.apply(this,M(arguments)),a))},immediate:function(){return q(clearImmediate,setImmediate(L.apply(this,arguments)))},inherits:zb}),!function(){function c(b,d,o,k,n,g,h){if(s(b)&&s(d))for(var a,l,e,r=i(k),p=(n?z:m)(d),t=p.length,q=0;t>q;)a=p[q++],j(b,a)&&(r?k(b[a],d[a]):k)?o&&c(b[a],d[a],1,k,n,g,h):n?(l=Q(b,a)||I,l.configurable!==!1&&delete b[a]&&(e=Q(d,a),!o||e.get||e.set||(e.value=c(f(e.value,1,1,g,h),l.value,1,1,1,g,h)),w(b,a,e))):b[a]=o?c(f(d[a],1,0,g,h),b[a],1,1,0,g,h):d[a];return b}function f(a,h,i,d,e){if(!s(a))return a;d||(d=[]),e||(e=[]);var b,f=d[D](a),g=a.constructor;if(~f)return e[f];switch(P(a)){case"Arguments":case"Array":b=k(a.length);break;case"Function":return a;case"RegExp":b=x(a.source,Ab.call(a));break;case"String":return new g(a);case"Boolean":case"Date":case"Number":b=new g(a.valueOf());break;default:b=O(K(a))}return d.push(a),e.push(b),c(b,a,h,0,i,d,e)}function g(a,b,c){return b?(c?bb:rb)(O(a),b):O(a)}function l(a,b,c,d){if(T(a,b))return!0;var e,g,f,i=P(a);if(!s(a)||!s(b)||i!=P(b)||K(a)!=K(b))return!1;switch(c=p(c)?c.concat([a]):[a],d=p(d)?d.concat([b]):[b],i){case"Boolean":case"String":case"Number":return a.valueOf()==b.valueOf();case"RegExp":return h(a)==h(b);case"Error":return a.message==b.message}if(g=z(a),e=g.length,e!=z(b).length)return!1;for(;e--;)if(!(~c[D](a[f=g[e]])&&~d[D](b[f])||l(a[f],b[f],c,d)))return!1;return!0}function n(b,g,h){for(var c,d=a(b),e=m(d),i=e.length,f=0;i>f;)g.call(h,d[c=e[f++]],c,b);return b}function o(c,g,h){for(var b,d=a(c),e=m(d),i=e.length,f=0;i>f;)if(g.call(h,d[b=e[f++]],b,c))return b}b(d,{has:j,isEnumerable:tb,isPrototype:E(I.isPrototypeOf),classof:P,bind:function(b,c){var a=H(arguments);return a.splice(1,1),N.bind.apply(b[c],a)},getPropertyDescriptor:Ib,getOwnPropertyDescriptors:W,getPropertyDescriptors:function(a){for(var b,f,c,d,e=W(a);a=K(a);)for(c=z(a),b=0,f=c.length;f>b;)j(e,d=c[b++])||(e[d]=Q(a,d));return e},getPropertyNames:function(a){for(var b,e,c,f,d=z(a);a=K(a);)for(b=0,c=z(a),e=c.length;e>b;)~d[D](f=c[b++])||d.push(f);return d},make:g,plane:function(a,b){return g(null,a,b)},clone:f,merge:c,defaults:function(a,b){return c(a,b,1,1)},values:function(b){for(var c=m(b),d=c.length,e=k(d),a=0;d>a;)e[a]=b[c[a++]];return e},invert:Db,every:function(b,g,h){for(var c,d=a(b),e=m(d),i=e.length,f=0;i>f;)if(!g.call(h,d[c=e[f++]],c,b))return!1;return!0},filter:function(d,h,i){for(var b,c=a(d),e={},f=m(c),j=f.length,g=0;j>g;)h.call(i,c[b=f[g++]],b,d)&&(e[b]=c[b]);return e},find:function(a,c,d){var b=o(a,c,d);return b===e?e:a[b]},findIndex:o,forEach:n,indexOf:function(f,g){for(var b,c=a(f),d=m(c),h=d.length,e=0;h>e;)if(T(c[b=d[e++]],g))return b},map:function(c,h,i){for(var b,d=a(c),e={},f=m(d),j=f.length,g=0;j>g;)e[b=f[g++]]=h.call(i,d[b],b,c);return e},reduce:function(e,i,b,j){var f,c=a(e),d=m(c),g=0,h=d.length;if(3>arguments.length){if(!h--)throw t(ob);b=c[d.shift()]}for(;h>g;)b=i.call(j,b,c[f=d[g++]],f,e);return b},some:function(b,g,h){for(var c,d=a(b),e=m(d),i=e.length,f=0;i>f;)if(g.call(h,d[c=e[f++]],c,b))return!0;return!1},props:function(b,i){b=a(b);for(var c,d,f=m(b),g={},j=f.length,h=0;j>h;)c=f[h++],d=b[c],g[c]=d==e?e:d[i];return g},reduceTo:function(b,c,a){return a=d(a),n(b,c,a),a},deepEqual:l,isObject:s,isUndefined:function(a){return a===e},isNull:function(a){return null===a},isNumber:function(a){return"[object Number]"==v(a)},isString:Cb,isBoolean:function(a){return a===!!a||"[object Boolean]"==v(a)},isArray:p,isFunction:i,isRegExp:function(a){return"[object RegExp]"==v(a)},isDate:function(a){return"[object Date]"==v(a)},isError:function(a){return"[object Error]"==v(a)}})}();var fb=S[c];b(d,{Wrap:S}),r("defineProperty,defineProperties,getPrototypeOf,create,assign,mixin,getOwnPropertyDescriptors,getPropertyDescriptors,make,plane,clone,merge,defaults,invert,filter,forEach,map,props,reduceTo").forEach(function(a){var b=d[a];i(b)&&w(fb,a,C(6,function(){var a,c=this.value,d=[c];return kb.apply(d,arguments),a=b.apply(this,d),c===a?this:new S(a)}))}),z(d).forEach(function(a){var b=d[a];i(b)&&!j(fb,a)&&w(fb,a,C(6,function(){var a=[this.value];return kb.apply(a,arguments),b.apply(this,a)}))}),b(fb,{get:function(a){var b=this.value;return j(b,a)?b[a]:e},set:function(a,b){return this.value[a]=b,this},"delete":function(a){return delete this.value[a],this}}),!function(){function d(e){for(var d=0,b=c(this,e),a=0,f=g(b.length);f>a;a++)a in b&&(d+=+b[a]);return d}function f(i){for(var c,d=a(this),f=g(d.length),h=k(f),b=0;f>b;b++)b in d&&(c=d[b],h[b]=c==e?e:c[i]);return h}function c(b,c){switch(P(c)){case"Function":return yb.call(b,c);case"String":case"Number":return f.call(b,c)}return a(b)}b(n,{at:function(b){return a(this)[0>b?this.length+b:b]},props:f,reduceTo:X,indexSame:function(b){return o(a(this),b)},merge:function(b){return kb.apply(this,a(b)),this},sum:d,avg:function(a){return this.length?d.call(this,a)/this.length:0},min:function(a){return G.apply(e,c(this,a))},max:function(a){return jb.apply(e,c(this,a))},unique:function(f){for(var b,a=[],d=c(this,f),h=g(d.length),e=0;h>e;)~o(a,b=d[e++])||a.push(b);return a},cross:function(f){for(var b,c=[],d=a(this),h=g(d.length),i=a(f),e=0;h>e;)!~o(c,b=d[e++])&&~o(i,b)&&c.push(b);return c}})}(),b(k,X.call(r("concat,join,pop,push,reverse,shift,slice,sort,splice,unshift,"+D+",lastIndexOf,every,some,forEach,map,filter,reduce,reduceRight,find,findIndex,at,props,reduceTo,indexSame,merge,sum,avg,min,max,unique,cross"),function(a){a in n&&(this[a]=E(n[a]))})),b(J,{toInteger:B}),b(pb,{div:function(b){var a=this/b;return(a>0?R:hb)(a)},times:function(b,e){var a=0,c=0|this,d=k(c);if(i(b))for(;c>a;)d[a]=b.call(e,a,a++,this);return d},random:function(d){var a=this||0,b=d||0,c=G(a,b);return mb()*(jb(a,b)-c)+c},rand:function(d){var a=B(this),b=B(d),c=G(a,b);return R(mb()*(jb(a,b)+1-c)+c)},isOdd:function(){return!(!(this%2)||this%1)},isEven:function(){return 0===this%2},format:function(b,c,f){var b=g(b),a=h(B(this)),d=A(B(gb(l.round((this-a)*ub(10,b)))),b);return c&&(a=a.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+c),d=d.replace(/(\d{3})(?=\d)/g,"$1"+c)),b?a+(f==e?".":f)+d:a}}),b(pb,X.call(r("round,floor,ceil,abs,sin,asin,cos,acos,tan,atan,exp,pow,sqrt,max,min,pow,atan2,acosh,asinh,atanh,cbrt,cosh,expm1,hypot,imul,log1p,log10,log2,sign,sinh,tanh,trunc"),function(a){a in l&&(this[a]=Hb.call(l[a]))})),!function(){var d=x(Bb),e=x(sb),a={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},c=Db(a),f=x("["+m(a).join("")+"]","g"),g=x("("+m(c).join("|")+")","g"),i=/([\\\/'*+?|()\[\]{}.^$])/g;b(ib,{trimLeft:function(){return h(this).replace(d,"")},trimRight:function(){return h(this).replace(e,"")},escapeHTML:function(){return h(this).replace(f,function(b){return a[b]})},unescapeHTML:function(){return h(this).replace(g,function(b,a){return c[a]})},escapeURL:function(a){return(a?encodeURIComponent:encodeURI)(this)},unescapeURL:function(a){return(a?decodeURIComponent:decodeURI)(this)},escapeRegExp:function(){return h(this).replace(i,"\\$1")},reverse:function(){return h(this).split("").reverse().join("")},at:function(a){var b=h(this);return b.charAt(0>a?b.length+a:a)}})}(),b(x[c],{fn:Fb,getFlags:Ab}),!function(){function o(m,c){var b=this,g=a[c&&j(a,c)?c:f];return h(m).replace(n,function(a,c){switch(c){case"ms":return b.getMilliseconds();case"s":return b[k]();case"ss":return A(b[k](),2);case"m":return b[l]();case"mm":return A(b[l](),2);case"h":return b[e]()%12||12;case"hh":return A(b[e]()%12||12,2);case"H":return b[e]();case"HH":return A(b[e](),2);case"d":return b.getDate();case"dd":return A(b.getDate(),2);case"w":return g.w[b.getDay()];case"n":return b[d]()+1;case"nn":return A(b[d]()+1,2);case"M":return g.M[b[d]()];case"MM":return g.MM[b[d]()];case"yy":return A(b[i]()%100,2);case"yyyy":return b[i]()}return a})}function g(c,b){a[c]={w:r(b.w),M:r(b.M).map(m(0)),MM:r(b.M).map(m(1))}}function m(a){return function(b){return b.replace(/\+(.+)$/,function(c,b){return b.split("|")[a]})}}var n=/\b(\w\w*)\b/g,f="en",a={},k="getSeconds",l="getMinutes",e="getHours",d="getMonth",i="getFullYear";b(ab,{locale:function(b){return j(a,b)&&(f=b),f},addLocale:g}),b(ab[c],{format:o}),g("en",{w:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",M:"January,February,March,April,May,June,July,August,September,October,November,December"}),g("ru",{w:"Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота",M:"Январ+ь|я,Феврал+ь|я,Март+|а,Апрел+ь|я,Ма+й|я,Июн+ь|я,Июл+ь|я,Август+|а,Сентябр+ь|я,Октябр+ь|я,Ноябр+ь|я,Декабр+ь|я"})}(),b(F,{series:function(a,c){function h(i,k){i==b&&(f=b++in a,!g||!k&&f?f&&(d=y.call(arguments,j),d.push(q(h,b)),a[b].apply(e,d)):c.apply(e,M(arguments)))}var d,f,g=i(c),j=g?2:1,b=0;a.length?a[0](q(h,0)):g&&c()},parallel:wb}),b(n,{asyncMap:function(a,b){wb(yb.call(this,function(b){return q(a,b)}),b)}});var nb=f.console||{},Z=X.call(r("assert,count,clear,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,table,trace,warn,markTimeline,profile,profileEnd,time,timeEnd,timeStamp"),function(a){this[a]=function(){return nb[a]&&Z.enable&&$.call(nb[a],nb,arguments)}},{enable:!0});try{delete f.console}catch(Kb){}Z=f.console=b(Z.log,Z)}("undefined"!=typeof window?window:global,Function,Object,Array,String,Number,RegExp,Date,TypeError,Math,isFinite); | ||
//# sourceMappingURL=./core.min.map |
1237
index.js
/** | ||
* Core.js v0.0.3 | ||
* Core.js v0.0.5 | ||
* http://core.zloirock.ru | ||
@@ -19,6 +19,4 @@ * © 2013 Denis Pushkarev | ||
, defineProperty = Object.defineProperty | ||
, pop = $Array.pop | ||
, push = $Array.push | ||
, slice = $Array.slice | ||
, unshift = $Array.unshift | ||
, apply = $Function.apply | ||
@@ -28,5 +26,3 @@ , call = $Function.call | ||
, ceil = Math.ceil | ||
, exp = Math.exp | ||
, floor = Math.floor | ||
, ln = Math.log | ||
, max = Math.max | ||
@@ -36,7 +32,4 @@ , min = Math.min | ||
, random = Math.random | ||
, sqrt = Math.sqrt | ||
, protoInObject = function(F){ | ||
F = Function(); | ||
return new F().__proto__ == F[prototype] | ||
} | ||
, DESCRIPTORS = 1 | ||
, REDUCE_ERROR = 'Reduce of empty object with no initial value' | ||
// How to get the context for calling the methods of the Array.prototype | ||
@@ -46,3 +39,3 @@ // Dummy, polyfill for not array-like strings for old ie in es5shim.js | ||
, isArray = Array.isArray || function(it){ | ||
return $toString(it) == '[object Array]' | ||
return toString(it) == '[object Array]' | ||
} | ||
@@ -52,32 +45,48 @@ , toArray = Array.from || function(arrayLike){ | ||
} | ||
, toString = 'toString' | ||
, toStringKey = 'toString' | ||
, $unbind = unbind.call(unbind) | ||
, $part = $unbind(part) | ||
// Unbind Object.prototype methods | ||
, _hasOwnProperty = $Object.hasOwnProperty | ||
, _toString = $Object[toString] | ||
, _isPrototypeOf = $Object.isPrototypeOf | ||
, _propertyIsEnumerable = $Object.propertyIsEnumerable | ||
, has = function(it, key){ | ||
return _hasOwnProperty.call(it, key) | ||
} | ||
, $toString = function(it){ | ||
return _toString.call(it) | ||
} | ||
, isPrototype = function(it, object){ | ||
return _isPrototypeOf.call(it, object) | ||
} | ||
, isEnumerable = function(it, key){ | ||
return _propertyIsEnumerable.call(it, key) | ||
} | ||
, $DESC = true | ||
, REDUCE_ERROR = 'Reduce of empty object with no initial value' | ||
, nativeFunctionRegExp = /^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/; | ||
, has = $unbind($Object.hasOwnProperty) | ||
, toString = $unbind($Object[toStringKey]) | ||
, isEnumerable = $unbind($Object.propertyIsEnumerable) | ||
// Native function? | ||
, isNative = RegExpToFunction.call(/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/); | ||
// Object internal [[Class]] | ||
function classof(it /*, args...*/){ | ||
return it === null ? 'Null' : it == undefined | ||
? 'Undefined' : $toString(it).slice(8, -1); | ||
function classof(it){ | ||
return it === undefined ? 'Undefined' : it == undefined ? 'Null' | ||
: toString(it).slice(8, -1) | ||
} | ||
// Native function? | ||
function isNative(it){ | ||
return nativeFunctionRegExp.test(it) | ||
// Simple bind context | ||
function ctx(that){ | ||
var fn = this; | ||
return function(){ | ||
return fn.apply(that, arguments); | ||
} | ||
} | ||
// Unbind method from context | ||
function unbind(){ | ||
return ctx.call(call, this); | ||
} | ||
// Partiall apply | ||
function part(/*args...*/){ | ||
var fn = this | ||
, i = 0 | ||
, length1 = arguments.length | ||
, args1 = Array(length1); | ||
while(length1 > i)args1[i] = arguments[i++]; | ||
return function(/*args...*/){ | ||
var args2 = args1.slice() | ||
, length2 = arguments.length | ||
, i = 0; | ||
while(length2 > i)args2[length1 + i] = arguments[i++]; | ||
return apply.call(fn, this, args2) | ||
} | ||
} | ||
function RegExpToFunction(){ | ||
var that = this; | ||
return function(it){ | ||
return that.test(it) | ||
} | ||
} | ||
function extendBuiltInObject(target, source, forced /* = false */){ | ||
@@ -94,6 +103,2 @@ for(var key in source){ | ||
} | ||
// splitComma('str1,str2,str3') => ['str1', 'str2', 'str3'] | ||
function splitComma(it){ | ||
return String(it).split(','); | ||
} | ||
function descriptor(bitmap, value){ | ||
@@ -107,2 +112,6 @@ return { | ||
} | ||
// splitComma('str1,str2,str3') => ['str1', 'str2', 'str3'] | ||
function splitComma(it){ | ||
return String(it).split(','); | ||
} | ||
// Module : stringInt | ||
@@ -119,3 +128,2 @@ var trimWS = '[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]' | ||
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor | ||
, some = $Array.some | ||
, forEach = $Array.forEach | ||
@@ -125,21 +133,2 @@ , map = $Array.map | ||
// Module : functionInt | ||
// partiall apply | ||
function part(/*args...*/){ | ||
var fn = this | ||
, i = 0 | ||
, length1 = arguments.length | ||
, args1 = Array(length1); | ||
while(length1 > i)args1[i] = arguments[i++]; | ||
return function(/*args...*/){ | ||
var args2 = args1.slice() | ||
, length2 = arguments.length | ||
, i = 0; | ||
while(length2 > i)args2[length1 + i] = arguments[i++]; | ||
return apply.call(fn, this, args2) | ||
} | ||
} | ||
// unbind method from context | ||
function unbind(){ | ||
return ctx.call(call, this); | ||
} | ||
/** | ||
@@ -161,8 +150,2 @@ * add `this` as first argument | ||
} | ||
function ctx(that){ | ||
var fn = this; | ||
return function(){ | ||
return fn.apply(that, arguments); | ||
} | ||
} | ||
// Module : objectInt | ||
@@ -191,15 +174,11 @@ // http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
} | ||
function isObject(it){ | ||
return it === Object(it) | ||
} | ||
function isString(it){ | ||
return $toString(it) == '[object String]' | ||
return toString(it) == '[object String]' | ||
} | ||
function isFunction(it){ | ||
return $toString(it) == '[object Function]' | ||
return toString(it) == '[object Function]' | ||
} | ||
function isDate(it){ | ||
return $toString(it) == '[object Date]' | ||
} | ||
// IE fix in es5.js | ||
function isArguments(it){ | ||
return $toString(it) == '[object Arguments]' | ||
} | ||
var assign = Object.assign || function(target, source){ | ||
@@ -216,5 +195,2 @@ var props = keys(source) | ||
} | ||
, isObject = Object.isObject || function(it){ | ||
return it === Object(it) | ||
} | ||
/** | ||
@@ -255,12 +231,15 @@ * http://es5.javascript.ru/x9.html#x9.12 | ||
} | ||
// http://es5.github.io/#x9.4 | ||
// http://es5.github.io/#x9.4 | ||
var toInt = Number.toInteger || function(it){ | ||
return (it = +it) != it ? 0 : it != 0 && it != Infinity && it != -Infinity ? (it > 0 ? floor : ceil)(it) : it | ||
} | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-20.1.2.4 | ||
, izNaN = Number.isNaN || function(it){ | ||
return typeof it == 'number' && it !== it | ||
} | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.2 | ||
, izFinite = Number.isFinite || function(it){ | ||
return typeof it == 'number' && isFinite(it) | ||
} | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.3 | ||
, isInt = Number.isInteger || function(it){ | ||
@@ -270,372 +249,371 @@ return izFinite(it) && floor(it) == it; | ||
// Module : regexpInt | ||
function getRegExpFlags(reg){ | ||
function getRegExpFlags(){ | ||
return String(this).match(/[^\/]*$/)[0] | ||
} | ||
// Module : es6 | ||
extendBuiltInObject(Object, { | ||
/** | ||
* 19.1.3.1 Object.assign ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.1 | ||
*/ | ||
assign: assign, | ||
/** | ||
* 19.1.3.10 Object.is ( value1, value2 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.10 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:egal | ||
*/ | ||
is: same, | ||
/** | ||
* 19.1.3.15 Object.mixin ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.15 | ||
*/ | ||
mixin: mixin//, | ||
/** | ||
* 19.1.3.19 Object.setPrototypeOf ( O, proto ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.19 | ||
* work only if browser support __proto__ | ||
setPrototypeOf: protoInObject() | ||
? function(O, proto){ | ||
if(!isObject(O) || !(isObject(proto) || proto === null)){ | ||
throw TypeError("Can't set " + proto + ' as prototype of ' + O) | ||
} | ||
O.__proto__ = proto; | ||
return O | ||
!function(){ | ||
var MAX_SAFE_INTEGER = 0x1fffffffffffff | ||
, exp = Math.exp | ||
, ln = Math.log | ||
, sqrt = Math.sqrt; | ||
extendBuiltInObject(Object, { | ||
/** | ||
* 19.1.3.1 Object.assign ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.1 | ||
*/ | ||
assign: assign, | ||
/** | ||
* 19.1.3.10 Object.is ( value1, value2 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.10 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:egal | ||
*/ | ||
is: same, | ||
/** | ||
* 19.1.3.15 Object.mixin ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.15 | ||
*/ | ||
mixin: mixin//, | ||
/** | ||
* 19.1.3.19 Object.setPrototypeOf ( O, proto ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.19 | ||
* work only if browser support __proto__ | ||
setPrototypeOf: function(O, proto){ | ||
if(!isObject(O) || !(isObject(proto) || proto === null)){ | ||
throw TypeError("Can't set " + proto + ' as prototype of ' + O) | ||
} | ||
: function(){ | ||
throw Error("Can't shim Object.setPrototypeOf") | ||
} | ||
*/ | ||
}); | ||
var MAX_SAFE_INTEGER = 0x1fffffffffffff; | ||
extendBuiltInObject(Number, { | ||
/** | ||
* 20.1.2.1 Number.EPSILON | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number_epsilon | ||
*/ | ||
EPSILON: 2.220446049250313e-16, | ||
/** | ||
* 20.1.2.2 Number.isFinite (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.2 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isfinite | ||
*/ | ||
isFinite: izFinite, | ||
/** | ||
* 20.1.2.3 Number.isInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger | ||
*/ | ||
isInteger: isInt, | ||
/** | ||
* 20.1.2.4 Number.isNaN (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.4 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan | ||
*/ | ||
isNaN: izNaN, | ||
/** | ||
* 20.1.2.5 Number.isSafeInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.5 | ||
*/ | ||
isSafeInteger: function(number){ | ||
return isInt(number) && abs(number) <= MAX_SAFE_INTEGER; | ||
}, | ||
/** | ||
* 20.1.2.6 Number.MAX_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.6 | ||
*/ | ||
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.10 Number.MIN_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.10 | ||
*/ | ||
MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.12 Number.parseFloat (string) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.12 | ||
*/ | ||
parseFloat: parseFloat, | ||
/*** | ||
* 20.1.2.13 Number.parseInt (string, radix) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.13 | ||
*/ | ||
parseInt: parseInt | ||
}); | ||
extendBuiltInObject($Number, { | ||
/** | ||
* 20.1.3.1 Number.prototype.clz () | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.3.1 | ||
*/ | ||
clz: function(){ | ||
var number = this >>> 0; | ||
return number ? 32 - number[toString](2).length : 32 | ||
O.__proto__ = proto; | ||
return O | ||
} | ||
*/ | ||
}); | ||
extendBuiltInObject(Number, { | ||
/** | ||
* 20.1.2.1 Number.EPSILON | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number_epsilon | ||
*/ | ||
EPSILON: 2.220446049250313e-16, | ||
/** | ||
* 20.1.2.2 Number.isFinite (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.2 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isfinite | ||
*/ | ||
isFinite: izFinite, | ||
/** | ||
* 20.1.2.3 Number.isInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger | ||
*/ | ||
isInteger: isInt, | ||
/** | ||
* 20.1.2.4 Number.isNaN (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.4 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan | ||
*/ | ||
isNaN: izNaN, | ||
/** | ||
* 20.1.2.5 Number.isSafeInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.5 | ||
*/ | ||
isSafeInteger: function(number){ | ||
return isInt(number) && abs(number) <= MAX_SAFE_INTEGER; | ||
}, | ||
/** | ||
* 20.1.2.6 Number.MAX_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.6 | ||
*/ | ||
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.10 Number.MIN_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.10 | ||
*/ | ||
MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.12 Number.parseFloat (string) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.12 | ||
*/ | ||
parseFloat: parseFloat, | ||
/*** | ||
* 20.1.2.13 Number.parseInt (string, radix) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.13 | ||
*/ | ||
parseInt: parseInt | ||
}); | ||
extendBuiltInObject($Number, { | ||
/** | ||
* 20.1.3.1 Number.prototype.clz () | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.3.1 | ||
*/ | ||
clz: function(){ | ||
var number = this >>> 0; | ||
return number ? 32 - number[toStringKey](2).length : 32 | ||
} | ||
}); | ||
extendBuiltInObject(Math, { | ||
/** | ||
* 20.2.2.3 Math.acosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.3 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic cosine of x. | ||
*/ | ||
acosh: function(x){ | ||
return ln(x + sqrt(x * x - 1)) | ||
}, | ||
/*** | ||
* 20.2.2.5 Math.asinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.5 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic sine of x. | ||
*/ | ||
asinh: function(x){ | ||
return !izFinite(x) || x === 0 ? x : ln(x + sqrt(x * x + 1)) | ||
}, | ||
/** | ||
* 20.2.2.7 Math.atanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.7 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic tangent of x. | ||
*/ | ||
atanh: function(x){ | ||
return x === 0 ? x : 0.5 * ln((1 + x) / (1 - x)) | ||
}, | ||
/** | ||
* 20.2.2.9 Math.cbrt(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.9 | ||
* Returns an implementation-dependent approximation to the cube root of x. | ||
*/ | ||
cbrt: function(x){ | ||
return sign(x) * pow(abs(x), 1/3); | ||
}, | ||
/** | ||
* 20.2.2.12 Math.cosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.12 | ||
* Returns an implementation-dependent approximation to the hyperbolic cosine of x. | ||
*/ | ||
cosh: function(x){ | ||
return ((x = +x) == -Infinity) || x === 0 ? x : x(exp(x) + exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.14 Math.expm1 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.14 | ||
* Returns an implementation-dependent approximation to subtracting 1 from the exponential function of x | ||
*/ | ||
expm1: function(x){ | ||
return same(x, -0) ? -0 : x > -1.0e-6 && x < 1.0e-6 ? x + x * x / 2 : exp(x) - 1 | ||
}, | ||
/** | ||
* 20.2.2.16 Math.hypot( value1 , value2, value3 = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.16 | ||
* Math.hypot returns an implementation-dependent approximation of the square root of the sum of squares of its arguments. | ||
*/ | ||
hypot: function(x, y, /*?*/z){ | ||
if(z === undefined)z = 0; | ||
return isFinite(x) ? isFinite(y) ? isFinite(z) ? sqrt(x * x + y * y + z * z) : z : y : x | ||
}, | ||
/** | ||
* 20.2.2.17 Math.imul(x, y) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.17 | ||
*/ | ||
imul: function(x, y){ | ||
var xh = (x >>> 0x10) & 0xffff | ||
, xl = x & 0xffff | ||
, yh = (y >>> 0x10) & 0xffff | ||
, yl = y & 0xffff; | ||
return xl * yl + (((xh * yl + xl * yh) << 0x10) >>> 0) | 0 | ||
}, | ||
/** | ||
* 20.2.2.19 Math.log1p (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.19 | ||
* Returns an implementation-dependent approximation to the natural logarithm of 1 + x. | ||
* The result is computed in a way that is accurate even when the value of x is close to zero. | ||
*/ | ||
log1p: function(x){ | ||
return (x > -1.0e-8 && x < 1.0e-8) ? (x - x * x / 2) : ln(1 + x) | ||
}, | ||
/** | ||
* 20.2.2.20 Math.log10 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.20 | ||
* Returns an implementation-dependent approximation to the base 10 logarithm of x. | ||
*/ | ||
log10: function(x){ | ||
return ln(x) / Math.LN10 | ||
}, | ||
/** | ||
* 20.2.2.21 Math.log2 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.21 | ||
* Returns an implementation-dependent approximation to the base 2 logarithm of x. | ||
*/ | ||
log2: function(x){ | ||
return ln(x) / Math.LN2 | ||
}, | ||
/** | ||
* 20.2.2.28 Math.sign(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.28 | ||
* Returns the sign of the x, indicating whether x is positive, negative or zero. | ||
*/ | ||
sign: sign, | ||
/** | ||
* 20.2.2.30 Math.sinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.30 | ||
* Returns an implementation-dependent approximation to the hyperbolic sine of x. | ||
*/ | ||
sinh: function(x){ | ||
return ((x = +x) == -Infinity) || x == 0 ? x : (exp(x) - exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.33 Math.tanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.33 | ||
* Returns an implementation-dependent approximation to the hyperbolic tangent of x. | ||
*/ | ||
tanh: function(x){ | ||
return izFinite(x = +x) ? x == 0 ? x : (exp(x) - exp(-x)) / (exp(x) + exp(-x)) : sign(x) | ||
}, | ||
/** | ||
* 20.2.2.34 Math.trunc(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.34 | ||
* Returns the integral part of the number x, removing any fractional digits. If x is already an integer, the result is x. | ||
*/ | ||
trunc: function(x){ | ||
return (x = +x) == 0 ? x : (x > 0 ? floor : ceil)(x) | ||
} | ||
}); | ||
/* | ||
extendBuiltInObject(String, { | ||
// 21.1.2.2 String.fromCodePoint ( ...codePoints) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.2 | ||
fromCodePoint: function(){ TODO }, | ||
// 21.1.2.4 String.raw ( callSite, ...substitutions) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.4 | ||
raw: function(){ TODO } | ||
}); | ||
*/ | ||
extendBuiltInObject($String, { | ||
/** | ||
* 21.1.3.3 String.prototype.codePointAt (pos) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.3 | ||
*/ | ||
codePointAt: function(pos /* = 0 */){ | ||
var value = String(this) | ||
, size = value.length; | ||
if((pos |= 0) < 0 || pos >= size)return NaN; | ||
var first = value.charCodeAt(pos); | ||
if(first < 0xD800 || first > 0xDBFF || pos + 1 == size)return first; | ||
var second = value.charCodeAt(pos + 1); | ||
return(second < 0xDC00 || first > 0xDFFF) ? first : ((first - 0xD800) << 1024) + (second - 0xDC00) + 0x10000 | ||
}, | ||
/** | ||
* 21.1.3.6 String.prototype.contains (searchString, position = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains | ||
*/ | ||
contains: function(searchString, position /* = 0 */){ | ||
return !!~String(this)[indexOf](searchString, position) | ||
}, | ||
/** | ||
* 21.1.3.7 String.prototype.endsWith (searchString [, endPosition] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.7 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith | ||
*/ | ||
endsWith: function(searchString, endPosition /* = @length */){ | ||
var length = this.length; | ||
searchString += ''; | ||
endPosition = toLength(min(endPosition === undefined ? length : endPosition, length)); | ||
return String(this).slice(endPosition - searchString.length, endPosition) === searchString | ||
}, | ||
/** | ||
* 21.1.3.13 String.prototype.repeat (count) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.13 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat | ||
*/ | ||
repeat: function(count){ | ||
return fill.call(Array(toInt(count)), this).join('') | ||
}, | ||
/** | ||
* 21.1.3.18 String.prototype.startsWith (searchString [, position ] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.18 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith | ||
*/ | ||
startsWith: function(searchString, position /* = 0 */){ | ||
searchString += ''; | ||
position = toLength(min(position, this.length)); | ||
return String(this).slice(position, position + searchString.length) === searchString | ||
} | ||
}); | ||
extendBuiltInObject(Array, { | ||
/** | ||
* 22.1.2.1 Array.from ( arrayLike , mapfn=undefined, thisArg=undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
from: function(arrayLike, mapfn /* -> it */, thisArg /* = undefind */){ | ||
var O = arrayLikeSelf(arrayLike) | ||
, i = 0 | ||
, length = toLength(O.length) | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
if(mapfn)for(; i < length; i++)i in O && (result[i] = mapfn.call(thisArg, O[i], i, O)); | ||
else for(; i < length; i++)i in O && (result[i] = O[i]); | ||
return result | ||
}, | ||
/** | ||
* 22.1.2.3 Array.of ( ...items ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
of: function(/*args...*/){ | ||
var i = 0 | ||
, length = arguments.length | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
while(i < length)result[i] = arguments[i++]; | ||
return result | ||
} | ||
}); | ||
function fill(value, start /* = 0 */, end /* = @length */){ | ||
var length = toLength(this.length); | ||
if((start |= 0) < 0 && (start = length + start) < 0)return this; | ||
end = end == undefined ? length : end | 0; | ||
while(end > start)this[start++] = value; | ||
return this | ||
} | ||
}); | ||
extendBuiltInObject(Math, { | ||
/** | ||
* 20.2.2.3 Math.acosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.3 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic cosine of x. | ||
*/ | ||
acosh: function(x){ | ||
return ln(x + sqrt(x * x - 1)) | ||
}, | ||
/*** | ||
* 20.2.2.5 Math.asinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.5 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic sine of x. | ||
*/ | ||
asinh: function(x){ | ||
return !izFinite(x) || x === 0 ? x : ln(x + sqrt(x * x + 1)) | ||
}, | ||
/** | ||
* 20.2.2.7 Math.atanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.7 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic tangent of x. | ||
*/ | ||
atanh: function(x){ | ||
return x === 0 ? x : 0.5 * ln((1 + x) / (1 - x)) | ||
}, | ||
/** | ||
* 20.2.2.9 Math.cbrt(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.9 | ||
* Returns an implementation-dependent approximation to the cube root of x. | ||
*/ | ||
cbrt: function(x){ | ||
return sign(x) * pow(abs(x), 1/3); | ||
}, | ||
/** | ||
* 20.2.2.12 Math.cosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.12 | ||
* Returns an implementation-dependent approximation to the hyperbolic cosine of x. | ||
*/ | ||
cosh: function(x){ | ||
return ((x = +x) == -Infinity) || x === 0 ? x : x(exp(x) + exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.14 Math.expm1 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.14 | ||
* Returns an implementation-dependent approximation to subtracting 1 from the exponential function of x | ||
*/ | ||
expm1: function(x){ | ||
return same(x, -0) ? -0 : x > -1.0e-6 && x < 1.0e-6 ? x + x * x / 2 : exp(x) - 1 | ||
}, | ||
/** | ||
* 20.2.2.16 Math.hypot( value1 , value2, value3 = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.16 | ||
* Math.hypot returns an implementation-dependent approximation of the square root of the sum of squares of its arguments. | ||
*/ | ||
hypot: function(x, y, /*?*/z){ | ||
if(z === undefined)z = 0; | ||
return isFinite(x) ? isFinite(y) ? isFinite(z) ? sqrt(x * x + y * y + z * z) : z : y : x | ||
}, | ||
/** | ||
* 20.2.2.17 Math.imul(x, y) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.17 | ||
*/ | ||
imul: function(x, y){ | ||
var xh = (x >>> 0x10) & 0xffff | ||
, xl = x & 0xffff | ||
, yh = (y >>> 0x10) & 0xffff | ||
, yl = y & 0xffff; | ||
return xl * yl + (((xh * yl + xl * yh) << 0x10) >>> 0) | 0 | ||
}, | ||
/** | ||
* 20.2.2.19 Math.log1p (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.19 | ||
* Returns an implementation-dependent approximation to the natural logarithm of 1 + x. | ||
* The result is computed in a way that is accurate even when the value of x is close to zero. | ||
*/ | ||
log1p: function(x){ | ||
return (x > -1.0e-8 && x < 1.0e-8) ? (x - x * x / 2) : ln(1 + x) | ||
}, | ||
/** | ||
* 20.2.2.20 Math.log10 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.20 | ||
* Returns an implementation-dependent approximation to the base 10 logarithm of x. | ||
*/ | ||
log10: function(x){ | ||
return ln(x) / Math.LN10 | ||
}, | ||
/** | ||
* 20.2.2.21 Math.log2 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.21 | ||
* Returns an implementation-dependent approximation to the base 2 logarithm of x. | ||
*/ | ||
log2: function(x){ | ||
return ln(x) / Math.LN2 | ||
}, | ||
/** | ||
* 20.2.2.28 Math.sign(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.28 | ||
* Returns the sign of the x, indicating whether x is positive, negative or zero. | ||
*/ | ||
sign: sign, | ||
/** | ||
* 20.2.2.30 Math.sinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.30 | ||
* Returns an implementation-dependent approximation to the hyperbolic sine of x. | ||
*/ | ||
sinh: function(x){ | ||
return ((x = +x) == -Infinity) || x == 0 ? x : (exp(x) - exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.33 Math.tanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.33 | ||
* Returns an implementation-dependent approximation to the hyperbolic tangent of x. | ||
*/ | ||
tanh: function(x){ | ||
return izFinite(x = +x) ? x == 0 ? x : (exp(x) - exp(-x)) / (exp(x) + exp(-x)) : sign(x) | ||
}, | ||
/** | ||
* 20.2.2.34 Math.trunc(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.34 | ||
* Returns the integral part of the number x, removing any fractional digits. If x is already an integer, the result is x. | ||
*/ | ||
trunc: function(x){ | ||
return (x = +x) == 0 ? x : (x > 0 ? floor : ceil)(x) | ||
} | ||
}); | ||
/* | ||
extendBuiltInObject(String, { | ||
// 21.1.2.2 String.fromCodePoint ( ...codePoints) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.2 | ||
fromCodePoint: function(){ TODO }, | ||
// 21.1.2.4 String.raw ( callSite, ...substitutions) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.4 | ||
raw: function(){ TODO } | ||
}); | ||
*/ | ||
extendBuiltInObject($String, { | ||
/** | ||
* 21.1.3.3 String.prototype.codePointAt (pos) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.3 | ||
*/ | ||
codePointAt: function(pos /* = 0 */){ | ||
var value = String(this) | ||
, size = value.length; | ||
if((pos |= 0) < 0 || pos >= size)return NaN; | ||
var first = value.charCodeAt(pos); | ||
if(first < 0xD800 || first > 0xDBFF || pos + 1 == size)return first; | ||
var second = value.charCodeAt(pos + 1); | ||
return(second < 0xDC00 || first > 0xDFFF) ? first : ((first - 0xD800) << 1024) + (second - 0xDC00) + 0x10000 | ||
}, | ||
/** | ||
* 21.1.3.6 String.prototype.contains (searchString, position = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains | ||
*/ | ||
contains: function(searchString, position /* = 0 */){ | ||
return !!~String(this)[indexOf](searchString, position) | ||
}, | ||
/** | ||
* 21.1.3.7 String.prototype.endsWith (searchString [, endPosition] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.7 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith | ||
*/ | ||
endsWith: function(searchString, endPosition /* = @length */){ | ||
var length = this.length; | ||
searchString += ''; | ||
endPosition = toLength(min(endPosition === undefined ? length : endPosition, length)); | ||
return String(this).slice(endPosition - searchString.length, endPosition) === searchString | ||
}, | ||
/** | ||
* 21.1.3.13 String.prototype.repeat (count) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.13 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat | ||
*/ | ||
repeat: function(count){ | ||
return fill.call(Array(toInt(count)), this).join('') | ||
}, | ||
/** | ||
* 21.1.3.18 String.prototype.startsWith (searchString [, position ] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.18 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith | ||
*/ | ||
startsWith: function(searchString, position /* = 0 */){ | ||
searchString += ''; | ||
position = toLength(min(position, this.length)); | ||
return String(this).slice(position, position + searchString.length) === searchString | ||
} | ||
}); | ||
extendBuiltInObject(Array, { | ||
/** | ||
* 22.1.2.1 Array.from ( arrayLike , mapfn=undefined, thisArg=undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
from: function(arrayLike, mapfn /* -> it */, thisArg /* = undefind */){ | ||
var O = arrayLikeSelf(arrayLike) | ||
, i = 0 | ||
, length = toLength(O.length) | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
if(mapfn)for(; i < length; i++)i in O && (result[i] = mapfn.call(thisArg, O[i], i, O)); | ||
else for(; i < length; i++)i in O && (result[i] = O[i]); | ||
return result | ||
}, | ||
/** | ||
* 22.1.2.3 Array.of ( ...items ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
of: function(/*args...*/){ | ||
var i = 0 | ||
, length = arguments.length | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
while(i < length)result[i] = arguments[i++]; | ||
return result | ||
} | ||
}); | ||
function fill(value, start /* = 0 */, end /* = @length */){ | ||
var length = toLength(this.length); | ||
if((start |= 0) < 0 && (start = length + start) < 0)return this; | ||
end = end == undefined ? length : end | 0; | ||
while(end > start)this[start++] = value; | ||
return this | ||
} | ||
extendBuiltInObject($Array, { | ||
/** | ||
* 22.1.3.3 Array.prototype.copyWithin (target, start, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.copywithin | ||
copyWithin: function(target, start, end){ | ||
extendBuiltInObject($Array, { | ||
/** | ||
* 22.1.3.3 Array.prototype.copyWithin (target, start, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.copywithin | ||
copyWithin: function(target, start, end){ | ||
}, | ||
*/ | ||
/** | ||
* 22.1.3.6 Array.prototype.fill (value, start = 0, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-22.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_fill_and_move | ||
*/ | ||
fill: fill, | ||
/** | ||
* 22.1.3.8 Array.prototype.find ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.8 | ||
*/ | ||
find: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, val, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, val = self[i], i, O))return val | ||
}, | ||
/** | ||
* 22.1.3.9 Array.prototype.findIndex ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.9 | ||
*/ | ||
findIndex: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, self[i], i, O))return i; | ||
return -1 | ||
} | ||
}); | ||
}, | ||
*/ | ||
/** | ||
* 22.1.3.6 Array.prototype.fill (value, start = 0, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-22.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_fill_and_move | ||
*/ | ||
fill: fill, | ||
/** | ||
* 22.1.3.8 Array.prototype.find ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.8 | ||
*/ | ||
find: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, val, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, val = self[i], i, O))return val | ||
}, | ||
/** | ||
* 22.1.3.9 Array.prototype.findIndex ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.9 | ||
*/ | ||
findIndex: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, self[i], i, O))return i; | ||
return -1 | ||
} | ||
}); | ||
}(); | ||
// Module : es6c | ||
!function(){ | ||
var Map = global.Map | ||
, Set = global.Set | ||
, sizeDesc = { | ||
!function(Map, Set){ | ||
var sizeDesc = { | ||
'get': function(){ | ||
@@ -668,3 +646,3 @@ return this._values.length; | ||
defineProperties(this, {_keys: descriptor(4, []), _values: descriptor(4, [])}); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
}, | ||
@@ -682,3 +660,3 @@ /** | ||
values.splice(index, 1); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
return true | ||
@@ -724,3 +702,3 @@ } | ||
values.push(value); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
} | ||
@@ -731,3 +709,3 @@ else values[index] = value; | ||
}); | ||
$DESC && defineProperty(Map[prototype], 'size', sizeDesc); | ||
DESCRIPTORS && defineProperty(Map[prototype], 'size', sizeDesc); | ||
} | ||
@@ -764,3 +742,3 @@ // IE 11 fix | ||
values.push(value); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
} | ||
@@ -775,3 +753,3 @@ return this | ||
defineProperty(this, '_values', descriptor(4, [])); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
}, | ||
@@ -787,3 +765,3 @@ /** | ||
values.splice(index, 1); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
return true | ||
@@ -812,3 +790,3 @@ } | ||
}); | ||
$DESC && defineProperty(Set[prototype], 'size', sizeDesc); | ||
DESCRIPTORS && defineProperty(Set[prototype], 'size', sizeDesc); | ||
} | ||
@@ -824,9 +802,200 @@ // IE 11 fix | ||
} | ||
}(); | ||
}(global.Map, global.Set); | ||
// Module : promise | ||
/** | ||
* ES6 Promises | ||
* https://github.com/domenic/promises-unwrapping | ||
* Based on: | ||
* https://github.com/jakearchibald/ES6-Promises | ||
* https://github.com/tildeio/rsvp.js | ||
*/ | ||
!function(Promise){ | ||
isFunction(Promise) | ||
// Some of these methods are missing from Firefox/Chrome experimental implementations | ||
&& splitComma('cast,resolve,reject,all,race').every($part(has, Promise)) | ||
// Older version of the spec had a resolver object as the arg rather than a function | ||
&& (function(resolve){ | ||
new Promise(function(r){ resolve = r }); | ||
return isFunction(resolve) | ||
})() | ||
&& 0 | ||
|| !function(){ | ||
var PENDING | ||
, SEALED = 0 | ||
, FULFILLED = 1 | ||
, REJECTED = 2 | ||
, _subscribers = '_subscribers' | ||
, _state = '_state' | ||
, _detail = '_detail' | ||
, setImmediate = global.setImmediate | ||
// https://github.com/domenic/promises-unwrapping#the-promise-constructor | ||
, Promise = global.Promise = function(resolver){ | ||
var promise = this | ||
, rejectPromise = $part(reject, promise); | ||
if(!isFunction(resolver))throw TypeError('First argument of Promise constructor must be an function'); | ||
if(!(promise instanceof Promise))throw TypeError('Promise constructor cannot be called as a function.'); | ||
promise[_subscribers] = []; | ||
try { | ||
resolver($part(resolve, promise), rejectPromise) | ||
} catch(e){ | ||
rejectPromise(e) | ||
} | ||
} | ||
function invokeCallback(settled, promise, callback, detail){ | ||
var hasCallback = isFunction(callback) | ||
, value, error, succeeded, failed; | ||
if(hasCallback){ | ||
try { | ||
value = callback(detail); | ||
succeeded = 1; | ||
} catch(e){ | ||
failed = 1; | ||
error = e; | ||
} | ||
} else { | ||
value = detail; | ||
succeeded = 1; | ||
} | ||
if(handleThenable(promise, value))return; | ||
else if(hasCallback && succeeded)resolve(promise, value); | ||
else if(failed)reject(promise, error); | ||
else if(settled === FULFILLED)resolve(promise, value); | ||
else if(settled === REJECTED)reject(promise, value); | ||
} | ||
function publish(promise, settled){ | ||
var subscribers = promise[_subscribers] | ||
, detail = promise[_detail] | ||
, child, callback, i = 0; | ||
for(; i < subscribers.length; i += 3){ | ||
child = subscribers[i]; | ||
callback = subscribers[i + settled]; | ||
invokeCallback(settled, child, callback, detail); | ||
} | ||
promise[_subscribers] = null; | ||
} | ||
assign(Promise[prototype], { | ||
// https://github.com/domenic/promises-unwrapping#promiseprototypecatch--onrejected- | ||
'catch': function(onRejection){ | ||
return this.then(null, onRejection); | ||
}, | ||
// https://github.com/domenic/promises-unwrapping#promiseprototypethen--onfulfilled--onrejected- | ||
then: function(onFulfillment, onRejection){ | ||
var promise = this | ||
, thenPromise = new Promise(Function()) | ||
, subscribers, length; | ||
if(promise[_state])setImmediate(function(){ | ||
invokeCallback(promise[_state], thenPromise, arguments[promise[_state] - 1], promise[_detail]) | ||
}, onFulfillment, onRejection); | ||
else { | ||
subscribers = promise[_subscribers]; | ||
length = subscribers.length; | ||
subscribers[length] = thenPromise; | ||
subscribers[length + FULFILLED] = onFulfillment; | ||
subscribers[length + REJECTED] = onRejection; | ||
} | ||
return thenPromise; | ||
} | ||
}); | ||
assign(Promise, { | ||
// https://github.com/domenic/promises-unwrapping#promiseall--iterable- | ||
all: function(promises){ | ||
if(!isArray(promises))throw TypeError('You must pass an array to all.'); | ||
return new this(function(resolve, reject){ | ||
var results = [] | ||
, remaining = promises.length | ||
, promise, i; | ||
if(remaining === 0)resolve([]); | ||
function resolveAll(index, value){ | ||
results[index] = value; | ||
if(--remaining === 0)resolve(results) | ||
} | ||
for(i = 0; i < promises.length; i++){ | ||
(promise = promises[i]) && isFunction(promise.then) | ||
? promise.then($part(resolveAll, i), reject) | ||
: resolveAll(i, promise) | ||
} | ||
}) | ||
}, | ||
// https://github.com/domenic/promises-unwrapping#promisecast--x- | ||
cast: function(object){ | ||
if(object && object instanceof this)return object; | ||
return new this(function(resolve){ | ||
resolve(object) | ||
}) | ||
}, | ||
// https://github.com/domenic/promises-unwrapping#promiserace--iterable- | ||
race: function(promises){ | ||
if(!isArray(promises))throw TypeError('You must pass an array to race.'); | ||
return new this(function(resolve, reject){ | ||
var results = [] | ||
, i = 0, promise; | ||
while(promises.length > i){ | ||
(promise = promises[i++]) && isFunction(promise.then) | ||
? promise.then(resolve, reject) | ||
: resolve(promise) | ||
} | ||
}) | ||
}, | ||
// https://github.com/domenic/promises-unwrapping#promisereject--r- | ||
reject: function(reason){ | ||
return new this(function(resolve, reject){ | ||
reject(reason) | ||
}) | ||
}, | ||
// https://github.com/domenic/promises-unwrapping#promiseresolve--x- | ||
resolve: function(value){ | ||
return new this(function(resolve, reject){ | ||
resolve(value) | ||
}) | ||
} | ||
}); | ||
function handleThenable(promise, value){ | ||
var resolved; | ||
try { | ||
if(promise === value)throw TypeError('A promises callback cannot return that same promise.'); | ||
if(isObject(value)){ | ||
if(isFunction(value.then)){ | ||
value.then(function(val){ | ||
if(resolved)return true; | ||
resolved = true; | ||
if(value !== val)resolve(promise, val); | ||
else fulfill(promise, val) | ||
}, function(val){ | ||
if(resolved)return true; | ||
resolved = true; | ||
reject(promise, val) | ||
}); | ||
return true | ||
} | ||
} | ||
} catch(error){ | ||
if(!resolved)reject(promise, error); | ||
return true | ||
} | ||
return false | ||
} | ||
function resolve(promise, value){ | ||
if(promise === value || !handleThenable(promise, value))fulfill(promise, value) | ||
} | ||
function fulfill(promise, value){ | ||
if(promise[_state] === PENDING){ | ||
promise[_state] = SEALED; | ||
promise[_detail] = value; | ||
setImmediate(function(){ | ||
publish(promise, promise[_state] = FULFILLED) | ||
}) | ||
} | ||
} | ||
function reject(promise, reason){ | ||
if(promise[_state] === PENDING){ | ||
promise[_state] = SEALED; | ||
promise[_detail] = reason; | ||
setImmediate(function(){ | ||
publish(promise, promise[_state] = REJECTED) | ||
}) | ||
} | ||
} | ||
}(); | ||
}(global.Promise); | ||
// Module : function | ||
function invoke(args){ | ||
var instance = create(this.prototype) | ||
, result = this.apply(instance, arrayLikeSelf(args || [])); | ||
return isObject(result) ? result : instance | ||
} | ||
function inherits(parent){ | ||
@@ -838,3 +1007,3 @@ this[prototype] = create(parent[prototype], getOwnPropertyDescriptors(this[prototype])); | ||
isNative: isNative, | ||
inherits: unbind.call(inherits) | ||
inherits: $unbind(inherits) | ||
}); | ||
@@ -875,11 +1044,6 @@ extendBuiltInObject($Function, { | ||
ctx: ctx, | ||
invoke: invoke, | ||
getInstance: function(){ | ||
var getInstance = 'getInstance', instance; | ||
if(!has(this, getInstance)){ // <= protect from Function.prototype.getInstance() | ||
this[getInstance] = function(){ | ||
return instance | ||
}; | ||
return instance = this.invoke(arguments) | ||
} | ||
invoke: function(args){ | ||
var instance = create(this[prototype]) | ||
, result = this.apply(instance, arrayLikeSelf(args || [])); | ||
return isObject(result) ? result : instance | ||
}, | ||
@@ -926,18 +1090,9 @@ once: function(){ | ||
timeout: function(del /*, args...*/){ | ||
return part.call( | ||
clearTimeout, | ||
setTimeout(part.apply(this, slice1(arguments)), del) | ||
) | ||
return $part(clearTimeout, setTimeout(part.apply(this, slice1(arguments)), del)) | ||
}, | ||
interval: function(del /*, args...*/){ | ||
return part.call( | ||
clearInterval, | ||
setInterval(part.apply(this, slice1(arguments)), del) | ||
) | ||
return $part(clearInterval, setInterval(part.apply(this, slice1(arguments)), del)) | ||
}, | ||
immediate: function(/* args...*/){ | ||
return part.call( | ||
clearImmediate, | ||
setImmediate(part.apply(this, arguments)) | ||
) | ||
return $part(clearImmediate, setImmediate(part.apply(this, arguments))) | ||
}, | ||
@@ -962,3 +1117,3 @@ inherits: inherits | ||
targetDescriptor = getOwnPropertyDescriptor(target, key) || $Object; | ||
if(targetDescriptor.configurable !== false && /*!targetDescriptor.get && !targetDescriptor.set && */delete target[key]){ | ||
if(targetDescriptor.configurable !== false && delete target[key]){ | ||
sourceDescriptor = getOwnPropertyDescriptor(source, key); | ||
@@ -1072,7 +1227,2 @@ if(deep && !sourceDescriptor.get && !sourceDescriptor.set){ | ||
} | ||
function objectReduceTo(object, fn, target){ | ||
target = Object(target); | ||
forOwnKeys(object, fn, target); | ||
return target; | ||
} | ||
function forOwnKeys(object, fn, that /* = undefined */){ | ||
@@ -1100,4 +1250,9 @@ var O = arrayLikeSelf(object) | ||
isEnumerable: isEnumerable, | ||
isPrototype: isPrototype, | ||
isPrototype: $unbind($Object.isPrototypeOf), | ||
classof: classof, | ||
bind: function(object, key){ | ||
var args = toArray(arguments); | ||
args.splice(1, 1); | ||
return $Function.bind.apply(object[key], args) | ||
}, | ||
// Extended object api from harmony and strawman : | ||
@@ -1138,3 +1293,3 @@ // http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
make: make, | ||
// Shugar for Object.make(null[, params, simple]) | ||
// Shugar for Object.make(null[, props, simple]) | ||
plane: function(props, simple /* = false */){ | ||
@@ -1145,7 +1300,7 @@ return make(null, props, simple) | ||
merge: merge, | ||
// Shugar for Object.merge(targ, src, 1, 1) | ||
// Shugar for Object.merge(target, props, 1, 1) | ||
defaults: function(target, props){ | ||
return merge(target, props, 1, 1) | ||
}, | ||
// {a:b} -> [b] | ||
// {a: b} -> [b] | ||
values: function(object){ | ||
@@ -1251,5 +1406,9 @@ var props = keys(object) | ||
}, | ||
reduceTo: objectReduceTo, | ||
reduceTo: function(object, fn, target){ | ||
target = Object(target); | ||
forOwnKeys(object, fn, target); | ||
return target; | ||
}, | ||
deepEqual: deepEqual, | ||
isObject : isObject, | ||
isObject: isObject, | ||
isUndefined: function(it){ | ||
@@ -1262,7 +1421,7 @@ return it === undefined | ||
isNumber : function(it){ | ||
return $toString(it) == '[object Number]' | ||
return toString(it) == '[object Number]' | ||
}, | ||
isString : isString, | ||
isBoolean : function(it){ | ||
return it === !!it || $toString(it) == '[object Boolean]' | ||
return it === !!it || toString(it) == '[object Boolean]' | ||
}, | ||
@@ -1272,9 +1431,10 @@ isArray : isArray, | ||
isRegExp : function(it){ | ||
return $toString(it) == '[object RegExp]' | ||
return toString(it) == '[object RegExp]' | ||
}, | ||
isDate : isDate, | ||
isDate : function(it){ | ||
return toString(it) == '[object Date]' | ||
}, | ||
isError : function(it){ | ||
return $toString(it) == '[object Error]' | ||
}, | ||
isArguments: isArguments | ||
return toString(it) == '[object Error]' | ||
} | ||
}); | ||
@@ -1414,3 +1574,5 @@ }(); | ||
extendBuiltInObject(Array, reduceTo.call( | ||
splitComma( | ||
// IE... | ||
// getOwnPropertyNames($Array), | ||
splitComma( | ||
// ES3: | ||
@@ -1426,3 +1588,3 @@ 'concat,join,pop,push,reverse,shift,slice,sort,splice,unshift,' + | ||
function(key){ | ||
if(key in $Array)this[key] = unbind.call($Array[key]) | ||
if(key in $Array)this[key] = $unbind($Array[key]) | ||
} | ||
@@ -1456,6 +1618,6 @@ )); | ||
}, | ||
odd: function(){ | ||
isOdd: function(){ | ||
return !!(this % 2) && !(this % 1) | ||
}, | ||
even: function(){ | ||
isEven: function(){ | ||
return 0 === this % 2 | ||
@@ -1475,4 +1637,4 @@ }, | ||
extendBuiltInObject($Number, reduceTo.call( | ||
//IE... | ||
//getOwnPropertyNames(Math), | ||
// IE... | ||
// getOwnPropertyNames(Math), | ||
splitComma( | ||
@@ -1543,9 +1705,4 @@ // ES3 | ||
extendBuiltInObject(RegExp[prototype], { | ||
fn: function(){ | ||
var that = this; | ||
return function(it){ | ||
return that.test(it) | ||
} | ||
}, | ||
getFlag: getRegExpFlags | ||
fn: RegExpToFunction, | ||
getFlags: getRegExpFlags | ||
}); | ||
@@ -1555,4 +1712,4 @@ // Module : date | ||
function format(template, lang /* = current */){ | ||
var that = isDate(this) ? this : new Date | ||
, locale = locales[has(locales, lang) ? lang : current]; | ||
var that = this | ||
, locale = locales[lang && has(locales, lang) ? lang : current]; | ||
return String(template).replace(formatRegExp, function(part, key){ | ||
@@ -1609,4 +1766,3 @@ switch(key){ | ||
}, | ||
addLocale: addLocale, | ||
format: format | ||
addLocale: addLocale | ||
}); | ||
@@ -1624,3 +1780,16 @@ extendBuiltInObject(Date[prototype], {format: format}); | ||
// Module : async | ||
var parallel; | ||
function parallel(fns, then){ | ||
var run = toLength(fns.length) | ||
, results = Array(run); | ||
if(run)forEach.call(fns, function(fn, key){ | ||
fn(function(error, result){ | ||
if(run && !(key in results)){ // <= protect from reexecution | ||
if(error)run = 1; | ||
results[key] = result; | ||
--run || then(error, results); | ||
} | ||
}); | ||
}); | ||
else then(undefined, results); | ||
} | ||
extendBuiltInObject(Function, { | ||
@@ -1638,3 +1807,3 @@ series: function(queue, then /* ? */){ | ||
args = slice.call(arguments, sliceArgs); | ||
args.push(part.call(next, current)); | ||
args.push($part(next, current)); | ||
queue[current].apply(undefined, args) | ||
@@ -1644,18 +1813,5 @@ } | ||
} | ||
queue.length ? queue[0](part.call(next, 0)) : isThen && then() | ||
queue.length ? queue[0]($part(next, 0)) : isThen && then() | ||
}, | ||
parallel: parallel = function(fns, then){ | ||
var run = toLength(fns.length) | ||
, results = Array(run); | ||
if(run)forEach.call(fns, function(fn, key){ | ||
fn(function(error, result){ | ||
if(run && !(key in results)){ // <= protect from reexecution | ||
if(error)run = 1; | ||
results[key] = result; | ||
--run || then(error, results); | ||
} | ||
}); | ||
}); | ||
else then(undefined, results); | ||
} | ||
parallel: parallel | ||
}); | ||
@@ -1665,3 +1821,3 @@ extendBuiltInObject($Array, { | ||
parallel(map.call(this, function(val){ | ||
return part.call(fn, val) | ||
return $part(fn, val) | ||
}), then); | ||
@@ -1675,10 +1831,11 @@ } | ||
splitComma('assert,count,clear,debug,dir,dirxml,error,exception,' + | ||
'group,groupCollapsed,groupEnd,info,log,table,trace,warn,markTimeline,profile,' + | ||
'profileEnd,time,timeEnd,timeStamp'), | ||
'group,groupCollapsed,groupEnd,info,log,table,trace,warn,' + | ||
'markTimeline,profile,profileEnd,time,timeEnd,timeStamp'), | ||
function(key){ | ||
this[key] = function(){ | ||
return _console[key] && $console.enable && apply.call(_console[key], _console, arguments) | ||
}; | ||
}, | ||
{enable: true}); | ||
this[key] = function(){ | ||
return _console[key] && $console.enable && apply.call(_console[key], _console, arguments) | ||
}; | ||
}, | ||
{enable: true} | ||
); | ||
try { | ||
@@ -1685,0 +1842,0 @@ delete global.console |
{ | ||
"name": "core-js", | ||
"description": "Blahblahblah", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -7,3 +7,5 @@ /** | ||
extendBuiltInObject(Array, reduceTo.call( | ||
splitComma( | ||
// IE... | ||
// getOwnPropertyNames($Array), | ||
splitComma( | ||
// ES3: | ||
@@ -19,4 +21,4 @@ 'concat,join,pop,push,reverse,shift,slice,sort,splice,unshift,' + | ||
function(key){ | ||
if(key in $Array)this[key] = unbind.call($Array[key]) | ||
if(key in $Array)this[key] = $unbind($Array[key]) | ||
} | ||
)); |
@@ -1,2 +0,15 @@ | ||
var parallel; | ||
function parallel(fns, then){ | ||
var run = toLength(fns.length) | ||
, results = Array(run); | ||
if(run)forEach.call(fns, function(fn, key){ | ||
fn(function(error, result){ | ||
if(run && !(key in results)){ // <= protect from reexecution | ||
if(error)run = 1; | ||
results[key] = result; | ||
--run || then(error, results); | ||
} | ||
}); | ||
}); | ||
else then(undefined, results); | ||
} | ||
extendBuiltInObject(Function, { | ||
@@ -14,3 +27,3 @@ series: function(queue, then /* ? */){ | ||
args = slice.call(arguments, sliceArgs); | ||
args.push(part.call(next, current)); | ||
args.push($part(next, current)); | ||
queue[current].apply(undefined, args) | ||
@@ -20,18 +33,5 @@ } | ||
} | ||
queue.length ? queue[0](part.call(next, 0)) : isThen && then() | ||
queue.length ? queue[0]($part(next, 0)) : isThen && then() | ||
}, | ||
parallel: parallel = function(fns, then){ | ||
var run = toLength(fns.length) | ||
, results = Array(run); | ||
if(run)forEach.call(fns, function(fn, key){ | ||
fn(function(error, result){ | ||
if(run && !(key in results)){ // <= protect from reexecution | ||
if(error)run = 1; | ||
results[key] = result; | ||
--run || then(error, results); | ||
} | ||
}); | ||
}); | ||
else then(undefined, results); | ||
} | ||
parallel: parallel | ||
}); | ||
@@ -41,5 +41,5 @@ extendBuiltInObject($Array, { | ||
parallel(map.call(this, function(val){ | ||
return part.call(fn, val) | ||
return $part(fn, val) | ||
}), then); | ||
} | ||
}); |
@@ -5,10 +5,11 @@ var _console = global.console || {} | ||
splitComma('assert,count,clear,debug,dir,dirxml,error,exception,' + | ||
'group,groupCollapsed,groupEnd,info,log,table,trace,warn,markTimeline,profile,' + | ||
'profileEnd,time,timeEnd,timeStamp'), | ||
'group,groupCollapsed,groupEnd,info,log,table,trace,warn,' + | ||
'markTimeline,profile,profileEnd,time,timeEnd,timeStamp'), | ||
function(key){ | ||
this[key] = function(){ | ||
return _console[key] && $console.enable && apply.call(_console[key], _console, arguments) | ||
}; | ||
}, | ||
{enable: true}); | ||
this[key] = function(){ | ||
return _console[key] && $console.enable && apply.call(_console[key], _console, arguments) | ||
}; | ||
}, | ||
{enable: true} | ||
); | ||
try { | ||
@@ -15,0 +16,0 @@ delete global.console |
!function(){ | ||
function format(template, lang /* = current */){ | ||
var that = isDate(this) ? this : new Date | ||
, locale = locales[has(locales, lang) ? lang : current]; | ||
var that = this | ||
, locale = locales[lang && has(locales, lang) ? lang : current]; | ||
return String(template).replace(formatRegExp, function(part, key){ | ||
@@ -56,4 +56,3 @@ switch(key){ | ||
}, | ||
addLocale: addLocale, | ||
format: format | ||
addLocale: addLocale | ||
}); | ||
@@ -60,0 +59,0 @@ extendBuiltInObject(Date[prototype], {format: format}); |
!function(){ | ||
// not enum keys | ||
var Empty = Function() | ||
, protoInObject = new Empty().__proto__ == Empty[prototype] | ||
, LTrimRegExp = RegExp(LTrim) | ||
, RTrimRegExp = RegExp(RTrim) | ||
// for fix IE 9- don't enum bug https://developer.mozilla.org/en-US/docs/ECMAScript_DontEnum_attribute | ||
, hidenNames1 = splitComma(toString + ',toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,constructor') | ||
// for fix IE 8- don't enum bug https://developer.mozilla.org/en-US/docs/ECMAScript_DontEnum_attribute | ||
, hidenNames1 = splitComma(toStringKey + ',toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,constructor') | ||
, hidenNames2 = hidenNames1.concat(['length']) | ||
@@ -13,3 +14,3 @@ , hidenNames1Length = hidenNames1.length | ||
// Create object with null as it's prototype | ||
, createNullProtoObject = protoInObject() | ||
, createNullProtoObject = protoInObject | ||
? function(){ | ||
@@ -48,10 +49,9 @@ return {__proto__: null} | ||
// The engine has a guaranteed way to get a prototype? | ||
, $PROTO = !!Object.getPrototypeOf || protoInObject(); | ||
, $PROTO = !!Object.getPrototypeOf || protoInObject; | ||
// The engine works fine with descriptors? Thank's IE8 for his funny defineProperty. | ||
try { | ||
defineProperty({}, 0, $Object); | ||
$DESC = true; | ||
} | ||
catch(e){ | ||
$DESC = false; | ||
DESCRIPTORS = 0; | ||
/** | ||
@@ -94,3 +94,3 @@ * 15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) | ||
, proto = O.__proto__ || ((constructor = O.constructor) ? constructor[prototype] : $Object); | ||
return O != proto && toString in O ? proto : null | ||
return O != proto && toStringKey in O ? proto : null | ||
}, | ||
@@ -297,6 +297,2 @@ /** | ||
}}); | ||
// IE isArguments fix | ||
isArguments(Function('return arguments')()) || (isArguments = function(it){ | ||
return !!(it && isFunction(it.callee)) | ||
}); | ||
}(); |
717
src/es6.js
@@ -1,361 +0,362 @@ | ||
extendBuiltInObject(Object, { | ||
/** | ||
* 19.1.3.1 Object.assign ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.1 | ||
*/ | ||
assign: assign, | ||
/** | ||
* 19.1.3.10 Object.is ( value1, value2 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.10 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:egal | ||
*/ | ||
is: same, | ||
/** | ||
* 19.1.3.15 Object.mixin ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.15 | ||
*/ | ||
mixin: mixin//, | ||
/** | ||
* 19.1.3.19 Object.setPrototypeOf ( O, proto ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.19 | ||
* work only if browser support __proto__ | ||
setPrototypeOf: protoInObject() | ||
? function(O, proto){ | ||
if(!isObject(O) || !(isObject(proto) || proto === null)){ | ||
throw TypeError("Can't set " + proto + ' as prototype of ' + O) | ||
} | ||
O.__proto__ = proto; | ||
return O | ||
!function(){ | ||
var MAX_SAFE_INTEGER = 0x1fffffffffffff | ||
, exp = Math.exp | ||
, ln = Math.log | ||
, sqrt = Math.sqrt; | ||
extendBuiltInObject(Object, { | ||
/** | ||
* 19.1.3.1 Object.assign ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.1 | ||
*/ | ||
assign: assign, | ||
/** | ||
* 19.1.3.10 Object.is ( value1, value2 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.10 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:egal | ||
*/ | ||
is: same, | ||
/** | ||
* 19.1.3.15 Object.mixin ( target, source ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.15 | ||
*/ | ||
mixin: mixin//, | ||
/** | ||
* 19.1.3.19 Object.setPrototypeOf ( O, proto ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-19.1.3.19 | ||
* work only if browser support __proto__ | ||
setPrototypeOf: function(O, proto){ | ||
if(!isObject(O) || !(isObject(proto) || proto === null)){ | ||
throw TypeError("Can't set " + proto + ' as prototype of ' + O) | ||
} | ||
: function(){ | ||
throw Error("Can't shim Object.setPrototypeOf") | ||
} | ||
*/ | ||
}); | ||
var MAX_SAFE_INTEGER = 0x1fffffffffffff; | ||
extendBuiltInObject(Number, { | ||
/** | ||
* 20.1.2.1 Number.EPSILON | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number_epsilon | ||
*/ | ||
EPSILON: 2.220446049250313e-16, | ||
/** | ||
* 20.1.2.2 Number.isFinite (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.2 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isfinite | ||
*/ | ||
isFinite: izFinite, | ||
/** | ||
* 20.1.2.3 Number.isInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger | ||
*/ | ||
isInteger: isInt, | ||
/** | ||
* 20.1.2.4 Number.isNaN (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.4 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan | ||
*/ | ||
isNaN: izNaN, | ||
/** | ||
* 20.1.2.5 Number.isSafeInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.5 | ||
*/ | ||
isSafeInteger: function(number){ | ||
return isInt(number) && abs(number) <= MAX_SAFE_INTEGER; | ||
}, | ||
/** | ||
* 20.1.2.6 Number.MAX_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.6 | ||
*/ | ||
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.10 Number.MIN_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.10 | ||
*/ | ||
MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.12 Number.parseFloat (string) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.12 | ||
*/ | ||
parseFloat: parseFloat, | ||
/*** | ||
* 20.1.2.13 Number.parseInt (string, radix) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.13 | ||
*/ | ||
parseInt: parseInt | ||
}); | ||
extendBuiltInObject($Number, { | ||
/** | ||
* 20.1.3.1 Number.prototype.clz () | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.3.1 | ||
*/ | ||
clz: function(){ | ||
var number = this >>> 0; | ||
return number ? 32 - number[toString](2).length : 32 | ||
O.__proto__ = proto; | ||
return O | ||
} | ||
*/ | ||
}); | ||
extendBuiltInObject(Number, { | ||
/** | ||
* 20.1.2.1 Number.EPSILON | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number_epsilon | ||
*/ | ||
EPSILON: 2.220446049250313e-16, | ||
/** | ||
* 20.1.2.2 Number.isFinite (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.2 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isfinite | ||
*/ | ||
isFinite: izFinite, | ||
/** | ||
* 20.1.2.3 Number.isInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger | ||
*/ | ||
isInteger: isInt, | ||
/** | ||
* 20.1.2.4 Number.isNaN (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.4 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan | ||
*/ | ||
isNaN: izNaN, | ||
/** | ||
* 20.1.2.5 Number.isSafeInteger (number) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.5 | ||
*/ | ||
isSafeInteger: function(number){ | ||
return isInt(number) && abs(number) <= MAX_SAFE_INTEGER; | ||
}, | ||
/** | ||
* 20.1.2.6 Number.MAX_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.6 | ||
*/ | ||
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.10 Number.MIN_SAFE_INTEGER | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.10 | ||
*/ | ||
MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER, | ||
/** | ||
* 20.1.2.12 Number.parseFloat (string) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.12 | ||
*/ | ||
parseFloat: parseFloat, | ||
/*** | ||
* 20.1.2.13 Number.parseInt (string, radix) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.13 | ||
*/ | ||
parseInt: parseInt | ||
}); | ||
extendBuiltInObject($Number, { | ||
/** | ||
* 20.1.3.1 Number.prototype.clz () | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.3.1 | ||
*/ | ||
clz: function(){ | ||
var number = this >>> 0; | ||
return number ? 32 - number[toStringKey](2).length : 32 | ||
} | ||
}); | ||
extendBuiltInObject(Math, { | ||
/** | ||
* 20.2.2.3 Math.acosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.3 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic cosine of x. | ||
*/ | ||
acosh: function(x){ | ||
return ln(x + sqrt(x * x - 1)) | ||
}, | ||
/*** | ||
* 20.2.2.5 Math.asinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.5 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic sine of x. | ||
*/ | ||
asinh: function(x){ | ||
return !izFinite(x) || x === 0 ? x : ln(x + sqrt(x * x + 1)) | ||
}, | ||
/** | ||
* 20.2.2.7 Math.atanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.7 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic tangent of x. | ||
*/ | ||
atanh: function(x){ | ||
return x === 0 ? x : 0.5 * ln((1 + x) / (1 - x)) | ||
}, | ||
/** | ||
* 20.2.2.9 Math.cbrt(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.9 | ||
* Returns an implementation-dependent approximation to the cube root of x. | ||
*/ | ||
cbrt: function(x){ | ||
return sign(x) * pow(abs(x), 1/3); | ||
}, | ||
/** | ||
* 20.2.2.12 Math.cosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.12 | ||
* Returns an implementation-dependent approximation to the hyperbolic cosine of x. | ||
*/ | ||
cosh: function(x){ | ||
return ((x = +x) == -Infinity) || x === 0 ? x : x(exp(x) + exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.14 Math.expm1 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.14 | ||
* Returns an implementation-dependent approximation to subtracting 1 from the exponential function of x | ||
*/ | ||
expm1: function(x){ | ||
return same(x, -0) ? -0 : x > -1.0e-6 && x < 1.0e-6 ? x + x * x / 2 : exp(x) - 1 | ||
}, | ||
/** | ||
* 20.2.2.16 Math.hypot( value1 , value2, value3 = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.16 | ||
* Math.hypot returns an implementation-dependent approximation of the square root of the sum of squares of its arguments. | ||
*/ | ||
hypot: function(x, y, /*?*/z){ | ||
if(z === undefined)z = 0; | ||
return isFinite(x) ? isFinite(y) ? isFinite(z) ? sqrt(x * x + y * y + z * z) : z : y : x | ||
}, | ||
/** | ||
* 20.2.2.17 Math.imul(x, y) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.17 | ||
*/ | ||
imul: function(x, y){ | ||
var xh = (x >>> 0x10) & 0xffff | ||
, xl = x & 0xffff | ||
, yh = (y >>> 0x10) & 0xffff | ||
, yl = y & 0xffff; | ||
return xl * yl + (((xh * yl + xl * yh) << 0x10) >>> 0) | 0 | ||
}, | ||
/** | ||
* 20.2.2.19 Math.log1p (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.19 | ||
* Returns an implementation-dependent approximation to the natural logarithm of 1 + x. | ||
* The result is computed in a way that is accurate even when the value of x is close to zero. | ||
*/ | ||
log1p: function(x){ | ||
return (x > -1.0e-8 && x < 1.0e-8) ? (x - x * x / 2) : ln(1 + x) | ||
}, | ||
/** | ||
* 20.2.2.20 Math.log10 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.20 | ||
* Returns an implementation-dependent approximation to the base 10 logarithm of x. | ||
*/ | ||
log10: function(x){ | ||
return ln(x) / Math.LN10 | ||
}, | ||
/** | ||
* 20.2.2.21 Math.log2 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.21 | ||
* Returns an implementation-dependent approximation to the base 2 logarithm of x. | ||
*/ | ||
log2: function(x){ | ||
return ln(x) / Math.LN2 | ||
}, | ||
/** | ||
* 20.2.2.28 Math.sign(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.28 | ||
* Returns the sign of the x, indicating whether x is positive, negative or zero. | ||
*/ | ||
sign: sign, | ||
/** | ||
* 20.2.2.30 Math.sinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.30 | ||
* Returns an implementation-dependent approximation to the hyperbolic sine of x. | ||
*/ | ||
sinh: function(x){ | ||
return ((x = +x) == -Infinity) || x == 0 ? x : (exp(x) - exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.33 Math.tanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.33 | ||
* Returns an implementation-dependent approximation to the hyperbolic tangent of x. | ||
*/ | ||
tanh: function(x){ | ||
return izFinite(x = +x) ? x == 0 ? x : (exp(x) - exp(-x)) / (exp(x) + exp(-x)) : sign(x) | ||
}, | ||
/** | ||
* 20.2.2.34 Math.trunc(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.34 | ||
* Returns the integral part of the number x, removing any fractional digits. If x is already an integer, the result is x. | ||
*/ | ||
trunc: function(x){ | ||
return (x = +x) == 0 ? x : (x > 0 ? floor : ceil)(x) | ||
} | ||
}); | ||
/* | ||
extendBuiltInObject(String, { | ||
// 21.1.2.2 String.fromCodePoint ( ...codePoints) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.2 | ||
fromCodePoint: function(){ TODO }, | ||
// 21.1.2.4 String.raw ( callSite, ...substitutions) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.4 | ||
raw: function(){ TODO } | ||
}); | ||
*/ | ||
extendBuiltInObject($String, { | ||
/** | ||
* 21.1.3.3 String.prototype.codePointAt (pos) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.3 | ||
*/ | ||
codePointAt: function(pos /* = 0 */){ | ||
var value = String(this) | ||
, size = value.length; | ||
if((pos |= 0) < 0 || pos >= size)return NaN; | ||
var first = value.charCodeAt(pos); | ||
if(first < 0xD800 || first > 0xDBFF || pos + 1 == size)return first; | ||
var second = value.charCodeAt(pos + 1); | ||
return(second < 0xDC00 || first > 0xDFFF) ? first : ((first - 0xD800) << 1024) + (second - 0xDC00) + 0x10000 | ||
}, | ||
/** | ||
* 21.1.3.6 String.prototype.contains (searchString, position = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains | ||
*/ | ||
contains: function(searchString, position /* = 0 */){ | ||
return !!~String(this)[indexOf](searchString, position) | ||
}, | ||
/** | ||
* 21.1.3.7 String.prototype.endsWith (searchString [, endPosition] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.7 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith | ||
*/ | ||
endsWith: function(searchString, endPosition /* = @length */){ | ||
var length = this.length; | ||
searchString += ''; | ||
endPosition = toLength(min(endPosition === undefined ? length : endPosition, length)); | ||
return String(this).slice(endPosition - searchString.length, endPosition) === searchString | ||
}, | ||
/** | ||
* 21.1.3.13 String.prototype.repeat (count) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.13 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat | ||
*/ | ||
repeat: function(count){ | ||
return fill.call(Array(toInt(count)), this).join('') | ||
}, | ||
/** | ||
* 21.1.3.18 String.prototype.startsWith (searchString [, position ] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.18 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith | ||
*/ | ||
startsWith: function(searchString, position /* = 0 */){ | ||
searchString += ''; | ||
position = toLength(min(position, this.length)); | ||
return String(this).slice(position, position + searchString.length) === searchString | ||
} | ||
}); | ||
extendBuiltInObject(Array, { | ||
/** | ||
* 22.1.2.1 Array.from ( arrayLike , mapfn=undefined, thisArg=undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
from: function(arrayLike, mapfn /* -> it */, thisArg /* = undefind */){ | ||
var O = arrayLikeSelf(arrayLike) | ||
, i = 0 | ||
, length = toLength(O.length) | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
if(mapfn)for(; i < length; i++)i in O && (result[i] = mapfn.call(thisArg, O[i], i, O)); | ||
else for(; i < length; i++)i in O && (result[i] = O[i]); | ||
return result | ||
}, | ||
/** | ||
* 22.1.2.3 Array.of ( ...items ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
of: function(/*args...*/){ | ||
var i = 0 | ||
, length = arguments.length | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
while(i < length)result[i] = arguments[i++]; | ||
return result | ||
} | ||
}); | ||
function fill(value, start /* = 0 */, end /* = @length */){ | ||
var length = toLength(this.length); | ||
if((start |= 0) < 0 && (start = length + start) < 0)return this; | ||
end = end == undefined ? length : end | 0; | ||
while(end > start)this[start++] = value; | ||
return this | ||
} | ||
}); | ||
extendBuiltInObject(Math, { | ||
/** | ||
* 20.2.2.3 Math.acosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.3 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic cosine of x. | ||
*/ | ||
acosh: function(x){ | ||
return ln(x + sqrt(x * x - 1)) | ||
}, | ||
/*** | ||
* 20.2.2.5 Math.asinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.5 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic sine of x. | ||
*/ | ||
asinh: function(x){ | ||
return !izFinite(x) || x === 0 ? x : ln(x + sqrt(x * x + 1)) | ||
}, | ||
/** | ||
* 20.2.2.7 Math.atanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.7 | ||
* Returns an implementation-dependent approximation to the inverse hyperbolic tangent of x. | ||
*/ | ||
atanh: function(x){ | ||
return x === 0 ? x : 0.5 * ln((1 + x) / (1 - x)) | ||
}, | ||
/** | ||
* 20.2.2.9 Math.cbrt(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.9 | ||
* Returns an implementation-dependent approximation to the cube root of x. | ||
*/ | ||
cbrt: function(x){ | ||
return sign(x) * pow(abs(x), 1/3); | ||
}, | ||
/** | ||
* 20.2.2.12 Math.cosh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.12 | ||
* Returns an implementation-dependent approximation to the hyperbolic cosine of x. | ||
*/ | ||
cosh: function(x){ | ||
return ((x = +x) == -Infinity) || x === 0 ? x : x(exp(x) + exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.14 Math.expm1 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.14 | ||
* Returns an implementation-dependent approximation to subtracting 1 from the exponential function of x | ||
*/ | ||
expm1: function(x){ | ||
return same(x, -0) ? -0 : x > -1.0e-6 && x < 1.0e-6 ? x + x * x / 2 : exp(x) - 1 | ||
}, | ||
/** | ||
* 20.2.2.16 Math.hypot( value1 , value2, value3 = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.16 | ||
* Math.hypot returns an implementation-dependent approximation of the square root of the sum of squares of its arguments. | ||
*/ | ||
hypot: function(x, y, /*?*/z){ | ||
if(z === undefined)z = 0; | ||
return isFinite(x) ? isFinite(y) ? isFinite(z) ? sqrt(x * x + y * y + z * z) : z : y : x | ||
}, | ||
/** | ||
* 20.2.2.17 Math.imul(x, y) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.17 | ||
*/ | ||
imul: function(x, y){ | ||
var xh = (x >>> 0x10) & 0xffff | ||
, xl = x & 0xffff | ||
, yh = (y >>> 0x10) & 0xffff | ||
, yl = y & 0xffff; | ||
return xl * yl + (((xh * yl + xl * yh) << 0x10) >>> 0) | 0 | ||
}, | ||
/** | ||
* 20.2.2.19 Math.log1p (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.19 | ||
* Returns an implementation-dependent approximation to the natural logarithm of 1 + x. | ||
* The result is computed in a way that is accurate even when the value of x is close to zero. | ||
*/ | ||
log1p: function(x){ | ||
return (x > -1.0e-8 && x < 1.0e-8) ? (x - x * x / 2) : ln(1 + x) | ||
}, | ||
/** | ||
* 20.2.2.20 Math.log10 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.20 | ||
* Returns an implementation-dependent approximation to the base 10 logarithm of x. | ||
*/ | ||
log10: function(x){ | ||
return ln(x) / Math.LN10 | ||
}, | ||
/** | ||
* 20.2.2.21 Math.log2 (x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.21 | ||
* Returns an implementation-dependent approximation to the base 2 logarithm of x. | ||
*/ | ||
log2: function(x){ | ||
return ln(x) / Math.LN2 | ||
}, | ||
/** | ||
* 20.2.2.28 Math.sign(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.28 | ||
* Returns the sign of the x, indicating whether x is positive, negative or zero. | ||
*/ | ||
sign: sign, | ||
/** | ||
* 20.2.2.30 Math.sinh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.30 | ||
* Returns an implementation-dependent approximation to the hyperbolic sine of x. | ||
*/ | ||
sinh: function(x){ | ||
return ((x = +x) == -Infinity) || x == 0 ? x : (exp(x) - exp(-x)) / 2 | ||
}, | ||
/** | ||
* 20.2.2.33 Math.tanh(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.33 | ||
* Returns an implementation-dependent approximation to the hyperbolic tangent of x. | ||
*/ | ||
tanh: function(x){ | ||
return izFinite(x = +x) ? x == 0 ? x : (exp(x) - exp(-x)) / (exp(x) + exp(-x)) : sign(x) | ||
}, | ||
/** | ||
* 20.2.2.34 Math.trunc(x) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.34 | ||
* Returns the integral part of the number x, removing any fractional digits. If x is already an integer, the result is x. | ||
*/ | ||
trunc: function(x){ | ||
return (x = +x) == 0 ? x : (x > 0 ? floor : ceil)(x) | ||
} | ||
}); | ||
/* | ||
extendBuiltInObject(String, { | ||
// 21.1.2.2 String.fromCodePoint ( ...codePoints) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.2 | ||
fromCodePoint: function(){ TODO }, | ||
// 21.1.2.4 String.raw ( callSite, ...substitutions) | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.2.4 | ||
raw: function(){ TODO } | ||
}); | ||
*/ | ||
extendBuiltInObject($String, { | ||
/** | ||
* 21.1.3.3 String.prototype.codePointAt (pos) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.3 | ||
*/ | ||
codePointAt: function(pos /* = 0 */){ | ||
var value = String(this) | ||
, size = value.length; | ||
if((pos |= 0) < 0 || pos >= size)return NaN; | ||
var first = value.charCodeAt(pos); | ||
if(first < 0xD800 || first > 0xDBFF || pos + 1 == size)return first; | ||
var second = value.charCodeAt(pos + 1); | ||
return(second < 0xDC00 || first > 0xDFFF) ? first : ((first - 0xD800) << 1024) + (second - 0xDC00) + 0x10000 | ||
}, | ||
/** | ||
* 21.1.3.6 String.prototype.contains (searchString, position = 0 ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains | ||
*/ | ||
contains: function(searchString, position /* = 0 */){ | ||
return !!~String(this)[indexOf](searchString, position) | ||
}, | ||
/** | ||
* 21.1.3.7 String.prototype.endsWith (searchString [, endPosition] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.7 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith | ||
*/ | ||
endsWith: function(searchString, endPosition /* = @length */){ | ||
var length = this.length; | ||
searchString += ''; | ||
endPosition = toLength(min(endPosition === undefined ? length : endPosition, length)); | ||
return String(this).slice(endPosition - searchString.length, endPosition) === searchString | ||
}, | ||
/** | ||
* 21.1.3.13 String.prototype.repeat (count) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.13 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat | ||
*/ | ||
repeat: function(count){ | ||
return fill.call(Array(toInt(count)), this).join('') | ||
}, | ||
/** | ||
* 21.1.3.18 String.prototype.startsWith (searchString [, position ] ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-21.1.3.18 | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:string_extras | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith | ||
*/ | ||
startsWith: function(searchString, position /* = 0 */){ | ||
searchString += ''; | ||
position = toLength(min(position, this.length)); | ||
return String(this).slice(position, position + searchString.length) === searchString | ||
} | ||
}); | ||
extendBuiltInObject(Array, { | ||
/** | ||
* 22.1.2.1 Array.from ( arrayLike , mapfn=undefined, thisArg=undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.1 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
from: function(arrayLike, mapfn /* -> it */, thisArg /* = undefind */){ | ||
var O = arrayLikeSelf(arrayLike) | ||
, i = 0 | ||
, length = toLength(O.length) | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
if(mapfn)for(; i < length; i++)i in O && (result[i] = mapfn.call(thisArg, O[i], i, O)); | ||
else for(; i < length; i++)i in O && (result[i] = O[i]); | ||
return result | ||
}, | ||
/** | ||
* 22.1.2.3 Array.of ( ...items ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.2.3 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_extras | ||
*/ | ||
of: function(/*args...*/){ | ||
var i = 0 | ||
, length = arguments.length | ||
, result = new (isFunction(this) ? this : Array)(length); | ||
while(i < length)result[i] = arguments[i++]; | ||
return result | ||
} | ||
}); | ||
function fill(value, start /* = 0 */, end /* = @length */){ | ||
var length = toLength(this.length); | ||
if((start |= 0) < 0 && (start = length + start) < 0)return this; | ||
end = end == undefined ? length : end | 0; | ||
while(end > start)this[start++] = value; | ||
return this | ||
} | ||
extendBuiltInObject($Array, { | ||
/** | ||
* 22.1.3.3 Array.prototype.copyWithin (target, start, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.copywithin | ||
copyWithin: function(target, start, end){ | ||
extendBuiltInObject($Array, { | ||
/** | ||
* 22.1.3.3 Array.prototype.copyWithin (target, start, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.copywithin | ||
copyWithin: function(target, start, end){ | ||
}, | ||
*/ | ||
/** | ||
* 22.1.3.6 Array.prototype.fill (value, start = 0, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-22.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_fill_and_move | ||
*/ | ||
fill: fill, | ||
/** | ||
* 22.1.3.8 Array.prototype.find ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.8 | ||
*/ | ||
find: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, val, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, val = self[i], i, O))return val | ||
}, | ||
/** | ||
* 22.1.3.9 Array.prototype.findIndex ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.9 | ||
*/ | ||
findIndex: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, self[i], i, O))return i; | ||
return -1 | ||
} | ||
}); | ||
}, | ||
*/ | ||
/** | ||
* 22.1.3.6 Array.prototype.fill (value, start = 0, end = this.length) | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-22.1.3.6 | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:array_fill_and_move | ||
*/ | ||
fill: fill, | ||
/** | ||
* 22.1.3.8 Array.prototype.find ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.8 | ||
*/ | ||
find: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, val, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, val = self[i], i, O))return val | ||
}, | ||
/** | ||
* 22.1.3.9 Array.prototype.findIndex ( predicate , thisArg = undefined ) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-22.1.3.9 | ||
*/ | ||
findIndex: function(predicate, thisArg /* = undefind */){ | ||
var O = Object(this) | ||
, self = arrayLikeSelf(O) | ||
, length = toLength(self.length) | ||
, i = 0; | ||
for(; i < length; i++)if(i in self && predicate.call(thisArg, self[i], i, O))return i; | ||
return -1 | ||
} | ||
}); | ||
}(); |
@@ -1,5 +0,3 @@ | ||
!function(){ | ||
var Map = global.Map | ||
, Set = global.Set | ||
, sizeDesc = { | ||
!function(Map, Set){ | ||
var sizeDesc = { | ||
'get': function(){ | ||
@@ -32,3 +30,3 @@ return this._values.length; | ||
defineProperties(this, {_keys: descriptor(4, []), _values: descriptor(4, [])}); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
}, | ||
@@ -46,3 +44,3 @@ /** | ||
values.splice(index, 1); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
return true | ||
@@ -88,3 +86,3 @@ } | ||
values.push(value); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
} | ||
@@ -95,3 +93,3 @@ else values[index] = value; | ||
}); | ||
$DESC && defineProperty(Map[prototype], 'size', sizeDesc); | ||
DESCRIPTORS && defineProperty(Map[prototype], 'size', sizeDesc); | ||
} | ||
@@ -128,3 +126,3 @@ // IE 11 fix | ||
values.push(value); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
} | ||
@@ -139,3 +137,3 @@ return this | ||
defineProperty(this, '_values', descriptor(4, [])); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
}, | ||
@@ -151,3 +149,3 @@ /** | ||
values.splice(index, 1); | ||
$DESC || setSize(this); | ||
DESCRIPTORS || setSize(this); | ||
return true | ||
@@ -176,3 +174,3 @@ } | ||
}); | ||
$DESC && defineProperty(Set[prototype], 'size', sizeDesc); | ||
DESCRIPTORS && defineProperty(Set[prototype], 'size', sizeDesc); | ||
} | ||
@@ -188,2 +186,2 @@ // IE 11 fix | ||
} | ||
}(); | ||
}(global.Map, global.Set); |
@@ -1,6 +0,1 @@ | ||
function invoke(args){ | ||
var instance = create(this.prototype) | ||
, result = this.apply(instance, arrayLikeSelf(args || [])); | ||
return isObject(result) ? result : instance | ||
} | ||
function inherits(parent){ | ||
@@ -12,3 +7,3 @@ this[prototype] = create(parent[prototype], getOwnPropertyDescriptors(this[prototype])); | ||
isNative: isNative, | ||
inherits: unbind.call(inherits) | ||
inherits: $unbind(inherits) | ||
}); | ||
@@ -49,11 +44,6 @@ extendBuiltInObject($Function, { | ||
ctx: ctx, | ||
invoke: invoke, | ||
getInstance: function(){ | ||
var getInstance = 'getInstance', instance; | ||
if(!has(this, getInstance)){ // <= protect from Function.prototype.getInstance() | ||
this[getInstance] = function(){ | ||
return instance | ||
}; | ||
return instance = this.invoke(arguments) | ||
} | ||
invoke: function(args){ | ||
var instance = create(this[prototype]) | ||
, result = this.apply(instance, arrayLikeSelf(args || [])); | ||
return isObject(result) ? result : instance | ||
}, | ||
@@ -100,20 +90,11 @@ once: function(){ | ||
timeout: function(del /*, args...*/){ | ||
return part.call( | ||
clearTimeout, | ||
setTimeout(part.apply(this, slice1(arguments)), del) | ||
) | ||
return $part(clearTimeout, setTimeout(part.apply(this, slice1(arguments)), del)) | ||
}, | ||
interval: function(del /*, args...*/){ | ||
return part.call( | ||
clearInterval, | ||
setInterval(part.apply(this, slice1(arguments)), del) | ||
) | ||
return $part(clearInterval, setInterval(part.apply(this, slice1(arguments)), del)) | ||
}, | ||
immediate: function(/* args...*/){ | ||
return part.call( | ||
clearImmediate, | ||
setImmediate(part.apply(this, arguments)) | ||
) | ||
return $part(clearImmediate, setImmediate(part.apply(this, arguments))) | ||
}, | ||
inherits: inherits | ||
}); |
@@ -1,20 +0,1 @@ | ||
// partiall apply | ||
function part(/*args...*/){ | ||
var fn = this | ||
, i = 0 | ||
, length1 = arguments.length | ||
, args1 = Array(length1); | ||
while(length1 > i)args1[i] = arguments[i++]; | ||
return function(/*args...*/){ | ||
var args2 = args1.slice() | ||
, length2 = arguments.length | ||
, i = 0; | ||
while(length2 > i)args2[length1 + i] = arguments[i++]; | ||
return apply.call(fn, this, args2) | ||
} | ||
} | ||
// unbind method from context | ||
function unbind(){ | ||
return ctx.call(call, this); | ||
} | ||
/** | ||
@@ -35,8 +16,2 @@ * add `this` as first argument | ||
} | ||
} | ||
function ctx(that){ | ||
var fn = this; | ||
return function(){ | ||
return fn.apply(that, arguments); | ||
} | ||
} |
@@ -10,6 +10,4 @@ var prototype = 'prototype' | ||
, defineProperty = Object.defineProperty | ||
, pop = $Array.pop | ||
, push = $Array.push | ||
, slice = $Array.slice | ||
, unshift = $Array.unshift | ||
, apply = $Function.apply | ||
@@ -19,5 +17,3 @@ , call = $Function.call | ||
, ceil = Math.ceil | ||
, exp = Math.exp | ||
, floor = Math.floor | ||
, ln = Math.log | ||
, max = Math.max | ||
@@ -27,7 +23,4 @@ , min = Math.min | ||
, random = Math.random | ||
, sqrt = Math.sqrt | ||
, protoInObject = function(F){ | ||
F = Function(); | ||
return new F().__proto__ == F[prototype] | ||
} | ||
, DESCRIPTORS = 1 | ||
, REDUCE_ERROR = 'Reduce of empty object with no initial value' | ||
// How to get the context for calling the methods of the Array.prototype | ||
@@ -37,3 +30,3 @@ // Dummy, polyfill for not array-like strings for old ie in es5shim.js | ||
, isArray = Array.isArray || function(it){ | ||
return $toString(it) == '[object Array]' | ||
return toString(it) == '[object Array]' | ||
} | ||
@@ -43,32 +36,48 @@ , toArray = Array.from || function(arrayLike){ | ||
} | ||
, toString = 'toString' | ||
, toStringKey = 'toString' | ||
, $unbind = unbind.call(unbind) | ||
, $part = $unbind(part) | ||
// Unbind Object.prototype methods | ||
, _hasOwnProperty = $Object.hasOwnProperty | ||
, _toString = $Object[toString] | ||
, _isPrototypeOf = $Object.isPrototypeOf | ||
, _propertyIsEnumerable = $Object.propertyIsEnumerable | ||
, has = function(it, key){ | ||
return _hasOwnProperty.call(it, key) | ||
} | ||
, $toString = function(it){ | ||
return _toString.call(it) | ||
} | ||
, isPrototype = function(it, object){ | ||
return _isPrototypeOf.call(it, object) | ||
} | ||
, isEnumerable = function(it, key){ | ||
return _propertyIsEnumerable.call(it, key) | ||
} | ||
, $DESC = true | ||
, REDUCE_ERROR = 'Reduce of empty object with no initial value' | ||
, nativeFunctionRegExp = /^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/; | ||
, has = $unbind($Object.hasOwnProperty) | ||
, toString = $unbind($Object[toStringKey]) | ||
, isEnumerable = $unbind($Object.propertyIsEnumerable) | ||
// Native function? | ||
, isNative = RegExpToFunction.call(/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/); | ||
// Object internal [[Class]] | ||
function classof(it /*, args...*/){ | ||
return it === null ? 'Null' : it == undefined | ||
? 'Undefined' : $toString(it).slice(8, -1); | ||
function classof(it){ | ||
return it === undefined ? 'Undefined' : it == undefined ? 'Null' | ||
: toString(it).slice(8, -1) | ||
} | ||
// Native function? | ||
function isNative(it){ | ||
return nativeFunctionRegExp.test(it) | ||
// Simple bind context | ||
function ctx(that){ | ||
var fn = this; | ||
return function(){ | ||
return fn.apply(that, arguments); | ||
} | ||
} | ||
// Unbind method from context | ||
function unbind(){ | ||
return ctx.call(call, this); | ||
} | ||
// Partiall apply | ||
function part(/*args...*/){ | ||
var fn = this | ||
, i = 0 | ||
, length1 = arguments.length | ||
, args1 = Array(length1); | ||
while(length1 > i)args1[i] = arguments[i++]; | ||
return function(/*args...*/){ | ||
var args2 = args1.slice() | ||
, length2 = arguments.length | ||
, i = 0; | ||
while(length2 > i)args2[length1 + i] = arguments[i++]; | ||
return apply.call(fn, this, args2) | ||
} | ||
} | ||
function RegExpToFunction(){ | ||
var that = this; | ||
return function(it){ | ||
return that.test(it) | ||
} | ||
} | ||
function extendBuiltInObject(target, source, forced /* = false */){ | ||
@@ -85,6 +94,2 @@ for(var key in source){ | ||
} | ||
// splitComma('str1,str2,str3') => ['str1', 'str2', 'str3'] | ||
function splitComma(it){ | ||
return String(it).split(','); | ||
} | ||
function descriptor(bitmap, value){ | ||
@@ -97,2 +102,6 @@ return { | ||
} | ||
} | ||
// splitComma('str1,str2,str3') => ['str1', 'str2', 'str3'] | ||
function splitComma(it){ | ||
return String(it).split(','); | ||
} |
@@ -26,6 +26,6 @@ extendBuiltInObject(Number, { | ||
}, | ||
odd: function(){ | ||
isOdd: function(){ | ||
return !!(this % 2) && !(this % 1) | ||
}, | ||
even: function(){ | ||
isEven: function(){ | ||
return 0 === this % 2 | ||
@@ -45,4 +45,4 @@ }, | ||
extendBuiltInObject($Number, reduceTo.call( | ||
//IE... | ||
//getOwnPropertyNames(Math), | ||
// IE... | ||
// getOwnPropertyNames(Math), | ||
splitComma( | ||
@@ -49,0 +49,0 @@ // ES3 |
@@ -13,14 +13,17 @@ function toLength(it){ | ||
} | ||
// http://es5.github.io/#x9.4 | ||
// http://es5.github.io/#x9.4 | ||
var toInt = Number.toInteger || function(it){ | ||
return (it = +it) != it ? 0 : it != 0 && it != Infinity && it != -Infinity ? (it > 0 ? floor : ceil)(it) : it | ||
} | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-20.1.2.4 | ||
, izNaN = Number.isNaN || function(it){ | ||
return typeof it == 'number' && it !== it | ||
} | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.2 | ||
, izFinite = Number.isFinite || function(it){ | ||
return typeof it == 'number' && isFinite(it) | ||
} | ||
// https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.3 | ||
, isInt = Number.isInteger || function(it){ | ||
return izFinite(it) && floor(it) == it; | ||
}; |
@@ -16,3 +16,3 @@ !function(){ | ||
targetDescriptor = getOwnPropertyDescriptor(target, key) || $Object; | ||
if(targetDescriptor.configurable !== false && /*!targetDescriptor.get && !targetDescriptor.set && */delete target[key]){ | ||
if(targetDescriptor.configurable !== false && delete target[key]){ | ||
sourceDescriptor = getOwnPropertyDescriptor(source, key); | ||
@@ -126,7 +126,2 @@ if(deep && !sourceDescriptor.get && !sourceDescriptor.set){ | ||
} | ||
function objectReduceTo(object, fn, target){ | ||
target = Object(target); | ||
forOwnKeys(object, fn, target); | ||
return target; | ||
} | ||
function forOwnKeys(object, fn, that /* = undefined */){ | ||
@@ -154,4 +149,9 @@ var O = arrayLikeSelf(object) | ||
isEnumerable: isEnumerable, | ||
isPrototype: isPrototype, | ||
isPrototype: $unbind($Object.isPrototypeOf), | ||
classof: classof, | ||
bind: function(object, key){ | ||
var args = toArray(arguments); | ||
args.splice(1, 1); | ||
return $Function.bind.apply(object[key], args) | ||
}, | ||
// Extended object api from harmony and strawman : | ||
@@ -192,3 +192,3 @@ // http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
make: make, | ||
// Shugar for Object.make(null[, params, simple]) | ||
// Shugar for Object.make(null[, props, simple]) | ||
plane: function(props, simple /* = false */){ | ||
@@ -199,7 +199,7 @@ return make(null, props, simple) | ||
merge: merge, | ||
// Shugar for Object.merge(targ, src, 1, 1) | ||
// Shugar for Object.merge(target, props, 1, 1) | ||
defaults: function(target, props){ | ||
return merge(target, props, 1, 1) | ||
}, | ||
// {a:b} -> [b] | ||
// {a: b} -> [b] | ||
values: function(object){ | ||
@@ -305,5 +305,9 @@ var props = keys(object) | ||
}, | ||
reduceTo: objectReduceTo, | ||
reduceTo: function(object, fn, target){ | ||
target = Object(target); | ||
forOwnKeys(object, fn, target); | ||
return target; | ||
}, | ||
deepEqual: deepEqual, | ||
isObject : isObject, | ||
isObject: isObject, | ||
isUndefined: function(it){ | ||
@@ -316,7 +320,7 @@ return it === undefined | ||
isNumber : function(it){ | ||
return $toString(it) == '[object Number]' | ||
return toString(it) == '[object Number]' | ||
}, | ||
isString : isString, | ||
isBoolean : function(it){ | ||
return it === !!it || $toString(it) == '[object Boolean]' | ||
return it === !!it || toString(it) == '[object Boolean]' | ||
}, | ||
@@ -326,10 +330,11 @@ isArray : isArray, | ||
isRegExp : function(it){ | ||
return $toString(it) == '[object RegExp]' | ||
return toString(it) == '[object RegExp]' | ||
}, | ||
isDate : isDate, | ||
isDate : function(it){ | ||
return toString(it) == '[object Date]' | ||
}, | ||
isError : function(it){ | ||
return $toString(it) == '[object Error]' | ||
}, | ||
isArguments: isArguments | ||
return toString(it) == '[object Error]' | ||
} | ||
}); | ||
}(); |
@@ -23,15 +23,11 @@ // http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
} | ||
function isObject(it){ | ||
return it === Object(it) | ||
} | ||
function isString(it){ | ||
return $toString(it) == '[object String]' | ||
return toString(it) == '[object String]' | ||
} | ||
function isFunction(it){ | ||
return $toString(it) == '[object Function]' | ||
return toString(it) == '[object Function]' | ||
} | ||
function isDate(it){ | ||
return $toString(it) == '[object Date]' | ||
} | ||
// IE fix in es5.js | ||
function isArguments(it){ | ||
return $toString(it) == '[object Arguments]' | ||
} | ||
var assign = Object.assign || function(target, source){ | ||
@@ -48,5 +44,2 @@ var props = keys(source) | ||
} | ||
, isObject = Object.isObject || function(it){ | ||
return it === Object(it) | ||
} | ||
/** | ||
@@ -53,0 +46,0 @@ * http://es5.javascript.ru/x9.html#x9.12 |
extendBuiltInObject(RegExp[prototype], { | ||
fn: function(){ | ||
var that = this; | ||
return function(it){ | ||
return that.test(it) | ||
} | ||
}, | ||
getFlag: getRegExpFlags | ||
fn: RegExpToFunction, | ||
getFlags: getRegExpFlags | ||
}); |
@@ -1,3 +0,3 @@ | ||
function getRegExpFlags(reg){ | ||
function getRegExpFlags(){ | ||
return String(this).match(/[^\/]*$/)[0] | ||
} |
@@ -7,5 +7,4 @@ var create = Object.create | ||
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor | ||
, some = $Array.some | ||
, forEach = $Array.forEach | ||
, map = $Array.map | ||
, indexOf = 'indexOf'; |
@@ -28,4 +28,4 @@ !function(navigator, setTimeout, setInterval, postMessage, setImmediate, clearImmediate, addEventListener){ | ||
, queue = {} | ||
, listner = function(e){ | ||
var id = e.data; | ||
, listner = function(event){ | ||
var id = event.data; | ||
if(id in queue){ | ||
@@ -39,3 +39,3 @@ queue[id](); | ||
queue[id] = timersBind(fn, slice1(arguments)); | ||
postMessage(id, global.location); | ||
postMessage(id, '*'); | ||
return counter | ||
@@ -51,3 +51,3 @@ } | ||
global[setImmediate] = function(fn /*, args...*/){ | ||
return setTimeout(timersBind(fn, slice1(arguments)), 0) | ||
return setTimeout(timersBind(fn, slice1(arguments)), 1) | ||
} | ||
@@ -54,0 +54,0 @@ global[clearImmediate] = Function('i','clearTimeout(i)') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
575757
62
14917
0
15
7