123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- 'use strict';
- var ArrayPrototype = Array.prototype;
- var ObjectPrototype = Object.prototype;
- var FunctionPrototype = Function.prototype;
- var StringPrototype = String.prototype;
- var array_slice = ArrayPrototype.slice;
- var _toString = ObjectPrototype.toString;
- var isFunction = function (val) {
- return ObjectPrototype.toString.call(val) === '[object Function]';
- };
- var isArray = function isArray(obj) {
- return _toString.call(obj) === '[object Array]';
- };
- var isString = function isString(obj) {
- return _toString.call(obj) === '[object String]';
- };
- var supportsDescriptors = Object.defineProperty && (function () {
- try {
- Object.defineProperty({}, 'x', {});
- return true;
- } catch (e) {
- return false;
- }
- }());
- var defineProperty;
- if (supportsDescriptors) {
- defineProperty = function (object, name, method, forceAssign) {
- if (!forceAssign && (name in object)) { return; }
- Object.defineProperty(object, name, {
- configurable: true,
- enumerable: false,
- writable: true,
- value: method
- });
- };
- } else {
- defineProperty = function (object, name, method, forceAssign) {
- if (!forceAssign && (name in object)) { return; }
- object[name] = method;
- };
- }
- var defineProperties = function (object, map, forceAssign) {
- for (var name in map) {
- if (ObjectPrototype.hasOwnProperty.call(map, name)) {
- defineProperty(object, name, map[name], forceAssign);
- }
- }
- };
- var toObject = function (o) {
- if (o == null) {
- throw new TypeError("can't convert " + o + ' to object');
- }
- return Object(o);
- };
- function toInteger(num) {
- var n = +num;
- if (n !== n) {
- n = 0;
- } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
- }
- return n;
- }
- function ToUint32(x) {
- return x >>> 0;
- }
- function Empty() {}
- defineProperties(FunctionPrototype, {
- bind: function bind(that) {
-
- var target = this;
-
- if (!isFunction(target)) {
- throw new TypeError('Function.prototype.bind called on incompatible ' + target);
- }
-
-
-
- var args = array_slice.call(arguments, 1);
-
-
-
-
-
-
-
-
-
- var binder = function () {
- if (this instanceof bound) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var result = target.apply(
- this,
- args.concat(array_slice.call(arguments))
- );
- if (Object(result) === result) {
- return result;
- }
- return this;
- } else {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return target.apply(
- that,
- args.concat(array_slice.call(arguments))
- );
- }
- };
-
-
-
-
-
- var boundLength = Math.max(0, target.length - args.length);
-
-
- var boundArgs = [];
- for (var i = 0; i < boundLength; i++) {
- boundArgs.push('$' + i);
- }
-
-
-
-
-
-
- var bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
- if (target.prototype) {
- Empty.prototype = target.prototype;
- bound.prototype = new Empty();
-
- Empty.prototype = null;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return bound;
- }
- });
- defineProperties(Array, { isArray: isArray });
- var boxedString = Object('a');
- var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
- var properlyBoxesContext = function properlyBoxed(method) {
-
- var properlyBoxesNonStrict = true;
- var properlyBoxesStrict = true;
- if (method) {
- method.call('foo', function (_, __, context) {
- if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
- });
- method.call([1], function () {
- 'use strict';
- properlyBoxesStrict = typeof this === 'string';
- }, 'x');
- }
- return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
- };
- defineProperties(ArrayPrototype, {
- forEach: function forEach(fun ) {
- var object = toObject(this),
- self = splitString && isString(this) ? this.split('') : object,
- thisp = arguments[1],
- i = -1,
- length = self.length >>> 0;
-
- if (!isFunction(fun)) {
- throw new TypeError();
- }
- while (++i < length) {
- if (i in self) {
-
-
-
- fun.call(thisp, self[i], i, object);
- }
- }
- }
- }, !properlyBoxesContext(ArrayPrototype.forEach));
- var hasFirefox2IndexOfBug = Array.prototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
- defineProperties(ArrayPrototype, {
- indexOf: function indexOf(sought ) {
- var self = splitString && isString(this) ? this.split('') : toObject(this),
- length = self.length >>> 0;
- if (!length) {
- return -1;
- }
- var i = 0;
- if (arguments.length > 1) {
- i = toInteger(arguments[1]);
- }
-
- i = i >= 0 ? i : Math.max(0, length + i);
- for (; i < length; i++) {
- if (i in self && self[i] === sought) {
- return i;
- }
- }
- return -1;
- }
- }, hasFirefox2IndexOfBug);
- var string_split = StringPrototype.split;
- if (
- 'ab'.split(/(?:ab)*/).length !== 2 ||
- '.'.split(/(.?)(.?)/).length !== 4 ||
- 'tesst'.split(/(s)*/)[1] === 't' ||
- 'test'.split(/(?:)/, -1).length !== 4 ||
- ''.split(/.?/).length ||
- '.'.split(/()()/).length > 1
- ) {
- (function () {
- var compliantExecNpcg = /()??/.exec('')[1] === void 0;
- StringPrototype.split = function (separator, limit) {
- var string = this;
- if (separator === void 0 && limit === 0) {
- return [];
- }
-
- if (_toString.call(separator) !== '[object RegExp]') {
- return string_split.call(this, separator, limit);
- }
- var output = [],
- flags = (separator.ignoreCase ? 'i' : '') +
- (separator.multiline ? 'm' : '') +
- (separator.extended ? 'x' : '') +
- (separator.sticky ? 'y' : ''),
- lastLastIndex = 0,
-
- separator2, match, lastIndex, lastLength;
- separator = new RegExp(separator.source, flags + 'g');
- string += '';
- if (!compliantExecNpcg) {
-
- separator2 = new RegExp('^' + separator.source + '$(?!\\s)', flags);
- }
-
- limit = limit === void 0 ?
- -1 >>> 0 :
- ToUint32(limit);
- while (match = separator.exec(string)) {
-
- lastIndex = match.index + match[0].length;
- if (lastIndex > lastLastIndex) {
- output.push(string.slice(lastLastIndex, match.index));
-
-
- if (!compliantExecNpcg && match.length > 1) {
- match[0].replace(separator2, function () {
- for (var i = 1; i < arguments.length - 2; i++) {
- if (arguments[i] === void 0) {
- match[i] = void 0;
- }
- }
- });
- }
- if (match.length > 1 && match.index < string.length) {
- ArrayPrototype.push.apply(output, match.slice(1));
- }
- lastLength = match[0].length;
- lastLastIndex = lastIndex;
- if (output.length >= limit) {
- break;
- }
- }
- if (separator.lastIndex === match.index) {
- separator.lastIndex++;
- }
- }
- if (lastLastIndex === string.length) {
- if (lastLength || !separator.test('')) {
- output.push('');
- }
- } else {
- output.push(string.slice(lastLastIndex));
- }
- return output.length > limit ? output.slice(0, limit) : output;
- };
- }());
- } else if ('0'.split(void 0, 0).length) {
- StringPrototype.split = function split(separator, limit) {
- if (separator === void 0 && limit === 0) { return []; }
- return string_split.call(this, separator, limit);
- };
- }
- var string_substr = StringPrototype.substr;
- var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';
- defineProperties(StringPrototype, {
- substr: function substr(start, length) {
- return string_substr.call(
- this,
- start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
- length
- );
- }
- }, hasNegativeSubstrBug);
|