forked from alexyoung/ico
-
Notifications
You must be signed in to change notification settings - Fork 25
/
es5-min.js
7 lines (7 loc) · 2.27 KB
/
es5-min.js
1
2
3
4
5
6
7
// ECMAScript 5 compatibility functions
//
// Copyright (c) 2011, Jean Vincent
//
// Licensed under the MIT license
//
Object.keys||(Object.keys=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}),Object.create||(Object.create=function(e){function t(){}if(arguments.length>1)throw new Error("Object.create implementation only accepts the first parameter.");return t.prototype=e,new t}),Function.prototype.bind||(Function.prototype.bind=function(e){if(typeof this!="function")throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=this,n=Array.prototype.slice,r=n.call(arguments,1),i=function(){return t.apply(e||{},r.concat(n.call(arguments)))};return i.prototype=this.prototype,i}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var n=this.length;if(n===0)return-1;t===undefined?t=0:t<0&&(t+=n)<0&&(t=0),t-=1;while(++t<n)if(this[t]===e)return t;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(e,t){var n=this.length;if(n===0)return-1;if(t===undefined)t=n-1;else{if(t<0&&(t+=n)<0)return-1;t>=n&&(t=n-1)}t+=1;while(--t>=0&&this[t]!==e);return t}),Array.prototype.forEach||(Array.prototype.forEach=function(e,t){t||(t=window);var n=-1;while(++n<this.length)n in this&&e.call(t,this[n],n,this)}),Array.prototype.every||(Array.prototype.every=function(e,t){t||(t=window);var n=-1;while(++n<this.length)if(n in this&&!e.call(t,this[n],n,this))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(e,t){t||(t=window);var n=-1;while(++n<this.length)if(n in this&&e.call(t,this[n],n,this))return!0;return!1}),Array.prototype.map||(Array.prototype.map=function(e,t){t||(t=window);var n=[],r=-1;while(++r<this.length)r in this&&(n[r]=e.call(t,this[r],r,this));return n}),Array.prototype.filter||(Array.prototype.filter=function(e,t){t||(t=window);var n=[],r,i=this.length,s=-1;while(++s<i)s in this&&e.call(t,r=this[s],s,this)&&n.push(r);return n}),Array.prototype.reduce||(Array.prototype.reduce=function(e,t){var n=-1;t===undefined&&(t=this[++n]);while(++n<this.length)n in this&&(t=e(t,this[n],n,this));return t}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(e,t){var n=this.length;t===undefined&&(t=this[--n]);while(--n>=0)n in this&&(t=e(t,this[n],n,this));return t});