Comparing version 0.0.5 to 0.0.7
/** | ||
* Core.js v0.0.3 | ||
* Core.js v0.0.5 | ||
* http://core.zloirock.ru | ||
@@ -7,3 +7,3 @@ * © 2013 Denis Pushkarev | ||
*/ | ||
!function(V,p,e,g,R,l,S,T,U,f,J,a){"use strict";function D(b){return null===b?"Null":b==a?"Undefined":q(b).slice(8,-1)}function A(a){return P.test(a)}function i(b,c,d){for(var a in c)try{s(c,a)&&(d||!s(b,a)||!A(b[a]))&&delete b[a]&&B(b,a,y(6,c[a]))}catch(e){}return b}function y(a,b){return{enumerable:!!(1&a),configurable:!!(2&a),writable:!!(4&a),value:b}}function j(){for(var d=this,a=0,b=arguments.length,c=g(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 E.call(d,this,e)}}function x(a){return"[object Function]"==q(a)}function I(a){return m.call(a,1)}function h(b,d){for(var a=0,e=c(b.length);e>a;a++)if(Q(b[a],d))return a;return-1}function w(c,a){return a=e(a),o.call(b(this),c,a),a}function c(b){var a=O(b);return a>0&&N(a)?a:0}var k="prototype",r=1/0,d=g[k],z=p[k],n=e[k],B=e.defineProperty,C=d.push,m=d.slice,E=z.apply,F=f.ceil,G=f.floor,H=f.max,v=f.min,b=e,K="toString",L=n.hasOwnProperty,M=n[K],s=function(a,b){return L.call(a,b)},q=function(a){return M.call(a)},P=/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/,o=d.forEach,u=d.map,Q=e.is||function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b},O=l.toInteger||function(a){return(a=+a)!=a?0:0!=a&&a!=r&&a!=-r?(a>0?G:F)(a):a},N=l.isFinite||function(a){return"number"==typeof a&&J(a)};!function(){function f(f){for(var d=0,b=e(this,f),a=0,g=c(b.length);g>a;a++)a in b&&(d+=+b[a]);return d}function j(j){for(var e,f=b(this),h=c(f.length),i=g(h),d=0;h>d;d++)d in f&&(e=f[d],i[d]=e==a?a:e[j]);return i}function e(a,c){switch(D(c)){case"Function":return u.call(a,c);case"String":case"Number":return j.call(a,c)}return b(a)}i(d,{at:function(a){return b(this)[0>a?c(this.length)+a:a]},props:j,reduceTo:w,indexSame:function(a){return h(b(this),a)},merge:function(a){return C.apply(this,b(a)),this},sum:f,avg:function(a){return this.length?f.call(this,a)/this.length:0},min:function(b){return v.apply(a,e(this,b))},max:function(b){return H.apply(a,e(this,b))},unique:function(g){for(var b,a=[],d=e(this,g),i=c(d.length),f=0;i>f;)~h(a,b=d[f++])||a.push(b);return a},cross:function(g){for(var a,d=[],e=b(this),i=c(e.length),j=b(g),f=0;i>f;)!~h(d,a=e[f++])&&~h(j,a)&&d.push(a);return d}})}();var t;i(p,{series:function(b,d){function h(i,k){i==c&&(f=c++in b,!g||!k&&f?f&&(e=m.call(arguments,g?2:1),e.push(j.call(h,c)),b[c].apply(a,e)):d.apply(a,I(arguments)))}var e,f,g=x(d),c=0;b.length?b[0](j.call(h,0)):g&&d()},parallel:t=function(e,f){var b=c(e.length),d=g(b);b?o.call(e,function(c,a){c(function(c,e){!b||a in d||(c&&(b=1),d[a]=e,--b||f(c,d))})}):f(a,d)}}),i(d,{asyncMap:function(a,b){t(u.call(this,function(b){return j.call(a,b)}),b)}})}("undefined"!=typeof window?window:global,Function,Object,Array,String,Number,RegExp,Date,TypeError,Math,isFinite); | ||
!function(a,f,d,m,O,y,ab,_,i,j,U,c){"use strict";function X(a){return a===c?"Undefined":a==c?"Null":r(a).slice(8,-1)}function R(a){var b=this;return function(){return b.apply(a,arguments)}}function z(){return R.call(I,this)}function w(){for(var d=this,a=0,b=arguments.length,c=m(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 H.call(d,this,e)}}function Z(){var a=this;return function(b){return a.test(b)}}function B(b,c,d){for(var a in c)try{q(c,a)&&(d||!q(b,a)||!V(b[a]))&&delete b[a]&&E(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 D(a){return O(a).split(",")}function b(a){return"[object Function]"==r(a)}function t(a){return o.call(a,1)}function S(b,c){for(var a=0,d=k(b.length);d>a;a++)if(G(b[a],c))return a;return-1}function T(b,a){return a=d(a),s(e(this),b,a),a}function k(b){var a=P(b);return a>0&&$(a)?a:0}var l="prototype",x=1/0,g=m[l],A=f[l],p=d[l],E=d.defineProperty,F=g.push,o=g.slice,H=A.apply,I=A.call,J=j.ceil,K=j.floor,L=j.max,M=j.min,N=j.random,e=d,u=m.isArray||function(a){return"[object Array]"==r(a)},Q="toString",h=z.call(z),n=h(w),q=h(p.hasOwnProperty),r=h(p[Q]),V=(h(p.propertyIsEnumerable),Z.call(/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/)),W=d.keys,s=h(g.forEach),Y=g.map,v=d.assign||function(a,b){for(var c,d=W(b),f=d.length,e=0;f>e;)a[c=d[e++]]=b[c];return a},G=d.is||function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b},P=y.toInteger||function(a){return(a=+a)!=a?0:0!=a&&a!=x&&a!=-x?(a>0?K:J)(a):a},$=y.isFinite||function(a){return"number"==typeof a&&U(a)};!function(k,j,p,i,d,g,h){function e(a,c){return w.apply(b(a)?a:f(a),c)}if(k&&/MSIE .\./.test(k.userAgent)&&(a.setTimeout=function(a,b){return j(e(a,o.call(arguments,2)),b||1)},a.setInterval=function(a,b){return p(e(a,o.call(arguments,2)),b||1)}),!b(a[d])||!b(a[g]))if(b(i)){var l=d+N(),m=0,c={},n=function(b){var a=b.data;if(a in c)try{c[a]()}catch(d){throw d}finally{delete c[a]}};a[d]=function(b){var a=++m+l;return c[a]=e(b,t(arguments)),i(a,"*"),m},a[g]=function(a){delete c[a+l]},h?h("message",n,!1):attachEvent("onmessage",n)}else a[d]=function(a){return j(e(a,t(arguments)),1)},a[g]=f("i","clearTimeout(i)")}(a.navigator,setTimeout,setInterval,a.postMessage,"setImmediate","clearImmediate",a.addEventListener),!function(d){b(d)&&D("cast,resolve,reject,all,race").every(n(q,d))&&function(a){return new d(function(b){a=b}),b(a)}()&&function(){try{return new d(f()).then(null)}catch(a){}}()||!function(){function h(c){var a=this,f=n(d,a,e);if(!b(c))throw i("First argument of Promise constructor must be an function");if(!(a instanceof h))throw i("Promise constructor cannot be called as a function.");a[k]=[];try{c(n(j,a),f)}catch(g){f(g)}}function w(g,c,h,i){var a,k,f,l,m=b(h);if(m)try{a=h(i),f=1}catch(n){l=1,k=n}else a=i,f=1;t(c,a)||(m&&f?j(c,a):l?d(c,e,k):g==o?j(c,a):g==e&&d(c,e,a))}function q(a){return new this(function(b){b(a)})}function t(a,f){var g;try{if(a===f)throw i("A promises callback cannot return that same promise.");if(f&&b(f.then))return f.then(function(b){return g?!0:(g=!0,f!==b?j(a,b):d(a,o,b),c)},function(b){return g?!0:(g=!0,d(a,e,b),c)}),1}catch(h){return g||d(a,e,h),1}}function j(a,b){a!==b&&t(a,b)||d(a,o,b)}function d(a,b,d){a[g]===x&&(a[g]=y,a[m]=d,r(function(){a[g]=b;for(var e=a[k],d=0;e.length>d;d+=3)w(b,e[d],e[d+b],a[m]);a[k]=c}))}var x,y=0,o=1,e=2,r=a.setImmediate,k="_subscribers",g="_state",m="_detail",p="You must pass an array to race or all";a.Promise=h,v(h[l],{"catch":function(a){return this.then(c,a)},then:function(c,d){var a=this,b=new h(f());return a[g]?r(function(){w(a[g],b,arguments[a[g]-1],a[m])},c,d):a[k].push(b,c,d),b}}),v(h,{all:function(a){if(!u(a))throw i(p);return new this(function(d,g){function e(a,b){c[a]=b,--f||d(c)}var c=[],f=a.length;f?s(a,function(a,c){a&&b(a.then)?a.then(n(e,c),g):e(c,a)}):d(c)})},cast:function(a){return a instanceof this?a:q.call(this,a)},race:function(a){if(!u(a))throw i(p);return new this(function(c,d){s(a,function(a){a&&b(a.then)?a.then(c,d):c(a)})})},reject:function(a){return new this(function(c,b){b(a)})},resolve:q})}()}(a.Promise),!function(){function b(e){for(var d=0,c=a(this,e),b=0,f=k(c.length);f>b;b++)b in c&&(d+=+c[b]);return d}function d(h){for(var b,d=e(this),f=k(d.length),g=m(f),a=0;f>a;a++)a in d&&(b=d[a],g[a]=b==c?c:b[h]);return g}function a(a,b){switch(X(b)){case"Function":return Y.call(a,b);case"String":case"Number":return d.call(a,b)}return e(a)}B(g,{at:function(a){return e(this)[0>a?this.length+a:a]},pluck:d,reduceTo:T,merge:function(a){return F.apply(this,e(a)),this},sum:b,avg:function(a){return this.length?b.call(this,a)/this.length:0},min:function(b){return M.apply(c,a(this,b))},max:function(b){return L.apply(c,a(this,b))},unique:function(f){for(var c,b=[],d=a(this,f),g=k(d.length),e=0;g>e;)~S(b,c=d[e++])||b.push(c);return b}})}()}("undefined"!=typeof window?window:global,Function,Object,Array,String,Number,RegExp,Date,TypeError,Math,isFinite); | ||
//# sourceMappingURL=./core.min.map |
/** | ||
* Core.js v0.0.5 | ||
* Core.js v0.0.7 | ||
* http://core.zloirock.ru | ||
* © 2013 Denis Pushkarev | ||
* © 2014 Denis Pushkarev | ||
* Available under MIT license | ||
*/ | ||
!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 | ||
!function(c,F,e){"use strict";function Qb(a,b){return a===b||a!==a&&b!==b}function C(a){return null!==a&&("object"==typeof a||"function"==typeof a)}function f(a){return"function"==typeof a}function qb(a){return _b.test(a)}function v(a,c,d){ab&&a&&((d?a:a[b])[ab]=c)}function Z(a){if(a==e)return a===e?"Undefined":"Null";var b=$b.call(a).slice(8,-1);return ab&&b==p&&a[ab]?a[ab]:b}function V(){for(var a=arguments.length,c=m(a),b=0,e=Y._,d=!1;a>b;)(c[b]=arguments[b++])===e&&(d=!0);return yb(this,c,a,d,!1)}function lb(a,b){return g(a),function(){return a.apply(b,arguments)}}function yb(a,b,d,c,e,f){return g(a),function(){var g,j=e?f:this,l=Y._,k=arguments.length,h=0,i=0;if(!c&&0==k)return a.apply(j,b);if(g=b.slice(),c)for(;d>h;h++)g[h]===l&&(g[h]=arguments[i++]);for(;k>i;)g.push(arguments[i++]);return a.apply(j,g)}}function E(a){return function(){return ec.apply(a,arguments)}}function h(a,b){return ac.call(a,b)}function Hb(a){for(var b,c={},d=Sb(a),f=d.length,e=0;f>e;)c[b=d[e++]]=eb(a,b);return c}function cc(a,b){if(b in a)do if(h(a,b))return eb(a,b);while(a=bb(a))}function X(a){return w(a).split(",")}function S(f,a){g(f),a=a==e?[]:i(a);for(var c=d(this),h=o(c.length),b=0;h>b&&!(b in c&&f(a,c[b],b,this)===!1);b++);return a}function o(a){return a>0?W(M(a),ib):0}function J(a){if(!a)throw rb(kb(arguments,1).join(" "))}function g(a){if(!f(a))throw rb(a+"is not a function!")}function $(a){if(!C(a))throw rb(a+"is not an object!")}function Bb(a,b,c){J(a instanceof b,c,": please use the 'new' operator!")}function k(a){return"@@"+a+"_"+(++bc+Fb()).toString(36)}function Eb(a,b){return{enumerable:!!(1&a),configurable:!!(2&a),writable:!!(4&a),value:b}}function G(a,b,c){return I(a,b,Eb(6,c))}function a(m,g,e,p){var a,n,i,k=m&D,r=m&l,o=m&j,d=k?c:r?c[g]:(c[g]||B)[b],s=k?q:q[g]||(q[g]={});k&&(p=e,e=g);for(a in e)h(e,a)&&(n=!p&&d&&h(d,a)&&(!f(d[a])||qb(d[a])),i=n?d[a]:e[a],s[a]=o&&f(i)?E(i):i,F&&d&&!n&&(k||delete d[a])&&I(d,a,Eb(6+!o,e[a])))}function pb(b,a){F&&(c[b]=a),q[b]=c[b]!=a?a:lb(a,c)}function Tb(a){function c(b){return this instanceof a?new a(b):a(b)}return F||!qb(a)?a:(c[b]=a[b],c)}var ab,p="Object",N="Function",s="Array",fb="String",gb="Number",Db="RegExp",T="Map",U="Set",wb="WeakMap",xb="WeakSet",zb="Promise",Kb="Arguments",Pb="process",b="prototype",Jb="createElement",K=c[N],i=c[p],m=c[s],w=c[fb],Zb=c[gb],fc=c[Db],u=c[T],t=c[U],H=c[wb],O=c[xb],Yb=c[zb],r=c.Math,rb=c.TypeError,cb=c.setTimeout,dc=c.clearTimeout,hb=c.setInterval,db=c.setImmediate,jb=c.clearImmediate,Ib=c[Pb],L=c.document,R=1/0,x=m[b],B=i[b],Ob=K[b],q={},Mb=i.is||function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b},_b=/^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/,$b=B.toString,ub=Ob.apply,ec=Ob.call,Y=F?c:q;q._=Y._=Y._||{};var A,P,vb,Ab,Vb,ac=B.hasOwnProperty,z=i.create,bb=i.getPrototypeOf,I=i.defineProperty,Q=i.defineProperties,eb=i.getOwnPropertyDescriptor,n=i.keys,Sb=i.getOwnPropertyNames,Xb=B.propertyIsEnumerable,Lb="__proto__"in B,Nb=!0,d=i,y=i.assign||function(a,b){a=i(a);for(var h=arguments.length,c=1;h>c;){b=d(arguments[c++]);for(var e,f=n(b),j=f.length,g=0;j>g;)a[e=f[g++]]=b[e]}return a},ob=x.push,nb=x.slice,Rb=m.indexOf||E(x.indexOf),mb=m.forEach||E(x.forEach),kb=m.slice||function(a,b){return nb.call(a,b)},Ub=r.ceil,tb=r.floor,Wb=r.max,W=r.min,Gb=r.pow,Fb=r.random,ib=Gb(2,53)-1,M=Zb.toInteger||function(a){return(a=+a)!=a?0:0!=a&&a!=R&&a!=-R?(a>0?tb:Ub)(a):a},Cb="Reduce of empty object with no initial value",bc=0,D=1,l=2,j=4,sb=Z(Ib)==Pb;sb&&(module.exports=q),(!sb||F)&&(c.C=q),!function(){function D(a){return function(){return a.apply(d(this),arguments)}}var v=K(),c=Z,t="[ \n\f\r \u2028\u2029]",u=fc("^"+t+"+|"+t+"+$","g"),r=X("toString,toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,constructor"),y=r.concat(["length"]),A=r.length,k=Lb?function(){return{__proto__:null}}:function(){var c,a=L[Jb]("iframe"),d=A,e=L.body||L.documentElement;for(a.style.display="none",e.appendChild(a),a.src="javascript:",c=a.contentWindow.document||a.contentDocument||a.document,c.open(),c.write("<script>document.F=Object</script>"),c.close(),k=c.F;d--;)delete k[b][r[d]];return k()},E=function(a,b){return function(e){e=d(e);var c,g=0,f=[];for(c in e)h(e,c)&&f.push(c);for(;b>g;)h(e,c=a[g++])&&!~Rb(f,c)&&f.push(c);return f}};try{i.defineProperty({},0,B)}catch(F){Nb=!1,eb=function(a,b){return h(a,b)?Eb(6+Xb.call(a,b),a[b]):e},I=function(a,c,b){return $(a),"value"in b&&(a[c]=b.value),a},Q=function(a,d){$(a);for(var b,c,e=n(d),g=e.length,f=0;g>f;)b=e[f++],c=d[b],"value"in c&&(a[b]=c.value);return a}}a(l,p,{getOwnPropertyDescriptor:eb,defineProperty:I,defineProperties:Q},1),a(l,p,{getPrototypeOf:function(a){var c,d=a.__proto__||((c=a.constructor)?c[b]:B);return a!==d&&"toString"in a?d:null},getOwnPropertyNames:E(y,y.length),create:function(a,c){if(null===a)return c?Q(k(),c):k();$(a),v[b]=a;var d=new v;return c&&Q(d,c),Lb||d.constructor[b]===a||(d.__proto__=a),d},keys:E(r,A)}),a(j,N,{bind:function(c){function d(){var d,e,g=f.concat(kb(arguments));return this instanceof a?C(d=ub.call(e=z(a[b]),c,g))?d:e:ub.call(a,c,g)}var a=this,f=kb(arguments,1);return g(a),d[b]=e,d}}),0 in i("q")&&"q"=="q"[0]||(d=function(a){return c(a)==fb?a.split(""):i(a)},nb=D(nb)),a(j,s,{slice:nb,join:D(x.join)},d!=i),a(l,s,{isArray:function(a){return c(a)==s}}),a(j,s,{indexOf:function(e,f){var b=d(this),c=o(b.length),a=0|f;for(0>a&&(a=o(c+a));c>a;a++)if(a in b&&b[a]===e)return a;return-1},lastIndexOf:function(e,f){var b=d(this),c=o(b.length),a=c-1;for(arguments.length>1&&(a=W(a,0|f)),0>a&&(a=o(c+a));a>=0;a--)if(a in b&&b[a]===e)return a;return-1},every:function(c,e){g(c);for(var b=d(this),f=o(b.length),a=0;f>a;a++)if(a in b&&!c.call(e,b[a],a,this))return!1;return!0},some:function(c,e){g(c);for(var b=d(this),f=o(b.length),a=0;f>a;a++)if(a in b&&c.call(e,b[a],a,this))return!0;return!1},forEach:function(c,e){g(c);for(var b=d(this),f=o(b.length),a=0;f>a;a++)a in b&&c.call(e,b[a],a,this)},map:function(a,c){g(a);var b=m(o(this.length));return mb(this,function(e,d,f){b[d]=a.call(c,e,d,f)}),b},filter:function(a,c){g(a);var b=[];return mb(this,function(d){a.apply(c,arguments)&&b.push(d)}),b},reduce:function(e,c){g(e);var b=d(this),f=o(b.length),a=0;if(2>arguments.length)for(;;){if(a in b){c=b[a++];break}J(f>++a,Cb)}for(;f>a;a++)a in b&&(c=e(c,b[a],a,this));return c},reduceRight:function(e,c){g(e);var b=d(this),a=o(b.length)-1;if(2>arguments.length)for(;;){if(a in b){c=b[a--];break}J(0<=--a,Cb)}for(;a>=0;a--)a in b&&(c=e(c,b[a],a,this));return c}}),a(j,fb,{trim:function(){return w(this).replace(u,"")}}),a(l,"Date",{now:function(){return+new Date}}),f(u)&&(f=function(a){return c(a)==N}),c(function(){return arguments}())==p&&(Z=function(a){var b=c(a);return b==p&&f(a.callee)?Kb:b}),z=q[p].create,bb=q[p].getPrototypeOf,n=q[p].keys,Sb=q[p].getOwnPropertyNames,Rb=q[s].indexOf,mb=q[s].forEach}(),a(D,{global:c}),!function(c,e,f,d,g){qb(c)||(c=function(b){if(!(this instanceof c))return new c(b);var a=k(b);I(B,a,{set:function(b){G(this,a,b)}}),G(this,f,a)},c[b].toString=c[b].valueOf=function(){return this[f]}),a(D,{Symbol:Tb(c)},1),a(l,e,{"for":function(a){return h(d,a)?d[a]:d[a]=c(a)},iterator:A=c.iterator||g in x?g:c(e+".iterator"),keyFor:function(b){for(var a in d)if(d[a]===b)return a},toStringTag:ab=c.toStringTag||c(e+".toStringTag")}),v(c,e)}(c.Symbol,"Symbol",k("tag"),{},"@@iterator"),!function(k){function n(a){return 0==(a=+a)||a!=a?a:0>a?-1:1}function t(a){return k(a=+a)&&0!==a?0>a?-t(-a):h(a+q(a*a+1)):a}function u(c,f){g(c);for(var e=i(this),b=d(e),h=o(b.length),a=0;h>a;a++)if(a in b&&c.call(f,b[a],a,e))return a;return-1}a(l,p,{assign:y,is:Mb}),Lb&&function(b,c){try{b({},x)}catch(d){c=!0}a(l,p,{setPrototypeOf:function(d,a){return $(d),J(C(a)||null===a,"Can't set",a,"as prototype"),c?d.__proto__=a:b(d,a),d}})}(E(eb(B,"__proto__").set)),a(l,gb,{EPSILON:Gb(2,-52),isFinite:function(a){return"number"==typeof a&&k(a)},isInteger:function(a){return k(a)&&tb(a)===a},isNaN:function(a){return"number"==typeof a&&a!=a},isSafeInteger:function(a){return A(a)&&z(a)<=ib},MAX_SAFE_INTEGER:ib,MIN_SAFE_INTEGER:-ib,parseFloat:parseFloat,parseInt:parseInt});var A=Zb.isInteger,z=r.abs,b=r.exp,h=r.log,q=r.sqrt;a(l,"Math",{acosh:function(a){return h(a+q(a*a-1))},asinh:t,atanh:function(a){return 0===a?a:.5*h((1+a)/(1-a))},cbrt:function(a){return n(a)*Gb(z(a),1/3)},clz32:function(a){return a>>>=0,a?32-a.toString(2).length:32},cosh:function(a){return(b(a)+b(-a))/2},expm1:function(a){return Mb(a,-0)?-0:a>-1e-6&&1e-6>a?a+a*a/2:b(a)-1},hypot:function(){for(var a,b=0,c=arguments.length;c--;){if(a=+arguments[c],a==R||a==-R)return R;b+=a*a}return q(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:h(1+a)},log10:function(a){return h(a)/r.LN10},log2:function(a){return h(a)/r.LN2},sign:n,sinh:function(a){return(a=+a)==-R||0==a?a:(b(a)-b(-a))/2},tanh:function(a){return k(a=+a)?0==a?a:(b(a)-b(-a))/(b(a)+b(-a)):n(a)},trunc:function(a){return 0==(a=+a)?a:(a>0?tb:Ub)(a)}}),v(r,"Math",1),a(j,fb,{contains:function(a,b){return!!~w(this).indexOf(a,b)},endsWith:function(b,a){var c=this.length;return b+="",a=o(W(a===e?c:a,c)),w(this).slice(a-b.length,a)===b},repeat:function(a){return J(0<=(a|=0),"Count can't be negative"),m(a+1).join(this)},startsWith:function(b,a){return b+="",a=o(W(a,this.length)),w(this).slice(a,a+b.length)===b}}),a(l,s,{from:function(n,a,j){a!==e&&g(a);var k,l,h,c=d(n),i=new(f(this)?this:m),b=0;if(vb&&vb(c))for(l=Ab(c);!(h=l.next()).done;)ob.call(i,a?a.call(j,h.value,b++):h.value);else for(k=o(c.length);k>b;b++)ob.call(i,a?a.call(j,c[b],b):c[b]);return i},of:function(){for(var a=0,c=arguments.length,b=new(f(this)?this:m);c>a;)ob.call(b,arguments[a++]);return b}}),a(j,s,{fill:function(d,a,b){var c=o(this.length);for(a=M(a),0>a&&(a=c+a),b=b==e?c:M(b);b>a;)this[a++]=d;return this},find:function(b,c){var a=u.call(this,b,c);return~a?d(this)[a]:e},findIndex:u}),v(c.JSON,"JSON",1)}(isFinite),f(db)&&f(jb)||!function(i,j,k,l,m,a,b,d){function g(b){if(h(a,b)){var c=a[b];delete a[b],c()}}function n(a){g(a.data)}db=function(c){for(var d=l+ ++m,g=[],h=1;arguments.length>h;)g.push(arguments[h++]);return a[d]=function(){(f(c)?c:K(c)).apply(e,g)},b(d),m},jb=function(b){delete a[l+b]},sb?b=function(a){Ib.nextTick(V.call(g,a))}:f(i)&&!c.importScripts?(b=function(a){i(a,"*")},addEventListener("message",n,!1)):f(j)?(d=new j,d.port1.onmessage=n,b=lb(d.port2.postMessage,d.port2)):b=L&&k in L[Jb]("script")?function(b){var a=L[Jb]("script");a[k]=function(){a.parentNode.removeChild(a),g(b)},L.documentElement.appendChild(a)}:function(a){cb(V.call(g,a),0)}}(c.postMessage,c.MessageChannel,"onreadystatechange",k("immediate"),0,{}),pb("setImmediate",db),pb("clearImmediate",jb),!function(c,d){f(c)&&f(c.resolve)&&f(c.reject)&&f(c.all)&&f(c.race)&&function(a){return c.resolve(a)===a}(new c(K()))||!function(j,i,l,r,n,h,s){function o(e,c,g,i){var b,d,j,l=f(g);if(l)try{b=g(i),d=1}catch(m){j=1,b=m}else b=i,d=1;p(c,b)||(l&&d?k(c,b):j?a(c,h,b):e==n?k(c,b):e==h&&a(c,h,b))}function p(b,c){var d;try{if(J(b!==c,"A promises callback can't return that same promise."),c&&f(c.then))return c.then(function(f){return d?!0:(d=!0,c!==f?k(b,f):a(b,n,f),e)},function(c){return d?!0:(d=!0,a(b,h,c),e)}),1}catch(g){return d||a(b,h,g),1}}function k(b,c){b!==c&&p(b,c)||a(b,n,c)}function a(a,b,c){a[i]===s&&(a[i]=r,a[l]=c,q(function(){a[i]=b;for(var d=a[j],c=0;d.length>c;c+=3)o(b,d[c],d[c+b],a[l]);a[j]=e}))}var q=sb?Ib.nextTick:c&&f(c.resolve)?function(a){d.resolve().then(a)}:db;c=function(d){var b=this,e=V.call(a,b,h);Bb(b,c,zb),g(d),b[j]=[];try{d(V.call(k,b),e)}catch(f){e(f)}},c[b]["catch"]=function(a){return this.then(e,a)},c[b].then=function(d,e){var a=this,b=new c(K()),f=[d,e];return a[i]?q(function(){o(a[i],b,f[a[i]-1],a[l])}):a[j].push(b,d,e),b},c.all=function(c){var b=this,a=[];return new b(function(f,g){P(c,ob,a);var d=a.length,e=m(d);d?mb(a,function(a,c){b.resolve(a).then(function(a){e[c]=a,--d||f(e)},g)}):f(e)})},c.race=function(b){var a=this;return new a(function(c,d){P(b,function(b){a.resolve(b).then(c,d)})})},c.reject=function(a){return new this(function(c,b){b(a)})},c.resolve=function(a){return C(a)&&bb(a)===this[b]?a:new this(function(b){b(a)})}}(k("subscribers"),k("state"),k("detail"),0,1,2),v(c,zb),a(D,{Promise:c},1)}(Yb,Yb),!function(){function A(a,b,c){return b!=e&&P&&P(b,c?a.add:a.set,a,!c),a}function q(b,c){function a(d){Bb(this,a,b),this.clear(),A(this,d,c)}return a}function o(a,h,d){function e(b){return Bb(this,e,h),A(new a,b,d)}var g,c=new a([d?r:[r,1]]),i=c.has(r),f=d?"add":"set";return F&&c[f](r,1)!==c&&(g=c[f],G(a[b],f,function(){return g.apply(this,arguments),this})),i?Tb(a):(e[b]=a[b],e)}function i(a,b){return C(a)?"O"+(h(a,p)?a[p]:b?I(a,p,{value:L++})[p]:""):("string"==typeof a?"S":"P")+a}function E(a){return function(d,i){g(d);for(var b,j=this[c],e=this[a],f=n(e),k=f.length,h=0;k>h;)b=f[h++],d.call(i,j[b],e[b],this)}}function s(a){return i(a)in this[c]}function w(){G(this,c,z(null)),G(this,l,0)}function x(a){return(h(a,d)?a:I(a,d,{value:{}}))[d]}var p=k("storeid"),m=k("keys"),c=k("values"),d=k("weakdata"),j=k("weakid"),l=Nb?k("size"):"size",L=0,K=0,r={},B={size:{get:function(){return this[l]}}};f(u)&&h(u[b],"forEach")?u=o(u,T):(u=q(T),y(u[b],{clear:function(){G(this,m,z(null)),w.call(this)},"delete":function(e){var a=i(e),b=this[c],d=a in b;return d&&(delete this[m][a],delete b[a],this[l]--),d},forEach:E(m),get:function(a){return this[c][i(a)]},has:s,set:function(b,e){var a=i(b,1),d=this[c];return a in d||(this[m][a]=b,this[l]++),d[a]=e,this}}),Q(u[b],B)),f(t)&&h(t[b],"forEach")?t=o(t,U,1):(t=q(U,1),y(t[b],{add:function(a){var b=i(a,1),d=this[c];return b in d||(d[b]=a,this[l]++),this},clear:w,"delete":function(e){var a=i(e),b=this[c],d=a in b;return d&&(delete b[a],this[l]--),d},forEach:E(c),has:s}),Q(t[b],B));var J={clear:function(){G(this,j,K++)},"delete":function(a){return this.has(a)&&delete a[d][this[j]]},has:function(a){return C(a)&&h(a,d)&&h(a[d],this[j])}};f(H)&&h(H[b],"clear")?H=o(H,wb):(H=q(wb),y(H[b],y({get:function(a){return C(a)&&h(a,d)?a[d][this[j]]:e},set:function(a,b){return $(a),x(a)[this[j]]=b,this}},J))),f(O)?O=o(O,xb,1):(O=q(xb,1),y(O[b],y({add:function(a){return $(a),x(a)[this[j]]=!0,this}},J))),v(u,T),v(t,U),v(H,wb),v(O,xb),a(D,{Map:u,Set:t,WeakMap:H,WeakSet:O},1)}(),!function(G,k,c,C,z,o,B,J){function g(a,b){return{value:a,done:!!b}}function l(a,b){return function(){return new a(this,b)}}function q(a,b){this[C]=d(a),this[z]=b,this[o]=0}function y(a,b){this[C]=a,this[z]=b,this[o]=0,a.forEach(function(b,a){this.push(a)},this[B]=[])}function r(a,b){this[z]=b,this[o]=0,a.forEach(function(a){this.push(a)},this[B]=[])}function H(a,b){this[C]=a,this[B]=n(a),this[o]=0,this[z]=b}function E(a,b){h(a,A)||(a[A]=b)}function I(a){return function(b){return new H(b,a)}}q[b]={next:function(){var b=this,d=b[C],a=b[o]++;if(a>=d.length)return g(e,1);switch(b[z]){case k:return g(a,0);case c:return g(d[a],0)}return g([a,d[a]],0)}},y[b]={next:function(){var a,b=this[C],d=this[B],f=this[o]++;if(f>=d.length)return g(e,1);switch(a=d[f],this[z]){case k:return g(a,0);case c:return g(b.get(a),0)}return g([a,b.get(a)],0)}},r[b]={next:function(){var a,b=this[B],d=this[o]++;return d>=b.length?g(e,1):(a=b[d],this[z]==c?g(a,0):g([a,a],0))}},H[b]={next:function(){var a,b=this[o]++,d=this[C],f=this[B];if(b>=f.length)return g(e,1);switch(a=f[b],this[z]){case k:return g(a,0);case c:return g(d[a],0)}return g([a,d[a]],0)}},v(q,s+G),v(y,T+G),v(r,U+G),v(H,p+G),q[b][A]=y[b][A]=r[b][A]=H[b][A]=J,vb=function(a){if(a!=e&&f(a[A]))return!0;switch(a&&a.constructor){case w:case m:case u:case t:return!0;case i:return Z(a)==Kb}return!1},Ab=function(a){if(a!=e&&f(a[A]))return a[A]();switch(a&&a.constructor){case i:if(Z(a)!=Kb)break;case w:case m:return new q(a,c);case u:return new y(a,k+c);case t:return new r(a,c)}throw rb(a+" is not iterable!")},P=function(e,b,c,f){for(var a,g=Ab(e);!(a=g.next()).done;)if((f?b.apply(c,d(a.value)):b.call(c,a.value))===!1)return},f(x.keys)&&E(bb([].keys()),J),a(j,s,{entries:l(q,k+c),keys:l(q,k),values:l(q,c)}),a(j,T,{entries:l(y,k+c),keys:l(y,k),values:l(y,c)}),a(j,U,{entries:l(r,k+c),keys:l(r,c),values:l(r,c)}),F&&(E(w[b],l(q,c)),E(x,x.values),E(u[b],l(y,k+c)),E(t[b],l(r,c))),Vb={keys:I(k),values:I(c),entries:I(k+c)},a(D,{forOf:P})}(" Iterator",1,2,k("iterated"),k("kind"),k("index"),k("keys"),K("return this")),!function(){function c(a){var b=z(null);return a!=e&&(vb(a)?P(a,function(a,c){b[a]=c},e,1):y(b,a)),b}function f(b,c,i){g(c);for(var a,e=d(b),f=n(e),j=f.length,h=0;j>h;)if(c.call(i,e[a=f[h++]],a,b))return a}function j(f,g){for(var a,b=d(f),c=n(b),h=c.length,e=0;h>e;)if(Qb(b[a=c[e++]],g))return a}c[b]=null,y(c,Vb,{every:function(a,b,i){g(b);for(var c,e=d(a),f=n(e),j=f.length,h=0;j>h;)if(!b.call(i,e[c=f[h++]],c,a))return!1;return!0},filter:function(c,e,j){g(e);for(var a,b=d(c),f=z(null),h=n(b),k=h.length,i=0;k>i;)e.call(j,b[a=h[i++]],a,c)&&(f[a]=b[a]);return f},find:function(a,c,g){var b=f(a,c,g);return b===e?e:d(a)[b]},findKey:f,forEach:function(a,b,i){g(b);for(var c,e=d(a),f=n(e),j=f.length,h=0;j>h;)b.call(i,e[c=f[h++]],c,a);return a},keyOf:j,map:function(b,c,j){g(c);for(var a,e=d(b),f=z(null),h=n(e),k=h.length,i=0;k>i;)f[a=h[i++]]=c.call(j,e[a],a,b);return f},reduce:function(e,f,a,k){g(f);var h,b=d(e),c=n(b),i=0,j=c.length;for(3>arguments.length&&(J(j--,Cb),a=b[c.shift()]);j>i;)a=f.call(k,a,b[h=c[i++]],h,e);return a},some:function(a,b,i){g(b);for(var c,e=d(a),f=n(e),j=f.length,h=0;j>h;)if(b.call(i,e[c=f[h++]],c,a))return!0;return!1},transform:function(b,c,a){g(c),a=a==e?z(null):i(a);for(var f,h=d(b),j=n(h),l=j.length,k=0;l>k&&c(a,h[f=j[k++]],f,b)!==!1;);return a},contains:function(a,b){return j(a,b)!==e},has:h,get:function(a,b){return h(a,b)?a[b]:e},isDict:function(a){return null==bb(a)}}),a(D,{Dict:c})}(),!function(a){function b(a){return function(b,c){return a(V.apply(f(b)?b:K(b),kb(arguments,2)),c||1)}}a&&/MSIE .\./.test(a.userAgent)&&(cb=b(cb),hb=b(hb)),pb("setTimeout",cb),pb("setInterval",hb)}(c.navigator),a(l,N,{isFunction:f,isNative:qb}),a(j,N,{construct:function(e){g(this);var a=z(this[b]),c=this.apply(a,d(e));return C(c)?c:a}}),!function(f,d){function e(e,h){function a(a){this[d]=e.apply(c,this[f]=a)}return a[b].set=function(){return h(this[d]),this[d]=e.apply(c,this[f]),this},a[b].clear=function(){return h(this[d]),this},function(){g(this);for(var b=[this],c=0;arguments.length>c;)b.push(arguments[c++]);return new a(b)}}a(j,N,{timeout:e(cb,dc),interval:e(hb,clearInterval),immediate:e(db,jb)})}(k("arguments"),k("id")),!function(){function c(e){var c,a=this,g=Y._,f=!1,b=arguments.length,d=1;if(2>b)return lb(a[e],a);for(c=m(b-1);b>d;)(c[d-1]=arguments[d++])===g&&(f=!0);return yb(a[e],c,b,f,!0,a)}var b={tie:c};a(j,N,y({part:V,by:function(d){var b,e=this,g=Y._,f=!1,a=arguments.length,c=1;if(2>a)return lb(e,d);for(b=m(a-1);a>c;)(b[c-1]=arguments[c++])===g&&(f=!0);return yb(e,b,a,f,!0,d)},methodize:function(){var a=this;return function(){for(var b=[this],c=0;arguments.length>c;)b.push(arguments[c++]);return ub.call(a,e,b)}}},b)),a(j,s,b),a(j,Db,b),a(l,p,{tie:E(c)}),q.useTie=function(){return a(j,p,b),_}}(),a(l,p,{isEnumerable:E(Xb),isPrototype:E(B.isPrototypeOf),getPropertyDescriptor:cc,getOwnPropertyDescriptors:Hb,make:function(a,b){return b==e?z(a):z(a,Hb(b))},define:function(a,b){return Q(a,Hb(b))},values:function(b){for(var g=d(b),c=n(b),e=c.length,a=0,f=m(e);e>a;)f[a]=g[c[a++]];return f},entries:function(b){for(var c,h=d(b),e=n(b),f=e.length,a=0,g=m(f);f>a;)g[a]=[c=e[a++],h[c]];return g},isObject:C,classof:Z,symbol:k,hidden:G}),a(j,s,{at:function(a){return a=M(a),d(this)[0>a?this.length+a:a]},transform:S,contains:function(c){for(var a=d(this),e=a.length,b=0;e>b;)if(Qb(c,a[b++]))return!0;return!1}}),a(l,s,S.call(X("concat,join,pop,push,reverse,shift,slice,sort,splice,unshift,indexOf,lastIndexOf,every,some,forEach,map,filter,reduce,reduceRight,fill,find,findIndex,keys,values,entries,at,transform,contains"),function(b,a){a in x&&(b[a]=E(x[a]))},{})),a(l,gb,{toInteger:M}),a(j,gb,{times:function(d,e){var b=o(this),c=m(b),a=0;if(f(d))for(;b>a;)c[a]=d.call(e,a,a++,this);else for(;b>a;)c[a]=a++;return c},random:function(d){var a=+this||0,b=+d||0,c=W(a,b);return Fb()*(Wb(a,b)-c)+c}}),a(l,"Math",{randomInt:function(a,b){a=M(a),b=M(b);var c=W(a,b);return tb(Fb()*(Wb(a,b)+1-c)+c)}}),a(j,gb,S.call(X("round,floor,ceil,abs,sin,asin,cos,acos,tan,atan,exp,sqrt,max,min,pow,atan2,acosh,asinh,atanh,cbrt,clz32,cosh,expm1,hypot,imul,log1p,log10,log2,sign,sinh,tanh,trunc,randomInt"),function(b,a){a in r&&(b[a]=function(a){return function(){for(var b=[+this],c=0;arguments.length>c;)b.push(arguments[c++]);return a.apply(e,b)}}(r[a]))},{})),!function(){var b={"&":"&","<":"<",">":">",'"':""","'":"'"},c=S.call(n(b),function(c,a){c[b[a]]=a},{}),d=/[&<>"']/g,e=/&(?:amp|lt|gt|quot|apos);/g;a(j,fb,{escapeHTML:function(){return w(this).replace(d,function(a){return b[a]})},unescapeHTML:function(){return w(this).replace(e,function(a){return c[a]})}})}(),!function(b){a(l,Db,{escape:function(a){return w(a).replace(b,"\\$1")}})}(/([\\\-[\]{}()*+?.,^$|])/g),!function(r,q,d,e,m,p,i,c,f,n){function o(a){return function(l,k){function g(b){return o[(a?"getUTC":"get")+b]()}var o=this,j=d[h(d,k)?k:e];return w(l).replace(r,function(d){switch(d){case"ms":var a=g("Milliseconds");return a>99?a:a>9?"0"+a:"00"+a;case"s":return g(m);case"ss":return b(g(m));case"m":return g(p);case"mm":return b(g(p));case"h":return g(i);case"hh":return b(g(i));case"D":return g(c);case"DD":return b(g(c));case"W":return j.W[g("Day")];case"N":return g(f)+1;case"NN":return b(g(f)+1);case"M":return j.M[g(f)];case"MM":return j.MM[g(f)];case"YY":return b(g(n)%100);case"YYYY":return g(n)}return d})}}function b(a){return a>9?a:"0"+a}function g(b,a){return d[b]={W:X(a.weekdays),MM:k(a.months,1),M:k(a.months,2)},Date}function k(a,b){return S.call(X(a),function(a,c){a.push(c.replace(q,"$"+b))})}a(l,c,{locale:function(a){return h(d,a)?e=a:e},addLocale:g}),a(j,c,{format:o(0),formatUTC:o(1)}),g(e,{weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",months:"January,February,March,April,May,June,July,August,September,October,November,December"}),g("ru",{weekdays:"Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота",months:"Январ:я|ь,Феврал:я|ь,Март:а|,Апрел:я|ь,Ма:я|й,Июн:я|ь,Июл:я|ь,Август:а|,Сентябр:я|ь,Октябр:я|ь,Ноябр:я|ь,Декабр:я|ь"})}(/\b\w{1,4}\b/g,/:(.*)\|(.*)$/,{},"en","Seconds","Minutes","Hours","Date","Month","FullYear"),!function(b){var f=S.call(X("assert,count,clear,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,table,trace,warn,markTimeline,profile,profileEnd,time,timeEnd,timeStamp"),function(c,a){c[a]=function(){return d&&b[a]?ub.call(b[a],b,arguments):e}},{enable:function(){d=!0},disable:function(){d=!1}}),d=!0;try{F&&delete c.console}catch(g){}a(D,{console:y(f.log,f)},1)}(c.console||{})}("undefined"!=typeof window?window:global,!0); | ||
//# sourceMappingURL=core.min.map |
{ | ||
"name": "core-js", | ||
"description": "Blahblahblah", | ||
"version": "0.0.5", | ||
"description": "Standard library", | ||
"version": "0.0.7", | ||
"repository": { | ||
@@ -16,4 +16,10 @@ "type": "git", | ||
"grunt-contrib-uglify": "*", | ||
"grunt-contrib-watch": "*" | ||
"grunt-contrib-watch": "*", | ||
"karma": "*", | ||
"karma-qunit": "*", | ||
"karma-chrome-launcher": "*", | ||
"karma-ie-launcher": "*", | ||
"karma-firefox-launcher": "*", | ||
"karma-opera-launcher": "*" | ||
} | ||
} |
@@ -1,75 +0,24 @@ | ||
!function(){ | ||
function arraySum(/*?*/mapArg){ | ||
var result = 0 | ||
, that = createMap(this, mapArg) | ||
, i = 0 | ||
, length = toLength(that.length); | ||
for(; length > i; i++)if(i in that)result += +that[i]; | ||
return result | ||
$define(PROTO, ARRAY, { | ||
/** | ||
* Alternatives: | ||
* http://sugarjs.com/api/Array/at | ||
* With Proxy: http://www.h3manth.com/new/blog/2013/negative-array-index-in-javascript/ | ||
*/ | ||
at: function(index){ | ||
index = toInteger(index); | ||
return ES5Object(this)[0 > index ? this.length + index : index]; | ||
}, | ||
/** | ||
* Alternatives: | ||
* http://lodash.com/docs#template | ||
*/ | ||
transform: transform, | ||
// ~ ES7 : http://esdiscuss.org/topic/april-8-2014-meeting-notes#content-1 | ||
contains: function(value){ | ||
var O = ES5Object(this) | ||
, length = O.length | ||
, i = 0; | ||
while(length > i)if(same0(value, O[i++]))return true; | ||
return false; | ||
} | ||
function props(key){ | ||
var that = arrayLikeSelf(this) | ||
, length = toLength(that.length) | ||
, result = Array(length) | ||
, i = 0 | ||
, val; | ||
for(; length > i; i++)if(i in that){ | ||
val = that[i]; | ||
result[i] = val == undefined ? undefined : val[key] | ||
} | ||
return result | ||
} | ||
function createMap(that, it){ | ||
switch(classof(it)){ | ||
case 'Function': | ||
return map.call(that, it); | ||
case 'String': | ||
case 'Number': | ||
return props.call(that, it) | ||
} | ||
return arrayLikeSelf(that) | ||
} | ||
extendBuiltInObject($Array, { | ||
at: function(index){ | ||
return arrayLikeSelf(this)[0 > index ? this.length + index : index] | ||
}, | ||
props : props, | ||
reduceTo: reduceTo, | ||
indexSame: function(val){ | ||
return indexSame(arrayLikeSelf(this), val) | ||
}, | ||
merge: function(arrayLike){ | ||
push.apply(this, arrayLikeSelf(arrayLike)); | ||
return this; | ||
}, | ||
sum: arraySum, | ||
avg: function(/*?*/mapArg){ | ||
return this.length ? arraySum.call(this, mapArg) / this.length : 0 | ||
}, | ||
min: function(/*?*/mapArg){ | ||
return min.apply(undefined, createMap(this, mapArg)); | ||
}, | ||
max: function(/*?*/mapArg){ | ||
return max.apply(undefined, createMap(this, mapArg)); | ||
}, | ||
unique: function(/*?*/mapArg){ | ||
var result = [] | ||
, that = createMap(this, mapArg) | ||
, length = toLength(that.length) | ||
, i = 0 | ||
, value; | ||
while(length > i)~indexSame(result, value = that[i++]) || result.push(value); | ||
return result | ||
}, | ||
cross: function(arrayLike){ | ||
var result = [] | ||
, that = arrayLikeSelf(this) | ||
, length = toLength(that.length) | ||
, array = arrayLikeSelf(arrayLike) | ||
, i = 0 | ||
, value; | ||
while(length > i)!~indexSame(result, value = that[i++]) && ~indexSame(array, value) && result.push(value); | ||
return result | ||
} | ||
}); | ||
}(); | ||
}); |
@@ -1,17 +0,31 @@ | ||
var _console = global.console || {} | ||
// https://github.com/DeveloperToolsWG/console-object/blob/master/api.md | ||
, $console = reduceTo.call( | ||
splitComma('assert,count,clear,debug,dir,dirxml,error,exception,' + | ||
'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) | ||
}; | ||
/** | ||
* https://github.com/DeveloperToolsWG/console-object/blob/master/api.md | ||
* https://developer.mozilla.org/en-US/docs/Web/API/console | ||
* Alternatives: | ||
* https://github.com/paulmillr/console-polyfill | ||
* https://github.com/theshock/console-cap | ||
*/ | ||
!function(console){ | ||
var $console = transform.call( | ||
array('assert,count,clear,debug,dir,dirxml,error,exception,' + | ||
'group,groupCollapsed,groupEnd,info,log,table,trace,warn,' + | ||
'markTimeline,profile,profileEnd,time,timeEnd,timeStamp'), | ||
function(memo, key){ | ||
memo[key] = function(){ | ||
if(enabled && console[key])return apply.call(console[key], console, arguments); | ||
}; | ||
}, | ||
{ | ||
enable: function(){ | ||
enabled = true; | ||
}, | ||
{enable: true} | ||
); | ||
try { | ||
delete global.console | ||
} catch(e){} | ||
$console = global.console = extendBuiltInObject($console.log, $console); | ||
disable: function(){ | ||
enabled = false; | ||
} | ||
} | ||
), enabled = true; | ||
try { | ||
framework && delete global.console; | ||
} catch(e){} | ||
$define(GLOBAL, {console: assign($console.log, $console)}, 1); | ||
}(global.console || {}); |
116
src/date.js
@@ -1,67 +0,75 @@ | ||
!function(){ | ||
function format(template, lang /* = current */){ | ||
var that = this | ||
, locale = locales[lang && has(locales, lang) ? lang : current]; | ||
return String(template).replace(formatRegExp, function(part, key){ | ||
switch(key){ | ||
case 'ms' : return that.getMilliseconds(); // mSec : 1-999 | ||
case 's' : return that[getSeconds](); // Seconds : 1-59 | ||
case 'ss' : return leadZero(that[getSeconds](), 2); // Seconds : 01-59 | ||
case 'm' : return that[getMinutes](); // Minutes : 1-59 | ||
case 'mm' : return leadZero(that[getMinutes](), 2); // Minutes : 01-59 | ||
case 'h' : return that[getHours]() % 12 || 12 // Hours : 1-23 | ||
case 'hh' : return leadZero(that[getHours]() % 12 || 12, 2);// Hours : 01-23 | ||
case 'H' : return that[getHours](); // Hours : 1-11 | ||
case 'HH' : return leadZero(that[getHours](), 2); // Hours : 01-11 | ||
case 'd' : return that.getDate(); // Date : 1-31 | ||
case 'dd' : return leadZero(that.getDate(), 2); // Date : 01-31 | ||
case 'w' : return locale.w[that.getDay()]; // Day : Понедельник | ||
case 'n' : return that[getMonth]() + 1; // Month : 1-12 | ||
case 'nn' : return leadZero(that[getMonth]() + 1, 2); // Month : 01-12 | ||
case 'M' : return locale.M[that[getMonth]()]; // Month : Январь | ||
case 'MM' : return locale.MM[that[getMonth]()]; // Month : Января | ||
case 'yy' : return leadZero(that[getFullYear]() % 100, 2); // Year : 13 | ||
case 'yyyy' : return that[getFullYear]() // Year : 2013 | ||
/** | ||
* Alternatives: | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl | ||
* https://github.com/andyearnshaw/Intl.js | ||
* http://momentjs.com/ | ||
* http://sugarjs.com/api/Date/format | ||
* http://mootools.net/docs/more/Types/Date#Date:format | ||
*/ | ||
!function(formatRegExp, flexioRegExp, locales, current, SECONDS, MINUTES, HOURS, DATE, MONTH, YEAR){ | ||
function createFormat(UTC){ | ||
return function(template, locale /* = current */){ | ||
var that = this | ||
, dict = locales[has(locales, locale) ? locale : current]; | ||
function get(unit){ | ||
return that[(UTC ? 'getUTC' : 'get') + unit](); | ||
} | ||
return part | ||
}) | ||
return String(template).replace(formatRegExp, function(part){ | ||
switch(part){ | ||
case 'ms' : var ms = get('Milliseconds'); // Milliseconds : 001-999 | ||
return ms > 99 ? ms : ms > 9 ? '0' + ms : '00' + ms; | ||
case 's' : return get(SECONDS); // Seconds : 1-59 | ||
case 'ss' : return lz(get(SECONDS)); // Seconds : 01-59 | ||
case 'm' : return get(MINUTES); // Minutes : 1-59 | ||
case 'mm' : return lz(get(MINUTES)); // Minutes : 01-59 | ||
case 'h' : return get(HOURS); // Hours : 0-23 | ||
case 'hh' : return lz(get(HOURS)); // Hours : 00-23 | ||
case 'D' : return get(DATE) // Date : 1-31 | ||
case 'DD' : return lz(get(DATE)); // Date : 01-31 | ||
case 'W' : return dict.W[get('Day')]; // Day : Понедельник | ||
case 'N' : return get(MONTH) + 1; // Month : 1-12 | ||
case 'NN' : return lz(get(MONTH) + 1); // Month : 01-12 | ||
case 'M' : return dict.M[get(MONTH)]; // Month : Январь | ||
case 'MM' : return dict.MM[get(MONTH)]; // Month : Января | ||
case 'YY' : return lz(get(YEAR) % 100); // Year : 13 | ||
case 'YYYY' : return get(YEAR); // Year : 2013 | ||
} | ||
return part; | ||
}); | ||
} | ||
} | ||
function lz(num){ | ||
return num > 9 ? num : '0' + num; | ||
} | ||
function addLocale(lang, locale){ | ||
locales[lang] = { | ||
w : splitComma(locale.w), | ||
M : splitComma(locale.M).map(flexio(0)), | ||
MM: splitComma(locale.M).map(flexio(1)) | ||
} | ||
W : array(locale.weekdays), | ||
MM: flexio(locale.months, 1), | ||
M : flexio(locale.months, 2) | ||
}; | ||
return Date; | ||
} | ||
function flexio(index){ | ||
return function(it){ | ||
return it.replace(/\+(.+)$/, function(part, str){ | ||
return str.split('|')[index] | ||
}) | ||
} | ||
function flexio(locale, index){ | ||
return transform.call(array(locale), function(memo, it){ | ||
memo.push(it.replace(flexioRegExp, '$' + index)); | ||
}); | ||
} | ||
var formatRegExp = /\b(\w\w*)\b/g | ||
, current = 'en' | ||
, locales = {} | ||
, getSeconds = 'getSeconds' | ||
, getMinutes = 'getMinutes' | ||
, getHours = 'getHours' | ||
, getMonth = 'getMonth' | ||
, getFullYear = 'getFullYear'; | ||
extendBuiltInObject(Date, { | ||
$define(STATIC, DATE, { | ||
locale: function(locale){ | ||
if(has(locales, locale))current = locale; | ||
return current | ||
return has(locales, locale) ? current = locale : current; | ||
}, | ||
addLocale: addLocale | ||
}); | ||
extendBuiltInObject(Date[prototype], {format: format}); | ||
addLocale('en', { | ||
w: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday', | ||
M: 'January,February,March,April,May,June,July,August,September,October,November,December' | ||
$define(PROTO, DATE, { | ||
format: createFormat(0), | ||
formatUTC: createFormat(1) | ||
}); | ||
addLocale(current, { | ||
weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday', | ||
months: 'January,February,March,April,May,June,July,August,September,October,November,December' | ||
}); | ||
addLocale('ru', { | ||
w: 'Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота', | ||
M: 'Январ+ь|я,Феврал+ь|я,Март+|а,Апрел+ь|я,Ма+й|я,Июн+ь|я,Июл+ь|я,Август+|а,Сентябр+ь|я,Октябр+ь|я,Ноябр+ь|я,Декабр+ь|я' | ||
weekdays: 'Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота', | ||
months: 'Январ:я|ь,Феврал:я|ь,Март:а|,Апрел:я|ь,Ма:я|й,Июн:я|ь,Июл:я|ь,Август:а|,Сентябр:я|ь,Октябр:я|ь,Ноябр:я|ь,Декабр:я|ь' | ||
}); | ||
}(); | ||
}(/\b\w{1,4}\b/g, /:(.*)\|(.*)$/, {}, 'en', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear'); |
376
src/es5.js
@@ -0,22 +1,29 @@ | ||
/** | ||
* ECMAScript 5 shim | ||
* http://es5.github.io/ | ||
* Alternatives: | ||
* https://github.com/es-shims/es5-shim | ||
* https://github.com/ddrcode/ddr-ecma5 | ||
* http://augmentjs.com/ | ||
* https://github.com/inexorabletash/polyfill/blob/master/es5.js | ||
*/ | ||
!function(){ | ||
// not enum keys | ||
var Empty = Function() | ||
, protoInObject = new Empty().__proto__ == Empty[prototype] | ||
, LTrimRegExp = RegExp(LTrim) | ||
, RTrimRegExp = RegExp(RTrim) | ||
var Empty = Function() | ||
, _classof = classof | ||
, whitespace = '[\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]' | ||
, trimRegExp = RegExp('^' + whitespace + '+|' + whitespace + '+$', 'g') | ||
// 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']) | ||
, hidenNames1Length = hidenNames1.length | ||
, nativeSlice = slice | ||
, nativeJoin = $Array.join | ||
// Create object with null as it's prototype | ||
, createNullProtoObject = protoInObject | ||
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation | ||
, hiddenNames1 = array('toString,toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,constructor') | ||
, hiddenNames2 = hiddenNames1.concat(['length']) | ||
, hiddenNames1Length = hiddenNames1.length | ||
// Create object with null prototype | ||
, createDict = __PROTO__ | ||
? function(){ | ||
return {__proto__: null} | ||
return {__proto__: null}; | ||
} | ||
: function(){ | ||
// Thrash, waste and sodomy | ||
var iframe = document.createElement('iframe') | ||
, i = hidenNames1Length | ||
var iframe = document[CREATE_ELEMENT]('iframe') | ||
, i = hiddenNames1Length | ||
, body = document.body || document.documentElement | ||
@@ -29,11 +36,11 @@ , iframeDocument; | ||
iframeDocument.open(); | ||
iframeDocument.write('<script>document._=Object</script>'); | ||
iframeDocument.write('<script>document.F=Object</script>'); | ||
iframeDocument.close(); | ||
createNullProtoObject = iframeDocument._; | ||
// body.removeChild(iframe); | ||
while(i--)delete createNullProtoObject[prototype][hidenNames1[i]]; | ||
return createNullProtoObject() | ||
createDict = iframeDocument.F; | ||
while(i--)delete createDict[PROTOTYPE][hiddenNames1[i]]; | ||
return createDict(); | ||
} | ||
, createGetKeys = function(names, length){ | ||
return function(O){ | ||
O = ES5Object(O); | ||
var i = 0 | ||
@@ -43,119 +50,108 @@ , result = [] | ||
for(key in O)has(O, key) && result.push(key); | ||
// hiden names for Object.getOwnPropertyNames & don't enum bug fix for Object.keys | ||
while(length > i)has(O, key = names[i++]) && !~result[indexOf](key) && result.push(key); | ||
return result | ||
// hidden names for Object.getOwnPropertyNames & don't enum bug fix for Object.keys | ||
while(length > i)has(O, key = names[i++]) && !~$indexOf(result, key) && result.push(key); | ||
return result; | ||
} | ||
} | ||
// The engine has a guaranteed way to get a prototype? | ||
, $PROTO = !!Object.getPrototypeOf || protoInObject; | ||
}; | ||
// The engine works fine with descriptors? Thank's IE8 for his funny defineProperty. | ||
try { | ||
defineProperty({}, 0, $Object); | ||
} | ||
catch(e){ | ||
DESCRIPTORS = 0; | ||
/** | ||
* 15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) | ||
* http://es5.github.io/#x15.2.3.3 | ||
*/ | ||
Object.getOwnPropertyDescriptor = function(O, P){ | ||
if(has(O, P))return descriptor(6 + isEnumerable(O, P), O[P]) | ||
Object.defineProperty({}, 0, $Object); | ||
} catch(e){ | ||
DESCRIPTORS = false; | ||
getOwnPropertyDescriptor = function(O, P){ | ||
if(has(O, P))return descriptor(6 + isEnumerable.call(O, P), O[P]); | ||
}; | ||
/** | ||
* 15.2.3.6 Object.defineProperty ( O, P, Attributes ) | ||
* http://es5.github.io/#x15.2.3.6 | ||
*/ | ||
Object.defineProperty = defineProperty = function(O, P, Attributes){ | ||
O[P] = Attributes.value; | ||
return O | ||
defineProperty = function(O, P, Attributes){ | ||
assertObject(O); | ||
if('value' in Attributes)O[P] = Attributes.value; | ||
return O; | ||
}; | ||
/** | ||
* 15.2.3.7 Object.defineProperties ( O, Properties ) | ||
* http://es5.github.io/#x15.2.3.7 | ||
*/ | ||
Object.defineProperties = function(O, Properties){ | ||
// IE 9- don't enum bug => Object.keys | ||
var names = keys(Properties) | ||
defineProperties = function(O, Properties){ | ||
assertObject(O); | ||
var names = keys(Properties) | ||
, length = names.length | ||
, i = 0 | ||
, key; | ||
while(length > i)O[key = names[i++]] = Properties[key].value; | ||
return O | ||
, P, Attributes; | ||
while(length > i){ | ||
P = names[i++]; | ||
Attributes = Properties[P]; | ||
if('value' in Attributes)O[P] = Attributes.value; | ||
} | ||
return O; | ||
} | ||
} | ||
extendBuiltInObject(Object, { | ||
/** | ||
* 15.2.3.2 Object.getPrototypeOf ( O ) | ||
* http://es5.github.io/#x15.2.3.2 | ||
*/ | ||
$define(STATIC, OBJECT, { | ||
// 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P) | ||
getOwnPropertyDescriptor: getOwnPropertyDescriptor, | ||
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) | ||
defineProperty: defineProperty, | ||
// 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) | ||
defineProperties: defineProperties | ||
}, 1); | ||
$define(STATIC, OBJECT, { | ||
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) | ||
getPrototypeOf: function(O){ | ||
var constructor | ||
, proto = O.__proto__ || ((constructor = O.constructor) ? constructor[prototype] : $Object); | ||
return O != proto && toStringKey in O ? proto : null | ||
, proto = O.__proto__ || ((constructor = O.constructor) ? constructor[PROTOTYPE] : $Object); | ||
return O !== proto && 'toString' in O ? proto : null; | ||
}, | ||
/** | ||
* 15.2.3.4 Object.getOwnPropertyNames ( O ) | ||
* http://es5.github.io/#x15.2.3.4 | ||
*/ | ||
getOwnPropertyNames: createGetKeys(hidenNames2, hidenNames2.length), | ||
/** | ||
* 15.2.3.5 Object.create ( O [, Properties] ) | ||
* http://es5.github.io/#x15.2.3.5 | ||
*/ | ||
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) | ||
getOwnPropertyNames: createGetKeys(hiddenNames2, hiddenNames2.length), | ||
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) | ||
create: function(O, /*?*/Properties){ | ||
if(O === null)return Properties ? defineProperties(createNullProtoObject(), Properties) : createNullProtoObject(); | ||
if(!isObject(O))throw TypeError('Object prototype may only be an Object or null'); | ||
Empty[prototype] = O; | ||
if(O === null)return Properties ? defineProperties(createDict(), Properties) : createDict(); | ||
assertObject(O); | ||
Empty[PROTOTYPE] = O; | ||
var result = new Empty(); | ||
if(Properties)defineProperties(result, Properties); | ||
// add __proto__ for Object.getPrototypeOf shim | ||
$PROTO || result.constructor[prototype] == O || (result.__proto__ = O); | ||
return result | ||
__PROTO__ || result.constructor[PROTOTYPE] === O || (result.__proto__ = O); | ||
return result; | ||
}, | ||
/** | ||
* 15.2.3.14 Object.keys ( O ) | ||
* http://es5.github.io/#x15.2.3.14 | ||
*/ | ||
keys: createGetKeys(hidenNames1, hidenNames1Length) | ||
// 19.1.2.14 / 15.2.3.14 Object.keys(O) | ||
keys: createGetKeys(hiddenNames1, hiddenNames1Length) | ||
}); | ||
// not array-like strings fix | ||
if(!(0 in Object('q'))){ | ||
arrayLikeSelf = function(it){ | ||
return isString(it) ? it.split('') : Object(it) | ||
}; | ||
// Array.prototype methods for strings in ES3 | ||
$Array.slice = slice = function(){ | ||
return nativeSlice.apply(arrayLikeSelf(this), arguments) | ||
}; | ||
$Array.join = function(){ | ||
return nativeJoin.apply(arrayLikeSelf(this), arguments) | ||
} | ||
} | ||
/** | ||
* 15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, …]]) | ||
* http://es5.github.io/#x15.3.4.5 | ||
*/ | ||
extendBuiltInObject($Function, { | ||
bind:function(scope /*, args...*/){ | ||
// 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg [, arg1 [, arg2, …]]) | ||
$define(PROTO, FUNCTION, { | ||
bind: function(scope /*, args... */){ | ||
var fn = this | ||
, args = slice1(arguments); | ||
function bound(){ | ||
return apply.call(fn, fn[prototype] && this instanceof fn ? this : scope, args.concat(toArray(arguments))) | ||
, args = $slice(arguments, 1); | ||
assertFunction(fn); | ||
function bound(/* args... */){ | ||
var _args = args.concat($slice(arguments)) | ||
, result, that | ||
if(this instanceof fn)return isObject(result = apply.call(that = create(fn[PROTOTYPE]), scope, _args)) ? result : that; | ||
return apply.call(fn, scope, _args); | ||
} | ||
bound[prototype] = fn[prototype]; | ||
return bound | ||
bound[PROTOTYPE] = undefined; | ||
return bound; | ||
} | ||
}); | ||
/** | ||
* 15.4.3.2 Array.isArray ( arg ) | ||
* http://es5.github.io/#x15.4.3.2 | ||
*/ | ||
extendBuiltInObject(Array, {isArray: isArray}); | ||
extendBuiltInObject($Array, { | ||
/** | ||
* 15.4.4.14 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) | ||
* http://es5.github.io/#x15.4.4.14 | ||
*/ | ||
// fix for not array-like ES3 string | ||
function arrayMethodFix(fn){ | ||
return function(){ | ||
return fn.apply(ES5Object(this), arguments); | ||
} | ||
} | ||
if(!(0 in Object('q') && 'q'[0] == 'q')){ | ||
ES5Object = function(it){ | ||
return _classof(it) == STRING ? it.split('') : Object(it); | ||
} | ||
slice = arrayMethodFix(slice); | ||
} | ||
$define(PROTO, ARRAY, { | ||
slice: slice, | ||
join: arrayMethodFix($Array.join) | ||
}, ES5Object != Object); | ||
// 22.1.2.2 / 15.4.3.2 Array.isArray(arg) | ||
$define(STATIC, ARRAY, {isArray: function(arg){ | ||
return _classof(arg) == ARRAY | ||
}}); | ||
$define(PROTO, ARRAY, { | ||
// 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex]) | ||
indexOf: function(searchElement, fromIndex /* = 0 */){ | ||
var self = arrayLikeSelf(this) | ||
var self = ES5Object(this) | ||
, length = toLength(self.length) | ||
@@ -165,10 +161,7 @@ , i = fromIndex | 0; | ||
for(;length > i; i++)if(i in self && self[i] === searchElement)return i; | ||
return -1 | ||
return -1; | ||
}, | ||
/** | ||
* 15.4.4.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) | ||
* http://es5.github.io/#x15.4.4.15 | ||
*/ | ||
// 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex]) | ||
lastIndexOf: function(searchElement, fromIndex /* = @[*-1] */){ | ||
var self = arrayLikeSelf(this) | ||
var self = ES5Object(this) | ||
, length = toLength(self.length) | ||
@@ -178,11 +171,9 @@ , i = length - 1; | ||
if(0 > i)i = toLength(length + i); | ||
for(; i >= 0; i--)if(i in self && self[i] === searchElement)return i; | ||
return -1 | ||
for(;i >= 0; i--)if(i in self && self[i] === searchElement)return i; | ||
return -1; | ||
}, | ||
/** | ||
* 15.4.4.16 Array.prototype.every ( callbackfn [ , thisArg ] ) | ||
* http://es5.github.io/#x15.4.4.16 | ||
*/ | ||
// 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg]) | ||
every: function(callbackfn, thisArg /* = undefined */){ | ||
var self = arrayLikeSelf(this) | ||
assertFunction(callbackfn); | ||
var self = ES5Object(this) | ||
, length = toLength(self.length) | ||
@@ -193,10 +184,8 @@ , i = 0; | ||
} | ||
return true | ||
return true; | ||
}, | ||
/** | ||
* 15.4.4.17 Array.prototype.some ( callbackfn [ , thisArg ] ) | ||
* http://es5.github.io/#x15.4.4.17 | ||
*/ | ||
// 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg]) | ||
some: function(callbackfn, thisArg /* = undefined */){ | ||
var self = arrayLikeSelf(this) | ||
assertFunction(callbackfn); | ||
var self = ES5Object(this) | ||
, length = toLength(self.length) | ||
@@ -207,94 +196,87 @@ , i = 0; | ||
} | ||
return false | ||
return false; | ||
}, | ||
/** | ||
* 15.4.4.18 Array.prototype.forEach ( callbackfn [ , thisArg ] ) | ||
* http://es5.github.io/#x15.4.4.18 | ||
*/ | ||
// 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) | ||
forEach: function(callbackfn, thisArg /* = undefined */){ | ||
var self = arrayLikeSelf(this) | ||
assertFunction(callbackfn); | ||
var self = ES5Object(this) | ||
, length = toLength(self.length) | ||
, i = 0; | ||
for(;length > i; i++)i in self && callbackfn.call(thisArg, self[i], i, this) | ||
for(;length > i; i++)i in self && callbackfn.call(thisArg, self[i], i, this); | ||
}, | ||
/** | ||
* 15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] ) | ||
* http://es5.github.io/#x15.4.4.19 | ||
*/ | ||
// 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg]) | ||
map: function(callbackfn, thisArg /* = undefined */){ | ||
var self = arrayLikeSelf(this) | ||
, length = toLength(self.length) | ||
, rez = Array(length) | ||
, i = 0; | ||
for(;length > i; i++){ | ||
if(i in self)rez[i] = callbackfn.call(thisArg, self[i], i, this); | ||
} | ||
return rez | ||
assertFunction(callbackfn); | ||
var result = Array(toLength(this.length)); | ||
$forEach(this, function(val, key, that){ | ||
result[key] = callbackfn.call(thisArg, val, key, that); | ||
}); | ||
return result; | ||
}, | ||
/** | ||
* 15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] ) | ||
* http://es5.github.io/#x15.4.4.20 | ||
*/ | ||
// 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg]) | ||
filter: function(callbackfn, thisArg /* = undefined */){ | ||
var self = arrayLikeSelf(this) | ||
, length = toLength(self.length) | ||
, i = 0 | ||
, rez = []; | ||
for(;length > i; i++){ | ||
i in self | ||
&& callbackfn.call(thisArg, self[i], i, this) | ||
&& rez.push(self[i]); | ||
} | ||
return rez | ||
assertFunction(callbackfn); | ||
var result = []; | ||
$forEach(this, function(val){ | ||
callbackfn.apply(thisArg, arguments) && result.push(val); | ||
}); | ||
return result; | ||
}, | ||
/** | ||
* 15.4.4.21 Array.prototype.reduce ( callbackfn [ , initialValue ] ) | ||
* http://es5.github.io/#x15.4.4.21 | ||
*/ | ||
reduce: function(callbackfn, memo /* = @.1 */){ | ||
var self = arrayLikeSelf(this) | ||
// 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) | ||
reduce: function(callbackfn, memo /* = @.0 */){ | ||
assertFunction(callbackfn); | ||
var self = ES5Object(this) | ||
, length = toLength(self.length) | ||
, i = 0; | ||
if(2 > arguments.length)while(true){ | ||
if(2 > arguments.length)for(;;){ | ||
if(i in self){ | ||
memo = self[i++]; | ||
break | ||
break; | ||
} | ||
if(length <= ++i)throw TypeError(REDUCE_ERROR) | ||
assert(length > ++i, REDUCE_ERROR); | ||
} | ||
for(;length > i; i++)if(i in self)memo = callbackfn(memo, self[i], i, this); | ||
return memo | ||
return memo; | ||
}, | ||
/** | ||
* 15.4.4.22 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) | ||
* http://es5.github.io/#x15.4.4.22 | ||
*/ | ||
// 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue]) | ||
reduceRight: function(callbackfn, memo /* = @[*-1] */){ | ||
var self = arrayLikeSelf(this) | ||
assertFunction(callbackfn); | ||
var self = ES5Object(this) | ||
, i = toLength(self.length) - 1; | ||
if(2 > arguments.length)while(true){ | ||
if(2 > arguments.length)for(;;){ | ||
if(i in self){ | ||
memo = self[i--]; | ||
break | ||
break; | ||
} | ||
if(0 > --i)throw TypeError(REDUCE_ERROR) | ||
assert(0 <= --i, REDUCE_ERROR); | ||
} | ||
for(;i >= 0; i--)if(i in self)memo = callbackfn(memo, self[i], i, this); | ||
return memo | ||
return memo; | ||
} | ||
}); | ||
/** | ||
* 15.5.4.20 String.prototype.trim ( ) | ||
* http://es5.github.io/#x15.5.4.20 | ||
*/ | ||
extendBuiltInObject($String, {trim: function(){ | ||
return String(this).replace(LTrimRegExp, '').replace(RTrimRegExp, '') | ||
// 21.1.3.25 / 15.5.4.20 String.prototype.trim() | ||
$define(PROTO, STRING, {trim: function(){ | ||
return String(this).replace(trimRegExp, ''); | ||
}}); | ||
/** | ||
* 15.9.4.4 Date.now ( ) | ||
* http://es5.github.io/#x15.9.4.4 | ||
*/ | ||
extendBuiltInObject(Date, {now: function(){ | ||
return +new Date | ||
// 20.3.3.1 / 15.9.4.4 Date.now() | ||
$define(STATIC, 'Date', {now: function(){ | ||
return +new Date; | ||
}}); | ||
if(isFunction(trimRegExp))isFunction = function(it){ | ||
return _classof(it) == FUNCTION; | ||
} | ||
if(_classof(function(){return arguments}()) == OBJECT)classof = function(it){ | ||
var cof = _classof(it); | ||
return cof != OBJECT || !isFunction(it.callee) ? cof : ARGUMENTS; | ||
} | ||
create = Export[OBJECT].create; | ||
getPrototypeOf = Export[OBJECT].getPrototypeOf; | ||
keys = Export[OBJECT].keys; | ||
getOwnPropertyNames = Export[OBJECT].getOwnPropertyNames; | ||
$indexOf = Export[ARRAY].indexOf; | ||
$forEach = Export[ARRAY].forEach; | ||
}(); |
491
src/es6.js
@@ -1,161 +0,124 @@ | ||
!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 | ||
*/ | ||
/** | ||
* ECMAScript 6 shim | ||
* http://people.mozilla.org/~jorendorff/es6-draft.html | ||
* http://wiki.ecmascript.org/doku.php?id=harmony:proposals | ||
* Alternatives: | ||
* https://github.com/paulmillr/es6-shim | ||
* https://github.com/monolithed/ECMAScript-6 | ||
* https://github.com/inexorabletash/polyfill/blob/master/harmony.js | ||
*/ | ||
!function(isFinite){ | ||
function sign(it){ | ||
return (it = +it) == 0 || it != it ? it : it < 0 ? -1 : 1; | ||
} | ||
$define(STATIC, OBJECT, { | ||
// 19.1.3.1 Object.assign(target, source) | ||
// The assign function is used to copy the values of all of the enumerable | ||
// own properties from a source object to a target object. | ||
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) | ||
// 19.1.3.10 Object.is(value1, value2) | ||
is: same | ||
}); | ||
// 19.1.3.19 Object.setPrototypeOf(O, proto) | ||
// Works with __proto__ only. Old v8 can't works with null proto objects. | ||
__PROTO__ && (function(set, buggy){ | ||
try { set({}, $Array) } | ||
catch(e){ buggy = true } | ||
$define(STATIC, OBJECT, { | ||
setPrototypeOf: function(O, proto){ | ||
assertObject(O); | ||
assert(isObject(proto) || proto === null, "Can't set", proto, 'as prototype'); | ||
if(buggy)O.__proto__ = proto; | ||
else set(O, proto); | ||
return O; | ||
} | ||
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 | ||
*/ | ||
}); | ||
})(unbind(getOwnPropertyDescriptor($Object, '__proto__').set)); | ||
$define(STATIC, NUMBER, { | ||
// 20.1.2.1 Number.EPSILON | ||
EPSILON: pow(2, -52), | ||
// 20.1.2.2 Number.isFinite(number) | ||
isFinite: function(it){ | ||
return typeof it == 'number' && isFinite(it); | ||
}, | ||
// 20.1.2.3 Number.isInteger(number) | ||
isInteger: function(it){ | ||
return isFinite(it) && floor(it) === it; | ||
}, | ||
// 20.1.2.4 Number.isNaN(number) | ||
isNaN: function(number){ | ||
return typeof number == 'number' && number != number; | ||
}, | ||
// 20.1.2.5 Number.isSafeInteger(number) | ||
isSafeInteger: function(number){ | ||
return isInt(number) && abs(number) <= MAX_SAFE_INTEGER; | ||
return isInteger(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 | ||
*/ | ||
// 20.1.2.6 Number.MAX_SAFE_INTEGER | ||
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 | ||
*/ | ||
// 20.1.2.10 Number.MIN_SAFE_INTEGER | ||
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 | ||
*/ | ||
// 20.1.2.12 Number.parseFloat(string) | ||
parseFloat: parseFloat, | ||
/*** | ||
* 20.1.2.13 Number.parseInt (string, radix) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.1.2.13 | ||
*/ | ||
// 20.1.2.13 Number.parseInt(string, radix) | ||
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. | ||
*/ | ||
var isInteger = Number.isInteger | ||
, abs = Math.abs | ||
, exp = Math.exp | ||
, log = Math.log | ||
, sqrt = Math.sqrt; | ||
function asinh(x){ | ||
return !isFinite(x = +x) || x === 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1)); | ||
} | ||
$define(STATIC, 'Math', { | ||
// 20.2.2.3 Math.acosh(x) | ||
// Returns an implementation-dependent approximation to the inverse hyperbolic cosine of x. | ||
acosh: function(x){ | ||
return ln(x + sqrt(x * x - 1)) | ||
return log(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. | ||
*/ | ||
// 20.2.2.5 Math.asinh(x) | ||
// Returns an implementation-dependent approximation to the inverse hyperbolic sine of x. | ||
asinh: asinh, | ||
// 20.2.2.7 Math.atanh(x) | ||
// 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)) | ||
return x === 0 ? x : 0.5 * log((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. | ||
*/ | ||
// 20.2.2.9 Math.cbrt(x) | ||
// 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. | ||
*/ | ||
// 20.2.2.11 Math.clz32 (x) | ||
clz32: function(x){ | ||
x = x >>> 0; | ||
return x ? 32 - x.toString(2).length : 32; | ||
}, | ||
// 20.2.2.12 Math.cosh(x) | ||
// 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 | ||
return (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 | ||
*/ | ||
// 20.2.2.14 Math.expm1(x) | ||
// 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 | ||
return same(x, -0) ? -0 : x > -1e-6 && x < 1e-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.16 Math.fround(x) | ||
// fround: function(x){ TODO }, | ||
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) | ||
// Returns an implementation-dependent approximation of the square root | ||
// of the sum of squares of its arguments. | ||
hypot: function(value1, value2){ | ||
var sum = 0 | ||
, length = arguments.length | ||
, value; | ||
while(length--){ | ||
value = +arguments[length]; | ||
if(value == Infinity || value == -Infinity)return Infinity; | ||
sum += value * value; | ||
} | ||
return sqrt(sum); | ||
}, | ||
/** | ||
* 20.2.2.17 Math.imul(x, y) | ||
* https://people.mozilla.com/~jorendorff/es6-draft.html#sec-20.2.2.17 | ||
*/ | ||
// 20.2.2.18 Math.imul(x, y) | ||
imul: function(x, y){ | ||
@@ -166,99 +129,58 @@ var xh = (x >>> 0x10) & 0xffff | ||
, yl = y & 0xffff; | ||
return xl * yl + (((xh * yl + xl * yh) << 0x10) >>> 0) | 0 | ||
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. | ||
*/ | ||
// 20.2.2.20 Math.log1p(x) | ||
// 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) | ||
return (x > -1e-8 && x < 1e-8) ? (x - x * x / 2) : log(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. | ||
*/ | ||
// 20.2.2.21 Math.log10(x) | ||
// Returns an implementation-dependent approximation to the base 10 logarithm of x. | ||
log10: function(x){ | ||
return ln(x) / Math.LN10 | ||
return log(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. | ||
*/ | ||
// 20.2.2.22 Math.log2(x) | ||
// Returns an implementation-dependent approximation to the base 2 logarithm of x. | ||
log2: function(x){ | ||
return ln(x) / Math.LN2 | ||
return log(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. | ||
*/ | ||
// 20.2.2.28 Math.sign(x) | ||
// 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. | ||
*/ | ||
// 20.2.2.30 Math.sinh(x) | ||
// 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 | ||
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. | ||
*/ | ||
// 20.2.2.33 Math.tanh(x) | ||
// 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) | ||
return isFinite(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. | ||
*/ | ||
// 20.2.2.34 Math.trunc(x) | ||
// 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) | ||
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 | ||
*/ | ||
// 20.2.1.9 Math [ @@toStringTag ] | ||
setTag(Math, 'Math', 1); | ||
/** | ||
$define(STATIC, STRING, { | ||
// 21.1.2.2 String.fromCodePoint(...codePoints) | ||
// fromCodePoint: function(){ TODO }, | ||
// 21.1.2.4 String.raw(callSite, ...substitutions) | ||
raw: function(){ TODO } | ||
}); | ||
*/ | ||
$define(PROTO, STRING, { | ||
// 21.1.3.3 String.prototype.codePointAt(pos) | ||
// codePointAt: function(pos /* = 0 * /){ TODO }, | ||
// 21.1.3.6 String.prototype.contains(searchString, position = 0) | ||
contains: function(searchString, position /* = 0 */){ | ||
return !!~String(this)[indexOf](searchString, position) | ||
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 | ||
*/ | ||
// 21.1.3.7 String.prototype.endsWith(searchString [, endPosition]) | ||
endsWith: function(searchString, endPosition /* = @length */){ | ||
@@ -268,97 +190,70 @@ var length = this.length; | ||
endPosition = toLength(min(endPosition === undefined ? length : endPosition, length)); | ||
return String(this).slice(endPosition - searchString.length, endPosition) === searchString | ||
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 | ||
*/ | ||
// 21.1.3.13 String.prototype.repeat(count) | ||
repeat: function(count){ | ||
return fill.call(Array(toInt(count)), this).join('') | ||
assert(0 <= (count |= 0), "Count can't be negative"); | ||
return Array(count + 1).join(this); | ||
}, | ||
/** | ||
* 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 | ||
*/ | ||
// 21.1.3.18 String.prototype.startsWith(searchString [, position ]) | ||
startsWith: function(searchString, position /* = 0 */){ | ||
searchString += ''; | ||
position = toLength(min(position, this.length)); | ||
return String(this).slice(position, position + searchString.length) === searchString | ||
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 | ||
*/ | ||
$define(STATIC, ARRAY, { | ||
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) | ||
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 | ||
if(mapfn !== undefined)assertFunction(mapfn); | ||
var O = ES5Object(arrayLike) | ||
, result = new (isFunction(this) ? this : Array) | ||
, i = 0, length, iter, step; | ||
if(isIterable && isIterable(O)){ | ||
iter = getIterator(O); | ||
while(!(step = iter.next()).done)push.call(result, mapfn ? mapfn.call(thisArg, step.value, i++) : step.value); | ||
} else for(length = toLength(O.length); i < length; i++)push.call(result, mapfn ? mapfn.call(thisArg, O[i], 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 | ||
// 22.1.2.3 Array.of( ...items) | ||
of: function(/*...args*/){ | ||
var i = 0, length = arguments.length | ||
, result = new (isFunction(this) ? this : Array); | ||
while(i < length)push.call(result, 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 | ||
function findIndex(predicate, thisArg /* = undefind */){ | ||
assertFunction(predicate); | ||
var O = Object(this) | ||
, self = ES5Object(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; | ||
} | ||
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){ | ||
$define(PROTO, ARRAY, { | ||
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) | ||
// copyWithin: function(target, start, end){ TODO }, | ||
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) | ||
fill: function(value, start /* = 0 */, end /* = @length */){ | ||
var length = toLength(this.length); | ||
start = toInteger(start); | ||
if(0 > start)start = length + start; | ||
end = end == undefined ? length : toInteger(end); | ||
while(end > start)this[start++] = value; | ||
return this; | ||
}, | ||
*/ | ||
/** | ||
* 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 | ||
*/ | ||
// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) | ||
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 | ||
var index = findIndex.call(this, predicate, thisArg); | ||
if(~index)return ES5Object(this)[index]; | ||
}, | ||
/** | ||
* 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.9 Array.prototype.findIndex(predicate, thisArg = undefined) | ||
findIndex: findIndex | ||
}); | ||
}(); | ||
// 24.3.3 JSON [ @@toStringTag ] | ||
setTag(global.JSON, 'JSON', 1); | ||
}(isFinite); |
@@ -1,97 +0,13 @@ | ||
function inherits(parent){ | ||
this[prototype] = create(parent[prototype], getOwnPropertyDescriptors(this[prototype])); | ||
return this | ||
} | ||
extendBuiltInObject(Function, { | ||
isNative: isNative, | ||
inherits: $unbind(inherits) | ||
$define(STATIC, FUNCTION, { | ||
isFunction: isFunction, | ||
isNative: isNative | ||
}); | ||
extendBuiltInObject($Function, { | ||
// method -> function | ||
unbind: unbind, | ||
// function -> method | ||
methodize: methodize, | ||
// partial apply | ||
part: part, | ||
partial: function(args/*?*/, that){ | ||
var fn = this | ||
, argsPart = toArray(args) | ||
, isThat = arguments.length > 1; | ||
return function(/*args...*/){ | ||
var args = toArray(argsPart) | ||
, length = arguments.length | ||
, i, current = i = 0; | ||
while(length > i){ | ||
while(args[current] !== undefined)current++; | ||
args[current++] = arguments[i++] | ||
} | ||
return fn.apply(isThat ? that : this, args) | ||
} | ||
}, | ||
// http://www.wirfs-brock.com/allen/posts/166 | ||
// http://habrahabr.ru/post/114737/ | ||
only: function(numberArguments/*?*/, that){ | ||
numberArguments |= 0; | ||
var fn = this | ||
, isThat = arguments.length > 1; | ||
return function(/*args...*/){ | ||
return fn.apply(isThat ? that : this, slice.call(arguments, 0, min(numberArguments, arguments.length))) | ||
} | ||
}, | ||
// simple bind context | ||
ctx: ctx, | ||
invoke: function(args){ | ||
var instance = create(this[prototype]) | ||
, result = this.apply(instance, arrayLikeSelf(args || [])); | ||
return isObject(result) ? result : instance | ||
}, | ||
once: function(){ | ||
var fn = this | ||
, wait = 1 | ||
, result; | ||
return function(/*args...*/){ | ||
if(wait){ | ||
wait = 0; | ||
result = fn.apply(this, arguments) | ||
} | ||
return result | ||
} | ||
}, | ||
// AOP | ||
error: function(cb /*cb(error, arguments)*/){ | ||
var fn = this; | ||
return function(/*args...*/){ | ||
var args = toArray(arguments); | ||
try{return fn.apply(this, args)} | ||
catch(e){return cb.call(this, e, args)} | ||
} | ||
}, | ||
before: function(cb /*cb(arguments)*/){ | ||
var fn = this; | ||
return function(/*args...*/){ | ||
var args = toArray(arguments); | ||
cb.call(this, args); | ||
return fn.apply(this, args) | ||
} | ||
}, | ||
after: function(cb /*cb(result, arguments)*/){ | ||
var fn = this; | ||
return function(/*args...*/){ | ||
var args = toArray(arguments) | ||
, result = fn.apply(this, args) | ||
, resultAfter = cb.call(this, result, args); | ||
return resultAfter === undefined ? result : resultAfter | ||
} | ||
}, | ||
// deferred call | ||
timeout: function(del /*, args...*/){ | ||
return $part(clearTimeout, setTimeout(part.apply(this, slice1(arguments)), del)) | ||
}, | ||
interval: function(del /*, args...*/){ | ||
return $part(clearInterval, setInterval(part.apply(this, slice1(arguments)), del)) | ||
}, | ||
immediate: function(/* args...*/){ | ||
return $part(clearImmediate, setImmediate(part.apply(this, arguments))) | ||
}, | ||
inherits: inherits | ||
$define(PROTO, FUNCTION, { | ||
// 7.3.18 Construct (F, argumentsList) | ||
construct: function(args){ | ||
assertFunction(this); | ||
var instance = create(this[PROTOTYPE]) | ||
, result = this.apply(instance, ES5Object(args)); | ||
return isObject(result) ? result : instance; | ||
} | ||
}); |
@@ -1,1 +0,1 @@ | ||
global.global = global; | ||
$define(GLOBAL, {global: global}); |
@@ -1,55 +0,72 @@ | ||
extendBuiltInObject(Number, { | ||
toInteger: toInt | ||
$define(STATIC, NUMBER, { | ||
/** | ||
* Alternatives: | ||
* http://mootools.net/docs/core/Types/Number#Number:toInt | ||
*/ | ||
toInteger: toInteger | ||
}); | ||
extendBuiltInObject($Number, { | ||
div: function(divisor){ | ||
var result = this / divisor; | ||
return (result > 0 ? floor : ceil)(result) | ||
$define(PROTO, NUMBER, { | ||
/** | ||
* Invoke function @ times and return array of results | ||
* Alternatives: | ||
* http://underscorejs.org/#times | ||
* http://sugarjs.com/api/Number/times | ||
* http://api.prototypejs.org/language/Number/prototype/times/ | ||
* http://mootools.net/docs/core/Types/Number#Number:times | ||
*/ | ||
times: function(fn /* = -> it */, that /* = undefined */){ | ||
var number = toLength(this) | ||
, result = Array(number) | ||
, i = 0; | ||
if(isFunction(fn))while(number > i)result[i] = fn.call(that, i, i++, this); | ||
else while(number > i)result[i] = i++; | ||
return result; | ||
}, | ||
times: function(fn, that /* = undefined */){ | ||
var i = 0, num = this | 0, result = Array(num); | ||
if(isFunction(fn))while(num > i)result[i] = fn.call(that, i, i++, this); | ||
return result | ||
}, | ||
random: function(number /* = 0 */){ | ||
var a = this || 0 | ||
, b = number || 0 | ||
var a = +this || 0 | ||
, b = +number || 0 | ||
, m = min(a, b); | ||
return random() * (max(a, b) - m) + m | ||
}, | ||
rand: function(number /* = 0 */){ | ||
var a = toInt(this) | ||
, b = toInt(number) | ||
, m = min(a, b); | ||
return floor((random() * (max(a, b) + 1 - m)) + m) | ||
}, | ||
isOdd: function(){ | ||
return !!(this % 2) && !(this % 1) | ||
}, | ||
isEven: function(){ | ||
return 0 === this % 2 | ||
}, | ||
format: function(afterDot /* = 0 */, thousandsSeparator /* = '' */, decimalMark /* = '.' */){ | ||
var afterDot = toLength(afterDot) | ||
, integer = String(toInt(this)) | ||
, fractional = leadZero(toInt(abs(Math.round((this - integer) * pow(10, afterDot)))), afterDot); | ||
if(thousandsSeparator){ | ||
integer = integer .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + thousandsSeparator); | ||
fractional = fractional.replace(/(\d{3})(?=\d)/g, '$1' + thousandsSeparator); | ||
} | ||
return afterDot ? integer + (decimalMark == undefined ? '.' : decimalMark) + fractional : integer; | ||
return random() * (max(a, b) - m) + m; | ||
} | ||
}); | ||
extendBuiltInObject($Number, reduceTo.call( | ||
// IE... | ||
// getOwnPropertyNames(Math), | ||
splitComma( | ||
$define(STATIC, 'Math', { | ||
/** | ||
* Alternatives: | ||
* http://underscorejs.org/#random | ||
* http://mootools.net/docs/core/Types/Number#Number:Number-random | ||
*/ | ||
randomInt: function(a /* = 0 */, b /* = 0 */){ | ||
a = toInteger(a); | ||
b = toInteger(b); | ||
var m = min(a, b); | ||
return floor((random() * (max(a, b) + 1 - m)) + m); | ||
} | ||
}); | ||
/** | ||
* Math functions in Number.prototype | ||
* Alternatives: | ||
* http://sugarjs.com/api/Number/math | ||
* http://mootools.net/docs/core/Types/Number#Number-Math | ||
*/ | ||
$define(PROTO, NUMBER, transform.call( | ||
// IE... getOwnPropertyNames(Math) | ||
array( | ||
// ES3 | ||
'round,floor,ceil,abs,sin,asin,cos,acos,tan,atan,exp,pow,sqrt,max,min,pow,atan2,' + | ||
'round,floor,ceil,abs,sin,asin,cos,acos,tan,atan,exp,sqrt,max,min,pow,atan2,' + | ||
// ES6 | ||
'acosh,asinh,atanh,cbrt,cosh,expm1,hypot,imul,log1p,log10,log2,sign,sinh,tanh,trunc' | ||
'acosh,asinh,atanh,cbrt,clz32,cosh,expm1,hypot,imul,log1p,log10,log2,sign,sinh,tanh,trunc,' + | ||
// Core.js | ||
'randomInt' | ||
), | ||
function(key){ | ||
if(key in Math)this[key] = methodize.call(Math[key]); | ||
} | ||
function(memo, key){ | ||
if(key in Math)memo[key] = (function(fn){ | ||
return function(/*...args*/){ | ||
// ie8- convert `this` to object -> convert it to number | ||
var args = [+this] | ||
, i = 0; | ||
while(arguments.length > i)args.push(arguments[i++]); | ||
return fn.apply(undefined, args); | ||
} | ||
})(Math[key]) | ||
}, {} | ||
)); |
@@ -1,332 +0,68 @@ | ||
!function(){ | ||
function merge(target, source, deep /* = false */, reverse /* = false */, desc /* = false */, stackA, stackB){ | ||
if(isObject(target) && isObject(source)){ | ||
var isComp = isFunction(reverse) | ||
, names = (desc ? getOwnPropertyNames : keys)(source) | ||
, length = names.length | ||
, i = 0 | ||
, key, targetDescriptor, sourceDescriptor; | ||
while(length > i){ | ||
key = names[i++]; | ||
if(has(target, key) && (isComp ? reverse(target[key], source[key]) : reverse)){// if key in target && reverse merge | ||
deep && merge(target[key], source[key], 1, reverse, desc, stackA, stackB) // if not deep - skip | ||
} | ||
else if(desc){ | ||
targetDescriptor = getOwnPropertyDescriptor(target, key) || $Object; | ||
if(targetDescriptor.configurable !== false && delete target[key]){ | ||
sourceDescriptor = getOwnPropertyDescriptor(source, key); | ||
if(deep && !sourceDescriptor.get && !sourceDescriptor.set){ | ||
sourceDescriptor.value = | ||
merge(clone(sourceDescriptor.value, 1, 1, stackA, stackB), | ||
targetDescriptor.value, 1, 1, 1, stackA, stackB); | ||
} | ||
defineProperty(target, key, sourceDescriptor) | ||
} | ||
} | ||
else target[key] = deep | ||
? merge(clone(source[key], 1, 0, stackA, stackB), target[key], 1, 1, 0, stackA, stackB) | ||
: source[key] | ||
} | ||
} | ||
return target | ||
} | ||
$define(STATIC, OBJECT, { | ||
/** | ||
* http://wiki.ecmascript.org/doku.php?id=strawman:structured_clone | ||
* https://github.com/dslomov-chromium/ecmascript-structured-clone | ||
* Alternatives: | ||
* http://underscorejs.org/#has | ||
* http://sugarjs.com/api/Object/has | ||
*/ | ||
function clone(object, deep /* = false */, desc /* = false */, stackA, stackB){ | ||
if(!isObject(object))return object; | ||
stackA || (stackA = []); | ||
stackB || (stackB = []); | ||
var already = stackA[indexOf](object) | ||
, F = object.constructor | ||
, result; | ||
if(~already)return stackB[already]; | ||
switch(classof(object)){ | ||
case 'Arguments' : | ||
case 'Array' : | ||
result = Array(object.length); | ||
break; | ||
case 'Function' : | ||
return object; | ||
case 'RegExp' : | ||
result = RegExp(object.source, getRegExpFlags.call(object)); | ||
break; | ||
case 'String' : | ||
return new F(object); | ||
case 'Boolean' : | ||
case 'Date' : | ||
case 'Number' : | ||
result = new F(object.valueOf()); | ||
break; | ||
/* | ||
case 'Set' : | ||
result = new F; | ||
object.forEach(result.add, result); | ||
break; | ||
case 'Map' : | ||
result = new F; | ||
object.forEach(function(val, key){ | ||
result.set(key, val); | ||
}); | ||
break; | ||
*/ | ||
default: | ||
result = create(getPrototypeOf(object)) | ||
} | ||
stackA.push(object); | ||
stackB.push(result); | ||
return merge(result, object, deep, 0, desc, stackA, stackB) | ||
} | ||
function make(proto, props, simple /* = false */){ | ||
return props ? (simple ? assign : mixin)(create(proto), props) : create(proto) | ||
} | ||
// Objects deep compare | ||
function deepEqual(a, b, StackA, StackB){ | ||
if(same(a, b))return true; | ||
var type = classof(a) | ||
, length, keys, val; | ||
if( | ||
!isObject(a) || !isObject(b) | ||
|| type != classof(b) | ||
|| getPrototypeOf(a) != getPrototypeOf(b) | ||
)return false; | ||
StackA = isArray(StackA) ? StackA.concat([a]) : [a]; | ||
StackB = isArray(StackB) ? StackB.concat([b]) : [b]; | ||
switch(type){ | ||
case'Boolean' : | ||
case'String' : | ||
case'Number' : return a.valueOf() == b.valueOf(); | ||
case'RegExp' : return String(a) == String(b); | ||
case'Error' : return a.message == b.message;/* | ||
case'Array' : | ||
case'Arguments' : | ||
length = toLength(a.length); | ||
if(length != b.length)return false; | ||
while(length--){ | ||
if( | ||
!(~StackA[indexOf](a[length]) && ~StackB[indexOf](b[length])) | ||
&& !deepEqual(a[length], b[length], StackA, StackB) | ||
)return false; | ||
} | ||
return true*/ | ||
} | ||
keys = getOwnPropertyNames(a); | ||
length = keys.length; | ||
if(length != getOwnPropertyNames(b).length)return false; | ||
while(length--){ | ||
if( | ||
!(~StackA[indexOf](a[val = keys[length]]) && ~StackB[indexOf](b[val])) | ||
&& !deepEqual(a[val], b[val], StackA, StackB) | ||
)return false | ||
} | ||
return true | ||
} | ||
function forOwnKeys(object, fn, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, props = keys(O) | ||
, length = props.length | ||
isEnumerable: unbind(isEnumerable), | ||
isPrototype: unbind($Object.isPrototypeOf), | ||
// http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
getPropertyDescriptor: getPropertyDescriptor, | ||
// http://wiki.ecmascript.org/doku.php?id=strawman:extended_object_api | ||
// ES7 : http://esdiscuss.org/topic/april-8-2014-meeting-notes#content-1 | ||
getOwnPropertyDescriptors: getOwnPropertyDescriptors, | ||
/** | ||
* Shugar for Object.create | ||
* Alternatives: | ||
* http://lodash.com/docs#create | ||
*/ | ||
make: function(proto, props){ | ||
return props == undefined ? create(proto) : create(proto, getOwnPropertyDescriptors(props)); | ||
}, | ||
/** | ||
* 19.1.3.15 Object.mixin ( target, source ) | ||
* Removed in Draft Rev 22, January 20, 2014 | ||
* http://esdiscuss.org/topic/november-19-2013-meeting-notes#content-1 | ||
*/ | ||
define: function(target, source){ | ||
return defineProperties(target, getOwnPropertyDescriptors(source)); | ||
}, | ||
// ~ ES7 : http://esdiscuss.org/topic/april-8-2014-meeting-notes#content-1 | ||
values: function(object){ | ||
var O = ES5Object(object) | ||
, names = keys(object) | ||
, length = names.length | ||
, i = 0 | ||
, key; | ||
while(length > i)fn.call(that, O[key = props[i++]], key, object); | ||
return object | ||
} | ||
function findIndex(object, fn, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, props = keys(O) | ||
, length = props.length | ||
, result = Array(length); | ||
while(length > i)result[i] = O[names[i++]]; | ||
return result; | ||
}, | ||
// ~ ES7 : http://esdiscuss.org/topic/april-8-2014-meeting-notes#content-1 | ||
entries: function(object){ | ||
var O = ES5Object(object) | ||
, names = keys(object) | ||
, length = names.length | ||
, i = 0 | ||
, result = Array(length) | ||
, key; | ||
while(length > i){ | ||
if(fn.call(that, O[key = props[i++]], key, object))return key | ||
} | ||
} | ||
extendBuiltInObject(Object, { | ||
has: has, | ||
isEnumerable: isEnumerable, | ||
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 : | ||
// http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
getPropertyDescriptor: getPropertyDescriptor, | ||
// http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api | ||
getOwnPropertyDescriptors: getOwnPropertyDescriptors, | ||
// http://wiki.ecmascript.org/doku.php?id=strawman:extended_object_api | ||
getPropertyDescriptors: function(object){ | ||
var result = getOwnPropertyDescriptors(object) | ||
, i, length, names, key; | ||
while(object = getPrototypeOf(object)){ | ||
names = getOwnPropertyNames(object); | ||
i = 0; | ||
length = names.length; | ||
while(length > i){ | ||
if(!has(result, key = names[i++])){ | ||
result[key] = getOwnPropertyDescriptor(object, key); | ||
} | ||
} | ||
} | ||
return result | ||
}, | ||
// http://wiki.ecmascript.org/doku.php?id=strawman:extended_object_api | ||
getPropertyNames: function(object){ | ||
var result = getOwnPropertyNames(object) | ||
, i, length, names, key; | ||
while(object = getPrototypeOf(object)){ | ||
i = 0; | ||
names = getOwnPropertyNames(object); | ||
length = names.length; | ||
while(length > i)~result[indexOf](key = names[i++]) || result.push(key) | ||
} | ||
return result | ||
}, | ||
// Shugar for Object.create | ||
make: make, | ||
// Shugar for Object.make(null[, props, simple]) | ||
plane: function(props, simple /* = false */){ | ||
return make(null, props, simple) | ||
}, | ||
clone: clone, | ||
merge: merge, | ||
// Shugar for Object.merge(target, props, 1, 1) | ||
defaults: function(target, props){ | ||
return merge(target, props, 1, 1) | ||
}, | ||
// {a: b} -> [b] | ||
values: function(object){ | ||
var props = keys(object) | ||
, length = props.length | ||
, result = Array(length) | ||
, i = 0; | ||
while(length > i)result[i] = object[props[i++]]; | ||
return result | ||
}, | ||
// {a: b} -> {b: a} | ||
invert: invert, | ||
// Enumerable | ||
every: function(object, fn, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, props = keys(O) | ||
, length = props.length | ||
, i = 0 | ||
, key; | ||
while(length > i){ | ||
if(!fn.call(that, O[key = props[i++]], key, object))return false; | ||
} | ||
return true | ||
}, | ||
filter: function(object, fn, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, result = {} | ||
, props = keys(O) | ||
, length = props.length | ||
, i = 0 | ||
, key; | ||
while(length > i){ | ||
if(fn.call(that, O[key = props[i++]], key, object))result[key] = O[key]; | ||
} | ||
return result | ||
}, | ||
find: function(object, fn, that /* = undefined */){ | ||
var index = findIndex(object, fn, that); | ||
return index === undefined ? undefined : object[index]; | ||
}, | ||
findIndex: findIndex, | ||
forEach: forOwnKeys, | ||
indexOf: function(object, searchElement){ | ||
var O = arrayLikeSelf(object) | ||
, props = keys(O) | ||
, length = props.length | ||
, i = 0 | ||
, key; | ||
while(length > i)if(same(O[key = props[i++]],searchElement))return key | ||
}, | ||
map: function(object, fn, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, result = {} | ||
, props = keys(O) | ||
, length = props.length | ||
, i = 0 | ||
, key; | ||
while(length > i){ | ||
result[key = props[i++]] = fn.call(that, O[key], key, object); | ||
} | ||
return result | ||
}, | ||
reduce: function(object, fn, result /* = undefined */, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, props = keys(O) | ||
, i = 0 | ||
, length = props.length | ||
, key; | ||
if(arguments.length < 3){ | ||
if(!length--)throw TypeError(REDUCE_ERROR); | ||
result = O[props.shift()]; | ||
} | ||
while(length > i){ | ||
result = fn.call(that, result, O[key = props[i++]], key, object); | ||
} | ||
return result | ||
}, | ||
some: function(object, fn, that /* = undefined */){ | ||
var O = arrayLikeSelf(object) | ||
, props = keys(O) | ||
, length = props.length | ||
, i = 0 | ||
, key; | ||
while(length > i){ | ||
if(fn.call(that, O[key = props[i++]], key, object))return true; | ||
} | ||
return false | ||
}, | ||
props: function(object, prop){ | ||
object = arrayLikeSelf(object); | ||
var names = keys(object) | ||
, result = {} | ||
, length = names.length | ||
, i = 0 | ||
, key, val; | ||
while(length > i){ | ||
key = names[i++]; | ||
val = object[key]; | ||
result[key] = val == undefined ? undefined : val[prop] | ||
} | ||
return result | ||
}, | ||
reduceTo: function(object, fn, target){ | ||
target = Object(target); | ||
forOwnKeys(object, fn, target); | ||
return target; | ||
}, | ||
deepEqual: deepEqual, | ||
isObject: isObject, | ||
isUndefined: function(it){ | ||
return it === undefined | ||
}, | ||
isNull : function(it){ | ||
return it === null | ||
}, | ||
isNumber : function(it){ | ||
return toString(it) == '[object Number]' | ||
}, | ||
isString : isString, | ||
isBoolean : function(it){ | ||
return it === !!it || toString(it) == '[object Boolean]' | ||
}, | ||
isArray : isArray, | ||
isFunction : isFunction, | ||
isRegExp : function(it){ | ||
return toString(it) == '[object RegExp]' | ||
}, | ||
isDate : function(it){ | ||
return toString(it) == '[object Date]' | ||
}, | ||
isError : function(it){ | ||
return toString(it) == '[object Error]' | ||
} | ||
}); | ||
}(); | ||
while(length > i)result[i] = [key = names[i++], O[key]]; | ||
return result; | ||
}, | ||
/** | ||
* Alternatives: | ||
* http://underscorejs.org/#isObject | ||
* http://sugarjs.com/api/Object/isType | ||
* http://docs.angularjs.org/api/angular.isObject | ||
*/ | ||
isObject: isObject, | ||
/** | ||
* Alternatives: | ||
* http://livescript.net/#operators -> typeof! | ||
* http://mootools.net/docs/core/Core/Core#Core:typeOf | ||
* http://api.jquery.com/jQuery.type/ | ||
*/ | ||
classof: classof, | ||
// Simple symbol API | ||
symbol: symbol, | ||
hidden: hidden | ||
}); |
@@ -1,4 +0,14 @@ | ||
extendBuiltInObject(RegExp[prototype], { | ||
fn: RegExpToFunction, | ||
getFlags: getRegExpFlags | ||
}); | ||
!function(escape){ | ||
/** | ||
* https://gist.github.com/kangax/9698100 | ||
* Alternatives: | ||
* http://sugarjs.com/api/String/escapeRegExp | ||
* http://api.prototypejs.org/language/RegExp/escape/ | ||
* http://mootools.net/docs/core/Types/String#String:escapeRegExp | ||
*/ | ||
$define(STATIC, REGEXP, { | ||
escape: function(it){ | ||
return String(it).replace(escape, '\\$1'); | ||
} | ||
}); | ||
}(/([\\\-[\]{}()*+?.,^$|])/g); |
!function(){ | ||
var LTrimRegExp = RegExp(LTrim) | ||
, RTrimRegExp = RegExp(RTrim) | ||
, dictionaryEscapeHTML = { | ||
var escapeHTMLDict = { | ||
'&': '&', | ||
@@ -9,45 +7,33 @@ '<': '<', | ||
'"': '"', | ||
"'": ''', | ||
'/': '/' | ||
"'": ''' | ||
} | ||
, dictionaryUnescapeHTML = invert(dictionaryEscapeHTML) | ||
, RegExpEscapeHTML = RegExp('[' + keys(dictionaryEscapeHTML).join('') + ']', 'g') | ||
, RegExpUnescapeHTML = RegExp('(' + keys(dictionaryUnescapeHTML).join('|') + ')', 'g') | ||
, RegExpEscapeRegExp = /([\\\/'*+?|()\[\]{}.^$])/g; | ||
extendBuiltInObject($String, { | ||
// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/trimLeft | ||
trimLeft: function(){ | ||
return String(this).replace(LTrimRegExp, '') | ||
}, | ||
// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/trimRight | ||
trimRight: function(){ | ||
return String(this).replace(RTrimRegExp, '') | ||
}, | ||
, unescapeHTMLDict = transform.call(keys(escapeHTMLDict), function(memo, key){ | ||
memo[escapeHTMLDict[key]] = key; | ||
}, {}) | ||
, RegExpEscapeHTML = /[&<>"']/g | ||
, RegExpUnescapeHTML = /&(?:amp|lt|gt|quot|apos);/g; | ||
$define(PROTO, STRING, { | ||
/** | ||
* Alternatives: | ||
* http://underscorejs.org/#escape | ||
* http://sugarjs.com/api/String/escapeHTML | ||
* http://api.prototypejs.org/language/String/prototype/escapeHTML/ | ||
*/ | ||
escapeHTML: function(){ | ||
return String(this).replace(RegExpEscapeHTML, function(part){ | ||
return dictionaryEscapeHTML[part]; | ||
}) | ||
return escapeHTMLDict[part]; | ||
}); | ||
}, | ||
/** | ||
* Alternatives: | ||
* http://underscorejs.org/#unescape | ||
* http://sugarjs.com/api/String/unescapeHTML | ||
* http://api.prototypejs.org/language/String/prototype/unescapeHTML/ | ||
*/ | ||
unescapeHTML: function(){ | ||
return String(this).replace(RegExpUnescapeHTML, function(part, key){ | ||
return dictionaryUnescapeHTML[key]; | ||
}) | ||
}, | ||
escapeURL: function(component /* = false */){ | ||
return (component ? encodeURIComponent : encodeURI)(this) | ||
}, | ||
unescapeURL: function(component /* = false */){ | ||
return (component ? decodeURIComponent : decodeURI)(this) | ||
}, | ||
escapeRegExp: function(){ | ||
return String(this).replace(RegExpEscapeRegExp, '\\$1') | ||
}, | ||
reverse: function(){ | ||
return String(this).split('').reverse().join('') | ||
}, | ||
at: function(index){ | ||
var that = String(this); | ||
return that.charAt(index < 0 ? that.length + index : index) | ||
return String(this).replace(RegExpUnescapeHTML, function(part){ | ||
return unescapeHTMLDict[part]; | ||
}); | ||
} | ||
}); | ||
}(); |
@@ -1,54 +0,21 @@ | ||
!function(navigator, setTimeout, setInterval, postMessage, setImmediate, clearImmediate, addEventListener){ | ||
function timersBind(fn, args){ | ||
return part.apply(isFunction(fn) ? fn : Function(fn), args); | ||
/** | ||
* ie9- setTimeout & setInterval additional parameters fix | ||
* http://www.w3.org/TR/html5/webappapis.html#timers | ||
* http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#timers | ||
* Alternatives: | ||
* https://developer.mozilla.org/ru/docs/Web/API/Window.setTimeout#IE_Only_Fix | ||
*/ | ||
!function(navigator){ | ||
function wrap(set){ | ||
return function(fn, time /*, ...args*/){ | ||
return set(part.apply(isFunction(fn) ? fn : Function(fn), $slice(arguments, 2)), time || 1); | ||
} | ||
} | ||
/** | ||
* ie9- setTimeout & setInterval additional parameters fix | ||
* on ie8- work only as (global|window).setTimeout, instead of setTimeout | ||
* http://www.w3.org/TR/html5/webappapis.html#timers | ||
* http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#timers | ||
*/ | ||
// ie9- dirty check | ||
if(navigator && /MSIE .\./.test(navigator.userAgent)){ | ||
global.setTimeout = function(fn, time /*, args...*/){ | ||
return setTimeout(timersBind(fn, slice.call(arguments, 2)), time || 1) | ||
}; | ||
global.setInterval = function(fn, time /*, args...*/){ | ||
return setInterval(timersBind(fn, slice.call(arguments, 2)), time || 1) | ||
} | ||
setTimeout = wrap(setTimeout); | ||
setInterval = wrap(setInterval); | ||
} | ||
/** | ||
* setImmediate | ||
* https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/setImmediate/Overview.html | ||
*/ | ||
if(!isFunction(global[setImmediate]) || !isFunction(global[clearImmediate])){ | ||
if(isFunction(postMessage)){ | ||
var msg = setImmediate + random() | ||
, counter = 0 | ||
, queue = {} | ||
, listner = function(event){ | ||
var id = event.data; | ||
if(id in queue){ | ||
queue[id](); | ||
delete queue[id] | ||
} | ||
} | ||
global[setImmediate] = function(fn /*, args...*/){ | ||
var id = ++counter + msg; | ||
queue[id] = timersBind(fn, slice1(arguments)); | ||
postMessage(id, '*'); | ||
return counter | ||
} | ||
global[clearImmediate] = function(id){ | ||
delete queue[id + msg] | ||
} | ||
if(addEventListener)addEventListener('message', listner, false); | ||
else attachEvent('onmessage', listner) | ||
} | ||
else { | ||
global[setImmediate] = function(fn /*, args...*/){ | ||
return setTimeout(timersBind(fn, slice1(arguments)), 1) | ||
} | ||
global[clearImmediate] = Function('i','clearTimeout(i)') | ||
} | ||
} | ||
}(global.navigator, setTimeout, setInterval, global.postMessage, 'setImmediate', 'clearImmediate', global.addEventListener); | ||
$defineTimer('setTimeout', setTimeout); | ||
$defineTimer('setInterval', setInterval); | ||
}(global.navigator); |
@@ -0,0 +0,0 @@ // Karma configuration |
@@ -0,0 +0,0 @@ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 |
/*global describe, specify, it, assert */ | ||
function isNative(fn){ | ||
return /^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/.test(fn); | ||
} | ||
var local = (typeof global === "undefined") ? this : global, | ||
@@ -285,14 +288,15 @@ oldSetTimeout, newSetTimeout; | ||
it('throws when not passed an array', function() { | ||
assert.throws(function () { | ||
var all = Promise.all(); | ||
}, TypeError); | ||
assert.throws(function () { | ||
var all = Promise.all(''); | ||
}, TypeError); | ||
assert.throws(function () { | ||
var all = Promise.all({}); | ||
}, TypeError); | ||
it('rejects when not passed an array', function() { | ||
Promise.all().then(function(){ | ||
assert(false, 'should not fulfill'); | ||
}, function(actualReason){ | ||
assert.equal(reason, undefined); | ||
}); | ||
var O ={} | ||
Promise.all(O).then(function(){ | ||
assert(false, 'should not fulfill'); | ||
}, function(actualReason){ | ||
assert.equal(reason, O); | ||
}); | ||
}); | ||
@@ -446,14 +450,15 @@ | ||
it("throws when not passed an array", function() { | ||
assert.throws(function () { | ||
var race = Promise.race(); | ||
}, TypeError); | ||
assert.throws(function () { | ||
var race = Promise.race(''); | ||
}, TypeError); | ||
assert.throws(function () { | ||
var race = Promise.race({}); | ||
}, TypeError); | ||
it("rejects when not passed an array", function() { | ||
Promise.race().then(function(){ | ||
assert(false, 'should not fulfill'); | ||
}, function(actualReason){ | ||
assert.equal(reason, undefined); | ||
}); | ||
var O ={} | ||
Promise.race(O).then(function(){ | ||
assert(false, 'should not fulfill'); | ||
}, function(actualReason){ | ||
assert.equal(reason, O); | ||
}); | ||
}); | ||
@@ -493,15 +498,9 @@ | ||
specify('if one of the promises is not thenable fulfills with it first', function(done) { | ||
var firstResolver, secondResolver, nonPromise = 5; | ||
var first = new Promise(function(resolve, reject) { | ||
resolve(true); | ||
specify('if one of the promises is not thenable', function(done) { | ||
Promise.race([Promise.resolve(1), Promise.resolve(2), 3]).then(function(value) { | ||
assert.equal(value, 1); | ||
done(); | ||
}); | ||
var second = new Promise(function(resolve, reject) { | ||
resolve(false); | ||
}); | ||
Promise.race([first, second, nonPromise]).then(function(value) { | ||
assert.equal(value, 5); | ||
Promise.race([1, Promise.resolve(2), Promise.resolve(3)]).then(function(value) { | ||
assert.equal(value, 1); | ||
done(); | ||
@@ -584,289 +583,6 @@ }); | ||
describe("RSVP.resolve", function(){ | ||
specify("it should exist", function(){ | ||
assert(Promise.resolve); | ||
}); | ||
describe("1. If x is a promise, adopt its state ", function(){ | ||
specify("1.1 If x is pending, promise must remain pending until x is fulfilled or rejected.", function(done){ | ||
var expectedValue, resolver, thenable, wrapped; | ||
expectedValue = 'the value'; | ||
thenable = { | ||
then: function(resolve, reject){ | ||
resolver = resolve; | ||
} | ||
}; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(value){ | ||
assert(value === expectedValue); | ||
done(); | ||
}); | ||
resolver(expectedValue); | ||
}); | ||
specify("1.2 If/when x is fulfilled, fulfill promise with the same value.", function(done){ | ||
var expectedValue, thenable, wrapped; | ||
expectedValue = 'the value'; | ||
thenable = { | ||
then: function(resolve, reject){ | ||
resolve(expectedValue); | ||
} | ||
}; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(value){ | ||
assert(value === expectedValue); | ||
done(); | ||
}) | ||
}); | ||
specify("1.3 If/when x is rejected, reject promise with the same reason.", function(done){ | ||
var expectedError, thenable, wrapped; | ||
expectedError = new Error(); | ||
thenable = { | ||
then: function(resolve, reject){ | ||
reject(expectedError); | ||
} | ||
}; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(null, function(error){ | ||
assert(error === expectedError); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("2. Otherwise, if x is an object or function,", function(){ | ||
specify("2.1 Let then x.then", function(done){ | ||
var accessCount, resolver, wrapped, thenable; | ||
accessCount = 0; | ||
thenable = { }; | ||
// we likely don't need to test this, if the browser doesn't support it | ||
if (typeof Object.defineProperty !== "function") { done(); return; } | ||
Object.defineProperty(thenable, 'then', { | ||
get: function(){ | ||
accessCount++; | ||
return function(){ }; | ||
} | ||
}); | ||
assert(accessCount === 0); | ||
wrapped = Promise.resolve(thenable); | ||
assert(accessCount > 0); | ||
done(); | ||
}); | ||
specify("2.2 If retrieving the property x.then results in a thrown exception e, reject promise with e as the reason.", function(done){ | ||
var wrapped, thenable, expectedError; | ||
expectedError = new Error(); | ||
thenable = { }; | ||
// we likely don't need to test this, if the browser doesn't support it | ||
if (typeof Object.defineProperty !== "function") { done(); return; } | ||
Object.defineProperty(thenable, 'then', { | ||
get: function(){ | ||
throw expectedError; | ||
} | ||
}); | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(null, function(error){ | ||
assert(error === expectedError, 'incorrect exception was thrown'); | ||
done(); | ||
}); | ||
}); | ||
describe('2.3. If then is a function, call it with x as this, first argument resolvePromise, and second argument rejectPromise, where', function(){ | ||
specify('2.3.1 If/when resolvePromise is called with a value y, run Resolve(promise, y)', function(done){ | ||
var expectedSuccess, resolver, rejector, thenable, wrapped, calledThis; | ||
thenable = { | ||
then: function(resolve, reject){ | ||
calledThis = this; | ||
resolver = resolve; | ||
rejector = reject; | ||
} | ||
}; | ||
expectedSuccess = 'success'; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(success){ | ||
assert(calledThis === thenable, 'this must be the thenable'); | ||
assert(success === expectedSuccess, 'rejected promise with x'); | ||
done(); | ||
}); | ||
resolver(expectedSuccess); | ||
}); | ||
specify('2.3.2 If/when rejectPromise is called with a reason r, reject promise with r.', function(done){ | ||
var expectedError, resolver, rejector, thenable, wrapped, calledThis, | ||
thenable = { | ||
then: function(resolve, reject){ | ||
calledThis = this; | ||
resolver = resolve; | ||
rejector = reject; | ||
} | ||
}; | ||
expectedError = new Error(); | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(null, function(error){ | ||
assert(error === expectedError, 'rejected promise with x'); | ||
done(); | ||
}); | ||
rejector(expectedError); | ||
}); | ||
specify("2.3.3 If both resolvePromise and rejectPromise are called, or multiple calls to the same argument are made, the first call takes precedence, and any further calls are ignored", function(done){ | ||
var expectedError, expectedSuccess, resolver, rejector, thenable, wrapped, calledThis, | ||
calledRejected, calledResolved; | ||
calledRejected = 0; | ||
calledResolved = 0; | ||
thenable = { | ||
then: function(resolve, reject){ | ||
calledThis = this; | ||
resolver = resolve; | ||
rejector = reject; | ||
} | ||
}; | ||
expectedError = new Error(); | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(){ | ||
calledResolved++; | ||
}, function(error){ | ||
calledRejected++; | ||
assert(calledResolved === 0, 'never resolved'); | ||
assert(calledRejected === 1, 'rejected only once'); | ||
assert(error === expectedError, 'rejected promise with x'); | ||
}); | ||
rejector(expectedError); | ||
rejector(expectedError); | ||
rejector('foo'); | ||
resolver('bar'); | ||
resolver('baz'); | ||
setTimeout(function(){ | ||
assert(calledRejected === 1, 'only rejected once'); | ||
assert(calledResolved === 0, 'never resolved'); | ||
done(); | ||
}, 50); | ||
}); | ||
describe("2.3.4 If calling then throws an exception e", function(){ | ||
specify("2.3.4.1 If resolvePromise or rejectPromise have been called, ignore it.", function(done){ | ||
var expectedSuccess, resolver, rejector, thenable, wrapped, calledThis, | ||
calledRejected, calledResolved; | ||
expectedSuccess = 'success'; | ||
thenable = { | ||
then: function(resolve, reject){ | ||
resolve(expectedSuccess); | ||
throw expectedError; | ||
} | ||
}; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(success){ | ||
assert(success === expectedSuccess, 'resolved not errored'); | ||
done(); | ||
}); | ||
}); | ||
specify("2.3.4.2 Otherwise, reject promise with e as the reason.", function(done) { | ||
var expectedError, resolver, rejector, thenable, wrapped, calledThis, callCount; | ||
expectedError = new Error(); | ||
callCount = 0; | ||
thenable = { then: function() { throw expectedError; } }; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(null, function(error){ | ||
callCount++; | ||
assert(expectedError === error, 'expected the correct error to be rejected'); | ||
done(); | ||
}); | ||
assert(callCount === 0, 'expected async, was sync'); | ||
}); | ||
}); | ||
}); | ||
specify("2.4 If then is not a function, fulfill promise with x", function(done){ | ||
var expectedError, resolver, rejector, thenable, wrapped, calledThis, callCount; | ||
thenable = { then: 3 }; | ||
callCount = 0; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(success){ | ||
callCount++; | ||
assert(thenable === success, 'fulfilled promise with x'); | ||
done(); | ||
}); | ||
assert(callCount === 0, 'expected async, was sync'); | ||
}); | ||
}); | ||
describe("3. If x is not an object or function, ", function(){ | ||
specify("fulfill promise with x.", function(done){ | ||
var thenable, callCount, wrapped; | ||
thenable = null; | ||
callCount = 0; | ||
wrapped = Promise.resolve(thenable); | ||
wrapped.then(function(success){ | ||
callCount++; | ||
assert(success === thenable, 'fulfilled promise with x'); | ||
done(); | ||
}, function(a){ | ||
assert(false, 'should not also reject'); | ||
}); | ||
assert(callCount === 0, 'expected async, was sync'); | ||
}); | ||
}); | ||
}); | ||
describe("Promise.cast", function () { | ||
describe("Promise.resolve", function () { | ||
it("If SameValue(constructor, C) is true, return x.", function(){ | ||
var promise = Promise.resolve(1); | ||
var casted = Promise.cast(promise); | ||
var casted = Promise.resolve(promise); | ||
@@ -878,3 +594,3 @@ assert.deepEqual(casted, promise); | ||
var promise = { then: function() { } }; | ||
var casted = Promise.cast(promise); | ||
var casted = Promise.resolve(promise); | ||
@@ -885,27 +601,5 @@ assert(casted instanceof Promise); | ||
it("If SameValue(constructor, C) is false, and isPromiseSubClass(C) is true, return PromiseResolve(promise, x).", function(done) { | ||
function PromiseSubclass() { | ||
Promise.apply(this, arguments); | ||
} | ||
PromiseSubclass.prototype = Object.create(Promise.prototype); | ||
PromiseSubclass.prototype.constructor = PromiseSubclass; | ||
PromiseSubclass.cast = Promise.cast; | ||
var promise = Promise.resolve(1); | ||
var casted = PromiseSubclass.cast(promise); | ||
assert(casted instanceof Promise); | ||
assert(casted instanceof PromiseSubclass); | ||
assert(casted !== promise); | ||
casted.then(function(value) { | ||
assert.equal(value, 1); | ||
done(); | ||
}); | ||
}); | ||
it("If SameValue(constructor, C) is false, and isThenable(C) is false, return PromiseResolve(promise, x).", function(){ | ||
var value = 1; | ||
var casted = Promise.cast(value); | ||
var casted = Promise.resolve(value); | ||
@@ -917,3 +611,3 @@ assert(casted instanceof Promise); | ||
it("casts null correctly", function(done){ | ||
Promise.cast(null).then(function(value){ | ||
Promise.resolve(null).then(function(value){ | ||
assert.equal(value, null); | ||
@@ -920,0 +614,0 @@ done(); |
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 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 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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
689866
67
17109
12