angular-pack 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1402 @@
1
+ /*!
2
+ * https://github.com/es-shims/es5-shim
3
+ * @license es5-shim Copyright 2009-2014 by contributors, MIT License
4
+ * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
5
+ */
6
+
7
+ // vim: ts=4 sts=4 sw=4 expandtab
8
+
9
+ //Add semicolon to prevent IIFE from being passed as argument to concated code.
10
+ ;
11
+
12
+ // UMD (Universal Module Definition)
13
+ // see https://github.com/umdjs/umd/blob/master/returnExports.js
14
+ (function (root, factory) {
15
+ if (typeof define === 'function' && define.amd) {
16
+ // AMD. Register as an anonymous module.
17
+ define(factory);
18
+ } else if (typeof exports === 'object') {
19
+ // Node. Does not work with strict CommonJS, but
20
+ // only CommonJS-like enviroments that support module.exports,
21
+ // like Node.
22
+ module.exports = factory();
23
+ } else {
24
+ // Browser globals (root is window)
25
+ root.returnExports = factory();
26
+ }
27
+ }(this, function () {
28
+
29
+ /**
30
+ * Brings an environment as close to ECMAScript 5 compliance
31
+ * as is possible with the facilities of erstwhile engines.
32
+ *
33
+ * Annotated ES5: http://es5.github.com/ (specific links below)
34
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
35
+ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
36
+ */
37
+
38
+ // Shortcut to an often accessed properties, in order to avoid multiple
39
+ // dereference that costs universally.
40
+ var call = Function.prototype.call;
41
+ var prototypeOfArray = Array.prototype;
42
+ var prototypeOfObject = Object.prototype;
43
+ var _Array_slice_ = prototypeOfArray.slice;
44
+ var array_splice = Array.prototype.splice;
45
+ var array_push = Array.prototype.push;
46
+ var array_unshift = Array.prototype.unshift;
47
+
48
+ var isFunction = function (val) {
49
+ return prototypeOfObject.toString.call(val) === '[object Function]';
50
+ };
51
+
52
+ //
53
+ // Function
54
+ // ========
55
+ //
56
+
57
+ // ES-5 15.3.4.5
58
+ // http://es5.github.com/#x15.3.4.5
59
+
60
+ function Empty() {}
61
+
62
+ if (!Function.prototype.bind) {
63
+ Function.prototype.bind = function bind(that) { // .length is 1
64
+ // 1. Let Target be the this value.
65
+ var target = this;
66
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
67
+ if (!isFunction(target)) {
68
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
69
+ }
70
+ // 3. Let A be a new (possibly empty) internal list of all of the
71
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
72
+ // XXX slicedArgs will stand in for "A" if used
73
+ var args = _Array_slice_.call(arguments, 1); // for normal call
74
+ // 4. Let F be a new native ECMAScript object.
75
+ // 11. Set the [[Prototype]] internal property of F to the standard
76
+ // built-in Function prototype object as specified in 15.3.3.1.
77
+ // 12. Set the [[Call]] internal property of F as described in
78
+ // 15.3.4.5.1.
79
+ // 13. Set the [[Construct]] internal property of F as described in
80
+ // 15.3.4.5.2.
81
+ // 14. Set the [[HasInstance]] internal property of F as described in
82
+ // 15.3.4.5.3.
83
+ var binder = function () {
84
+
85
+ if (this instanceof bound) {
86
+ // 15.3.4.5.2 [[Construct]]
87
+ // When the [[Construct]] internal method of a function object,
88
+ // F that was created using the bind function is called with a
89
+ // list of arguments ExtraArgs, the following steps are taken:
90
+ // 1. Let target be the value of F's [[TargetFunction]]
91
+ // internal property.
92
+ // 2. If target has no [[Construct]] internal method, a
93
+ // TypeError exception is thrown.
94
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
95
+ // property.
96
+ // 4. Let args be a new list containing the same values as the
97
+ // list boundArgs in the same order followed by the same
98
+ // values as the list ExtraArgs in the same order.
99
+ // 5. Return the result of calling the [[Construct]] internal
100
+ // method of target providing args as the arguments.
101
+
102
+ var result = target.apply(
103
+ this,
104
+ args.concat(_Array_slice_.call(arguments))
105
+ );
106
+ if (Object(result) === result) {
107
+ return result;
108
+ }
109
+ return this;
110
+
111
+ } else {
112
+ // 15.3.4.5.1 [[Call]]
113
+ // When the [[Call]] internal method of a function object, F,
114
+ // which was created using the bind function is called with a
115
+ // this value and a list of arguments ExtraArgs, the following
116
+ // steps are taken:
117
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
118
+ // property.
119
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
120
+ // property.
121
+ // 3. Let target be the value of F's [[TargetFunction]] internal
122
+ // property.
123
+ // 4. Let args be a new list containing the same values as the
124
+ // list boundArgs in the same order followed by the same
125
+ // values as the list ExtraArgs in the same order.
126
+ // 5. Return the result of calling the [[Call]] internal method
127
+ // of target providing boundThis as the this value and
128
+ // providing args as the arguments.
129
+
130
+ // equiv: target.call(this, ...boundArgs, ...args)
131
+ return target.apply(
132
+ that,
133
+ args.concat(_Array_slice_.call(arguments))
134
+ );
135
+
136
+ }
137
+
138
+ };
139
+
140
+ // 15. If the [[Class]] internal property of Target is "Function", then
141
+ // a. Let L be the length property of Target minus the length of A.
142
+ // b. Set the length own property of F to either 0 or L, whichever is
143
+ // larger.
144
+ // 16. Else set the length own property of F to 0.
145
+
146
+ var boundLength = Math.max(0, target.length - args.length);
147
+
148
+ // 17. Set the attributes of the length own property of F to the values
149
+ // specified in 15.3.5.1.
150
+ var boundArgs = [];
151
+ for (var i = 0; i < boundLength; i++) {
152
+ boundArgs.push("$" + i);
153
+ }
154
+
155
+ // XXX Build a dynamic function with desired amount of arguments is the only
156
+ // way to set the length property of a function.
157
+ // In environments where Content Security Policies enabled (Chrome extensions,
158
+ // for ex.) all use of eval or Function costructor throws an exception.
159
+ // However in all of these environments Function.prototype.bind exists
160
+ // and so this code will never be executed.
161
+ var bound = Function("binder", "return function(" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
162
+
163
+ if (target.prototype) {
164
+ Empty.prototype = target.prototype;
165
+ bound.prototype = new Empty();
166
+ // Clean up dangling references.
167
+ Empty.prototype = null;
168
+ }
169
+
170
+ // TODO
171
+ // 18. Set the [[Extensible]] internal property of F to true.
172
+
173
+ // TODO
174
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
175
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
176
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
177
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
178
+ // false.
179
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
180
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
181
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
182
+ // and false.
183
+
184
+ // TODO
185
+ // NOTE Function objects created using Function.prototype.bind do not
186
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
187
+ // [[Scope]] internal properties.
188
+ // XXX can't delete prototype in pure-js.
189
+
190
+ // 22. Return F.
191
+ return bound;
192
+ };
193
+ }
194
+
195
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
196
+ // us it in defining shortcuts.
197
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
198
+ // Having a toString local variable name breaks in Opera so use _toString.
199
+ var _toString = call.bind(prototypeOfObject.toString);
200
+
201
+ // If JS engine supports accessors creating shortcuts.
202
+ var defineGetter;
203
+ var defineSetter;
204
+ var lookupGetter;
205
+ var lookupSetter;
206
+ var supportsAccessors;
207
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
208
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
209
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
210
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
211
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
212
+ }
213
+
214
+ //
215
+ // Array
216
+ // =====
217
+ //
218
+
219
+ // ES5 15.4.4.12
220
+ // http://es5.github.com/#x15.4.4.12
221
+ // Default value for second param
222
+ // [bugfix, ielt9, old browsers]
223
+ // IE < 9 bug: [1,2].splice(0).join("") === "" but should be "12"
224
+ if ([1, 2].splice(0).length !== 2) {
225
+ if (function () { // test IE < 9 to splice bug - see issue #138
226
+ function makeArray(l) {
227
+ var a = [];
228
+ while (l--) {
229
+ a.unshift(l);
230
+ }
231
+ return a;
232
+ }
233
+
234
+ var array = [];
235
+ var lengthBefore;
236
+
237
+ array.splice.bind(array, 0, 0).apply(null, makeArray(20));
238
+ array.splice.bind(array, 0, 0).apply(null, makeArray(26));
239
+
240
+ lengthBefore = array.length; //20
241
+ array.splice(5, 0, "XXX"); // add one element
242
+
243
+ if (lengthBefore + 1 === array.length) {
244
+ return true;// has right splice implementation without bugs
245
+ }
246
+ // else {
247
+ // IE8 bug
248
+ // }
249
+ }()) { // IE 6/7
250
+ Array.prototype.splice = function(start, deleteCount) {
251
+ if (!arguments.length) {
252
+ return [];
253
+ } else {
254
+ return array_splice.apply(this, [
255
+ start === void 0 ? 0 : start,
256
+ deleteCount === void 0 ? (this.length - start) : deleteCount
257
+ ].concat(_Array_slice_.call(arguments, 2)));
258
+ }
259
+ };
260
+ } else { // IE8
261
+ Array.prototype.splice = function(start, deleteCount) {
262
+ var result;
263
+ var args = _Array_slice_.call(arguments, 2);
264
+ var addElementsCount = args.length;
265
+
266
+ if (!arguments.length) {
267
+ return [];
268
+ }
269
+
270
+ if (start === void 0) { // default
271
+ start = 0;
272
+ }
273
+ if (deleteCount === void 0) { // default
274
+ deleteCount = this.length - start;
275
+ }
276
+
277
+ if (addElementsCount > 0) {
278
+ if (deleteCount <= 0) {
279
+ if (start === this.length) { // tiny optimisation #1
280
+ array_push.apply(this, args);
281
+ return [];
282
+ }
283
+
284
+ if (start === 0) { // tiny optimisation #2
285
+ array_unshift.apply(this, args);
286
+ return [];
287
+ }
288
+ }
289
+
290
+ // Array.prototype.splice implementation
291
+ result = _Array_slice_.call(this, start, start + deleteCount);// delete part
292
+ args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
293
+ args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
294
+
295
+ // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
296
+ args.unshift(0, this.length);
297
+
298
+ array_splice.apply(this, args);
299
+
300
+ return result;
301
+ }
302
+
303
+ return array_splice.call(this, start, deleteCount);
304
+ };
305
+
306
+ }
307
+ }
308
+
309
+ // ES5 15.4.4.12
310
+ // http://es5.github.com/#x15.4.4.13
311
+ // Return len+argCount.
312
+ // [bugfix, ielt8]
313
+ // IE < 8 bug: [].unshift(0) === undefined but should be "1"
314
+ if ([].unshift(0) !== 1) {
315
+ Array.prototype.unshift = function() {
316
+ array_unshift.apply(this, arguments);
317
+ return this.length;
318
+ };
319
+ }
320
+
321
+ // ES5 15.4.3.2
322
+ // http://es5.github.com/#x15.4.3.2
323
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
324
+ if (!Array.isArray) {
325
+ Array.isArray = function isArray(obj) {
326
+ return _toString(obj) === "[object Array]";
327
+ };
328
+ }
329
+
330
+ // The IsCallable() check in the Array functions
331
+ // has been replaced with a strict check on the
332
+ // internal class of the object to trap cases where
333
+ // the provided function was actually a regular
334
+ // expression literal, which in V8 and
335
+ // JavaScriptCore is a typeof "function". Only in
336
+ // V8 are regular expression literals permitted as
337
+ // reduce parameters, so it is desirable in the
338
+ // general case for the shim to match the more
339
+ // strict and common behavior of rejecting regular
340
+ // expressions.
341
+
342
+ // ES5 15.4.4.18
343
+ // http://es5.github.com/#x15.4.4.18
344
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
345
+
346
+
347
+ // Check failure of by-index access of string characters (IE < 9)
348
+ // and failure of `0 in boxedString` (Rhino)
349
+ var boxedString = Object("a");
350
+ var splitString = boxedString[0] !== "a" || !(0 in boxedString);
351
+
352
+ var properlyBoxesContext = function properlyBoxed(method) {
353
+ // Check node 0.6.21 bug where third parameter is not boxed
354
+ var properlyBoxes = true;
355
+ if (method) {
356
+ method.call('foo', function (_, __, context) {
357
+ if (typeof context !== 'object') { properlyBoxes = false; }
358
+ });
359
+ }
360
+ return !!method && properlyBoxes;
361
+ };
362
+
363
+ if (!Array.prototype.forEach || !properlyBoxesContext(Array.prototype.forEach)) {
364
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
365
+ var object = toObject(this),
366
+ self = splitString && _toString(this) === "[object String]" ?
367
+ this.split("") :
368
+ object,
369
+ thisp = arguments[1],
370
+ i = -1,
371
+ length = self.length >>> 0;
372
+
373
+ // If no callback function or if callback is not a callable function
374
+ if (!isFunction(fun)) {
375
+ throw new TypeError(); // TODO message
376
+ }
377
+
378
+ while (++i < length) {
379
+ if (i in self) {
380
+ // Invoke the callback function with call, passing arguments:
381
+ // context, property value, property key, thisArg object
382
+ // context
383
+ fun.call(thisp, self[i], i, object);
384
+ }
385
+ }
386
+ };
387
+ }
388
+
389
+ // ES5 15.4.4.19
390
+ // http://es5.github.com/#x15.4.4.19
391
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
392
+ if (!Array.prototype.map || !properlyBoxesContext(Array.prototype.map)) {
393
+ Array.prototype.map = function map(fun /*, thisp*/) {
394
+ var object = toObject(this),
395
+ self = splitString && _toString(this) === "[object String]" ?
396
+ this.split("") :
397
+ object,
398
+ length = self.length >>> 0,
399
+ result = Array(length),
400
+ thisp = arguments[1];
401
+
402
+ // If no callback function or if callback is not a callable function
403
+ if (!isFunction(fun)) {
404
+ throw new TypeError(fun + " is not a function");
405
+ }
406
+
407
+ for (var i = 0; i < length; i++) {
408
+ if (i in self)
409
+ result[i] = fun.call(thisp, self[i], i, object);
410
+ }
411
+ return result;
412
+ };
413
+ }
414
+
415
+ // ES5 15.4.4.20
416
+ // http://es5.github.com/#x15.4.4.20
417
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
418
+ if (!Array.prototype.filter || !properlyBoxesContext(Array.prototype.filter)) {
419
+ Array.prototype.filter = function filter(fun /*, thisp */) {
420
+ var object = toObject(this),
421
+ self = splitString && _toString(this) === "[object String]" ?
422
+ this.split("") :
423
+ object,
424
+ length = self.length >>> 0,
425
+ result = [],
426
+ value,
427
+ thisp = arguments[1];
428
+
429
+ // If no callback function or if callback is not a callable function
430
+ if (!isFunction(fun)) {
431
+ throw new TypeError(fun + " is not a function");
432
+ }
433
+
434
+ for (var i = 0; i < length; i++) {
435
+ if (i in self) {
436
+ value = self[i];
437
+ if (fun.call(thisp, value, i, object)) {
438
+ result.push(value);
439
+ }
440
+ }
441
+ }
442
+ return result;
443
+ };
444
+ }
445
+
446
+ // ES5 15.4.4.16
447
+ // http://es5.github.com/#x15.4.4.16
448
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
449
+ if (!Array.prototype.every || !properlyBoxesContext(Array.prototype.every)) {
450
+ Array.prototype.every = function every(fun /*, thisp */) {
451
+ var object = toObject(this),
452
+ self = splitString && _toString(this) === "[object String]" ?
453
+ this.split("") :
454
+ object,
455
+ length = self.length >>> 0,
456
+ thisp = arguments[1];
457
+
458
+ // If no callback function or if callback is not a callable function
459
+ if (!isFunction(fun)) {
460
+ throw new TypeError(fun + " is not a function");
461
+ }
462
+
463
+ for (var i = 0; i < length; i++) {
464
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
465
+ return false;
466
+ }
467
+ }
468
+ return true;
469
+ };
470
+ }
471
+
472
+ // ES5 15.4.4.17
473
+ // http://es5.github.com/#x15.4.4.17
474
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
475
+ if (!Array.prototype.some || !properlyBoxesContext(Array.prototype.some)) {
476
+ Array.prototype.some = function some(fun /*, thisp */) {
477
+ var object = toObject(this),
478
+ self = splitString && _toString(this) === "[object String]" ?
479
+ this.split("") :
480
+ object,
481
+ length = self.length >>> 0,
482
+ thisp = arguments[1];
483
+
484
+ // If no callback function or if callback is not a callable function
485
+ if (!isFunction(fun)) {
486
+ throw new TypeError(fun + " is not a function");
487
+ }
488
+
489
+ for (var i = 0; i < length; i++) {
490
+ if (i in self && fun.call(thisp, self[i], i, object)) {
491
+ return true;
492
+ }
493
+ }
494
+ return false;
495
+ };
496
+ }
497
+
498
+ // ES5 15.4.4.21
499
+ // http://es5.github.com/#x15.4.4.21
500
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
501
+ var reduceCoercesToObject = false;
502
+ if (Array.prototype.reduce) {
503
+ reduceCoercesToObject = typeof Array.prototype.reduce.call('a', function (_, __, ___, list) { return list; }) === 'object';
504
+ }
505
+ if (!Array.prototype.reduce || !reduceCoercesToObject) {
506
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
507
+ var object = toObject(this),
508
+ self = splitString && _toString(this) === "[object String]" ?
509
+ this.split("") :
510
+ object,
511
+ length = self.length >>> 0;
512
+
513
+ // If no callback function or if callback is not a callable function
514
+ if (!isFunction(fun)) {
515
+ throw new TypeError(fun + " is not a function");
516
+ }
517
+
518
+ // no value to return if no initial value and an empty array
519
+ if (!length && arguments.length === 1) {
520
+ throw new TypeError("reduce of empty array with no initial value");
521
+ }
522
+
523
+ var i = 0;
524
+ var result;
525
+ if (arguments.length >= 2) {
526
+ result = arguments[1];
527
+ } else {
528
+ do {
529
+ if (i in self) {
530
+ result = self[i++];
531
+ break;
532
+ }
533
+
534
+ // if array contains no values, no initial value to return
535
+ if (++i >= length) {
536
+ throw new TypeError("reduce of empty array with no initial value");
537
+ }
538
+ } while (true);
539
+ }
540
+
541
+ for (; i < length; i++) {
542
+ if (i in self) {
543
+ result = fun.call(void 0, result, self[i], i, object);
544
+ }
545
+ }
546
+
547
+ return result;
548
+ };
549
+ }
550
+
551
+ // ES5 15.4.4.22
552
+ // http://es5.github.com/#x15.4.4.22
553
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
554
+ if (!Array.prototype.reduceRight) {
555
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
556
+ var object = toObject(this),
557
+ self = splitString && _toString(this) === "[object String]" ?
558
+ this.split("") :
559
+ object,
560
+ length = self.length >>> 0;
561
+
562
+ // If no callback function or if callback is not a callable function
563
+ if (!isFunction(fun)) {
564
+ throw new TypeError(fun + " is not a function");
565
+ }
566
+
567
+ // no value to return if no initial value, empty array
568
+ if (!length && arguments.length === 1) {
569
+ throw new TypeError("reduceRight of empty array with no initial value");
570
+ }
571
+
572
+ var result, i = length - 1;
573
+ if (arguments.length >= 2) {
574
+ result = arguments[1];
575
+ } else {
576
+ do {
577
+ if (i in self) {
578
+ result = self[i--];
579
+ break;
580
+ }
581
+
582
+ // if array contains no values, no initial value to return
583
+ if (--i < 0) {
584
+ throw new TypeError("reduceRight of empty array with no initial value");
585
+ }
586
+ } while (true);
587
+ }
588
+
589
+ if (i < 0) {
590
+ return result;
591
+ }
592
+
593
+ do {
594
+ if (i in this) {
595
+ result = fun.call(void 0, result, self[i], i, object);
596
+ }
597
+ } while (i--);
598
+
599
+ return result;
600
+ };
601
+ }
602
+
603
+ // ES5 15.4.4.14
604
+ // http://es5.github.com/#x15.4.4.14
605
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
606
+ if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) !== -1)) {
607
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
608
+ var self = splitString && _toString(this) === "[object String]" ?
609
+ this.split("") :
610
+ toObject(this),
611
+ length = self.length >>> 0;
612
+
613
+ if (!length) {
614
+ return -1;
615
+ }
616
+
617
+ var i = 0;
618
+ if (arguments.length > 1) {
619
+ i = toInteger(arguments[1]);
620
+ }
621
+
622
+ // handle negative indices
623
+ i = i >= 0 ? i : Math.max(0, length + i);
624
+ for (; i < length; i++) {
625
+ if (i in self && self[i] === sought) {
626
+ return i;
627
+ }
628
+ }
629
+ return -1;
630
+ };
631
+ }
632
+
633
+ // ES5 15.4.4.15
634
+ // http://es5.github.com/#x15.4.4.15
635
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
636
+ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) !== -1)) {
637
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
638
+ var self = splitString && _toString(this) === "[object String]" ?
639
+ this.split("") :
640
+ toObject(this),
641
+ length = self.length >>> 0;
642
+
643
+ if (!length) {
644
+ return -1;
645
+ }
646
+ var i = length - 1;
647
+ if (arguments.length > 1) {
648
+ i = Math.min(i, toInteger(arguments[1]));
649
+ }
650
+ // handle negative indices
651
+ i = i >= 0 ? i : length - Math.abs(i);
652
+ for (; i >= 0; i--) {
653
+ if (i in self && sought === self[i]) {
654
+ return i;
655
+ }
656
+ }
657
+ return -1;
658
+ };
659
+ }
660
+
661
+ //
662
+ // Object
663
+ // ======
664
+ //
665
+
666
+ // ES5 15.2.3.14
667
+ // http://es5.github.com/#x15.2.3.14
668
+ if (!Object.keys) {
669
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
670
+ var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
671
+ hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
672
+ dontEnums = [
673
+ "toString",
674
+ "toLocaleString",
675
+ "valueOf",
676
+ "hasOwnProperty",
677
+ "isPrototypeOf",
678
+ "propertyIsEnumerable",
679
+ "constructor"
680
+ ],
681
+ dontEnumsLength = dontEnums.length,
682
+ isArguments = function isArguments(value) {
683
+ var str = _toString(value);
684
+ var isArgs = str === '[object Arguments]';
685
+ if (!isArgs) {
686
+ isArgs = !Array.isArray(str)
687
+ && value !== null
688
+ && typeof value === 'object'
689
+ && typeof value.length === 'number'
690
+ && value.length >= 0
691
+ && isFunction(value.callee);
692
+ }
693
+ return isArgs;
694
+ };
695
+
696
+ Object.keys = function keys(object) {
697
+ var isFn = isFunction(object),
698
+ isArgs = isArguments(object),
699
+ isObject = object !== null && typeof object === 'object',
700
+ isString = isObject && _toString(object) === '[object String]';
701
+
702
+ if (!isObject && !isFn && !isArgs) {
703
+ throw new TypeError("Object.keys called on a non-object");
704
+ }
705
+
706
+ var theKeys = [];
707
+ var skipProto = hasProtoEnumBug && isFn;
708
+ if (isString || isArgs) {
709
+ for (var i = 0; i < object.length; ++i) {
710
+ theKeys.push(String(i));
711
+ }
712
+ } else {
713
+ for (var name in object) {
714
+ if (!(skipProto && name === 'prototype') && owns(object, name)) {
715
+ theKeys.push(String(name));
716
+ }
717
+ }
718
+ }
719
+
720
+ if (hasDontEnumBug) {
721
+ var ctor = object.constructor,
722
+ skipConstructor = ctor && ctor.prototype === object;
723
+ for (var j = 0; j < dontEnumsLength; j++) {
724
+ var dontEnum = dontEnums[j];
725
+ if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
726
+ theKeys.push(dontEnum);
727
+ }
728
+ }
729
+ }
730
+ return theKeys;
731
+ };
732
+
733
+ }
734
+
735
+ //
736
+ // Date
737
+ // ====
738
+ //
739
+
740
+ // ES5 15.9.5.43
741
+ // http://es5.github.com/#x15.9.5.43
742
+ // This function returns a String value represent the instance in time
743
+ // represented by this Date object. The format of the String is the Date Time
744
+ // string format defined in 15.9.1.15. All fields are present in the String.
745
+ // The time zone is always UTC, denoted by the suffix Z. If the time value of
746
+ // this object is not a finite Number a RangeError exception is thrown.
747
+ var negativeDate = -62198755200000,
748
+ negativeYearString = "-000001";
749
+ if (
750
+ !Date.prototype.toISOString ||
751
+ (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
752
+ ) {
753
+ Date.prototype.toISOString = function toISOString() {
754
+ var result, length, value, year, month;
755
+ if (!isFinite(this)) {
756
+ throw new RangeError("Date.prototype.toISOString called on non-finite value.");
757
+ }
758
+
759
+ year = this.getUTCFullYear();
760
+
761
+ month = this.getUTCMonth();
762
+ // see https://github.com/es-shims/es5-shim/issues/111
763
+ year += Math.floor(month / 12);
764
+ month = (month % 12 + 12) % 12;
765
+
766
+ // the date time string format is specified in 15.9.1.15.
767
+ result = [month + 1, this.getUTCDate(),
768
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
769
+ year = (
770
+ (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
771
+ ("00000" + Math.abs(year))
772
+ .slice(0 <= year && year <= 9999 ? -4 : -6)
773
+ );
774
+
775
+ length = result.length;
776
+ while (length--) {
777
+ value = result[length];
778
+ // pad months, days, hours, minutes, and seconds to have two
779
+ // digits.
780
+ if (value < 10) {
781
+ result[length] = "0" + value;
782
+ }
783
+ }
784
+ // pad milliseconds to have three digits.
785
+ return (
786
+ year + "-" + result.slice(0, 2).join("-") +
787
+ "T" + result.slice(2).join(":") + "." +
788
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
789
+ );
790
+ };
791
+ }
792
+
793
+
794
+ // ES5 15.9.5.44
795
+ // http://es5.github.com/#x15.9.5.44
796
+ // This function provides a String representation of a Date object for use by
797
+ // JSON.stringify (15.12.3).
798
+ var dateToJSONIsSupported = false;
799
+ try {
800
+ dateToJSONIsSupported = (
801
+ Date.prototype.toJSON &&
802
+ new Date(NaN).toJSON() === null &&
803
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
804
+ Date.prototype.toJSON.call({ // generic
805
+ toISOString: function () {
806
+ return true;
807
+ }
808
+ })
809
+ );
810
+ } catch (e) {
811
+ }
812
+ if (!dateToJSONIsSupported) {
813
+ Date.prototype.toJSON = function toJSON(key) {
814
+ // When the toJSON method is called with argument key, the following
815
+ // steps are taken:
816
+
817
+ // 1. Let O be the result of calling ToObject, giving it the this
818
+ // value as its argument.
819
+ // 2. Let tv be toPrimitive(O, hint Number).
820
+ var o = Object(this),
821
+ tv = toPrimitive(o),
822
+ toISO;
823
+ // 3. If tv is a Number and is not finite, return null.
824
+ if (typeof tv === "number" && !isFinite(tv)) {
825
+ return null;
826
+ }
827
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
828
+ // O with argument "toISOString".
829
+ toISO = o.toISOString;
830
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
831
+ if (typeof toISO !== "function") {
832
+ throw new TypeError("toISOString property is not callable");
833
+ }
834
+ // 6. Return the result of calling the [[Call]] internal method of
835
+ // toISO with O as the this value and an empty argument list.
836
+ return toISO.call(o);
837
+
838
+ // NOTE 1 The argument is ignored.
839
+
840
+ // NOTE 2 The toJSON function is intentionally generic; it does not
841
+ // require that its this value be a Date object. Therefore, it can be
842
+ // transferred to other kinds of objects for use as a method. However,
843
+ // it does require that any such object have a toISOString method. An
844
+ // object is free to use the argument key to filter its
845
+ // stringification.
846
+ };
847
+ }
848
+
849
+ // ES5 15.9.4.2
850
+ // http://es5.github.com/#x15.9.4.2
851
+ // based on work shared by Daniel Friesen (dantman)
852
+ // http://gist.github.com/303249
853
+ var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
854
+ var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z'));
855
+ var doesNotParseY2KNewYear = isNaN(Date.parse("2000-01-01T00:00:00.000Z"));
856
+ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
857
+ // XXX global assignment won't work in embeddings that use
858
+ // an alternate object for the context.
859
+ Date = (function(NativeDate) {
860
+
861
+ // Date.length === 7
862
+ function Date(Y, M, D, h, m, s, ms) {
863
+ var length = arguments.length;
864
+ if (this instanceof NativeDate) {
865
+ var date = length === 1 && String(Y) === Y ? // isString(Y)
866
+ // We explicitly pass it through parse:
867
+ new NativeDate(Date.parse(Y)) :
868
+ // We have to manually make calls depending on argument
869
+ // length here
870
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
871
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
872
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
873
+ length >= 4 ? new NativeDate(Y, M, D, h) :
874
+ length >= 3 ? new NativeDate(Y, M, D) :
875
+ length >= 2 ? new NativeDate(Y, M) :
876
+ length >= 1 ? new NativeDate(Y) :
877
+ new NativeDate();
878
+ // Prevent mixups with unfixed Date object
879
+ date.constructor = Date;
880
+ return date;
881
+ }
882
+ return NativeDate.apply(this, arguments);
883
+ }
884
+
885
+ // 15.9.1.15 Date Time String Format.
886
+ var isoDateExpression = new RegExp("^" +
887
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
888
+ // 6-digit extended year
889
+ "(?:-(\\d{2})" + // optional month capture
890
+ "(?:-(\\d{2})" + // optional day capture
891
+ "(?:" + // capture hours:minutes:seconds.milliseconds
892
+ "T(\\d{2})" + // hours capture
893
+ ":(\\d{2})" + // minutes capture
894
+ "(?:" + // optional :seconds.milliseconds
895
+ ":(\\d{2})" + // seconds capture
896
+ "(?:(\\.\\d{1,}))?" + // milliseconds capture
897
+ ")?" +
898
+ "(" + // capture UTC offset component
899
+ "Z|" + // UTC capture
900
+ "(?:" + // offset specifier +/-hours:minutes
901
+ "([-+])" + // sign capture
902
+ "(\\d{2})" + // hours offset capture
903
+ ":(\\d{2})" + // minutes offset capture
904
+ ")" +
905
+ ")?)?)?)?" +
906
+ "$");
907
+
908
+ var months = [
909
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
910
+ ];
911
+
912
+ function dayFromMonth(year, month) {
913
+ var t = month > 1 ? 1 : 0;
914
+ return (
915
+ months[month] +
916
+ Math.floor((year - 1969 + t) / 4) -
917
+ Math.floor((year - 1901 + t) / 100) +
918
+ Math.floor((year - 1601 + t) / 400) +
919
+ 365 * (year - 1970)
920
+ );
921
+ }
922
+
923
+ function toUTC(t) {
924
+ return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
925
+ }
926
+
927
+ // Copy any custom methods a 3rd party library may have added
928
+ for (var key in NativeDate) {
929
+ Date[key] = NativeDate[key];
930
+ }
931
+
932
+ // Copy "native" methods explicitly; they may be non-enumerable
933
+ Date.now = NativeDate.now;
934
+ Date.UTC = NativeDate.UTC;
935
+ Date.prototype = NativeDate.prototype;
936
+ Date.prototype.constructor = Date;
937
+
938
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
939
+ Date.parse = function parse(string) {
940
+ var match = isoDateExpression.exec(string);
941
+ if (match) {
942
+ // parse months, days, hours, minutes, seconds, and milliseconds
943
+ // provide default values if necessary
944
+ // parse the UTC offset component
945
+ var year = Number(match[1]),
946
+ month = Number(match[2] || 1) - 1,
947
+ day = Number(match[3] || 1) - 1,
948
+ hour = Number(match[4] || 0),
949
+ minute = Number(match[5] || 0),
950
+ second = Number(match[6] || 0),
951
+ millisecond = Math.floor(Number(match[7] || 0) * 1000),
952
+ // When time zone is missed, local offset should be used
953
+ // (ES 5.1 bug)
954
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=112
955
+ isLocalTime = Boolean(match[4] && !match[8]),
956
+ signOffset = match[9] === "-" ? 1 : -1,
957
+ hourOffset = Number(match[10] || 0),
958
+ minuteOffset = Number(match[11] || 0),
959
+ result;
960
+ if (
961
+ hour < (
962
+ minute > 0 || second > 0 || millisecond > 0 ?
963
+ 24 : 25
964
+ ) &&
965
+ minute < 60 && second < 60 && millisecond < 1000 &&
966
+ month > -1 && month < 12 && hourOffset < 24 &&
967
+ minuteOffset < 60 && // detect invalid offsets
968
+ day > -1 &&
969
+ day < (
970
+ dayFromMonth(year, month + 1) -
971
+ dayFromMonth(year, month)
972
+ )
973
+ ) {
974
+ result = (
975
+ (dayFromMonth(year, month) + day) * 24 +
976
+ hour +
977
+ hourOffset * signOffset
978
+ ) * 60;
979
+ result = (
980
+ (result + minute + minuteOffset * signOffset) * 60 +
981
+ second
982
+ ) * 1000 + millisecond;
983
+ if (isLocalTime) {
984
+ result = toUTC(result);
985
+ }
986
+ if (-8.64e15 <= result && result <= 8.64e15) {
987
+ return result;
988
+ }
989
+ }
990
+ return NaN;
991
+ }
992
+ return NativeDate.parse.apply(this, arguments);
993
+ };
994
+
995
+ return Date;
996
+ })(Date);
997
+ }
998
+
999
+ // ES5 15.9.4.4
1000
+ // http://es5.github.com/#x15.9.4.4
1001
+ if (!Date.now) {
1002
+ Date.now = function now() {
1003
+ return new Date().getTime();
1004
+ };
1005
+ }
1006
+
1007
+
1008
+ //
1009
+ // Number
1010
+ // ======
1011
+ //
1012
+
1013
+ // ES5.1 15.7.4.5
1014
+ // http://es5.github.com/#x15.7.4.5
1015
+ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
1016
+ // Hide these variables and functions
1017
+ (function () {
1018
+ var base, size, data, i;
1019
+
1020
+ base = 1e7;
1021
+ size = 6;
1022
+ data = [0, 0, 0, 0, 0, 0];
1023
+
1024
+ function multiply(n, c) {
1025
+ var i = -1;
1026
+ while (++i < size) {
1027
+ c += n * data[i];
1028
+ data[i] = c % base;
1029
+ c = Math.floor(c / base);
1030
+ }
1031
+ }
1032
+
1033
+ function divide(n) {
1034
+ var i = size, c = 0;
1035
+ while (--i >= 0) {
1036
+ c += data[i];
1037
+ data[i] = Math.floor(c / n);
1038
+ c = (c % n) * base;
1039
+ }
1040
+ }
1041
+
1042
+ function toString() {
1043
+ var i = size;
1044
+ var s = '';
1045
+ while (--i >= 0) {
1046
+ if (s !== '' || i === 0 || data[i] !== 0) {
1047
+ var t = String(data[i]);
1048
+ if (s === '') {
1049
+ s = t;
1050
+ } else {
1051
+ s += '0000000'.slice(0, 7 - t.length) + t;
1052
+ }
1053
+ }
1054
+ }
1055
+ return s;
1056
+ }
1057
+
1058
+ function pow(x, n, acc) {
1059
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1060
+ }
1061
+
1062
+ function log(x) {
1063
+ var n = 0;
1064
+ while (x >= 4096) {
1065
+ n += 12;
1066
+ x /= 4096;
1067
+ }
1068
+ while (x >= 2) {
1069
+ n += 1;
1070
+ x /= 2;
1071
+ }
1072
+ return n;
1073
+ }
1074
+
1075
+ Number.prototype.toFixed = function toFixed(fractionDigits) {
1076
+ var f, x, s, m, e, z, j, k;
1077
+
1078
+ // Test for NaN and round fractionDigits down
1079
+ f = Number(fractionDigits);
1080
+ f = f !== f ? 0 : Math.floor(f);
1081
+
1082
+ if (f < 0 || f > 20) {
1083
+ throw new RangeError("Number.toFixed called with invalid number of decimals");
1084
+ }
1085
+
1086
+ x = Number(this);
1087
+
1088
+ // Test for NaN
1089
+ if (x !== x) {
1090
+ return "NaN";
1091
+ }
1092
+
1093
+ // If it is too big or small, return the string value of the number
1094
+ if (x <= -1e21 || x >= 1e21) {
1095
+ return String(x);
1096
+ }
1097
+
1098
+ s = "";
1099
+
1100
+ if (x < 0) {
1101
+ s = "-";
1102
+ x = -x;
1103
+ }
1104
+
1105
+ m = "0";
1106
+
1107
+ if (x > 1e-21) {
1108
+ // 1e-21 < x < 1e21
1109
+ // -70 < log2(x) < 70
1110
+ e = log(x * pow(2, 69, 1)) - 69;
1111
+ z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1112
+ z *= 0x10000000000000; // Math.pow(2, 52);
1113
+ e = 52 - e;
1114
+
1115
+ // -18 < e < 122
1116
+ // x = z / 2 ^ e
1117
+ if (e > 0) {
1118
+ multiply(0, z);
1119
+ j = f;
1120
+
1121
+ while (j >= 7) {
1122
+ multiply(1e7, 0);
1123
+ j -= 7;
1124
+ }
1125
+
1126
+ multiply(pow(10, j, 1), 0);
1127
+ j = e - 1;
1128
+
1129
+ while (j >= 23) {
1130
+ divide(1 << 23);
1131
+ j -= 23;
1132
+ }
1133
+
1134
+ divide(1 << j);
1135
+ multiply(1, 1);
1136
+ divide(2);
1137
+ m = toString();
1138
+ } else {
1139
+ multiply(0, z);
1140
+ multiply(1 << (-e), 0);
1141
+ m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1142
+ }
1143
+ }
1144
+
1145
+ if (f > 0) {
1146
+ k = m.length;
1147
+
1148
+ if (k <= f) {
1149
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1150
+ } else {
1151
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1152
+ }
1153
+ } else {
1154
+ m = s + m;
1155
+ }
1156
+
1157
+ return m;
1158
+ };
1159
+ }());
1160
+ }
1161
+
1162
+
1163
+ //
1164
+ // String
1165
+ // ======
1166
+ //
1167
+
1168
+
1169
+ // ES5 15.5.4.14
1170
+ // http://es5.github.com/#x15.5.4.14
1171
+
1172
+ // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1173
+ // Many browsers do not split properly with regular expressions or they
1174
+ // do not perform the split correctly under obscure conditions.
1175
+ // See http://blog.stevenlevithan.com/archives/cross-browser-split
1176
+ // I've tested in many browsers and this seems to cover the deviant ones:
1177
+ // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1178
+ // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1179
+ // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1180
+ // [undefined, "t", undefined, "e", ...]
1181
+ // ''.split(/.?/) should be [], not [""]
1182
+ // '.'.split(/()()/) should be ["."], not ["", "", "."]
1183
+
1184
+ var string_split = String.prototype.split;
1185
+ if (
1186
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
1187
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1188
+ 'tesst'.split(/(s)*/)[1] === "t" ||
1189
+ ''.split(/.?/).length ||
1190
+ '.'.split(/()()/).length > 1
1191
+ ) {
1192
+ (function () {
1193
+ var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1194
+
1195
+ String.prototype.split = function (separator, limit) {
1196
+ var string = this;
1197
+ if (separator === void 0 && limit === 0)
1198
+ return [];
1199
+
1200
+ // If `separator` is not a regex, use native split
1201
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1202
+ return string_split.apply(this, arguments);
1203
+ }
1204
+
1205
+ var output = [],
1206
+ flags = (separator.ignoreCase ? "i" : "") +
1207
+ (separator.multiline ? "m" : "") +
1208
+ (separator.extended ? "x" : "") + // Proposed for ES6
1209
+ (separator.sticky ? "y" : ""), // Firefox 3+
1210
+ lastLastIndex = 0,
1211
+ // Make `global` and avoid `lastIndex` issues by working with a copy
1212
+ separator2, match, lastIndex, lastLength;
1213
+ separator = new RegExp(separator.source, flags + "g");
1214
+ string += ""; // Type-convert
1215
+ if (!compliantExecNpcg) {
1216
+ // Doesn't need flags gy, but they don't hurt
1217
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1218
+ }
1219
+ /* Values for `limit`, per the spec:
1220
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
1221
+ * If 0, Infinity, or NaN: 0
1222
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1223
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1224
+ * If other: Type-convert, then use the above rules
1225
+ */
1226
+ limit = limit === void 0 ?
1227
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1228
+ limit >>> 0; // ToUint32(limit)
1229
+ while (match = separator.exec(string)) {
1230
+ // `separator.lastIndex` is not reliable cross-browser
1231
+ lastIndex = match.index + match[0].length;
1232
+ if (lastIndex > lastLastIndex) {
1233
+ output.push(string.slice(lastLastIndex, match.index));
1234
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
1235
+ // nonparticipating capturing groups
1236
+ if (!compliantExecNpcg && match.length > 1) {
1237
+ match[0].replace(separator2, function () {
1238
+ for (var i = 1; i < arguments.length - 2; i++) {
1239
+ if (arguments[i] === void 0) {
1240
+ match[i] = void 0;
1241
+ }
1242
+ }
1243
+ });
1244
+ }
1245
+ if (match.length > 1 && match.index < string.length) {
1246
+ Array.prototype.push.apply(output, match.slice(1));
1247
+ }
1248
+ lastLength = match[0].length;
1249
+ lastLastIndex = lastIndex;
1250
+ if (output.length >= limit) {
1251
+ break;
1252
+ }
1253
+ }
1254
+ if (separator.lastIndex === match.index) {
1255
+ separator.lastIndex++; // Avoid an infinite loop
1256
+ }
1257
+ }
1258
+ if (lastLastIndex === string.length) {
1259
+ if (lastLength || !separator.test("")) {
1260
+ output.push("");
1261
+ }
1262
+ } else {
1263
+ output.push(string.slice(lastLastIndex));
1264
+ }
1265
+ return output.length > limit ? output.slice(0, limit) : output;
1266
+ };
1267
+ }());
1268
+
1269
+ // [bugfix, chrome]
1270
+ // If separator is undefined, then the result array contains just one String,
1271
+ // which is the this value (converted to a String). If limit is not undefined,
1272
+ // then the output array is truncated so that it contains no more than limit
1273
+ // elements.
1274
+ // "0".split(undefined, 0) -> []
1275
+ } else if ("0".split(void 0, 0).length) {
1276
+ String.prototype.split = function split(separator, limit) {
1277
+ if (separator === void 0 && limit === 0) return [];
1278
+ return string_split.apply(this, arguments);
1279
+ };
1280
+ }
1281
+
1282
+
1283
+ // ECMA-262, 3rd B.2.3
1284
+ // Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1285
+ // non-normative section suggesting uniform semantics and it should be
1286
+ // normalized across all browsers
1287
+ // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1288
+ if ("".substr && "0b".substr(-1) !== "b") {
1289
+ var string_substr = String.prototype.substr;
1290
+ /**
1291
+ * Get the substring of a string
1292
+ * @param {integer} start where to start the substring
1293
+ * @param {integer} length how many characters to return
1294
+ * @return {string}
1295
+ */
1296
+ String.prototype.substr = function substr(start, length) {
1297
+ return string_substr.call(
1298
+ this,
1299
+ start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1300
+ length
1301
+ );
1302
+ };
1303
+ }
1304
+
1305
+ // ES5 15.5.4.20
1306
+ // whitespace from: http://es5.github.io/#x15.5.4.20
1307
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1308
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1309
+ "\u2029\uFEFF";
1310
+ var zeroWidth = '\u200b';
1311
+ if (!String.prototype.trim || ws.trim() || !zeroWidth.trim()) {
1312
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1313
+ // http://perfectionkills.com/whitespace-deviations/
1314
+ ws = "[" + ws + "]";
1315
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1316
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1317
+ String.prototype.trim = function trim() {
1318
+ if (this === void 0 || this === null) {
1319
+ throw new TypeError("can't convert "+this+" to object");
1320
+ }
1321
+ return String(this)
1322
+ .replace(trimBeginRegexp, "")
1323
+ .replace(trimEndRegexp, "");
1324
+ };
1325
+ }
1326
+
1327
+ // ES-5 15.1.2.2
1328
+ if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
1329
+ parseInt = (function (origParseInt) {
1330
+ var hexRegex = /^0[xX]/;
1331
+ return function parseIntES5(str, radix) {
1332
+ str = String(str).trim();
1333
+ if (!Number(radix)) {
1334
+ radix = hexRegex.test(str) ? 16 : 10;
1335
+ }
1336
+ return origParseInt(str, radix);
1337
+ };
1338
+ }(parseInt));
1339
+ }
1340
+
1341
+ //
1342
+ // Util
1343
+ // ======
1344
+ //
1345
+
1346
+ // ES5 9.4
1347
+ // http://es5.github.com/#x9.4
1348
+ // http://jsperf.com/to-integer
1349
+
1350
+ function toInteger(n) {
1351
+ n = +n;
1352
+ if (n !== n) { // isNaN
1353
+ n = 0;
1354
+ } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
1355
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
1356
+ }
1357
+ return n;
1358
+ }
1359
+
1360
+ function isPrimitive(input) {
1361
+ var type = typeof input;
1362
+ return (
1363
+ input === null ||
1364
+ type === "undefined" ||
1365
+ type === "boolean" ||
1366
+ type === "number" ||
1367
+ type === "string"
1368
+ );
1369
+ }
1370
+
1371
+ function toPrimitive(input) {
1372
+ var val, valueOf, toStr;
1373
+ if (isPrimitive(input)) {
1374
+ return input;
1375
+ }
1376
+ valueOf = input.valueOf;
1377
+ if (isFunction(valueOf)) {
1378
+ val = valueOf.call(input);
1379
+ if (isPrimitive(val)) {
1380
+ return val;
1381
+ }
1382
+ }
1383
+ toStr = input.toString;
1384
+ if (isFunction(toStr)) {
1385
+ val = toStr.call(input);
1386
+ if (isPrimitive(val)) {
1387
+ return val;
1388
+ }
1389
+ }
1390
+ throw new TypeError();
1391
+ }
1392
+
1393
+ // ES5 9.9
1394
+ // http://es5.github.com/#x9.9
1395
+ var toObject = function (o) {
1396
+ if (o == null) { // this matches both null and undefined
1397
+ throw new TypeError("can't convert "+o+" to object");
1398
+ }
1399
+ return Object(o);
1400
+ };
1401
+
1402
+ }));