123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = function(callback) {
- var _arr = this;
- var val, j;
- for (var i in _arr) {
- if (_arr.hasOwnProperty(i)) {
- j = parseInt(i);
- val = _arr[j];
- callback(val, j, _arr);
- }
- }
- }
- }
- if (!Array.prototype.map) {
- Array.prototype.map = function(callback) {
- var _arr = [];
- this.forEach(function(el, i, arr) {
- _arr.push(callback(el, i, arr));
- });
- return _arr;
- }
- }
- if (!Array.prototype.filter) {
- Array.prototype.filter = function(callback) {
- var _arr = [];
- this.forEach(function(el, i, arr) {
- if (callback(el, i, arr)) {
- _arr.push(el);
- }
- });
- return _arr;
- }
- }
- if (!Array.prototype.find) {
- Array.prototype.find = function(callback) {
- var _arr = this;
- var val, j;
- for (var i in _arr) {
- if (_arr.hasOwnProperty(i)) {
- j = parseInt(i);
- val = _arr[j];
- if (callback(val, j, _arr)) {
- return val;
- }
- }
- }
- return null;
- }
- }
- if (!Array.prototype.findIndex) {
- Array.prototype.findIndex = function(callback) {
- var _arr = this;
- var val, j;
- for (var i in _arr) {
- if (_arr.hasOwnProperty(i)) {
- j = parseInt(i);
- val = _arr[j];
- if (callback(val, j, _arr)) {
- return j;
- }
- }
- }
- return -1;
- }
- }
- if (!Array.prototype.reduce) {
- Array.prototype.reduce = function(callback) {
- var _arr = this,
- len = _arr.length,
- a = _arr[0],
- b = _arr[1];
- a = callback(a, b, 0, _arr);
- for (var i = 1; i < len - 2; i++) {
- if (_arr.hasOwnProperty(i)) {
- b = _arr[i + 1];
- a = callback(a, b, i, _arr);
- }
- }
- return a;
- }
- }
- if (!Array.prototype.reduceRight) {
- Array.prototype.reduceRight = function(callback) {
- var _arr = this,
- len = _arr.length,
- a = _arr[len - 1],
- b = _arr[len - 2];
- a = callback(a, b, 0, _arr);
- for (var i = len - 2; i > 0; i--) {
- if (_arr.hasOwnProperty(i)) {
- b = _arr[i - 1];
- a = callback(a, b, len - i - 1, _arr);
- }
- }
- return a;
- }
- }
- if (!Array.prototype.some) {
- Array.prototype.some = function(callback) {
- var _arr = this;
- var val, j;
- for (var i in _arr) {
- if (_arr.hasOwnProperty(i)) {
- j = parseInt(i);
- val = _arr[j];
- if (callback(val, j, _arr)) {
- return true;
- }
- }
- }
- return false;
- }
- }
- if (!Array.prototype.every) {
- Array.prototype.every = function(callback) {
- var _arr = this;
- var val, j;
- for (var i in _arr) {
- if (_arr.hasOwnProperty(i)) {
- j = parseInt(i);
- val = _arr[j];
- if (!callback(val, j, _arr)) {
- return false;
- }
- }
- }
- return true;
- }
- }
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function(el) {
- var _arr = this;
- var val;
- for (var i in _arr) {
- val = _arr[i];
- if (_arr.hasOwnProperty(i) && val === el) {
- return parseInt(i);
- }
- }
- return -1;
- }
- }
- if (!Function.prototype.bind) {
- Function.prototype.bind = function() {
- var fn = this,
- slice = Array.prototype.slice,
- presetArgs = slice.call(arguments),
- context = presetArgs.shift();
- return function() {
- return fn.apply(context, presetArgs.concat(slice.call(arguments)));
- };
- };
- }
- if (typeof Object.assign != 'function') {
- Object.assign = function(target) {
- if (target === undefined || target === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
- var output = Object(target);
- for (var index = 1; index < arguments.length; index++) {
- var source = arguments[index];
- if (source !== undefined && source !== null) {
- for (var nextKey in source) {
- if (source.hasOwnProperty(nextKey)) {
- output[nextKey] = source[nextKey];
- }
- }
- }
- }
- return output;
- };
- }
- if (typeof Object.create !== 'function') {
- Object.create = function(o) {
- function F() {}
- F.prototype = o?o:Object;
- F.prototype.constructor = F;
- return new F();
- };
- }
- if (!Object.keys) {
- Object.keys = (function() {
- 'use strict';
- var hasOwnProperty = Object.prototype.hasOwnProperty,
- hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
- dontEnums = [
- 'toString',
- 'toLocaleString',
- 'valueOf',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'constructor'
- ],
- dontEnumsLength = dontEnums.length;
- return function(obj) {
- if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
- throw new TypeError('Object.keys called on non-object');
- }
- var result = [],
- prop,
- i;
- for (prop in obj) {
- if (hasOwnProperty.call(obj, prop)) {
- result.push(prop);
- }
- }
- if (hasDontEnumBug) {
- for (i = 0; i < dontEnumsLength; i++) {
- if (hasOwnProperty.call(obj, dontEnums[i])) {
- result.push(dontEnums[i]);
- }
- }
- }
- return result;
- };
- }());
- }
- ! function(window) {
- if (!window.console) {
- window.console = {};
- }
- var con = window.console;
- var prop,
- method;
- var dummy = function() {};
- var properties = ['memory'];
- var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEn' +
- 'd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,time' +
- 'line,timelineEnd,timeStamp,trace,warn').split(',');
- while (prop = properties.pop())
- if (!con[prop])
- con[prop] = {};
- while (method = methods.pop())
- if (!con[method])
- con[method] = dummy;
- Array.isArray || (Array.isArray = function(arr) {
- return Object.prototype.toString.call(arr) == '[object Array]';
- });
- Object.is || (Object.is = function is(x, y) {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10 Steps 6.b-6.e: +0 != -0 Added the nonzero y check to make
- // Flow happy, but it is redundant
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
- }
- });
- }(window);
|