Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

core-js

Package Overview
Dependencies
0
Maintainers
1
Versions
273
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.8

tests/promises_tests_adapter.js

8

core.min.js
/**
* Core.js v0.0.7
* http://core.zloirock.ru
* Core.js 0.0.7
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2014 Denis Pushkarev
* Available under MIT license
*/
!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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"},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);
!function(kb,L,f){"use strict";function tc(a,b){return a===b||a!==a&&b!==b}function z(a){return null!==a&&("object"==typeof a||"function"==typeof a)}function j(a){return"function"==typeof a}function ab(b,c,d){bb&&b&&h(d?b:b[a],bb,c)}function eb(a){return a==f?a===f?"Undefined":"Null":vc.call(a).slice(8,-1)}function tb(b){var a,c=eb(b);return c==C&&bb&&(a=b[bb])&&!~rb.call(uc,a)?a:c}function sb(){for(var a=arguments.length,c=v(a),b=0,d=$._,e=!1;a>b;)(c[b]=arguments[b++])===d&&(e=!0);return _b(this,c,a,e,d,!1)}function _b(a,b,d,c,e,f,g){return w(a),function(){var h,k=f?g:this,l=arguments.length,i=0,j=0;if(!c&&0==l)return u(a,b,k);if(h=b.slice(),c)for(;d>i;i++)h[i]===e&&(h[i]=arguments[j++]);for(;l>j;)h.push(arguments[j++]);return u(a,h,k)}}function g(a,b,c){if(w(a),~c&&b===f)return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)}}return function(){return a.apply(b,arguments)}}function u(b,a,c){var d=c===f;switch(a.length){case 0:return d?b():b.call(c);case 1:return d?b(a[0]):b.call(c,a[0]);case 2:return d?b(a[0],a[1]):b.call(c,a[0],a[1]);case 3:return d?b(a[0],a[1],a[2]):b.call(c,a[0],a[1],a[2]);case 4:return d?b(a[0],a[1],a[2],a[3]):b.call(c,a[0],a[1],a[2],a[3]);case 5:return d?b(a[0],a[1],a[2],a[3],a[4]):b.call(c,a[0],a[1],a[2],a[3],a[4])}return b.apply(c,a)}function e(a,b){return zc.call(a,b)}function Jb(a){return function(d){for(var e,f=k(d),c=y(d),g=c.length,b=0,h=v(g);g>b;)h[b]=a?[e=c[b++],f[e]]:f[c[b++]];return h}}function sc(e,f){for(var a,b=k(e),c=y(b),g=c.length,d=0;g>d;)if(b[a=c[d++]]===f)return a}function Bb(a,f,c){var h,d,b,g,i,k,l=eb(a),j=l==r;if(j||l==C){if(h=rb.call(f,a),~h)return c[h];if(f.push(a),c.push(d=j?v(g=a.length):D(S(a))),j)for(b=0;g>b;)e(a,b)&&(d[b]=Bb(a[b++],f,c));else for(i=y(a),g=i.length,b=0;g>b;)d[k=i[b++]]=Bb(a[k],f,c);return d}return a}function db(a){return X(a).split(",")}function U(a){var c=1==a,e=2==a,h=3==a,b=4==a,d=6==a,j=5==a||d;return function(t,u){for(var m,o,w=g(t,u,3),r=i(this),p=k(r),s=n(p.length),l=0,q=c?v(s):e?[]:f;s>l;l++)if((j||l in p)&&(m=p[l],o=w(m,l,r),a))if(c)q[l]=o;else if(o)switch(a){case 3:return!0;case 5:return m;case 6:return l;case 2:q.push(m)}else if(b)return!1;return d?-1:h||b?b:q}}function gb(b,c){w(b);for(var d=c==f?[]:i(c),e=k(this),g=n(e.length),a=0;g>a&&b(d,e[a],a,this)!==!1;a++);return d}function yb(a,b){return"function"==typeof a?a:b}function n(a){return a>0?H(t(a),Eb):0}function xb(b,a,c){var d=z(a)?function(b){return a[b]}:a;return function(a){return X(c?a:this).replace(b,d)}}function K(c,a,b){if(!c)throw bc(b?a+b:a)}function w(a){return K(j(a),a," is not a function!"),a}function J(a){return K(z(a),a," is not an object!"),a}function Ib(a,b,c){K(a instanceof b,c,": use the 'new' operator!")}function rc(a,b){return{enumerable:!(1&a),configurable:!(2&a),writable:!(4&a),value:b}}function qc(a,b,c){return a[b]=c,a}function pc(a){return lb?function(b,c,d){return hb(b,c,rc(a,d))}:qc}function wb(a){return W+"("+a+")_"+(++wc+Yb())[I](36)}function b(h,k,p){var e,m,b,i,n=h&F,f=n?c:h&l?c[k]:(c[k]||A)[a],q=n?E:E[k]||(E[k]={});n&&(p=k);for(e in p)m=!(h&V)&&f&&e in f&&(!j(f[e])||G(f[e])),b=(m?f:p)[e],h&Sb&&m?i=g(b,c):h&Pb&&!L&&f[e]==b?(i=function(a){return this instanceof b?new b(a):b(a)},i[a]=b[a]):i=h&o&&j(b)?g(N,b):b,m||(b.CORE=i.CORE=!0),q[e]!=b&&(q[e]=i),L&&f&&!m&&(n||delete f[e])&&d(f,e,b)}var bb,c=kb(),C="Object",R="Function",r="Array",M="String",Z="Number",Qb="RegExp",O="Date",Tb="Map",Wb="Set",nc="WeakMap",mc="WeakSet",W="Symbol",ub="Promise",Gb="Math",Kb="Arguments",a="prototype",T="constructor",I="toString",jb="forEach",lc="process",Xb="createElement",mb=c[R],i=c[C],v=c[r],X=c[M],ac=c[Z],jc=c[Qb],Bc=c[O],P=c[Tb],Q=c[Wb],Ab=c[nc],Vb=c[mc],p=c[W],s=c[Gb],bc=c.TypeError,cb=c.setTimeout,Ac=c.clearTimeout,zb=c.setInterval,ob=c.setImmediate,vb=c.clearImmediate,Lb=c[lc],gc=Lb&&Lb.nextTick,ib=c.document,Rb=c.define,x=v[a],A=i[a],Ub=mb[a],fb=1/0,E={},$=L?c:E,fc=i.is||function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b},G=g(/./.test,/\[native code\]\s*\}\s*$/,1),vc=A[I],uc=[Kb,r,"Boolean",O,"Error",R,Z,Qb,M],dc=Ub.apply,N=Ub.call;E._=$._=L?$._||{}:{};var B,q,Mb,kc,Ob,Hb,D=i.create,S=i.getPrototypeOf,hb=i.defineProperty,pb=i.defineProperties,qb=i.getOwnPropertyDescriptor,y=i.keys,Cb=i.getOwnPropertyNames,zc=A.hasOwnProperty,ic=A.propertyIsEnumerable,Fb="__proto__"in A,k=i,Y=i.assign||function(g){for(var a=i(g),h=arguments.length,b=1;h>b;)for(var c,d=k(arguments[b++]),e=y(d),j=e.length,f=0;j>f;)a[c=e[f++]]=d[c];return a},xc=x.push,_=x.slice,yc=x.splice,rb=x.indexOf,Nb=x[jb],cc=s.ceil,Db=s.floor,nb=s.max,H=s.min,ec=s.pow,Yb=s.random,Eb=9007199254740991,t=ac.toInteger||function(a){return(a=+a)!=a?0:0!=a&&a!=fb&&a!=-fb?(a>0?Db:cc)(a):a},hc="Reduce of empty object with no initial value",lb=!!function(){try{return hb({},0,A)}catch(a){}}(),wc=0,d=pc(1),m=p||wb,h=p?qc:d,$b=ib&&ib.documentElement,Zb=eb(Lb)==lc,oc=j(Rb)&&Rb.amd,V=1,F=2,l=4,o=8,Sb=16,Pb=32;E.CORE=!0,Zb&&(module.exports=E),oc&&Rb(function(){return E}),(!Zb&&!oc||L)&&(c.core=E),!function(){function q(a){return function(){return a.apply(k(this),arguments)}}function s(a){return function(g,d){w(g);var c=k(this),e=n(c.length),b=a?e-1:0,f=a?-1:1;if(2>arguments.length)for(;;){if(b in c){d=c[b],b+=f;break}b+=f,K(a?b>=0:e>b,hc)}for(;a?b>=0:e>b;b+=f)b in c&&(d=g(d,c[b],b,this));return d}}var h=mb(),B=tb,E="[ \n \f\r   ᠎              \u2028\u2029]",d=db(I+",toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,"+T),p=d.concat(a,"length"),v=d.length,G=!ic.call({toString:f},I),g=m(a),c=Fb?function(){return{__proto__:null}}:function(){var b,e=ib[Xb]("iframe"),f=v;for(e.style.display="none",$b.appendChild(e),e.src="javascript:",b=e.contentWindow.document,b.open(),b.write("<script>document.F=Object</script>"),b.close(),c=b.F;f--;)delete c[a][d[f]];return c()},F=function(a,b,c){return function(j){var d,h=k(j),i=0,f=[];for(d in h)d!==g&&e(h,d)&&f.push(d);if(G||c)for(;b>i;)e(h,d=a[i++])&&(~rb.call(f,d)||f.push(d));return f}};lb||(qb=function(a,b){return e(a,b)?rc(!ic.call(a,b),a[b]):f},hb=function(a,c,b){return"value"in b&&(J(a)[c]=b.value),a},pb=function(a,d){J(a);for(var b,c,e=y(d),g=e.length,f=0;g>f;)b=e[f++],c=d[b],"value"in c&&(a[b]=c.value);return a}),b(l+V*!lb,C,{getOwnPropertyDescriptor:qb,defineProperty:hb,defineProperties:pb}),b(l,C,{getPrototypeOf:S=S||function(b){return J(b),e(b,g)?b[g]:Fb&&"__proto__"in b?b.__proto__:j(b[T])&&b!=b[T][a]?b[T][a]:b instanceof i?A:null},getOwnPropertyNames:Cb=Cb||F(p,p.length,!0),create:D=D||function(b,d){if(null===b)return d?pb(c(),d):c();h[a]=J(b);var e=new h;return h[a]=null,d&&pb(e,d),Fb||e[T][a]===b||(e[g]=b),e},keys:y=y||F(d,v,!1)}),b(o,R,{bind:function(c){function d(){var d,f,g=e.concat(_.call(arguments));return this instanceof b?z(d=u(f=D(b[a]),g,c))?d:f:dc.call(b,c,g)}var b=w(this),e=_.call(arguments,1);return d[a]=f,d}}),0 in i("q")&&"q"=="q"[0]||(k=function(a){return eb(a)==M?a.split(""):i(a)},_=q(_)),b(o+V*(k!=i),r,{slice:_,join:q(x.join)}),b(l,r,{isArray:function(a){return eb(a)==r}}),b(o,r,{forEach:Nb=Nb||U(0),map:U(1),filter:U(2),some:U(3),every:U(4),reduce:s(!1),reduceRight:s(!0),indexOf:rb=rb||function(d,e){var b=k(this),c=n(b.length),a=t(e);for(0>a&&(a=nb(c+a,0));c>a;a++)if(a in b&&b[a]===d)return a;return-1},lastIndexOf:function(d,e){var b=k(this),c=n(b.length),a=c-1;for(arguments.length>1&&(a=H(a,t(e))),0>a&&(a=n(c+a));a>=0;a--)if(a in b&&b[a]===d)return a;return-1}}),b(o,M,{trim:xb(jc("^"+E+"+|"+E+"+$","g"),"")}),b(l,O,{now:function(){return+new Bc}}),j(/./)&&(j=function(a){return eb(a)==R}),B(function(){return arguments}())==C&&(tb=function(a){var b=B(a);return b==C&&j(a.callee)?Kb:b})}(),b(F,{global:c}),!function(i,f,g,c){G(p)||(p=function(c){K(!(this instanceof p),W+" is not a "+T);var b=wb(c);return hb(A,b,{configurable:!0,set:function(a){d(this,b,a)}}),d(D(p[a]),i,b)},d(p[a],I,function(){return this[i]})),B=f in p?p[f]:wb(W+"."+f),bb=g in p?p[g]:p(W+"."+g),b(F+Pb,{Symbol:p}),b(l,W,{"for":function(a){return e(c,a+="")?c[a]:c[a]=p(a)},iterator:B,keyFor:sb.call(sc,c),toStringTag:bb,pure:m,set:h}),ab(p,W)}(m("tag"),"iterator",I+"Tag",{}),!function(e){function i(a){return 0==(a=+a)||a!=a?a:0>a?-1:1}function m(a){return e(a=+a)&&0!==a?0>a?-m(-a):d(a+j(a*a+1)):a}b(l,C,{assign:Y,is:fc}),Fb&&function(a){var c;try{a({},x)}catch(d){c=!0}b(l,C,{setPrototypeOf:function(d,b){return J(d),K(null===b||z(b),b,": can't set as prototype!"),c?d.__proto__=b:a(d,b),d}})}(g(N,qb(A,"__proto__").set,2)),b(l,Z,{EPSILON:ec(2,-52),isFinite:function(a){return"number"==typeof a&&e(a)},isInteger:function(a){return e(a)&&Db(a)===a},isNaN:function(a){return a!=a},isSafeInteger:function(a){return u(a)&&p(a)<=Eb},MAX_SAFE_INTEGER:Eb,MIN_SAFE_INTEGER:-Eb,parseFloat:parseFloat,parseInt:parseInt});var u=ac.isInteger,p=s.abs,a=s.exp,d=s.log,j=s.sqrt,h=65535;b(l,Gb,{acosh:function(a){return d(a+j(a*a-1))},asinh:m,atanh:function(a){return 0===a?a:.5*d((1+a)/(1-a))},cbrt:function(a){return i(a)*ec(p(a),1/3)},clz32:function(a){return(a>>>=0)?32-a[I](2).length:32},cosh:function(b){return(a(b)+a(-b))/2},expm1:function(b){return fc(b,-0)?-0:b>-1e-6&&1e-6>b?b+b*b/2:a(b)-1},hypot:function(){for(var a,b=0,c=arguments.length;c--;){if(a=+arguments[c],a==fb||a==-fb)return fb;b+=a*a}return j(b)},imul:function(a,b){var e=h&a>>>16,c=h&a,f=h&b>>>16,d=h&b;return 0|c*d+(e*d+c*f<<16>>>0)},log1p:function(a){return a>-1e-8&&1e-8>a?a-a*a/2:d(1+a)},log10:function(a){return d(a)/s.LN10},log2:function(a){return d(a)/s.LN2},sign:i,sinh:function(b){return(b=+b)==-fb||0==b?b:(a(b)-a(-b))/2},tanh:function(b){return e(b=+b)?0==b?b:(a(b)-a(-b))/(a(b)+a(-b)):i(b)},trunc:function(a){return 0==(a=+a)?a:(a>0?Db:cc)(a)}}),ab(s,Gb,!0),b(o,M,{contains:function(a,b){return!!~X(this).indexOf(a,b)},endsWith:function(a,b){var c=this.length,d=n(H(b===f?c:b,c));return a+="",X(this).slice(d-a.length,d)===a},repeat:function(d){var b=""+this,c="",a=t(d);for(K(a>=0,"Count can't be negative");a>0;(a>>>=1)&&(b+=b))1&a&&(c+=b);return c},startsWith:function(a,c){var b=n(H(c,this.length));return a+="",X(this).slice(b,b+a.length)===a}}),b(l,r,{from:function(j,h,l){var i,d,b=k(j),c=new(yb(this,v)),e=h!==f,a=0;if(e&&(d=g(h,l,2)),q&&Mb(b))q(b).of(function(b){c[a]=e?d(b,a):b,a++});else for(i=n(b.length);i>a;a++)c[a]=e?d(b[a],a):b[a];return c.length=a,c},of:function(){for(var a=0,b=arguments.length,c=new(yb(this,v))(b);b>a;)c[a]=arguments[a++];return c.length=b,c}}),b(o,r,{fill:function(e,g,d){var a,c=n(this.length),b=t(g);for(0>b&&(b=nb(b+c,0)),d===f?a=c:(a=t(d),0>a&&(a+=c),a=H(a,c));a>b;)this[b++]=e;return this},find:U(5),findIndex:U(6)}),ab(c.JSON,"JSON",!0)}(isFinite),j(ob)&&j(vb)||function(o){function d(b){if(e(a,b)){var c=a[b];delete a[b],c()}}function n(a){d(a.data)}var b,h,f,k=c.postMessage,l=c.addEventListener,m=c.MessageChannel,i=0,a={};ob=function(c){for(var d=[],e=1;arguments.length>e;)d.push(arguments[e++]);return a[++i]=function(){u(j(c)?c:mb(c),d)},b(i),i},vb=function(b){delete a[b]},Zb?b=function(a){gc(sb.call(d,a))}:l&&j(k)&&!c.importScripts?(b=function(a){k(a,"*")},l("message",n,!1)):j(m)?(h=new m,f=h.port2,h.port1.onmessage=n,b=g(f.postMessage,f,1)):b=ib&&o in ib[Xb]("script")?function(a){$b.appendChild(ib[Xb]("script"))[o]=function(){$b.removeChild(this),d(a)}}:function(a){cb(sb.call(d,a),0)}}("onreadystatechange"),b(F+Sb,{setImmediate:ob,clearImmediate:vb}),!function(c){j(c)&&j(c.resolve)&&function(a){return c.resolve(a)==a}(new c(mb()))||!function(m,i){function k(b){var a;return z(b)&&(a=b.then),j(a)?a:!1}function e(b){var a=b.chain;a.length&&m(function(){for(var c=b.msg,e=1==b.state,d=0;a.length>d;)!function(a){var b,f,d=e?a.ok:a.fail;try{d?(b=d===!0?c:d(c),b===a.P?a.rej(bc(ub+"-chain cycle")):(f=k(b))?f.call(b,a.res,a.rej):a.res(b)):a.rej(c)}catch(g){a.rej(g)}}(a[d++]);a.length=0})}function l(d){var f,c,a=this;if(!a.done){a.done=!0,a=a.def||a;try{(f=k(d))?(c={def:a,done:!1},f.call(d,g(l,c,1),g(b,c,1))):(a.msg=d,a.state=1,e(a))}catch(h){b.call(c||{def:a,done:!1},h)}}}function b(b){var a=this;a.done||(a.done=!0,a=a.def||a,a.msg=b,a.state=2,e(a))}c=function(d){w(d),Ib(this,c,ub);var a={chain:[],state:0,done:!1,msg:f};h(this,i,a);try{d(g(l,a,1),g(b,a,1))}catch(e){b.call(a,e)}},d(c[a],"then",function(c,d){var a={ok:j(c)?c:!0,fail:j(d)?d:!1},f=a.P=new this[T](function(b,c){a.res=w(b),a.rej=w(c)}),b=this[i];return b.chain.push(a),b.state&&e(b),f}),d(c[a],"catch",function(a){return this.then(f,a)}),d(c,"all",function(c){var b=this,a=[];return new b(function(f,g){q(c).of(xc,a);var d=a.length,e=v(d);d?Nb.call(a,function(a,c){b.resolve(a).then(function(a){e[c]=a,--d||f(e)},g)}):f(e)})}),d(c,"race",function(b){var a=this;return new a(function(c,d){q(b).of(function(b){a.resolve(b).then(c,d)})})}),d(c,"reject",function(a){return new this(function(c,b){b(a)})}),d(c,"resolve",function(b){return z(b)&&S(b)===this[a]?b:new this(function(a){a(b)})})}(gc||ob,m("def")),ab(c,ub),b(F+V*!G(c),{Promise:c})}(c[ub]),!function(){function o(c,i,u,t,n,k,s){function p(a,b){return b!=f&&q&&q(b,k).of(a[j],a),a}var j=k?"set":"add",r=n.clear;if(u){var m=c,g={},e=new c([k?[g,1]:g]),v=e[j];B in x&&e.has(g)||(c=function(a){return Ib(this,c,i),p(new m,a)},c[a]=m[a]),L&&e[j](g,1)!==e&&d(c[a],j,function(a,b){return v.call(this,a,b),this})}else c=function(a){Ib(this,c,i),r.call(this),p(this,a)},h(c,Hb,!0),Y(c[a],t,n),s||hb(c[a],"size",{get:function(){return this[l]}});ab(c,i);var o={};return o[i]=c,b(F+Pb+V*!G(c),o),c}function n(a,b){if(!z(a))return("string"==typeof a?"S":"P")+a;if(!e(a,p)){if(!b)return"";h(a,p,++v)}return"O"+a[p]}function t(a){return{clear:function(){h(this,i,D(null)),a==j&&h(this,j,D(null)),h(this,l,0)},"delete":function(e){var b=n(e),c=this[i],d=b in c;return d&&(delete c[b],a==j&&delete this[j][b],this[l]--),d},forEach:function(f,h){for(var b,j=g(f,h,3),k=this[a],c=this[i],d=y(c),l=d.length,e=0;l>e;)b=d[e++],j(k[b],c[b],this)},has:function(a){return n(a)in this[i]}}}function s(a){return e(a,c)||h(a,c,{}),a[c]}function r(a){return z(a)&&e(a,c)&&e(a[c],this[k])}Hb=m("shim");var i=Ob=m("keys"),j=m("values"),p=m("storeId"),c=m("weakData"),k=m("weakId"),l=lb?m("size"):"size",v=0,w=0;P=o(P,Tb,G(P)&&e(P[a],jb),{get:function(a){return this[j][n(a)]},set:function(b,d){var a=n(b,!0),c=this[j];return a in c||(this[i][a]=b,this[l]++),c[a]=d,this}},t(j),!0),Q=o(Q,Wb,G(Q)&&e(Q[a],jb),{add:function(a){var b=n(a,!0),c=this[i];return b in c||(c[b]=a,this[l]++),this}},t(i));var u={clear:function(){h(this,k,w++)},"delete":function(a){return r.call(this,a)&&delete a[c][this[k]]},has:r};Ab=o(Ab,nc,G(Ab)&&e(Ab[a],"clear"),{get:function(a){return z(a)&&e(a,c)?a[c][this[k]]:f},set:function(a,b){return s(J(a))[this[k]]=b,this}},u,!0,!0),Vb=o(Vb,mc,G(Vb),{add:function(a){return s(J(a))[this[k]]=!0,this}},u,!1,!0)}(),!function(s){function p(a,b){return{value:b,done:!!a}}function z(e,f,g,h,i){e[a]={},d(e[a],"next",h),d(e[a],B,kb),C&&d(e[a],s,kb),ab(e,f+" Iterator"),b(o,f,{entries:y(e,n+c),keys:y(e,n),values:y(e,c)}),g&&A(g,f,y(e,i))}function y(a,b){return function(){return new a(this,b)}}function A(f,g,j){var b=f[a],h=e(b,s),c=e(b,B)?b[B]:h?b[s]:j;L&&(!e(b,B)&&d(b,B,c),h?d(S(c.call(new f)),B,kb):C&&d(b,s,c)),i[g]=c,i[g+" Iterator"]=kb}function H(a,b){h(this,l,k(a)),h(this,j,b),h(this,w,0)}function I(c,e){var d,b=this;P[Hb]?d=E(c[Ob]):P[a][jb].call(c,function(b,a){this.push(a)},d=[]),h(b,l,c),h(b,j,e),h(b,w,0),h(b,t,d)}function G(c,d){var b;Q[Hb]?b=E(c[Ob]):Q[a][jb].call(c,function(a){this.push(a)},b=[]),h(this,j,d),h(this,t,b.reverse())}var C=s in x,n=1,c=2,l=m("iterated"),j=m("kind"),w=m("index"),t=m("keys"),D=m("entries"),E=Jb(!1),i={};z(H,r,v,function(){var d,b=this[l],a=this[w]++,e=this[j];return a>=b.length?p(1):(d=e==n?a:e==c?b[a]:[a,b[a]],p(0,d))},c),A(X,M,i[r]),i[Kb]=i[r],z(I,Tb,P,function(){var a,d,b=this,e=b[l],f=b[t],g=b[w]++,h=b[j];return g>=f.length?p(1):(a=f[g],d=h==n?a:h==c?e.get(a):[a,e.get(a)],p(0,d))},n+c),z(G,Wb,Q,function(){var a,b=this[t];return b.length?(a=b.pop(),p(0,this[j]==n+c?[a,a]:a)):p(1)},c),q=function(a,b){return this instanceof q?(h(this,l,a),h(this,D,b),f):new q(a,b)},q[a].of=function(d,e){for(var a,f=kc(this[l]),b=this[D],c=g(d,e,b?2:1);!(a=f.next()).done;)if((b?u(c,a.value):c(a.value))===!1)return},q.isIterable=Mb=function(a){return a!=f&&B in a||e(i,tb(a))},q.getIterator=kc=function(a){return J((a[B]||i[tb(a)]).call(a))},b(F,{$for:q})}("@@iterator"),!function(){function d(a){var b=D(null);return a!=f&&(q&&Mb(a)?q(a,!0).of(function(a,c){b[a]=c}):Y(b,a)),b}function c(a){var c=1==a,e=2==a,h=3==a,b=4==a;return function(o,r,t){for(var i,j,m,u=g(r,t,3),q=k(o),p=y(q),s=p.length,n=0,l=c||e?new(yb(this,d)):f;s>n;)if(i=p[n++],j=q[i],m=u(j,i,o),a)if(c)l[i]=m;else if(m)switch(a){case 3:return!0;case 5:return j;case 6:return i;case 2:l[i]=j}else if(b)return!1;return h||b?b:l}}function h(a){return function(l,m,e){w(m);var b,n,g,h=k(l),j=y(h),o=j.length,c=0;for(a?b=e==f?new(yb(this,d)):i(e):3>arguments.length?(K(o>c,hc),b=h[j[c++]]):b=i(e);o>c;)if(g=m(b,h[n=j[c++]],n,l),a){if(g===!1)break}else b=g;return b}}d[a]=null,Y(d,{forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findKey:c(6),reduce:h(!1),turn:h(!0),keyOf:sc,contains:function(d,e){for(var a=k(d),b=y(a),f=b.length,c=0;f>c;)if(tc(a[b[c++]],e))return!0;return!1},clone:function(a){return Bb(a,[],[])},has:e,get:function(a,b){return e(a,b)?a[b]:f},set:pc(0),isDict:function(b){return S(b)==d[a]}}),b(F,{Dict:d})}(),!function(a){function c(a){return function(b,c){return a(u(sb,_.call(arguments,2),j(b)?b:mb(b)),c||1)}}a&&/MSIE .\./.test(a.userAgent)&&(cb=c(cb),zb=c(zb)),b(F+Sb+V*!G(cb),{setTimeout:cb,setInterval:zb})}(c.navigator),b(o,R,{construct:function(d){var b=D(w(this)[a]),c=u(this,d,b);return z(c)?c:b},invoke:function(a,b){return u(this,a,b)}}),!function(f,c){function e(e,g){function b(a){this[c]=u(e,this[f]=a)}return d(b[a],"set",function(){return g(this[c]),this[c]=u(e,this[f]),this}),d(b[a],"clear",function(){return g(this[c]),this}),function(){for(var a=[w(this)],c=0;arguments.length>c;)a.push(arguments[c++]);return new b(a)}}b(o,R,{timeout:e(cb,Ac),interval:e(zb,clearInterval),immediate:e(ob,vb)})}(m("arguments"),m("id")),!function(c){function e(e){var c,a=this,f=$._,h=!1,b=arguments.length,d=1;if(2>b)return g(a[e],a,-1);for(c=v(b-1);b>d;)(c[d-1]=arguments[d++])===f&&(h=!0);return _b(a[e],c,b,h,f,!0,a)}b(o,R,{part:sb,by:function(e){var f,a=this,h=$._,i=!1,b=arguments.length,c=e===h,d=c?0:1,j=d;if(2>b)return c?g(N,a,-1):g(a,e,-1);for(f=v(b-j);b>d;)(f[d-j]=arguments[d++])===h&&(i=!0);return _b(c?N:a,f,b,i,h,!0,c?a:e)},only:function(a,b){var c=w(this),d=n(a),e=arguments.length>1;return function(){for(var f=H(d,arguments.length),g=v(f),a=0;f>a;)g[a]=arguments[a++];return u(c,g,e?b:this)}},methodize:function(){var a=this;return function(){for(var b=[this],c=0;arguments.length>c;)b.push(arguments[c++]);return u(a,b)}}}),b(l,C,{tie:E.tie=g(N,e)}),d($._,I,function(){return c}),lb&&d(A,c,e),d(Ub,c,e),d(x,c,e),d(jc[a],c,e)}(wb("tie")),!function(){function a(a){for(var b,c={},e=d(a),g=e.length,f=0;g>f;)c[b=e[f++]]=qb(a,b);return c}var c=i.getOwnPropertySymbols,d=c?function(a){return Cb(a).concat(c(a))}:Cb;b(l,C,{isPrototype:g(N,A.isPrototypeOf,2),getOwnPropertyKeys:d,getPropertyDescriptor:function(c,b){var a=c;if(b in a)do if(e(a,b))return qb(a,b);while(a=S(a))},getOwnPropertyDescriptors:a,make:function(a,b){return Y(D(a),b)},define:function(b,c){return pb(b,a(c))},values:Jb(!1),entries:Jb(!0),isObject:z,classof:tb})}(),b(o,r,{get:function(a){var b=k(this),c=n(this.length),a=t(a);return 0>a&&(a+=c),b[a]},set:function(a,b){var c=n(this.length),a=t(a);return 0>a&&(a+=c),this[a]=b,this},"delete":function(a){var b=n(this.length),a=t(a);return 0>a&&(a+=b),a>=b||0>a?!1:(yc.call(this,a,1),!0)},contains:function(d,e){var b=k(this),c=n(b.length),a=t(e);for(0>a&&(a=nb(a+c,0));c>a;)if(tc(d,b[a++]))return!0;return!1},clone:function(){return Bb(this,[],[])},turn:gb}),b(l,r,gb.call(db("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,get,set,delete,contains,clone,turn"),function(b,a){a in x&&(b[a]=g(N,x[a]))},{})),b(l,Z,{toInteger:t}),b(o,Z,{times:function(d,h){var e,f=+this,b=n(f),c=v(b),a=0;if(j(d))for(e=g(d,h,3);b>a;)c[a]=e(a,a++,f);else for(;b>a;)c[a]=a++;return c},random:function(a){var b=+this,c=a==f?0:+a,d=H(b,c);return Yb()*(nb(b,c)-d)+d}}),b(l,Gb,{randomInt:function(d,e){var a=t(d),b=t(e),c=H(a,b);return Db(Yb()*(nb(a,b)+1-c)+c)}}),b(o,Z,gb.call(db("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(c,a){var b=s[a];b&&(c[a]=function(){for(var a=[+this],c=0;arguments.length>c;)a.push(arguments[c++]);return u(b,a)})},{})),!function(){var a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"},c=gb.call(y(a),function(c,b){c[a[b]]=b},{});b(o,M,{escapeHTML:xb(/[&<>"']/g,a),unescapeHTML:xb(/&(?:amp|lt|gt|quot|apos);/g,c)})}(),b(l,Qb,{escape:xb(/([\\\-[\]{}()*+?.,^$|])/g,"\\$1",!0)}),!function(p,n,c,d,j,h,i,f,k){function m(b){return function(n,m){function g(a){return o[(b?"getUTC":"get")+a]()}var o=this,l=c[e(c,m)?m:d];return X(n).replace(p,function(c){switch(c){case"ms":var b=g("Milliseconds");return b>99?b:"0"+a(b);case"s":return g(j);case"ss":return a(g(j));case"m":return g(h);case"mm":return a(g(h));case"h":return g(i);case"hh":return a(g(i));case"D":return g(O);case"DD":return a(g(O));case"W":return l.W[g("Day")];case"N":return g(f)+1;case"NN":return a(g(f)+1);case"M":return l.M[g(f)];case"MM":return l.MM[g(f)];case"YY":return a(g(k)%100);case"YYYY":return g(k)}return c})}}function a(a){return a>9?a:"0"+a}function g(d,a){function b(b){return gb.call(db(a.months),function(a,c){a.push(c.replace(n,"$"+b))})}return c[d]={W:db(a.weekdays),MM:b(1),M:b(2)},this}b(l,O,{locale:function(a){return e(c,a)?d=a:d},addLocale:g}),b(o,O,{format:m(!1),formatUTC:m(!0)}),g(d,{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","Month","FullYear"),!function(d){var e=gb.call(db("assert,count,clear,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,table,trace,warn,markTimeline,profile,profileEnd,time,timeEnd,timeStamp"),function(e,b){var c=d[b];e[b]=function(){return a&&c?dc.call(c,d,arguments):f}},{enable:function(){a=!0},disable:function(){a=!1}}),a=!0;try{L&&delete c.console}catch(g){}b(F+V,{console:Y(e.log,e)})}(c.console||{})}(Function("return this"),!0);
//# sourceMappingURL=core.min.map
{
"name": "core-js",
"description": "Standard library",
"version": "0.0.7",
"version": "0.0.8",
"repository": {

@@ -22,4 +22,8 @@ "type": "git",

"karma-firefox-launcher": "*",
"karma-opera-launcher": "*"
"karma-opera-launcher": "*",
"promises-aplus-tests": "*"
},
"scripts": {
"promises-tests": "promises-aplus-tests tests/promises_tests_adapter"
}
}
# Core.js
Alternative standard library for javascript. Includes polyfills for ECMAScript 5, ECMAScript 6, setImmediate, promises, static array methods, extended object api, console cap and other sugar.
Alternative standard library for javascript. Includes polyfills for ECMAScript 5, ECMAScript 6: Set, Map, WeakSet, WeakMap, Promise, Symbol, iterators; setImmediate, static array methods, console cap. Additional functionality: Dict, extended partial application, extended object api, Date formatting and other sugar.
### Install

@@ -15,2 +15,197 @@ ```

require('core-js');
```
### API:
```livescript
global -> object node
Object
.create(proto | null, descs?) -> object es5
.getPrototypeOf(object) -> proto | null es5 sham
.setPrototypeOf(object, proto | null) -> &0 es6 sham
.defineProperty(object, key, desc) -> &0 es5 sham
.defineProperties(object, descs) -> &0 es5 sham
.getOwnPropertyNames(object) -> array es5 sham
.getOwnPropertyDescriptor(object, key) -> desc es5
.keys(object) -> array es5
.values(object) -> array es7
.entries(object) -> array es7
.assign(target, ...src) -> &0 es6
.is(a, b) -> bool es6
.isPrototype(proto, object) -> bool core
.getOwnPropertyKeys(object) -> array core
.getPropertyDescriptor(object, key) -> desc core
.getOwnPropertyDescriptors(object) -> descs core
.make(proto | null, props?) -> object core
.define(object, props) -> &0 core
.isObject(var) -> bool core
.classof(var) -> string core
.tie(object, key, ...args | _) -> fn(...args) core
::[_](key, ...args | _) -> fn(...args) core
Function
::bind(object, ...args | _) -> fn(...args) es5
::part(...args | _) -> fn(...args) core
::by(object | _, ...args | _) -> fn(...args) core
::only(numberArguments, that /* = @ */) -> fn(...args) core
::methodize() -> fn(that, ...args) core
::invoke(args, that) -> var core
::construct(args) -> object core
::timeout(time, ...args) -> deferred core
::interval(time, ...args) -> deferred core
::immediate(...args) -> deferred core
Array
.isArray(var) -> bool es5
.from(iterable | array-like, fn(val, key, @)?, that) -> array es6
.of(...args) -> array es6
.{...Array::} js1.6
::slice(start?, end?) -> array es5
::join(string = ',') -> string es5
::indexOf(var, from?) -> int es5
::lastIndexOf(var, from?) -> int es5
::every(fn(val, key, @), that) -> bool es5
::some(fn(val, key, @), that) -> bool es5
::forEach(fn(val, key, @), that) -> void es5
::map(fn(val, key, @), that) -> array es5
::filter(fn(val, key, @), that) -> array es5
::reduce(fn(memo, val, key, @), memo?) -> var es5
::reduceRight(fn(memo, val, key, @), memo?) -> var es5
::fill(var, start?, end?) -> @ es5
::find(fn(val, key, @), that) -> var es6
::findIndex(fn(val, key, @), that) -> int es6
::values() -> iterator es6
::keys() -> iterator es6
::entries() -> iterator (entries) es6
::@@iterator() -> iterator es6
::get(index) -> var core
::set(index, value) -> @ core
::delete(index) -> bool core
::contains(var, from?) -> bool es7
::clone() -> var core
::turn(fn(memo, val, key, @), memo = []) -> memo core
[new] Dict(itarable (entries) | object ?) -> dict core
.isDict(var) -> bool core
.has(object, key) -> bool core
.get(object, key) -> val core
.set(object, key, value) -> &0 core
.forEach(object, fn(val, key, @), that) -> void core
.map(object, fn(val, key, @), that) -> new @ core
.filter(object, fn(val, key, @), that) -> new @ core
.some(object, fn(val, key, @), that) -> bool core
.every(object, fn(val, key, @), that) -> bool core
.find(object, fn(val, key, @), that) -> val core
.findKey(object, fn(val, key, @), that) -> key core
.keyOf(object, var) -> key core
.contains(object, var) -> bool core
.reduce(object, fn(memo, val, key, @), memo?) -> var core
.turn(object, fn(memo, val, key, @), memo = new @) -> memo core
.clone(foo) -> var core
new Set(iterable?) -> set es6
::add(key) -> @ es6
::clear() -> void es6
::delete(key) -> bool es6
::forEach(fn(el, el, @), that) -> void es6
::has(key) -> bool es6
::size -> uint es6
::values() -> iterator es6
::keys() -> iterator es6
::entries() -> iterator (entries) es6
::@@iterator() -> iterator es6
new Map(iterable (entries) ?) -> map es6
::clear() -> void es6
::delete(key) -> bool es6
::forEach(fn(val, key, @), that) -> void es6
::get(key) -> val es6
::has(key) -> bool es6
::set(key, val) -> @ es6
::size -> uint es6
::values() -> iterator es6
::keys() -> iterator es6
::entries() -> iterator (entries) es6
::@@iterator() -> iterator (entries) es6
new WeakSet(iterable?) -> weakset es6
::add(key) -> @ es6
::clear() -> void es6
::delete(key) -> bool es6
::has(key) -> bool es6
new WeakMap(iterable (entries) ?) -> weakmap es6 sham
::clear() -> void es6 sham
::delete(key) -> bool es6
::get(key) -> val es6
::has(key) -> bool es6
::set(key, val) -> @ es6
String
::trim() -> str es5
::contains(str, from?) -> bool es6
::startsWith(str, from?) -> bool es6
::endsWith(str, from?) -> bool es6
::repeat(num) -> str es6
::@@iterator() -> iterator es6 sham
::escapeHTML() -> str core
::unescapeHTML() -> str core
RegExp
.escape(str) -> str es7
Number
.EPSILON -> num es6
.isFinite(num) -> bool es6
.isInteger(num) -> bool es6
.isNaN(num) -> bool es6
.isSafeInteger(num) -> bool es6
.MAX_SAFE_INTEGER -> int es6
.MIN_SAFE_INTEGER -> int es6
.parseFloat(str) -> num es6
.parseInt(str) -> int es6
.toInteger(num) -> int core
::times(fn(i, i, @), that) -> array core
::random(lim = 0) -> num core
::{...Math} core
Math
.acosh(num) -> num es6
.asinh(num) -> num es6
.atanh(num) -> num es6
.cbrt(num) -> num es6
.clz32(num) -> uint es6
.cosh(num) -> num es6
.expm1(num) -> num es6
.hypot(...args) -> num es6
.imul(num, num) -> int es6
.log1p(num) -> num es6
.log10(num) -> num es6
.log2(num) -> num es6
.sign(num) -> 1 | -1 | 0 | -0 | NaN es6
.sinh(num) -> num es6
.tanh(num) -> num es6
.trunc(num) -> num es6
.randomInt(lim1, lim2 = 0) -> int core
Date
.now() -> int es5
.addLocale(key, object) -> @ core
.locale(key?) -> key core
::format(str, key?) -> str core
::formatUTC(str, key?) -> str core
Symbol(description?) -> symbol es6 sham
.for(key) -> symbol es6
.keyFor(symbol) -> key es6
.iterator -> symbol es6 sham
.toStringTag -> symbol es6
.pure() -> symbol || string core
.set(object, key, val) -> &0 core
new Promise(resolver(resolve(var), reject(var))) -> promise es6
::then(resolved(var), rejected(var)) -> promise es6
::catch(rejected(var)) -> promise es6
.resolve(var || promise) -> promise es6
.reject(var) -> promise es6
.all(iterable) -> promise es6
.race(iterable) -> promise es6
setTimeout(fn(...args), time, ...args) -> id w3c / whatwg
setInterval(fn(...args), time, ...args) -> id w3c / whatwg
setImmediate(fn(...args), ...args) -> id w3c / whatwg
clearImmediate(id) -> void w3c / whatwg
console(...args) -> void core
.{...console API} console api
.enable() -> void core
.disable() -> void core
$for(iterable, entries).of(fn(value, key?), that) -> void core
.isIterable(var) -> bool core
.getIterator(iterable) -> iterator core
core core
.{...global} core
_ -> object core / undescore
```
/**
* Array static methods
* http://wiki.ecmascript.org/doku.php?id=strawman:array_statics
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Array_generic_methods
* JavaScript 1.6
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.6#Array_and_String_generics
* Alternatives:
* https://github.com/plusdude/array-generics
* http://mootools.net/docs/core/Core/Core#Type:generics
* Strawman: http://wiki.ecmascript.org/doku.php?id=strawman:array_statics
* JavaScript 1.6: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.6#Array_and_String_generics
*/
$define(STATIC, ARRAY, transform.call(
// IE... getOwnPropertyNames($Array),
$define(STATIC, ARRAY, turn.call(
// IE... getNames(ArrayProto),
array(

@@ -20,8 +15,8 @@ // ES3:

'fill,find,findIndex,keys,values,entries,' +
// Core.js:
'at,transform,contains'
// Core:
'get,set,delete,contains,clone,turn'
),
function(memo, key){
if(key in $Array)memo[key] = unbind($Array[key]);
if(key in ArrayProto)memo[key] = ctx(call, ArrayProto[key]);
}, {}
));

@@ -7,19 +7,41 @@ $define(PROTO, ARRAY, {

*/
at: function(index){
index = toInteger(index);
return ES5Object(this)[0 > index ? this.length + index : index];
get: function(index){
var O = ES5Object(this)
, length = toLength(this.length)
, index = toInteger(index);
if(index < 0)index += length;
return O[index];
},
set: function(index, value){
var length = toLength(this.length)
, index = toInteger(index);
if(index < 0)index += length;
this[index] = value;
return this;
},
'delete': function(index){
var length = toLength(this.length)
, index = toInteger(index);
if(index < 0)index += length;
if(index >= length || index < 0)return false;
splice.call(this, index, 1);
return true;
},
// ~ ES7 : https://github.com/domenic/Array.prototype.contains
contains: function(searchElement, fromIndex){
var O = ES5Object(this)
, length = toLength(O.length)
, index = toInteger(fromIndex);
if(index < 0)index = max(index + length, 0);
while(length > index)if(sameValueZero(searchElement, O[index++]))return true;
return false;
},
clone: function(){
return clone(this, [], []);
},
/**
* Alternatives:
* http://lodash.com/docs#template
* http://lodash.com/docs#transform
*/
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;
}
turn: turn
});

@@ -1,21 +0,3 @@

!function(){
/**
* Alternatives:
* http://www.2ality.com/2013/06/auto-binding.html
* http://livescript.net/#property-access -> foo~bar
* http://lodash.com/docs#bindKey
*/
function tie(key){
var that = this
, _ = path._
, placeholder = false
, length = arguments.length
, i = 1, args;
if(length < 2)return ctx(that[key], that);
args = Array(length - 1)
while(length > i)if((args[i - 1] = arguments[i++]) === _)placeholder = true;
return createPartialApplication(that[key], args, length, placeholder, true, that);
}
var $tie = {tie: tie};
$define(PROTO, FUNCTION, assign({
!function(_){
$define(PROTO, FUNCTION, {
/**

@@ -27,17 +9,35 @@ * Partial apply.

* http://mootools.net/docs/core/Types/Function#Function:pass
* http://fitzgen.github.io/wu.js/#wu-partial
*/
part: part,
by: function(that){
var fn = this
, _ = path._
, placeholder = false
, length = arguments.length
, i = 1, args;
if(length < 2)return ctx(fn, that);
args = Array(length - 1);
while(length > i)if((args[i - 1] = arguments[i++]) === _)placeholder = true;
return createPartialApplication(fn, args, length, placeholder, true, that);
var fn = this
, _ = path._
, holder = false
, length = arguments.length
, woctx = that === _
, i = woctx ? 0 : 1
, indent = i
, args;
if(length < 2)return woctx ? ctx(call, fn, -1) : ctx(fn, that, -1);
args = Array(length - indent);
while(length > i)if((args[i - indent] = arguments[i++]) === _)holder = true;
return partial(woctx ? call : fn, args, length, holder, _, true, woctx ? fn : that);
},
/**
* http://www.wirfs-brock.com/allen/posts/166
* http://habrahabr.ru/post/114737/
*/
only: function(numberArguments, that /* = @ */){
var fn = assertFunction(this)
, n = toLength(numberArguments)
, isThat = arguments.length > 1;
return function(/* ...args */){
var length = min(n, arguments.length)
, args = Array(length)
, i = 0;
while(length > i)args[i] = arguments[i++];
return invoke(fn, args, isThat ? that : this);
}
},
/**
* fn(a, b, c, ...) -> a.fn(b, c, ...)

@@ -49,19 +49,38 @@ * Alternatives:

var fn = this;
return function(/*...args*/){
return function(/* ...args */){
var args = [this]
, i = 0;
while(arguments.length > i)args.push(arguments[i++]);
return apply.call(fn, undefined, args);
return invoke(fn, args);
}
}
}, $tie));
$define(PROTO, ARRAY, $tie);
$define(PROTO, REGEXP, $tie);
$define(STATIC, OBJECT, {
tie: unbind(tie)
});
Export.useTie = function(){
$define(PROTO, OBJECT, $tie);
/**
* Alternatives:
* http://www.2ality.com/2013/06/auto-binding.html
* http://livescript.net/#property-access -> foo~bar
* http://lodash.com/docs#bindKey
*/
function tie(key){
var that = this
, _ = path._
, holder = false
, length = arguments.length
, i = 1, args;
if(length < 2)return ctx(that[key], that, -1);
args = Array(length - 1)
while(length > i)if((args[i - 1] = arguments[i++]) === _)holder = true;
return partial(that[key], args, length, holder, _, true, that);
}
$define(STATIC, OBJECT, {tie: core.tie = ctx(call, tie)});
hidden(path._, TO_STRING, function(){
return _;
}
}();
});
DESCRIPTORS && hidden(ObjectProto, _, tie);
hidden(FunctionProto, _, tie);
hidden(ArrayProto, _, tie);
hidden(RegExp[PROTOTYPE], _, tie);
}(uid('tie'));

@@ -1,10 +0,8 @@

/**
* 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(
var $console = turn.call(
/**
* Methods from:
* https://github.com/DeveloperToolsWG/console-object/blob/master/api.md
* https://developer.mozilla.org/en-US/docs/Web/API/console
*/
array('assert,count,clear,debug,dir,dirxml,error,exception,' +

@@ -14,4 +12,5 @@ 'group,groupCollapsed,groupEnd,info,log,table,trace,warn,' +

function(memo, key){
var fn = console[key];
memo[key] = function(){
if(enabled && console[key])return apply.call(console[key], console, arguments);
if(enabled && fn)return apply.call(fn, console, arguments);
};

@@ -31,3 +30,3 @@ },

} catch(e){}
$define(GLOBAL, {console: assign($console.log, $console)}, 1);
$define(GLOBAL + FORCED, {console: assign($console.log, $console)});
}(global.console || {});

@@ -1,44 +0,55 @@

// Shortcuts for property names
var OBJECT = 'Object'
, FUNCTION = 'Function'
, ARRAY = 'Array'
, STRING = 'String'
, NUMBER = 'Number'
, REGEXP = 'RegExp'
, MAP = 'Map'
, SET = 'Set'
, WEAKMAP = 'WeakMap'
, WEAKSET = 'WeakSet'
, PROMISE = 'Promise'
, ARGUMENTS = 'Arguments'
, PROCESS = 'process'
, PROTOTYPE = 'prototype'
, CREATE_ELEMENT = 'createElement'
var global = returnThis()
// Shortcuts for [[Class]] & property names
, OBJECT = 'Object'
, FUNCTION = 'Function'
, ARRAY = 'Array'
, STRING = 'String'
, NUMBER = 'Number'
, REGEXP = 'RegExp'
, DATE = 'Date'
, MAP = 'Map'
, SET = 'Set'
, WEAKMAP = 'WeakMap'
, WEAKSET = 'WeakSet'
, SYMBOL = 'Symbol'
, PROMISE = 'Promise'
, MATH = 'Math'
, ARGUMENTS = 'Arguments'
, PROTOTYPE = 'prototype'
, CONSTRUCTOR = 'constructor'
, TO_STRING = 'toString'
, FOR_EACH = 'forEach'
, PROCESS = 'process'
, CREATE_ELEMENT = 'createElement'
// Aliases global objects and prototypes
, Function = global[FUNCTION]
, Object = global[OBJECT]
, Array = global[ARRAY]
, String = global[STRING]
, Number = global[NUMBER]
, RegExp = global[REGEXP]
, Map = global[MAP]
, Set = global[SET]
, WeakMap = global[WEAKMAP]
, WeakSet = global[WEAKSET]
, Promise = global[PROMISE]
, Math = global.Math
, TypeError = global.TypeError
, setTimeout = global.setTimeout
, clearTimeout = global.clearTimeout
, setInterval = global.setInterval
, setImmediate = global.setImmediate
, clearImmediate = global.clearImmediate
, process = global[PROCESS]
, document = global.document
, Infinity = 1 / 0
, $Array = Array[PROTOTYPE]
, $Object = Object[PROTOTYPE]
, $Function = Function[PROTOTYPE]
, Export = {};
, Function = global[FUNCTION]
, Object = global[OBJECT]
, Array = global[ARRAY]
, String = global[STRING]
, Number = global[NUMBER]
, RegExp = global[REGEXP]
, Date = global[DATE]
, Map = global[MAP]
, Set = global[SET]
, WeakMap = global[WEAKMAP]
, WeakSet = global[WEAKSET]
, Symbol = global[SYMBOL]
, Math = global[MATH]
, TypeError = global.TypeError
, setTimeout = global.setTimeout
, clearTimeout = global.clearTimeout
, setInterval = global.setInterval
, setImmediate = global.setImmediate
, clearImmediate = global.clearImmediate
, process = global[PROCESS]
, nextTick = process && process.nextTick
, document = global.document
, define = global.define
, ArrayProto = Array[PROTOTYPE]
, ObjectProto = Object[PROTOTYPE]
, FunctionProto = Function[PROTOTYPE]
, Infinity = 1 / 0
, core = {}
, path = framework ? global : core;
// 7.2.3 SameValue(x, y)

@@ -49,5 +60,6 @@ var same = Object.is || function(x, y){

// 7.2.4 SameValueZero(x, y)
function same0(x, y){
return x === y || (x !== x && y !== y);
function sameValueZero(x, y){
return x === y || x !== x && y !== y;
}
// http://jsperf.com/core-js-isobject

@@ -60,26 +72,31 @@ function isObject(it){

}
// native function?
var nativeRegExp = /^\s*function[^{]+\{\s*\[native code\]\s*\}\s*$/;
function isNative(it){
return nativeRegExp.test(it);
}
var toString = $Object.toString
// Native function?
var isNative = ctx(/./.test, /\[native code\]\s*\}\s*$/, 1);
// Object internal [[Class]] or toStringTag
// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring
var toString = ObjectProto[TO_STRING]
, classes = [ARGUMENTS, ARRAY, 'Boolean', DATE, 'Error', FUNCTION, NUMBER, REGEXP, STRING]
// define in es6_symbol module
, TOSTRINGTAG;
function setTag(constructor, tag, stat){
if(TOSTRINGTAG && constructor)(stat ? constructor : constructor[PROTOTYPE])[TOSTRINGTAG] = tag;
function setToStringTag(constructor, tag, stat){
if(TOSTRINGTAG && constructor)set(stat ? constructor : constructor[PROTOTYPE], TOSTRINGTAG, tag);
}
// object internal [[Class]]
function cof(it){
return it == undefined ? it === undefined ? 'Undefined' : 'Null' : toString.call(it).slice(8, -1);
}
function classof(it){
if(it == undefined)return it === undefined ? 'Undefined' : 'Null';
var cof = toString.call(it).slice(8, -1);
return TOSTRINGTAG && cof == OBJECT && it[TOSTRINGTAG] ? it[TOSTRINGTAG] : cof;
var klass = cof(it)
, tag;
if(klass == OBJECT && TOSTRINGTAG && (tag = it[TOSTRINGTAG]) && !~indexOf.call(classes, tag))return tag;
return klass;
}
// Function:
var apply = $Function.apply
, call = $Function.call
, path = framework ? global : Export;
Export._ = path._ = path._ || {};
// partial apply
function part(/*...args*/){
// Function
var apply = FunctionProto.apply
, call = FunctionProto.call;
// Placeholder
core._ = path._ = framework ? path._ || {} : {};
// Partial apply
function part(/* ...args */){
var length = arguments.length

@@ -89,84 +106,131 @@ , args = Array(length)

, _ = path._
, placeholder = false;
while(length > i)if((args[i] = arguments[i++]) === _)placeholder = true;
return createPartialApplication(this, args, length, placeholder, false);
, holder = false;
while(length > i)if((args[i] = arguments[i++]) === _)holder = true;
return partial(this, args, length, holder, _, false);
}
function ctx(fn, that){
// Internal partial application & context binding
function partial(fn, argsPart, lengthPart, holder, _, bind, context){
assertFunction(fn);
return function(/*...args*/){
return fn.apply(that, arguments);
}
}
function createPartialApplication(fn, argsPart, lengthPart, placeholder, bind, context){
assertFunction(fn);
return function(/*...args*/){
return function(/* ...args */){
var that = bind ? context : this
, _ = path._
, length = arguments.length
, i = 0, j = 0, args;
if(!placeholder && length == 0)return fn.apply(that, argsPart);
if(!holder && length == 0)return invoke(fn, argsPart, that);
args = argsPart.slice();
if(placeholder)for(;lengthPart > i; i++)if(args[i] === _)args[i] = arguments[j++];
if(holder)for(;lengthPart > i; i++)if(args[i] === _)args[i] = arguments[j++];
while(length > j)args.push(arguments[j++]);
return fn.apply(that, args);
return invoke(fn, args, that);
}
}
// unbind method from context
// foo.fn(arg1, arg2, ...) => fn(foo, arg1, arg2, ...)
function unbind(that){
return function(){
return call.apply(that, arguments);
function ctx(fn, that, length){
assertFunction(fn);
if(~length && that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
}
case 2: return function(a, b){
return fn.call(that, a, b);
}
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
}
} return function(/* ...args */){
return fn.apply(that, arguments);
}
}
// Fast apply
// http://jsperf.lnkit.com/fast-apply/5
function invoke(fn, args, that){
var un = that === undefined;
switch(args.length){
case 0: return un ? fn()
: fn.call(that);
case 1: return un ? fn(args[0])
: fn.call(that, args[0]);
case 2: return un ? fn(args[0], args[1])
: fn.call(that, args[0], args[1]);
case 3: return un ? fn(args[0], args[1], args[2])
: fn.call(that, args[0], args[1], args[2]);
case 4: return un ? fn(args[0], args[1], args[2], args[3])
: fn.call(that, args[0], args[1], args[2], args[3]);
case 5: return un ? fn(args[0], args[1], args[2], args[3], args[4])
: fn.call(that, args[0], args[1], args[2], args[3], args[4]);
} return fn.apply(that, args);
}
// Object:
var _hasOwn = $Object.hasOwnProperty;
var create = Object.create
, getPrototypeOf = Object.getPrototypeOf
, defineProperty = Object.defineProperty
, defineProperties = Object.defineProperties
, getOwnDescriptor = Object.getOwnPropertyDescriptor
, getKeys = Object.keys
, getNames = Object.getOwnPropertyNames
, hasOwnProperty = ObjectProto.hasOwnProperty
, isEnumerable = ObjectProto.propertyIsEnumerable
, __PROTO__ = '__proto__' in ObjectProto
// Dummy, fix for not array-like ES3 string in es5 module
, ES5Object = Object;
function has(object, key){
return _hasOwn.call(object, key);
return hasOwnProperty.call(object, key);
}
var create = Object.create
, getPrototypeOf = Object.getPrototypeOf
, defineProperty = Object.defineProperty
, defineProperties = Object.defineProperties
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor
, keys = Object.keys
, getOwnPropertyNames = Object.getOwnPropertyNames
, isEnumerable = $Object.propertyIsEnumerable
, __PROTO__ = '__proto__' in $Object
, DESCRIPTORS = true
// Dummy, fix for not array-like ES3 string in es5.js
, ES5Object = Object;
// http://wiki.ecmascript.org/doku.php?id=strawman:extended_object_api
function getOwnPropertyDescriptors(object){
var result = {}
, names = getOwnPropertyNames(object)
, length = names.length
, i = 0
, key;
while(length > i)result[key = names[i++]] = getOwnPropertyDescriptor(object, key);
return result;
}
// http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api
function getPropertyDescriptor(object, key){
if(key in object)do {
if(has(object, key))return getOwnPropertyDescriptor(object, key);
} while(object = getPrototypeOf(object));
}
// 19.1.2.1 Object.assign ( target, source, ... )
// 19.1.2.1 Object.assign(target, source, ...)
var assign = Object.assign || function(target, source){
target = Object(target);
var agsLength = arguments.length
, i = 1;
while(agsLength > i){
source = ES5Object(arguments[i++]);
var props = keys(source)
, length = props.length
var T = Object(target)
, l = arguments.length
, i = 1;
while(l > i){
var S = ES5Object(arguments[i++])
, keys = getKeys(S)
, length = keys.length
, j = 0
, key;
while(length > j)target[key = props[j++]] = source[key];
while(length > j)T[key = keys[j++]] = S[key];
}
return target;
return T;
}
function createObjectToArray(isEntries){
return function(object){
var O = ES5Object(object)
, keys = getKeys(object)
, length = keys.length
, i = 0
, result = Array(length)
, key;
while(length > i)result[i] = isEntries ? [key = keys[i++], O[key]] : O[keys[i++]];
return result;
}
}
function keyOf(object, searchElement){
var O = ES5Object(object)
, keys = getKeys(O)
, length = keys.length
, index = 0
, key;
while(length > index)if(O[key = keys[index++]] === searchElement)return key;
}
// Simple structured cloning
function clone(it, stack1, stack2){
var klass = cof(it)
, isArray = klass == ARRAY
, index, result, i, l, keys, key;
if(isArray || klass == OBJECT){
index = indexOf.call(stack1, it);
if(~index)return stack2[index];
stack1.push(it);
stack2.push(result = isArray ? Array(l = it.length) : create(getPrototypeOf(it)));
if(isArray){
for(i = 0; l > i;)if(has(it, i))result[i] = clone(it[i++], stack1, stack2);
} else {
keys = getKeys(it);
l = keys.length;
for(i = 0; l > i;)result[key = keys[i++]] = clone(it[key], stack1, stack2);
}
return result;
}
return it;
}
// Array:
// Array
// array('str1,str2,str3') => ['str1', 'str2', 'str3']

@@ -176,22 +240,65 @@ function array(it){

}
var push = $Array.push
, unshift = $Array.unshift
, slice = $Array.slice
, $indexOf = Array.indexOf || unbind($Array.indexOf)
, $forEach = Array.forEach || unbind($Array.forEach)
, $slice = Array.slice || function(arrayLike, from){
return slice.call(arrayLike, from);
var push = ArrayProto.push
, unshift = ArrayProto.unshift
, slice = ArrayProto.slice
, splice = ArrayProto.splice
, indexOf = ArrayProto.indexOf
, forEach = ArrayProto[FOR_EACH];
/*
* 0 -> forEach
* 1 -> map
* 2 -> filter
* 3 -> some
* 4 -> every
* 5 -> find
* 6 -> findIndex
*/
function createArrayMethod(type){
var isMap = type == 1
, isFilter = type == 2
, isSome = type == 3
, isEvery = type == 4
, isFindIndex = type == 6
, noholes = type == 5 || isFindIndex;
return function(callbackfn, thisArg /* = undefined */){
var f = ctx(callbackfn, thisArg, 3)
, O = Object(this)
, self = ES5Object(O)
, length = toLength(self.length)
, index = 0
, result = isMap ? Array(length) : isFilter ? [] : undefined
, val, res;
for(;length > index; index++)if(noholes || index in self){
val = self[index];
res = f(val, index, O);
if(type){
if(isMap)result[index] = res; // map
else if(res)switch(type){
case 3: return true; // some
case 5: return val; // find
case 6: return index; // findIndex
case 2: result.push(val); // filter
} else if(isEvery)return false; // every
}
}
// simple reduce to object
function transform(mapfn, target /* = [] */){
return isFindIndex ? -1 : isSome || isEvery ? isEvery : result;
}
}
// Simple reduce to object
function turn(mapfn, target /* = [] */){
assertFunction(mapfn);
target = target == undefined ? [] : Object(target);
var self = ES5Object(this)
, length = toLength(self.length)
, i = 0;
for(;length > i; i++)if(i in self && mapfn(target, self[i], i, this) === false)break;
return target;
var memo = target == undefined ? [] : Object(target)
, O = ES5Object(this)
, length = toLength(O.length)
, index = 0;
for(;length > index; index++){
if(mapfn(memo, O[index], index, this) === false)break;
}
return memo;
}
function generic(A, B){
return typeof A == 'function' ? A : B; // strange IE quirks mode bug -> use typeof vs isFunction
}
// Math:
// Math
var ceil = Math.ceil

@@ -203,3 +310,3 @@ , floor = Math.floor

, random = Math.random
, MAX_SAFE_INTEGER = pow(2, 53) - 1; // 0x1fffffffffffff == 9007199254740991
, MAX_SAFE_INTEGER = 0x1fffffffffffff; // pow(2, 53) - 1 == 9007199254740991
// 7.1.4 ToInteger

@@ -214,76 +321,111 @@ var toInteger = Number.toInteger || function(it){

// Assertion & errors:
function createEscaper(regExp, replace, isStatic){
var replacer = isObject(replace) ? function(part){
return replace[part];
} : replace;
return function(it){
return String(isStatic ? it : this).replace(regExp, replacer);
}
}
// Assertion & errors
var REDUCE_ERROR = 'Reduce of empty object with no initial value';
function assert(condition){
if(!condition)throw TypeError($slice(arguments, 1).join(' '));
function assert(condition, msg1, msg2){
if(!condition)throw TypeError(msg2 ? msg1 + msg2 : msg1);
}
function assertFunction(it){
if(!isFunction(it))throw TypeError(it + 'is not a function!');
assert(isFunction(it), it, ' is not a function!');
return it;
}
function assertObject(it){
if(!isObject(it))throw TypeError(it + 'is not an object!');
assert(isObject(it), it, ' is not an object!');
return it;
}
function assertInstance(it, constructor, name){
assert(it instanceof constructor, name, ": please use the 'new' operator!");
function assertInstance(it, Constructor, name){
assert(it instanceof Constructor, name, ": use the 'new' operator!");
}
var symbolUniq = 0;
function symbol(key){
return '@@' + key + '_' + (++symbolUniq + random()).toString(36);
}
// Property descriptors & Symbol
function descriptor(bitmap, value){
return {
enumerable : !!(bitmap & 1),
configurable: !!(bitmap & 2),
writable : !!(bitmap & 4),
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
}
}
function hidden(object, key, value){
return defineProperty(object, key, descriptor(6, value));
function simpleSet(object, key, value){
object[key] = value;
return object;
}
function createDefiner(bitmap){
return DESCRIPTORS ? function(object, key, value){
return defineProperty(object, key, descriptor(bitmap, value));
} : simpleSet;
}
function uid(key){
return SYMBOL + '(' + key + ')_' + (++sid + random())[TO_STRING](36);
}
// The engine works fine with descriptors? Thank's IE8 for his funny defineProperty.
var DESCRIPTORS = !!function(){try{return defineProperty({}, 0, ObjectProto)}catch(e){}}()
, sid = 0
, hidden = createDefiner(1)
, symbol = Symbol || uid
, set = Symbol ? simpleSet : hidden;
var ITERATOR, forOf, isIterable, getIterator, objectIterators; // define in symbol & iterators modules
// Collections & iterators variables, define in over modules
var ITERATOR
, $for
, isIterable
, getIterator
, COLLECTION_KEYS
, SHIM;
var GLOBAL = 1
, STATIC = 2
, PROTO = 4;
function $define(type, name, source, forced /* = false */){
var key, own, prop
// DOM
var html = document && document.documentElement;
// core
var NODE = cof(process) == PROCESS
, REQJS = isFunction(define) && define.amd
// type bitmap
, FORCED = 1
, GLOBAL = 2
, STATIC = 4
, PROTO = 8
, BIND = 16
, WRAP = 32;
function $define(type, name, source){
var key, own, out, exp
, isGlobal = type & GLOBAL
, isStatic = type & STATIC
, isProto = type & PROTO
, target = isGlobal ? global : isStatic ? global[name] : (global[name] || $Object)[PROTOTYPE]
, exports = isGlobal ? Export : Export[name] || (Export[name] = {});
if(isGlobal){
forced = source;
source = name;
, target = isGlobal ? global : (type & STATIC) ? global[name] : (global[name] || ObjectProto)[PROTOTYPE]
, exports = isGlobal ? core : core[name] || (core[name] = {});
if(isGlobal)source = name;
for(key in source){
// there is a similar native
own = !(type & FORCED) && target && key in target && (!isFunction(target[key]) || isNative(target[key]));
// export native or passed
out = (own ? target : source)[key];
// bind timers to global for call from export context
if(type & BIND && own)exp = ctx(out, global);
// wrap global constructors for prevent change them in library
else if(type & WRAP && !framework && target[key] == out){
exp = function(param){
return this instanceof out ? new out(param) : out(param);
}
exp[PROTOTYPE] = out[PROTOTYPE];
} else exp = type & PROTO && isFunction(out) ? ctx(call, out) : out;
// .CORE mark
if(!own)out.CORE = exp.CORE = true;
// export
if(exports[key] != out)exports[key] = exp;
// extend global
framework && target && !own && (isGlobal || delete target[key]) && hidden(target, key, out);
}
for(key in source)if(has(source, key)){
own = !forced && target && has(target, key) && (!isFunction(target[key]) || isNative(target[key]));
prop = own ? target[key] : source[key];
// export to `C`
exports[key] = isProto && isFunction(prop) ? unbind(prop) : prop;
// if build as framework, extend global objects
framework && target && !own && (isGlobal || delete target[key])
&& defineProperty(target, key, descriptor(6 + !isProto, source[key]));
}
}
function $defineTimer(key, fn){
if(framework)global[key] = fn;
Export[key] = global[key] != fn ? fn : ctx(fn, global);
}
// wrap to prevent obstruction of the global constructors, when build as library
function wrapGlobalConstructor(Base){
if(framework || !isNative(Base))return Base;
function F(param){
// used on constructors that takes 1 argument
return this instanceof Base ? new Base(param) : Base(param);
}
F[PROTOTYPE] = Base[PROTOTYPE];
return F;
}
// export
var isNode = classof(process) == PROCESS;
if(isNode)module.exports = Export;
if(!isNode || framework)global.C = Export;
core.CORE = true;
// CommonJS export
if(NODE)module.exports = core;
// RequireJS export
if(REQJS)define(function(){return core});
// Export to global object
if(!NODE && !REQJS || framework)global.core = core;

@@ -1,10 +0,2 @@

/**
* 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(formatRegExp, flexioRegExp, locales, current, SECONDS, MINUTES, HOURS, MONTH, YEAR){
function createFormat(UTC){

@@ -19,8 +11,8 @@ return function(template, locale /* = current */){

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 'ms' : var ms = get('Milliseconds'); // Milliseconds : 000-999
return ms > 99 ? ms : '0' + lz(ms);
case 's' : return get(SECONDS); // Seconds : 0-59
case 'ss' : return lz(get(SECONDS)); // Seconds : 00-59
case 'm' : return get(MINUTES); // Minutes : 0-59
case 'mm' : return lz(get(MINUTES)); // Minutes : 00-59
case 'h' : return get(HOURS); // Hours : 0-23

@@ -35,6 +27,5 @@ case 'hh' : return lz(get(HOURS)); // Hours : 00-23

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;
case 'YY' : return lz(get(YEAR) % 100); // Year : 14
case 'YYYY' : return get(YEAR); // Year : 2014
} return part;
});

@@ -47,14 +38,14 @@ }

function addLocale(lang, locale){
function split(index){
return turn.call(array(locale.months), function(memo, it){
memo.push(it.replace(flexioRegExp, '$' + index));
});
}
locales[lang] = {
W : array(locale.weekdays),
MM: flexio(locale.months, 1),
M : flexio(locale.months, 2)
MM: split(1),
M : split(2)
};
return Date;
return this;
}
function flexio(locale, index){
return transform.call(array(locale), function(memo, it){
memo.push(it.replace(flexioRegExp, '$' + index));
});
}
$define(STATIC, DATE, {

@@ -67,4 +58,4 @@ locale: function(locale){

$define(PROTO, DATE, {
format: createFormat(0),
formatUTC: createFormat(1)
format: createFormat(false),
formatUTC: createFormat(true)
});

@@ -79,2 +70,2 @@ addLocale(current, {

});
}(/\b\w{1,4}\b/g, /:(.*)\|(.*)$/, {}, 'en', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear');
}(/\b\w{1,4}\b/g, /:(.*)\|(.*)$/, {}, 'en', 'Seconds', 'Minutes', 'Hours', 'Month', 'FullYear');

@@ -13,16 +13,16 @@ /**

function Deferred(args){
this[ID] = set.apply(global, this[ARGUMENTS] = args)
this[ID] = invoke(set, this[ARGUMENTS] = args);
}
Deferred[PROTOTYPE].set = function(){
hidden(Deferred[PROTOTYPE], 'set', function(){
clear(this[ID]);
this[ID] = set.apply(global, this[ARGUMENTS]);
this[ID] = invoke(set, this[ARGUMENTS]);
return this;
}
Deferred[PROTOTYPE].clear = function(){
});
hidden(Deferred[PROTOTYPE], 'clear', function(){
clear(this[ID]);
return this;
}
});
return function(/* ...args */){
assertFunction(this);
var args = [this], i = 0;
var args = [assertFunction(this)]
, i = 0;
while(arguments.length > i)args.push(arguments[i++]);

@@ -33,6 +33,6 @@ return new Deferred(args);

$define(PROTO, FUNCTION, {
timeout: createDeferredFactory(setTimeout, clearTimeout),
interval: createDeferredFactory(setInterval, clearInterval),
timeout: createDeferredFactory(setTimeout, clearTimeout),
interval: createDeferredFactory(setInterval, clearInterval),
immediate: createDeferredFactory(setImmediate, clearImmediate)
});
}(symbol('arguments'), symbol('id'));

@@ -5,5 +5,5 @@ !function(){

if(iterable != undefined){
if(isIterable(iterable))forOf(iterable, function(key, value){
if($for && isIterable(iterable))$for(iterable, true).of(function(key, value){
dict[key] = value;
}, undefined, 1);
});
else assign(dict, iterable);

@@ -14,130 +14,89 @@ }

Dict[PROTOTYPE] = null;
function findKey(object, fn, that /* = undefined */){
assertFunction(fn);
var O = ES5Object(object)
, props = keys(O)
, length = props.length
, i = 0
, key;
while(length > i){
if(fn.call(that, O[key = props[i++]], key, object))return key;
}
}
function keyOf(object, searchElement){
var O = ES5Object(object)
, props = keys(O)
, length = props.length
, i = 0
, key;
while(length > i)if(same0(O[key = props[i++]], searchElement))return key;
}
assign(Dict, objectIterators, {
/**
* Object enumumerabe
* Alternatives:
* http://underscorejs.org/ _.{...enumerable}
* http://sugarjs.com/api/Object/enumerable Object.{...enumerable}
* http://mootools.net/docs/core/Types/Object Object.{...enumerable}
* http://api.jquery.com/category/utilities/ $.{...enumerable}
* http://docs.angularjs.org/api/ng/function angular.{...enumerable}
*/
every: function(object, fn, that /* = undefined */){
assertFunction(fn);
var O = ES5Object(object)
, props = keys(O)
, length = props.length
/*
* 0 -> forEach
* 1 -> map
* 2 -> filter
* 3 -> some
* 4 -> every
* 5 -> find
* 6 -> findKey
*/
function createDictMethod(type){
var isMap = type == 1
, isFilter = type == 2
, isSome = type == 3
, isEvery = type == 4;
return function(object, callbackfn, thisArg /* = undefined */){
var f = ctx(callbackfn, thisArg, 3)
, O = ES5Object(object)
, keys = getKeys(O)
, length = keys.length
, i = 0
, key;
, result = isMap || isFilter ? new (generic(this, Dict)) : undefined
, key, val, res;
while(length > i){
if(!fn.call(that, O[key = props[i++]], key, object))return false;
key = keys[i++];
val = O[key];
res = f(val, key, object);
if(type){
if(isMap)result[key] = res; // map
else if(res)switch(type){
case 3: return true; // some
case 5: return val; // find
case 6: return key; // findKey
case 2: result[key] = val; // filter
} else if(isEvery)return false; // every
}
}
return true;
},
filter: function(object, fn, that /* = undefined */){
assertFunction(fn);
return isSome || isEvery ? isEvery : result;
}
}
function createDictReduce(isTurn){
return function(object, mapfn, init){
assertFunction(mapfn);
var O = ES5Object(object)
, result = create(null)
, props = keys(O)
, length = props.length
, keys = getKeys(O)
, length = keys.length
, i = 0
, key;
, memo, key, result;
if(isTurn)memo = init == undefined ? new (generic(this, Dict)) : Object(init);
else if(arguments.length < 3){
assert(length > i, REDUCE_ERROR);
memo = O[keys[i++]];
} else memo = Object(init);
while(length > i){
if(fn.call(that, O[key = props[i++]], key, object))result[key] = O[key];
result = mapfn(memo, O[key = keys[i++]], key, object);
if(isTurn){
if(result === false)break;
} else memo = result;
}
return result;
},
find: function(object, fn, that /* = undefined */){
var index = findKey(object, fn, that);
return index === undefined ? undefined : ES5Object(object)[index];
},
findKey: findKey,
forEach: function(object, fn, that /* = undefined */){
assertFunction(fn);
return memo;
}
}
assign(Dict, {
forEach: createDictMethod(0),
map: createDictMethod(1),
filter: createDictMethod(2),
some: createDictMethod(3),
every: createDictMethod(4),
find: createDictMethod(5),
findKey: createDictMethod(6),
reduce: createDictReduce(false),
turn: createDictReduce(true),
keyOf: keyOf,
contains: function(object, searchElement){
var O = ES5Object(object)
, props = keys(O)
, length = props.length
, i = 0
, key;
while(length > i)fn.call(that, O[key = props[i++]], key, object);
return object;
},
keyOf: keyOf,
map: function(object, fn, that /* = undefined */){
assertFunction(fn);
var O = ES5Object(object)
, result = create(null)
, props = keys(O)
, length = props.length
, i = 0
, key;
, keys = getKeys(O)
, length = keys.length
, i = 0;
while(length > i){
result[key = props[i++]] = fn.call(that, O[key], key, object);
if(sameValueZero(O[keys[i++]], searchElement))return true;
}
return result;
},
reduce: function(object, fn, result /* = undefined */, that /* = undefined */){
assertFunction(fn);
var O = ES5Object(object)
, props = keys(O)
, i = 0
, length = props.length
, key;
if(arguments.length < 3){
assert(length--, 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 */){
assertFunction(fn);
var O = ES5Object(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;
},
transform: function(object, mapfn, target /* = Dict() */){
assertFunction(mapfn);
target = target == undefined ? create(null) : Object(target);
var O = ES5Object(object)
, props = keys(O)
, length = props.length
, i = 0
, key;
while(length > i){
if(mapfn(target, O[key = props[i++]], key, object) === false)break;
}
return target;
clone: function(it){
return clone(it, [], []);
},
contains: function(object, value){
return keyOf(object, value) !== undefined;
},
// Has / get own property
// Has / get / set own property
has: has,

@@ -147,4 +106,5 @@ get: function(object, key){

},
set: createDefiner(0),
isDict: function(it){
return getPrototypeOf(it) == null;
return getPrototypeOf(it) == Dict[PROTOTYPE];
}

@@ -151,0 +111,0 @@ });

/**
* 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(){
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
// 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
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]'
// For fix IE 8- don't enum bug https://developer.mozilla.org/en-US/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
, slyKeys1 = array(TO_STRING + ',toLocaleString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,' + CONSTRUCTOR)
, slyKeys2 = slyKeys1.concat(PROTOTYPE, 'length')
, slyKeysLen1 = slyKeys1.length
, dontEnumBug = !isEnumerable.call({toString: undefined}, TO_STRING)
, $PROTO = symbol(PROTOTYPE)
// Create object with null prototype
, createDict = __PROTO__
, createDict = __PROTO__
? function(){

@@ -28,9 +23,8 @@ return {__proto__: null};

var iframe = document[CREATE_ELEMENT]('iframe')
, i = hiddenNames1Length
, body = document.body || document.documentElement
, i = slyKeysLen1
, iframeDocument;
iframe.style.display = 'none';
body.appendChild(iframe);
html.appendChild(iframe);
iframe.src = 'javascript:';
iframeDocument = iframe.contentWindow.document || iframe.contentDocument || iframe.document;
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();

@@ -40,28 +34,25 @@ iframeDocument.write('<script>document.F=Object</script>');

createDict = iframeDocument.F;
while(i--)delete createDict[PROTOTYPE][hiddenNames1[i]];
while(i--)delete createDict[PROTOTYPE][slyKeys1[i]];
return createDict();
}
, createGetKeys = function(names, length){
return function(O){
O = ES5Object(O);
var i = 0
, createGetKeys = function(names, length, isNames){
return function(object){
var O = ES5Object(object)
, i = 0
, result = []
, key;
for(key in O)has(O, key) && result.push(key);
// 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);
for(key in O)(key !== $PROTO) && has(O, key) && result.push(key);
// Hidden names for Object.getOwnPropertyNames & don't enum bug fix for Object.keys
if(dontEnumBug || isNames)while(length > i)if(has(O, key = names[i++])){
~indexOf.call(result, key) || result.push(key);
}
return result;
}
};
// The engine works fine with descriptors? Thank's IE8 for his funny defineProperty.
try {
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]);
if(!DESCRIPTORS){
getOwnDescriptor = function(O, P){
if(has(O, P))return descriptor(!isEnumerable.call(O, P), O[P]);
};
defineProperty = function(O, P, Attributes){
assertObject(O);
if('value' in Attributes)O[P] = Attributes.value;
if('value' in Attributes)assertObject(O)[P] = Attributes.value;
return O;

@@ -71,8 +62,8 @@ };

assertObject(O);
var names = keys(Properties)
, length = names.length
var keys = getKeys(Properties)
, length = keys.length
, i = 0
, P, Attributes;
while(length > i){
P = names[i++];
P = keys[i++];
Attributes = Properties[P];

@@ -82,7 +73,7 @@ if('value' in Attributes)O[P] = Attributes.value;

return O;
}
};
}
$define(STATIC, OBJECT, {
$define(STATIC + FORCED * !DESCRIPTORS, OBJECT, {
// 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P)
getOwnPropertyDescriptor: getOwnPropertyDescriptor,
getOwnPropertyDescriptor: getOwnDescriptor,
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)

@@ -92,25 +83,28 @@ defineProperty: defineProperty,

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 && 'toString' in O ? proto : null;
getPrototypeOf: getPrototypeOf = getPrototypeOf || function(O){
assertObject(O);
if(has(O, $PROTO))return O[$PROTO];
if(__PROTO__ && '__proto__' in O)return O.__proto__;
if(isFunction(O[CONSTRUCTOR]) && O != O[CONSTRUCTOR][PROTOTYPE])return O[CONSTRUCTOR][PROTOTYPE];
if(O instanceof Object)return ObjectProto;
return null;
},
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
getOwnPropertyNames: createGetKeys(hiddenNames2, hiddenNames2.length),
getOwnPropertyNames: getNames = getNames || createGetKeys(slyKeys2, slyKeys2.length, true),
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
create: function(O, /*?*/Properties){
create: create = create || function(O, /*?*/Properties){
if(O === null)return Properties ? defineProperties(createDict(), Properties) : createDict();
assertObject(O);
Empty[PROTOTYPE] = O;
Empty[PROTOTYPE] = assertObject(O);
var result = new Empty();
Empty[PROTOTYPE] = null;
if(Properties)defineProperties(result, Properties);
// add __proto__ for Object.getPrototypeOf shim
__PROTO__ || result.constructor[PROTOTYPE] === O || (result.__proto__ = O);
__PROTO__ || result[CONSTRUCTOR][PROTOTYPE] === O || (result[$PROTO] = O);
return result;
},
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
keys: createGetKeys(hiddenNames1, hiddenNames1Length)
keys: getKeys = getKeys || createGetKeys(slyKeys1, slyKeysLen1, false)
});

@@ -121,9 +115,8 @@

bind: function(scope /*, args... */){
var fn = this
, args = $slice(arguments, 1);
assertFunction(fn);
var fn = assertFunction(this)
, args = slice.call(arguments, 1);
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;
var _args = args.concat(slice.call(arguments))
, result, that;
if(this instanceof fn)return isObject(result = invoke(that = create(fn[PROTOTYPE]), _args, scope)) ? result : that;
return apply.call(fn, scope, _args);

@@ -136,3 +129,3 @@ }

// fix for not array-like ES3 string
// Fix for not array-like ES3 string
function arrayMethodFix(fn){

@@ -145,113 +138,76 @@ return function(){

ES5Object = function(it){
return _classof(it) == STRING ? it.split('') : Object(it);
return cof(it) == STRING ? it.split('') : Object(it);
}
slice = arrayMethodFix(slice);
}
$define(PROTO, ARRAY, {
$define(PROTO + FORCED * (ES5Object != Object), ARRAY, {
slice: slice,
join: arrayMethodFix($Array.join)
}, ES5Object != Object);
join: arrayMethodFix(ArrayProto.join)
});
// 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 = ES5Object(this)
, length = toLength(self.length)
, i = fromIndex | 0;
if(0 > i)i = toLength(length + i);
for(;length > i; i++)if(i in self && self[i] === searchElement)return i;
return -1;
},
// 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
lastIndexOf: function(searchElement, fromIndex /* = @[*-1] */){
var self = ES5Object(this)
, length = toLength(self.length)
, i = length - 1;
if(arguments.length > 1)i = min(i, fromIndex | 0);
if(0 > i)i = toLength(length + i);
for(;i >= 0; i--)if(i in self && self[i] === searchElement)return i;
return -1;
},
// 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
every: function(callbackfn, thisArg /* = undefined */){
$define(STATIC, ARRAY, {
isArray: function(arg){
return cof(arg) == ARRAY
}
});
function createArrayReduce(isRight){
return function(callbackfn, memo /* = @.0 */){
assertFunction(callbackfn);
var self = ES5Object(this)
, length = toLength(self.length)
, i = 0;
for(;length > i; i++){
if(i in self && !callbackfn.call(thisArg, self[i], i, this))return false;
var O = ES5Object(this)
, length = toLength(O.length)
, index = isRight ? length - 1 : 0
, inc = isRight ? -1 : 1;
if(2 > arguments.length)for(;;){
if(index in O){
memo = O[index];
index += inc;
break;
}
index += inc;
assert(isRight ? index >= 0 : length > index, REDUCE_ERROR);
}
return true;
},
// 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
some: function(callbackfn, thisArg /* = undefined */){
assertFunction(callbackfn);
var self = ES5Object(this)
, length = toLength(self.length)
, i = 0;
for(;length > i; i++){
if(i in self && callbackfn.call(thisArg, self[i], i, this))return true;
for(;isRight ? index >= 0 : length > index; index += inc)if(index in O){
memo = callbackfn(memo, O[index], index, this);
}
return false;
},
return memo;
}
}
$define(PROTO, ARRAY, {
// 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
forEach: function(callbackfn, thisArg /* = undefined */){
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);
},
forEach: forEach = forEach || createArrayMethod(0),
// 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
map: function(callbackfn, thisArg /* = undefined */){
assertFunction(callbackfn);
var result = Array(toLength(this.length));
$forEach(this, function(val, key, that){
result[key] = callbackfn.call(thisArg, val, key, that);
});
return result;
},
map: createArrayMethod(1),
// 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
filter: function(callbackfn, thisArg /* = undefined */){
assertFunction(callbackfn);
var result = [];
$forEach(this, function(val){
callbackfn.apply(thisArg, arguments) && result.push(val);
});
return result;
},
filter: createArrayMethod(2),
// 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
some: createArrayMethod(3),
// 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
every: createArrayMethod(4),
// 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)for(;;){
if(i in self){
memo = self[i++];
break;
}
assert(length > ++i, REDUCE_ERROR);
reduce: createArrayReduce(false),
// 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
reduceRight: createArrayReduce(true),
// 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
indexOf: indexOf = indexOf || function(searchElement, fromIndex /* = 0 */){
var O = ES5Object(this)
, length = toLength(O.length)
, index = toInteger(fromIndex);
if(index < 0)index = max(length + index, 0);
for(;length > index; index++)if(index in O){
if(O[index] === searchElement)return index;
}
for(;length > i; i++)if(i in self)memo = callbackfn(memo, self[i], i, this);
return memo;
return -1;
},
// 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
reduceRight: function(callbackfn, memo /* = @[*-1] */){
assertFunction(callbackfn);
var self = ES5Object(this)
, i = toLength(self.length) - 1;
if(2 > arguments.length)for(;;){
if(i in self){
memo = self[i--];
break;
}
assert(0 <= --i, REDUCE_ERROR);
// 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
lastIndexOf: function(searchElement, fromIndex /* = @[*-1] */){
var O = ES5Object(this)
, length = toLength(O.length)
, index = length - 1;
if(arguments.length > 1)index = min(index, toInteger(fromIndex));
if(index < 0)index = toLength(length + index);
for(;index >= 0; index--)if(index in O){
if(O[index] === searchElement)return index;
}
for(;i >= 0; i--)if(i in self)memo = callbackfn(memo, self[i], i, this);
return memo;
return -1;
}

@@ -261,25 +217,18 @@ });

// 21.1.3.25 / 15.5.4.20 String.prototype.trim()
$define(PROTO, STRING, {trim: function(){
return String(this).replace(trimRegExp, '');
}});
$define(PROTO, STRING, {
trim: createEscaper(RegExp('^' + whitespace + '+|' + whitespace + '+$', 'g'), '')
});
// 20.3.3.1 / 15.9.4.4 Date.now()
$define(STATIC, 'Date', {now: function(){
$define(STATIC, DATE, {now: function(){
return +new Date;
}});
if(isFunction(trimRegExp))isFunction = function(it){
return _classof(it) == FUNCTION;
if(isFunction(/./))isFunction = function(it){
return cof(it) == FUNCTION;
}
if(_classof(function(){return arguments}()) == OBJECT)classof = function(it){
if(_classof(function(){return arguments}()) == OBJECT)classof = function(it){
var cof = _classof(it);
return cof != OBJECT || !isFunction(it.callee) ? cof : ARGUMENTS;
return cof == OBJECT && isFunction(it.callee) ? ARGUMENTS : cof;
}
create = Export[OBJECT].create;
getPrototypeOf = Export[OBJECT].getPrototypeOf;
keys = Export[OBJECT].keys;
getOwnPropertyNames = Export[OBJECT].getOwnPropertyNames;
$indexOf = Export[ARRAY].indexOf;
$forEach = Export[ARRAY].forEach;
}();

@@ -6,4 +6,2 @@ /**

* Alternatives:
* https://github.com/paulmillr/es6-shim
* https://github.com/monolithed/ECMAScript-6
* https://github.com/Benvie/harmony-collections

@@ -16,96 +14,91 @@ * https://github.com/eriwen/es6-map-shim

!function(){
var STOREID = symbol('storeid')
, KEYS = symbol('keys')
SHIM = symbol('shim');
var KEYS = COLLECTION_KEYS = symbol('keys')
, VALUES = symbol('values')
, WEAKDATA = symbol('weakdata')
, WEAKID = symbol('weakid')
, STOREID = symbol('storeId')
, WEAKDATA = symbol('weakData')
, WEAKID = symbol('weakId')
, SIZE = DESCRIPTORS ? symbol('size') : 'size'
, uid = 0
, wid = 0
, tmp = {}
, sizeGetter = {size: {get: function(){
, uid = 0
, wid = 0;
function getCollection(C, NAME, test, methods, commonMethods, isMap, isWeak){
var ADDER_KEY = isMap ? 'set' : 'add'
, init = commonMethods.clear;
function initFromIterable(that, iterable){
if(iterable != undefined && $for){
$for(iterable, isMap).of(that[ADDER_KEY], that);
}
return that;
}
if(!test){
// create collection constructor
C = function(iterable){
assertInstance(this, C, NAME);
init.call(this);
initFromIterable(this, iterable);
}
set(C, SHIM, true);
assign(C[PROTOTYPE], methods, commonMethods);
isWeak || defineProperty(C[PROTOTYPE], 'size', {get: function(){
return this[SIZE];
}}};
function initCollection(that, iterable, isSet){
if(iterable != undefined)forOf && forOf(iterable, isSet ? that.add : that.set, that, !isSet);
return that;
}
function createCollectionConstructor(name, isSet){
function F(iterable){
assertInstance(this, F, name);
this.clear();
initCollection(this, iterable, isSet);
}});
} else {
var Native = C
, test_key = {}
, collection = new C([isMap ? [test_key, 1] : test_key])
, adder = collection[ADDER_KEY];
// wrap to init collections from iterable
if(!(ITERATOR in ArrayProto && collection.has(test_key))){
C = function(iterable){
assertInstance(this, C, NAME);
return initFromIterable(new Native, iterable);
}
C[PROTOTYPE] = Native[PROTOTYPE];
}
// fix .add & .set for chaining
if(framework && collection[ADDER_KEY](test_key, 1) !== collection){
hidden(C[PROTOTYPE], ADDER_KEY, function(a, b){
adder.call(this, a, b);
return this;
});
}
}
return F;
setToStringTag(C, NAME);
var O = {};
O[NAME] = C;
$define(GLOBAL + WRAP + FORCED * !isNative(C), O);
return C;
}
function fixCollection(Base, name, isSet){
var collection = new Base([isSet ? tmp : [tmp, 1]])
, initFromIter = collection.has(tmp)
, key = isSet ? 'add' : 'set'
, fn;
// fix .add & .set for chaining
if(framework && collection[key](tmp, 1) !== collection){
fn = collection[key];
hidden(Base[PROTOTYPE], key, function(){
fn.apply(this, arguments);
return this;
});
}
if(initFromIter)return wrapGlobalConstructor(Base);
// wrap to init collections from iterable
function F(iterable){
assertInstance(this, F, name);
return initCollection(new Base, iterable, isSet);
}
F[PROTOTYPE] = Base[PROTOTYPE];
return F;
}
function fastKey(it, create){
return isObject(it)
? 'O' + (has(it, STOREID)
? it[STOREID]
: create ? defineProperty(it, STOREID, {value: uid++})[STOREID] : '')
: (typeof it == 'string' ? 'S' : 'P') + it;
}
function createForEach(key){
return function(callbackfn, thisArg /* = undefined */){
assertFunction(callbackfn);
var values = this[VALUES]
, keyz = this[key]
, names = keys(keyz)
, length = names.length
, i = 0
, index;
while(length > i){
index = names[i++];
callbackfn.call(thisArg, values[index], keyz[index], this);
}
// return it with 'S' prefix if it's string or with 'P' prefix for over primitives
if(!isObject(it))return (typeof it == 'string' ? 'S' : 'P') + it;
// if it hasn't object id - add next
if(!has(it, STOREID)){
if(create)set(it, STOREID, ++uid);
else return '';
}
// return object id with 'O' prefix
return 'O' + it[STOREID];
}
function collectionHas(key){
return fastKey(key) in this[VALUES];
}
function clearSet(){
hidden(this, VALUES, create(null));
hidden(this, SIZE, 0);
}
// 23.1 Map Objects
if(!isFunction(Map) || !has(Map[PROTOTYPE], 'forEach')){
Map = createCollectionConstructor(MAP);
assign(Map[PROTOTYPE], {
function collectionMethods($VALUES){
return {
// 23.1.3.1 Map.prototype.clear()
// 23.2.3.2 Set.prototype.clear()
clear: function(){
hidden(this, KEYS, create(null));
clearSet.call(this);
set(this, KEYS, create(null));
if($VALUES == VALUES)set(this, VALUES, create(null));
set(this, SIZE, 0);
},
// 23.1.3.3 Map.prototype.delete(key)
// 23.2.3.4 Set.prototype.delete(value)
'delete': function(key){
var index = fastKey(key)
, values = this[VALUES]
, contains = index in values;
, keys = this[KEYS]
, contains = index in keys;
if(contains){
delete this[KEYS][index];
delete values[index];
delete keys[index];
if($VALUES == VALUES)delete this[VALUES][index];
this[SIZE]--;

@@ -115,65 +108,65 @@ }

},
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
forEach: createForEach(KEYS),
// 23.1.3.6 Map.prototype.get(key)
get: function(key){
return this[VALUES][fastKey(key)];
forEach: function(callbackfn, thisArg /* = undefined */){
var f = ctx(callbackfn, thisArg, 3)
, values = this[$VALUES]
, keys = this[KEYS]
, names = getKeys(keys)
, length = names.length
, i = 0
, index;
while(length > i){
index = names[i++];
f(values[index], keys[index], this);
}
},
// 23.1.3.7 Map.prototype.has(key)
has: collectionHas,
// 23.1.3.9 Map.prototype.set(key, value)
set: function(key, value){
var index = fastKey(key, 1)
, values = this[VALUES];
if(!(index in values)){
this[KEYS][index] = key;
this[SIZE]++;
}
values[index] = value;
return this;
// 23.2.3.7 Set.prototype.has(value)
has: function(key){
return fastKey(key) in this[KEYS];
}
});
// 23.1.3.10 get Map.prototype.size
defineProperties(Map[PROTOTYPE], sizeGetter);
} else Map = fixCollection(Map, MAP);
}
}
// 23.1 Map Objects
Map = getCollection(Map, MAP, isNative(Map) && has(Map[PROTOTYPE], FOR_EACH), {
// 23.1.3.6 Map.prototype.get(key)
get: function(key){
return this[VALUES][fastKey(key)];
},
// 23.1.3.9 Map.prototype.set(key, value)
set: function(key, value){
var index = fastKey(key, true)
, values = this[VALUES];
if(!(index in values)){
this[KEYS][index] = key;
this[SIZE]++;
}
values[index] = value;
return this;
}
}, collectionMethods(VALUES), true);
// 23.2 Set Objects
if(!isFunction(Set) || !has(Set[PROTOTYPE], 'forEach')){
Set = createCollectionConstructor(SET, 1);
assign(Set[PROTOTYPE], {
// 23.2.3.1 Set.prototype.add(value)
add: function(value){
var index = fastKey(value, 1)
, values = this[VALUES];
if(!(index in values)){
values[index] = value;
this[SIZE]++;
}
return this;
},
// 23.2.3.2 Set.prototype.clear()
clear: clearSet,
// 23.2.3.4 Set.prototype.delete(value)
'delete': function(value){
var index = fastKey(value)
, values = this[VALUES]
, contains = index in values;
if(contains){
delete values[index];
this[SIZE]--;
}
return contains;
},
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
forEach: createForEach(VALUES),
// 23.2.3.7 Set.prototype.has(value)
has: collectionHas
});
// 23.2.3.9 get Set.prototype.size
defineProperties(Set[PROTOTYPE], sizeGetter);
} else Set = fixCollection(Set, SET, 1);
Set = getCollection(Set, SET, isNative(Set) && has(Set[PROTOTYPE], FOR_EACH), {
// 23.2.3.1 Set.prototype.add(value)
add: function(value){
var index = fastKey(value, true)
, values = this[KEYS];
if(!(index in values)){
values[index] = value;
this[SIZE]++;
}
return this;
}
}, collectionMethods(KEYS));
function getWeakData(it){
return (has(it, WEAKDATA) ? it : defineProperty(it, WEAKDATA, {value: {}}))[WEAKDATA];
has(it, WEAKDATA) || set(it, WEAKDATA, {});
return it[WEAKDATA];
}
function weakCollectionHas(key){
return isObject(key) && has(key, WEAKDATA) && has(key[WEAKDATA], this[WEAKID]);
}
var weakCollectionMethods = {

@@ -183,3 +176,3 @@ // 23.3.3.1 WeakMap.prototype.clear()

clear: function(){
hidden(this, WEAKID, wid++);
set(this, WEAKID, wid++);
},

@@ -189,52 +182,30 @@ // 23.3.3.3 WeakMap.prototype.delete(key)

'delete': function(key){
return this.has(key) && delete key[WEAKDATA][this[WEAKID]];
return weakCollectionHas.call(this, key) && delete key[WEAKDATA][this[WEAKID]];
},
// 23.3.3.5 WeakMap.prototype.has(key)
// 23.4.3.5 WeakSet.prototype.has(value)
has: function(key){
return isObject(key) && has(key, WEAKDATA) && has(key[WEAKDATA], this[WEAKID]);
}
has: weakCollectionHas
};
// 23.3 WeakMap Objects
if(!isFunction(WeakMap) || !has(WeakMap[PROTOTYPE], 'clear')){
WeakMap = createCollectionConstructor(WEAKMAP);
assign(WeakMap[PROTOTYPE], assign({
// 23.3.3.4 WeakMap.prototype.get(key)
get: function(key){
return isObject(key) && has(key, WEAKDATA) ? key[WEAKDATA][this[WEAKID]] : undefined;
},
// 23.3.3.6 WeakMap.prototype.set(key, value)
set: function(key, value){
assertObject(key);
getWeakData(key)[this[WEAKID]] = value;
return this;
}
}, weakCollectionMethods));
} else WeakMap = fixCollection(WeakMap, WEAKMAP);
WeakMap = getCollection(WeakMap, WEAKMAP, isNative(WeakMap) && has(WeakMap[PROTOTYPE], 'clear'), {
// 23.3.3.4 WeakMap.prototype.get(key)
get: function(key){
if(isObject(key) && has(key, WEAKDATA))return key[WEAKDATA][this[WEAKID]];
},
// 23.3.3.6 WeakMap.prototype.set(key, value)
set: function(key, value){
getWeakData(assertObject(key))[this[WEAKID]] = value;
return this;
}
}, weakCollectionMethods, true, true);
// 23.4 WeakSet Objects
if(!isFunction(WeakSet)){
WeakSet = createCollectionConstructor(WEAKSET, 1);
assign(WeakSet[PROTOTYPE], assign({
// 23.4.3.1 WeakSet.prototype.add(value)
add: function(value){
assertObject(value);
getWeakData(value)[this[WEAKID]] = true;
return this;
}
}, weakCollectionMethods));
} else WeakSet = fixCollection(WeakSet, WEAKSET, 1);
setTag(Map, MAP);
setTag(Set, SET);
setTag(WeakMap, WEAKMAP);
setTag(WeakSet, WEAKSET);
$define(GLOBAL, {
Map: Map,
Set: Set,
WeakMap: WeakMap,
WeakSet: WeakSet
}, 1);
WeakSet = getCollection(WeakSet, WEAKSET, isNative(WeakSet), {
// 23.4.3.1 WeakSet.prototype.add(value)
add: function(value){
getWeakData(assertObject(value))[this[WEAKID]] = true;
return this;
}
}, weakCollectionMethods, false, true);
}();

@@ -1,186 +0,172 @@

!function($ITERATOR, KEY, VALUE, ITERATED, KIND, INDEX, KEYS, returnThis){
function createIterResultObject(value, done){
!function($$ITERATOR){
var FFITERATOR = $$ITERATOR in ArrayProto
, KEY = 1
, VALUE = 2
, ITERATED = symbol('iterated')
, KIND = symbol('kind')
, INDEX = symbol('index')
, KEYS = symbol('keys')
, ENTRIES = symbol('entries')
, getValues = createObjectToArray(false)
, Iterators = {};
function createIterResultObject(done, value){
return {value: value, done: !!done};
}
function createIteratorFactory(constructor, kind){
function createIteratorClass(Constructor, NAME, Base, next, DEFAULT){
Constructor[PROTOTYPE] = {};
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
// 23.1.5.2.1 %MapIteratorPrototype%.next()
// 23.2.5.2.1 %SetIteratorPrototype%.next()
hidden(Constructor[PROTOTYPE], 'next', next);
// 22.1.5.2.2 %ArrayIteratorPrototype%[@@iterator]()
// 23.1.5.2.2 %MapIteratorPrototype%[@@iterator]()
// 23.2.5.2.2 %SetIteratorPrototype%[@@iterator]()
hidden(Constructor[PROTOTYPE], ITERATOR, returnThis);
// Add iterator for FF iterator protocol
FFITERATOR && hidden(Constructor[PROTOTYPE], $$ITERATOR, returnThis);
// 22.1.5.2.3 %ArrayIteratorPrototype%[@@toStringTag]
// 23.1.5.2.3 %MapIteratorPrototype%[@@toStringTag]
// 23.2.5.2.3 %SetIteratorPrototype%[@@toStringTag]
setToStringTag(Constructor, NAME + ' Iterator');
$define(PROTO, NAME, {
// 22.1.3.4 Array.prototype.entries()
// 23.1.3.4 Map.prototype.entries()
// 23.2.3.5 Set.prototype.entries()
entries: createIteratorFactory(Constructor, KEY+VALUE),
// 22.1.3.13 Array.prototype.keys()
// 23.1.3.8 Map.prototype.keys()
// 23.2.3.8 Set.prototype.keys()
keys: createIteratorFactory(Constructor, KEY),
// 22.1.3.29 Array.prototype.values()
// 23.1.3.11 Map.prototype.values()
// 23.2.3.10 Set.prototype.values()
values: createIteratorFactory(Constructor, VALUE)
});
// 22.1.3.30 Array.prototype[@@iterator]()
// 23.1.3.12 Map.prototype[@@iterator]()
// 23.2.3.11 Set.prototype[@@iterator]()
Base && defineIterator(Base, NAME, createIteratorFactory(Constructor, DEFAULT));
}
function createIteratorFactory(Constructor, kind){
return function(){
return new constructor(this, kind);
return new Constructor(this, kind);
}
}
function defineIterator(Constructor, NAME, value){
var proto = Constructor[PROTOTYPE]
, has$$ITERATOR = has(proto, $$ITERATOR);
var iter = has(proto, ITERATOR)
? proto[ITERATOR]
: has$$ITERATOR
? proto[$$ITERATOR]
: value;
if(framework){
// Define iterator
!has(proto, ITERATOR) && hidden(proto, ITERATOR, iter);
// FF fix
if(has$$ITERATOR)hidden(getPrototypeOf(iter.call(new Constructor)), ITERATOR, returnThis);
// Add iterator for FF iterator protocol
else FFITERATOR && hidden(proto, $$ITERATOR, iter);
}
// Plug for library
Iterators[NAME] = iter;
// FF & v8 fix
Iterators[NAME + ' Iterator'] = returnThis;
}
// 22.1.5.1 CreateArrayIterator Abstract Operation
function ArrayIterator(iterated, kind){
this[ITERATED] = ES5Object(iterated);
this[KIND] = kind;
this[INDEX] = 0;
set(this, ITERATED, ES5Object(iterated));
set(this, KIND, kind);
set(this, INDEX, 0);
}
ArrayIterator[PROTOTYPE] = {
next: function(){
var that = this
, iterated = that[ITERATED]
, index = that[INDEX]++;
if(index >= iterated.length)return createIterResultObject(undefined, 1);
switch(that[KIND]){
case KEY : return createIterResultObject(index, 0);
case VALUE : return createIterResultObject(iterated[index], 0);
}
return createIterResultObject([index, iterated[index]], 0);
}
};
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
createIteratorClass(ArrayIterator, ARRAY, Array, function(){
var iterated = this[ITERATED]
, index = this[INDEX]++
, kind = this[KIND]
, value;
if(index >= iterated.length)return createIterResultObject(1);
if(kind == KEY) value = index;
else if(kind == VALUE)value = iterated[index];
else value = [index, iterated[index]];
return createIterResultObject(0, value);
}, VALUE);
// 21.1.3.27 String.prototype[@@iterator]() - SHAM, TODO
defineIterator(String, STRING, Iterators[ARRAY]);
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
Iterators[ARGUMENTS] = Iterators[ARRAY];
// 23.1.5.1 CreateMapIterator Abstract Operation
function MapIterator(iterated, kind){
this[ITERATED] = iterated;
this[KIND] = kind;
this[INDEX] = 0;
iterated.forEach(function(val, key){
var that = this, keys;
if(Map[SHIM])keys = getValues(iterated[COLLECTION_KEYS]);
else Map[PROTOTYPE][FOR_EACH].call(iterated, function(val, key){
this.push(key);
}, this[KEYS] = []);
}, keys = []);
set(that, ITERATED, iterated);
set(that, KIND, kind);
set(that, INDEX, 0);
set(that, KEYS, keys);
}
MapIterator[PROTOTYPE] = {
next: function(){
var iterated = this[ITERATED]
, keys = this[KEYS]
, index = this[INDEX]++
, key;
if(index >= keys.length)return createIterResultObject(undefined, 1);
key = keys[index];
switch(this[KIND]){
case KEY : return createIterResultObject(key, 0);
case VALUE : return createIterResultObject(iterated.get(key), 0);
}
return createIterResultObject([key, iterated.get(key)], 0);
}
};
// 23.1.5.2.1 %MapIteratorPrototype%.next()
createIteratorClass(MapIterator, MAP, Map, function(){
var that = this
, iterated = that[ITERATED]
, keys = that[KEYS]
, index = that[INDEX]++
, kind = that[KIND]
, key, value;
if(index >= keys.length)return createIterResultObject(1);
key = keys[index];
if(kind == KEY) value = key;
else if(kind == VALUE)value = iterated.get(key);
else value = [key, iterated.get(key)];
return createIterResultObject(0, value);
}, KEY+VALUE);
// 23.2.5.1 CreateSetIterator Abstract Operation
function SetIterator(iterated, kind){
this[KIND] = kind;
this[INDEX] = 0;
iterated.forEach(function(val){
var keys;
if(Set[SHIM])keys = getValues(iterated[COLLECTION_KEYS]);
else Set[PROTOTYPE][FOR_EACH].call(iterated, function(val){
this.push(val);
}, this[KEYS] = []);
}, keys = []);
set(this, KIND, kind);
set(this, KEYS, keys.reverse());
}
SetIterator[PROTOTYPE] = {
next: function(){
var keys = this[KEYS]
, index = this[INDEX]++
, key;
if(index >= keys.length)return createIterResultObject(undefined, 1);
key = keys[index];
if(this[KIND] == VALUE)return createIterResultObject(key, 0);
return createIterResultObject([key, key], 0);
}
};
// 23.2.5.2.1 %SetIteratorPrototype%.next()
createIteratorClass(SetIterator, SET, Set, function(){
var keys = this[KEYS]
, key;
if(!keys.length)return createIterResultObject(1);
key = keys.pop();
return createIterResultObject(0, this[KIND] == KEY+VALUE ? [key, key] : key);
}, VALUE);
function ObjectIterator(iterated, kind){
this[ITERATED] = iterated;
this[KEYS] = keys(iterated);
this[INDEX] = 0;
this[KIND] = kind;
$for = function(iterable, entries){
if(!(this instanceof $for))return new $for(iterable, entries);
set(this, ITERATED, iterable);
set(this, ENTRIES, entries);
}
ObjectIterator[PROTOTYPE] = {
next: function(){
var index = this[INDEX]++
, object = this[ITERATED]
, keys = this[KEYS]
, key;
if(index >= keys.length)return createIterResultObject(undefined, 1);
key = keys[index];
switch(this[KIND]){
case KEY : return createIterResultObject(key, 0);
case VALUE : return createIterResultObject(object[key], 0);
}
return createIterResultObject([key, object[key]], 0);
}
}
setTag(ArrayIterator, ARRAY + $ITERATOR);
setTag(MapIterator, MAP + $ITERATOR);
setTag(SetIterator, SET + $ITERATOR);
setTag(ObjectIterator, OBJECT + $ITERATOR);
ArrayIterator[PROTOTYPE][ITERATOR] = MapIterator[PROTOTYPE][ITERATOR] =
SetIterator[PROTOTYPE][ITERATOR] = ObjectIterator[PROTOTYPE][ITERATOR] = returnThis;
function defineIterator(object, value){
has(object, ITERATOR) || (object[ITERATOR] = value);
}
isIterable = function(it){
if(it != undefined && isFunction(it[ITERATOR]))return true;
// plug for library. TODO: correct proto check
switch(it && it.constructor){
case String: case Array: case Map: case Set: return true;
case Object: return classof(it) == ARGUMENTS;
} return false;
}
getIterator = function(it){
if(it != undefined && isFunction(it[ITERATOR]))return it[ITERATOR]();
// plug for library. TODO: correct proto check
switch(it && it.constructor){
case Object : if(classof(it) != ARGUMENTS)break;
case String :
case Array : return new ArrayIterator(it, VALUE);
case Map : return new MapIterator(it, KEY+VALUE);
case Set : return new SetIterator(it, VALUE);
} throw TypeError(it + ' is not iterable!');
}
forOf = function(it, fn, that, entries){
var iterator = getIterator(it), step, value;
$for[PROTOTYPE].of = function(fn, that){
var iterator = getIterator(this[ITERATED])
, entries = this[ENTRIES]
, f = ctx(fn, that, entries ? 2 : 1)
, step;
while(!(step = iterator.next()).done){
if((entries ? fn.apply(that, ES5Object(step.value)) : fn.call(that, step.value)) === false)return;
if((entries ? invoke(f, step.value) : f(step.value)) === false)return;
}
}
// v8 & FF fix
isFunction($Array.keys) && defineIterator(getPrototypeOf([].keys()), returnThis);
//isFunction(Set[PROTOTYPE].keys) && defineIterator(getPrototypeOf(new Set().keys()), returnThis);
//isFunction(Map[PROTOTYPE].keys) && defineIterator(getPrototypeOf(new Map().keys()), returnThis);
$define(PROTO, ARRAY, {
// 22.1.3.4 Array.prototype.entries()
entries: createIteratorFactory(ArrayIterator, KEY+VALUE),
// 22.1.3.13 Array.prototype.keys()
keys: createIteratorFactory(ArrayIterator, KEY),
// 22.1.3.29 Array.prototype.values()
values: createIteratorFactory(ArrayIterator, VALUE)
});
$define(PROTO, MAP, {
// 23.1.3.4 Map.prototype.entries()
entries: createIteratorFactory(MapIterator, KEY+VALUE),
// 23.1.3.8 Map.prototype.keys()
keys: createIteratorFactory(MapIterator, KEY),
// 23.1.3.11 Map.prototype.values()
values: createIteratorFactory(MapIterator, VALUE)
});
$define(PROTO, SET, {
// 23.2.3.5 Set.prototype.entries()
entries: createIteratorFactory(SetIterator, KEY+VALUE),
// 23.2.3.8 Set.prototype.keys()
keys: createIteratorFactory(SetIterator, VALUE),
// 23.2.3.10 Set.prototype.values()
values: createIteratorFactory(SetIterator, VALUE)
});
if(framework){
// 21.1.3.27 String.prototype[@@iterator]()
defineIterator(String[PROTOTYPE], createIteratorFactory(ArrayIterator, VALUE));
// 22.1.3.30 Array.prototype[@@iterator]()
defineIterator($Array, $Array.values);
// 23.1.3.12 Map.prototype[@@iterator]()
defineIterator(Map[PROTOTYPE], createIteratorFactory(MapIterator, KEY+VALUE));
// 23.2.3.11 Set.prototype[@@iterator]()
defineIterator(Set[PROTOTYPE], createIteratorFactory(SetIterator, VALUE));
$for.isIterable = isIterable = function(it){
return (it != undefined && ITERATOR in it) || has(Iterators, classof(it));
}
function createObjectIteratorFactory(kind){
return function(it){
return new ObjectIterator(it, kind);
}
$for.getIterator = getIterator = function(it){
return assertObject((it[ITERATOR] || Iterators[classof(it)]).call(it));
}
objectIterators = {
keys: createObjectIteratorFactory(KEY),
values: createObjectIteratorFactory(VALUE),
entries: createObjectIteratorFactory(KEY+VALUE)
}
$define(GLOBAL, {forOf: forOf});
}(' Iterator', 1, 2, symbol('iterated'), symbol('kind'), symbol('index'), symbol('keys'), Function('return this'));
$define(GLOBAL, {$for: $for});
}('@@iterator');

@@ -5,59 +5,107 @@ /**

* https://github.com/domenic/promises-unwrapping
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
* http://caniuse.com/promises
* Based on:
* https://github.com/jakearchibald/ES6-Promises
* Alternatives:
* https://github.com/paulmillr/es6-shim
* Based on https://github.com/getify/native-promise-only/
*/
!function(Promise, $Promise){
isFunction(Promise)
&& isFunction(Promise.resolve) && isFunction(Promise.reject) && isFunction(Promise.all) && isFunction(Promise.race)
&& (function(promise){
return Promise.resolve(promise) === promise;
})(new Promise(Function()))
|| !function(SUBSCRIBERS, STATE, DETAIL, SEALED, FULFILLED, REJECTED, PENDING){
// microtask or, if not possible, macrotask
var asap =
isNode ? process.nextTick :
Promise && isFunction(Promise.resolve) ? function(fn){ $Promise.resolve().then(fn); } :
setImmediate;
// 25.4.3 The Promise Constructor
!function(Promise){
isFunction(Promise) && isFunction(Promise.resolve)
&& function(promise){
return Promise.resolve(promise) == promise;
}(new Promise(Function()))
|| !function(asap, DEF){
function isThenable(o){
var then;
if(isObject(o))then = o.then;
return isFunction(then) ? then : false;
}
function notify(def){
var chain = def.chain;
chain.length && asap(function(){
var msg = def.msg
, ok = def.state == 1
, i = 0;
while(chain.length > i)!function(react){
var cb = ok ? react.ok : react.fail
, ret, then;
try {
if(cb){
ret = cb === true ? msg : cb(msg);
if(ret === react.P){
react.rej(TypeError(PROMISE + '-chain cycle'));
} else if(then = isThenable(ret)){
then.call(ret, react.res, react.rej);
} else react.res(ret);
} else react.rej(msg);
} catch(err){
react.rej(err);
}
}(chain[i++]);
chain.length = 0;
});
}
function resolve(msg){
var def = this
, then, wrapper;
if(def.done)return;
def.done = true;
def = def.def || def; // unwrap
try {
if(then = isThenable(msg)){
wrapper = {def: def, done : false}; // wrap
then.call(msg, ctx(resolve, wrapper, 1), ctx(reject, wrapper, 1));
} else {
def.msg = msg;
def.state = 1;
notify(def);
}
} catch(err){
reject.call(wrapper || {def: def, done : false}, err); // wrap
}
}
function reject(msg){
var def = this;
if(def.done)return;
def.done = true;
def = def.def || def; // unwrap
def.msg = msg;
def.state = 2;
notify(def);
}
// 25.4.3.1 Promise(executor)
Promise = function(executor){
var promise = this
, rejectPromise = part.call(handle, promise, REJECTED);
assertInstance(promise, Promise, PROMISE);
assertFunction(executor);
promise[SUBSCRIBERS] = [];
assertInstance(this, Promise, PROMISE);
var def = {chain: [], state: 0, done : false, msg: undefined};
set(this, DEF, def);
try {
executor(part.call(resolve, promise), rejectPromise);
} catch(e){
rejectPromise(e);
executor(ctx(resolve, def, 1), ctx(reject, def, 1));
} catch(err){
reject.call(def, err);
}
}
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
hidden(Promise[PROTOTYPE], 'then', function(onFulfilled, onRejected){
var react = {
ok: isFunction(onFulfilled) ? onFulfilled : true,
fail: isFunction(onRejected) ? onRejected : false
} , P = react.P = new this[CONSTRUCTOR](function(resolve, reject){
react.res = assertFunction(resolve);
react.rej = assertFunction(reject);
}), def = this[DEF];
def.chain.push(react);
def.state && notify(def);
return P;
});
// 25.4.5.1 Promise.prototype.catch(onRejected)
Promise[PROTOTYPE]['catch'] = function(onRejected){
hidden(Promise[PROTOTYPE], 'catch', function(onRejected){
return this.then(undefined, onRejected);
},
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
Promise[PROTOTYPE].then = function(onFulfilled, onRejected){
var promise = this
, thenPromise = new Promise(Function())
, args = [onFulfilled, onRejected];
if(promise[STATE])asap(function(){
invokeCallback(promise[STATE], thenPromise, args[promise[STATE] - 1], promise[DETAIL]);
});
else promise[SUBSCRIBERS].push(thenPromise, onFulfilled, onRejected);
return thenPromise;
}
});
// 25.4.4.1 Promise.all(iterable)
Promise.all = function(iterable){
var C = this
, values = [];
return new C(function(resolve, reject){
forOf(iterable, push, values);
hidden(Promise, 'all', function(iterable){
var Promise = this
, values = [];
return new Promise(function(resolve, reject){
$for(iterable).of(push, values);
var remaining = values.length
, results = Array(remaining);
if(remaining)$forEach(values, function(promise, index){
C.resolve(promise).then(function(value){
if(remaining)forEach.call(values, function(promise, index){
Promise.resolve(promise).then(function(value){
results[index] = value;

@@ -69,86 +117,27 @@ --remaining || resolve(results);

});
}
});
// 25.4.4.4 Promise.race(iterable)
Promise.race = function(iterable){
var C = this;
return new C(function(resolve, reject){
forOf(iterable, function(promise){
C.resolve(promise).then(resolve, reject)
hidden(Promise, 'race', function(iterable){
var Promise = this;
return new Promise(function(resolve, reject){
$for(iterable).of(function(promise){
Promise.resolve(promise).then(resolve, reject);
});
});
}
});
// 25.4.4.5 Promise.reject(r)
Promise.reject = function(r){
hidden(Promise, 'reject', function(r){
return new this(function(resolve, reject){
reject(r);
});
}
});
// 25.4.4.6 Promise.resolve(x)
Promise.resolve = function(x){
hidden(Promise, 'resolve', function(x){
return isObject(x) && getPrototypeOf(x) === this[PROTOTYPE] ? x : new this(function(resolve, reject){
resolve(x);
});
}
function invokeCallback(settled, promise, callback, detail){
var hasCallback = isFunction(callback)
, value, succeeded, failed;
if(hasCallback){
try {
value = callback(detail);
succeeded = 1;
} catch(e){
failed = 1;
value = e;
}
} else {
value = detail;
succeeded = 1;
}
if(handleThenable(promise, value))return;
else if(hasCallback && succeeded)resolve(promise, value);
else if(failed)handle(promise, REJECTED, value);
else if(settled == FULFILLED)resolve(promise, value);
else if(settled == REJECTED)handle(promise, REJECTED, value);
}
function handleThenable(promise, value){
var resolved;
try {
assert(promise !== value, "A promises callback can't return that same promise.");
if(value && isFunction(value.then)){
value.then(function(val){
if(resolved)return true;
resolved = true;
if(value !== val)resolve(promise, val);
else handle(promise, FULFILLED, val);
}, function(val){
if(resolved)return true;
resolved = true;
handle(promise, REJECTED, val);
});
return 1;
}
} catch(error){
if(!resolved)handle(promise, REJECTED, error);
return 1;
}
}
function resolve(promise, value){
if(promise === value || !handleThenable(promise, value))handle(promise, FULFILLED, value);
}
function handle(promise, state, reason){
if(promise[STATE] === PENDING){
promise[STATE] = SEALED;
promise[DETAIL] = reason;
asap(function(){
promise[STATE] = state;
for(var subscribers = promise[SUBSCRIBERS], i = 0; i < subscribers.length; i += 3){
invokeCallback(state, subscribers[i], subscribers[i + state], promise[DETAIL]);
}
promise[SUBSCRIBERS] = undefined;
});
}
}
}(symbol('subscribers'), symbol('state'), symbol('detail'), 0, 1, 2);
setTag(Promise, PROMISE)
$define(GLOBAL, {Promise: Promise}, 1);
}(Promise, Promise);
});
}(nextTick || setImmediate, symbol('def'));
setToStringTag(Promise, PROMISE);
$define(GLOBAL + FORCED * !isNative(Promise), {Promise: Promise});
}(global[PROMISE]);
/**
* ECMAScript 6 Symbol
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects
* Alternatives:
* http://webreflection.blogspot.com.au/2013/03/simulating-es6-symbols-in-es5.html
* https://github.com/seanmonstar/symbol
*/
!function(Symbol, SYMBOL, TAG, SymbolRegistry, FFITERATOR){
// 19.4.1 The Symbol Constructor
!function(TAG, $ITERATOR, $TOSTRINGTAG, SymbolRegistry){
// 19.4.1.1 Symbol([description])
if(!isNative(Symbol)){
Symbol = function(description){
if(!(this instanceof Symbol))return new Symbol(description);
var tag = symbol(description);
defineProperty($Object, tag, {
assert(!(this instanceof Symbol), SYMBOL + ' is not a ' + CONSTRUCTOR);
var tag = uid(description);
defineProperty(ObjectProto, tag, {
configurable: true,
set: function(value){

@@ -19,24 +18,30 @@ hidden(this, tag, value);

});
hidden(this, TAG, tag);
return hidden(create(Symbol[PROTOTYPE]), TAG, tag);
}
Symbol[PROTOTYPE].toString = Symbol[PROTOTYPE].valueOf = function(){
hidden(Symbol[PROTOTYPE], TO_STRING, function(){
return this[TAG];
}
});
}
$define(GLOBAL, {Symbol: wrapGlobalConstructor(Symbol)}, 1);
ITERATOR = $ITERATOR in Symbol
? Symbol[$ITERATOR]
: uid(SYMBOL + '.' + $ITERATOR);
TOSTRINGTAG = $TOSTRINGTAG in Symbol
? Symbol[$TOSTRINGTAG]
: Symbol(SYMBOL + '.' + $TOSTRINGTAG);
$define(GLOBAL + WRAP, {Symbol: Symbol});
$define(STATIC, SYMBOL, {
// 19.4.2.2 Symbol.for(key)
'for': function(key){
return has(SymbolRegistry, key) ? SymbolRegistry[key] : SymbolRegistry[key] = Symbol(key);
return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = Symbol(key);
},
// 19.4.2.6 Symbol.iterator
iterator: ITERATOR = Symbol.iterator || FFITERATOR in $Array ? FFITERATOR : Symbol(SYMBOL + '.iterator'),
iterator: ITERATOR,
// 19.4.2.7 Symbol.keyFor(sym)
keyFor: function(sym){
for(var key in SymbolRegistry)if(SymbolRegistry[key] === sym)return key;
},
keyFor: part.call(keyOf, SymbolRegistry),
// 19.4.2.10 Symbol.toStringTag
toStringTag: TOSTRINGTAG = Symbol.toStringTag || Symbol(SYMBOL + '.toStringTag')
toStringTag: TOSTRINGTAG,
pure: symbol,
set: set
});
setTag(Symbol, SYMBOL);
}(global.Symbol, 'Symbol', symbol('tag'), {}, '@@iterator');
setToStringTag(Symbol, SYMBOL);
}(symbol('tag'), 'iterator', TO_STRING + 'Tag', {});
/**
* 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){
// 20.2.2.28 Math.sign(x)
function sign(it){

@@ -24,4 +20,5 @@ return (it = +it) == 0 || it != it ? it : it < 0 ? -1 : 1;

// Works with __proto__ only. Old v8 can't works with null proto objects.
__PROTO__ && (function(set, buggy){
try { set({}, $Array) }
__PROTO__ && function(set){
var buggy;
try { set({}, ArrayProto) }
catch(e){ buggy = true }

@@ -31,3 +28,3 @@ $define(STATIC, OBJECT, {

assertObject(O);
assert(isObject(proto) || proto === null, "Can't set", proto, 'as prototype');
assert(proto === null || isObject(proto), proto, ": can't set as prototype!");
if(buggy)O.__proto__ = proto;

@@ -38,3 +35,3 @@ else set(O, proto);

});
})(unbind(getOwnPropertyDescriptor($Object, '__proto__').set));
}(ctx(call, getOwnDescriptor(ObjectProto, '__proto__').set, 2));
$define(STATIC, NUMBER, {

@@ -53,3 +50,3 @@ // 20.1.2.1 Number.EPSILON

isNaN: function(number){
return typeof number == 'number' && number != number;
return number != number;
},

@@ -73,7 +70,8 @@ // 20.1.2.5 Number.isSafeInteger(number)

, log = Math.log
, sqrt = Math.sqrt;
, sqrt = Math.sqrt
, Oxffff = 0xffff;
function asinh(x){
return !isFinite(x = +x) || x === 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));
}
$define(STATIC, 'Math', {
$define(STATIC, MATH, {
// 20.2.2.3 Math.acosh(x)

@@ -90,3 +88,3 @@ // Returns an implementation-dependent approximation to the inverse hyperbolic cosine of x.

atanh: function(x){
return x === 0 ? x : 0.5 * log((1 + x) / (1 - x));
return x === 0 ? x : .5 * log((1 + x) / (1 - x));
},

@@ -96,8 +94,7 @@ // 20.2.2.9 Math.cbrt(x)

cbrt: function(x){
return sign(x) * pow(abs(x), 1/3);
return sign(x) * pow(abs(x), 1 / 3);
},
// 20.2.2.11 Math.clz32 (x)
clz32: function(x){
x = x >>> 0;
return x ? 32 - x.toString(2).length : 32;
return (x >>>= 0) ? 32 - x[TO_STRING](2).length : 32;
},

@@ -115,3 +112,3 @@ // 20.2.2.12 Math.cosh(x)

// 20.2.2.16 Math.fround(x)
// fround: function(x){ TODO },
// TODO
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])

@@ -133,7 +130,7 @@ // Returns an implementation-dependent approximation of the square root

imul: function(x, y){
var xh = (x >>> 0x10) & 0xffff
, xl = x & 0xffff
, yh = (y >>> 0x10) & 0xffff
, yl = y & 0xffff;
return xl * yl + (((xh * yl + xl * yh) << 0x10) >>> 0) | 0;
var xh = Oxffff & x >>> 0x10
, xl = Oxffff & x
, yh = Oxffff & y >>> 0x10
, yl = Oxffff & y;
return 0 | xl * yl + (xh * yl + xl * yh << 0x10 >>> 0);
},

@@ -162,3 +159,3 @@ // 20.2.2.20 Math.log1p(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;
},

@@ -178,14 +175,10 @@ // 20.2.2.33 Math.tanh(x)

// 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 }
});
*/
setToStringTag(Math, MATH, true);
// 21.1.2.2 String.fromCodePoint(...codePoints)
// TODO
// 21.1.2.4 String.raw(callSite, ...substitutions)
// TODO
$define(PROTO, STRING, {
// 21.1.3.3 String.prototype.codePointAt(pos)
// codePointAt: function(pos /* = 0 * /){ TODO },
// TODO
// 21.1.3.6 String.prototype.contains(searchString, position = 0)

@@ -197,17 +190,21 @@ contains: function(searchString, position /* = 0 */){

endsWith: function(searchString, endPosition /* = @length */){
var length = this.length;
var length = this.length
, end = toLength(min(endPosition === undefined ? length : endPosition, length));
searchString += '';
endPosition = toLength(min(endPosition === undefined ? length : endPosition, length));
return String(this).slice(endPosition - searchString.length, endPosition) === searchString;
return String(this).slice(end - searchString.length, end) === searchString;
},
// 21.1.3.13 String.prototype.repeat(count)
repeat: function(count){
assert(0 <= (count |= 0), "Count can't be negative");
return Array(count + 1).join(this);
var str = '' + this
, result = ''
, n = toInteger(count);
assert(0 <= n, "Count can't be negative");
for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)result += str;
return result;
},
// 21.1.3.18 String.prototype.startsWith(searchString [, position ])
startsWith: function(searchString, position /* = 0 */){
var index = toLength(min(position, this.length));
searchString += '';
position = toLength(min(position, this.length));
return String(this).slice(position, position + searchString.length) === searchString;
return String(this).slice(index, index + searchString.length) === searchString;
}

@@ -218,53 +215,53 @@ });

from: function(arrayLike, mapfn /* -> it */, thisArg /* = undefind */){
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]);
var O = ES5Object(arrayLike)
, result = new (generic(this, Array))
, mapping = mapfn !== undefined
, index = 0
, length, f;
if(mapping)f = ctx(mapfn, thisArg, 2);
if($for && isIterable(O))$for(O).of(function(value){
result[index] = mapping ? f(value, index) : value;
index++;
});
else for(length = toLength(O.length); length > index; index++){
result[index] = mapping ? f(O[index], index) : O[index];
}
result.length = index;
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++]);
of: function(/* ...args */){
var index = 0
, length = arguments.length
, result = new (generic(this, Array))(length);
while(length > index)result[index] = arguments[index++];
result.length = length;
return result;
}
});
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;
}
$define(PROTO, ARRAY, {
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
// copyWithin: function(target, start, end){ TODO },
// 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;
var length = toLength(this.length)
, index = toInteger(start)
, endPos;
if(index < 0)index = max(index + length, 0);
if(end === undefined)endPos = length;
else {
endPos = toInteger(end);
if(endPos < 0)endPos += length;
endPos = min(endPos, length);
}
while(endPos > index)this[index++] = value;
return this;
},
// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
find: function(predicate, thisArg /* = undefind */){
var index = findIndex.call(this, predicate, thisArg);
if(~index)return ES5Object(this)[index];
},
find: createArrayMethod(5),
// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
findIndex: findIndex
findIndex: createArrayMethod(6)
});
// 24.3.3 JSON [ @@toStringTag ]
setTag(global.JSON, 'JSON', 1);
setToStringTag(global.JSON, 'JSON', true);
}(isFinite);

@@ -1,13 +0,11 @@

$define(STATIC, FUNCTION, {
isFunction: isFunction,
isNative: isNative
});
$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));
var instance = create(assertFunction(this)[PROTOTYPE])
, result = invoke(this, args, instance);
return isObject(result) ? result : instance;
},
invoke: function(args, that){
return invoke(this, args, that);
}
});

@@ -10,16 +10,20 @@ /**

// Node.js 0.9+ & IE10+ has setImmediate, else:
isFunction(setImmediate) && isFunction(clearImmediate) || !function(postMessage, MessageChannel,
ONREADYSTATECHANGE, IMMEDIATE_PREFIX, counter, queue, defer, channel){
isFunction(setImmediate) && isFunction(clearImmediate) || function(ONREADYSTATECHANGE){
var postMessage = global.postMessage
, addEventListener = global.addEventListener
, MessageChannel = global.MessageChannel
, counter = 0
, queue = {}
, defer, channel, port;
setImmediate = function(fn){
var id = IMMEDIATE_PREFIX + ++counter
, args = [], i = 1;
var args = [], i = 1;
while(arguments.length > i)args.push(arguments[i++]);
queue[id] = function(){
(isFunction(fn) ? fn : Function(fn)).apply(undefined, args);
queue[++counter] = function(){
invoke(isFunction(fn) ? fn : Function(fn), args);
}
defer(id);
defer(counter);
return counter;
}
clearImmediate = function(id){
delete queue[IMMEDIATE_PREFIX + id];
delete queue[id];
}

@@ -37,9 +41,9 @@ function run(id){

// Node.js 0.8-
if(isNode){
if(NODE){
defer = function(id){
process.nextTick(part.call(run, id));
nextTick(part.call(run, id));
}
// Modern browsers, skip implementation for WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is object
} else if(isFunction(postMessage) && !global.importScripts){
} else if(addEventListener && isFunction(postMessage) && !global.importScripts){
defer = function(id){

@@ -52,13 +56,12 @@ postMessage(id, '*');

channel = new MessageChannel();
port = channel.port2;
channel.port1.onmessage = listner;
defer = ctx(channel.port2.postMessage, channel.port2);
defer = ctx(port.postMessage, port, 1);
// IE8-
} else if(document && ONREADYSTATECHANGE in document[CREATE_ELEMENT]('script')){
defer = function(id){
var el = document[CREATE_ELEMENT]('script');
el[ONREADYSTATECHANGE] = function(){
el.parentNode.removeChild(el);
html.appendChild(document[CREATE_ELEMENT]('script'))[ONREADYSTATECHANGE] = function(){
html.removeChild(this);
run(id);
}
document.documentElement.appendChild(el);
}

@@ -71,4 +74,6 @@ // Rest old browsers

}
}(global.postMessage, global.MessageChannel, 'onreadystatechange', symbol('immediate'), 0, {});
$defineTimer('setImmediate', setImmediate);
$defineTimer('clearImmediate', clearImmediate);
}('onreadystatechange');
$define(GLOBAL + BIND, {
setImmediate: setImmediate,
clearImmediate: clearImmediate
});

@@ -1,8 +0,3 @@

$define(STATIC, NUMBER, {
/**
* Alternatives:
* http://mootools.net/docs/core/Types/Number#Number:toInt
*/
toInteger: toInteger
});
// Number.toInteger was part of the draft ECMAScript 6 specification, but has been removed
$define(STATIC, NUMBER, {toInteger: toInteger});
$define(PROTO, NUMBER, {

@@ -17,13 +12,17 @@ /**

*/
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++;
times: function(mapfn /* = -> it */, thisArg /* = undefined */){
var number = +this
, length = toLength(number)
, result = Array(length)
, i = 0
, f;
if(isFunction(mapfn)){
f = ctx(mapfn, thisArg, 3);
while(length > i)result[i] = f(i, i++, number);
} else while(length > i)result[i] = i++;
return result;
},
random: function(number /* = 0 */){
var a = +this || 0
, b = +number || 0
random: function(lim /* = 0 */){
var a = +this
, b = lim == undefined ? 0 : +lim
, m = min(a, b);

@@ -33,13 +32,8 @@ return random() * (max(a, b) - m) + m;

});
$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);
$define(STATIC, MATH, {
randomInt: function(lim1 /* = 0 */, lim2 /* = 0 */){
var a = toInteger(lim1)
, b = toInteger(lim2)
, m = min(a, b);
return floor(random() * (max(a, b) + 1 - m) + m);
}

@@ -53,23 +47,22 @@ });

*/
$define(PROTO, NUMBER, transform.call(
// IE... getOwnPropertyNames(Math)
$define(PROTO, NUMBER, turn.call(
// IE... getNames(Math)
array(
// ES3
// ES3:
'round,floor,ceil,abs,sin,asin,cos,acos,tan,atan,exp,sqrt,max,min,pow,atan2,' +
// ES6
// ES6:
'acosh,asinh,atanh,cbrt,clz32,cosh,expm1,hypot,imul,log1p,log10,log2,sign,sinh,tanh,trunc,' +
// Core.js
// Core:
'randomInt'
),
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])
var fn = Math[key];
if(fn)memo[key] = 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 invoke(fn, args);
}
}, {}
));

@@ -1,68 +0,55 @@

$define(STATIC, OBJECT, {
/**
* Alternatives:
* http://underscorejs.org/#has
* http://sugarjs.com/api/Object/has
*/
isEnumerable: unbind(isEnumerable),
isPrototype: unbind($Object.isPrototypeOf),
// http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api
getPropertyDescriptor: getPropertyDescriptor,
!function(){
var getSymbols = Object.getOwnPropertySymbols
, getPropertyKeys = getSymbols
? function(it){
return getNames(it).concat(getSymbols(it));
}
: getNames;
// 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
// https://gist.github.com/WebReflection/9353781
function getOwnPropertyDescriptors(object){
var result = {}
, keys = getPropertyKeys(object)
, length = keys.length
, i = 0
, 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)result[i] = [key = names[i++], O[key]];
while(length > i)result[key = keys[i++]] = getOwnDescriptor(object, 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
});
}
$define(STATIC, OBJECT, {
isPrototype: ctx(call, ObjectProto.isPrototypeOf, 2),
getOwnPropertyKeys: getPropertyKeys,
// http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api
getPropertyDescriptor: function(object, key){
var O = object;
if(key in O)do {
if(has(O, key))return getOwnDescriptor(O, key);
} while(O = getPrototypeOf(O));
},
// 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 assign(create(proto), 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: createObjectToArray(false),
// ~ ES7 : http://esdiscuss.org/topic/april-8-2014-meeting-notes#content-1
entries: createObjectToArray(true),
isObject: isObject,
classof: classof
});
}();

@@ -1,14 +0,4 @@

!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);
// ~ES7 : https://gist.github.com/kangax/9698100
$define(STATIC, REGEXP, {
escape: createEscaper(/([\\\-[\]{}()*+?.,^$|])/g, '\\$1', true)
});

@@ -9,31 +9,9 @@ !function(){

}
, unescapeHTMLDict = transform.call(keys(escapeHTMLDict), function(memo, key){
, unescapeHTMLDict = turn.call(getKeys(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 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){
return unescapeHTMLDict[part];
});
}
escapeHTML: createEscaper(/[&<>"']/g, escapeHTMLDict),
unescapeHTML: createEscaper(/&(?:amp|lt|gt|quot|apos);/g, unescapeHTMLDict)
});
}();

@@ -5,9 +5,7 @@ /**

* 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);
return function(fn, time /*, ...args */){
return set(invoke(part, slice.call(arguments, 2), isFunction(fn) ? fn : Function(fn)), time || 1);
}

@@ -20,4 +18,6 @@ }

}
$defineTimer('setTimeout', setTimeout);
$defineTimer('setInterval', setInterval);
$define(GLOBAL + BIND + FORCED * !isNative(setTimeout), {
setTimeout: setTimeout,
setInterval: setInterval
});
}(global.navigator);

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 too big to display

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc