| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global['jest-mock'] = factory());
- }(this, (function () { 'use strict';
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
- function unwrapExports (x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
- }
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
- var _global = createCommonjsModule(function (module) {
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
- var global = module.exports = typeof window != 'undefined' && window.Math == Math
- ? window : typeof self != 'undefined' && self.Math == Math ? self
- // eslint-disable-next-line no-new-func
- : Function('return this')();
- if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
- });
- var _core = createCommonjsModule(function (module) {
- var core = module.exports = { version: '2.5.7' };
- if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
- });
- var _core_1 = _core.version;
- var _aFunction = function (it) {
- if (typeof it != 'function') throw TypeError(it + ' is not a function!');
- return it;
- };
- // optional / simple context binding
- var _ctx = function (fn, that, length) {
- _aFunction(fn);
- if (that === undefined) return fn;
- switch (length) {
- case 1: return function (a) {
- return fn.call(that, a);
- };
- case 2: return function (a, b) {
- return fn.call(that, a, b);
- };
- case 3: return function (a, b, c) {
- return fn.call(that, a, b, c);
- };
- }
- return function (/* ...args */) {
- return fn.apply(that, arguments);
- };
- };
- var _isObject = function (it) {
- return typeof it === 'object' ? it !== null : typeof it === 'function';
- };
- var _anObject = function (it) {
- if (!_isObject(it)) throw TypeError(it + ' is not an object!');
- return it;
- };
- var _fails = function (exec) {
- try {
- return !!exec();
- } catch (e) {
- return true;
- }
- };
- // Thank's IE8 for his funny defineProperty
- var _descriptors = !_fails(function () {
- return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
- });
- var document$1 = _global.document;
- // typeof document.createElement is 'object' in old IE
- var is = _isObject(document$1) && _isObject(document$1.createElement);
- var _domCreate = function (it) {
- return is ? document$1.createElement(it) : {};
- };
- var _ie8DomDefine = !_descriptors && !_fails(function () {
- return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
- });
- // 7.1.1 ToPrimitive(input [, PreferredType])
- // instead of the ES6 spec version, we didn't implement @@toPrimitive case
- // and the second argument - flag - preferred type is a string
- var _toPrimitive = function (it, S) {
- if (!_isObject(it)) return it;
- var fn, val;
- if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
- if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
- if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
- throw TypeError("Can't convert object to primitive value");
- };
- var dP = Object.defineProperty;
- var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
- _anObject(O);
- P = _toPrimitive(P, true);
- _anObject(Attributes);
- if (_ie8DomDefine) try {
- return dP(O, P, Attributes);
- } catch (e) { /* empty */ }
- if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
- if ('value' in Attributes) O[P] = Attributes.value;
- return O;
- };
- var _objectDp = {
- f: f
- };
- var _propertyDesc = function (bitmap, value) {
- return {
- enumerable: !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable: !(bitmap & 4),
- value: value
- };
- };
- var _hide = _descriptors ? function (object, key, value) {
- return _objectDp.f(object, key, _propertyDesc(1, value));
- } : function (object, key, value) {
- object[key] = value;
- return object;
- };
- var hasOwnProperty = {}.hasOwnProperty;
- var _has = function (it, key) {
- return hasOwnProperty.call(it, key);
- };
- var PROTOTYPE = 'prototype';
- var $export = function (type, name, source) {
- var IS_FORCED = type & $export.F;
- var IS_GLOBAL = type & $export.G;
- var IS_STATIC = type & $export.S;
- var IS_PROTO = type & $export.P;
- var IS_BIND = type & $export.B;
- var IS_WRAP = type & $export.W;
- var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
- var expProto = exports[PROTOTYPE];
- var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
- var key, own, out;
- if (IS_GLOBAL) source = name;
- for (key in source) {
- // contains in native
- own = !IS_FORCED && target && target[key] !== undefined;
- if (own && _has(exports, key)) continue;
- // export native or passed
- out = own ? target[key] : source[key];
- // prevent global pollution for namespaces
- exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
- // bind timers to global for call from export context
- : IS_BIND && own ? _ctx(out, _global)
- // wrap global constructors for prevent change them in library
- : IS_WRAP && target[key] == out ? (function (C) {
- var F = function (a, b, c) {
- if (this instanceof C) {
- switch (arguments.length) {
- case 0: return new C();
- case 1: return new C(a);
- case 2: return new C(a, b);
- } return new C(a, b, c);
- } return C.apply(this, arguments);
- };
- F[PROTOTYPE] = C[PROTOTYPE];
- return F;
- // make static versions for prototype methods
- })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
- // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
- if (IS_PROTO) {
- (exports.virtual || (exports.virtual = {}))[key] = out;
- // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
- if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
- }
- }
- };
- // type bitmap
- $export.F = 1; // forced
- $export.G = 2; // global
- $export.S = 4; // static
- $export.P = 8; // proto
- $export.B = 16; // bind
- $export.W = 32; // wrap
- $export.U = 64; // safe
- $export.R = 128; // real proto method for `library`
- var _export = $export;
- // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
- _export(_export.S + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f });
- var $Object = _core.Object;
- var defineProperty = function defineProperty(it, key, desc) {
- return $Object.defineProperty(it, key, desc);
- };
- var defineProperty$1 = createCommonjsModule(function (module) {
- module.exports = { "default": defineProperty, __esModule: true };
- });
- var _Object$defineProperty = unwrapExports(defineProperty$1);
- // 7.1.4 ToInteger
- var ceil = Math.ceil;
- var floor = Math.floor;
- var _toInteger = function (it) {
- return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
- };
- // 7.2.1 RequireObjectCoercible(argument)
- var _defined = function (it) {
- if (it == undefined) throw TypeError("Can't call method on " + it);
- return it;
- };
- // true -> String#at
- // false -> String#codePointAt
- var _stringAt = function (TO_STRING) {
- return function (that, pos) {
- var s = String(_defined(that));
- var i = _toInteger(pos);
- var l = s.length;
- var a, b;
- if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
- a = s.charCodeAt(i);
- return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
- ? TO_STRING ? s.charAt(i) : a
- : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
- };
- };
- var _library = true;
- var _redefine = _hide;
- var _iterators = {};
- var toString = {}.toString;
- var _cof = function (it) {
- return toString.call(it).slice(8, -1);
- };
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
- // eslint-disable-next-line no-prototype-builtins
- var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
- return _cof(it) == 'String' ? it.split('') : Object(it);
- };
- // to indexed object, toObject with fallback for non-array-like ES3 strings
- var _toIobject = function (it) {
- return _iobject(_defined(it));
- };
- // 7.1.15 ToLength
- var min = Math.min;
- var _toLength = function (it) {
- return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
- };
- var max = Math.max;
- var min$1 = Math.min;
- var _toAbsoluteIndex = function (index, length) {
- index = _toInteger(index);
- return index < 0 ? max(index + length, 0) : min$1(index, length);
- };
- // false -> Array#indexOf
- // true -> Array#includes
- var _arrayIncludes = function (IS_INCLUDES) {
- return function ($this, el, fromIndex) {
- var O = _toIobject($this);
- var length = _toLength(O.length);
- var index = _toAbsoluteIndex(fromIndex, length);
- var value;
- // Array#includes uses SameValueZero equality algorithm
- // eslint-disable-next-line no-self-compare
- if (IS_INCLUDES && el != el) while (length > index) {
- value = O[index++];
- // eslint-disable-next-line no-self-compare
- if (value != value) return true;
- // Array#indexOf ignores holes, Array#includes - not
- } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
- if (O[index] === el) return IS_INCLUDES || index || 0;
- } return !IS_INCLUDES && -1;
- };
- };
- var _shared = createCommonjsModule(function (module) {
- var SHARED = '__core-js_shared__';
- var store = _global[SHARED] || (_global[SHARED] = {});
- (module.exports = function (key, value) {
- return store[key] || (store[key] = value !== undefined ? value : {});
- })('versions', []).push({
- version: _core.version,
- mode: _library ? 'pure' : 'global',
- copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
- });
- });
- var id = 0;
- var px = Math.random();
- var _uid = function (key) {
- return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
- };
- var shared = _shared('keys');
- var _sharedKey = function (key) {
- return shared[key] || (shared[key] = _uid(key));
- };
- var arrayIndexOf = _arrayIncludes(false);
- var IE_PROTO = _sharedKey('IE_PROTO');
- var _objectKeysInternal = function (object, names) {
- var O = _toIobject(object);
- var i = 0;
- var result = [];
- var key;
- for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
- // Don't enum bug & hidden keys
- while (names.length > i) if (_has(O, key = names[i++])) {
- ~arrayIndexOf(result, key) || result.push(key);
- }
- return result;
- };
- // IE 8- don't enum bug keys
- var _enumBugKeys = (
- 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
- ).split(',');
- // 19.1.2.14 / 15.2.3.14 Object.keys(O)
- var _objectKeys = Object.keys || function keys(O) {
- return _objectKeysInternal(O, _enumBugKeys);
- };
- var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
- _anObject(O);
- var keys = _objectKeys(Properties);
- var length = keys.length;
- var i = 0;
- var P;
- while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
- return O;
- };
- var document$2 = _global.document;
- var _html = document$2 && document$2.documentElement;
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- var IE_PROTO$1 = _sharedKey('IE_PROTO');
- var Empty = function () { /* empty */ };
- var PROTOTYPE$1 = 'prototype';
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
- var createDict = function () {
- // Thrash, waste and sodomy: IE GC bug
- var iframe = _domCreate('iframe');
- var i = _enumBugKeys.length;
- var lt = '<';
- var gt = '>';
- var iframeDocument;
- iframe.style.display = 'none';
- _html.appendChild(iframe);
- iframe.src = 'javascript:'; // eslint-disable-line no-script-url
- // createDict = iframe.contentWindow.Object;
- // html.removeChild(iframe);
- iframeDocument = iframe.contentWindow.document;
- iframeDocument.open();
- iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
- iframeDocument.close();
- createDict = iframeDocument.F;
- while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
- return createDict();
- };
- var _objectCreate = Object.create || function create(O, Properties) {
- var result;
- if (O !== null) {
- Empty[PROTOTYPE$1] = _anObject(O);
- result = new Empty();
- Empty[PROTOTYPE$1] = null;
- // add "__proto__" for Object.getPrototypeOf polyfill
- result[IE_PROTO$1] = O;
- } else result = createDict();
- return Properties === undefined ? result : _objectDps(result, Properties);
- };
- var _wks = createCommonjsModule(function (module) {
- var store = _shared('wks');
- var Symbol = _global.Symbol;
- var USE_SYMBOL = typeof Symbol == 'function';
- var $exports = module.exports = function (name) {
- return store[name] || (store[name] =
- USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
- };
- $exports.store = store;
- });
- var def = _objectDp.f;
- var TAG = _wks('toStringTag');
- var _setToStringTag = function (it, tag, stat) {
- if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
- };
- var IteratorPrototype = {};
- // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
- _hide(IteratorPrototype, _wks('iterator'), function () { return this; });
- var _iterCreate = function (Constructor, NAME, next) {
- Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
- _setToStringTag(Constructor, NAME + ' Iterator');
- };
- // 7.1.13 ToObject(argument)
- var _toObject = function (it) {
- return Object(_defined(it));
- };
- // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
- var IE_PROTO$2 = _sharedKey('IE_PROTO');
- var ObjectProto = Object.prototype;
- var _objectGpo = Object.getPrototypeOf || function (O) {
- O = _toObject(O);
- if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
- if (typeof O.constructor == 'function' && O instanceof O.constructor) {
- return O.constructor.prototype;
- } return O instanceof Object ? ObjectProto : null;
- };
- var ITERATOR = _wks('iterator');
- var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
- var FF_ITERATOR = '@@iterator';
- var KEYS = 'keys';
- var VALUES = 'values';
- var returnThis = function () { return this; };
- var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
- _iterCreate(Constructor, NAME, next);
- var getMethod = function (kind) {
- if (!BUGGY && kind in proto) return proto[kind];
- switch (kind) {
- case KEYS: return function keys() { return new Constructor(this, kind); };
- case VALUES: return function values() { return new Constructor(this, kind); };
- } return function entries() { return new Constructor(this, kind); };
- };
- var TAG = NAME + ' Iterator';
- var DEF_VALUES = DEFAULT == VALUES;
- var VALUES_BUG = false;
- var proto = Base.prototype;
- var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
- var $default = $native || getMethod(DEFAULT);
- var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
- var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
- var methods, key, IteratorPrototype;
- // Fix native
- if ($anyNative) {
- IteratorPrototype = _objectGpo($anyNative.call(new Base()));
- if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
- // Set @@toStringTag to native iterators
- _setToStringTag(IteratorPrototype, TAG, true);
- // fix for some old engines
- if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
- }
- }
- // fix Array#{values, @@iterator}.name in V8 / FF
- if (DEF_VALUES && $native && $native.name !== VALUES) {
- VALUES_BUG = true;
- $default = function values() { return $native.call(this); };
- }
- // Define iterator
- if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
- _hide(proto, ITERATOR, $default);
- }
- // Plug for library
- _iterators[NAME] = $default;
- _iterators[TAG] = returnThis;
- if (DEFAULT) {
- methods = {
- values: DEF_VALUES ? $default : getMethod(VALUES),
- keys: IS_SET ? $default : getMethod(KEYS),
- entries: $entries
- };
- if (FORCED) for (key in methods) {
- if (!(key in proto)) _redefine(proto, key, methods[key]);
- } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
- }
- return methods;
- };
- var $at = _stringAt(true);
- // 21.1.3.27 String.prototype[@@iterator]()
- _iterDefine(String, 'String', function (iterated) {
- this._t = String(iterated); // target
- this._i = 0; // next index
- // 21.1.5.2.1 %StringIteratorPrototype%.next()
- }, function () {
- var O = this._t;
- var index = this._i;
- var point;
- if (index >= O.length) return { value: undefined, done: true };
- point = $at(O, index);
- this._i += point.length;
- return { value: point, done: false };
- });
- var _iterStep = function (done, value) {
- return { value: value, done: !!done };
- };
- // 22.1.3.4 Array.prototype.entries()
- // 22.1.3.13 Array.prototype.keys()
- // 22.1.3.29 Array.prototype.values()
- // 22.1.3.30 Array.prototype[@@iterator]()
- var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
- this._t = _toIobject(iterated); // target
- this._i = 0; // next index
- this._k = kind; // kind
- // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
- }, function () {
- var O = this._t;
- var kind = this._k;
- var index = this._i++;
- if (!O || index >= O.length) {
- this._t = undefined;
- return _iterStep(1);
- }
- if (kind == 'keys') return _iterStep(0, index);
- if (kind == 'values') return _iterStep(0, O[index]);
- return _iterStep(0, [index, O[index]]);
- }, 'values');
- // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
- _iterators.Arguments = _iterators.Array;
- var TO_STRING_TAG = _wks('toStringTag');
- var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
- 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
- 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
- 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
- 'TextTrackList,TouchList').split(',');
- for (var i = 0; i < DOMIterables.length; i++) {
- var NAME = DOMIterables[i];
- var Collection = _global[NAME];
- var proto = Collection && Collection.prototype;
- if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
- _iterators[NAME] = _iterators.Array;
- }
- var f$1 = _wks;
- var _wksExt = {
- f: f$1
- };
- var iterator = _wksExt.f('iterator');
- var iterator$1 = createCommonjsModule(function (module) {
- module.exports = { "default": iterator, __esModule: true };
- });
- unwrapExports(iterator$1);
- var _meta = createCommonjsModule(function (module) {
- var META = _uid('meta');
- var setDesc = _objectDp.f;
- var id = 0;
- var isExtensible = Object.isExtensible || function () {
- return true;
- };
- var FREEZE = !_fails(function () {
- return isExtensible(Object.preventExtensions({}));
- });
- var setMeta = function (it) {
- setDesc(it, META, { value: {
- i: 'O' + ++id, // object ID
- w: {} // weak collections IDs
- } });
- };
- var fastKey = function (it, create) {
- // return primitive with prefix
- if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
- if (!_has(it, META)) {
- // can't set metadata to uncaught frozen object
- if (!isExtensible(it)) return 'F';
- // not necessary to add metadata
- if (!create) return 'E';
- // add missing metadata
- setMeta(it);
- // return object ID
- } return it[META].i;
- };
- var getWeak = function (it, create) {
- if (!_has(it, META)) {
- // can't set metadata to uncaught frozen object
- if (!isExtensible(it)) return true;
- // not necessary to add metadata
- if (!create) return false;
- // add missing metadata
- setMeta(it);
- // return hash weak collections IDs
- } return it[META].w;
- };
- // add metadata on freeze-family methods calling
- var onFreeze = function (it) {
- if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
- return it;
- };
- var meta = module.exports = {
- KEY: META,
- NEED: false,
- fastKey: fastKey,
- getWeak: getWeak,
- onFreeze: onFreeze
- };
- });
- var _meta_1 = _meta.KEY;
- var _meta_2 = _meta.NEED;
- var _meta_3 = _meta.fastKey;
- var _meta_4 = _meta.getWeak;
- var _meta_5 = _meta.onFreeze;
- var defineProperty$2 = _objectDp.f;
- var _wksDefine = function (name) {
- var $Symbol = _core.Symbol || (_core.Symbol = _library ? {} : _global.Symbol || {});
- if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty$2($Symbol, name, { value: _wksExt.f(name) });
- };
- var f$2 = Object.getOwnPropertySymbols;
- var _objectGops = {
- f: f$2
- };
- var f$3 = {}.propertyIsEnumerable;
- var _objectPie = {
- f: f$3
- };
- // all enumerable object keys, includes symbols
- var _enumKeys = function (it) {
- var result = _objectKeys(it);
- var getSymbols = _objectGops.f;
- if (getSymbols) {
- var symbols = getSymbols(it);
- var isEnum = _objectPie.f;
- var i = 0;
- var key;
- while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
- } return result;
- };
- // 7.2.2 IsArray(argument)
- var _isArray = Array.isArray || function isArray(arg) {
- return _cof(arg) == 'Array';
- };
- // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
- var hiddenKeys = _enumBugKeys.concat('length', 'prototype');
- var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
- return _objectKeysInternal(O, hiddenKeys);
- };
- var _objectGopn = {
- f: f$4
- };
- // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
- var gOPN = _objectGopn.f;
- var toString$1 = {}.toString;
- var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
- ? Object.getOwnPropertyNames(window) : [];
- var getWindowNames = function (it) {
- try {
- return gOPN(it);
- } catch (e) {
- return windowNames.slice();
- }
- };
- var f$5 = function getOwnPropertyNames(it) {
- return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it));
- };
- var _objectGopnExt = {
- f: f$5
- };
- var gOPD = Object.getOwnPropertyDescriptor;
- var f$6 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
- O = _toIobject(O);
- P = _toPrimitive(P, true);
- if (_ie8DomDefine) try {
- return gOPD(O, P);
- } catch (e) { /* empty */ }
- if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
- };
- var _objectGopd = {
- f: f$6
- };
- // ECMAScript 6 symbols shim
- var META = _meta.KEY;
- var gOPD$1 = _objectGopd.f;
- var dP$1 = _objectDp.f;
- var gOPN$1 = _objectGopnExt.f;
- var $Symbol = _global.Symbol;
- var $JSON = _global.JSON;
- var _stringify = $JSON && $JSON.stringify;
- var PROTOTYPE$2 = 'prototype';
- var HIDDEN = _wks('_hidden');
- var TO_PRIMITIVE = _wks('toPrimitive');
- var isEnum = {}.propertyIsEnumerable;
- var SymbolRegistry = _shared('symbol-registry');
- var AllSymbols = _shared('symbols');
- var OPSymbols = _shared('op-symbols');
- var ObjectProto$1 = Object[PROTOTYPE$2];
- var USE_NATIVE = typeof $Symbol == 'function';
- var QObject = _global.QObject;
- // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
- var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild;
- // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
- var setSymbolDesc = _descriptors && _fails(function () {
- return _objectCreate(dP$1({}, 'a', {
- get: function () { return dP$1(this, 'a', { value: 7 }).a; }
- })).a != 7;
- }) ? function (it, key, D) {
- var protoDesc = gOPD$1(ObjectProto$1, key);
- if (protoDesc) delete ObjectProto$1[key];
- dP$1(it, key, D);
- if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc);
- } : dP$1;
- var wrap = function (tag) {
- var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]);
- sym._k = tag;
- return sym;
- };
- var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
- return typeof it == 'symbol';
- } : function (it) {
- return it instanceof $Symbol;
- };
- var $defineProperty = function defineProperty(it, key, D) {
- if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D);
- _anObject(it);
- key = _toPrimitive(key, true);
- _anObject(D);
- if (_has(AllSymbols, key)) {
- if (!D.enumerable) {
- if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {}));
- it[HIDDEN][key] = true;
- } else {
- if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
- D = _objectCreate(D, { enumerable: _propertyDesc(0, false) });
- } return setSymbolDesc(it, key, D);
- } return dP$1(it, key, D);
- };
- var $defineProperties = function defineProperties(it, P) {
- _anObject(it);
- var keys = _enumKeys(P = _toIobject(P));
- var i = 0;
- var l = keys.length;
- var key;
- while (l > i) $defineProperty(it, key = keys[i++], P[key]);
- return it;
- };
- var $create = function create(it, P) {
- return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P);
- };
- var $propertyIsEnumerable = function propertyIsEnumerable(key) {
- var E = isEnum.call(this, key = _toPrimitive(key, true));
- if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false;
- return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
- };
- var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
- it = _toIobject(it);
- key = _toPrimitive(key, true);
- if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return;
- var D = gOPD$1(it, key);
- if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
- return D;
- };
- var $getOwnPropertyNames = function getOwnPropertyNames(it) {
- var names = gOPN$1(_toIobject(it));
- var result = [];
- var i = 0;
- var key;
- while (names.length > i) {
- if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
- } return result;
- };
- var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
- var IS_OP = it === ObjectProto$1;
- var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it));
- var result = [];
- var i = 0;
- var key;
- while (names.length > i) {
- if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]);
- } return result;
- };
- // 19.4.1.1 Symbol([description])
- if (!USE_NATIVE) {
- $Symbol = function Symbol() {
- if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
- var tag = _uid(arguments.length > 0 ? arguments[0] : undefined);
- var $set = function (value) {
- if (this === ObjectProto$1) $set.call(OPSymbols, value);
- if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
- setSymbolDesc(this, tag, _propertyDesc(1, value));
- };
- if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set });
- return wrap(tag);
- };
- _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() {
- return this._k;
- });
- _objectGopd.f = $getOwnPropertyDescriptor;
- _objectDp.f = $defineProperty;
- _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames;
- _objectPie.f = $propertyIsEnumerable;
- _objectGops.f = $getOwnPropertySymbols;
- if (_descriptors && !_library) {
- _redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true);
- }
- _wksExt.f = function (name) {
- return wrap(_wks(name));
- };
- }
- _export(_export.G + _export.W + _export.F * !USE_NATIVE, { Symbol: $Symbol });
- for (var es6Symbols = (
- // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
- 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
- ).split(','), j = 0; es6Symbols.length > j;)_wks(es6Symbols[j++]);
- for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]);
- _export(_export.S + _export.F * !USE_NATIVE, 'Symbol', {
- // 19.4.2.1 Symbol.for(key)
- 'for': function (key) {
- return _has(SymbolRegistry, key += '')
- ? SymbolRegistry[key]
- : SymbolRegistry[key] = $Symbol(key);
- },
- // 19.4.2.5 Symbol.keyFor(sym)
- keyFor: function keyFor(sym) {
- if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
- for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
- },
- useSetter: function () { setter = true; },
- useSimple: function () { setter = false; }
- });
- _export(_export.S + _export.F * !USE_NATIVE, 'Object', {
- // 19.1.2.2 Object.create(O [, Properties])
- create: $create,
- // 19.1.2.4 Object.defineProperty(O, P, Attributes)
- defineProperty: $defineProperty,
- // 19.1.2.3 Object.defineProperties(O, Properties)
- defineProperties: $defineProperties,
- // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
- getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
- // 19.1.2.7 Object.getOwnPropertyNames(O)
- getOwnPropertyNames: $getOwnPropertyNames,
- // 19.1.2.8 Object.getOwnPropertySymbols(O)
- getOwnPropertySymbols: $getOwnPropertySymbols
- });
- // 24.3.2 JSON.stringify(value [, replacer [, space]])
- $JSON && _export(_export.S + _export.F * (!USE_NATIVE || _fails(function () {
- var S = $Symbol();
- // MS Edge converts symbol values to JSON as {}
- // WebKit converts symbol values to JSON as null
- // V8 throws on boxed symbols
- return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
- })), 'JSON', {
- stringify: function stringify(it) {
- var args = [it];
- var i = 1;
- var replacer, $replacer;
- while (arguments.length > i) args.push(arguments[i++]);
- $replacer = replacer = args[1];
- if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
- if (!_isArray(replacer)) replacer = function (key, value) {
- if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
- if (!isSymbol(value)) return value;
- };
- args[1] = replacer;
- return _stringify.apply($JSON, args);
- }
- });
- // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
- $Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf);
- // 19.4.3.5 Symbol.prototype[@@toStringTag]
- _setToStringTag($Symbol, 'Symbol');
- // 20.2.1.9 Math[@@toStringTag]
- _setToStringTag(Math, 'Math', true);
- // 24.3.3 JSON[@@toStringTag]
- _setToStringTag(_global.JSON, 'JSON', true);
- _wksDefine('asyncIterator');
- _wksDefine('observable');
- var symbol = _core.Symbol;
- var symbol$1 = createCommonjsModule(function (module) {
- module.exports = { "default": symbol, __esModule: true };
- });
- unwrapExports(symbol$1);
- var _typeof_1 = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- var _iterator2 = _interopRequireDefault(iterator$1);
- var _symbol2 = _interopRequireDefault(symbol$1);
- var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
- return typeof obj === "undefined" ? "undefined" : _typeof(obj);
- } : function (obj) {
- return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
- };
- });
- var _typeof = unwrapExports(_typeof_1);
- var _redefineAll = function (target, src, safe) {
- for (var key in src) {
- if (safe && target[key]) target[key] = src[key];
- else _hide(target, key, src[key]);
- } return target;
- };
- var _anInstance = function (it, Constructor, name, forbiddenField) {
- if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
- throw TypeError(name + ': incorrect invocation!');
- } return it;
- };
- // call something on iterator step with safe closing on error
- var _iterCall = function (iterator, fn, value, entries) {
- try {
- return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
- // 7.4.6 IteratorClose(iterator, completion)
- } catch (e) {
- var ret = iterator['return'];
- if (ret !== undefined) _anObject(ret.call(iterator));
- throw e;
- }
- };
- // check on default Array iterator
- var ITERATOR$1 = _wks('iterator');
- var ArrayProto = Array.prototype;
- var _isArrayIter = function (it) {
- return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it);
- };
- // getting tag from 19.1.3.6 Object.prototype.toString()
- var TAG$1 = _wks('toStringTag');
- // ES3 wrong here
- var ARG = _cof(function () { return arguments; }()) == 'Arguments';
- // fallback for IE11 Script Access Denied error
- var tryGet = function (it, key) {
- try {
- return it[key];
- } catch (e) { /* empty */ }
- };
- var _classof = function (it) {
- var O, T, B;
- return it === undefined ? 'Undefined' : it === null ? 'Null'
- // @@toStringTag case
- : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
- // builtinTag case
- : ARG ? _cof(O)
- // ES3 arguments fallback
- : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
- };
- var ITERATOR$2 = _wks('iterator');
- var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
- if (it != undefined) return it[ITERATOR$2]
- || it['@@iterator']
- || _iterators[_classof(it)];
- };
- var _forOf = createCommonjsModule(function (module) {
- var BREAK = {};
- var RETURN = {};
- var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
- var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
- var f = _ctx(fn, that, entries ? 2 : 1);
- var index = 0;
- var length, step, iterator, result;
- if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
- // fast case for arrays with default iterator
- if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
- result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
- if (result === BREAK || result === RETURN) return result;
- } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
- result = _iterCall(iterator, f, step.value, entries);
- if (result === BREAK || result === RETURN) return result;
- }
- };
- exports.BREAK = BREAK;
- exports.RETURN = RETURN;
- });
- var SPECIES = _wks('species');
- var _setSpecies = function (KEY) {
- var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY];
- if (_descriptors && C && !C[SPECIES]) _objectDp.f(C, SPECIES, {
- configurable: true,
- get: function () { return this; }
- });
- };
- var _validateCollection = function (it, TYPE) {
- if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
- return it;
- };
- var dP$2 = _objectDp.f;
- var fastKey = _meta.fastKey;
- var SIZE = _descriptors ? '_s' : 'size';
- var getEntry = function (that, key) {
- // fast case
- var index = fastKey(key);
- var entry;
- if (index !== 'F') return that._i[index];
- // frozen object case
- for (entry = that._f; entry; entry = entry.n) {
- if (entry.k == key) return entry;
- }
- };
- var _collectionStrong = {
- getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
- var C = wrapper(function (that, iterable) {
- _anInstance(that, C, NAME, '_i');
- that._t = NAME; // collection type
- that._i = _objectCreate(null); // index
- that._f = undefined; // first entry
- that._l = undefined; // last entry
- that[SIZE] = 0; // size
- if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
- });
- _redefineAll(C.prototype, {
- // 23.1.3.1 Map.prototype.clear()
- // 23.2.3.2 Set.prototype.clear()
- clear: function clear() {
- for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
- entry.r = true;
- if (entry.p) entry.p = entry.p.n = undefined;
- delete data[entry.i];
- }
- that._f = that._l = undefined;
- that[SIZE] = 0;
- },
- // 23.1.3.3 Map.prototype.delete(key)
- // 23.2.3.4 Set.prototype.delete(value)
- 'delete': function (key) {
- var that = _validateCollection(this, NAME);
- var entry = getEntry(that, key);
- if (entry) {
- var next = entry.n;
- var prev = entry.p;
- delete that._i[entry.i];
- entry.r = true;
- if (prev) prev.n = next;
- if (next) next.p = prev;
- if (that._f == entry) that._f = next;
- if (that._l == entry) that._l = prev;
- that[SIZE]--;
- } return !!entry;
- },
- // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
- // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
- forEach: function forEach(callbackfn /* , that = undefined */) {
- _validateCollection(this, NAME);
- var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
- var entry;
- while (entry = entry ? entry.n : this._f) {
- f(entry.v, entry.k, this);
- // revert to the last existing entry
- while (entry && entry.r) entry = entry.p;
- }
- },
- // 23.1.3.7 Map.prototype.has(key)
- // 23.2.3.7 Set.prototype.has(value)
- has: function has(key) {
- return !!getEntry(_validateCollection(this, NAME), key);
- }
- });
- if (_descriptors) dP$2(C.prototype, 'size', {
- get: function () {
- return _validateCollection(this, NAME)[SIZE];
- }
- });
- return C;
- },
- def: function (that, key, value) {
- var entry = getEntry(that, key);
- var prev, index;
- // change existing entry
- if (entry) {
- entry.v = value;
- // create new entry
- } else {
- that._l = entry = {
- i: index = fastKey(key, true), // <- index
- k: key, // <- key
- v: value, // <- value
- p: prev = that._l, // <- previous entry
- n: undefined, // <- next entry
- r: false // <- removed
- };
- if (!that._f) that._f = entry;
- if (prev) prev.n = entry;
- that[SIZE]++;
- // add to index
- if (index !== 'F') that._i[index] = entry;
- } return that;
- },
- getEntry: getEntry,
- setStrong: function (C, NAME, IS_MAP) {
- // add .keys, .values, .entries, [@@iterator]
- // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
- _iterDefine(C, NAME, function (iterated, kind) {
- this._t = _validateCollection(iterated, NAME); // target
- this._k = kind; // kind
- this._l = undefined; // previous
- }, function () {
- var that = this;
- var kind = that._k;
- var entry = that._l;
- // revert to the last existing entry
- while (entry && entry.r) entry = entry.p;
- // get next entry
- if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
- // or finish the iteration
- that._t = undefined;
- return _iterStep(1);
- }
- // return step by kind
- if (kind == 'keys') return _iterStep(0, entry.k);
- if (kind == 'values') return _iterStep(0, entry.v);
- return _iterStep(0, [entry.k, entry.v]);
- }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
- // add [@@species], 23.1.2.2, 23.2.2.2
- _setSpecies(NAME);
- }
- };
- var SPECIES$1 = _wks('species');
- var _arraySpeciesConstructor = function (original) {
- var C;
- if (_isArray(original)) {
- C = original.constructor;
- // cross-realm fallback
- if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
- if (_isObject(C)) {
- C = C[SPECIES$1];
- if (C === null) C = undefined;
- }
- } return C === undefined ? Array : C;
- };
- // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
- var _arraySpeciesCreate = function (original, length) {
- return new (_arraySpeciesConstructor(original))(length);
- };
- // 0 -> Array#forEach
- // 1 -> Array#map
- // 2 -> Array#filter
- // 3 -> Array#some
- // 4 -> Array#every
- // 5 -> Array#find
- // 6 -> Array#findIndex
- var _arrayMethods = function (TYPE, $create) {
- var IS_MAP = TYPE == 1;
- var IS_FILTER = TYPE == 2;
- var IS_SOME = TYPE == 3;
- var IS_EVERY = TYPE == 4;
- var IS_FIND_INDEX = TYPE == 6;
- var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
- var create = $create || _arraySpeciesCreate;
- return function ($this, callbackfn, that) {
- var O = _toObject($this);
- var self = _iobject(O);
- var f = _ctx(callbackfn, that, 3);
- var length = _toLength(self.length);
- var index = 0;
- var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
- var val, res;
- for (;length > index; index++) if (NO_HOLES || index in self) {
- val = self[index];
- res = f(val, index, O);
- if (TYPE) {
- if (IS_MAP) result[index] = res; // map
- else if (res) switch (TYPE) {
- case 3: return true; // some
- case 5: return val; // find
- case 6: return index; // findIndex
- case 2: result.push(val); // filter
- } else if (IS_EVERY) return false; // every
- }
- }
- return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
- };
- };
- var dP$3 = _objectDp.f;
- var each = _arrayMethods(0);
- var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
- var Base = _global[NAME];
- var C = Base;
- var ADDER = IS_MAP ? 'set' : 'add';
- var proto = C && C.prototype;
- var O = {};
- if (!_descriptors || typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
- new C().entries().next();
- }))) {
- // create collection constructor
- C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
- _redefineAll(C.prototype, methods);
- _meta.NEED = true;
- } else {
- C = wrapper(function (target, iterable) {
- _anInstance(target, C, NAME, '_c');
- target._c = new Base();
- if (iterable != undefined) _forOf(iterable, IS_MAP, target[ADDER], target);
- });
- each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
- var IS_ADDER = KEY == 'add' || KEY == 'set';
- if (KEY in proto && !(IS_WEAK && KEY == 'clear')) _hide(C.prototype, KEY, function (a, b) {
- _anInstance(this, C, KEY);
- if (!IS_ADDER && IS_WEAK && !_isObject(a)) return KEY == 'get' ? undefined : false;
- var result = this._c[KEY](a === 0 ? 0 : a, b);
- return IS_ADDER ? this : result;
- });
- });
- IS_WEAK || dP$3(C.prototype, 'size', {
- get: function () {
- return this._c.size;
- }
- });
- }
- _setToStringTag(C, NAME);
- O[NAME] = C;
- _export(_export.G + _export.W + _export.F, O);
- if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
- return C;
- };
- var MAP = 'Map';
- // 23.1 Map Objects
- var es6_map = _collection(MAP, function (get) {
- return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.1.3.6 Map.prototype.get(key)
- get: function get(key) {
- var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key);
- return entry && entry.v;
- },
- // 23.1.3.9 Map.prototype.set(key, value)
- set: function set(key, value) {
- return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value);
- }
- }, _collectionStrong, true);
- var _arrayFromIterable = function (iter, ITERATOR) {
- var result = [];
- _forOf(iter, false, result.push, result, ITERATOR);
- return result;
- };
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- var _collectionToJson = function (NAME) {
- return function toJSON() {
- if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
- return _arrayFromIterable(this);
- };
- };
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- _export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') });
- // https://tc39.github.io/proposal-setmap-offrom/
- var _setCollectionOf = function (COLLECTION) {
- _export(_export.S, COLLECTION, { of: function of() {
- var length = arguments.length;
- var A = new Array(length);
- while (length--) A[length] = arguments[length];
- return new this(A);
- } });
- };
- // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
- _setCollectionOf('Map');
- // https://tc39.github.io/proposal-setmap-offrom/
- var _setCollectionFrom = function (COLLECTION) {
- _export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
- var mapFn = arguments[1];
- var mapping, A, n, cb;
- _aFunction(this);
- mapping = mapFn !== undefined;
- if (mapping) _aFunction(mapFn);
- if (source == undefined) return new this();
- A = [];
- if (mapping) {
- n = 0;
- cb = _ctx(mapFn, arguments[2], 2);
- _forOf(source, false, function (nextItem) {
- A.push(cb(nextItem, n++));
- });
- } else {
- _forOf(source, false, A.push, A);
- }
- return new this(A);
- } });
- };
- // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
- _setCollectionFrom('Map');
- var map = _core.Map;
- var map$1 = createCommonjsModule(function (module) {
- module.exports = { "default": map, __esModule: true };
- });
- var _Map = unwrapExports(map$1);
- // 7.3.20 SpeciesConstructor(O, defaultConstructor)
- var SPECIES$2 = _wks('species');
- var _speciesConstructor = function (O, D) {
- var C = _anObject(O).constructor;
- var S;
- return C === undefined || (S = _anObject(C)[SPECIES$2]) == undefined ? D : _aFunction(S);
- };
- // fast apply, http://jsperf.lnkit.com/fast-apply/5
- var _invoke = function (fn, args, that) {
- var un = that === undefined;
- switch (args.length) {
- case 0: return un ? fn()
- : fn.call(that);
- case 1: return un ? fn(args[0])
- : fn.call(that, args[0]);
- case 2: return un ? fn(args[0], args[1])
- : fn.call(that, args[0], args[1]);
- case 3: return un ? fn(args[0], args[1], args[2])
- : fn.call(that, args[0], args[1], args[2]);
- case 4: return un ? fn(args[0], args[1], args[2], args[3])
- : fn.call(that, args[0], args[1], args[2], args[3]);
- } return fn.apply(that, args);
- };
- var process = _global.process;
- var setTask = _global.setImmediate;
- var clearTask = _global.clearImmediate;
- var MessageChannel = _global.MessageChannel;
- var Dispatch = _global.Dispatch;
- var counter = 0;
- var queue = {};
- var ONREADYSTATECHANGE = 'onreadystatechange';
- var defer, channel, port;
- var run = function () {
- var id = +this;
- // eslint-disable-next-line no-prototype-builtins
- if (queue.hasOwnProperty(id)) {
- var fn = queue[id];
- delete queue[id];
- fn();
- }
- };
- var listener = function (event) {
- run.call(event.data);
- };
- // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
- if (!setTask || !clearTask) {
- setTask = function setImmediate(fn) {
- var args = [];
- var i = 1;
- while (arguments.length > i) args.push(arguments[i++]);
- queue[++counter] = function () {
- // eslint-disable-next-line no-new-func
- _invoke(typeof fn == 'function' ? fn : Function(fn), args);
- };
- defer(counter);
- return counter;
- };
- clearTask = function clearImmediate(id) {
- delete queue[id];
- };
- // Node.js 0.8-
- if (_cof(process) == 'process') {
- defer = function (id) {
- process.nextTick(_ctx(run, id, 1));
- };
- // Sphere (JS game engine) Dispatch API
- } else if (Dispatch && Dispatch.now) {
- defer = function (id) {
- Dispatch.now(_ctx(run, id, 1));
- };
- // Browsers with MessageChannel, includes WebWorkers
- } else if (MessageChannel) {
- channel = new MessageChannel();
- port = channel.port2;
- channel.port1.onmessage = listener;
- defer = _ctx(port.postMessage, port, 1);
- // Browsers with postMessage, skip WebWorkers
- // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
- } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {
- defer = function (id) {
- _global.postMessage(id + '', '*');
- };
- _global.addEventListener('message', listener, false);
- // IE8-
- } else if (ONREADYSTATECHANGE in _domCreate('script')) {
- defer = function (id) {
- _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {
- _html.removeChild(this);
- run.call(id);
- };
- };
- // Rest old browsers
- } else {
- defer = function (id) {
- setTimeout(_ctx(run, id, 1), 0);
- };
- }
- }
- var _task = {
- set: setTask,
- clear: clearTask
- };
- var macrotask = _task.set;
- var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
- var process$1 = _global.process;
- var Promise = _global.Promise;
- var isNode = _cof(process$1) == 'process';
- var _microtask = function () {
- var head, last, notify;
- var flush = function () {
- var parent, fn;
- if (isNode && (parent = process$1.domain)) parent.exit();
- while (head) {
- fn = head.fn;
- head = head.next;
- try {
- fn();
- } catch (e) {
- if (head) notify();
- else last = undefined;
- throw e;
- }
- } last = undefined;
- if (parent) parent.enter();
- };
- // Node.js
- if (isNode) {
- notify = function () {
- process$1.nextTick(flush);
- };
- // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
- } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
- var toggle = true;
- var node = document.createTextNode('');
- new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
- notify = function () {
- node.data = toggle = !toggle;
- };
- // environments with maybe non-completely correct, but existent Promise
- } else if (Promise && Promise.resolve) {
- // Promise.resolve without an argument throws an error in LG WebOS 2
- var promise = Promise.resolve(undefined);
- notify = function () {
- promise.then(flush);
- };
- // for other environments - macrotask based on:
- // - setImmediate
- // - MessageChannel
- // - window.postMessag
- // - onreadystatechange
- // - setTimeout
- } else {
- notify = function () {
- // strange IE + webpack dev server bug - use .call(global)
- macrotask.call(_global, flush);
- };
- }
- return function (fn) {
- var task = { fn: fn, next: undefined };
- if (last) last.next = task;
- if (!head) {
- head = task;
- notify();
- } last = task;
- };
- };
- // 25.4.1.5 NewPromiseCapability(C)
- function PromiseCapability(C) {
- var resolve, reject;
- this.promise = new C(function ($$resolve, $$reject) {
- if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
- resolve = $$resolve;
- reject = $$reject;
- });
- this.resolve = _aFunction(resolve);
- this.reject = _aFunction(reject);
- }
- var f$7 = function (C) {
- return new PromiseCapability(C);
- };
- var _newPromiseCapability = {
- f: f$7
- };
- var _perform = function (exec) {
- try {
- return { e: false, v: exec() };
- } catch (e) {
- return { e: true, v: e };
- }
- };
- var navigator = _global.navigator;
- var _userAgent = navigator && navigator.userAgent || '';
- var _promiseResolve = function (C, x) {
- _anObject(C);
- if (_isObject(x) && x.constructor === C) return x;
- var promiseCapability = _newPromiseCapability.f(C);
- var resolve = promiseCapability.resolve;
- resolve(x);
- return promiseCapability.promise;
- };
- var ITERATOR$3 = _wks('iterator');
- var SAFE_CLOSING = false;
- try {
- var riter = [7][ITERATOR$3]();
- riter['return'] = function () { SAFE_CLOSING = true; };
- } catch (e) { /* empty */ }
- var _iterDetect = function (exec, skipClosing) {
- if (!skipClosing && !SAFE_CLOSING) return false;
- var safe = false;
- try {
- var arr = [7];
- var iter = arr[ITERATOR$3]();
- iter.next = function () { return { done: safe = true }; };
- arr[ITERATOR$3] = function () { return iter; };
- exec(arr);
- } catch (e) { /* empty */ }
- return safe;
- };
- var task = _task.set;
- var microtask = _microtask();
- var PROMISE = 'Promise';
- var TypeError$1 = _global.TypeError;
- var process$2 = _global.process;
- var versions = process$2 && process$2.versions;
- var v8 = versions && versions.v8 || '';
- var $Promise = _global[PROMISE];
- var isNode$1 = _classof(process$2) == 'process';
- var empty = function () { /* empty */ };
- var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
- var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
- var USE_NATIVE$1 = !!function () {
- try {
- // correct subclassing with @@species support
- var promise = $Promise.resolve(1);
- var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {
- exec(empty, empty);
- };
- // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
- return (isNode$1 || typeof PromiseRejectionEvent == 'function')
- && promise.then(empty) instanceof FakePromise
- // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
- // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
- // we can't detect it synchronously, so just check versions
- && v8.indexOf('6.6') !== 0
- && _userAgent.indexOf('Chrome/66') === -1;
- } catch (e) { /* empty */ }
- }();
- // helpers
- var isThenable = function (it) {
- var then;
- return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
- };
- var notify = function (promise, isReject) {
- if (promise._n) return;
- promise._n = true;
- var chain = promise._c;
- microtask(function () {
- var value = promise._v;
- var ok = promise._s == 1;
- var i = 0;
- var run = function (reaction) {
- var handler = ok ? reaction.ok : reaction.fail;
- var resolve = reaction.resolve;
- var reject = reaction.reject;
- var domain = reaction.domain;
- var result, then, exited;
- try {
- if (handler) {
- if (!ok) {
- if (promise._h == 2) onHandleUnhandled(promise);
- promise._h = 1;
- }
- if (handler === true) result = value;
- else {
- if (domain) domain.enter();
- result = handler(value); // may throw
- if (domain) {
- domain.exit();
- exited = true;
- }
- }
- if (result === reaction.promise) {
- reject(TypeError$1('Promise-chain cycle'));
- } else if (then = isThenable(result)) {
- then.call(result, resolve, reject);
- } else resolve(result);
- } else reject(value);
- } catch (e) {
- if (domain && !exited) domain.exit();
- reject(e);
- }
- };
- while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
- promise._c = [];
- promise._n = false;
- if (isReject && !promise._h) onUnhandled(promise);
- });
- };
- var onUnhandled = function (promise) {
- task.call(_global, function () {
- var value = promise._v;
- var unhandled = isUnhandled(promise);
- var result, handler, console;
- if (unhandled) {
- result = _perform(function () {
- if (isNode$1) {
- process$2.emit('unhandledRejection', value, promise);
- } else if (handler = _global.onunhandledrejection) {
- handler({ promise: promise, reason: value });
- } else if ((console = _global.console) && console.error) {
- console.error('Unhandled promise rejection', value);
- }
- });
- // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
- promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
- } promise._a = undefined;
- if (unhandled && result.e) throw result.v;
- });
- };
- var isUnhandled = function (promise) {
- return promise._h !== 1 && (promise._a || promise._c).length === 0;
- };
- var onHandleUnhandled = function (promise) {
- task.call(_global, function () {
- var handler;
- if (isNode$1) {
- process$2.emit('rejectionHandled', promise);
- } else if (handler = _global.onrejectionhandled) {
- handler({ promise: promise, reason: promise._v });
- }
- });
- };
- var $reject = function (value) {
- var promise = this;
- if (promise._d) return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- promise._v = value;
- promise._s = 2;
- if (!promise._a) promise._a = promise._c.slice();
- notify(promise, true);
- };
- var $resolve = function (value) {
- var promise = this;
- var then;
- if (promise._d) return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- try {
- if (promise === value) throw TypeError$1("Promise can't be resolved itself");
- if (then = isThenable(value)) {
- microtask(function () {
- var wrapper = { _w: promise, _d: false }; // wrap
- try {
- then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
- } catch (e) {
- $reject.call(wrapper, e);
- }
- });
- } else {
- promise._v = value;
- promise._s = 1;
- notify(promise, false);
- }
- } catch (e) {
- $reject.call({ _w: promise, _d: false }, e); // wrap
- }
- };
- // constructor polyfill
- if (!USE_NATIVE$1) {
- // 25.4.3.1 Promise(executor)
- $Promise = function Promise(executor) {
- _anInstance(this, $Promise, PROMISE, '_h');
- _aFunction(executor);
- Internal.call(this);
- try {
- executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
- } catch (err) {
- $reject.call(this, err);
- }
- };
- // eslint-disable-next-line no-unused-vars
- Internal = function Promise(executor) {
- this._c = []; // <- awaiting reactions
- this._a = undefined; // <- checked in isUnhandled reactions
- this._s = 0; // <- state
- this._d = false; // <- done
- this._v = undefined; // <- value
- this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
- this._n = false; // <- notify
- };
- Internal.prototype = _redefineAll($Promise.prototype, {
- // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
- then: function then(onFulfilled, onRejected) {
- var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
- reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
- reaction.fail = typeof onRejected == 'function' && onRejected;
- reaction.domain = isNode$1 ? process$2.domain : undefined;
- this._c.push(reaction);
- if (this._a) this._a.push(reaction);
- if (this._s) notify(this, false);
- return reaction.promise;
- },
- // 25.4.5.1 Promise.prototype.catch(onRejected)
- 'catch': function (onRejected) {
- return this.then(undefined, onRejected);
- }
- });
- OwnPromiseCapability = function () {
- var promise = new Internal();
- this.promise = promise;
- this.resolve = _ctx($resolve, promise, 1);
- this.reject = _ctx($reject, promise, 1);
- };
- _newPromiseCapability.f = newPromiseCapability = function (C) {
- return C === $Promise || C === Wrapper
- ? new OwnPromiseCapability(C)
- : newGenericPromiseCapability(C);
- };
- }
- _export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { Promise: $Promise });
- _setToStringTag($Promise, PROMISE);
- _setSpecies(PROMISE);
- Wrapper = _core[PROMISE];
- // statics
- _export(_export.S + _export.F * !USE_NATIVE$1, PROMISE, {
- // 25.4.4.5 Promise.reject(r)
- reject: function reject(r) {
- var capability = newPromiseCapability(this);
- var $$reject = capability.reject;
- $$reject(r);
- return capability.promise;
- }
- });
- _export(_export.S + _export.F * (_library || !USE_NATIVE$1), PROMISE, {
- // 25.4.4.6 Promise.resolve(x)
- resolve: function resolve(x) {
- return _promiseResolve(_library && this === Wrapper ? $Promise : this, x);
- }
- });
- _export(_export.S + _export.F * !(USE_NATIVE$1 && _iterDetect(function (iter) {
- $Promise.all(iter)['catch'](empty);
- })), PROMISE, {
- // 25.4.4.1 Promise.all(iterable)
- all: function all(iterable) {
- var C = this;
- var capability = newPromiseCapability(C);
- var resolve = capability.resolve;
- var reject = capability.reject;
- var result = _perform(function () {
- var values = [];
- var index = 0;
- var remaining = 1;
- _forOf(iterable, false, function (promise) {
- var $index = index++;
- var alreadyCalled = false;
- values.push(undefined);
- remaining++;
- C.resolve(promise).then(function (value) {
- if (alreadyCalled) return;
- alreadyCalled = true;
- values[$index] = value;
- --remaining || resolve(values);
- }, reject);
- });
- --remaining || resolve(values);
- });
- if (result.e) reject(result.v);
- return capability.promise;
- },
- // 25.4.4.4 Promise.race(iterable)
- race: function race(iterable) {
- var C = this;
- var capability = newPromiseCapability(C);
- var reject = capability.reject;
- var result = _perform(function () {
- _forOf(iterable, false, function (promise) {
- C.resolve(promise).then(capability.resolve, reject);
- });
- });
- if (result.e) reject(result.v);
- return capability.promise;
- }
- });
- _export(_export.P + _export.R, 'Promise', { 'finally': function (onFinally) {
- var C = _speciesConstructor(this, _core.Promise || _global.Promise);
- var isFunction = typeof onFinally == 'function';
- return this.then(
- isFunction ? function (x) {
- return _promiseResolve(C, onFinally()).then(function () { return x; });
- } : onFinally,
- isFunction ? function (e) {
- return _promiseResolve(C, onFinally()).then(function () { throw e; });
- } : onFinally
- );
- } });
- // https://github.com/tc39/proposal-promise-try
- _export(_export.S, 'Promise', { 'try': function (callbackfn) {
- var promiseCapability = _newPromiseCapability.f(this);
- var result = _perform(callbackfn);
- (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
- return promiseCapability.promise;
- } });
- var promise = _core.Promise;
- var promise$1 = createCommonjsModule(function (module) {
- module.exports = { "default": promise, __esModule: true };
- });
- var _Promise = unwrapExports(promise$1);
- var SET = 'Set';
- // 23.2 Set Objects
- var es6_set = _collection(SET, function (get) {
- return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.2.3.1 Set.prototype.add(value)
- add: function add(value) {
- return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value);
- }
- }, _collectionStrong);
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- _export(_export.P + _export.R, 'Set', { toJSON: _collectionToJson('Set') });
- // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
- _setCollectionOf('Set');
- // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
- _setCollectionFrom('Set');
- var set = _core.Set;
- var set$1 = createCommonjsModule(function (module) {
- module.exports = { "default": set, __esModule: true };
- });
- var _Set = unwrapExports(set$1);
- // 19.1.2.1 Object.assign(target, source, ...)
- var $assign = Object.assign;
- // should work with symbols and should have deterministic property order (V8 bug)
- var _objectAssign = !$assign || _fails(function () {
- var A = {};
- var B = {};
- // eslint-disable-next-line no-undef
- var S = Symbol();
- var K = 'abcdefghijklmnopqrst';
- A[S] = 7;
- K.split('').forEach(function (k) { B[k] = k; });
- return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
- }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
- var T = _toObject(target);
- var aLen = arguments.length;
- var index = 1;
- var getSymbols = _objectGops.f;
- var isEnum = _objectPie.f;
- while (aLen > index) {
- var S = _iobject(arguments[index++]);
- var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
- var length = keys.length;
- var j = 0;
- var key;
- while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
- } return T;
- } : $assign;
- var getWeak = _meta.getWeak;
- var arrayFind = _arrayMethods(5);
- var arrayFindIndex = _arrayMethods(6);
- var id$1 = 0;
- // fallback for uncaught frozen keys
- var uncaughtFrozenStore = function (that) {
- return that._l || (that._l = new UncaughtFrozenStore());
- };
- var UncaughtFrozenStore = function () {
- this.a = [];
- };
- var findUncaughtFrozen = function (store, key) {
- return arrayFind(store.a, function (it) {
- return it[0] === key;
- });
- };
- UncaughtFrozenStore.prototype = {
- get: function (key) {
- var entry = findUncaughtFrozen(this, key);
- if (entry) return entry[1];
- },
- has: function (key) {
- return !!findUncaughtFrozen(this, key);
- },
- set: function (key, value) {
- var entry = findUncaughtFrozen(this, key);
- if (entry) entry[1] = value;
- else this.a.push([key, value]);
- },
- 'delete': function (key) {
- var index = arrayFindIndex(this.a, function (it) {
- return it[0] === key;
- });
- if (~index) this.a.splice(index, 1);
- return !!~index;
- }
- };
- var _collectionWeak = {
- getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
- var C = wrapper(function (that, iterable) {
- _anInstance(that, C, NAME, '_i');
- that._t = NAME; // collection type
- that._i = id$1++; // collection id
- that._l = undefined; // leak store for uncaught frozen objects
- if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
- });
- _redefineAll(C.prototype, {
- // 23.3.3.2 WeakMap.prototype.delete(key)
- // 23.4.3.3 WeakSet.prototype.delete(value)
- 'delete': function (key) {
- if (!_isObject(key)) return false;
- var data = getWeak(key);
- if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME))['delete'](key);
- return data && _has(data, this._i) && delete data[this._i];
- },
- // 23.3.3.4 WeakMap.prototype.has(key)
- // 23.4.3.4 WeakSet.prototype.has(value)
- has: function has(key) {
- if (!_isObject(key)) return false;
- var data = getWeak(key);
- if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME)).has(key);
- return data && _has(data, this._i);
- }
- });
- return C;
- },
- def: function (that, key, value) {
- var data = getWeak(_anObject(key), true);
- if (data === true) uncaughtFrozenStore(that).set(key, value);
- else data[that._i] = value;
- return that;
- },
- ufstore: uncaughtFrozenStore
- };
- var es6_weakMap = createCommonjsModule(function (module) {
- var each = _arrayMethods(0);
- var WEAK_MAP = 'WeakMap';
- var getWeak = _meta.getWeak;
- var isExtensible = Object.isExtensible;
- var uncaughtFrozenStore = _collectionWeak.ufstore;
- var tmp = {};
- var InternalMap;
- var wrapper = function (get) {
- return function WeakMap() {
- return get(this, arguments.length > 0 ? arguments[0] : undefined);
- };
- };
- var methods = {
- // 23.3.3.3 WeakMap.prototype.get(key)
- get: function get(key) {
- if (_isObject(key)) {
- var data = getWeak(key);
- if (data === true) return uncaughtFrozenStore(_validateCollection(this, WEAK_MAP)).get(key);
- return data ? data[this._i] : undefined;
- }
- },
- // 23.3.3.5 WeakMap.prototype.set(key, value)
- set: function set(key, value) {
- return _collectionWeak.def(_validateCollection(this, WEAK_MAP), key, value);
- }
- };
- // 23.3 WeakMap Objects
- var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true);
- // IE11 WeakMap frozen keys fix
- if (_fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
- InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP);
- _objectAssign(InternalMap.prototype, methods);
- _meta.NEED = true;
- each(['delete', 'has', 'get', 'set'], function (key) {
- var proto = $WeakMap.prototype;
- var method = proto[key];
- _redefine(proto, key, function (a, b) {
- // store frozen objects on internal weakmap shim
- if (_isObject(a) && !isExtensible(a)) {
- if (!this._f) this._f = new InternalMap();
- var result = this._f[key](a, b);
- return key == 'set' ? this : result;
- // store all the rest on native weakmap
- } return method.call(this, a, b);
- });
- });
- }
- });
- // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of
- _setCollectionOf('WeakMap');
- // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from
- _setCollectionFrom('WeakMap');
- var weakMap = _core.WeakMap;
- var weakMap$1 = createCommonjsModule(function (module) {
- module.exports = { "default": weakMap, __esModule: true };
- });
- var _WeakMap = unwrapExports(weakMap$1);
- var classCallCheck = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- exports.default = function (instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- };
- });
- var _classCallCheck = unwrapExports(classCallCheck);
- var createClass = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- var _defineProperty2 = _interopRequireDefault(defineProperty$1);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- exports.default = function () {
- function defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ("value" in descriptor) descriptor.writable = true;
- (0, _defineProperty2.default)(target, descriptor.key, descriptor);
- }
- }
- return function (Constructor, protoProps, staticProps) {
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
- if (staticProps) defineProperties(Constructor, staticProps);
- return Constructor;
- };
- }();
- });
- var _createClass = unwrapExports(createClass);
- // most Object methods by ES6 should accept primitives
- var _objectSap = function (KEY, exec) {
- var fn = (_core.Object || {})[KEY] || Object[KEY];
- var exp = {};
- exp[KEY] = exec(fn);
- _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
- };
- // 19.1.2.14 Object.keys(O)
- _objectSap('keys', function () {
- return function keys(it) {
- return _objectKeys(_toObject(it));
- };
- });
- var keys = _core.Object.keys;
- var keys$1 = createCommonjsModule(function (module) {
- module.exports = { "default": keys, __esModule: true };
- });
- var _Object$keys = unwrapExports(keys$1);
- // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
- var $getOwnPropertyDescriptor$1 = _objectGopd.f;
- _objectSap('getOwnPropertyDescriptor', function () {
- return function getOwnPropertyDescriptor(it, key) {
- return $getOwnPropertyDescriptor$1(_toIobject(it), key);
- };
- });
- var $Object$1 = _core.Object;
- var getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
- return $Object$1.getOwnPropertyDescriptor(it, key);
- };
- var getOwnPropertyDescriptor$1 = createCommonjsModule(function (module) {
- module.exports = { "default": getOwnPropertyDescriptor, __esModule: true };
- });
- var _Object$getOwnPropertyDescriptor = unwrapExports(getOwnPropertyDescriptor$1);
- // 19.1.2.7 Object.getOwnPropertyNames(O)
- _objectSap('getOwnPropertyNames', function () {
- return _objectGopnExt.f;
- });
- var $Object$2 = _core.Object;
- var getOwnPropertyNames = function getOwnPropertyNames(it) {
- return $Object$2.getOwnPropertyNames(it);
- };
- var getOwnPropertyNames$1 = createCommonjsModule(function (module) {
- module.exports = { "default": getOwnPropertyNames, __esModule: true };
- });
- var _Object$getOwnPropertyNames = unwrapExports(getOwnPropertyNames$1);
- // 19.1.2.9 Object.getPrototypeOf(O)
- _objectSap('getPrototypeOf', function () {
- return function getPrototypeOf(it) {
- return _objectGpo(_toObject(it));
- };
- });
- var getPrototypeOf = _core.Object.getPrototypeOf;
- var getPrototypeOf$1 = createCommonjsModule(function (module) {
- module.exports = { "default": getPrototypeOf, __esModule: true };
- });
- var _Object$getPrototypeOf = unwrapExports(getPrototypeOf$1);
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- _export(_export.S, 'Object', { create: _objectCreate });
- var $Object$3 = _core.Object;
- var create = function create(P, D) {
- return $Object$3.create(P, D);
- };
- var create$1 = createCommonjsModule(function (module) {
- module.exports = { "default": create, __esModule: true };
- });
- var _Object$create = unwrapExports(create$1);
- // 19.1.3.1 Object.assign(target, source)
- _export(_export.S + _export.F, 'Object', { assign: _objectAssign });
- var assign = _core.Object.assign;
- var assign$1 = createCommonjsModule(function (module) {
- module.exports = { "default": assign, __esModule: true };
- });
- var _Object$assign = unwrapExports(assign$1);
- var src = createCommonjsModule(function (module) {
- /**
- * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
- /**
- * Represents the result of a single call to a mock function.
- */
- var MOCK_CONSTRUCTOR_NAME = 'mockConstructor';
- var FUNCTION_NAME_RESERVED_PATTERN = /[\s!-\/:-@\[-`{-~]/;
- var FUNCTION_NAME_RESERVED_REPLACE = new RegExp(FUNCTION_NAME_RESERVED_PATTERN.source, 'g');
- var RESERVED_KEYWORDS = _Object$assign(_Object$create(null), {
- arguments: true,
- await: true,
- break: true,
- case: true,
- catch: true,
- class: true,
- const: true,
- continue: true,
- debugger: true,
- default: true,
- delete: true,
- do: true,
- else: true,
- enum: true,
- eval: true,
- export: true,
- extends: true,
- false: true,
- finally: true,
- for: true,
- function: true,
- if: true,
- implements: true,
- import: true,
- in: true,
- instanceof: true,
- interface: true,
- let: true,
- new: true,
- null: true,
- package: true,
- private: true,
- protected: true,
- public: true,
- return: true,
- static: true,
- super: true,
- switch: true,
- this: true,
- throw: true,
- true: true,
- try: true,
- typeof: true,
- var: true,
- void: true,
- while: true,
- with: true,
- yield: true
- });
- function matchArity(fn, length) {
- var mockConstructor = void 0;
- switch (length) {
- case 1:
- mockConstructor = function mockConstructor(a) {
- return fn.apply(this, arguments);
- };
- break;
- case 2:
- mockConstructor = function mockConstructor(a, b) {
- return fn.apply(this, arguments);
- };
- break;
- case 3:
- mockConstructor = function mockConstructor(a, b, c) {
- return fn.apply(this, arguments);
- };
- break;
- case 4:
- mockConstructor = function mockConstructor(a, b, c, d) {
- return fn.apply(this, arguments);
- };
- break;
- case 5:
- mockConstructor = function mockConstructor(a, b, c, d, e) {
- return fn.apply(this, arguments);
- };
- break;
- case 6:
- mockConstructor = function mockConstructor(a, b, c, d, e, f) {
- return fn.apply(this, arguments);
- };
- break;
- case 7:
- mockConstructor = function mockConstructor(a, b, c, d, e, f, g) {
- return fn.apply(this, arguments);
- };
- break;
- case 8:
- mockConstructor = function mockConstructor(a, b, c, d, e, f, g, h) {
- return fn.apply(this, arguments);
- };
- break;
- case 9:
- mockConstructor = function mockConstructor(a, b, c, d, e, f, g, h, i) {
- return fn.apply(this, arguments);
- };
- break;
- default:
- mockConstructor = function mockConstructor() {
- return fn.apply(this, arguments);
- };
- break;
- }
- return mockConstructor;
- }
- function isA(typeName, value) {
- return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
- }
- function getType(ref) {
- if (isA('Function', ref) || isA('AsyncFunction', ref) || isA('GeneratorFunction', ref)) {
- return 'function';
- } else if (Array.isArray(ref)) {
- return 'array';
- } else if (isA('Object', ref)) {
- return 'object';
- } else if (isA('Number', ref) || isA('String', ref) || isA('Boolean', ref) || isA('Symbol', ref)) {
- return 'constant';
- } else if (isA('Map', ref) || isA('WeakMap', ref) || isA('Set', ref)) {
- return 'collection';
- } else if (isA('RegExp', ref)) {
- return 'regexp';
- } else if (ref === undefined) {
- return 'undefined';
- } else if (ref === null) {
- return 'null';
- } else {
- return null;
- }
- }
- function isReadonlyProp(object, prop) {
- return (prop === 'arguments' || prop === 'caller' || prop === 'callee' || prop === 'name' || prop === 'length') && (isA('Function', object) || isA('AsyncFunction', object) || isA('GeneratorFunction', object)) || (prop === 'source' || prop === 'global' || prop === 'ignoreCase' || prop === 'multiline') && isA('RegExp', object);
- }
- function getSlots(object) {
- var slots = {};
- if (!object) {
- return [];
- }
- var parent = _Object$getPrototypeOf(object);
- do {
- if (object === _Object$getPrototypeOf(Function)) {
- break;
- }
- var ownNames = _Object$getOwnPropertyNames(object);
- for (var i = 0; i < ownNames.length; i++) {
- var prop = ownNames[i];
- if (!isReadonlyProp(object, prop)) {
- var propDesc = _Object$getOwnPropertyDescriptor(object, prop);
- if (propDesc !== undefined && !propDesc.get || object.__esModule) {
- slots[prop] = true;
- }
- }
- }
- object = parent;
- } while (object && (parent = _Object$getPrototypeOf(object)) !== null);
- return _Object$keys(slots);
- }
- var ModuleMockerClass = function () {
- /**
- * @see README.md
- * @param global Global object of the test environment, used to create
- * mocks
- */
- function ModuleMockerClass(global) {
- _classCallCheck(this, ModuleMockerClass);
- this._environmentGlobal = global;
- this._mockState = new _WeakMap();
- this._mockConfigRegistry = new _WeakMap();
- this._spyState = new _Set();
- this.ModuleMocker = ModuleMockerClass;
- this._invocationCallCounter = 1;
- }
- _createClass(ModuleMockerClass, [{
- key: '_ensureMockConfig',
- value: function _ensureMockConfig(f) {
- var config = this._mockConfigRegistry.get(f);
- if (!config) {
- config = this._defaultMockConfig();
- this._mockConfigRegistry.set(f, config);
- }
- return config;
- }
- }, {
- key: '_ensureMockState',
- value: function _ensureMockState(f) {
- var state = this._mockState.get(f);
- if (!state) {
- state = this._defaultMockState();
- this._mockState.set(f, state);
- }
- return state;
- }
- }, {
- key: '_defaultMockConfig',
- value: function _defaultMockConfig() {
- return {
- defaultReturnValue: undefined,
- isReturnValueLastSet: false,
- mockImpl: undefined,
- mockName: 'jest.fn()',
- specificMockImpls: [],
- specificReturnValues: []
- };
- }
- }, {
- key: '_defaultMockState',
- value: function _defaultMockState() {
- return {
- calls: [],
- instances: [],
- invocationCallOrder: [],
- results: []
- };
- }
- }, {
- key: '_makeComponent',
- value: function _makeComponent(metadata, restore) {
- var _this2 = this;
- if (metadata.type === 'object') {
- return new this._environmentGlobal.Object();
- } else if (metadata.type === 'array') {
- return new this._environmentGlobal.Array();
- } else if (metadata.type === 'regexp') {
- return new this._environmentGlobal.RegExp('');
- } else if (metadata.type === 'constant' || metadata.type === 'collection' || metadata.type === 'null' || metadata.type === 'undefined') {
- return metadata.value;
- } else if (metadata.type === 'function') {
- /* eslint-disable prefer-const */
- var f = void 0;
- /* eslint-enable prefer-const */
- var prototype = metadata.members && metadata.members.prototype && metadata.members.prototype.members || {};
- var prototypeSlots = getSlots(prototype);
- var mocker = this;
- var mockConstructor = matchArity(function () {
- var _this = this,
- _arguments = arguments;
- var mockState = mocker._ensureMockState(f);
- var mockConfig = mocker._ensureMockConfig(f);
- mockState.instances.push(this);
- mockState.calls.push(Array.prototype.slice.call(arguments));
- mockState.invocationCallOrder.push(mocker._invocationCallCounter++);
- // Will be set to the return value of the mock if an error is not thrown
- var finalReturnValue = void 0;
- // Will be set to the error that is thrown by the mock (if it throws)
- var thrownError = void 0;
- // Will be set to true if the mock throws an error. The presence of a
- // value in `thrownError` is not a 100% reliable indicator because a
- // function could throw a value of undefined.
- var callDidThrowError = false;
- try {
- // The bulk of the implementation is wrapped in an immediately
- // executed arrow function so the return value of the mock function
- // can be easily captured and recorded, despite the many separate
- // return points within the logic.
- finalReturnValue = function () {
- if (_this instanceof f) {
- // This is probably being called as a constructor
- prototypeSlots.forEach(function (slot) {
- // Copy prototype methods to the instance to make
- // it easier to interact with mock instance call and
- // return values
- if (prototype[slot].type === 'function') {
- var protoImpl = _this[slot];
- _this[slot] = mocker.generateFromMetadata(prototype[slot]);
- _this[slot]._protoImpl = protoImpl;
- }
- });
- // Run the mock constructor implementation
- var mockImpl = mockConfig.specificMockImpls.length ? mockConfig.specificMockImpls.shift() : mockConfig.mockImpl;
- return mockImpl && mockImpl.apply(_this, _arguments);
- }
- var returnValue = mockConfig.defaultReturnValue;
- // If return value is last set, either specific or default, i.e.
- // mockReturnValueOnce()/mockReturnValue() is called and no
- // mockImplementationOnce()/mockImplementation() is called after
- // that.
- // use the set return value.
- if (mockConfig.specificReturnValues.length) {
- return mockConfig.specificReturnValues.shift();
- }
- if (mockConfig.isReturnValueLastSet) {
- return mockConfig.defaultReturnValue;
- }
- // If mockImplementationOnce()/mockImplementation() is last set,
- // or specific return values are used up, use the mock
- // implementation.
- var specificMockImpl = void 0;
- if (returnValue === undefined) {
- specificMockImpl = mockConfig.specificMockImpls.shift();
- if (specificMockImpl === undefined) {
- specificMockImpl = mockConfig.mockImpl;
- }
- if (specificMockImpl) {
- return specificMockImpl.apply(_this, _arguments);
- }
- }
- // Otherwise use prototype implementation
- if (returnValue === undefined && f._protoImpl) {
- return f._protoImpl.apply(_this, _arguments);
- }
- return returnValue;
- }();
- } catch (error) {
- // Store the thrown error so we can record it, then re-throw it.
- thrownError = error;
- callDidThrowError = true;
- throw error;
- } finally {
- // Record the result of the function
- mockState.results.push({
- isThrow: callDidThrowError,
- value: callDidThrowError ? thrownError : finalReturnValue
- });
- }
- return finalReturnValue;
- }, metadata.length || 0);
- f = this._createMockFunction(metadata, mockConstructor);
- f._isMockFunction = true;
- f.getMockImplementation = function () {
- return _this2._ensureMockConfig(f).mockImpl;
- };
- if (typeof restore === 'function') {
- this._spyState.add(restore);
- }
- this._mockState.set(f, this._defaultMockState());
- this._mockConfigRegistry.set(f, this._defaultMockConfig());
- // $FlowFixMe - defineProperty getters not supported
- Object.defineProperty(f, 'mock', {
- configurable: false,
- enumerable: true,
- get: function get() {
- return _this2._ensureMockState(f);
- },
- set: function set(val) {
- return _this2._mockState.set(f, val);
- }
- });
- f.mockClear = function () {
- _this2._mockState.delete(f);
- return f;
- };
- f.mockReset = function () {
- f.mockClear();
- _this2._mockConfigRegistry.delete(f);
- return f;
- };
- f.mockRestore = function () {
- f.mockReset();
- return restore ? restore() : undefined;
- };
- f.mockReturnValueOnce = function (value) {
- // next function call will return this value or default return value
- var mockConfig = _this2._ensureMockConfig(f);
- mockConfig.specificReturnValues.push(value);
- return f;
- };
- f.mockResolvedValueOnce = function (value) {
- return f.mockImplementationOnce(function () {
- return _Promise.resolve(value);
- });
- };
- f.mockRejectedValueOnce = function (value) {
- return f.mockImplementationOnce(function () {
- return _Promise.reject(value);
- });
- };
- f.mockReturnValue = function (value) {
- // next function call will return specified return value or this one
- var mockConfig = _this2._ensureMockConfig(f);
- mockConfig.isReturnValueLastSet = true;
- mockConfig.defaultReturnValue = value;
- return f;
- };
- f.mockResolvedValue = function (value) {
- return f.mockImplementation(function () {
- return _Promise.resolve(value);
- });
- };
- f.mockRejectedValue = function (value) {
- return f.mockImplementation(function () {
- return _Promise.reject(value);
- });
- };
- f.mockImplementationOnce = function (fn) {
- // next function call will use this mock implementation return value
- // or default mock implementation return value
- var mockConfig = _this2._ensureMockConfig(f);
- mockConfig.isReturnValueLastSet = false;
- mockConfig.specificMockImpls.push(fn);
- return f;
- };
- f.mockImplementation = function (fn) {
- // next function call will use mock implementation return value
- var mockConfig = _this2._ensureMockConfig(f);
- mockConfig.isReturnValueLastSet = false;
- mockConfig.defaultReturnValue = undefined;
- mockConfig.mockImpl = fn;
- return f;
- };
- f.mockReturnThis = function () {
- return f.mockImplementation(function () {
- return this;
- });
- };
- f.mockName = function (name) {
- if (name) {
- var mockConfig = _this2._ensureMockConfig(f);
- mockConfig.mockName = name;
- }
- return f;
- };
- f.getMockName = function () {
- var mockConfig = _this2._ensureMockConfig(f);
- return mockConfig.mockName || 'jest.fn()';
- };
- if (metadata.mockImpl) {
- f.mockImplementation(metadata.mockImpl);
- }
- return f;
- } else {
- var unknownType = metadata.type || 'undefined type';
- throw new Error('Unrecognized type ' + unknownType);
- }
- }
- }, {
- key: '_createMockFunction',
- value: function _createMockFunction(metadata, mockConstructor) {
- var name = metadata.name;
- if (!name) {
- return mockConstructor;
- }
- // Preserve `name` property of mocked function.
- var boundFunctionPrefix = 'bound ';
- var bindCall = '';
- // if-do-while for perf reasons. The common case is for the if to fail.
- if (name && name.startsWith(boundFunctionPrefix)) {
- do {
- name = name.substring(boundFunctionPrefix.length);
- // Call bind() just to alter the function name.
- bindCall = '.bind(null)';
- } while (name && name.startsWith(boundFunctionPrefix));
- }
- // Special case functions named `mockConstructor` to guard for infinite
- // loops.
- if (name === MOCK_CONSTRUCTOR_NAME) {
- return mockConstructor;
- }
- // It's a syntax error to define functions with a reserved keyword
- // as name.
- if (RESERVED_KEYWORDS[name]) {
- name = '$' + name;
- }
- // It's also a syntax error to define a function with a reserved character
- // as part of it's name.
- if (FUNCTION_NAME_RESERVED_PATTERN.test(name)) {
- name = name.replace(FUNCTION_NAME_RESERVED_REPLACE, '$');
- }
- var body = 'return function ' + name + '() {' + 'return ' + MOCK_CONSTRUCTOR_NAME + '.apply(this,arguments);' + '}' + bindCall;
- var createConstructor = new this._environmentGlobal.Function(MOCK_CONSTRUCTOR_NAME, body);
- return createConstructor(mockConstructor);
- }
- }, {
- key: '_generateMock',
- value: function _generateMock(metadata, callbacks, refs) {
- var _this3 = this;
- var mock = this._makeComponent(metadata);
- if (metadata.refID != null) {
- refs[metadata.refID] = mock;
- }
- getSlots(metadata.members).forEach(function (slot) {
- var slotMetadata = metadata.members && metadata.members[slot] || {};
- if (slotMetadata.ref != null) {
- callbacks.push(function () {
- return mock[slot] = refs[slotMetadata.ref];
- });
- } else {
- mock[slot] = _this3._generateMock(slotMetadata, callbacks, refs);
- }
- });
- if (metadata.type !== 'undefined' && metadata.type !== 'null' && mock.prototype) {
- mock.prototype.constructor = mock;
- }
- return mock;
- }
- /**
- * @see README.md
- * @param metadata Metadata for the mock in the schema returned by the
- * getMetadata method of this module.
- */
- }, {
- key: 'generateFromMetadata',
- value: function generateFromMetadata(_metadata) {
- var callbacks = [];
- var refs = {};
- var mock = this._generateMock(_metadata, callbacks, refs);
- callbacks.forEach(function (setter) {
- return setter();
- });
- return mock;
- }
- /**
- * @see README.md
- * @param component The component for which to retrieve metadata.
- */
- }, {
- key: 'getMetadata',
- value: function getMetadata(component, _refs) {
- var _this4 = this;
- var refs = _refs || new _Map();
- var ref = refs.get(component);
- if (ref != null) {
- return { ref: ref };
- }
- var type = getType(component);
- if (!type) {
- return null;
- }
- var metadata = { type: type };
- if (type === 'constant' || type === 'collection' || type === 'undefined' || type === 'null') {
- metadata.value = component;
- return metadata;
- } else if (type === 'function') {
- metadata.name = component.name;
- if (component._isMockFunction) {
- metadata.mockImpl = component.getMockImplementation();
- }
- }
- metadata.refID = refs.size;
- refs.set(component, metadata.refID);
- var members = null;
- // Leave arrays alone
- if (type !== 'array') {
- if (type !== 'undefined') {
- getSlots(component).forEach(function (slot) {
- if (type === 'function' && component._isMockFunction && slot.match(/^mock/)) {
- return;
- }
- if (!component.hasOwnProperty && component[slot] !== undefined || component.hasOwnProperty && component.hasOwnProperty(slot) || type === 'object' && component[slot] != Object.prototype[slot]) {
- var slotMetadata = _this4.getMetadata(component[slot], refs);
- if (slotMetadata) {
- if (!members) {
- members = {};
- }
- members[slot] = slotMetadata;
- }
- }
- });
- }
- // If component is native code function, prototype might be undefined
- if (type === 'function' && component.prototype) {
- var prototype = this.getMetadata(component.prototype, refs);
- if (prototype && prototype.members) {
- if (!members) {
- members = {};
- }
- members.prototype = prototype;
- }
- }
- }
- if (members) {
- metadata.members = members;
- }
- return metadata;
- }
- }, {
- key: 'isMockFunction',
- value: function isMockFunction(fn) {
- return !!(fn && fn._isMockFunction);
- }
- }, {
- key: 'fn',
- value: function fn(implementation) {
- var length = implementation ? implementation.length : 0;
- var fn = this._makeComponent({ length: length, type: 'function' });
- if (implementation) {
- fn.mockImplementation(implementation);
- }
- return fn;
- }
- }, {
- key: 'spyOn',
- value: function spyOn(object, methodName, accessType) {
- if (accessType) {
- return this._spyOnProperty(object, methodName, accessType);
- }
- if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object' && typeof object !== 'function') {
- throw new Error('Cannot spyOn on a primitive value; ' + this._typeOf(object) + ' given');
- }
- var original = object[methodName];
- if (!this.isMockFunction(original)) {
- if (typeof original !== 'function') {
- throw new Error('Cannot spy the ' + methodName + ' property because it is not a function; ' + this._typeOf(original) + ' given instead');
- }
- object[methodName] = this._makeComponent({ type: 'function' }, function () {
- object[methodName] = original;
- });
- object[methodName].mockImplementation(function () {
- return original.apply(this, arguments);
- });
- }
- return object[methodName];
- }
- }, {
- key: '_spyOnProperty',
- value: function _spyOnProperty(obj, propertyName) {
- var accessType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get';
- if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' && typeof obj !== 'function') {
- throw new Error('Cannot spyOn on a primitive value; ' + this._typeOf(obj) + ' given');
- }
- if (!obj) {
- throw new Error('spyOn could not find an object to spy upon for ' + propertyName + '');
- }
- if (!propertyName) {
- throw new Error('No property name supplied');
- }
- var descriptor = _Object$getOwnPropertyDescriptor(obj, propertyName);
- var proto = _Object$getPrototypeOf(obj);
- while (!descriptor && proto !== null) {
- descriptor = _Object$getOwnPropertyDescriptor(proto, propertyName);
- proto = _Object$getPrototypeOf(proto);
- }
- if (!descriptor) {
- throw new Error(propertyName + ' property does not exist');
- }
- if (!descriptor.configurable) {
- throw new Error(propertyName + ' is not declared configurable');
- }
- if (!descriptor[accessType]) {
- throw new Error('Property ' + propertyName + ' does not have access type ' + accessType);
- }
- var original = descriptor[accessType];
- if (!this.isMockFunction(original)) {
- if (typeof original !== 'function') {
- throw new Error('Cannot spy the ' + propertyName + ' property because it is not a function; ' + this._typeOf(original) + ' given instead');
- }
- descriptor[accessType] = this._makeComponent({ type: 'function' }, function () {
- // $FlowFixMe
- descriptor[accessType] = original;
- // $FlowFixMe
- _Object$defineProperty(obj, propertyName, descriptor);
- });
- descriptor[accessType].mockImplementation(function () {
- return original.apply(this, arguments);
- });
- }
- _Object$defineProperty(obj, propertyName, descriptor);
- return descriptor[accessType];
- }
- }, {
- key: 'clearAllMocks',
- value: function clearAllMocks() {
- this._mockState = new _WeakMap();
- }
- }, {
- key: 'resetAllMocks',
- value: function resetAllMocks() {
- this._mockConfigRegistry = new _WeakMap();
- this._mockState = new _WeakMap();
- }
- }, {
- key: 'restoreAllMocks',
- value: function restoreAllMocks() {
- this._spyState.forEach(function (restore) {
- return restore();
- });
- this._spyState = new _Set();
- }
- }, {
- key: '_typeOf',
- value: function _typeOf(value) {
- return value == null ? '' + value : typeof value === 'undefined' ? 'undefined' : _typeof(value);
- }
- }]);
- return ModuleMockerClass;
- }();
- module.exports = new ModuleMockerClass(commonjsGlobal);
- });
- var index = unwrapExports(src);
- return index;
- })));
|