forked from es-shims/es5-shim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes5-shim.min.js
16 lines (16 loc) · 8.05 KB
/
es5-shim.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(function(q){"function"==typeof define?define(q):"function"==typeof YUI?YUI.add("es5",q):q()})(function(){function q(b){b=+b;b!==b?b=0:0!==b&&(b!==1/0&&b!==-(1/0))&&(b=(0<b||-1)*Math.floor(Math.abs(b)));return b}function t(b){var c=typeof b;return null===b||"undefined"===c||"boolean"===c||"number"===c||"string"===c}Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if("function"!=typeof c)throw new TypeError("Function.prototype.bind called on incompatible "+c);var d=r.call(arguments,
1),a=function(){if(this instanceof a){var e=c.apply(this,d.concat(r.call(arguments)));return Object(e)===e?e:this}return c.apply(b,d.concat(r.call(arguments)))};c.prototype&&(a.prototype=Object.create(c.prototype));return a});var k=Function.prototype.call,n=Object.prototype,r=Array.prototype.slice,h=k.bind(n.toString),u=k.bind(n.hasOwnProperty);u(n,"__defineGetter__")&&(k.bind(n.__defineGetter__),k.bind(n.__defineSetter__),k.bind(n.__lookupGetter__),k.bind(n.__lookupSetter__));if(2!=[1,2].splice(0).length){var y=
Array.prototype.splice;Array.prototype.splice=function(b,c){return!arguments.length?[]:y.apply(this,[b===void 0?0:b,c===void 0?this.length-b:c].concat(r.call(arguments,2)))}}Array.isArray||(Array.isArray=function(b){return h(b)=="[object Array]"});var k=Object("a"),m="a"!=k[0]||!(0 in k);Array.prototype.forEach||(Array.prototype.forEach=function(b,c){var d=l(this),a=m&&h(this)=="[object String]"?this.split(""):d,e=-1,f=a.length>>>0;if(h(b)!="[object Function]")throw new TypeError;for(;++e<f;)e in
a&&b.call(c,a[e],e,d)});Array.prototype.map||(Array.prototype.map=function(b,c){var d=l(this),a=m&&h(this)=="[object String]"?this.split(""):d,e=a.length>>>0,f=Array(e);if(h(b)!="[object Function]")throw new TypeError(b+" is not a function");for(var g=0;g<e;g++)g in a&&(f[g]=b.call(c,a[g],g,d));return f});Array.prototype.filter||(Array.prototype.filter=function(b,c){var d=l(this),a=m&&h(this)=="[object String]"?this.split(""):d,e=a.length>>>0,f=[],g;if(h(b)!="[object Function]")throw new TypeError(b+
" is not a function");for(var p=0;p<e;p++)if(p in a){g=a[p];b.call(c,g,p,d)&&f.push(g)}return f});Array.prototype.every||(Array.prototype.every=function(b,c){var d=l(this),a=m&&h(this)=="[object String]"?this.split(""):d,e=a.length>>>0;if(h(b)!="[object Function]")throw new TypeError(b+" is not a function");for(var f=0;f<e;f++)if(f in a&&!b.call(c,a[f],f,d))return false;return true});Array.prototype.some||(Array.prototype.some=function(b,c){var d=l(this),a=m&&h(this)=="[object String]"?this.split(""):
d,e=a.length>>>0;if(h(b)!="[object Function]")throw new TypeError(b+" is not a function");for(var f=0;f<e;f++)if(f in a&&b.call(c,a[f],f,d))return true;return false});Array.prototype.reduce||(Array.prototype.reduce=function(b){var c=l(this),d=m&&h(this)=="[object String]"?this.split(""):c,a=d.length>>>0;if(h(b)!="[object Function]")throw new TypeError(b+" is not a function");if(!a&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var e=0,f;if(arguments.length>=
2)f=arguments[1];else{do{if(e in d){f=d[e++];break}if(++e>=a)throw new TypeError("reduce of empty array with no initial value");}while(1)}for(;e<a;e++)e in d&&(f=b.call(void 0,f,d[e],e,c));return f});Array.prototype.reduceRight||(Array.prototype.reduceRight=function(b){var c=l(this),d=m&&h(this)=="[object String]"?this.split(""):c,a=d.length>>>0;if(h(b)!="[object Function]")throw new TypeError(b+" is not a function");if(!a&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");
var e,a=a-1;if(arguments.length>=2)e=arguments[1];else{do{if(a in d){e=d[a--];break}if(--a<0)throw new TypeError("reduceRight of empty array with no initial value");}while(1)}do a in this&&(e=b.call(void 0,e,d[a],a,c));while(a--);return e});if(!Array.prototype.indexOf||-1!=[0,1].indexOf(1,2))Array.prototype.indexOf=function(b){var c=m&&h(this)=="[object String]"?this.split(""):l(this),d=c.length>>>0;if(!d)return-1;var a=0;arguments.length>1&&(a=q(arguments[1]));for(a=a>=0?a:Math.max(0,d+a);a<d;a++)if(a in
c&&c[a]===b)return a;return-1};if(!Array.prototype.lastIndexOf||-1!=[0,1].lastIndexOf(0,-3))Array.prototype.lastIndexOf=function(b){var c=m&&h(this)=="[object String]"?this.split(""):l(this),d=c.length>>>0;if(!d)return-1;var a=d-1;arguments.length>1&&(a=Math.min(a,q(arguments[1])));for(a=a>=0?a:d-Math.abs(a);a>=0;a--)if(a in c&&b===c[a])return a;return-1};if(!Object.keys){var w=!0,x="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "),z=x.length,
s;for(s in{toString:null})w=!1;Object.keys=function(b){if(typeof b!="object"&&typeof b!="function"||b===null)throw new TypeError("Object.keys called on a non-object");var c=[],d;for(d in b)u(b,d)&&c.push(d);if(w)for(d=0;d<z;d++){var a=x[d];u(b,a)&&c.push(a)}return c}}if(!Date.prototype.toISOString||-1===(new Date(-621987552E5)).toISOString().indexOf("-000001"))Date.prototype.toISOString=function(){var b,c,d,a;if(!isFinite(this))throw new RangeError("Date.prototype.toISOString called on non-finite value.");
a=this.getUTCFullYear();b=this.getUTCMonth();a=a+Math.floor(b/12);b=[(b%12+12)%12+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()];a=(a<0?"-":a>9999?"+":"")+("00000"+Math.abs(a)).slice(0<=a&&a<=9999?-4:-6);for(c=b.length;c--;){d=b[c];d<10&&(b[c]="0"+d)}return a+"-"+b.slice(0,2).join("-")+"T"+b.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"};s=!1;try{s=Date.prototype.toJSON&&null===(new Date(NaN)).toJSON()&&-1!==(new Date(-621987552E5)).toJSON().indexOf("-000001")&&
Date.prototype.toJSON.call({toISOString:function(){return true}})}catch(G){}s||(Date.prototype.toJSON=function(){var b=Object(this),c;a:if(t(b))c=b;else{c=b.valueOf;if(typeof c==="function"){c=c.call(b);if(t(c))break a}c=b.toString;if(typeof c==="function"){c=c.call(b);if(t(c))break a}throw new TypeError;}if(typeof c==="number"&&!isFinite(c))return null;c=b.toISOString;if(typeof c!="function")throw new TypeError("toISOString property is not callable");return c.call(b)});var g=Date,v=function(b,c){var d=
c>1?1:0;return A[c]+Math.floor((b-1969+d)/4)-Math.floor((b-1901+d)/100)+Math.floor((b-1601+d)/400)+365*(b-1970)},o=function c(d,a,e,f,h,p,i){var j=arguments.length;if(this instanceof g){j=j==1&&String(d)===d?new g(c.parse(d)):j>=7?new g(d,a,e,f,h,p,i):j>=6?new g(d,a,e,f,h,p):j>=5?new g(d,a,e,f,h):j>=4?new g(d,a,e,f):j>=3?new g(d,a,e):j>=2?new g(d,a):j>=1?new g(d):new g;j.constructor=c;return j}return g.apply(this,arguments)},B=RegExp("^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$"),
A=[0,31,59,90,120,151,181,212,243,273,304,334,365],i;for(i in g)o[i]=g[i];o.now=g.now;o.UTC=g.UTC;o.prototype=g.prototype;o.prototype.constructor=o;o.parse=function(c){var d=B.exec(c);if(d){var a=Number(d[1]),e=Number(d[2]||1)-1,f=Number(d[3]||1)-1,h=Number(d[4]||0),i=Number(d[5]||0),k=Number(d[6]||0),j=Number(d[7]||0),m=!d[4]||d[8]?0:Number(new o(1970,0)),l=d[9]==="-"?1:-1,n=Number(d[10]||0),d=Number(d[11]||0);if(h<(i>0||k>0||j>0?24:25)&&i<60&&k<60&&j<1E3&&e>-1&&e<12&&n<24&&d<60&&f>-1&&f<v(a,e+1)-
v(a,e)){a=((v(a,e)+f)*24+h+n*l)*60;a=((a+i+d*l)*60+k)*1E3+j+m;if(-864E13<=a&&a<=864E13)return a}return NaN}return g.parse.apply(this,arguments)};Date=o;Date.now||(Date.now=function(){return(new Date).getTime()});if("0".split(void 0,0).length){var C=String.prototype.split;String.prototype.split=function(c,d){return c===void 0&&d===0?[]:C.apply(this,arguments)}}if("".substr&&"b"!=="0b".substr(-1)){var D=String.prototype.substr;String.prototype.substr=function(c,d){return D.call(this,c<0?(c=this.length+
c)<0?0:c:c,d)}}i="\t\n\x0B\f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff";if(!String.prototype.trim||i.trim()){i="["+i+"]";var E=RegExp("^"+i+i+"*"),F=RegExp(i+i+"*$");String.prototype.trim=function(){if(this===void 0||this===null)throw new TypeError("can't convert "+this+" to object");return String(this).replace(E,"").replace(F,"")}}var l=function(c){if(c==null)throw new TypeError("can't convert "+c+" to object");return Object(c)}});