UNPKG

38.3 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var prettier = _interopDefault(require('prettier'));
8
9var isPure = false;
10
11// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
12var global = typeof window == 'object' && window && window.Math == Math ? window
13 : typeof self == 'object' && self && self.Math == Math ? self
14 // eslint-disable-next-line no-new-func
15 : Function('return this')();
16
17var fails = function (exec) {
18 try {
19 return !!exec();
20 } catch (error) {
21 return true;
22 }
23};
24
25// Thank's IE8 for his funny defineProperty
26var descriptors = !fails(function () {
27 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
28});
29
30var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
31var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
32
33// Nashorn ~ JDK8 bug
34var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
35
36var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
37 var descriptor = nativeGetOwnPropertyDescriptor(this, V);
38 return !!descriptor && descriptor.enumerable;
39} : nativePropertyIsEnumerable;
40
41var objectPropertyIsEnumerable = {
42 f: f
43};
44
45var createPropertyDescriptor = function (bitmap, value) {
46 return {
47 enumerable: !(bitmap & 1),
48 configurable: !(bitmap & 2),
49 writable: !(bitmap & 4),
50 value: value
51 };
52};
53
54var toString = {}.toString;
55
56var classofRaw = function (it) {
57 return toString.call(it).slice(8, -1);
58};
59
60// fallback for non-array-like ES3 and non-enumerable old V8 strings
61
62
63var split = ''.split;
64
65var indexedObject = fails(function () {
66 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
67 // eslint-disable-next-line no-prototype-builtins
68 return !Object('z').propertyIsEnumerable(0);
69}) ? function (it) {
70 return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
71} : Object;
72
73// `RequireObjectCoercible` abstract operation
74// https://tc39.github.io/ecma262/#sec-requireobjectcoercible
75var requireObjectCoercible = function (it) {
76 if (it == undefined) throw TypeError("Can't call method on " + it);
77 return it;
78};
79
80// toObject with fallback for non-array-like ES3 strings
81
82
83
84var toIndexedObject = function (it) {
85 return indexedObject(requireObjectCoercible(it));
86};
87
88var isObject = function (it) {
89 return typeof it === 'object' ? it !== null : typeof it === 'function';
90};
91
92// 7.1.1 ToPrimitive(input [, PreferredType])
93
94// instead of the ES6 spec version, we didn't implement @@toPrimitive case
95// and the second argument - flag - preferred type is a string
96var toPrimitive = function (it, S) {
97 if (!isObject(it)) return it;
98 var fn, val;
99 if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
100 if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
101 if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
102 throw TypeError("Can't convert object to primitive value");
103};
104
105var hasOwnProperty = {}.hasOwnProperty;
106
107var has = function (it, key) {
108 return hasOwnProperty.call(it, key);
109};
110
111var document$1 = global.document;
112// typeof document.createElement is 'object' in old IE
113var exist = isObject(document$1) && isObject(document$1.createElement);
114
115var documentCreateElement = function (it) {
116 return exist ? document$1.createElement(it) : {};
117};
118
119// Thank's IE8 for his funny defineProperty
120var ie8DomDefine = !descriptors && !fails(function () {
121 return Object.defineProperty(documentCreateElement('div'), 'a', {
122 get: function () { return 7; }
123 }).a != 7;
124});
125
126var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
127
128var f$1 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
129 O = toIndexedObject(O);
130 P = toPrimitive(P, true);
131 if (ie8DomDefine) try {
132 return nativeGetOwnPropertyDescriptor$1(O, P);
133 } catch (error) { /* empty */ }
134 if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
135};
136
137var objectGetOwnPropertyDescriptor = {
138 f: f$1
139};
140
141var anObject = function (it) {
142 if (!isObject(it)) {
143 throw TypeError(String(it) + ' is not an object');
144 } return it;
145};
146
147var nativeDefineProperty = Object.defineProperty;
148
149var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
150 anObject(O);
151 P = toPrimitive(P, true);
152 anObject(Attributes);
153 if (ie8DomDefine) try {
154 return nativeDefineProperty(O, P, Attributes);
155 } catch (error) { /* empty */ }
156 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
157 if ('value' in Attributes) O[P] = Attributes.value;
158 return O;
159};
160
161var objectDefineProperty = {
162 f: f$2
163};
164
165var hide = descriptors ? function (object, key, value) {
166 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
167} : function (object, key, value) {
168 object[key] = value;
169 return object;
170};
171
172function createCommonjsModule(fn, module) {
173 return module = { exports: {} }, fn(module, module.exports), module.exports;
174}
175
176var setGlobal = function (key, value) {
177 try {
178 hide(global, key, value);
179 } catch (error) {
180 global[key] = value;
181 } return value;
182};
183
184var shared = createCommonjsModule(function (module) {
185var SHARED = '__core-js_shared__';
186var store = global[SHARED] || setGlobal(SHARED, {});
187
188(module.exports = function (key, value) {
189 return store[key] || (store[key] = value !== undefined ? value : {});
190})('versions', []).push({
191 version: '3.0.1',
192 mode: 'global',
193 copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
194});
195});
196
197var functionToString = shared('native-function-to-string', Function.toString);
198
199var WeakMap = global.WeakMap;
200
201var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap));
202
203var id = 0;
204var postfix = Math.random();
205
206var uid = function (key) {
207 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
208};
209
210var shared$1 = shared('keys');
211
212
213var sharedKey = function (key) {
214 return shared$1[key] || (shared$1[key] = uid(key));
215};
216
217var hiddenKeys = {};
218
219var WeakMap$1 = global.WeakMap;
220var set, get, has$1;
221
222var enforce = function (it) {
223 return has$1(it) ? get(it) : set(it, {});
224};
225
226var getterFor = function (TYPE) {
227 return function (it) {
228 var state;
229 if (!isObject(it) || (state = get(it)).type !== TYPE) {
230 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
231 } return state;
232 };
233};
234
235if (nativeWeakMap) {
236 var store = new WeakMap$1();
237 var wmget = store.get;
238 var wmhas = store.has;
239 var wmset = store.set;
240 set = function (it, metadata) {
241 wmset.call(store, it, metadata);
242 return metadata;
243 };
244 get = function (it) {
245 return wmget.call(store, it) || {};
246 };
247 has$1 = function (it) {
248 return wmhas.call(store, it);
249 };
250} else {
251 var STATE = sharedKey('state');
252 hiddenKeys[STATE] = true;
253 set = function (it, metadata) {
254 hide(it, STATE, metadata);
255 return metadata;
256 };
257 get = function (it) {
258 return has(it, STATE) ? it[STATE] : {};
259 };
260 has$1 = function (it) {
261 return has(it, STATE);
262 };
263}
264
265var internalState = {
266 set: set,
267 get: get,
268 has: has$1,
269 enforce: enforce,
270 getterFor: getterFor
271};
272
273var redefine = createCommonjsModule(function (module) {
274var getInternalState = internalState.get;
275var enforceInternalState = internalState.enforce;
276var TEMPLATE = String(functionToString).split('toString');
277
278shared('inspectSource', function (it) {
279 return functionToString.call(it);
280});
281
282(module.exports = function (O, key, value, options) {
283 var unsafe = options ? !!options.unsafe : false;
284 var simple = options ? !!options.enumerable : false;
285 var noTargetGet = options ? !!options.noTargetGet : false;
286 if (typeof value == 'function') {
287 if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
288 enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
289 }
290 if (O === global) {
291 if (simple) O[key] = value;
292 else setGlobal(key, value);
293 return;
294 } else if (!unsafe) {
295 delete O[key];
296 } else if (!noTargetGet && O[key]) {
297 simple = true;
298 }
299 if (simple) O[key] = value;
300 else hide(O, key, value);
301// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
302})(Function.prototype, 'toString', function toString() {
303 return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
304});
305});
306
307var ceil = Math.ceil;
308var floor = Math.floor;
309
310// `ToInteger` abstract operation
311// https://tc39.github.io/ecma262/#sec-tointeger
312var toInteger = function (argument) {
313 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
314};
315
316var min = Math.min;
317
318// `ToLength` abstract operation
319// https://tc39.github.io/ecma262/#sec-tolength
320var toLength = function (argument) {
321 return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
322};
323
324var max = Math.max;
325var min$1 = Math.min;
326
327// Helper for a popular repeating case of the spec:
328// Let integer be ? ToInteger(index).
329// If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
330var toAbsoluteIndex = function (index, length) {
331 var integer = toInteger(index);
332 return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
333};
334
335// `Array.prototype.{ indexOf, includes }` methods implementation
336// false -> Array#indexOf
337// https://tc39.github.io/ecma262/#sec-array.prototype.indexof
338// true -> Array#includes
339// https://tc39.github.io/ecma262/#sec-array.prototype.includes
340var arrayIncludes = function (IS_INCLUDES) {
341 return function ($this, el, fromIndex) {
342 var O = toIndexedObject($this);
343 var length = toLength(O.length);
344 var index = toAbsoluteIndex(fromIndex, length);
345 var value;
346 // Array#includes uses SameValueZero equality algorithm
347 // eslint-disable-next-line no-self-compare
348 if (IS_INCLUDES && el != el) while (length > index) {
349 value = O[index++];
350 // eslint-disable-next-line no-self-compare
351 if (value != value) return true;
352 // Array#indexOf ignores holes, Array#includes - not
353 } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
354 if (O[index] === el) return IS_INCLUDES || index || 0;
355 } return !IS_INCLUDES && -1;
356 };
357};
358
359var arrayIndexOf = arrayIncludes(false);
360
361
362var objectKeysInternal = function (object, names) {
363 var O = toIndexedObject(object);
364 var i = 0;
365 var result = [];
366 var key;
367 for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
368 // Don't enum bug & hidden keys
369 while (names.length > i) if (has(O, key = names[i++])) {
370 ~arrayIndexOf(result, key) || result.push(key);
371 }
372 return result;
373};
374
375// IE8- don't enum bug keys
376var enumBugKeys = [
377 'constructor',
378 'hasOwnProperty',
379 'isPrototypeOf',
380 'propertyIsEnumerable',
381 'toLocaleString',
382 'toString',
383 'valueOf'
384];
385
386// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
387
388var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
389
390var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
391 return objectKeysInternal(O, hiddenKeys$1);
392};
393
394var objectGetOwnPropertyNames = {
395 f: f$3
396};
397
398var f$4 = Object.getOwnPropertySymbols;
399
400var objectGetOwnPropertySymbols = {
401 f: f$4
402};
403
404var Reflect = global.Reflect;
405
406// all object keys, includes non-enumerable and symbols
407var ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) {
408 var keys = objectGetOwnPropertyNames.f(anObject(it));
409 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
410 return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
411};
412
413var copyConstructorProperties = function (target, source) {
414 var keys = ownKeys(source);
415 var defineProperty = objectDefineProperty.f;
416 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
417 for (var i = 0; i < keys.length; i++) {
418 var key = keys[i];
419 if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
420 }
421};
422
423var replacement = /#|\.prototype\./;
424
425var isForced = function (feature, detection) {
426 var value = data[normalize(feature)];
427 return value == POLYFILL ? true
428 : value == NATIVE ? false
429 : typeof detection == 'function' ? fails(detection)
430 : !!detection;
431};
432
433var normalize = isForced.normalize = function (string) {
434 return String(string).replace(replacement, '.').toLowerCase();
435};
436
437var data = isForced.data = {};
438var NATIVE = isForced.NATIVE = 'N';
439var POLYFILL = isForced.POLYFILL = 'P';
440
441var isForced_1 = isForced;
442
443var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
444
445
446
447
448
449
450/*
451 options.target - name of the target object
452 options.global - target is the global object
453 options.stat - export as static methods of target
454 options.proto - export as prototype methods of target
455 options.real - real prototype method for the `pure` version
456 options.forced - export even if the native feature is available
457 options.bind - bind methods to the target, required for the `pure` version
458 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
459 options.unsafe - use the simple assignment of property instead of delete + defineProperty
460 options.sham - add a flag to not completely full polyfills
461 options.enumerable - export as enumerable property
462 options.noTargetGet - prevent calling a getter on target
463*/
464var _export = function (options, source) {
465 var TARGET = options.target;
466 var GLOBAL = options.global;
467 var STATIC = options.stat;
468 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
469 if (GLOBAL) {
470 target = global;
471 } else if (STATIC) {
472 target = global[TARGET] || setGlobal(TARGET, {});
473 } else {
474 target = (global[TARGET] || {}).prototype;
475 }
476 if (target) for (key in source) {
477 sourceProperty = source[key];
478 if (options.noTargetGet) {
479 descriptor = getOwnPropertyDescriptor(target, key);
480 targetProperty = descriptor && descriptor.value;
481 } else targetProperty = target[key];
482 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
483 // contained in target
484 if (!FORCED && targetProperty !== undefined) {
485 if (typeof sourceProperty === typeof targetProperty) continue;
486 copyConstructorProperties(sourceProperty, targetProperty);
487 }
488 // add a flag to not completely full polyfills
489 if (options.sham || (targetProperty && targetProperty.sham)) {
490 hide(sourceProperty, 'sham', true);
491 }
492 // extend global
493 redefine(target, key, sourceProperty, options);
494 }
495};
496
497var aFunction = function (it) {
498 if (typeof it != 'function') {
499 throw TypeError(String(it) + ' is not a function');
500 } return it;
501};
502
503var anInstance = function (it, Constructor, name) {
504 if (!(it instanceof Constructor)) {
505 throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
506 } return it;
507};
508
509var iterators = {};
510
511// Chrome 38 Symbol has incorrect toString conversion
512var nativeSymbol = !fails(function () {
513 // eslint-disable-next-line no-undef
514 return !String(Symbol());
515});
516
517var store$1 = shared('wks');
518
519var Symbol$1 = global.Symbol;
520
521
522var wellKnownSymbol = function (name) {
523 return store$1[name] || (store$1[name] = nativeSymbol && Symbol$1[name]
524 || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
525};
526
527// check on default Array iterator
528
529var ITERATOR = wellKnownSymbol('iterator');
530var ArrayPrototype = Array.prototype;
531
532var isArrayIteratorMethod = function (it) {
533 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it);
534};
535
536// optional / simple context binding
537var bindContext = function (fn, that, length) {
538 aFunction(fn);
539 if (that === undefined) return fn;
540 switch (length) {
541 case 0: return function () {
542 return fn.call(that);
543 };
544 case 1: return function (a) {
545 return fn.call(that, a);
546 };
547 case 2: return function (a, b) {
548 return fn.call(that, a, b);
549 };
550 case 3: return function (a, b, c) {
551 return fn.call(that, a, b, c);
552 };
553 }
554 return function (/* ...args */) {
555 return fn.apply(that, arguments);
556 };
557};
558
559var TO_STRING_TAG = wellKnownSymbol('toStringTag');
560// ES3 wrong here
561var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
562
563// fallback for IE11 Script Access Denied error
564var tryGet = function (it, key) {
565 try {
566 return it[key];
567 } catch (error) { /* empty */ }
568};
569
570// getting tag from ES6+ `Object.prototype.toString`
571var classof = function (it) {
572 var O, tag, result;
573 return it === undefined ? 'Undefined' : it === null ? 'Null'
574 // @@toStringTag case
575 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
576 // builtinTag case
577 : CORRECT_ARGUMENTS ? classofRaw(O)
578 // ES3 arguments fallback
579 : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
580};
581
582var ITERATOR$1 = wellKnownSymbol('iterator');
583
584
585var getIteratorMethod = function (it) {
586 if (it != undefined) return it[ITERATOR$1]
587 || it['@@iterator']
588 || iterators[classof(it)];
589};
590
591// call something on iterator step with safe closing on error
592var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
593 try {
594 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
595 // 7.4.6 IteratorClose(iterator, completion)
596 } catch (error) {
597 var returnMethod = iterator['return'];
598 if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
599 throw error;
600 }
601};
602
603var iterate = createCommonjsModule(function (module) {
604var BREAK = {};
605
606var exports = module.exports = function (iterable, fn, that, ENTRIES, ITERATOR) {
607 var boundFunction = bindContext(fn, that, ENTRIES ? 2 : 1);
608 var iterator, iterFn, index, length, result, step;
609
610 if (ITERATOR) {
611 iterator = iterable;
612 } else {
613 iterFn = getIteratorMethod(iterable);
614 if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
615 // optimisation for array iterators
616 if (isArrayIteratorMethod(iterFn)) {
617 for (index = 0, length = toLength(iterable.length); length > index; index++) {
618 result = ENTRIES ? boundFunction(anObject(step = iterable[index])[0], step[1]) : boundFunction(iterable[index]);
619 if (result === BREAK) return BREAK;
620 } return;
621 }
622 iterator = iterFn.call(iterable);
623 }
624
625 while (!(step = iterator.next()).done) {
626 if (callWithSafeIterationClosing(iterator, boundFunction, step.value, ENTRIES) === BREAK) return BREAK;
627 }
628};
629
630exports.BREAK = BREAK;
631});
632
633var ITERATOR$2 = wellKnownSymbol('iterator');
634var SAFE_CLOSING = false;
635
636try {
637 var called = 0;
638 var iteratorWithReturn = {
639 next: function () {
640 return { done: !!called++ };
641 },
642 'return': function () {
643 SAFE_CLOSING = true;
644 }
645 };
646 iteratorWithReturn[ITERATOR$2] = function () {
647 return this;
648 };
649} catch (error) { /* empty */ }
650
651var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
652 if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
653 var ITERATION_SUPPORT = false;
654 try {
655 var object = {};
656 object[ITERATOR$2] = function () {
657 return {
658 next: function () {
659 return { done: ITERATION_SUPPORT = true };
660 }
661 };
662 };
663 exec(object);
664 } catch (error) { /* empty */ }
665 return ITERATION_SUPPORT;
666};
667
668var SPECIES = wellKnownSymbol('species');
669
670// `SpeciesConstructor` abstract operation
671// https://tc39.github.io/ecma262/#sec-speciesconstructor
672var speciesConstructor = function (O, defaultConstructor) {
673 var C = anObject(O).constructor;
674 var S;
675 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
676};
677
678var document$2 = global.document;
679
680var html = document$2 && document$2.documentElement;
681
682var set$1 = global.setImmediate;
683var clear = global.clearImmediate;
684var process = global.process;
685var MessageChannel = global.MessageChannel;
686var Dispatch = global.Dispatch;
687var counter = 0;
688var queue = {};
689var ONREADYSTATECHANGE = 'onreadystatechange';
690var defer, channel, port;
691
692var run = function () {
693 var id = +this;
694 // eslint-disable-next-line no-prototype-builtins
695 if (queue.hasOwnProperty(id)) {
696 var fn = queue[id];
697 delete queue[id];
698 fn();
699 }
700};
701
702var listener = function (event) {
703 run.call(event.data);
704};
705
706// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
707if (!set$1 || !clear) {
708 set$1 = function setImmediate(fn) {
709 var args = [];
710 var i = 1;
711 while (arguments.length > i) args.push(arguments[i++]);
712 queue[++counter] = function () {
713 // eslint-disable-next-line no-new-func
714 (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
715 };
716 defer(counter);
717 return counter;
718 };
719 clear = function clearImmediate(id) {
720 delete queue[id];
721 };
722 // Node.js 0.8-
723 if (classofRaw(process) == 'process') {
724 defer = function (id) {
725 process.nextTick(bindContext(run, id, 1));
726 };
727 // Sphere (JS game engine) Dispatch API
728 } else if (Dispatch && Dispatch.now) {
729 defer = function (id) {
730 Dispatch.now(bindContext(run, id, 1));
731 };
732 // Browsers with MessageChannel, includes WebWorkers
733 } else if (MessageChannel) {
734 channel = new MessageChannel();
735 port = channel.port2;
736 channel.port1.onmessage = listener;
737 defer = bindContext(port.postMessage, port, 1);
738 // Browsers with postMessage, skip WebWorkers
739 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
740 } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
741 defer = function (id) {
742 global.postMessage(id + '', '*');
743 };
744 global.addEventListener('message', listener, false);
745 // IE8-
746 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) {
747 defer = function (id) {
748 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () {
749 html.removeChild(this);
750 run.call(id);
751 };
752 };
753 // Rest old browsers
754 } else {
755 defer = function (id) {
756 setTimeout(bindContext(run, id, 1), 0);
757 };
758 }
759}
760
761var task = {
762 set: set$1,
763 clear: clear
764};
765
766var navigator = global.navigator;
767
768var userAgent = navigator && navigator.userAgent || '';
769
770var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
771
772var macrotask = task.set;
773
774var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
775var process$1 = global.process;
776var Promise = global.Promise;
777var IS_NODE = classofRaw(process$1) == 'process';
778// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
779var queueMicrotaskDescriptor = getOwnPropertyDescriptor$1(global, 'queueMicrotask');
780var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
781
782var flush, head, last, notify, toggle, node, promise;
783
784// modern engines have queueMicrotask method
785if (!queueMicrotask) {
786 flush = function () {
787 var parent, fn;
788 if (IS_NODE && (parent = process$1.domain)) parent.exit();
789 while (head) {
790 fn = head.fn;
791 head = head.next;
792 try {
793 fn();
794 } catch (error) {
795 if (head) notify();
796 else last = undefined;
797 throw error;
798 }
799 } last = undefined;
800 if (parent) parent.enter();
801 };
802
803 // Node.js
804 if (IS_NODE) {
805 notify = function () {
806 process$1.nextTick(flush);
807 };
808 // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
809 } else if (MutationObserver && !/(iPhone|iPod|iPad).*AppleWebKit/i.test(userAgent)) {
810 toggle = true;
811 node = document.createTextNode('');
812 new MutationObserver(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
813 notify = function () {
814 node.data = toggle = !toggle;
815 };
816 // environments with maybe non-completely correct, but existent Promise
817 } else if (Promise && Promise.resolve) {
818 // Promise.resolve without an argument throws an error in LG WebOS 2
819 promise = Promise.resolve(undefined);
820 notify = function () {
821 promise.then(flush);
822 };
823 // for other environments - macrotask based on:
824 // - setImmediate
825 // - MessageChannel
826 // - window.postMessag
827 // - onreadystatechange
828 // - setTimeout
829 } else {
830 notify = function () {
831 // strange IE + webpack dev server bug - use .call(global)
832 macrotask.call(global, flush);
833 };
834 }
835}
836
837var microtask = queueMicrotask || function (fn) {
838 var task = { fn: fn, next: undefined };
839 if (last) last.next = task;
840 if (!head) {
841 head = task;
842 notify();
843 } last = task;
844};
845
846// 25.4.1.5 NewPromiseCapability(C)
847
848
849var PromiseCapability = function (C) {
850 var resolve, reject;
851 this.promise = new C(function ($$resolve, $$reject) {
852 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
853 resolve = $$resolve;
854 reject = $$reject;
855 });
856 this.resolve = aFunction(resolve);
857 this.reject = aFunction(reject);
858};
859
860var f$5 = function (C) {
861 return new PromiseCapability(C);
862};
863
864var newPromiseCapability = {
865 f: f$5
866};
867
868var promiseResolve = function (C, x) {
869 anObject(C);
870 if (isObject(x) && x.constructor === C) return x;
871 var promiseCapability = newPromiseCapability.f(C);
872 var resolve = promiseCapability.resolve;
873 resolve(x);
874 return promiseCapability.promise;
875};
876
877var hostReportErrors = function (a, b) {
878 var console = global.console;
879 if (console && console.error) {
880 arguments.length === 1 ? console.error(a) : console.error(a, b);
881 }
882};
883
884var perform = function (exec) {
885 try {
886 return { error: false, value: exec() };
887 } catch (error) {
888 return { error: true, value: error };
889 }
890};
891
892var redefineAll = function (target, src, options) {
893 for (var key in src) redefine(target, key, src[key], options);
894 return target;
895};
896
897var defineProperty = objectDefineProperty.f;
898
899var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
900
901var setToStringTag = function (it, TAG, STATIC) {
902 if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG$1)) {
903 defineProperty(it, TO_STRING_TAG$1, { configurable: true, value: TAG });
904 }
905};
906
907var path = global;
908
909var aFunction$1 = function (variable) {
910 return typeof variable == 'function' ? variable : undefined;
911};
912
913var getBuiltIn = function (namespace, method) {
914 return arguments.length < 2 ? aFunction$1(path[namespace]) || aFunction$1(global[namespace])
915 : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
916};
917
918var SPECIES$1 = wellKnownSymbol('species');
919
920var setSpecies = function (CONSTRUCTOR_NAME) {
921 var C = getBuiltIn(CONSTRUCTOR_NAME);
922 var defineProperty = objectDefineProperty.f;
923 if (descriptors && C && !C[SPECIES$1]) defineProperty(C, SPECIES$1, {
924 configurable: true,
925 get: function () { return this; }
926 });
927};
928
929var PROMISE = 'Promise';
930
931
932
933
934
935
936
937
938
939
940var task$1 = task.set;
941
942
943
944
945
946
947var SPECIES$2 = wellKnownSymbol('species');
948
949
950var getInternalState = internalState.get;
951var setInternalState = internalState.set;
952var getInternalPromiseState = internalState.getterFor(PROMISE);
953var PromiseConstructor = global[PROMISE];
954var TypeError$1 = global.TypeError;
955var document$3 = global.document;
956var process$2 = global.process;
957var $fetch = global.fetch;
958var versions = process$2 && process$2.versions;
959var v8 = versions && versions.v8 || '';
960var newPromiseCapability$1 = newPromiseCapability.f;
961var newGenericPromiseCapability = newPromiseCapability$1;
962var IS_NODE$1 = classofRaw(process$2) == 'process';
963var DISPATCH_EVENT = !!(document$3 && document$3.createEvent && global.dispatchEvent);
964var UNHANDLED_REJECTION = 'unhandledrejection';
965var REJECTION_HANDLED = 'rejectionhandled';
966var PENDING = 0;
967var FULFILLED = 1;
968var REJECTED = 2;
969var HANDLED = 1;
970var UNHANDLED = 2;
971var Internal, OwnPromiseCapability, PromiseWrapper;
972
973var FORCED = isForced_1(PROMISE, function () {
974 // correct subclassing with @@species support
975 var promise = PromiseConstructor.resolve(1);
976 var empty = function () { /* empty */ };
977 var FakePromise = (promise.constructor = {})[SPECIES$2] = function (exec) {
978 exec(empty, empty);
979 };
980 // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
981 return !((IS_NODE$1 || typeof PromiseRejectionEvent == 'function')
982 && (!isPure || promise['finally'])
983 && promise.then(empty) instanceof FakePromise
984 // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
985 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
986 // we can't detect it synchronously, so just check versions
987 && v8.indexOf('6.6') !== 0
988 && userAgent.indexOf('Chrome/66') === -1);
989});
990
991var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
992 PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
993});
994
995// helpers
996var isThenable = function (it) {
997 var then;
998 return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
999};
1000
1001var notify$1 = function (promise, state, isReject) {
1002 if (state.notified) return;
1003 state.notified = true;
1004 var chain = state.reactions;
1005 microtask(function () {
1006 var value = state.value;
1007 var ok = state.state == FULFILLED;
1008 var i = 0;
1009 var run = function (reaction) {
1010 var handler = ok ? reaction.ok : reaction.fail;
1011 var resolve = reaction.resolve;
1012 var reject = reaction.reject;
1013 var domain = reaction.domain;
1014 var result, then, exited;
1015 try {
1016 if (handler) {
1017 if (!ok) {
1018 if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
1019 state.rejection = HANDLED;
1020 }
1021 if (handler === true) result = value;
1022 else {
1023 if (domain) domain.enter();
1024 result = handler(value); // may throw
1025 if (domain) {
1026 domain.exit();
1027 exited = true;
1028 }
1029 }
1030 if (result === reaction.promise) {
1031 reject(TypeError$1('Promise-chain cycle'));
1032 } else if (then = isThenable(result)) {
1033 then.call(result, resolve, reject);
1034 } else resolve(result);
1035 } else reject(value);
1036 } catch (error) {
1037 if (domain && !exited) domain.exit();
1038 reject(error);
1039 }
1040 };
1041 while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
1042 state.reactions = [];
1043 state.notified = false;
1044 if (isReject && !state.rejection) onUnhandled(promise, state);
1045 });
1046};
1047
1048var dispatchEvent = function (name, promise, reason) {
1049 var event, handler;
1050 if (DISPATCH_EVENT) {
1051 event = document$3.createEvent('Event');
1052 event.promise = promise;
1053 event.reason = reason;
1054 event.initEvent(name, false, true);
1055 global.dispatchEvent(event);
1056 } else event = { promise: promise, reason: reason };
1057 if (handler = global['on' + name]) handler(event);
1058 else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
1059};
1060
1061var onUnhandled = function (promise, state) {
1062 task$1.call(global, function () {
1063 var value = state.value;
1064 var IS_UNHANDLED = isUnhandled(state);
1065 var result;
1066 if (IS_UNHANDLED) {
1067 result = perform(function () {
1068 if (IS_NODE$1) {
1069 process$2.emit('unhandledRejection', value, promise);
1070 } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
1071 });
1072 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
1073 state.rejection = IS_NODE$1 || isUnhandled(state) ? UNHANDLED : HANDLED;
1074 if (result.error) throw result.value;
1075 }
1076 });
1077};
1078
1079var isUnhandled = function (state) {
1080 return state.rejection !== HANDLED && !state.parent;
1081};
1082
1083var onHandleUnhandled = function (promise, state) {
1084 task$1.call(global, function () {
1085 if (IS_NODE$1) {
1086 process$2.emit('rejectionHandled', promise);
1087 } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
1088 });
1089};
1090
1091var bind = function (fn, promise, state, unwrap) {
1092 return function (value) {
1093 fn(promise, state, value, unwrap);
1094 };
1095};
1096
1097var internalReject = function (promise, state, value, unwrap) {
1098 if (state.done) return;
1099 state.done = true;
1100 if (unwrap) state = unwrap;
1101 state.value = value;
1102 state.state = REJECTED;
1103 notify$1(promise, state, true);
1104};
1105
1106var internalResolve = function (promise, state, value, unwrap) {
1107 if (state.done) return;
1108 state.done = true;
1109 if (unwrap) state = unwrap;
1110 try {
1111 if (promise === value) throw TypeError$1("Promise can't be resolved itself");
1112 var then = isThenable(value);
1113 if (then) {
1114 microtask(function () {
1115 var wrapper = { done: false };
1116 try {
1117 then.call(value,
1118 bind(internalResolve, promise, wrapper, state),
1119 bind(internalReject, promise, wrapper, state)
1120 );
1121 } catch (error) {
1122 internalReject(promise, wrapper, error, state);
1123 }
1124 });
1125 } else {
1126 state.value = value;
1127 state.state = FULFILLED;
1128 notify$1(promise, state, false);
1129 }
1130 } catch (error) {
1131 internalReject(promise, { done: false }, error, state);
1132 }
1133};
1134
1135// constructor polyfill
1136if (FORCED) {
1137 // 25.4.3.1 Promise(executor)
1138 PromiseConstructor = function Promise(executor) {
1139 anInstance(this, PromiseConstructor, PROMISE);
1140 aFunction(executor);
1141 Internal.call(this);
1142 var state = getInternalState(this);
1143 try {
1144 executor(bind(internalResolve, this, state), bind(internalReject, this, state));
1145 } catch (error) {
1146 internalReject(this, state, error);
1147 }
1148 };
1149 // eslint-disable-next-line no-unused-vars
1150 Internal = function Promise(executor) {
1151 setInternalState(this, {
1152 type: PROMISE,
1153 done: false,
1154 notified: false,
1155 parent: false,
1156 reactions: [],
1157 rejection: false,
1158 state: PENDING,
1159 value: undefined
1160 });
1161 };
1162 Internal.prototype = redefineAll(PromiseConstructor.prototype, {
1163 // `Promise.prototype.then` method
1164 // https://tc39.github.io/ecma262/#sec-promise.prototype.then
1165 then: function then(onFulfilled, onRejected) {
1166 var state = getInternalPromiseState(this);
1167 var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
1168 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
1169 reaction.fail = typeof onRejected == 'function' && onRejected;
1170 reaction.domain = IS_NODE$1 ? process$2.domain : undefined;
1171 state.parent = true;
1172 state.reactions.push(reaction);
1173 if (state.state != PENDING) notify$1(this, state, false);
1174 return reaction.promise;
1175 },
1176 // `Promise.prototype.catch` method
1177 // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
1178 'catch': function (onRejected) {
1179 return this.then(undefined, onRejected);
1180 }
1181 });
1182 OwnPromiseCapability = function () {
1183 var promise = new Internal();
1184 var state = getInternalState(promise);
1185 this.promise = promise;
1186 this.resolve = bind(internalResolve, promise, state);
1187 this.reject = bind(internalReject, promise, state);
1188 };
1189 newPromiseCapability.f = newPromiseCapability$1 = function (C) {
1190 return C === PromiseConstructor || C === PromiseWrapper
1191 ? new OwnPromiseCapability(C)
1192 : newGenericPromiseCapability(C);
1193 };
1194
1195 // wrap fetch result
1196 if (typeof $fetch == 'function') _export({ global: true, enumerable: true, forced: true }, {
1197 // eslint-disable-next-line no-unused-vars
1198 fetch: function fetch(input) {
1199 return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
1200 }
1201 });
1202}
1203
1204_export({ global: true, wrap: true, forced: FORCED }, { Promise: PromiseConstructor });
1205
1206setToStringTag(PromiseConstructor, PROMISE, false, true);
1207setSpecies(PROMISE);
1208
1209PromiseWrapper = path[PROMISE];
1210
1211// statics
1212_export({ target: PROMISE, stat: true, forced: FORCED }, {
1213 // `Promise.reject` method
1214 // https://tc39.github.io/ecma262/#sec-promise.reject
1215 reject: function reject(r) {
1216 var capability = newPromiseCapability$1(this);
1217 capability.reject.call(undefined, r);
1218 return capability.promise;
1219 }
1220});
1221
1222_export({ target: PROMISE, stat: true, forced: FORCED }, {
1223 // `Promise.resolve` method
1224 // https://tc39.github.io/ecma262/#sec-promise.resolve
1225 resolve: function resolve(x) {
1226 return promiseResolve(this, x);
1227 }
1228});
1229
1230_export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
1231 // `Promise.all` method
1232 // https://tc39.github.io/ecma262/#sec-promise.all
1233 all: function all(iterable) {
1234 var C = this;
1235 var capability = newPromiseCapability$1(C);
1236 var resolve = capability.resolve;
1237 var reject = capability.reject;
1238 var result = perform(function () {
1239 var values = [];
1240 var counter = 0;
1241 var remaining = 1;
1242 iterate(iterable, function (promise) {
1243 var index = counter++;
1244 var alreadyCalled = false;
1245 values.push(undefined);
1246 remaining++;
1247 C.resolve(promise).then(function (value) {
1248 if (alreadyCalled) return;
1249 alreadyCalled = true;
1250 values[index] = value;
1251 --remaining || resolve(values);
1252 }, reject);
1253 });
1254 --remaining || resolve(values);
1255 });
1256 if (result.error) reject(result.value);
1257 return capability.promise;
1258 },
1259 // `Promise.race` method
1260 // https://tc39.github.io/ecma262/#sec-promise.race
1261 race: function race(iterable) {
1262 var C = this;
1263 var capability = newPromiseCapability$1(C);
1264 var reject = capability.reject;
1265 var result = perform(function () {
1266 iterate(iterable, function (promise) {
1267 C.resolve(promise).then(capability.resolve, reject);
1268 });
1269 });
1270 if (result.error) reject(result.value);
1271 return capability.promise;
1272 }
1273});
1274
1275async function getFileInfo(path) {
1276 return prettier.getFileInfo(path);
1277}
1278async function format(fileContents, config) {
1279 return prettier.format(fileContents, config);
1280}
1281
1282exports.format = format;
1283exports.getFileInfo = getFileInfo;