sprockets-es6 0.1.1 → 0.2.0

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.
@@ -1,3271 +0,0 @@
1
- (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- if (typeof Symbol === "undefined") {
3
- require("es6-symbol/implement");
4
- }
5
-
6
- require("es6-shim");
7
- require("regenerator-6to5/runtime");
8
-
9
- },{"es6-shim":3,"es6-symbol/implement":4,"regenerator-6to5/runtime":27}],2:[function(require,module,exports){
10
- // shim for using process in browser
11
-
12
- var process = module.exports = {};
13
-
14
- process.nextTick = (function () {
15
- var canSetImmediate = typeof window !== 'undefined'
16
- && window.setImmediate;
17
- var canMutationObserver = typeof window !== 'undefined'
18
- && window.MutationObserver;
19
- var canPost = typeof window !== 'undefined'
20
- && window.postMessage && window.addEventListener
21
- ;
22
-
23
- if (canSetImmediate) {
24
- return function (f) { return window.setImmediate(f) };
25
- }
26
-
27
- var queue = [];
28
-
29
- if (canMutationObserver) {
30
- var hiddenDiv = document.createElement("div");
31
- var observer = new MutationObserver(function () {
32
- var queueList = queue.slice();
33
- queue.length = 0;
34
- queueList.forEach(function (fn) {
35
- fn();
36
- });
37
- });
38
-
39
- observer.observe(hiddenDiv, { attributes: true });
40
-
41
- return function nextTick(fn) {
42
- if (!queue.length) {
43
- hiddenDiv.setAttribute('yes', 'no');
44
- }
45
- queue.push(fn);
46
- };
47
- }
48
-
49
- if (canPost) {
50
- window.addEventListener('message', function (ev) {
51
- var source = ev.source;
52
- if ((source === window || source === null) && ev.data === 'process-tick') {
53
- ev.stopPropagation();
54
- if (queue.length > 0) {
55
- var fn = queue.shift();
56
- fn();
57
- }
58
- }
59
- }, true);
60
-
61
- return function nextTick(fn) {
62
- queue.push(fn);
63
- window.postMessage('process-tick', '*');
64
- };
65
- }
66
-
67
- return function nextTick(fn) {
68
- setTimeout(fn, 0);
69
- };
70
- })();
71
-
72
- process.title = 'browser';
73
- process.browser = true;
74
- process.env = {};
75
- process.argv = [];
76
-
77
- function noop() {}
78
-
79
- process.on = noop;
80
- process.addListener = noop;
81
- process.once = noop;
82
- process.off = noop;
83
- process.removeListener = noop;
84
- process.removeAllListeners = noop;
85
- process.emit = noop;
86
-
87
- process.binding = function (name) {
88
- throw new Error('process.binding is not supported');
89
- };
90
-
91
- // TODO(shtylman)
92
- process.cwd = function () { return '/' };
93
- process.chdir = function (dir) {
94
- throw new Error('process.chdir is not supported');
95
- };
96
-
97
- },{}],3:[function(require,module,exports){
98
- (function (process){
99
- /*!
100
- * https://github.com/paulmillr/es6-shim
101
- * @license es6-shim Copyright 2013-2014 by Paul Miller (http://paulmillr.com)
102
- * and contributors, MIT License
103
- * es6-shim: v0.20.2
104
- * see https://github.com/paulmillr/es6-shim/blob/master/LICENSE
105
- * Details and documentation:
106
- * https://github.com/paulmillr/es6-shim/
107
- */
108
-
109
- // UMD (Universal Module Definition)
110
- // see https://github.com/umdjs/umd/blob/master/returnExports.js
111
- (function (root, factory) {
112
- if (typeof define === 'function' && define.amd) {
113
- // AMD. Register as an anonymous module.
114
- define(factory);
115
- } else if (typeof exports === 'object') {
116
- // Node. Does not work with strict CommonJS, but
117
- // only CommonJS-like enviroments that support module.exports,
118
- // like Node.
119
- module.exports = factory();
120
- } else {
121
- // Browser globals (root is window)
122
- root.returnExports = factory();
123
- }
124
- }(this, function () {
125
- 'use strict';
126
-
127
- var isCallableWithoutNew = function (func) {
128
- try { func(); }
129
- catch (e) { return false; }
130
- return true;
131
- };
132
-
133
- var supportsSubclassing = function (C, f) {
134
- /* jshint proto:true */
135
- try {
136
- var Sub = function () { C.apply(this, arguments); };
137
- if (!Sub.__proto__) { return false; /* skip test on IE < 11 */ }
138
- Object.setPrototypeOf(Sub, C);
139
- Sub.prototype = Object.create(C.prototype, {
140
- constructor: { value: C }
141
- });
142
- return f(Sub);
143
- } catch (e) {
144
- return false;
145
- }
146
- };
147
-
148
- var arePropertyDescriptorsSupported = function () {
149
- try {
150
- Object.defineProperty({}, 'x', {});
151
- return true;
152
- } catch (e) { /* this is IE 8. */
153
- return false;
154
- }
155
- };
156
-
157
- var startsWithRejectsRegex = function () {
158
- var rejectsRegex = false;
159
- if (String.prototype.startsWith) {
160
- try {
161
- '/a/'.startsWith(/a/);
162
- } catch (e) { /* this is spec compliant */
163
- rejectsRegex = true;
164
- }
165
- }
166
- return rejectsRegex;
167
- };
168
-
169
- /*jshint evil: true */
170
- var getGlobal = new Function('return this;');
171
- /*jshint evil: false */
172
-
173
- var globals = getGlobal();
174
- var global_isFinite = globals.isFinite;
175
- var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
176
- var startsWithIsCompliant = startsWithRejectsRegex();
177
- var _slice = Array.prototype.slice;
178
- var _indexOf = String.prototype.indexOf;
179
- var _toString = Object.prototype.toString;
180
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
181
- var ArrayIterator; // make our implementation private
182
-
183
- var defineProperty = function (object, name, value, force) {
184
- if (!force && name in object) { return; }
185
- if (supportsDescriptors) {
186
- Object.defineProperty(object, name, {
187
- configurable: true,
188
- enumerable: false,
189
- writable: true,
190
- value: value
191
- });
192
- } else {
193
- object[name] = value;
194
- }
195
- };
196
-
197
- // Define configurable, writable and non-enumerable props
198
- // if they don’t exist.
199
- var defineProperties = function (object, map) {
200
- Object.keys(map).forEach(function (name) {
201
- var method = map[name];
202
- defineProperty(object, name, method, false);
203
- });
204
- };
205
-
206
- // Simple shim for Object.create on ES3 browsers
207
- // (unlike real shim, no attempt to support `prototype === null`)
208
- var create = Object.create || function (prototype, properties) {
209
- function Type() {}
210
- Type.prototype = prototype;
211
- var object = new Type();
212
- if (typeof properties !== 'undefined') {
213
- defineProperties(object, properties);
214
- }
215
- return object;
216
- };
217
-
218
- // This is a private name in the es6 spec, equal to '[Symbol.iterator]'
219
- // we're going to use an arbitrary _-prefixed name to make our shims
220
- // work properly with each other, even though we don't have full Iterator
221
- // support. That is, `Array.from(map.keys())` will work, but we don't
222
- // pretend to export a "real" Iterator interface.
223
- var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
224
- '_es6shim_iterator_';
225
- // Firefox ships a partial implementation using the name @@iterator.
226
- // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
227
- // So use that name if we detect it.
228
- if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') {
229
- $iterator$ = '@@iterator';
230
- }
231
- var addIterator = function (prototype, impl) {
232
- if (!impl) { impl = function iterator() { return this; }; }
233
- var o = {};
234
- o[$iterator$] = impl;
235
- defineProperties(prototype, o);
236
- /* jshint notypeof: true */
237
- if (!prototype[$iterator$] && typeof $iterator$ === 'symbol') {
238
- // implementations are buggy when $iterator$ is a Symbol
239
- prototype[$iterator$] = impl;
240
- }
241
- };
242
-
243
- // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
244
- // can be replaced with require('is-arguments') if we ever use a build process instead
245
- var isArguments = function isArguments(value) {
246
- var str = _toString.call(value);
247
- var result = str === '[object Arguments]';
248
- if (!result) {
249
- result = str !== '[object Array]' &&
250
- value !== null &&
251
- typeof value === 'object' &&
252
- typeof value.length === 'number' &&
253
- value.length >= 0 &&
254
- _toString.call(value.callee) === '[object Function]';
255
- }
256
- return result;
257
- };
258
-
259
- var emulateES6construct = function (o) {
260
- if (!ES.TypeIsObject(o)) { throw new TypeError('bad object'); }
261
- // es5 approximation to es6 subclass semantics: in es6, 'new Foo'
262
- // would invoke Foo.@@create to allocation/initialize the new object.
263
- // In es5 we just get the plain object. So if we detect an
264
- // uninitialized object, invoke o.constructor.@@create
265
- if (!o._es6construct) {
266
- if (o.constructor && ES.IsCallable(o.constructor['@@create'])) {
267
- o = o.constructor['@@create'](o);
268
- }
269
- defineProperties(o, { _es6construct: true });
270
- }
271
- return o;
272
- };
273
-
274
- var ES = {
275
- CheckObjectCoercible: function (x, optMessage) {
276
- /* jshint eqnull:true */
277
- if (x == null) {
278
- throw new TypeError(optMessage || 'Cannot call method on ' + x);
279
- }
280
- return x;
281
- },
282
-
283
- TypeIsObject: function (x) {
284
- /* jshint eqnull:true */
285
- // this is expensive when it returns false; use this function
286
- // when you expect it to return true in the common case.
287
- return x != null && Object(x) === x;
288
- },
289
-
290
- ToObject: function (o, optMessage) {
291
- return Object(ES.CheckObjectCoercible(o, optMessage));
292
- },
293
-
294
- IsCallable: function (x) {
295
- return typeof x === 'function' &&
296
- // some versions of IE say that typeof /abc/ === 'function'
297
- _toString.call(x) === '[object Function]';
298
- },
299
-
300
- ToInt32: function (x) {
301
- return x >> 0;
302
- },
303
-
304
- ToUint32: function (x) {
305
- return x >>> 0;
306
- },
307
-
308
- ToInteger: function (value) {
309
- var number = +value;
310
- if (Number.isNaN(number)) { return 0; }
311
- if (number === 0 || !Number.isFinite(number)) { return number; }
312
- return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
313
- },
314
-
315
- ToLength: function (value) {
316
- var len = ES.ToInteger(value);
317
- if (len <= 0) { return 0; } // includes converting -0 to +0
318
- if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; }
319
- return len;
320
- },
321
-
322
- SameValue: function (a, b) {
323
- if (a === b) {
324
- // 0 === -0, but they are not identical.
325
- if (a === 0) { return 1 / a === 1 / b; }
326
- return true;
327
- }
328
- return Number.isNaN(a) && Number.isNaN(b);
329
- },
330
-
331
- SameValueZero: function (a, b) {
332
- // same as SameValue except for SameValueZero(+0, -0) == true
333
- return (a === b) || (Number.isNaN(a) && Number.isNaN(b));
334
- },
335
-
336
- IsIterable: function (o) {
337
- return ES.TypeIsObject(o) &&
338
- (typeof o[$iterator$] !== 'undefined' || isArguments(o));
339
- },
340
-
341
- GetIterator: function (o) {
342
- if (isArguments(o)) {
343
- // special case support for `arguments`
344
- return new ArrayIterator(o, 'value');
345
- }
346
- var it = o[$iterator$]();
347
- if (!ES.TypeIsObject(it)) {
348
- throw new TypeError('bad iterator');
349
- }
350
- return it;
351
- },
352
-
353
- IteratorNext: function (it) {
354
- var result = arguments.length > 1 ? it.next(arguments[1]) : it.next();
355
- if (!ES.TypeIsObject(result)) {
356
- throw new TypeError('bad iterator');
357
- }
358
- return result;
359
- },
360
-
361
- Construct: function (C, args) {
362
- // CreateFromConstructor
363
- var obj;
364
- if (ES.IsCallable(C['@@create'])) {
365
- obj = C['@@create']();
366
- } else {
367
- // OrdinaryCreateFromConstructor
368
- obj = create(C.prototype || null);
369
- }
370
- // Mark that we've used the es6 construct path
371
- // (see emulateES6construct)
372
- defineProperties(obj, { _es6construct: true });
373
- // Call the constructor.
374
- var result = C.apply(obj, args);
375
- return ES.TypeIsObject(result) ? result : obj;
376
- }
377
- };
378
-
379
- var numberConversion = (function () {
380
- // from https://github.com/inexorabletash/polyfill/blob/master/typedarray.js#L176-L266
381
- // with permission and license, per https://twitter.com/inexorabletash/status/372206509540659200
382
-
383
- function roundToEven(n) {
384
- var w = Math.floor(n), f = n - w;
385
- if (f < 0.5) {
386
- return w;
387
- }
388
- if (f > 0.5) {
389
- return w + 1;
390
- }
391
- return w % 2 ? w + 1 : w;
392
- }
393
-
394
- function packIEEE754(v, ebits, fbits) {
395
- var bias = (1 << (ebits - 1)) - 1,
396
- s, e, f, ln,
397
- i, bits, str, bytes;
398
-
399
- // Compute sign, exponent, fraction
400
- if (v !== v) {
401
- // NaN
402
- // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
403
- e = (1 << ebits) - 1;
404
- f = Math.pow(2, fbits - 1);
405
- s = 0;
406
- } else if (v === Infinity || v === -Infinity) {
407
- e = (1 << ebits) - 1;
408
- f = 0;
409
- s = (v < 0) ? 1 : 0;
410
- } else if (v === 0) {
411
- e = 0;
412
- f = 0;
413
- s = (1 / v === -Infinity) ? 1 : 0;
414
- } else {
415
- s = v < 0;
416
- v = Math.abs(v);
417
-
418
- if (v >= Math.pow(2, 1 - bias)) {
419
- e = Math.min(Math.floor(Math.log(v) / Math.LN2), 1023);
420
- f = roundToEven(v / Math.pow(2, e) * Math.pow(2, fbits));
421
- if (f / Math.pow(2, fbits) >= 2) {
422
- e = e + 1;
423
- f = 1;
424
- }
425
- if (e > bias) {
426
- // Overflow
427
- e = (1 << ebits) - 1;
428
- f = 0;
429
- } else {
430
- // Normal
431
- e = e + bias;
432
- f = f - Math.pow(2, fbits);
433
- }
434
- } else {
435
- // Subnormal
436
- e = 0;
437
- f = roundToEven(v / Math.pow(2, 1 - bias - fbits));
438
- }
439
- }
440
-
441
- // Pack sign, exponent, fraction
442
- bits = [];
443
- for (i = fbits; i; i -= 1) {
444
- bits.push(f % 2 ? 1 : 0);
445
- f = Math.floor(f / 2);
446
- }
447
- for (i = ebits; i; i -= 1) {
448
- bits.push(e % 2 ? 1 : 0);
449
- e = Math.floor(e / 2);
450
- }
451
- bits.push(s ? 1 : 0);
452
- bits.reverse();
453
- str = bits.join('');
454
-
455
- // Bits to bytes
456
- bytes = [];
457
- while (str.length) {
458
- bytes.push(parseInt(str.slice(0, 8), 2));
459
- str = str.slice(8);
460
- }
461
- return bytes;
462
- }
463
-
464
- function unpackIEEE754(bytes, ebits, fbits) {
465
- // Bytes to bits
466
- var bits = [], i, j, b, str,
467
- bias, s, e, f;
468
-
469
- for (i = bytes.length; i; i -= 1) {
470
- b = bytes[i - 1];
471
- for (j = 8; j; j -= 1) {
472
- bits.push(b % 2 ? 1 : 0);
473
- b = b >> 1;
474
- }
475
- }
476
- bits.reverse();
477
- str = bits.join('');
478
-
479
- // Unpack sign, exponent, fraction
480
- bias = (1 << (ebits - 1)) - 1;
481
- s = parseInt(str.slice(0, 1), 2) ? -1 : 1;
482
- e = parseInt(str.slice(1, 1 + ebits), 2);
483
- f = parseInt(str.slice(1 + ebits), 2);
484
-
485
- // Produce number
486
- if (e === (1 << ebits) - 1) {
487
- return f !== 0 ? NaN : s * Infinity;
488
- } else if (e > 0) {
489
- // Normalized
490
- return s * Math.pow(2, e - bias) * (1 + f / Math.pow(2, fbits));
491
- } else if (f !== 0) {
492
- // Denormalized
493
- return s * Math.pow(2, -(bias - 1)) * (f / Math.pow(2, fbits));
494
- } else {
495
- return s < 0 ? -0 : 0;
496
- }
497
- }
498
-
499
- function unpackFloat64(b) { return unpackIEEE754(b, 11, 52); }
500
- function packFloat64(v) { return packIEEE754(v, 11, 52); }
501
- function unpackFloat32(b) { return unpackIEEE754(b, 8, 23); }
502
- function packFloat32(v) { return packIEEE754(v, 8, 23); }
503
-
504
- var conversions = {
505
- toFloat32: function (num) { return unpackFloat32(packFloat32(num)); }
506
- };
507
- if (typeof Float32Array !== 'undefined') {
508
- var float32array = new Float32Array(1);
509
- conversions.toFloat32 = function (num) {
510
- float32array[0] = num;
511
- return float32array[0];
512
- };
513
- }
514
- return conversions;
515
- }());
516
-
517
- defineProperties(String, {
518
- fromCodePoint: function (_) { // length = 1
519
- var points = _slice.call(arguments, 0, arguments.length);
520
- var result = [];
521
- var next;
522
- for (var i = 0, length = points.length; i < length; i++) {
523
- next = Number(points[i]);
524
- if (!ES.SameValue(next, ES.ToInteger(next)) ||
525
- next < 0 || next > 0x10FFFF) {
526
- throw new RangeError('Invalid code point ' + next);
527
- }
528
-
529
- if (next < 0x10000) {
530
- result.push(String.fromCharCode(next));
531
- } else {
532
- next -= 0x10000;
533
- result.push(String.fromCharCode((next >> 10) + 0xD800));
534
- result.push(String.fromCharCode((next % 0x400) + 0xDC00));
535
- }
536
- }
537
- return result.join('');
538
- },
539
-
540
- raw: function (callSite) { // raw.length===1
541
- var substitutions = _slice.call(arguments, 1, arguments.length);
542
- var cooked = ES.ToObject(callSite, 'bad callSite');
543
- var rawValue = cooked.raw;
544
- var raw = ES.ToObject(rawValue, 'bad raw value');
545
- var len = Object.keys(raw).length;
546
- var literalsegments = ES.ToLength(len);
547
- if (literalsegments === 0) {
548
- return '';
549
- }
550
-
551
- var stringElements = [];
552
- var nextIndex = 0;
553
- var nextKey, next, nextSeg, nextSub;
554
- while (nextIndex < literalsegments) {
555
- nextKey = String(nextIndex);
556
- next = raw[nextKey];
557
- nextSeg = String(next);
558
- stringElements.push(nextSeg);
559
- if (nextIndex + 1 >= literalsegments) {
560
- break;
561
- }
562
- next = substitutions[nextKey];
563
- if (typeof next === 'undefined') {
564
- break;
565
- }
566
- nextSub = String(next);
567
- stringElements.push(nextSub);
568
- nextIndex++;
569
- }
570
- return stringElements.join('');
571
- }
572
- });
573
-
574
- // Firefox 31 reports this function's length as 0
575
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484
576
- if (String.fromCodePoint.length !== 1) {
577
- var originalFromCodePoint = String.fromCodePoint;
578
- defineProperty(String, 'fromCodePoint', function (_) { return originalFromCodePoint.apply(this, arguments); }, true);
579
- }
580
-
581
- var StringShims = {
582
- // Fast repeat, uses the `Exponentiation by squaring` algorithm.
583
- // Perf: http://jsperf.com/string-repeat2/2
584
- repeat: (function () {
585
- var repeat = function (s, times) {
586
- if (times < 1) { return ''; }
587
- if (times % 2) { return repeat(s, times - 1) + s; }
588
- var half = repeat(s, times / 2);
589
- return half + half;
590
- };
591
-
592
- return function (times) {
593
- var thisStr = String(ES.CheckObjectCoercible(this));
594
- times = ES.ToInteger(times);
595
- if (times < 0 || times === Infinity) {
596
- throw new RangeError('Invalid String#repeat value');
597
- }
598
- return repeat(thisStr, times);
599
- };
600
- })(),
601
-
602
- startsWith: function (searchStr) {
603
- var thisStr = String(ES.CheckObjectCoercible(this));
604
- if (_toString.call(searchStr) === '[object RegExp]') {
605
- throw new TypeError('Cannot call method "startsWith" with a regex');
606
- }
607
- searchStr = String(searchStr);
608
- var startArg = arguments.length > 1 ? arguments[1] : void 0;
609
- var start = Math.max(ES.ToInteger(startArg), 0);
610
- return thisStr.slice(start, start + searchStr.length) === searchStr;
611
- },
612
-
613
- endsWith: function (searchStr) {
614
- var thisStr = String(ES.CheckObjectCoercible(this));
615
- if (_toString.call(searchStr) === '[object RegExp]') {
616
- throw new TypeError('Cannot call method "endsWith" with a regex');
617
- }
618
- searchStr = String(searchStr);
619
- var thisLen = thisStr.length;
620
- var posArg = arguments.length > 1 ? arguments[1] : void 0;
621
- var pos = typeof posArg === 'undefined' ? thisLen : ES.ToInteger(posArg);
622
- var end = Math.min(Math.max(pos, 0), thisLen);
623
- return thisStr.slice(end - searchStr.length, end) === searchStr;
624
- },
625
-
626
- contains: function (searchString) {
627
- var position = arguments.length > 1 ? arguments[1] : void 0;
628
- // Somehow this trick makes method 100% compat with the spec.
629
- return _indexOf.call(this, searchString, position) !== -1;
630
- },
631
-
632
- codePointAt: function (pos) {
633
- var thisStr = String(ES.CheckObjectCoercible(this));
634
- var position = ES.ToInteger(pos);
635
- var length = thisStr.length;
636
- if (position < 0 || position >= length) { return; }
637
- var first = thisStr.charCodeAt(position);
638
- var isEnd = (position + 1 === length);
639
- if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; }
640
- var second = thisStr.charCodeAt(position + 1);
641
- if (second < 0xDC00 || second > 0xDFFF) { return first; }
642
- return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
643
- }
644
- };
645
- defineProperties(String.prototype, StringShims);
646
-
647
- var hasStringTrimBug = '\u0085'.trim().length !== 1;
648
- if (hasStringTrimBug) {
649
- var originalStringTrim = String.prototype.trim;
650
- delete String.prototype.trim;
651
- // whitespace from: http://es5.github.io/#x15.5.4.20
652
- // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
653
- var ws = [
654
- '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
655
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
656
- '\u2029\uFEFF'
657
- ].join('');
658
- var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
659
- defineProperties(String.prototype, {
660
- trim: function () {
661
- if (typeof this === 'undefined' || this === null) {
662
- throw new TypeError("can't convert " + this + ' to object');
663
- }
664
- return String(this).replace(trimRegexp, '');
665
- }
666
- });
667
- }
668
-
669
- // see https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype-@@iterator
670
- var StringIterator = function (s) {
671
- this._s = String(ES.CheckObjectCoercible(s));
672
- this._i = 0;
673
- };
674
- StringIterator.prototype.next = function () {
675
- var s = this._s, i = this._i;
676
- if (typeof s === 'undefined' || i >= s.length) {
677
- this._s = void 0;
678
- return { value: void 0, done: true };
679
- }
680
- var first = s.charCodeAt(i), second, len;
681
- if (first < 0xD800 || first > 0xDBFF || (i + 1) == s.length) {
682
- len = 1;
683
- } else {
684
- second = s.charCodeAt(i + 1);
685
- len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2;
686
- }
687
- this._i = i + len;
688
- return { value: s.substr(i, len), done: false };
689
- };
690
- addIterator(StringIterator.prototype);
691
- addIterator(String.prototype, function () {
692
- return new StringIterator(this);
693
- });
694
-
695
- if (!startsWithIsCompliant) {
696
- // Firefox has a noncompliant startsWith implementation
697
- String.prototype.startsWith = StringShims.startsWith;
698
- String.prototype.endsWith = StringShims.endsWith;
699
- }
700
-
701
- var ArrayShims = {
702
- from: function (iterable) {
703
- var mapFn = arguments.length > 1 ? arguments[1] : void 0;
704
-
705
- var list = ES.ToObject(iterable, 'bad iterable');
706
- if (typeof mapFn !== 'undefined' && !ES.IsCallable(mapFn)) {
707
- throw new TypeError('Array.from: when provided, the second argument must be a function');
708
- }
709
-
710
- var hasThisArg = arguments.length > 2;
711
- var thisArg = hasThisArg ? arguments[2] : void 0;
712
-
713
- var usingIterator = ES.IsIterable(list);
714
- // does the spec really mean that Arrays should use ArrayIterator?
715
- // https://bugs.ecmascript.org/show_bug.cgi?id=2416
716
- //if (Array.isArray(list)) { usingIterator=false; }
717
-
718
- var length;
719
- var result, i, value;
720
- if (usingIterator) {
721
- i = 0;
722
- result = ES.IsCallable(this) ? Object(new this()) : [];
723
- var it = usingIterator ? ES.GetIterator(list) : null;
724
- var iterationValue;
725
-
726
- do {
727
- iterationValue = ES.IteratorNext(it);
728
- if (!iterationValue.done) {
729
- value = iterationValue.value;
730
- if (mapFn) {
731
- result[i] = hasThisArg ? mapFn.call(thisArg, value, i) : mapFn(value, i);
732
- } else {
733
- result[i] = value;
734
- }
735
- i += 1;
736
- }
737
- } while (!iterationValue.done);
738
- length = i;
739
- } else {
740
- length = ES.ToLength(list.length);
741
- result = ES.IsCallable(this) ? Object(new this(length)) : new Array(length);
742
- for (i = 0; i < length; ++i) {
743
- value = list[i];
744
- if (mapFn) {
745
- result[i] = hasThisArg ? mapFn.call(thisArg, value, i) : mapFn(value, i);
746
- } else {
747
- result[i] = value;
748
- }
749
- }
750
- }
751
-
752
- result.length = length;
753
- return result;
754
- },
755
-
756
- of: function () {
757
- return Array.from(arguments);
758
- }
759
- };
760
- defineProperties(Array, ArrayShims);
761
-
762
- var arrayFromSwallowsNegativeLengths = function () {
763
- try {
764
- return Array.from({ length: -1 }).length === 0;
765
- } catch (e) {
766
- return false;
767
- }
768
- };
769
- // Fixes a Firefox bug in v32
770
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993
771
- if (!arrayFromSwallowsNegativeLengths()) {
772
- defineProperty(Array, 'from', ArrayShims.from, true);
773
- }
774
-
775
- // Our ArrayIterator is private; see
776
- // https://github.com/paulmillr/es6-shim/issues/252
777
- ArrayIterator = function (array, kind) {
778
- this.i = 0;
779
- this.array = array;
780
- this.kind = kind;
781
- };
782
-
783
- defineProperties(ArrayIterator.prototype, {
784
- next: function () {
785
- var i = this.i, array = this.array;
786
- if (!(this instanceof ArrayIterator)) {
787
- throw new TypeError('Not an ArrayIterator');
788
- }
789
- if (typeof array !== 'undefined') {
790
- var len = ES.ToLength(array.length);
791
- for (; i < len; i++) {
792
- var kind = this.kind;
793
- var retval;
794
- if (kind === 'key') {
795
- retval = i;
796
- } else if (kind === 'value') {
797
- retval = array[i];
798
- } else if (kind === 'entry') {
799
- retval = [i, array[i]];
800
- }
801
- this.i = i + 1;
802
- return { value: retval, done: false };
803
- }
804
- }
805
- this.array = void 0;
806
- return { value: void 0, done: true };
807
- }
808
- });
809
- addIterator(ArrayIterator.prototype);
810
-
811
- var ArrayPrototypeShims = {
812
- copyWithin: function (target, start) {
813
- var end = arguments[2]; // copyWithin.length must be 2
814
- var o = ES.ToObject(this);
815
- var len = ES.ToLength(o.length);
816
- target = ES.ToInteger(target);
817
- start = ES.ToInteger(start);
818
- var to = target < 0 ? Math.max(len + target, 0) : Math.min(target, len);
819
- var from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
820
- end = typeof end === 'undefined' ? len : ES.ToInteger(end);
821
- var fin = end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
822
- var count = Math.min(fin - from, len - to);
823
- var direction = 1;
824
- if (from < to && to < (from + count)) {
825
- direction = -1;
826
- from += count - 1;
827
- to += count - 1;
828
- }
829
- while (count > 0) {
830
- if (_hasOwnProperty.call(o, from)) {
831
- o[to] = o[from];
832
- } else {
833
- delete o[from];
834
- }
835
- from += direction;
836
- to += direction;
837
- count -= 1;
838
- }
839
- return o;
840
- },
841
-
842
- fill: function (value) {
843
- var start = arguments.length > 1 ? arguments[1] : void 0;
844
- var end = arguments.length > 2 ? arguments[2] : void 0;
845
- var O = ES.ToObject(this);
846
- var len = ES.ToLength(O.length);
847
- start = ES.ToInteger(typeof start === 'undefined' ? 0 : start);
848
- end = ES.ToInteger(typeof end === 'undefined' ? len : end);
849
-
850
- var relativeStart = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
851
- var relativeEnd = end < 0 ? len + end : end;
852
-
853
- for (var i = relativeStart; i < len && i < relativeEnd; ++i) {
854
- O[i] = value;
855
- }
856
- return O;
857
- },
858
-
859
- find: function find(predicate) {
860
- var list = ES.ToObject(this);
861
- var length = ES.ToLength(list.length);
862
- if (!ES.IsCallable(predicate)) {
863
- throw new TypeError('Array#find: predicate must be a function');
864
- }
865
- var thisArg = arguments[1];
866
- for (var i = 0, value; i < length; i++) {
867
- value = list[i];
868
- if (predicate.call(thisArg, value, i, list)) { return value; }
869
- }
870
- return;
871
- },
872
-
873
- findIndex: function findIndex(predicate) {
874
- var list = ES.ToObject(this);
875
- var length = ES.ToLength(list.length);
876
- if (!ES.IsCallable(predicate)) {
877
- throw new TypeError('Array#findIndex: predicate must be a function');
878
- }
879
- var thisArg = arguments[1];
880
- for (var i = 0; i < length; i++) {
881
- if (predicate.call(thisArg, list[i], i, list)) { return i; }
882
- }
883
- return -1;
884
- },
885
-
886
- keys: function () {
887
- return new ArrayIterator(this, 'key');
888
- },
889
-
890
- values: function () {
891
- return new ArrayIterator(this, 'value');
892
- },
893
-
894
- entries: function () {
895
- return new ArrayIterator(this, 'entry');
896
- }
897
- };
898
- // Safari 7.1 defines Array#keys and Array#entries natively,
899
- // but the resulting ArrayIterator objects don't have a "next" method.
900
- if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) {
901
- delete Array.prototype.keys;
902
- }
903
- if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) {
904
- delete Array.prototype.entries;
905
- }
906
- defineProperties(Array.prototype, ArrayPrototypeShims);
907
-
908
- addIterator(Array.prototype, function () { return this.values(); });
909
- // Chrome defines keys/values/entries on Array, but doesn't give us
910
- // any way to identify its iterator. So add our own shimmed field.
911
- if (Object.getPrototypeOf) {
912
- addIterator(Object.getPrototypeOf([].values()));
913
- }
914
-
915
- var maxSafeInteger = Math.pow(2, 53) - 1;
916
- defineProperties(Number, {
917
- MAX_SAFE_INTEGER: maxSafeInteger,
918
- MIN_SAFE_INTEGER: -maxSafeInteger,
919
- EPSILON: 2.220446049250313e-16,
920
-
921
- parseInt: globals.parseInt,
922
- parseFloat: globals.parseFloat,
923
-
924
- isFinite: function (value) {
925
- return typeof value === 'number' && global_isFinite(value);
926
- },
927
-
928
- isInteger: function (value) {
929
- return Number.isFinite(value) &&
930
- ES.ToInteger(value) === value;
931
- },
932
-
933
- isSafeInteger: function (value) {
934
- return Number.isInteger(value) && Math.abs(value) <= Number.MAX_SAFE_INTEGER;
935
- },
936
-
937
- isNaN: function (value) {
938
- // NaN !== NaN, but they are identical.
939
- // NaNs are the only non-reflexive value, i.e., if x !== x,
940
- // then x is NaN.
941
- // isNaN is broken: it converts its argument to number, so
942
- // isNaN('foo') => true
943
- return value !== value;
944
- }
945
-
946
- });
947
-
948
- // Work around bugs in Array#find and Array#findIndex -- early
949
- // implementations skipped holes in sparse arrays. (Note that the
950
- // implementations of find/findIndex indirectly use shimmed
951
- // methods of Number, so this test has to happen down here.)
952
- if (![, 1].find(function (item, idx) { return idx === 0; })) {
953
- defineProperty(Array.prototype, 'find', ArrayPrototypeShims.find, true);
954
- }
955
- if ([, 1].findIndex(function (item, idx) { return idx === 0; }) !== 0) {
956
- defineProperty(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex, true);
957
- }
958
-
959
- if (supportsDescriptors) {
960
- defineProperties(Object, {
961
- getPropertyDescriptor: function (subject, name) {
962
- var pd = Object.getOwnPropertyDescriptor(subject, name);
963
- var proto = Object.getPrototypeOf(subject);
964
- while (typeof pd === 'undefined' && proto !== null) {
965
- pd = Object.getOwnPropertyDescriptor(proto, name);
966
- proto = Object.getPrototypeOf(proto);
967
- }
968
- return pd;
969
- },
970
-
971
- getPropertyNames: function (subject) {
972
- var result = Object.getOwnPropertyNames(subject);
973
- var proto = Object.getPrototypeOf(subject);
974
-
975
- var addProperty = function (property) {
976
- if (result.indexOf(property) === -1) {
977
- result.push(property);
978
- }
979
- };
980
-
981
- while (proto !== null) {
982
- Object.getOwnPropertyNames(proto).forEach(addProperty);
983
- proto = Object.getPrototypeOf(proto);
984
- }
985
- return result;
986
- }
987
- });
988
-
989
- defineProperties(Object, {
990
- // 19.1.3.1
991
- assign: function (target, source) {
992
- if (!ES.TypeIsObject(target)) {
993
- throw new TypeError('target must be an object');
994
- }
995
- return Array.prototype.reduce.call(arguments, function (target, source) {
996
- return Object.keys(Object(source)).reduce(function (target, key) {
997
- target[key] = source[key];
998
- return target;
999
- }, target);
1000
- });
1001
- },
1002
-
1003
- is: function (a, b) {
1004
- return ES.SameValue(a, b);
1005
- },
1006
-
1007
- // 19.1.3.9
1008
- // shim from https://gist.github.com/WebReflection/5593554
1009
- setPrototypeOf: (function (Object, magic) {
1010
- var set;
1011
-
1012
- var checkArgs = function (O, proto) {
1013
- if (!ES.TypeIsObject(O)) {
1014
- throw new TypeError('cannot set prototype on a non-object');
1015
- }
1016
- if (!(proto === null || ES.TypeIsObject(proto))) {
1017
- throw new TypeError('can only set prototype to an object or null' + proto);
1018
- }
1019
- };
1020
-
1021
- var setPrototypeOf = function (O, proto) {
1022
- checkArgs(O, proto);
1023
- set.call(O, proto);
1024
- return O;
1025
- };
1026
-
1027
- try {
1028
- // this works already in Firefox and Safari
1029
- set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
1030
- set.call({}, null);
1031
- } catch (e) {
1032
- if (Object.prototype !== {}[magic]) {
1033
- // IE < 11 cannot be shimmed
1034
- return;
1035
- }
1036
- // probably Chrome or some old Mobile stock browser
1037
- set = function (proto) {
1038
- this[magic] = proto;
1039
- };
1040
- // please note that this will **not** work
1041
- // in those browsers that do not inherit
1042
- // __proto__ by mistake from Object.prototype
1043
- // in these cases we should probably throw an error
1044
- // or at least be informed about the issue
1045
- setPrototypeOf.polyfill = setPrototypeOf(
1046
- setPrototypeOf({}, null),
1047
- Object.prototype
1048
- ) instanceof Object;
1049
- // setPrototypeOf.polyfill === true means it works as meant
1050
- // setPrototypeOf.polyfill === false means it's not 100% reliable
1051
- // setPrototypeOf.polyfill === undefined
1052
- // or
1053
- // setPrototypeOf.polyfill == null means it's not a polyfill
1054
- // which means it works as expected
1055
- // we can even delete Object.prototype.__proto__;
1056
- }
1057
- return setPrototypeOf;
1058
- })(Object, '__proto__')
1059
- });
1060
- }
1061
-
1062
- // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work,
1063
- // but Object.create(null) does.
1064
- if (Object.setPrototypeOf && Object.getPrototypeOf &&
1065
- Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null &&
1066
- Object.getPrototypeOf(Object.create(null)) === null) {
1067
- (function () {
1068
- var FAKENULL = Object.create(null);
1069
- var gpo = Object.getPrototypeOf, spo = Object.setPrototypeOf;
1070
- Object.getPrototypeOf = function (o) {
1071
- var result = gpo(o);
1072
- return result === FAKENULL ? null : result;
1073
- };
1074
- Object.setPrototypeOf = function (o, p) {
1075
- if (p === null) { p = FAKENULL; }
1076
- return spo(o, p);
1077
- };
1078
- Object.setPrototypeOf.polyfill = false;
1079
- })();
1080
- }
1081
-
1082
- try {
1083
- Object.keys('foo');
1084
- } catch (e) {
1085
- var originalObjectKeys = Object.keys;
1086
- Object.keys = function (obj) {
1087
- return originalObjectKeys(ES.ToObject(obj));
1088
- };
1089
- }
1090
-
1091
- var MathShims = {
1092
- acosh: function (value) {
1093
- value = Number(value);
1094
- if (Number.isNaN(value) || value < 1) { return NaN; }
1095
- if (value === 1) { return 0; }
1096
- if (value === Infinity) { return value; }
1097
- return Math.log(value + Math.sqrt(value * value - 1));
1098
- },
1099
-
1100
- asinh: function (value) {
1101
- value = Number(value);
1102
- if (value === 0 || !global_isFinite(value)) {
1103
- return value;
1104
- }
1105
- return value < 0 ? -Math.asinh(-value) : Math.log(value + Math.sqrt(value * value + 1));
1106
- },
1107
-
1108
- atanh: function (value) {
1109
- value = Number(value);
1110
- if (Number.isNaN(value) || value < -1 || value > 1) {
1111
- return NaN;
1112
- }
1113
- if (value === -1) { return -Infinity; }
1114
- if (value === 1) { return Infinity; }
1115
- if (value === 0) { return value; }
1116
- return 0.5 * Math.log((1 + value) / (1 - value));
1117
- },
1118
-
1119
- cbrt: function (value) {
1120
- value = Number(value);
1121
- if (value === 0) { return value; }
1122
- var negate = value < 0, result;
1123
- if (negate) { value = -value; }
1124
- result = Math.pow(value, 1 / 3);
1125
- return negate ? -result : result;
1126
- },
1127
-
1128
- clz32: function (value) {
1129
- // See https://bugs.ecmascript.org/show_bug.cgi?id=2465
1130
- value = Number(value);
1131
- var number = ES.ToUint32(value);
1132
- if (number === 0) {
1133
- return 32;
1134
- }
1135
- return 32 - (number).toString(2).length;
1136
- },
1137
-
1138
- cosh: function (value) {
1139
- value = Number(value);
1140
- if (value === 0) { return 1; } // +0 or -0
1141
- if (Number.isNaN(value)) { return NaN; }
1142
- if (!global_isFinite(value)) { return Infinity; }
1143
- if (value < 0) { value = -value; }
1144
- if (value > 21) { return Math.exp(value) / 2; }
1145
- return (Math.exp(value) + Math.exp(-value)) / 2;
1146
- },
1147
-
1148
- expm1: function (value) {
1149
- value = Number(value);
1150
- if (value === -Infinity) { return -1; }
1151
- if (!global_isFinite(value) || value === 0) { return value; }
1152
- return Math.exp(value) - 1;
1153
- },
1154
-
1155
- hypot: function (x, y) {
1156
- var anyNaN = false;
1157
- var allZero = true;
1158
- var anyInfinity = false;
1159
- var numbers = [];
1160
- Array.prototype.every.call(arguments, function (arg) {
1161
- var num = Number(arg);
1162
- if (Number.isNaN(num)) {
1163
- anyNaN = true;
1164
- } else if (num === Infinity || num === -Infinity) {
1165
- anyInfinity = true;
1166
- } else if (num !== 0) {
1167
- allZero = false;
1168
- }
1169
- if (anyInfinity) {
1170
- return false;
1171
- } else if (!anyNaN) {
1172
- numbers.push(Math.abs(num));
1173
- }
1174
- return true;
1175
- });
1176
- if (anyInfinity) { return Infinity; }
1177
- if (anyNaN) { return NaN; }
1178
- if (allZero) { return 0; }
1179
-
1180
- numbers.sort(function (a, b) { return b - a; });
1181
- var largest = numbers[0];
1182
- var divided = numbers.map(function (number) { return number / largest; });
1183
- var sum = divided.reduce(function (sum, number) { return sum += number * number; }, 0);
1184
- return largest * Math.sqrt(sum);
1185
- },
1186
-
1187
- log2: function (value) {
1188
- return Math.log(value) * Math.LOG2E;
1189
- },
1190
-
1191
- log10: function (value) {
1192
- return Math.log(value) * Math.LOG10E;
1193
- },
1194
-
1195
- log1p: function (value) {
1196
- value = Number(value);
1197
- if (value < -1 || Number.isNaN(value)) { return NaN; }
1198
- if (value === 0 || value === Infinity) { return value; }
1199
- if (value === -1) { return -Infinity; }
1200
- var result = 0;
1201
- var n = 50;
1202
-
1203
- if (value < 0 || value > 1) { return Math.log(1 + value); }
1204
- for (var i = 1; i < n; i++) {
1205
- if ((i % 2) === 0) {
1206
- result -= Math.pow(value, i) / i;
1207
- } else {
1208
- result += Math.pow(value, i) / i;
1209
- }
1210
- }
1211
-
1212
- return result;
1213
- },
1214
-
1215
- sign: function (value) {
1216
- var number = +value;
1217
- if (number === 0) { return number; }
1218
- if (Number.isNaN(number)) { return number; }
1219
- return number < 0 ? -1 : 1;
1220
- },
1221
-
1222
- sinh: function (value) {
1223
- value = Number(value);
1224
- if (!global_isFinite(value) || value === 0) { return value; }
1225
- return (Math.exp(value) - Math.exp(-value)) / 2;
1226
- },
1227
-
1228
- tanh: function (value) {
1229
- value = Number(value);
1230
- if (Number.isNaN(value) || value === 0) { return value; }
1231
- if (value === Infinity) { return 1; }
1232
- if (value === -Infinity) { return -1; }
1233
- return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
1234
- },
1235
-
1236
- trunc: function (value) {
1237
- var number = Number(value);
1238
- return number < 0 ? -Math.floor(-number) : Math.floor(number);
1239
- },
1240
-
1241
- imul: function (x, y) {
1242
- // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
1243
- x = ES.ToUint32(x);
1244
- y = ES.ToUint32(y);
1245
- var ah = (x >>> 16) & 0xffff;
1246
- var al = x & 0xffff;
1247
- var bh = (y >>> 16) & 0xffff;
1248
- var bl = y & 0xffff;
1249
- // the shift by 0 fixes the sign on the high part
1250
- // the final |0 converts the unsigned value into a signed value
1251
- return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
1252
- },
1253
-
1254
- fround: function (x) {
1255
- if (x === 0 || x === Infinity || x === -Infinity || Number.isNaN(x)) {
1256
- return x;
1257
- }
1258
- var num = Number(x);
1259
- return numberConversion.toFloat32(num);
1260
- }
1261
- };
1262
- defineProperties(Math, MathShims);
1263
-
1264
- if (Math.imul(0xffffffff, 5) !== -5) {
1265
- // Safari 6.1, at least, reports "0" for this value
1266
- Math.imul = MathShims.imul;
1267
- }
1268
-
1269
- // Promises
1270
- // Simplest possible implementation; use a 3rd-party library if you
1271
- // want the best possible speed and/or long stack traces.
1272
- var PromiseShim = (function () {
1273
-
1274
- var Promise, Promise$prototype;
1275
-
1276
- ES.IsPromise = function (promise) {
1277
- if (!ES.TypeIsObject(promise)) {
1278
- return false;
1279
- }
1280
- if (!promise._promiseConstructor) {
1281
- // _promiseConstructor is a bit more unique than _status, so we'll
1282
- // check that instead of the [[PromiseStatus]] internal field.
1283
- return false;
1284
- }
1285
- if (typeof promise._status === 'undefined') {
1286
- return false; // uninitialized
1287
- }
1288
- return true;
1289
- };
1290
-
1291
- // "PromiseCapability" in the spec is what most promise implementations
1292
- // call a "deferred".
1293
- var PromiseCapability = function (C) {
1294
- if (!ES.IsCallable(C)) {
1295
- throw new TypeError('bad promise constructor');
1296
- }
1297
- var capability = this;
1298
- var resolver = function (resolve, reject) {
1299
- capability.resolve = resolve;
1300
- capability.reject = reject;
1301
- };
1302
- capability.promise = ES.Construct(C, [resolver]);
1303
- // see https://bugs.ecmascript.org/show_bug.cgi?id=2478
1304
- if (!capability.promise._es6construct) {
1305
- throw new TypeError('bad promise constructor');
1306
- }
1307
- if (!(ES.IsCallable(capability.resolve) &&
1308
- ES.IsCallable(capability.reject))) {
1309
- throw new TypeError('bad promise constructor');
1310
- }
1311
- };
1312
-
1313
- // find an appropriate setImmediate-alike
1314
- var setTimeout = globals.setTimeout;
1315
- var makeZeroTimeout;
1316
- if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) {
1317
- makeZeroTimeout = function () {
1318
- // from http://dbaron.org/log/20100309-faster-timeouts
1319
- var timeouts = [];
1320
- var messageName = 'zero-timeout-message';
1321
- var setZeroTimeout = function (fn) {
1322
- timeouts.push(fn);
1323
- window.postMessage(messageName, '*');
1324
- };
1325
- var handleMessage = function (event) {
1326
- if (event.source == window && event.data == messageName) {
1327
- event.stopPropagation();
1328
- if (timeouts.length === 0) { return; }
1329
- var fn = timeouts.shift();
1330
- fn();
1331
- }
1332
- };
1333
- window.addEventListener('message', handleMessage, true);
1334
- return setZeroTimeout;
1335
- };
1336
- }
1337
- var makePromiseAsap = function () {
1338
- // An efficient task-scheduler based on a pre-existing Promise
1339
- // implementation, which we can use even if we override the
1340
- // global Promise below (in order to workaround bugs)
1341
- // https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671
1342
- var P = globals.Promise;
1343
- return P && P.resolve && function (task) {
1344
- return P.resolve().then(task);
1345
- };
1346
- };
1347
- var enqueue = ES.IsCallable(globals.setImmediate) ?
1348
- globals.setImmediate.bind(globals) :
1349
- typeof process === 'object' && process.nextTick ? process.nextTick :
1350
- makePromiseAsap() ||
1351
- (ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() :
1352
- function (task) { setTimeout(task, 0); }); // fallback
1353
-
1354
- var triggerPromiseReactions = function (reactions, x) {
1355
- reactions.forEach(function (reaction) {
1356
- enqueue(function () {
1357
- // PromiseReactionTask
1358
- var handler = reaction.handler;
1359
- var capability = reaction.capability;
1360
- var resolve = capability.resolve;
1361
- var reject = capability.reject;
1362
- try {
1363
- var result = handler(x);
1364
- if (result === capability.promise) {
1365
- throw new TypeError('self resolution');
1366
- }
1367
- var updateResult =
1368
- updatePromiseFromPotentialThenable(result, capability);
1369
- if (!updateResult) {
1370
- resolve(result);
1371
- }
1372
- } catch (e) {
1373
- reject(e);
1374
- }
1375
- });
1376
- });
1377
- };
1378
-
1379
- var updatePromiseFromPotentialThenable = function (x, capability) {
1380
- if (!ES.TypeIsObject(x)) {
1381
- return false;
1382
- }
1383
- var resolve = capability.resolve;
1384
- var reject = capability.reject;
1385
- try {
1386
- var then = x.then; // only one invocation of accessor
1387
- if (!ES.IsCallable(then)) { return false; }
1388
- then.call(x, resolve, reject);
1389
- } catch (e) {
1390
- reject(e);
1391
- }
1392
- return true;
1393
- };
1394
-
1395
- var promiseResolutionHandler = function (promise, onFulfilled, onRejected) {
1396
- return function (x) {
1397
- if (x === promise) {
1398
- return onRejected(new TypeError('self resolution'));
1399
- }
1400
- var C = promise._promiseConstructor;
1401
- var capability = new PromiseCapability(C);
1402
- var updateResult = updatePromiseFromPotentialThenable(x, capability);
1403
- if (updateResult) {
1404
- return capability.promise.then(onFulfilled, onRejected);
1405
- } else {
1406
- return onFulfilled(x);
1407
- }
1408
- };
1409
- };
1410
-
1411
- Promise = function (resolver) {
1412
- var promise = this;
1413
- promise = emulateES6construct(promise);
1414
- if (!promise._promiseConstructor) {
1415
- // we use _promiseConstructor as a stand-in for the internal
1416
- // [[PromiseStatus]] field; it's a little more unique.
1417
- throw new TypeError('bad promise');
1418
- }
1419
- if (typeof promise._status !== 'undefined') {
1420
- throw new TypeError('promise already initialized');
1421
- }
1422
- // see https://bugs.ecmascript.org/show_bug.cgi?id=2482
1423
- if (!ES.IsCallable(resolver)) {
1424
- throw new TypeError('not a valid resolver');
1425
- }
1426
- promise._status = 'unresolved';
1427
- promise._resolveReactions = [];
1428
- promise._rejectReactions = [];
1429
-
1430
- var resolve = function (resolution) {
1431
- if (promise._status !== 'unresolved') { return; }
1432
- var reactions = promise._resolveReactions;
1433
- promise._result = resolution;
1434
- promise._resolveReactions = void 0;
1435
- promise._rejectReactions = void 0;
1436
- promise._status = 'has-resolution';
1437
- triggerPromiseReactions(reactions, resolution);
1438
- };
1439
- var reject = function (reason) {
1440
- if (promise._status !== 'unresolved') { return; }
1441
- var reactions = promise._rejectReactions;
1442
- promise._result = reason;
1443
- promise._resolveReactions = void 0;
1444
- promise._rejectReactions = void 0;
1445
- promise._status = 'has-rejection';
1446
- triggerPromiseReactions(reactions, reason);
1447
- };
1448
- try {
1449
- resolver(resolve, reject);
1450
- } catch (e) {
1451
- reject(e);
1452
- }
1453
- return promise;
1454
- };
1455
- Promise$prototype = Promise.prototype;
1456
- defineProperties(Promise, {
1457
- '@@create': function (obj) {
1458
- var constructor = this;
1459
- // AllocatePromise
1460
- // The `obj` parameter is a hack we use for es5
1461
- // compatibility.
1462
- var prototype = constructor.prototype || Promise$prototype;
1463
- obj = obj || create(prototype);
1464
- defineProperties(obj, {
1465
- _status: void 0,
1466
- _result: void 0,
1467
- _resolveReactions: void 0,
1468
- _rejectReactions: void 0,
1469
- _promiseConstructor: void 0
1470
- });
1471
- obj._promiseConstructor = constructor;
1472
- return obj;
1473
- }
1474
- });
1475
-
1476
- var _promiseAllResolver = function (index, values, capability, remaining) {
1477
- var done = false;
1478
- return function (x) {
1479
- if (done) { return; } // protect against being called multiple times
1480
- done = true;
1481
- values[index] = x;
1482
- if ((--remaining.count) === 0) {
1483
- var resolve = capability.resolve;
1484
- resolve(values); // call w/ this===undefined
1485
- }
1486
- };
1487
- };
1488
-
1489
- Promise.all = function (iterable) {
1490
- var C = this;
1491
- var capability = new PromiseCapability(C);
1492
- var resolve = capability.resolve;
1493
- var reject = capability.reject;
1494
- try {
1495
- if (!ES.IsIterable(iterable)) {
1496
- throw new TypeError('bad iterable');
1497
- }
1498
- var it = ES.GetIterator(iterable);
1499
- var values = [], remaining = { count: 1 };
1500
- for (var index = 0; ; index++) {
1501
- var next = ES.IteratorNext(it);
1502
- if (next.done) {
1503
- break;
1504
- }
1505
- var nextPromise = C.resolve(next.value);
1506
- var resolveElement = _promiseAllResolver(
1507
- index, values, capability, remaining
1508
- );
1509
- remaining.count++;
1510
- nextPromise.then(resolveElement, capability.reject);
1511
- }
1512
- if ((--remaining.count) === 0) {
1513
- resolve(values); // call w/ this===undefined
1514
- }
1515
- } catch (e) {
1516
- reject(e);
1517
- }
1518
- return capability.promise;
1519
- };
1520
-
1521
- Promise.race = function (iterable) {
1522
- var C = this;
1523
- var capability = new PromiseCapability(C);
1524
- var resolve = capability.resolve;
1525
- var reject = capability.reject;
1526
- try {
1527
- if (!ES.IsIterable(iterable)) {
1528
- throw new TypeError('bad iterable');
1529
- }
1530
- var it = ES.GetIterator(iterable);
1531
- while (true) {
1532
- var next = ES.IteratorNext(it);
1533
- if (next.done) {
1534
- // If iterable has no items, resulting promise will never
1535
- // resolve; see:
1536
- // https://github.com/domenic/promises-unwrapping/issues/75
1537
- // https://bugs.ecmascript.org/show_bug.cgi?id=2515
1538
- break;
1539
- }
1540
- var nextPromise = C.resolve(next.value);
1541
- nextPromise.then(resolve, reject);
1542
- }
1543
- } catch (e) {
1544
- reject(e);
1545
- }
1546
- return capability.promise;
1547
- };
1548
-
1549
- Promise.reject = function (reason) {
1550
- var C = this;
1551
- var capability = new PromiseCapability(C);
1552
- var reject = capability.reject;
1553
- reject(reason); // call with this===undefined
1554
- return capability.promise;
1555
- };
1556
-
1557
- Promise.resolve = function (v) {
1558
- var C = this;
1559
- if (ES.IsPromise(v)) {
1560
- var constructor = v._promiseConstructor;
1561
- if (constructor === C) { return v; }
1562
- }
1563
- var capability = new PromiseCapability(C);
1564
- var resolve = capability.resolve;
1565
- resolve(v); // call with this===undefined
1566
- return capability.promise;
1567
- };
1568
-
1569
- Promise.prototype['catch'] = function (onRejected) {
1570
- return this.then(void 0, onRejected);
1571
- };
1572
-
1573
- Promise.prototype.then = function (onFulfilled, onRejected) {
1574
- var promise = this;
1575
- if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); }
1576
- // this.constructor not this._promiseConstructor; see
1577
- // https://bugs.ecmascript.org/show_bug.cgi?id=2513
1578
- var C = this.constructor;
1579
- var capability = new PromiseCapability(C);
1580
- if (!ES.IsCallable(onRejected)) {
1581
- onRejected = function (e) { throw e; };
1582
- }
1583
- if (!ES.IsCallable(onFulfilled)) {
1584
- onFulfilled = function (x) { return x; };
1585
- }
1586
- var resolutionHandler =
1587
- promiseResolutionHandler(promise, onFulfilled, onRejected);
1588
- var resolveReaction =
1589
- { capability: capability, handler: resolutionHandler };
1590
- var rejectReaction =
1591
- { capability: capability, handler: onRejected };
1592
- switch (promise._status) {
1593
- case 'unresolved':
1594
- promise._resolveReactions.push(resolveReaction);
1595
- promise._rejectReactions.push(rejectReaction);
1596
- break;
1597
- case 'has-resolution':
1598
- triggerPromiseReactions([resolveReaction], promise._result);
1599
- break;
1600
- case 'has-rejection':
1601
- triggerPromiseReactions([rejectReaction], promise._result);
1602
- break;
1603
- default:
1604
- throw new TypeError('unexpected');
1605
- }
1606
- return capability.promise;
1607
- };
1608
-
1609
- return Promise;
1610
- })();
1611
- // export the Promise constructor.
1612
- defineProperties(globals, { Promise: PromiseShim });
1613
- // In Chrome 33 (and thereabouts) Promise is defined, but the
1614
- // implementation is buggy in a number of ways. Let's check subclassing
1615
- // support to see if we have a buggy implementation.
1616
- var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) {
1617
- return S.resolve(42) instanceof S;
1618
- });
1619
- var promiseIgnoresNonFunctionThenCallbacks = (function () {
1620
- try {
1621
- globals.Promise.reject(42).then(null, 5).then(null, function () {});
1622
- return true;
1623
- } catch (ex) {
1624
- return false;
1625
- }
1626
- }());
1627
- var promiseRequiresObjectContext = (function () {
1628
- try { Promise.call(3, function () {}); } catch (e) { return true; }
1629
- return false;
1630
- }());
1631
- if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks || !promiseRequiresObjectContext) {
1632
- globals.Promise = PromiseShim;
1633
- }
1634
-
1635
- // Map and Set require a true ES5 environment
1636
- // Their fast path also requires that the environment preserve
1637
- // property insertion order, which is not guaranteed by the spec.
1638
- var testOrder = function (a) {
1639
- var b = Object.keys(a.reduce(function (o, k) {
1640
- o[k] = true;
1641
- return o;
1642
- }, {}));
1643
- return a.join(':') === b.join(':');
1644
- };
1645
- var preservesInsertionOrder = testOrder(['z', 'a', 'bb']);
1646
- // some engines (eg, Chrome) only preserve insertion order for string keys
1647
- var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]);
1648
-
1649
- if (supportsDescriptors) {
1650
-
1651
- var fastkey = function fastkey(key) {
1652
- if (!preservesInsertionOrder) {
1653
- return null;
1654
- }
1655
- var type = typeof key;
1656
- if (type === 'string') {
1657
- return '$' + key;
1658
- } else if (type === 'number') {
1659
- // note that -0 will get coerced to "0" when used as a property key
1660
- if (!preservesNumericInsertionOrder) {
1661
- return 'n' + key;
1662
- }
1663
- return key;
1664
- }
1665
- return null;
1666
- };
1667
-
1668
- var emptyObject = function emptyObject() {
1669
- // accomodate some older not-quite-ES5 browsers
1670
- return Object.create ? Object.create(null) : {};
1671
- };
1672
-
1673
- var collectionShims = {
1674
- Map: (function () {
1675
-
1676
- var empty = {};
1677
-
1678
- function MapEntry(key, value) {
1679
- this.key = key;
1680
- this.value = value;
1681
- this.next = null;
1682
- this.prev = null;
1683
- }
1684
-
1685
- MapEntry.prototype.isRemoved = function () {
1686
- return this.key === empty;
1687
- };
1688
-
1689
- function MapIterator(map, kind) {
1690
- this.head = map._head;
1691
- this.i = this.head;
1692
- this.kind = kind;
1693
- }
1694
-
1695
- MapIterator.prototype = {
1696
- next: function () {
1697
- var i = this.i, kind = this.kind, head = this.head, result;
1698
- if (typeof this.i === 'undefined') {
1699
- return { value: void 0, done: true };
1700
- }
1701
- while (i.isRemoved() && i !== head) {
1702
- // back up off of removed entries
1703
- i = i.prev;
1704
- }
1705
- // advance to next unreturned element.
1706
- while (i.next !== head) {
1707
- i = i.next;
1708
- if (!i.isRemoved()) {
1709
- if (kind === 'key') {
1710
- result = i.key;
1711
- } else if (kind === 'value') {
1712
- result = i.value;
1713
- } else {
1714
- result = [i.key, i.value];
1715
- }
1716
- this.i = i;
1717
- return { value: result, done: false };
1718
- }
1719
- }
1720
- // once the iterator is done, it is done forever.
1721
- this.i = void 0;
1722
- return { value: void 0, done: true };
1723
- }
1724
- };
1725
- addIterator(MapIterator.prototype);
1726
-
1727
- function Map(iterable) {
1728
- var map = this;
1729
- map = emulateES6construct(map);
1730
- if (!map._es6map) {
1731
- throw new TypeError('bad map');
1732
- }
1733
-
1734
- var head = new MapEntry(null, null);
1735
- // circular doubly-linked list.
1736
- head.next = head.prev = head;
1737
-
1738
- defineProperties(map, {
1739
- _head: head,
1740
- _storage: emptyObject(),
1741
- _size: 0
1742
- });
1743
-
1744
- // Optionally initialize map from iterable
1745
- if (typeof iterable !== 'undefined' && iterable !== null) {
1746
- var it = ES.GetIterator(iterable);
1747
- var adder = map.set;
1748
- if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); }
1749
- while (true) {
1750
- var next = ES.IteratorNext(it);
1751
- if (next.done) { break; }
1752
- var nextItem = next.value;
1753
- if (!ES.TypeIsObject(nextItem)) {
1754
- throw new TypeError('expected iterable of pairs');
1755
- }
1756
- adder.call(map, nextItem[0], nextItem[1]);
1757
- }
1758
- }
1759
- return map;
1760
- }
1761
- var Map$prototype = Map.prototype;
1762
- defineProperties(Map, {
1763
- '@@create': function (obj) {
1764
- var constructor = this;
1765
- var prototype = constructor.prototype || Map$prototype;
1766
- obj = obj || create(prototype);
1767
- defineProperties(obj, { _es6map: true });
1768
- return obj;
1769
- }
1770
- });
1771
-
1772
- Object.defineProperty(Map.prototype, 'size', {
1773
- configurable: true,
1774
- enumerable: false,
1775
- get: function () {
1776
- if (typeof this._size === 'undefined') {
1777
- throw new TypeError('size method called on incompatible Map');
1778
- }
1779
- return this._size;
1780
- }
1781
- });
1782
-
1783
- defineProperties(Map.prototype, {
1784
- get: function (key) {
1785
- var fkey = fastkey(key);
1786
- if (fkey !== null) {
1787
- // fast O(1) path
1788
- var entry = this._storage[fkey];
1789
- if (entry) {
1790
- return entry.value;
1791
- } else {
1792
- return;
1793
- }
1794
- }
1795
- var head = this._head, i = head;
1796
- while ((i = i.next) !== head) {
1797
- if (ES.SameValueZero(i.key, key)) {
1798
- return i.value;
1799
- }
1800
- }
1801
- return;
1802
- },
1803
-
1804
- has: function (key) {
1805
- var fkey = fastkey(key);
1806
- if (fkey !== null) {
1807
- // fast O(1) path
1808
- return typeof this._storage[fkey] !== 'undefined';
1809
- }
1810
- var head = this._head, i = head;
1811
- while ((i = i.next) !== head) {
1812
- if (ES.SameValueZero(i.key, key)) {
1813
- return true;
1814
- }
1815
- }
1816
- return false;
1817
- },
1818
-
1819
- set: function (key, value) {
1820
- var head = this._head, i = head, entry;
1821
- var fkey = fastkey(key);
1822
- if (fkey !== null) {
1823
- // fast O(1) path
1824
- if (typeof this._storage[fkey] !== 'undefined') {
1825
- this._storage[fkey].value = value;
1826
- return;
1827
- } else {
1828
- entry = this._storage[fkey] = new MapEntry(key, value);
1829
- i = head.prev;
1830
- // fall through
1831
- }
1832
- }
1833
- while ((i = i.next) !== head) {
1834
- if (ES.SameValueZero(i.key, key)) {
1835
- i.value = value;
1836
- return;
1837
- }
1838
- }
1839
- entry = entry || new MapEntry(key, value);
1840
- if (ES.SameValue(-0, key)) {
1841
- entry.key = +0; // coerce -0 to +0 in entry
1842
- }
1843
- entry.next = this._head;
1844
- entry.prev = this._head.prev;
1845
- entry.prev.next = entry;
1846
- entry.next.prev = entry;
1847
- this._size += 1;
1848
- return this;
1849
- },
1850
-
1851
- 'delete': function (key) {
1852
- var head = this._head, i = head;
1853
- var fkey = fastkey(key);
1854
- if (fkey !== null) {
1855
- // fast O(1) path
1856
- if (typeof this._storage[fkey] === 'undefined') {
1857
- return false;
1858
- }
1859
- i = this._storage[fkey].prev;
1860
- delete this._storage[fkey];
1861
- // fall through
1862
- }
1863
- while ((i = i.next) !== head) {
1864
- if (ES.SameValueZero(i.key, key)) {
1865
- i.key = i.value = empty;
1866
- i.prev.next = i.next;
1867
- i.next.prev = i.prev;
1868
- this._size -= 1;
1869
- return true;
1870
- }
1871
- }
1872
- return false;
1873
- },
1874
-
1875
- clear: function () {
1876
- this._size = 0;
1877
- this._storage = emptyObject();
1878
- var head = this._head, i = head, p = i.next;
1879
- while ((i = p) !== head) {
1880
- i.key = i.value = empty;
1881
- p = i.next;
1882
- i.next = i.prev = head;
1883
- }
1884
- head.next = head.prev = head;
1885
- },
1886
-
1887
- keys: function () {
1888
- return new MapIterator(this, 'key');
1889
- },
1890
-
1891
- values: function () {
1892
- return new MapIterator(this, 'value');
1893
- },
1894
-
1895
- entries: function () {
1896
- return new MapIterator(this, 'key+value');
1897
- },
1898
-
1899
- forEach: function (callback) {
1900
- var context = arguments.length > 1 ? arguments[1] : null;
1901
- var it = this.entries();
1902
- for (var entry = it.next(); !entry.done; entry = it.next()) {
1903
- callback.call(context, entry.value[1], entry.value[0], this);
1904
- }
1905
- }
1906
- });
1907
- addIterator(Map.prototype, function () { return this.entries(); });
1908
-
1909
- return Map;
1910
- })(),
1911
-
1912
- Set: (function () {
1913
- // Creating a Map is expensive. To speed up the common case of
1914
- // Sets containing only string or numeric keys, we use an object
1915
- // as backing storage and lazily create a full Map only when
1916
- // required.
1917
- var SetShim = function Set(iterable) {
1918
- var set = this;
1919
- set = emulateES6construct(set);
1920
- if (!set._es6set) {
1921
- throw new TypeError('bad set');
1922
- }
1923
-
1924
- defineProperties(set, {
1925
- '[[SetData]]': null,
1926
- _storage: emptyObject()
1927
- });
1928
-
1929
- // Optionally initialize map from iterable
1930
- if (typeof iterable !== 'undefined' && iterable !== null) {
1931
- var it = ES.GetIterator(iterable);
1932
- var adder = set.add;
1933
- if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); }
1934
- while (true) {
1935
- var next = ES.IteratorNext(it);
1936
- if (next.done) { break; }
1937
- var nextItem = next.value;
1938
- adder.call(set, nextItem);
1939
- }
1940
- }
1941
- return set;
1942
- };
1943
- var Set$prototype = SetShim.prototype;
1944
- defineProperties(SetShim, {
1945
- '@@create': function (obj) {
1946
- var constructor = this;
1947
- var prototype = constructor.prototype || Set$prototype;
1948
- obj = obj || create(prototype);
1949
- defineProperties(obj, { _es6set: true });
1950
- return obj;
1951
- }
1952
- });
1953
-
1954
- // Switch from the object backing storage to a full Map.
1955
- var ensureMap = function ensureMap(set) {
1956
- if (!set['[[SetData]]']) {
1957
- var m = set['[[SetData]]'] = new collectionShims.Map();
1958
- Object.keys(set._storage).forEach(function (k) {
1959
- // fast check for leading '$'
1960
- if (k.charCodeAt(0) === 36) {
1961
- k = k.slice(1);
1962
- } else if (k.charAt(0) === 'n') {
1963
- k = +k.slice(1);
1964
- } else {
1965
- k = +k;
1966
- }
1967
- m.set(k, k);
1968
- });
1969
- set._storage = null; // free old backing storage
1970
- }
1971
- };
1972
-
1973
- Object.defineProperty(SetShim.prototype, 'size', {
1974
- configurable: true,
1975
- enumerable: false,
1976
- get: function () {
1977
- if (typeof this._storage === 'undefined') {
1978
- // https://github.com/paulmillr/es6-shim/issues/176
1979
- throw new TypeError('size method called on incompatible Set');
1980
- }
1981
- ensureMap(this);
1982
- return this['[[SetData]]'].size;
1983
- }
1984
- });
1985
-
1986
- defineProperties(SetShim.prototype, {
1987
- has: function (key) {
1988
- var fkey;
1989
- if (this._storage && (fkey = fastkey(key)) !== null) {
1990
- return !!this._storage[fkey];
1991
- }
1992
- ensureMap(this);
1993
- return this['[[SetData]]'].has(key);
1994
- },
1995
-
1996
- add: function (key) {
1997
- var fkey;
1998
- if (this._storage && (fkey = fastkey(key)) !== null) {
1999
- this._storage[fkey] = true;
2000
- return;
2001
- }
2002
- ensureMap(this);
2003
- this['[[SetData]]'].set(key, key);
2004
- return this;
2005
- },
2006
-
2007
- 'delete': function (key) {
2008
- var fkey;
2009
- if (this._storage && (fkey = fastkey(key)) !== null) {
2010
- var hasFKey = _hasOwnProperty.call(this._storage, fkey);
2011
- return (delete this._storage[fkey]) && hasFKey;
2012
- }
2013
- ensureMap(this);
2014
- return this['[[SetData]]']['delete'](key);
2015
- },
2016
-
2017
- clear: function () {
2018
- if (this._storage) {
2019
- this._storage = emptyObject();
2020
- return;
2021
- }
2022
- return this['[[SetData]]'].clear();
2023
- },
2024
-
2025
- keys: function () {
2026
- ensureMap(this);
2027
- return this['[[SetData]]'].keys();
2028
- },
2029
-
2030
- values: function () {
2031
- ensureMap(this);
2032
- return this['[[SetData]]'].values();
2033
- },
2034
-
2035
- entries: function () {
2036
- ensureMap(this);
2037
- return this['[[SetData]]'].entries();
2038
- },
2039
-
2040
- forEach: function (callback) {
2041
- var context = arguments.length > 1 ? arguments[1] : null;
2042
- var entireSet = this;
2043
- ensureMap(this);
2044
- this['[[SetData]]'].forEach(function (value, key) {
2045
- callback.call(context, key, key, entireSet);
2046
- });
2047
- }
2048
- });
2049
- addIterator(SetShim.prototype, function () { return this.values(); });
2050
-
2051
- return SetShim;
2052
- })()
2053
- };
2054
- defineProperties(globals, collectionShims);
2055
-
2056
- if (globals.Map || globals.Set) {
2057
- /*
2058
- - In Firefox < 23, Map#size is a function.
2059
- - In all current Firefox, Set#entries/keys/values & Map#clear do not exist
2060
- - https://bugzilla.mozilla.org/show_bug.cgi?id=869996
2061
- - In Firefox 24, Map and Set do not implement forEach
2062
- - In Firefox 25 at least, Map and Set are callable without "new"
2063
- */
2064
- if (
2065
- typeof globals.Map.prototype.clear !== 'function' ||
2066
- new globals.Set().size !== 0 ||
2067
- new globals.Map().size !== 0 ||
2068
- typeof globals.Map.prototype.keys !== 'function' ||
2069
- typeof globals.Set.prototype.keys !== 'function' ||
2070
- typeof globals.Map.prototype.forEach !== 'function' ||
2071
- typeof globals.Set.prototype.forEach !== 'function' ||
2072
- isCallableWithoutNew(globals.Map) ||
2073
- isCallableWithoutNew(globals.Set) ||
2074
- !supportsSubclassing(globals.Map, function (M) {
2075
- var m = new M([]);
2076
- // Firefox 32 is ok with the instantiating the subclass but will
2077
- // throw when the map is used.
2078
- m.set(42, 42);
2079
- return m instanceof M;
2080
- })
2081
- ) {
2082
- globals.Map = collectionShims.Map;
2083
- globals.Set = collectionShims.Set;
2084
- }
2085
- }
2086
- // Shim incomplete iterator implementations.
2087
- addIterator(Object.getPrototypeOf((new globals.Map()).keys()));
2088
- addIterator(Object.getPrototypeOf((new globals.Set()).keys()));
2089
- }
2090
-
2091
- return globals;
2092
- }));
2093
-
2094
-
2095
- }).call(this,require('_process'))
2096
- },{"_process":2}],4:[function(require,module,exports){
2097
- 'use strict';
2098
-
2099
- if (!require('./is-implemented')()) {
2100
- Object.defineProperty(require('es5-ext/global'), 'Symbol',
2101
- { value: require('./polyfill'), configurable: true, enumerable: false,
2102
- writable: true });
2103
- }
2104
-
2105
- },{"./is-implemented":5,"./polyfill":20,"es5-ext/global":7}],5:[function(require,module,exports){
2106
- 'use strict';
2107
-
2108
- module.exports = function () {
2109
- var symbol;
2110
- if (typeof Symbol !== 'function') return false;
2111
- symbol = Symbol('test symbol');
2112
- try { String(symbol); } catch (e) { return false; }
2113
- if (typeof Symbol.iterator === 'symbol') return true;
2114
-
2115
- // Return 'true' for polyfills
2116
- if (typeof Symbol.isConcatSpreadable !== 'object') return false;
2117
- if (typeof Symbol.isRegExp !== 'object') return false;
2118
- if (typeof Symbol.iterator !== 'object') return false;
2119
- if (typeof Symbol.toPrimitive !== 'object') return false;
2120
- if (typeof Symbol.toStringTag !== 'object') return false;
2121
- if (typeof Symbol.unscopables !== 'object') return false;
2122
-
2123
- return true;
2124
- };
2125
-
2126
- },{}],6:[function(require,module,exports){
2127
- 'use strict';
2128
-
2129
- var assign = require('es5-ext/object/assign')
2130
- , normalizeOpts = require('es5-ext/object/normalize-options')
2131
- , isCallable = require('es5-ext/object/is-callable')
2132
- , contains = require('es5-ext/string/#/contains')
2133
-
2134
- , d;
2135
-
2136
- d = module.exports = function (dscr, value/*, options*/) {
2137
- var c, e, w, options, desc;
2138
- if ((arguments.length < 2) || (typeof dscr !== 'string')) {
2139
- options = value;
2140
- value = dscr;
2141
- dscr = null;
2142
- } else {
2143
- options = arguments[2];
2144
- }
2145
- if (dscr == null) {
2146
- c = w = true;
2147
- e = false;
2148
- } else {
2149
- c = contains.call(dscr, 'c');
2150
- e = contains.call(dscr, 'e');
2151
- w = contains.call(dscr, 'w');
2152
- }
2153
-
2154
- desc = { value: value, configurable: c, enumerable: e, writable: w };
2155
- return !options ? desc : assign(normalizeOpts(options), desc);
2156
- };
2157
-
2158
- d.gs = function (dscr, get, set/*, options*/) {
2159
- var c, e, options, desc;
2160
- if (typeof dscr !== 'string') {
2161
- options = set;
2162
- set = get;
2163
- get = dscr;
2164
- dscr = null;
2165
- } else {
2166
- options = arguments[3];
2167
- }
2168
- if (get == null) {
2169
- get = undefined;
2170
- } else if (!isCallable(get)) {
2171
- options = get;
2172
- get = set = undefined;
2173
- } else if (set == null) {
2174
- set = undefined;
2175
- } else if (!isCallable(set)) {
2176
- options = set;
2177
- set = undefined;
2178
- }
2179
- if (dscr == null) {
2180
- c = true;
2181
- e = false;
2182
- } else {
2183
- c = contains.call(dscr, 'c');
2184
- e = contains.call(dscr, 'e');
2185
- }
2186
-
2187
- desc = { get: get, set: set, configurable: c, enumerable: e };
2188
- return !options ? desc : assign(normalizeOpts(options), desc);
2189
- };
2190
-
2191
- },{"es5-ext/object/assign":8,"es5-ext/object/is-callable":11,"es5-ext/object/normalize-options":15,"es5-ext/string/#/contains":17}],7:[function(require,module,exports){
2192
- 'use strict';
2193
-
2194
- module.exports = new Function("return this")();
2195
-
2196
- },{}],8:[function(require,module,exports){
2197
- 'use strict';
2198
-
2199
- module.exports = require('./is-implemented')()
2200
- ? Object.assign
2201
- : require('./shim');
2202
-
2203
- },{"./is-implemented":9,"./shim":10}],9:[function(require,module,exports){
2204
- 'use strict';
2205
-
2206
- module.exports = function () {
2207
- var assign = Object.assign, obj;
2208
- if (typeof assign !== 'function') return false;
2209
- obj = { foo: 'raz' };
2210
- assign(obj, { bar: 'dwa' }, { trzy: 'trzy' });
2211
- return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy';
2212
- };
2213
-
2214
- },{}],10:[function(require,module,exports){
2215
- 'use strict';
2216
-
2217
- var keys = require('../keys')
2218
- , value = require('../valid-value')
2219
-
2220
- , max = Math.max;
2221
-
2222
- module.exports = function (dest, src/*, …srcn*/) {
2223
- var error, i, l = max(arguments.length, 2), assign;
2224
- dest = Object(value(dest));
2225
- assign = function (key) {
2226
- try { dest[key] = src[key]; } catch (e) {
2227
- if (!error) error = e;
2228
- }
2229
- };
2230
- for (i = 1; i < l; ++i) {
2231
- src = arguments[i];
2232
- keys(src).forEach(assign);
2233
- }
2234
- if (error !== undefined) throw error;
2235
- return dest;
2236
- };
2237
-
2238
- },{"../keys":12,"../valid-value":16}],11:[function(require,module,exports){
2239
- // Deprecated
2240
-
2241
- 'use strict';
2242
-
2243
- module.exports = function (obj) { return typeof obj === 'function'; };
2244
-
2245
- },{}],12:[function(require,module,exports){
2246
- 'use strict';
2247
-
2248
- module.exports = require('./is-implemented')()
2249
- ? Object.keys
2250
- : require('./shim');
2251
-
2252
- },{"./is-implemented":13,"./shim":14}],13:[function(require,module,exports){
2253
- 'use strict';
2254
-
2255
- module.exports = function () {
2256
- try {
2257
- Object.keys('primitive');
2258
- return true;
2259
- } catch (e) { return false; }
2260
- };
2261
-
2262
- },{}],14:[function(require,module,exports){
2263
- 'use strict';
2264
-
2265
- var keys = Object.keys;
2266
-
2267
- module.exports = function (object) {
2268
- return keys(object == null ? object : Object(object));
2269
- };
2270
-
2271
- },{}],15:[function(require,module,exports){
2272
- 'use strict';
2273
-
2274
- var assign = require('./assign')
2275
-
2276
- , forEach = Array.prototype.forEach
2277
- , create = Object.create, getPrototypeOf = Object.getPrototypeOf
2278
-
2279
- , process;
2280
-
2281
- process = function (src, obj) {
2282
- var proto = getPrototypeOf(src);
2283
- return assign(proto ? process(proto, obj) : obj, src);
2284
- };
2285
-
2286
- module.exports = function (options/*, …options*/) {
2287
- var result = create(null);
2288
- forEach.call(arguments, function (options) {
2289
- if (options == null) return;
2290
- process(Object(options), result);
2291
- });
2292
- return result;
2293
- };
2294
-
2295
- },{"./assign":8}],16:[function(require,module,exports){
2296
- 'use strict';
2297
-
2298
- module.exports = function (value) {
2299
- if (value == null) throw new TypeError("Cannot use null or undefined");
2300
- return value;
2301
- };
2302
-
2303
- },{}],17:[function(require,module,exports){
2304
- 'use strict';
2305
-
2306
- module.exports = require('./is-implemented')()
2307
- ? String.prototype.contains
2308
- : require('./shim');
2309
-
2310
- },{"./is-implemented":18,"./shim":19}],18:[function(require,module,exports){
2311
- 'use strict';
2312
-
2313
- var str = 'razdwatrzy';
2314
-
2315
- module.exports = function () {
2316
- if (typeof str.contains !== 'function') return false;
2317
- return ((str.contains('dwa') === true) && (str.contains('foo') === false));
2318
- };
2319
-
2320
- },{}],19:[function(require,module,exports){
2321
- 'use strict';
2322
-
2323
- var indexOf = String.prototype.indexOf;
2324
-
2325
- module.exports = function (searchString/*, position*/) {
2326
- return indexOf.call(this, searchString, arguments[1]) > -1;
2327
- };
2328
-
2329
- },{}],20:[function(require,module,exports){
2330
- 'use strict';
2331
-
2332
- var d = require('d')
2333
-
2334
- , create = Object.create, defineProperties = Object.defineProperties
2335
- , generateName, Symbol;
2336
-
2337
- generateName = (function () {
2338
- var created = create(null);
2339
- return function (desc) {
2340
- var postfix = 0;
2341
- while (created[desc + (postfix || '')]) ++postfix;
2342
- desc += (postfix || '');
2343
- created[desc] = true;
2344
- return '@@' + desc;
2345
- };
2346
- }());
2347
-
2348
- module.exports = Symbol = function (description) {
2349
- var symbol;
2350
- if (this instanceof Symbol) {
2351
- throw new TypeError('TypeError: Symbol is not a constructor');
2352
- }
2353
- symbol = create(Symbol.prototype);
2354
- description = (description === undefined ? '' : String(description));
2355
- return defineProperties(symbol, {
2356
- __description__: d('', description),
2357
- __name__: d('', generateName(description))
2358
- });
2359
- };
2360
-
2361
- Object.defineProperties(Symbol, {
2362
- create: d('', Symbol('create')),
2363
- hasInstance: d('', Symbol('hasInstance')),
2364
- isConcatSpreadable: d('', Symbol('isConcatSpreadable')),
2365
- isRegExp: d('', Symbol('isRegExp')),
2366
- iterator: d('', Symbol('iterator')),
2367
- toPrimitive: d('', Symbol('toPrimitive')),
2368
- toStringTag: d('', Symbol('toStringTag')),
2369
- unscopables: d('', Symbol('unscopables'))
2370
- });
2371
-
2372
- defineProperties(Symbol.prototype, {
2373
- properToString: d(function () {
2374
- return 'Symbol (' + this.__description__ + ')';
2375
- }),
2376
- toString: d('', function () { return this.__name__; })
2377
- });
2378
- Object.defineProperty(Symbol.prototype, Symbol.toPrimitive, d('',
2379
- function (hint) {
2380
- throw new TypeError("Conversion of symbol objects is not allowed");
2381
- }));
2382
- Object.defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol'));
2383
-
2384
- },{"d":6}],21:[function(require,module,exports){
2385
- 'use strict';
2386
-
2387
- module.exports = require('./lib/core.js')
2388
- require('./lib/done.js')
2389
- require('./lib/es6-extensions.js')
2390
- require('./lib/node-extensions.js')
2391
- },{"./lib/core.js":22,"./lib/done.js":23,"./lib/es6-extensions.js":24,"./lib/node-extensions.js":25}],22:[function(require,module,exports){
2392
- 'use strict';
2393
-
2394
- var asap = require('asap')
2395
-
2396
- module.exports = Promise;
2397
- function Promise(fn) {
2398
- if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new')
2399
- if (typeof fn !== 'function') throw new TypeError('not a function')
2400
- var state = null
2401
- var value = null
2402
- var deferreds = []
2403
- var self = this
2404
-
2405
- this.then = function(onFulfilled, onRejected) {
2406
- return new self.constructor(function(resolve, reject) {
2407
- handle(new Handler(onFulfilled, onRejected, resolve, reject))
2408
- })
2409
- }
2410
-
2411
- function handle(deferred) {
2412
- if (state === null) {
2413
- deferreds.push(deferred)
2414
- return
2415
- }
2416
- asap(function() {
2417
- var cb = state ? deferred.onFulfilled : deferred.onRejected
2418
- if (cb === null) {
2419
- (state ? deferred.resolve : deferred.reject)(value)
2420
- return
2421
- }
2422
- var ret
2423
- try {
2424
- ret = cb(value)
2425
- }
2426
- catch (e) {
2427
- deferred.reject(e)
2428
- return
2429
- }
2430
- deferred.resolve(ret)
2431
- })
2432
- }
2433
-
2434
- function resolve(newValue) {
2435
- try { //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
2436
- if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.')
2437
- if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
2438
- var then = newValue.then
2439
- if (typeof then === 'function') {
2440
- doResolve(then.bind(newValue), resolve, reject)
2441
- return
2442
- }
2443
- }
2444
- state = true
2445
- value = newValue
2446
- finale()
2447
- } catch (e) { reject(e) }
2448
- }
2449
-
2450
- function reject(newValue) {
2451
- state = false
2452
- value = newValue
2453
- finale()
2454
- }
2455
-
2456
- function finale() {
2457
- for (var i = 0, len = deferreds.length; i < len; i++)
2458
- handle(deferreds[i])
2459
- deferreds = null
2460
- }
2461
-
2462
- doResolve(fn, resolve, reject)
2463
- }
2464
-
2465
-
2466
- function Handler(onFulfilled, onRejected, resolve, reject){
2467
- this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null
2468
- this.onRejected = typeof onRejected === 'function' ? onRejected : null
2469
- this.resolve = resolve
2470
- this.reject = reject
2471
- }
2472
-
2473
- /**
2474
- * Take a potentially misbehaving resolver function and make sure
2475
- * onFulfilled and onRejected are only called once.
2476
- *
2477
- * Makes no guarantees about asynchrony.
2478
- */
2479
- function doResolve(fn, onFulfilled, onRejected) {
2480
- var done = false;
2481
- try {
2482
- fn(function (value) {
2483
- if (done) return
2484
- done = true
2485
- onFulfilled(value)
2486
- }, function (reason) {
2487
- if (done) return
2488
- done = true
2489
- onRejected(reason)
2490
- })
2491
- } catch (ex) {
2492
- if (done) return
2493
- done = true
2494
- onRejected(ex)
2495
- }
2496
- }
2497
-
2498
- },{"asap":26}],23:[function(require,module,exports){
2499
- 'use strict';
2500
-
2501
- var Promise = require('./core.js')
2502
- var asap = require('asap')
2503
-
2504
- module.exports = Promise
2505
- Promise.prototype.done = function (onFulfilled, onRejected) {
2506
- var self = arguments.length ? this.then.apply(this, arguments) : this
2507
- self.then(null, function (err) {
2508
- asap(function () {
2509
- throw err
2510
- })
2511
- })
2512
- }
2513
- },{"./core.js":22,"asap":26}],24:[function(require,module,exports){
2514
- 'use strict';
2515
-
2516
- //This file contains the ES6 extensions to the core Promises/A+ API
2517
-
2518
- var Promise = require('./core.js')
2519
- var asap = require('asap')
2520
-
2521
- module.exports = Promise
2522
-
2523
- /* Static Functions */
2524
-
2525
- function ValuePromise(value) {
2526
- this.then = function (onFulfilled) {
2527
- if (typeof onFulfilled !== 'function') return this
2528
- return new Promise(function (resolve, reject) {
2529
- asap(function () {
2530
- try {
2531
- resolve(onFulfilled(value))
2532
- } catch (ex) {
2533
- reject(ex);
2534
- }
2535
- })
2536
- })
2537
- }
2538
- }
2539
- ValuePromise.prototype = Promise.prototype
2540
-
2541
- var TRUE = new ValuePromise(true)
2542
- var FALSE = new ValuePromise(false)
2543
- var NULL = new ValuePromise(null)
2544
- var UNDEFINED = new ValuePromise(undefined)
2545
- var ZERO = new ValuePromise(0)
2546
- var EMPTYSTRING = new ValuePromise('')
2547
-
2548
- Promise.resolve = function (value) {
2549
- if (value instanceof Promise) return value
2550
-
2551
- if (value === null) return NULL
2552
- if (value === undefined) return UNDEFINED
2553
- if (value === true) return TRUE
2554
- if (value === false) return FALSE
2555
- if (value === 0) return ZERO
2556
- if (value === '') return EMPTYSTRING
2557
-
2558
- if (typeof value === 'object' || typeof value === 'function') {
2559
- try {
2560
- var then = value.then
2561
- if (typeof then === 'function') {
2562
- return new Promise(then.bind(value))
2563
- }
2564
- } catch (ex) {
2565
- return new Promise(function (resolve, reject) {
2566
- reject(ex)
2567
- })
2568
- }
2569
- }
2570
-
2571
- return new ValuePromise(value)
2572
- }
2573
-
2574
- Promise.all = function (arr) {
2575
- var args = Array.prototype.slice.call(arr)
2576
-
2577
- return new Promise(function (resolve, reject) {
2578
- if (args.length === 0) return resolve([])
2579
- var remaining = args.length
2580
- function res(i, val) {
2581
- try {
2582
- if (val && (typeof val === 'object' || typeof val === 'function')) {
2583
- var then = val.then
2584
- if (typeof then === 'function') {
2585
- then.call(val, function (val) { res(i, val) }, reject)
2586
- return
2587
- }
2588
- }
2589
- args[i] = val
2590
- if (--remaining === 0) {
2591
- resolve(args);
2592
- }
2593
- } catch (ex) {
2594
- reject(ex)
2595
- }
2596
- }
2597
- for (var i = 0; i < args.length; i++) {
2598
- res(i, args[i])
2599
- }
2600
- })
2601
- }
2602
-
2603
- Promise.reject = function (value) {
2604
- return new Promise(function (resolve, reject) {
2605
- reject(value);
2606
- });
2607
- }
2608
-
2609
- Promise.race = function (values) {
2610
- return new Promise(function (resolve, reject) {
2611
- values.forEach(function(value){
2612
- Promise.resolve(value).then(resolve, reject);
2613
- })
2614
- });
2615
- }
2616
-
2617
- /* Prototype Methods */
2618
-
2619
- Promise.prototype['catch'] = function (onRejected) {
2620
- return this.then(null, onRejected);
2621
- }
2622
-
2623
- },{"./core.js":22,"asap":26}],25:[function(require,module,exports){
2624
- 'use strict';
2625
-
2626
- //This file contains then/promise specific extensions that are only useful for node.js interop
2627
-
2628
- var Promise = require('./core.js')
2629
- var asap = require('asap')
2630
-
2631
- module.exports = Promise
2632
-
2633
- /* Static Functions */
2634
-
2635
- Promise.denodeify = function (fn, argumentCount) {
2636
- argumentCount = argumentCount || Infinity
2637
- return function () {
2638
- var self = this
2639
- var args = Array.prototype.slice.call(arguments)
2640
- return new Promise(function (resolve, reject) {
2641
- while (args.length && args.length > argumentCount) {
2642
- args.pop()
2643
- }
2644
- args.push(function (err, res) {
2645
- if (err) reject(err)
2646
- else resolve(res)
2647
- })
2648
- fn.apply(self, args)
2649
- })
2650
- }
2651
- }
2652
- Promise.nodeify = function (fn) {
2653
- return function () {
2654
- var args = Array.prototype.slice.call(arguments)
2655
- var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null
2656
- var ctx = this
2657
- try {
2658
- return fn.apply(this, arguments).nodeify(callback, ctx)
2659
- } catch (ex) {
2660
- if (callback === null || typeof callback == 'undefined') {
2661
- return new Promise(function (resolve, reject) { reject(ex) })
2662
- } else {
2663
- asap(function () {
2664
- callback.call(ctx, ex)
2665
- })
2666
- }
2667
- }
2668
- }
2669
- }
2670
-
2671
- Promise.prototype.nodeify = function (callback, ctx) {
2672
- if (typeof callback != 'function') return this
2673
-
2674
- this.then(function (value) {
2675
- asap(function () {
2676
- callback.call(ctx, null, value)
2677
- })
2678
- }, function (err) {
2679
- asap(function () {
2680
- callback.call(ctx, err)
2681
- })
2682
- })
2683
- }
2684
-
2685
- },{"./core.js":22,"asap":26}],26:[function(require,module,exports){
2686
- (function (process){
2687
-
2688
- // Use the fastest possible means to execute a task in a future turn
2689
- // of the event loop.
2690
-
2691
- // linked list of tasks (single, with head node)
2692
- var head = {task: void 0, next: null};
2693
- var tail = head;
2694
- var flushing = false;
2695
- var requestFlush = void 0;
2696
- var isNodeJS = false;
2697
-
2698
- function flush() {
2699
- /* jshint loopfunc: true */
2700
-
2701
- while (head.next) {
2702
- head = head.next;
2703
- var task = head.task;
2704
- head.task = void 0;
2705
- var domain = head.domain;
2706
-
2707
- if (domain) {
2708
- head.domain = void 0;
2709
- domain.enter();
2710
- }
2711
-
2712
- try {
2713
- task();
2714
-
2715
- } catch (e) {
2716
- if (isNodeJS) {
2717
- // In node, uncaught exceptions are considered fatal errors.
2718
- // Re-throw them synchronously to interrupt flushing!
2719
-
2720
- // Ensure continuation if the uncaught exception is suppressed
2721
- // listening "uncaughtException" events (as domains does).
2722
- // Continue in next event to avoid tick recursion.
2723
- if (domain) {
2724
- domain.exit();
2725
- }
2726
- setTimeout(flush, 0);
2727
- if (domain) {
2728
- domain.enter();
2729
- }
2730
-
2731
- throw e;
2732
-
2733
- } else {
2734
- // In browsers, uncaught exceptions are not fatal.
2735
- // Re-throw them asynchronously to avoid slow-downs.
2736
- setTimeout(function() {
2737
- throw e;
2738
- }, 0);
2739
- }
2740
- }
2741
-
2742
- if (domain) {
2743
- domain.exit();
2744
- }
2745
- }
2746
-
2747
- flushing = false;
2748
- }
2749
-
2750
- if (typeof process !== "undefined" && process.nextTick) {
2751
- // Node.js before 0.9. Note that some fake-Node environments, like the
2752
- // Mocha test runner, introduce a `process` global without a `nextTick`.
2753
- isNodeJS = true;
2754
-
2755
- requestFlush = function () {
2756
- process.nextTick(flush);
2757
- };
2758
-
2759
- } else if (typeof setImmediate === "function") {
2760
- // In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate
2761
- if (typeof window !== "undefined") {
2762
- requestFlush = setImmediate.bind(window, flush);
2763
- } else {
2764
- requestFlush = function () {
2765
- setImmediate(flush);
2766
- };
2767
- }
2768
-
2769
- } else if (typeof MessageChannel !== "undefined") {
2770
- // modern browsers
2771
- // http://www.nonblocking.io/2011/06/windownexttick.html
2772
- var channel = new MessageChannel();
2773
- channel.port1.onmessage = flush;
2774
- requestFlush = function () {
2775
- channel.port2.postMessage(0);
2776
- };
2777
-
2778
- } else {
2779
- // old browsers
2780
- requestFlush = function () {
2781
- setTimeout(flush, 0);
2782
- };
2783
- }
2784
-
2785
- function asap(task) {
2786
- tail = tail.next = {
2787
- task: task,
2788
- domain: isNodeJS && process.domain,
2789
- next: null
2790
- };
2791
-
2792
- if (!flushing) {
2793
- flushing = true;
2794
- requestFlush();
2795
- }
2796
- };
2797
-
2798
- module.exports = asap;
2799
-
2800
-
2801
- }).call(this,require('_process'))
2802
- },{"_process":2}],27:[function(require,module,exports){
2803
- /**
2804
- * Copyright (c) 2014, Facebook, Inc.
2805
- * All rights reserved.
2806
- *
2807
- * This source code is licensed under the BSD-style license found in the
2808
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
2809
- * additional grant of patent rights can be found in the PATENTS file in
2810
- * the same directory.
2811
- */
2812
-
2813
- !(function() {
2814
- var hasOwn = Object.prototype.hasOwnProperty;
2815
- var undefined; // More compressible than void 0.
2816
- var iteratorSymbol =
2817
- typeof Symbol === "function" && Symbol.iterator || "@@iterator";
2818
-
2819
- // Make a reasonable attempt to provide a Promise polyfill.
2820
- if (typeof Promise === "undefined") try {
2821
- Promise = require("promise");
2822
- } catch (ignored) {}
2823
-
2824
- if (typeof regeneratorRuntime === "object") {
2825
- return;
2826
- }
2827
-
2828
- var runtime = regeneratorRuntime =
2829
- typeof exports === "undefined" ? {} : exports;
2830
-
2831
- function wrap(innerFn, outerFn, self, tryList) {
2832
- return new Generator(innerFn, outerFn, self || null, tryList || []);
2833
- }
2834
- runtime.wrap = wrap;
2835
-
2836
- var GenStateSuspendedStart = "suspendedStart";
2837
- var GenStateSuspendedYield = "suspendedYield";
2838
- var GenStateExecuting = "executing";
2839
- var GenStateCompleted = "completed";
2840
-
2841
- // Returning this object from the innerFn has the same effect as
2842
- // breaking out of the dispatch switch statement.
2843
- var ContinueSentinel = {};
2844
-
2845
- // Dummy constructor that we use as the .constructor property for
2846
- // functions that return Generator objects.
2847
- var GF = function GeneratorFunction() {};
2848
- var GFp = function GeneratorFunctionPrototype() {};
2849
- var Gp = GFp.prototype = Generator.prototype;
2850
- (GFp.constructor = GF).prototype =
2851
- Gp.constructor = GFp;
2852
-
2853
- // Ensure isGeneratorFunction works when Function#name not supported.
2854
- var GFName = "GeneratorFunction";
2855
- if (GF.name !== GFName) GF.name = GFName;
2856
- if (GF.name !== GFName) throw new Error(GFName + " renamed?");
2857
-
2858
- runtime.isGeneratorFunction = function(genFun) {
2859
- var ctor = genFun && genFun.constructor;
2860
- return ctor ? GF.name === ctor.name : false;
2861
- };
2862
-
2863
- runtime.mark = function(genFun) {
2864
- genFun.__proto__ = GFp;
2865
- genFun.prototype = Object.create(Gp);
2866
- return genFun;
2867
- };
2868
-
2869
- runtime.async = function(innerFn, outerFn, self, tryList) {
2870
- return new Promise(function(resolve, reject) {
2871
- var generator = wrap(innerFn, outerFn, self, tryList);
2872
- var callNext = step.bind(generator.next);
2873
- var callThrow = step.bind(generator["throw"]);
2874
-
2875
- function step(arg) {
2876
- try {
2877
- var info = this(arg);
2878
- var value = info.value;
2879
- } catch (error) {
2880
- return reject(error);
2881
- }
2882
-
2883
- if (info.done) {
2884
- resolve(value);
2885
- } else {
2886
- Promise.resolve(value).then(callNext, callThrow);
2887
- }
2888
- }
2889
-
2890
- callNext();
2891
- });
2892
- };
2893
-
2894
- function Generator(innerFn, outerFn, self, tryList) {
2895
- var generator = outerFn ? Object.create(outerFn.prototype) : this;
2896
- var context = new Context(tryList);
2897
- var state = GenStateSuspendedStart;
2898
-
2899
- function invoke(method, arg) {
2900
- if (state === GenStateExecuting) {
2901
- throw new Error("Generator is already running");
2902
- }
2903
-
2904
- if (state === GenStateCompleted) {
2905
- throw new Error("Generator has already finished");
2906
- }
2907
-
2908
- while (true) {
2909
- var delegate = context.delegate;
2910
- if (delegate) {
2911
- try {
2912
- var info = delegate.iterator[method](arg);
2913
-
2914
- // Delegate generator ran and handled its own exceptions so
2915
- // regardless of what the method was, we continue as if it is
2916
- // "next" with an undefined arg.
2917
- method = "next";
2918
- arg = undefined;
2919
-
2920
- } catch (uncaught) {
2921
- context.delegate = null;
2922
-
2923
- // Like returning generator.throw(uncaught), but without the
2924
- // overhead of an extra function call.
2925
- method = "throw";
2926
- arg = uncaught;
2927
-
2928
- continue;
2929
- }
2930
-
2931
- if (info.done) {
2932
- context[delegate.resultName] = info.value;
2933
- context.next = delegate.nextLoc;
2934
- } else {
2935
- state = GenStateSuspendedYield;
2936
- return info;
2937
- }
2938
-
2939
- context.delegate = null;
2940
- }
2941
-
2942
- if (method === "next") {
2943
- if (state === GenStateSuspendedStart &&
2944
- typeof arg !== "undefined") {
2945
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
2946
- throw new TypeError(
2947
- "attempt to send " + JSON.stringify(arg) + " to newborn generator"
2948
- );
2949
- }
2950
-
2951
- if (state === GenStateSuspendedYield) {
2952
- context.sent = arg;
2953
- } else {
2954
- delete context.sent;
2955
- }
2956
-
2957
- } else if (method === "throw") {
2958
- if (state === GenStateSuspendedStart) {
2959
- state = GenStateCompleted;
2960
- throw arg;
2961
- }
2962
-
2963
- if (context.dispatchException(arg)) {
2964
- // If the dispatched exception was caught by a catch block,
2965
- // then let that catch block handle the exception normally.
2966
- method = "next";
2967
- arg = undefined;
2968
- }
2969
-
2970
- } else if (method === "return") {
2971
- context.abrupt("return", arg);
2972
- }
2973
-
2974
- state = GenStateExecuting;
2975
-
2976
- try {
2977
- var value = innerFn.call(self, context);
2978
-
2979
- // If an exception is thrown from innerFn, we leave state ===
2980
- // GenStateExecuting and loop back for another invocation.
2981
- state = context.done
2982
- ? GenStateCompleted
2983
- : GenStateSuspendedYield;
2984
-
2985
- var info = {
2986
- value: value,
2987
- done: context.done
2988
- };
2989
-
2990
- if (value === ContinueSentinel) {
2991
- if (context.delegate && method === "next") {
2992
- // Deliberately forget the last sent value so that we don't
2993
- // accidentally pass it on to the delegate.
2994
- arg = undefined;
2995
- }
2996
- } else {
2997
- return info;
2998
- }
2999
-
3000
- } catch (thrown) {
3001
- state = GenStateCompleted;
3002
-
3003
- if (method === "next") {
3004
- context.dispatchException(thrown);
3005
- } else {
3006
- arg = thrown;
3007
- }
3008
- }
3009
- }
3010
- }
3011
-
3012
- generator.next = invoke.bind(generator, "next");
3013
- generator["throw"] = invoke.bind(generator, "throw");
3014
- generator["return"] = invoke.bind(generator, "return");
3015
-
3016
- return generator;
3017
- }
3018
-
3019
- Gp[iteratorSymbol] = function() {
3020
- return this;
3021
- };
3022
-
3023
- Gp.toString = function() {
3024
- return "[object Generator]";
3025
- };
3026
-
3027
- function pushTryEntry(triple) {
3028
- var entry = { tryLoc: triple[0] };
3029
-
3030
- if (1 in triple) {
3031
- entry.catchLoc = triple[1];
3032
- }
3033
-
3034
- if (2 in triple) {
3035
- entry.finallyLoc = triple[2];
3036
- }
3037
-
3038
- this.tryEntries.push(entry);
3039
- }
3040
-
3041
- function resetTryEntry(entry, i) {
3042
- var record = entry.completion || {};
3043
- record.type = i === 0 ? "normal" : "return";
3044
- delete record.arg;
3045
- entry.completion = record;
3046
- }
3047
-
3048
- function Context(tryList) {
3049
- // The root entry object (effectively a try statement without a catch
3050
- // or a finally block) gives us a place to store values thrown from
3051
- // locations where there is no enclosing try statement.
3052
- this.tryEntries = [{ tryLoc: "root" }];
3053
- tryList.forEach(pushTryEntry, this);
3054
- this.reset();
3055
- }
3056
-
3057
- runtime.keys = function(object) {
3058
- var keys = [];
3059
- for (var key in object) {
3060
- keys.push(key);
3061
- }
3062
- keys.reverse();
3063
-
3064
- // Rather than returning an object with a next method, we keep
3065
- // things simple and return the next function itself.
3066
- return function next() {
3067
- while (keys.length) {
3068
- var key = keys.pop();
3069
- if (key in object) {
3070
- next.value = key;
3071
- next.done = false;
3072
- return next;
3073
- }
3074
- }
3075
-
3076
- // To avoid creating an additional object, we just hang the .value
3077
- // and .done properties off the next function object itself. This
3078
- // also ensures that the minifier will not anonymize the function.
3079
- next.done = true;
3080
- return next;
3081
- };
3082
- };
3083
-
3084
- function values(iterable) {
3085
- var iterator = iterable;
3086
- if (iteratorSymbol in iterable) {
3087
- iterator = iterable[iteratorSymbol]();
3088
- } else if (!isNaN(iterable.length)) {
3089
- var i = -1;
3090
- iterator = function next() {
3091
- while (++i < iterable.length) {
3092
- if (i in iterable) {
3093
- next.value = iterable[i];
3094
- next.done = false;
3095
- return next;
3096
- }
3097
- };
3098
- next.done = true;
3099
- return next;
3100
- };
3101
- iterator.next = iterator;
3102
- }
3103
- return iterator;
3104
- }
3105
- runtime.values = values;
3106
-
3107
- Context.prototype = {
3108
- constructor: Context,
3109
-
3110
- reset: function() {
3111
- this.prev = 0;
3112
- this.next = 0;
3113
- this.sent = undefined;
3114
- this.done = false;
3115
- this.delegate = null;
3116
-
3117
- this.tryEntries.forEach(resetTryEntry);
3118
-
3119
- // Pre-initialize at least 20 temporary variables to enable hidden
3120
- // class optimizations for simple generators.
3121
- for (var tempIndex = 0, tempName;
3122
- hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20;
3123
- ++tempIndex) {
3124
- this[tempName] = null;
3125
- }
3126
- },
3127
-
3128
- stop: function() {
3129
- this.done = true;
3130
-
3131
- var rootEntry = this.tryEntries[0];
3132
- var rootRecord = rootEntry.completion;
3133
- if (rootRecord.type === "throw") {
3134
- throw rootRecord.arg;
3135
- }
3136
-
3137
- return this.rval;
3138
- },
3139
-
3140
- dispatchException: function(exception) {
3141
- if (this.done) {
3142
- throw exception;
3143
- }
3144
-
3145
- var context = this;
3146
- function handle(loc, caught) {
3147
- record.type = "throw";
3148
- record.arg = exception;
3149
- context.next = loc;
3150
- return !!caught;
3151
- }
3152
-
3153
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3154
- var entry = this.tryEntries[i];
3155
- var record = entry.completion;
3156
-
3157
- if (entry.tryLoc === "root") {
3158
- // Exception thrown outside of any try block that could handle
3159
- // it, so set the completion value of the entire function to
3160
- // throw the exception.
3161
- return handle("end");
3162
- }
3163
-
3164
- if (entry.tryLoc <= this.prev) {
3165
- var hasCatch = hasOwn.call(entry, "catchLoc");
3166
- var hasFinally = hasOwn.call(entry, "finallyLoc");
3167
-
3168
- if (hasCatch && hasFinally) {
3169
- if (this.prev < entry.catchLoc) {
3170
- return handle(entry.catchLoc, true);
3171
- } else if (this.prev < entry.finallyLoc) {
3172
- return handle(entry.finallyLoc);
3173
- }
3174
-
3175
- } else if (hasCatch) {
3176
- if (this.prev < entry.catchLoc) {
3177
- return handle(entry.catchLoc, true);
3178
- }
3179
-
3180
- } else if (hasFinally) {
3181
- if (this.prev < entry.finallyLoc) {
3182
- return handle(entry.finallyLoc);
3183
- }
3184
-
3185
- } else {
3186
- throw new Error("try statement without catch or finally");
3187
- }
3188
- }
3189
- }
3190
- },
3191
-
3192
- _findFinallyEntry: function(finallyLoc) {
3193
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3194
- var entry = this.tryEntries[i];
3195
- if (entry.tryLoc <= this.prev &&
3196
- hasOwn.call(entry, "finallyLoc") && (
3197
- entry.finallyLoc === finallyLoc ||
3198
- this.prev < entry.finallyLoc)) {
3199
- return entry;
3200
- }
3201
- }
3202
- },
3203
-
3204
- abrupt: function(type, arg) {
3205
- var entry = this._findFinallyEntry();
3206
- var record = entry ? entry.completion : {};
3207
-
3208
- record.type = type;
3209
- record.arg = arg;
3210
-
3211
- if (entry) {
3212
- this.next = entry.finallyLoc;
3213
- } else {
3214
- this.complete(record);
3215
- }
3216
-
3217
- return ContinueSentinel;
3218
- },
3219
-
3220
- complete: function(record) {
3221
- if (record.type === "throw") {
3222
- throw record.arg;
3223
- }
3224
-
3225
- if (record.type === "break" ||
3226
- record.type === "continue") {
3227
- this.next = record.arg;
3228
- } else if (record.type === "return") {
3229
- this.rval = record.arg;
3230
- this.next = "end";
3231
- }
3232
-
3233
- return ContinueSentinel;
3234
- },
3235
-
3236
- finish: function(finallyLoc) {
3237
- var entry = this._findFinallyEntry(finallyLoc);
3238
- return this.complete(entry.completion);
3239
- },
3240
-
3241
- "catch": function(tryLoc) {
3242
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3243
- var entry = this.tryEntries[i];
3244
- if (entry.tryLoc === tryLoc) {
3245
- var record = entry.completion;
3246
- if (record.type === "throw") {
3247
- var thrown = record.arg;
3248
- resetTryEntry(entry, i);
3249
- }
3250
- return thrown;
3251
- }
3252
- }
3253
-
3254
- // The context.catch method must only be called with a location
3255
- // argument that corresponds to a known catch block.
3256
- throw new Error("illegal catch attempt");
3257
- },
3258
-
3259
- delegateYield: function(iterable, resultName, nextLoc) {
3260
- this.delegate = {
3261
- iterator: values(iterable),
3262
- resultName: resultName,
3263
- nextLoc: nextLoc
3264
- };
3265
-
3266
- return ContinueSentinel;
3267
- }
3268
- };
3269
- })();
3270
-
3271
- },{"promise":21}]},{},[1]);