mocha.js (903853B)
1 (function (global, factory) { 2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 3 typeof define === 'function' && define.amd ? define(factory) : 4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mocha = factory()); 5 }(this, (function () { 'use strict'; 6 7 var regeneratorRuntime; 8 9 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 10 11 function createCommonjsModule(fn, basedir, module) { 12 return module = { 13 path: basedir, 14 exports: {}, 15 require: function (path, base) { 16 return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); 17 } 18 }, fn(module, module.exports), module.exports; 19 } 20 21 function getCjsExportFromNamespace (n) { 22 return n && n['default'] || n; 23 } 24 25 function commonjsRequire () { 26 throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); 27 } 28 29 var check = function (it) { 30 return it && it.Math == Math && it; 31 }; 32 33 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 34 var global_1 = 35 // eslint-disable-next-line no-undef 36 check(typeof globalThis == 'object' && globalThis) || 37 check(typeof window == 'object' && window) || 38 check(typeof self == 'object' && self) || 39 check(typeof commonjsGlobal == 'object' && commonjsGlobal) || 40 // eslint-disable-next-line no-new-func 41 (function () { return this; })() || Function('return this')(); 42 43 var fails = function (exec) { 44 try { 45 return !!exec(); 46 } catch (error) { 47 return true; 48 } 49 }; 50 51 // Detect IE8's incomplete defineProperty implementation 52 var descriptors = !fails(function () { 53 return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; 54 }); 55 56 var nativePropertyIsEnumerable = {}.propertyIsEnumerable; 57 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 58 59 // Nashorn ~ JDK8 bug 60 var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1); 61 62 // `Object.prototype.propertyIsEnumerable` method implementation 63 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 64 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 65 var descriptor = getOwnPropertyDescriptor(this, V); 66 return !!descriptor && descriptor.enumerable; 67 } : nativePropertyIsEnumerable; 68 69 var objectPropertyIsEnumerable = { 70 f: f 71 }; 72 73 var createPropertyDescriptor = function (bitmap, value) { 74 return { 75 enumerable: !(bitmap & 1), 76 configurable: !(bitmap & 2), 77 writable: !(bitmap & 4), 78 value: value 79 }; 80 }; 81 82 var toString = {}.toString; 83 84 var classofRaw = function (it) { 85 return toString.call(it).slice(8, -1); 86 }; 87 88 var split = ''.split; 89 90 // fallback for non-array-like ES3 and non-enumerable old V8 strings 91 var indexedObject = fails(function () { 92 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 93 // eslint-disable-next-line no-prototype-builtins 94 return !Object('z').propertyIsEnumerable(0); 95 }) ? function (it) { 96 return classofRaw(it) == 'String' ? split.call(it, '') : Object(it); 97 } : Object; 98 99 // `RequireObjectCoercible` abstract operation 100 // https://tc39.es/ecma262/#sec-requireobjectcoercible 101 var requireObjectCoercible = function (it) { 102 if (it == undefined) throw TypeError("Can't call method on " + it); 103 return it; 104 }; 105 106 // toObject with fallback for non-array-like ES3 strings 107 108 109 110 var toIndexedObject = function (it) { 111 return indexedObject(requireObjectCoercible(it)); 112 }; 113 114 var isObject = function (it) { 115 return typeof it === 'object' ? it !== null : typeof it === 'function'; 116 }; 117 118 // `ToPrimitive` abstract operation 119 // https://tc39.es/ecma262/#sec-toprimitive 120 // instead of the ES6 spec version, we didn't implement @@toPrimitive case 121 // and the second argument - flag - preferred type is a string 122 var toPrimitive = function (input, PREFERRED_STRING) { 123 if (!isObject(input)) return input; 124 var fn, val; 125 if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; 126 if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val; 127 if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; 128 throw TypeError("Can't convert object to primitive value"); 129 }; 130 131 var hasOwnProperty = {}.hasOwnProperty; 132 133 var has = function (it, key) { 134 return hasOwnProperty.call(it, key); 135 }; 136 137 var document$1 = global_1.document; 138 // typeof document.createElement is 'object' in old IE 139 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 140 141 var documentCreateElement = function (it) { 142 return EXISTS ? document$1.createElement(it) : {}; 143 }; 144 145 // Thank's IE8 for his funny defineProperty 146 var ie8DomDefine = !descriptors && !fails(function () { 147 return Object.defineProperty(documentCreateElement('div'), 'a', { 148 get: function () { return 7; } 149 }).a != 7; 150 }); 151 152 var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 153 154 // `Object.getOwnPropertyDescriptor` method 155 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 156 var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 157 O = toIndexedObject(O); 158 P = toPrimitive(P, true); 159 if (ie8DomDefine) try { 160 return nativeGetOwnPropertyDescriptor(O, P); 161 } catch (error) { /* empty */ } 162 if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]); 163 }; 164 165 var objectGetOwnPropertyDescriptor = { 166 f: f$1 167 }; 168 169 var anObject = function (it) { 170 if (!isObject(it)) { 171 throw TypeError(String(it) + ' is not an object'); 172 } return it; 173 }; 174 175 var nativeDefineProperty = Object.defineProperty; 176 177 // `Object.defineProperty` method 178 // https://tc39.es/ecma262/#sec-object.defineproperty 179 var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) { 180 anObject(O); 181 P = toPrimitive(P, true); 182 anObject(Attributes); 183 if (ie8DomDefine) try { 184 return nativeDefineProperty(O, P, Attributes); 185 } catch (error) { /* empty */ } 186 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); 187 if ('value' in Attributes) O[P] = Attributes.value; 188 return O; 189 }; 190 191 var objectDefineProperty = { 192 f: f$2 193 }; 194 195 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 196 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 197 } : function (object, key, value) { 198 object[key] = value; 199 return object; 200 }; 201 202 var setGlobal = function (key, value) { 203 try { 204 createNonEnumerableProperty(global_1, key, value); 205 } catch (error) { 206 global_1[key] = value; 207 } return value; 208 }; 209 210 var SHARED = '__core-js_shared__'; 211 var store = global_1[SHARED] || setGlobal(SHARED, {}); 212 213 var sharedStore = store; 214 215 var functionToString = Function.toString; 216 217 // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper 218 if (typeof sharedStore.inspectSource != 'function') { 219 sharedStore.inspectSource = function (it) { 220 return functionToString.call(it); 221 }; 222 } 223 224 var inspectSource = sharedStore.inspectSource; 225 226 var WeakMap = global_1.WeakMap; 227 228 var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap)); 229 230 var shared = createCommonjsModule(function (module) { 231 (module.exports = function (key, value) { 232 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 233 })('versions', []).push({ 234 version: '3.8.3', 235 mode: 'global', 236 copyright: '© 2021 Denis Pushkarev (zloirock.ru)' 237 }); 238 }); 239 240 var id = 0; 241 var postfix = Math.random(); 242 243 var uid = function (key) { 244 return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36); 245 }; 246 247 var keys = shared('keys'); 248 249 var sharedKey = function (key) { 250 return keys[key] || (keys[key] = uid(key)); 251 }; 252 253 var hiddenKeys = {}; 254 255 var WeakMap$1 = global_1.WeakMap; 256 var set, get, has$1; 257 258 var enforce = function (it) { 259 return has$1(it) ? get(it) : set(it, {}); 260 }; 261 262 var getterFor = function (TYPE) { 263 return function (it) { 264 var state; 265 if (!isObject(it) || (state = get(it)).type !== TYPE) { 266 throw TypeError('Incompatible receiver, ' + TYPE + ' required'); 267 } return state; 268 }; 269 }; 270 271 if (nativeWeakMap) { 272 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 273 var wmget = store$1.get; 274 var wmhas = store$1.has; 275 var wmset = store$1.set; 276 set = function (it, metadata) { 277 metadata.facade = it; 278 wmset.call(store$1, it, metadata); 279 return metadata; 280 }; 281 get = function (it) { 282 return wmget.call(store$1, it) || {}; 283 }; 284 has$1 = function (it) { 285 return wmhas.call(store$1, it); 286 }; 287 } else { 288 var STATE = sharedKey('state'); 289 hiddenKeys[STATE] = true; 290 set = function (it, metadata) { 291 metadata.facade = it; 292 createNonEnumerableProperty(it, STATE, metadata); 293 return metadata; 294 }; 295 get = function (it) { 296 return has(it, STATE) ? it[STATE] : {}; 297 }; 298 has$1 = function (it) { 299 return has(it, STATE); 300 }; 301 } 302 303 var internalState = { 304 set: set, 305 get: get, 306 has: has$1, 307 enforce: enforce, 308 getterFor: getterFor 309 }; 310 311 var redefine = createCommonjsModule(function (module) { 312 var getInternalState = internalState.get; 313 var enforceInternalState = internalState.enforce; 314 var TEMPLATE = String(String).split('String'); 315 316 (module.exports = function (O, key, value, options) { 317 var unsafe = options ? !!options.unsafe : false; 318 var simple = options ? !!options.enumerable : false; 319 var noTargetGet = options ? !!options.noTargetGet : false; 320 var state; 321 if (typeof value == 'function') { 322 if (typeof key == 'string' && !has(value, 'name')) { 323 createNonEnumerableProperty(value, 'name', key); 324 } 325 state = enforceInternalState(value); 326 if (!state.source) { 327 state.source = TEMPLATE.join(typeof key == 'string' ? key : ''); 328 } 329 } 330 if (O === global_1) { 331 if (simple) O[key] = value; 332 else setGlobal(key, value); 333 return; 334 } else if (!unsafe) { 335 delete O[key]; 336 } else if (!noTargetGet && O[key]) { 337 simple = true; 338 } 339 if (simple) O[key] = value; 340 else createNonEnumerableProperty(O, key, value); 341 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 342 })(Function.prototype, 'toString', function toString() { 343 return typeof this == 'function' && getInternalState(this).source || inspectSource(this); 344 }); 345 }); 346 347 var path = global_1; 348 349 var aFunction = function (variable) { 350 return typeof variable == 'function' ? variable : undefined; 351 }; 352 353 var getBuiltIn = function (namespace, method) { 354 return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace]) 355 : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method]; 356 }; 357 358 var ceil = Math.ceil; 359 var floor = Math.floor; 360 361 // `ToInteger` abstract operation 362 // https://tc39.es/ecma262/#sec-tointeger 363 var toInteger = function (argument) { 364 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument); 365 }; 366 367 var min = Math.min; 368 369 // `ToLength` abstract operation 370 // https://tc39.es/ecma262/#sec-tolength 371 var toLength = function (argument) { 372 return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 373 }; 374 375 var max = Math.max; 376 var min$1 = Math.min; 377 378 // Helper for a popular repeating case of the spec: 379 // Let integer be ? ToInteger(index). 380 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 381 var toAbsoluteIndex = function (index, length) { 382 var integer = toInteger(index); 383 return integer < 0 ? max(integer + length, 0) : min$1(integer, length); 384 }; 385 386 // `Array.prototype.{ indexOf, includes }` methods implementation 387 var createMethod = function (IS_INCLUDES) { 388 return function ($this, el, fromIndex) { 389 var O = toIndexedObject($this); 390 var length = toLength(O.length); 391 var index = toAbsoluteIndex(fromIndex, length); 392 var value; 393 // Array#includes uses SameValueZero equality algorithm 394 // eslint-disable-next-line no-self-compare 395 if (IS_INCLUDES && el != el) while (length > index) { 396 value = O[index++]; 397 // eslint-disable-next-line no-self-compare 398 if (value != value) return true; 399 // Array#indexOf ignores holes, Array#includes - not 400 } else for (;length > index; index++) { 401 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 402 } return !IS_INCLUDES && -1; 403 }; 404 }; 405 406 var arrayIncludes = { 407 // `Array.prototype.includes` method 408 // https://tc39.es/ecma262/#sec-array.prototype.includes 409 includes: createMethod(true), 410 // `Array.prototype.indexOf` method 411 // https://tc39.es/ecma262/#sec-array.prototype.indexof 412 indexOf: createMethod(false) 413 }; 414 415 var indexOf = arrayIncludes.indexOf; 416 417 418 var objectKeysInternal = function (object, names) { 419 var O = toIndexedObject(object); 420 var i = 0; 421 var result = []; 422 var key; 423 for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key); 424 // Don't enum bug & hidden keys 425 while (names.length > i) if (has(O, key = names[i++])) { 426 ~indexOf(result, key) || result.push(key); 427 } 428 return result; 429 }; 430 431 // IE8- don't enum bug keys 432 var enumBugKeys = [ 433 'constructor', 434 'hasOwnProperty', 435 'isPrototypeOf', 436 'propertyIsEnumerable', 437 'toLocaleString', 438 'toString', 439 'valueOf' 440 ]; 441 442 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); 443 444 // `Object.getOwnPropertyNames` method 445 // https://tc39.es/ecma262/#sec-object.getownpropertynames 446 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 447 return objectKeysInternal(O, hiddenKeys$1); 448 }; 449 450 var objectGetOwnPropertyNames = { 451 f: f$3 452 }; 453 454 var f$4 = Object.getOwnPropertySymbols; 455 456 var objectGetOwnPropertySymbols = { 457 f: f$4 458 }; 459 460 // all object keys, includes non-enumerable and symbols 461 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 462 var keys = objectGetOwnPropertyNames.f(anObject(it)); 463 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 464 return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys; 465 }; 466 467 var copyConstructorProperties = function (target, source) { 468 var keys = ownKeys(source); 469 var defineProperty = objectDefineProperty.f; 470 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 471 for (var i = 0; i < keys.length; i++) { 472 var key = keys[i]; 473 if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 474 } 475 }; 476 477 var replacement = /#|\.prototype\./; 478 479 var isForced = function (feature, detection) { 480 var value = data[normalize(feature)]; 481 return value == POLYFILL ? true 482 : value == NATIVE ? false 483 : typeof detection == 'function' ? fails(detection) 484 : !!detection; 485 }; 486 487 var normalize = isForced.normalize = function (string) { 488 return String(string).replace(replacement, '.').toLowerCase(); 489 }; 490 491 var data = isForced.data = {}; 492 var NATIVE = isForced.NATIVE = 'N'; 493 var POLYFILL = isForced.POLYFILL = 'P'; 494 495 var isForced_1 = isForced; 496 497 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 498 499 500 501 502 503 504 /* 505 options.target - name of the target object 506 options.global - target is the global object 507 options.stat - export as static methods of target 508 options.proto - export as prototype methods of target 509 options.real - real prototype method for the `pure` version 510 options.forced - export even if the native feature is available 511 options.bind - bind methods to the target, required for the `pure` version 512 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 513 options.unsafe - use the simple assignment of property instead of delete + defineProperty 514 options.sham - add a flag to not completely full polyfills 515 options.enumerable - export as enumerable property 516 options.noTargetGet - prevent calling a getter on target 517 */ 518 var _export = function (options, source) { 519 var TARGET = options.target; 520 var GLOBAL = options.global; 521 var STATIC = options.stat; 522 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 523 if (GLOBAL) { 524 target = global_1; 525 } else if (STATIC) { 526 target = global_1[TARGET] || setGlobal(TARGET, {}); 527 } else { 528 target = (global_1[TARGET] || {}).prototype; 529 } 530 if (target) for (key in source) { 531 sourceProperty = source[key]; 532 if (options.noTargetGet) { 533 descriptor = getOwnPropertyDescriptor$1(target, key); 534 targetProperty = descriptor && descriptor.value; 535 } else targetProperty = target[key]; 536 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); 537 // contained in target 538 if (!FORCED && targetProperty !== undefined) { 539 if (typeof sourceProperty === typeof targetProperty) continue; 540 copyConstructorProperties(sourceProperty, targetProperty); 541 } 542 // add a flag to not completely full polyfills 543 if (options.sham || (targetProperty && targetProperty.sham)) { 544 createNonEnumerableProperty(sourceProperty, 'sham', true); 545 } 546 // extend global 547 redefine(target, key, sourceProperty, options); 548 } 549 }; 550 551 var aFunction$1 = function (it) { 552 if (typeof it != 'function') { 553 throw TypeError(String(it) + ' is not a function'); 554 } return it; 555 }; 556 557 // optional / simple context binding 558 var functionBindContext = function (fn, that, length) { 559 aFunction$1(fn); 560 if (that === undefined) return fn; 561 switch (length) { 562 case 0: return function () { 563 return fn.call(that); 564 }; 565 case 1: return function (a) { 566 return fn.call(that, a); 567 }; 568 case 2: return function (a, b) { 569 return fn.call(that, a, b); 570 }; 571 case 3: return function (a, b, c) { 572 return fn.call(that, a, b, c); 573 }; 574 } 575 return function (/* ...args */) { 576 return fn.apply(that, arguments); 577 }; 578 }; 579 580 // `ToObject` abstract operation 581 // https://tc39.es/ecma262/#sec-toobject 582 var toObject = function (argument) { 583 return Object(requireObjectCoercible(argument)); 584 }; 585 586 // `IsArray` abstract operation 587 // https://tc39.es/ecma262/#sec-isarray 588 var isArray = Array.isArray || function isArray(arg) { 589 return classofRaw(arg) == 'Array'; 590 }; 591 592 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 593 // Chrome 38 Symbol has incorrect toString conversion 594 // eslint-disable-next-line no-undef 595 return !String(Symbol()); 596 }); 597 598 var useSymbolAsUid = nativeSymbol 599 // eslint-disable-next-line no-undef 600 && !Symbol.sham 601 // eslint-disable-next-line no-undef 602 && typeof Symbol.iterator == 'symbol'; 603 604 var WellKnownSymbolsStore = shared('wks'); 605 var Symbol$1 = global_1.Symbol; 606 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 607 608 var wellKnownSymbol = function (name) { 609 if (!has(WellKnownSymbolsStore, name)) { 610 if (nativeSymbol && has(Symbol$1, name)) WellKnownSymbolsStore[name] = Symbol$1[name]; 611 else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name); 612 } return WellKnownSymbolsStore[name]; 613 }; 614 615 var SPECIES = wellKnownSymbol('species'); 616 617 // `ArraySpeciesCreate` abstract operation 618 // https://tc39.es/ecma262/#sec-arrayspeciescreate 619 var arraySpeciesCreate = function (originalArray, length) { 620 var C; 621 if (isArray(originalArray)) { 622 C = originalArray.constructor; 623 // cross-realm fallback 624 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; 625 else if (isObject(C)) { 626 C = C[SPECIES]; 627 if (C === null) C = undefined; 628 } 629 } return new (C === undefined ? Array : C)(length === 0 ? 0 : length); 630 }; 631 632 var push = [].push; 633 634 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterOut }` methods implementation 635 var createMethod$1 = function (TYPE) { 636 var IS_MAP = TYPE == 1; 637 var IS_FILTER = TYPE == 2; 638 var IS_SOME = TYPE == 3; 639 var IS_EVERY = TYPE == 4; 640 var IS_FIND_INDEX = TYPE == 6; 641 var IS_FILTER_OUT = TYPE == 7; 642 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 643 return function ($this, callbackfn, that, specificCreate) { 644 var O = toObject($this); 645 var self = indexedObject(O); 646 var boundFunction = functionBindContext(callbackfn, that, 3); 647 var length = toLength(self.length); 648 var index = 0; 649 var create = specificCreate || arraySpeciesCreate; 650 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_OUT ? create($this, 0) : undefined; 651 var value, result; 652 for (;length > index; index++) if (NO_HOLES || index in self) { 653 value = self[index]; 654 result = boundFunction(value, index, O); 655 if (TYPE) { 656 if (IS_MAP) target[index] = result; // map 657 else if (result) switch (TYPE) { 658 case 3: return true; // some 659 case 5: return value; // find 660 case 6: return index; // findIndex 661 case 2: push.call(target, value); // filter 662 } else switch (TYPE) { 663 case 4: return false; // every 664 case 7: push.call(target, value); // filterOut 665 } 666 } 667 } 668 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 669 }; 670 }; 671 672 var arrayIteration = { 673 // `Array.prototype.forEach` method 674 // https://tc39.es/ecma262/#sec-array.prototype.foreach 675 forEach: createMethod$1(0), 676 // `Array.prototype.map` method 677 // https://tc39.es/ecma262/#sec-array.prototype.map 678 map: createMethod$1(1), 679 // `Array.prototype.filter` method 680 // https://tc39.es/ecma262/#sec-array.prototype.filter 681 filter: createMethod$1(2), 682 // `Array.prototype.some` method 683 // https://tc39.es/ecma262/#sec-array.prototype.some 684 some: createMethod$1(3), 685 // `Array.prototype.every` method 686 // https://tc39.es/ecma262/#sec-array.prototype.every 687 every: createMethod$1(4), 688 // `Array.prototype.find` method 689 // https://tc39.es/ecma262/#sec-array.prototype.find 690 find: createMethod$1(5), 691 // `Array.prototype.findIndex` method 692 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 693 findIndex: createMethod$1(6), 694 // `Array.prototype.filterOut` method 695 // https://github.com/tc39/proposal-array-filtering 696 filterOut: createMethod$1(7) 697 }; 698 699 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 700 701 var process = global_1.process; 702 var versions = process && process.versions; 703 var v8 = versions && versions.v8; 704 var match, version; 705 706 if (v8) { 707 match = v8.split('.'); 708 version = match[0] + match[1]; 709 } else if (engineUserAgent) { 710 match = engineUserAgent.match(/Edge\/(\d+)/); 711 if (!match || match[1] >= 74) { 712 match = engineUserAgent.match(/Chrome\/(\d+)/); 713 if (match) version = match[1]; 714 } 715 } 716 717 var engineV8Version = version && +version; 718 719 var SPECIES$1 = wellKnownSymbol('species'); 720 721 var arrayMethodHasSpeciesSupport = function (METHOD_NAME) { 722 // We can't use this feature detection in V8 since it causes 723 // deoptimization and serious performance degradation 724 // https://github.com/zloirock/core-js/issues/677 725 return engineV8Version >= 51 || !fails(function () { 726 var array = []; 727 var constructor = array.constructor = {}; 728 constructor[SPECIES$1] = function () { 729 return { foo: 1 }; 730 }; 731 return array[METHOD_NAME](Boolean).foo !== 1; 732 }); 733 }; 734 735 var defineProperty = Object.defineProperty; 736 var cache = {}; 737 738 var thrower = function (it) { throw it; }; 739 740 var arrayMethodUsesToLength = function (METHOD_NAME, options) { 741 if (has(cache, METHOD_NAME)) return cache[METHOD_NAME]; 742 if (!options) options = {}; 743 var method = [][METHOD_NAME]; 744 var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false; 745 var argument0 = has(options, 0) ? options[0] : thrower; 746 var argument1 = has(options, 1) ? options[1] : undefined; 747 748 return cache[METHOD_NAME] = !!method && !fails(function () { 749 if (ACCESSORS && !descriptors) return true; 750 var O = { length: -1 }; 751 752 if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower }); 753 else O[1] = 1; 754 755 method.call(O, argument0, argument1); 756 }); 757 }; 758 759 var $filter = arrayIteration.filter; 760 761 762 763 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter'); 764 // Edge 14- issue 765 var USES_TO_LENGTH = arrayMethodUsesToLength('filter'); 766 767 // `Array.prototype.filter` method 768 // https://tc39.es/ecma262/#sec-array.prototype.filter 769 // with adding support of @@species 770 _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, { 771 filter: function filter(callbackfn /* , thisArg */) { 772 return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 773 } 774 }); 775 776 var createProperty = function (object, key, value) { 777 var propertyKey = toPrimitive(key); 778 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value)); 779 else object[propertyKey] = value; 780 }; 781 782 var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('splice'); 783 var USES_TO_LENGTH$1 = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 }); 784 785 var max$1 = Math.max; 786 var min$2 = Math.min; 787 var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; 788 var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; 789 790 // `Array.prototype.splice` method 791 // https://tc39.es/ecma262/#sec-array.prototype.splice 792 // with adding support of @@species 793 _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 || !USES_TO_LENGTH$1 }, { 794 splice: function splice(start, deleteCount /* , ...items */) { 795 var O = toObject(this); 796 var len = toLength(O.length); 797 var actualStart = toAbsoluteIndex(start, len); 798 var argumentsLength = arguments.length; 799 var insertCount, actualDeleteCount, A, k, from, to; 800 if (argumentsLength === 0) { 801 insertCount = actualDeleteCount = 0; 802 } else if (argumentsLength === 1) { 803 insertCount = 0; 804 actualDeleteCount = len - actualStart; 805 } else { 806 insertCount = argumentsLength - 2; 807 actualDeleteCount = min$2(max$1(toInteger(deleteCount), 0), len - actualStart); 808 } 809 if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) { 810 throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED); 811 } 812 A = arraySpeciesCreate(O, actualDeleteCount); 813 for (k = 0; k < actualDeleteCount; k++) { 814 from = actualStart + k; 815 if (from in O) createProperty(A, k, O[from]); 816 } 817 A.length = actualDeleteCount; 818 if (insertCount < actualDeleteCount) { 819 for (k = actualStart; k < len - actualDeleteCount; k++) { 820 from = k + actualDeleteCount; 821 to = k + insertCount; 822 if (from in O) O[to] = O[from]; 823 else delete O[to]; 824 } 825 for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1]; 826 } else if (insertCount > actualDeleteCount) { 827 for (k = len - actualDeleteCount; k > actualStart; k--) { 828 from = k + actualDeleteCount - 1; 829 to = k + insertCount - 1; 830 if (from in O) O[to] = O[from]; 831 else delete O[to]; 832 } 833 } 834 for (k = 0; k < insertCount; k++) { 835 O[k + actualStart] = arguments[k + 2]; 836 } 837 O.length = len - actualDeleteCount + insertCount; 838 return A; 839 } 840 }); 841 842 // `Object.keys` method 843 // https://tc39.es/ecma262/#sec-object.keys 844 var objectKeys = Object.keys || function keys(O) { 845 return objectKeysInternal(O, enumBugKeys); 846 }; 847 848 var nativeAssign = Object.assign; 849 var defineProperty$1 = Object.defineProperty; 850 851 // `Object.assign` method 852 // https://tc39.es/ecma262/#sec-object.assign 853 var objectAssign = !nativeAssign || fails(function () { 854 // should have correct order of operations (Edge bug) 855 if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty$1({}, 'a', { 856 enumerable: true, 857 get: function () { 858 defineProperty$1(this, 'b', { 859 value: 3, 860 enumerable: false 861 }); 862 } 863 }), { b: 2 })).b !== 1) return true; 864 // should work with symbols and should have deterministic property order (V8 bug) 865 var A = {}; 866 var B = {}; 867 // eslint-disable-next-line no-undef 868 var symbol = Symbol(); 869 var alphabet = 'abcdefghijklmnopqrst'; 870 A[symbol] = 7; 871 alphabet.split('').forEach(function (chr) { B[chr] = chr; }); 872 return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet; 873 }) ? function assign(target, source) { // eslint-disable-line no-unused-vars 874 var T = toObject(target); 875 var argumentsLength = arguments.length; 876 var index = 1; 877 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 878 var propertyIsEnumerable = objectPropertyIsEnumerable.f; 879 while (argumentsLength > index) { 880 var S = indexedObject(arguments[index++]); 881 var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S); 882 var length = keys.length; 883 var j = 0; 884 var key; 885 while (length > j) { 886 key = keys[j++]; 887 if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key]; 888 } 889 } return T; 890 } : nativeAssign; 891 892 // `Object.assign` method 893 // https://tc39.es/ecma262/#sec-object.assign 894 _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, { 895 assign: objectAssign 896 }); 897 898 var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); }); 899 900 // `Object.keys` method 901 // https://tc39.es/ecma262/#sec-object.keys 902 _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, { 903 keys: function keys(it) { 904 return objectKeys(toObject(it)); 905 } 906 }); 907 908 // `RegExp.prototype.flags` getter implementation 909 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 910 var regexpFlags = function () { 911 var that = anObject(this); 912 var result = ''; 913 if (that.global) result += 'g'; 914 if (that.ignoreCase) result += 'i'; 915 if (that.multiline) result += 'm'; 916 if (that.dotAll) result += 's'; 917 if (that.unicode) result += 'u'; 918 if (that.sticky) result += 'y'; 919 return result; 920 }; 921 922 // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError, 923 // so we use an intermediate function. 924 function RE(s, f) { 925 return RegExp(s, f); 926 } 927 928 var UNSUPPORTED_Y = fails(function () { 929 // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 930 var re = RE('a', 'y'); 931 re.lastIndex = 2; 932 return re.exec('abcd') != null; 933 }); 934 935 var BROKEN_CARET = fails(function () { 936 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 937 var re = RE('^r', 'gy'); 938 re.lastIndex = 2; 939 return re.exec('str') != null; 940 }); 941 942 var regexpStickyHelpers = { 943 UNSUPPORTED_Y: UNSUPPORTED_Y, 944 BROKEN_CARET: BROKEN_CARET 945 }; 946 947 var nativeExec = RegExp.prototype.exec; 948 // This always refers to the native implementation, because the 949 // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, 950 // which loads this file before patching the method. 951 var nativeReplace = String.prototype.replace; 952 953 var patchedExec = nativeExec; 954 955 var UPDATES_LAST_INDEX_WRONG = (function () { 956 var re1 = /a/; 957 var re2 = /b*/g; 958 nativeExec.call(re1, 'a'); 959 nativeExec.call(re2, 'a'); 960 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 961 })(); 962 963 var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y || regexpStickyHelpers.BROKEN_CARET; 964 965 // nonparticipating capturing group, copied from es5-shim's String#split patch. 966 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 967 968 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1; 969 970 if (PATCH) { 971 patchedExec = function exec(str) { 972 var re = this; 973 var lastIndex, reCopy, match, i; 974 var sticky = UNSUPPORTED_Y$1 && re.sticky; 975 var flags = regexpFlags.call(re); 976 var source = re.source; 977 var charsAdded = 0; 978 var strCopy = str; 979 980 if (sticky) { 981 flags = flags.replace('y', ''); 982 if (flags.indexOf('g') === -1) { 983 flags += 'g'; 984 } 985 986 strCopy = String(str).slice(re.lastIndex); 987 // Support anchored sticky behavior. 988 if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\n')) { 989 source = '(?: ' + source + ')'; 990 strCopy = ' ' + strCopy; 991 charsAdded++; 992 } 993 // ^(? + rx + ) is needed, in combination with some str slicing, to 994 // simulate the 'y' flag. 995 reCopy = new RegExp('^(?:' + source + ')', flags); 996 } 997 998 if (NPCG_INCLUDED) { 999 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 1000 } 1001 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 1002 1003 match = nativeExec.call(sticky ? reCopy : re, strCopy); 1004 1005 if (sticky) { 1006 if (match) { 1007 match.input = match.input.slice(charsAdded); 1008 match[0] = match[0].slice(charsAdded); 1009 match.index = re.lastIndex; 1010 re.lastIndex += match[0].length; 1011 } else re.lastIndex = 0; 1012 } else if (UPDATES_LAST_INDEX_WRONG && match) { 1013 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 1014 } 1015 if (NPCG_INCLUDED && match && match.length > 1) { 1016 // Fix browsers whose `exec` methods don't consistently return `undefined` 1017 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 1018 nativeReplace.call(match[0], reCopy, function () { 1019 for (i = 1; i < arguments.length - 2; i++) { 1020 if (arguments[i] === undefined) match[i] = undefined; 1021 } 1022 }); 1023 } 1024 1025 return match; 1026 }; 1027 } 1028 1029 var regexpExec = patchedExec; 1030 1031 // `RegExp.prototype.exec` method 1032 // https://tc39.es/ecma262/#sec-regexp.prototype.exec 1033 _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, { 1034 exec: regexpExec 1035 }); 1036 1037 // TODO: Remove from `core-js@4` since it's moved to entry points 1038 1039 1040 1041 1042 1043 1044 1045 var SPECIES$2 = wellKnownSymbol('species'); 1046 1047 var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () { 1048 // #replace needs built-in support for named groups. 1049 // #match works fine because it just return the exec results, even if it has 1050 // a "grops" property. 1051 var re = /./; 1052 re.exec = function () { 1053 var result = []; 1054 result.groups = { a: '7' }; 1055 return result; 1056 }; 1057 return ''.replace(re, '$<a>') !== '7'; 1058 }); 1059 1060 // IE <= 11 replaces $0 with the whole match, as if it was $& 1061 // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 1062 var REPLACE_KEEPS_$0 = (function () { 1063 return 'a'.replace(/./, '$0') === '$0'; 1064 })(); 1065 1066 var REPLACE = wellKnownSymbol('replace'); 1067 // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string 1068 var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { 1069 if (/./[REPLACE]) { 1070 return /./[REPLACE]('a', '$0') === ''; 1071 } 1072 return false; 1073 })(); 1074 1075 // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec 1076 // Weex JS has frozen built-in prototypes, so use try / catch wrapper 1077 var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () { 1078 var re = /(?:)/; 1079 var originalExec = re.exec; 1080 re.exec = function () { return originalExec.apply(this, arguments); }; 1081 var result = 'ab'.split(re); 1082 return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b'; 1083 }); 1084 1085 var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) { 1086 var SYMBOL = wellKnownSymbol(KEY); 1087 1088 var DELEGATES_TO_SYMBOL = !fails(function () { 1089 // String methods call symbol-named RegEp methods 1090 var O = {}; 1091 O[SYMBOL] = function () { return 7; }; 1092 return ''[KEY](O) != 7; 1093 }); 1094 1095 var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () { 1096 // Symbol-named RegExp methods call .exec 1097 var execCalled = false; 1098 var re = /a/; 1099 1100 if (KEY === 'split') { 1101 // We can't use real regex here since it causes deoptimization 1102 // and serious performance degradation in V8 1103 // https://github.com/zloirock/core-js/issues/306 1104 re = {}; 1105 // RegExp[@@split] doesn't call the regex's exec method, but first creates 1106 // a new one. We need to return the patched regex when creating the new one. 1107 re.constructor = {}; 1108 re.constructor[SPECIES$2] = function () { return re; }; 1109 re.flags = ''; 1110 re[SYMBOL] = /./[SYMBOL]; 1111 } 1112 1113 re.exec = function () { execCalled = true; return null; }; 1114 1115 re[SYMBOL](''); 1116 return !execCalled; 1117 }); 1118 1119 if ( 1120 !DELEGATES_TO_SYMBOL || 1121 !DELEGATES_TO_EXEC || 1122 (KEY === 'replace' && !( 1123 REPLACE_SUPPORTS_NAMED_GROUPS && 1124 REPLACE_KEEPS_$0 && 1125 !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE 1126 )) || 1127 (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) 1128 ) { 1129 var nativeRegExpMethod = /./[SYMBOL]; 1130 var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { 1131 if (regexp.exec === regexpExec) { 1132 if (DELEGATES_TO_SYMBOL && !forceStringMethod) { 1133 // The native String method already delegates to @@method (this 1134 // polyfilled function), leasing to infinite recursion. 1135 // We avoid it by directly calling the native @@method method. 1136 return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; 1137 } 1138 return { done: true, value: nativeMethod.call(str, regexp, arg2) }; 1139 } 1140 return { done: false }; 1141 }, { 1142 REPLACE_KEEPS_$0: REPLACE_KEEPS_$0, 1143 REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE 1144 }); 1145 var stringMethod = methods[0]; 1146 var regexMethod = methods[1]; 1147 1148 redefine(String.prototype, KEY, stringMethod); 1149 redefine(RegExp.prototype, SYMBOL, length == 2 1150 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) 1151 // 21.2.5.11 RegExp.prototype[@@split](string, limit) 1152 ? function (string, arg) { return regexMethod.call(string, this, arg); } 1153 // 21.2.5.6 RegExp.prototype[@@match](string) 1154 // 21.2.5.9 RegExp.prototype[@@search](string) 1155 : function (string) { return regexMethod.call(string, this); } 1156 ); 1157 } 1158 1159 if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true); 1160 }; 1161 1162 // `SameValue` abstract operation 1163 // https://tc39.es/ecma262/#sec-samevalue 1164 var sameValue = Object.is || function is(x, y) { 1165 // eslint-disable-next-line no-self-compare 1166 return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; 1167 }; 1168 1169 // `RegExpExec` abstract operation 1170 // https://tc39.es/ecma262/#sec-regexpexec 1171 var regexpExecAbstract = function (R, S) { 1172 var exec = R.exec; 1173 if (typeof exec === 'function') { 1174 var result = exec.call(R, S); 1175 if (typeof result !== 'object') { 1176 throw TypeError('RegExp exec method returned something other than an Object or null'); 1177 } 1178 return result; 1179 } 1180 1181 if (classofRaw(R) !== 'RegExp') { 1182 throw TypeError('RegExp#exec called on incompatible receiver'); 1183 } 1184 1185 return regexpExec.call(R, S); 1186 }; 1187 1188 // @@search logic 1189 fixRegexpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) { 1190 return [ 1191 // `String.prototype.search` method 1192 // https://tc39.es/ecma262/#sec-string.prototype.search 1193 function search(regexp) { 1194 var O = requireObjectCoercible(this); 1195 var searcher = regexp == undefined ? undefined : regexp[SEARCH]; 1196 return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); 1197 }, 1198 // `RegExp.prototype[@@search]` method 1199 // https://tc39.es/ecma262/#sec-regexp.prototype-@@search 1200 function (regexp) { 1201 var res = maybeCallNative(nativeSearch, regexp, this); 1202 if (res.done) return res.value; 1203 1204 var rx = anObject(regexp); 1205 var S = String(this); 1206 1207 var previousLastIndex = rx.lastIndex; 1208 if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0; 1209 var result = regexpExecAbstract(rx, S); 1210 if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex; 1211 return result === null ? -1 : result.index; 1212 } 1213 ]; 1214 }); 1215 1216 // iterable DOM collections 1217 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 1218 var domIterables = { 1219 CSSRuleList: 0, 1220 CSSStyleDeclaration: 0, 1221 CSSValueList: 0, 1222 ClientRectList: 0, 1223 DOMRectList: 0, 1224 DOMStringList: 0, 1225 DOMTokenList: 1, 1226 DataTransferItemList: 0, 1227 FileList: 0, 1228 HTMLAllCollection: 0, 1229 HTMLCollection: 0, 1230 HTMLFormElement: 0, 1231 HTMLSelectElement: 0, 1232 MediaList: 0, 1233 MimeTypeArray: 0, 1234 NamedNodeMap: 0, 1235 NodeList: 1, 1236 PaintRequestList: 0, 1237 Plugin: 0, 1238 PluginArray: 0, 1239 SVGLengthList: 0, 1240 SVGNumberList: 0, 1241 SVGPathSegList: 0, 1242 SVGPointList: 0, 1243 SVGStringList: 0, 1244 SVGTransformList: 0, 1245 SourceBufferList: 0, 1246 StyleSheetList: 0, 1247 TextTrackCueList: 0, 1248 TextTrackList: 0, 1249 TouchList: 0 1250 }; 1251 1252 var arrayMethodIsStrict = function (METHOD_NAME, argument) { 1253 var method = [][METHOD_NAME]; 1254 return !!method && fails(function () { 1255 // eslint-disable-next-line no-useless-call,no-throw-literal 1256 method.call(null, argument || function () { throw 1; }, 1); 1257 }); 1258 }; 1259 1260 var $forEach = arrayIteration.forEach; 1261 1262 1263 1264 var STRICT_METHOD = arrayMethodIsStrict('forEach'); 1265 var USES_TO_LENGTH$2 = arrayMethodUsesToLength('forEach'); 1266 1267 // `Array.prototype.forEach` method implementation 1268 // https://tc39.es/ecma262/#sec-array.prototype.foreach 1269 var arrayForEach = (!STRICT_METHOD || !USES_TO_LENGTH$2) ? function forEach(callbackfn /* , thisArg */) { 1270 return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 1271 } : [].forEach; 1272 1273 for (var COLLECTION_NAME in domIterables) { 1274 var Collection = global_1[COLLECTION_NAME]; 1275 var CollectionPrototype = Collection && Collection.prototype; 1276 // some Chrome versions have non-configurable methods on DOMTokenList 1277 if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try { 1278 createNonEnumerableProperty(CollectionPrototype, 'forEach', arrayForEach); 1279 } catch (error) { 1280 CollectionPrototype.forEach = arrayForEach; 1281 } 1282 } 1283 1284 var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable'); 1285 var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF; 1286 var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; 1287 1288 // We can't use this feature detection in V8 since it causes 1289 // deoptimization and serious performance degradation 1290 // https://github.com/zloirock/core-js/issues/679 1291 var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () { 1292 var array = []; 1293 array[IS_CONCAT_SPREADABLE] = false; 1294 return array.concat()[0] !== array; 1295 }); 1296 1297 var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat'); 1298 1299 var isConcatSpreadable = function (O) { 1300 if (!isObject(O)) return false; 1301 var spreadable = O[IS_CONCAT_SPREADABLE]; 1302 return spreadable !== undefined ? !!spreadable : isArray(O); 1303 }; 1304 1305 var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; 1306 1307 // `Array.prototype.concat` method 1308 // https://tc39.es/ecma262/#sec-array.prototype.concat 1309 // with adding support of @@isConcatSpreadable and @@species 1310 _export({ target: 'Array', proto: true, forced: FORCED }, { 1311 concat: function concat(arg) { // eslint-disable-line no-unused-vars 1312 var O = toObject(this); 1313 var A = arraySpeciesCreate(O, 0); 1314 var n = 0; 1315 var i, k, length, len, E; 1316 for (i = -1, length = arguments.length; i < length; i++) { 1317 E = i === -1 ? O : arguments[i]; 1318 if (isConcatSpreadable(E)) { 1319 len = toLength(E.length); 1320 if (n + len > MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); 1321 for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]); 1322 } else { 1323 if (n >= MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); 1324 createProperty(A, n++, E); 1325 } 1326 } 1327 A.length = n; 1328 return A; 1329 } 1330 }); 1331 1332 var global$1 = typeof global$2 !== "undefined" ? global$2 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}; 1333 1334 var global$2 = typeof global$1 !== "undefined" ? global$1 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}; 1335 1336 // based off https://github.com/defunctzombie/node-process/blob/master/browser.js 1337 1338 function defaultSetTimout() { 1339 throw new Error('setTimeout has not been defined'); 1340 } 1341 1342 function defaultClearTimeout() { 1343 throw new Error('clearTimeout has not been defined'); 1344 } 1345 1346 var cachedSetTimeout = defaultSetTimout; 1347 var cachedClearTimeout = defaultClearTimeout; 1348 1349 if (typeof global$2.setTimeout === 'function') { 1350 cachedSetTimeout = setTimeout; 1351 } 1352 1353 if (typeof global$2.clearTimeout === 'function') { 1354 cachedClearTimeout = clearTimeout; 1355 } 1356 1357 function runTimeout(fun) { 1358 if (cachedSetTimeout === setTimeout) { 1359 //normal enviroments in sane situations 1360 return setTimeout(fun, 0); 1361 } // if setTimeout wasn't available but was latter defined 1362 1363 1364 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 1365 cachedSetTimeout = setTimeout; 1366 return setTimeout(fun, 0); 1367 } 1368 1369 try { 1370 // when when somebody has screwed with setTimeout but no I.E. maddness 1371 return cachedSetTimeout(fun, 0); 1372 } catch (e) { 1373 try { 1374 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 1375 return cachedSetTimeout.call(null, fun, 0); 1376 } catch (e) { 1377 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 1378 return cachedSetTimeout.call(this, fun, 0); 1379 } 1380 } 1381 } 1382 1383 function runClearTimeout(marker) { 1384 if (cachedClearTimeout === clearTimeout) { 1385 //normal enviroments in sane situations 1386 return clearTimeout(marker); 1387 } // if clearTimeout wasn't available but was latter defined 1388 1389 1390 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 1391 cachedClearTimeout = clearTimeout; 1392 return clearTimeout(marker); 1393 } 1394 1395 try { 1396 // when when somebody has screwed with setTimeout but no I.E. maddness 1397 return cachedClearTimeout(marker); 1398 } catch (e) { 1399 try { 1400 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 1401 return cachedClearTimeout.call(null, marker); 1402 } catch (e) { 1403 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 1404 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 1405 return cachedClearTimeout.call(this, marker); 1406 } 1407 } 1408 } 1409 1410 var queue = []; 1411 var draining = false; 1412 var currentQueue; 1413 var queueIndex = -1; 1414 1415 function cleanUpNextTick() { 1416 if (!draining || !currentQueue) { 1417 return; 1418 } 1419 1420 draining = false; 1421 1422 if (currentQueue.length) { 1423 queue = currentQueue.concat(queue); 1424 } else { 1425 queueIndex = -1; 1426 } 1427 1428 if (queue.length) { 1429 drainQueue(); 1430 } 1431 } 1432 1433 function drainQueue() { 1434 if (draining) { 1435 return; 1436 } 1437 1438 var timeout = runTimeout(cleanUpNextTick); 1439 draining = true; 1440 var len = queue.length; 1441 1442 while (len) { 1443 currentQueue = queue; 1444 queue = []; 1445 1446 while (++queueIndex < len) { 1447 if (currentQueue) { 1448 currentQueue[queueIndex].run(); 1449 } 1450 } 1451 1452 queueIndex = -1; 1453 len = queue.length; 1454 } 1455 1456 currentQueue = null; 1457 draining = false; 1458 runClearTimeout(timeout); 1459 } 1460 1461 function nextTick(fun) { 1462 var args = new Array(arguments.length - 1); 1463 1464 if (arguments.length > 1) { 1465 for (var i = 1; i < arguments.length; i++) { 1466 args[i - 1] = arguments[i]; 1467 } 1468 } 1469 1470 queue.push(new Item(fun, args)); 1471 1472 if (queue.length === 1 && !draining) { 1473 runTimeout(drainQueue); 1474 } 1475 } // v8 likes predictible objects 1476 1477 function Item(fun, array) { 1478 this.fun = fun; 1479 this.array = array; 1480 } 1481 1482 Item.prototype.run = function () { 1483 this.fun.apply(null, this.array); 1484 }; 1485 1486 var title = 'browser'; 1487 var platform = 'browser'; 1488 var browser = true; 1489 var env = {}; 1490 var argv = []; 1491 var version$1 = ''; // empty string to avoid regexp issues 1492 1493 var versions$1 = {}; 1494 var release = {}; 1495 var config = {}; 1496 1497 function noop() {} 1498 1499 var on = noop; 1500 var addListener = noop; 1501 var once = noop; 1502 var off = noop; 1503 var removeListener = noop; 1504 var removeAllListeners = noop; 1505 var emit = noop; 1506 function binding(name) { 1507 throw new Error('process.binding is not supported'); 1508 } 1509 function cwd() { 1510 return '/'; 1511 } 1512 function chdir(dir) { 1513 throw new Error('process.chdir is not supported'); 1514 } 1515 function umask() { 1516 return 0; 1517 } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js 1518 1519 var performance = global$2.performance || {}; 1520 1521 var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () { 1522 return new Date().getTime(); 1523 }; // generate timestamp or delta 1524 // see http://nodejs.org/api/process.html#process_process_hrtime 1525 1526 1527 function hrtime(previousTimestamp) { 1528 var clocktime = performanceNow.call(performance) * 1e-3; 1529 var seconds = Math.floor(clocktime); 1530 var nanoseconds = Math.floor(clocktime % 1 * 1e9); 1531 1532 if (previousTimestamp) { 1533 seconds = seconds - previousTimestamp[0]; 1534 nanoseconds = nanoseconds - previousTimestamp[1]; 1535 1536 if (nanoseconds < 0) { 1537 seconds--; 1538 nanoseconds += 1e9; 1539 } 1540 } 1541 1542 return [seconds, nanoseconds]; 1543 } 1544 var startTime = new Date(); 1545 function uptime() { 1546 var currentTime = new Date(); 1547 var dif = currentTime - startTime; 1548 return dif / 1000; 1549 } 1550 var process$1 = { 1551 nextTick: nextTick, 1552 title: title, 1553 browser: browser, 1554 env: env, 1555 argv: argv, 1556 version: version$1, 1557 versions: versions$1, 1558 on: on, 1559 addListener: addListener, 1560 once: once, 1561 off: off, 1562 removeListener: removeListener, 1563 removeAllListeners: removeAllListeners, 1564 emit: emit, 1565 binding: binding, 1566 cwd: cwd, 1567 chdir: chdir, 1568 umask: umask, 1569 hrtime: hrtime, 1570 platform: platform, 1571 release: release, 1572 config: config, 1573 uptime: uptime 1574 }; 1575 1576 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 1577 var test = {}; 1578 1579 test[TO_STRING_TAG] = 'z'; 1580 1581 var toStringTagSupport = String(test) === '[object z]'; 1582 1583 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 1584 // ES3 wrong here 1585 var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; 1586 1587 // fallback for IE11 Script Access Denied error 1588 var tryGet = function (it, key) { 1589 try { 1590 return it[key]; 1591 } catch (error) { /* empty */ } 1592 }; 1593 1594 // getting tag from ES6+ `Object.prototype.toString` 1595 var classof = toStringTagSupport ? classofRaw : function (it) { 1596 var O, tag, result; 1597 return it === undefined ? 'Undefined' : it === null ? 'Null' 1598 // @@toStringTag case 1599 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$1)) == 'string' ? tag 1600 // builtinTag case 1601 : CORRECT_ARGUMENTS ? classofRaw(O) 1602 // ES3 arguments fallback 1603 : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result; 1604 }; 1605 1606 // `Object.prototype.toString` method implementation 1607 // https://tc39.es/ecma262/#sec-object.prototype.tostring 1608 var objectToString = toStringTagSupport ? {}.toString : function toString() { 1609 return '[object ' + classof(this) + ']'; 1610 }; 1611 1612 // `Object.prototype.toString` method 1613 // https://tc39.es/ecma262/#sec-object.prototype.tostring 1614 if (!toStringTagSupport) { 1615 redefine(Object.prototype, 'toString', objectToString, { unsafe: true }); 1616 } 1617 1618 var TO_STRING = 'toString'; 1619 var RegExpPrototype = RegExp.prototype; 1620 var nativeToString = RegExpPrototype[TO_STRING]; 1621 1622 var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; }); 1623 // FF44- RegExp#toString has a wrong name 1624 var INCORRECT_NAME = nativeToString.name != TO_STRING; 1625 1626 // `RegExp.prototype.toString` method 1627 // https://tc39.es/ecma262/#sec-regexp.prototype.tostring 1628 if (NOT_GENERIC || INCORRECT_NAME) { 1629 redefine(RegExp.prototype, TO_STRING, function toString() { 1630 var R = anObject(this); 1631 var p = String(R.source); 1632 var rf = R.flags; 1633 var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? regexpFlags.call(R) : rf); 1634 return '/' + p + '/' + f; 1635 }, { unsafe: true }); 1636 } 1637 1638 var defineProperty$2 = objectDefineProperty.f; 1639 1640 var FunctionPrototype = Function.prototype; 1641 var FunctionPrototypeToString = FunctionPrototype.toString; 1642 var nameRE = /^\s*function ([^ (]*)/; 1643 var NAME = 'name'; 1644 1645 // Function instances `.name` property 1646 // https://tc39.es/ecma262/#sec-function-instances-name 1647 if (descriptors && !(NAME in FunctionPrototype)) { 1648 defineProperty$2(FunctionPrototype, NAME, { 1649 configurable: true, 1650 get: function () { 1651 try { 1652 return FunctionPrototypeToString.call(this).match(nameRE)[1]; 1653 } catch (error) { 1654 return ''; 1655 } 1656 } 1657 }); 1658 } 1659 1660 var correctPrototypeGetter = !fails(function () { 1661 function F() { /* empty */ } 1662 F.prototype.constructor = null; 1663 return Object.getPrototypeOf(new F()) !== F.prototype; 1664 }); 1665 1666 var IE_PROTO = sharedKey('IE_PROTO'); 1667 var ObjectPrototype = Object.prototype; 1668 1669 // `Object.getPrototypeOf` method 1670 // https://tc39.es/ecma262/#sec-object.getprototypeof 1671 var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) { 1672 O = toObject(O); 1673 if (has(O, IE_PROTO)) return O[IE_PROTO]; 1674 if (typeof O.constructor == 'function' && O instanceof O.constructor) { 1675 return O.constructor.prototype; 1676 } return O instanceof Object ? ObjectPrototype : null; 1677 }; 1678 1679 var FAILS_ON_PRIMITIVES$1 = fails(function () { objectGetPrototypeOf(1); }); 1680 1681 // `Object.getPrototypeOf` method 1682 // https://tc39.es/ecma262/#sec-object.getprototypeof 1683 _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$1, sham: !correctPrototypeGetter }, { 1684 getPrototypeOf: function getPrototypeOf(it) { 1685 return objectGetPrototypeOf(toObject(it)); 1686 } 1687 }); 1688 1689 // `Reflect.ownKeys` method 1690 // https://tc39.es/ecma262/#sec-reflect.ownkeys 1691 _export({ target: 'Reflect', stat: true }, { 1692 ownKeys: ownKeys 1693 }); 1694 1695 var domain; // This constructor is used to store event handlers. Instantiating this is 1696 // faster than explicitly calling `Object.create(null)` to get a "clean" empty 1697 // object (tested with v8 v4.9). 1698 1699 function EventHandlers() {} 1700 1701 EventHandlers.prototype = Object.create(null); 1702 1703 function EventEmitter() { 1704 EventEmitter.init.call(this); 1705 } 1706 // require('events') === require('events').EventEmitter 1707 1708 EventEmitter.EventEmitter = EventEmitter; 1709 EventEmitter.usingDomains = false; 1710 EventEmitter.prototype.domain = undefined; 1711 EventEmitter.prototype._events = undefined; 1712 EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are 1713 // added to it. This is a useful default which helps finding memory leaks. 1714 1715 EventEmitter.defaultMaxListeners = 10; 1716 1717 EventEmitter.init = function () { 1718 this.domain = null; 1719 1720 if (EventEmitter.usingDomains) { 1721 // if there is an active domain, then attach to it. 1722 if (domain.active ) ; 1723 } 1724 1725 if (!this._events || this._events === Object.getPrototypeOf(this)._events) { 1726 this._events = new EventHandlers(); 1727 this._eventsCount = 0; 1728 } 1729 1730 this._maxListeners = this._maxListeners || undefined; 1731 }; // Obviously not all Emitters should be limited to 10. This function allows 1732 // that to be increased. Set to zero for unlimited. 1733 1734 1735 EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { 1736 if (typeof n !== 'number' || n < 0 || isNaN(n)) throw new TypeError('"n" argument must be a positive number'); 1737 this._maxListeners = n; 1738 return this; 1739 }; 1740 1741 function $getMaxListeners(that) { 1742 if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners; 1743 return that._maxListeners; 1744 } 1745 1746 EventEmitter.prototype.getMaxListeners = function getMaxListeners() { 1747 return $getMaxListeners(this); 1748 }; // These standalone emit* functions are used to optimize calling of event 1749 // handlers for fast cases because emit() itself often has a variable number of 1750 // arguments and can be deoptimized because of that. These functions always have 1751 // the same number of arguments and thus do not get deoptimized, so the code 1752 // inside them can execute faster. 1753 1754 1755 function emitNone(handler, isFn, self) { 1756 if (isFn) handler.call(self);else { 1757 var len = handler.length; 1758 var listeners = arrayClone(handler, len); 1759 1760 for (var i = 0; i < len; ++i) { 1761 listeners[i].call(self); 1762 } 1763 } 1764 } 1765 1766 function emitOne(handler, isFn, self, arg1) { 1767 if (isFn) handler.call(self, arg1);else { 1768 var len = handler.length; 1769 var listeners = arrayClone(handler, len); 1770 1771 for (var i = 0; i < len; ++i) { 1772 listeners[i].call(self, arg1); 1773 } 1774 } 1775 } 1776 1777 function emitTwo(handler, isFn, self, arg1, arg2) { 1778 if (isFn) handler.call(self, arg1, arg2);else { 1779 var len = handler.length; 1780 var listeners = arrayClone(handler, len); 1781 1782 for (var i = 0; i < len; ++i) { 1783 listeners[i].call(self, arg1, arg2); 1784 } 1785 } 1786 } 1787 1788 function emitThree(handler, isFn, self, arg1, arg2, arg3) { 1789 if (isFn) handler.call(self, arg1, arg2, arg3);else { 1790 var len = handler.length; 1791 var listeners = arrayClone(handler, len); 1792 1793 for (var i = 0; i < len; ++i) { 1794 listeners[i].call(self, arg1, arg2, arg3); 1795 } 1796 } 1797 } 1798 1799 function emitMany(handler, isFn, self, args) { 1800 if (isFn) handler.apply(self, args);else { 1801 var len = handler.length; 1802 var listeners = arrayClone(handler, len); 1803 1804 for (var i = 0; i < len; ++i) { 1805 listeners[i].apply(self, args); 1806 } 1807 } 1808 } 1809 1810 EventEmitter.prototype.emit = function emit(type) { 1811 var er, handler, len, args, i, events, domain; 1812 var doError = type === 'error'; 1813 events = this._events; 1814 if (events) doError = doError && events.error == null;else if (!doError) return false; 1815 domain = this.domain; // If there is no 'error' event listener then throw. 1816 1817 if (doError) { 1818 er = arguments[1]; 1819 1820 if (domain) { 1821 if (!er) er = new Error('Uncaught, unspecified "error" event'); 1822 er.domainEmitter = this; 1823 er.domain = domain; 1824 er.domainThrown = false; 1825 domain.emit('error', er); 1826 } else if (er instanceof Error) { 1827 throw er; // Unhandled 'error' event 1828 } else { 1829 // At least give some kind of context to the user 1830 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); 1831 err.context = er; 1832 throw err; 1833 } 1834 1835 return false; 1836 } 1837 1838 handler = events[type]; 1839 if (!handler) return false; 1840 var isFn = typeof handler === 'function'; 1841 len = arguments.length; 1842 1843 switch (len) { 1844 // fast cases 1845 case 1: 1846 emitNone(handler, isFn, this); 1847 break; 1848 1849 case 2: 1850 emitOne(handler, isFn, this, arguments[1]); 1851 break; 1852 1853 case 3: 1854 emitTwo(handler, isFn, this, arguments[1], arguments[2]); 1855 break; 1856 1857 case 4: 1858 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); 1859 break; 1860 // slower 1861 1862 default: 1863 args = new Array(len - 1); 1864 1865 for (i = 1; i < len; i++) { 1866 args[i - 1] = arguments[i]; 1867 } 1868 1869 emitMany(handler, isFn, this, args); 1870 } 1871 return true; 1872 }; 1873 1874 function _addListener(target, type, listener, prepend) { 1875 var m; 1876 var events; 1877 var existing; 1878 if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function'); 1879 events = target._events; 1880 1881 if (!events) { 1882 events = target._events = new EventHandlers(); 1883 target._eventsCount = 0; 1884 } else { 1885 // To avoid recursion in the case that type === "newListener"! Before 1886 // adding it to the listeners, first emit "newListener". 1887 if (events.newListener) { 1888 target.emit('newListener', type, listener.listener ? listener.listener : listener); // Re-assign `events` because a newListener handler could have caused the 1889 // this._events to be assigned to a new object 1890 1891 events = target._events; 1892 } 1893 1894 existing = events[type]; 1895 } 1896 1897 if (!existing) { 1898 // Optimize the case of one listener. Don't need the extra array object. 1899 existing = events[type] = listener; 1900 ++target._eventsCount; 1901 } else { 1902 if (typeof existing === 'function') { 1903 // Adding the second element, need to change to array. 1904 existing = events[type] = prepend ? [listener, existing] : [existing, listener]; 1905 } else { 1906 // If we've already got an array, just append. 1907 if (prepend) { 1908 existing.unshift(listener); 1909 } else { 1910 existing.push(listener); 1911 } 1912 } // Check for listener leak 1913 1914 1915 if (!existing.warned) { 1916 m = $getMaxListeners(target); 1917 1918 if (m && m > 0 && existing.length > m) { 1919 existing.warned = true; 1920 var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' ' + type + ' listeners added. ' + 'Use emitter.setMaxListeners() to increase limit'); 1921 w.name = 'MaxListenersExceededWarning'; 1922 w.emitter = target; 1923 w.type = type; 1924 w.count = existing.length; 1925 emitWarning(w); 1926 } 1927 } 1928 } 1929 1930 return target; 1931 } 1932 1933 function emitWarning(e) { 1934 typeof console.warn === 'function' ? console.warn(e) : console.log(e); 1935 } 1936 1937 EventEmitter.prototype.addListener = function addListener(type, listener) { 1938 return _addListener(this, type, listener, false); 1939 }; 1940 1941 EventEmitter.prototype.on = EventEmitter.prototype.addListener; 1942 1943 EventEmitter.prototype.prependListener = function prependListener(type, listener) { 1944 return _addListener(this, type, listener, true); 1945 }; 1946 1947 function _onceWrap(target, type, listener) { 1948 var fired = false; 1949 1950 function g() { 1951 target.removeListener(type, g); 1952 1953 if (!fired) { 1954 fired = true; 1955 listener.apply(target, arguments); 1956 } 1957 } 1958 1959 g.listener = listener; 1960 return g; 1961 } 1962 1963 EventEmitter.prototype.once = function once(type, listener) { 1964 if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function'); 1965 this.on(type, _onceWrap(this, type, listener)); 1966 return this; 1967 }; 1968 1969 EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) { 1970 if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function'); 1971 this.prependListener(type, _onceWrap(this, type, listener)); 1972 return this; 1973 }; // emits a 'removeListener' event iff the listener was removed 1974 1975 1976 EventEmitter.prototype.removeListener = function removeListener(type, listener) { 1977 var list, events, position, i, originalListener; 1978 if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function'); 1979 events = this._events; 1980 if (!events) return this; 1981 list = events[type]; 1982 if (!list) return this; 1983 1984 if (list === listener || list.listener && list.listener === listener) { 1985 if (--this._eventsCount === 0) this._events = new EventHandlers();else { 1986 delete events[type]; 1987 if (events.removeListener) this.emit('removeListener', type, list.listener || listener); 1988 } 1989 } else if (typeof list !== 'function') { 1990 position = -1; 1991 1992 for (i = list.length; i-- > 0;) { 1993 if (list[i] === listener || list[i].listener && list[i].listener === listener) { 1994 originalListener = list[i].listener; 1995 position = i; 1996 break; 1997 } 1998 } 1999 2000 if (position < 0) return this; 2001 2002 if (list.length === 1) { 2003 list[0] = undefined; 2004 2005 if (--this._eventsCount === 0) { 2006 this._events = new EventHandlers(); 2007 return this; 2008 } else { 2009 delete events[type]; 2010 } 2011 } else { 2012 spliceOne(list, position); 2013 } 2014 2015 if (events.removeListener) this.emit('removeListener', type, originalListener || listener); 2016 } 2017 2018 return this; 2019 }; 2020 2021 EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) { 2022 var listeners, events; 2023 events = this._events; 2024 if (!events) return this; // not listening for removeListener, no need to emit 2025 2026 if (!events.removeListener) { 2027 if (arguments.length === 0) { 2028 this._events = new EventHandlers(); 2029 this._eventsCount = 0; 2030 } else if (events[type]) { 2031 if (--this._eventsCount === 0) this._events = new EventHandlers();else delete events[type]; 2032 } 2033 2034 return this; 2035 } // emit removeListener for all listeners on all events 2036 2037 2038 if (arguments.length === 0) { 2039 var keys = Object.keys(events); 2040 2041 for (var i = 0, key; i < keys.length; ++i) { 2042 key = keys[i]; 2043 if (key === 'removeListener') continue; 2044 this.removeAllListeners(key); 2045 } 2046 2047 this.removeAllListeners('removeListener'); 2048 this._events = new EventHandlers(); 2049 this._eventsCount = 0; 2050 return this; 2051 } 2052 2053 listeners = events[type]; 2054 2055 if (typeof listeners === 'function') { 2056 this.removeListener(type, listeners); 2057 } else if (listeners) { 2058 // LIFO order 2059 do { 2060 this.removeListener(type, listeners[listeners.length - 1]); 2061 } while (listeners[0]); 2062 } 2063 2064 return this; 2065 }; 2066 2067 EventEmitter.prototype.listeners = function listeners(type) { 2068 var evlistener; 2069 var ret; 2070 var events = this._events; 2071 if (!events) ret = [];else { 2072 evlistener = events[type]; 2073 if (!evlistener) ret = [];else if (typeof evlistener === 'function') ret = [evlistener.listener || evlistener];else ret = unwrapListeners(evlistener); 2074 } 2075 return ret; 2076 }; 2077 2078 EventEmitter.listenerCount = function (emitter, type) { 2079 if (typeof emitter.listenerCount === 'function') { 2080 return emitter.listenerCount(type); 2081 } else { 2082 return listenerCount.call(emitter, type); 2083 } 2084 }; 2085 2086 EventEmitter.prototype.listenerCount = listenerCount; 2087 2088 function listenerCount(type) { 2089 var events = this._events; 2090 2091 if (events) { 2092 var evlistener = events[type]; 2093 2094 if (typeof evlistener === 'function') { 2095 return 1; 2096 } else if (evlistener) { 2097 return evlistener.length; 2098 } 2099 } 2100 2101 return 0; 2102 } 2103 2104 EventEmitter.prototype.eventNames = function eventNames() { 2105 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; 2106 }; // About 1.5x faster than the two-arg version of Array#splice(). 2107 2108 2109 function spliceOne(list, index) { 2110 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) { 2111 list[i] = list[k]; 2112 } 2113 2114 list.pop(); 2115 } 2116 2117 function arrayClone(arr, i) { 2118 var copy = new Array(i); 2119 2120 while (i--) { 2121 copy[i] = arr[i]; 2122 } 2123 2124 return copy; 2125 } 2126 2127 function unwrapListeners(arr) { 2128 var ret = new Array(arr.length); 2129 2130 for (var i = 0; i < ret.length; ++i) { 2131 ret[i] = arr[i].listener || arr[i]; 2132 } 2133 2134 return ret; 2135 } 2136 2137 var nativeJoin = [].join; 2138 2139 var ES3_STRINGS = indexedObject != Object; 2140 var STRICT_METHOD$1 = arrayMethodIsStrict('join', ','); 2141 2142 // `Array.prototype.join` method 2143 // https://tc39.es/ecma262/#sec-array.prototype.join 2144 _export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$1 }, { 2145 join: function join(separator) { 2146 return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator); 2147 } 2148 }); 2149 2150 var $map = arrayIteration.map; 2151 2152 2153 2154 var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('map'); 2155 // FF49- issue 2156 var USES_TO_LENGTH$3 = arrayMethodUsesToLength('map'); 2157 2158 // `Array.prototype.map` method 2159 // https://tc39.es/ecma262/#sec-array.prototype.map 2160 // with adding support of @@species 2161 _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 || !USES_TO_LENGTH$3 }, { 2162 map: function map(callbackfn /* , thisArg */) { 2163 return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 2164 } 2165 }); 2166 2167 var aPossiblePrototype = function (it) { 2168 if (!isObject(it) && it !== null) { 2169 throw TypeError("Can't set " + String(it) + ' as a prototype'); 2170 } return it; 2171 }; 2172 2173 // `Object.setPrototypeOf` method 2174 // https://tc39.es/ecma262/#sec-object.setprototypeof 2175 // Works with __proto__ only. Old v8 can't work with null proto objects. 2176 /* eslint-disable no-proto */ 2177 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2178 var CORRECT_SETTER = false; 2179 var test = {}; 2180 var setter; 2181 try { 2182 setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set; 2183 setter.call(test, []); 2184 CORRECT_SETTER = test instanceof Array; 2185 } catch (error) { /* empty */ } 2186 return function setPrototypeOf(O, proto) { 2187 anObject(O); 2188 aPossiblePrototype(proto); 2189 if (CORRECT_SETTER) setter.call(O, proto); 2190 else O.__proto__ = proto; 2191 return O; 2192 }; 2193 }() : undefined); 2194 2195 // makes subclassing work correct for wrapped built-ins 2196 var inheritIfRequired = function ($this, dummy, Wrapper) { 2197 var NewTarget, NewTargetPrototype; 2198 if ( 2199 // it can work only with native `setPrototypeOf` 2200 objectSetPrototypeOf && 2201 // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 2202 typeof (NewTarget = dummy.constructor) == 'function' && 2203 NewTarget !== Wrapper && 2204 isObject(NewTargetPrototype = NewTarget.prototype) && 2205 NewTargetPrototype !== Wrapper.prototype 2206 ) objectSetPrototypeOf($this, NewTargetPrototype); 2207 return $this; 2208 }; 2209 2210 // `Object.defineProperties` method 2211 // https://tc39.es/ecma262/#sec-object.defineproperties 2212 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2213 anObject(O); 2214 var keys = objectKeys(Properties); 2215 var length = keys.length; 2216 var index = 0; 2217 var key; 2218 while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]); 2219 return O; 2220 }; 2221 2222 var html = getBuiltIn('document', 'documentElement'); 2223 2224 var GT = '>'; 2225 var LT = '<'; 2226 var PROTOTYPE = 'prototype'; 2227 var SCRIPT = 'script'; 2228 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2229 2230 var EmptyConstructor = function () { /* empty */ }; 2231 2232 var scriptTag = function (content) { 2233 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2234 }; 2235 2236 // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2237 var NullProtoObjectViaActiveX = function (activeXDocument) { 2238 activeXDocument.write(scriptTag('')); 2239 activeXDocument.close(); 2240 var temp = activeXDocument.parentWindow.Object; 2241 activeXDocument = null; // avoid memory leak 2242 return temp; 2243 }; 2244 2245 // Create object with fake `null` prototype: use iframe Object with cleared prototype 2246 var NullProtoObjectViaIFrame = function () { 2247 // Thrash, waste and sodomy: IE GC bug 2248 var iframe = documentCreateElement('iframe'); 2249 var JS = 'java' + SCRIPT + ':'; 2250 var iframeDocument; 2251 iframe.style.display = 'none'; 2252 html.appendChild(iframe); 2253 // https://github.com/zloirock/core-js/issues/475 2254 iframe.src = String(JS); 2255 iframeDocument = iframe.contentWindow.document; 2256 iframeDocument.open(); 2257 iframeDocument.write(scriptTag('document.F=Object')); 2258 iframeDocument.close(); 2259 return iframeDocument.F; 2260 }; 2261 2262 // Check for document.domain and active x support 2263 // No need to use active x approach when document.domain is not set 2264 // see https://github.com/es-shims/es5-shim/issues/150 2265 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2266 // avoid IE GC bug 2267 var activeXDocument; 2268 var NullProtoObject = function () { 2269 try { 2270 /* global ActiveXObject */ 2271 activeXDocument = document.domain && new ActiveXObject('htmlfile'); 2272 } catch (error) { /* ignore */ } 2273 NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame(); 2274 var length = enumBugKeys.length; 2275 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2276 return NullProtoObject(); 2277 }; 2278 2279 hiddenKeys[IE_PROTO$1] = true; 2280 2281 // `Object.create` method 2282 // https://tc39.es/ecma262/#sec-object.create 2283 var objectCreate = Object.create || function create(O, Properties) { 2284 var result; 2285 if (O !== null) { 2286 EmptyConstructor[PROTOTYPE] = anObject(O); 2287 result = new EmptyConstructor(); 2288 EmptyConstructor[PROTOTYPE] = null; 2289 // add "__proto__" for Object.getPrototypeOf polyfill 2290 result[IE_PROTO$1] = O; 2291 } else result = NullProtoObject(); 2292 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2293 }; 2294 2295 // a string of all valid unicode whitespaces 2296 // eslint-disable-next-line max-len 2297 var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; 2298 2299 var whitespace = '[' + whitespaces + ']'; 2300 var ltrim = RegExp('^' + whitespace + whitespace + '*'); 2301 var rtrim = RegExp(whitespace + whitespace + '*$'); 2302 2303 // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation 2304 var createMethod$2 = function (TYPE) { 2305 return function ($this) { 2306 var string = String(requireObjectCoercible($this)); 2307 if (TYPE & 1) string = string.replace(ltrim, ''); 2308 if (TYPE & 2) string = string.replace(rtrim, ''); 2309 return string; 2310 }; 2311 }; 2312 2313 var stringTrim = { 2314 // `String.prototype.{ trimLeft, trimStart }` methods 2315 // https://tc39.es/ecma262/#sec-string.prototype.trimstart 2316 start: createMethod$2(1), 2317 // `String.prototype.{ trimRight, trimEnd }` methods 2318 // https://tc39.es/ecma262/#sec-string.prototype.trimend 2319 end: createMethod$2(2), 2320 // `String.prototype.trim` method 2321 // https://tc39.es/ecma262/#sec-string.prototype.trim 2322 trim: createMethod$2(3) 2323 }; 2324 2325 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 2326 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 2327 var defineProperty$3 = objectDefineProperty.f; 2328 var trim = stringTrim.trim; 2329 2330 var NUMBER = 'Number'; 2331 var NativeNumber = global_1[NUMBER]; 2332 var NumberPrototype = NativeNumber.prototype; 2333 2334 // Opera ~12 has broken Object#toString 2335 var BROKEN_CLASSOF = classofRaw(objectCreate(NumberPrototype)) == NUMBER; 2336 2337 // `ToNumber` abstract operation 2338 // https://tc39.es/ecma262/#sec-tonumber 2339 var toNumber = function (argument) { 2340 var it = toPrimitive(argument, false); 2341 var first, third, radix, maxCode, digits, length, index, code; 2342 if (typeof it == 'string' && it.length > 2) { 2343 it = trim(it); 2344 first = it.charCodeAt(0); 2345 if (first === 43 || first === 45) { 2346 third = it.charCodeAt(2); 2347 if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix 2348 } else if (first === 48) { 2349 switch (it.charCodeAt(1)) { 2350 case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i 2351 case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i 2352 default: return +it; 2353 } 2354 digits = it.slice(2); 2355 length = digits.length; 2356 for (index = 0; index < length; index++) { 2357 code = digits.charCodeAt(index); 2358 // parseInt parses a string to a first unavailable symbol 2359 // but ToNumber should return NaN if a string contains unavailable symbols 2360 if (code < 48 || code > maxCode) return NaN; 2361 } return parseInt(digits, radix); 2362 } 2363 } return +it; 2364 }; 2365 2366 // `Number` constructor 2367 // https://tc39.es/ecma262/#sec-number-constructor 2368 if (isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) { 2369 var NumberWrapper = function Number(value) { 2370 var it = arguments.length < 1 ? 0 : value; 2371 var dummy = this; 2372 return dummy instanceof NumberWrapper 2373 // check on 1..constructor(foo) case 2374 && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classofRaw(dummy) != NUMBER) 2375 ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it); 2376 }; 2377 for (var keys$1 = descriptors ? getOwnPropertyNames(NativeNumber) : ( 2378 // ES3: 2379 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + 2380 // ES2015 (in case, if modules with ES2015 Number statics required before): 2381 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + 2382 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,' + 2383 // ESNext 2384 'fromString,range' 2385 ).split(','), j = 0, key; keys$1.length > j; j++) { 2386 if (has(NativeNumber, key = keys$1[j]) && !has(NumberWrapper, key)) { 2387 defineProperty$3(NumberWrapper, key, getOwnPropertyDescriptor$2(NativeNumber, key)); 2388 } 2389 } 2390 NumberWrapper.prototype = NumberPrototype; 2391 NumberPrototype.constructor = NumberWrapper; 2392 redefine(global_1, NUMBER, NumberWrapper); 2393 } 2394 2395 var nativeGetOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2396 2397 2398 var FAILS_ON_PRIMITIVES$2 = fails(function () { nativeGetOwnPropertyDescriptor$1(1); }); 2399 var FORCED$1 = !descriptors || FAILS_ON_PRIMITIVES$2; 2400 2401 // `Object.getOwnPropertyDescriptor` method 2402 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2403 _export({ target: 'Object', stat: true, forced: FORCED$1, sham: !descriptors }, { 2404 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) { 2405 return nativeGetOwnPropertyDescriptor$1(toIndexedObject(it), key); 2406 } 2407 }); 2408 2409 var nativeGetOwnPropertyNames = objectGetOwnPropertyNames.f; 2410 2411 var toString$1 = {}.toString; 2412 2413 var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames 2414 ? Object.getOwnPropertyNames(window) : []; 2415 2416 var getWindowNames = function (it) { 2417 try { 2418 return nativeGetOwnPropertyNames(it); 2419 } catch (error) { 2420 return windowNames.slice(); 2421 } 2422 }; 2423 2424 // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window 2425 var f$5 = function getOwnPropertyNames(it) { 2426 return windowNames && toString$1.call(it) == '[object Window]' 2427 ? getWindowNames(it) 2428 : nativeGetOwnPropertyNames(toIndexedObject(it)); 2429 }; 2430 2431 var objectGetOwnPropertyNamesExternal = { 2432 f: f$5 2433 }; 2434 2435 var nativeGetOwnPropertyNames$1 = objectGetOwnPropertyNamesExternal.f; 2436 2437 var FAILS_ON_PRIMITIVES$3 = fails(function () { return !Object.getOwnPropertyNames(1); }); 2438 2439 // `Object.getOwnPropertyNames` method 2440 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2441 _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$3 }, { 2442 getOwnPropertyNames: nativeGetOwnPropertyNames$1 2443 }); 2444 2445 var MATCH = wellKnownSymbol('match'); 2446 2447 // `IsRegExp` abstract operation 2448 // https://tc39.es/ecma262/#sec-isregexp 2449 var isRegexp = function (it) { 2450 var isRegExp; 2451 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 2452 }; 2453 2454 var SPECIES$3 = wellKnownSymbol('species'); 2455 2456 var setSpecies = function (CONSTRUCTOR_NAME) { 2457 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 2458 var defineProperty = objectDefineProperty.f; 2459 2460 if (descriptors && Constructor && !Constructor[SPECIES$3]) { 2461 defineProperty(Constructor, SPECIES$3, { 2462 configurable: true, 2463 get: function () { return this; } 2464 }); 2465 } 2466 }; 2467 2468 var defineProperty$4 = objectDefineProperty.f; 2469 var getOwnPropertyNames$1 = objectGetOwnPropertyNames.f; 2470 2471 2472 2473 2474 2475 var setInternalState = internalState.set; 2476 2477 2478 2479 var MATCH$1 = wellKnownSymbol('match'); 2480 var NativeRegExp = global_1.RegExp; 2481 var RegExpPrototype$1 = NativeRegExp.prototype; 2482 var re1 = /a/g; 2483 var re2 = /a/g; 2484 2485 // "new" should create a new object, old webkit bug 2486 var CORRECT_NEW = new NativeRegExp(re1) !== re1; 2487 2488 var UNSUPPORTED_Y$2 = regexpStickyHelpers.UNSUPPORTED_Y; 2489 2490 var FORCED$2 = descriptors && isForced_1('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y$2 || fails(function () { 2491 re2[MATCH$1] = false; 2492 // RegExp constructor can alter flags and IsRegExp works correct with @@match 2493 return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i'; 2494 }))); 2495 2496 // `RegExp` constructor 2497 // https://tc39.es/ecma262/#sec-regexp-constructor 2498 if (FORCED$2) { 2499 var RegExpWrapper = function RegExp(pattern, flags) { 2500 var thisIsRegExp = this instanceof RegExpWrapper; 2501 var patternIsRegExp = isRegexp(pattern); 2502 var flagsAreUndefined = flags === undefined; 2503 var sticky; 2504 2505 if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) { 2506 return pattern; 2507 } 2508 2509 if (CORRECT_NEW) { 2510 if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source; 2511 } else if (pattern instanceof RegExpWrapper) { 2512 if (flagsAreUndefined) flags = regexpFlags.call(pattern); 2513 pattern = pattern.source; 2514 } 2515 2516 if (UNSUPPORTED_Y$2) { 2517 sticky = !!flags && flags.indexOf('y') > -1; 2518 if (sticky) flags = flags.replace(/y/g, ''); 2519 } 2520 2521 var result = inheritIfRequired( 2522 CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags), 2523 thisIsRegExp ? this : RegExpPrototype$1, 2524 RegExpWrapper 2525 ); 2526 2527 if (UNSUPPORTED_Y$2 && sticky) setInternalState(result, { sticky: sticky }); 2528 2529 return result; 2530 }; 2531 var proxy = function (key) { 2532 key in RegExpWrapper || defineProperty$4(RegExpWrapper, key, { 2533 configurable: true, 2534 get: function () { return NativeRegExp[key]; }, 2535 set: function (it) { NativeRegExp[key] = it; } 2536 }); 2537 }; 2538 var keys$2 = getOwnPropertyNames$1(NativeRegExp); 2539 var index = 0; 2540 while (keys$2.length > index) proxy(keys$2[index++]); 2541 RegExpPrototype$1.constructor = RegExpWrapper; 2542 RegExpWrapper.prototype = RegExpPrototype$1; 2543 redefine(global_1, 'RegExp', RegExpWrapper); 2544 } 2545 2546 // https://tc39.es/ecma262/#sec-get-regexp-@@species 2547 setSpecies('RegExp'); 2548 2549 // `String.prototype.{ codePointAt, at }` methods implementation 2550 var createMethod$3 = function (CONVERT_TO_STRING) { 2551 return function ($this, pos) { 2552 var S = String(requireObjectCoercible($this)); 2553 var position = toInteger(pos); 2554 var size = S.length; 2555 var first, second; 2556 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 2557 first = S.charCodeAt(position); 2558 return first < 0xD800 || first > 0xDBFF || position + 1 === size 2559 || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF 2560 ? CONVERT_TO_STRING ? S.charAt(position) : first 2561 : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; 2562 }; 2563 }; 2564 2565 var stringMultibyte = { 2566 // `String.prototype.codePointAt` method 2567 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 2568 codeAt: createMethod$3(false), 2569 // `String.prototype.at` method 2570 // https://github.com/mathiasbynens/String.prototype.at 2571 charAt: createMethod$3(true) 2572 }; 2573 2574 var charAt = stringMultibyte.charAt; 2575 2576 // `AdvanceStringIndex` abstract operation 2577 // https://tc39.es/ecma262/#sec-advancestringindex 2578 var advanceStringIndex = function (S, index, unicode) { 2579 return index + (unicode ? charAt(S, index).length : 1); 2580 }; 2581 2582 // @@match logic 2583 fixRegexpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) { 2584 return [ 2585 // `String.prototype.match` method 2586 // https://tc39.es/ecma262/#sec-string.prototype.match 2587 function match(regexp) { 2588 var O = requireObjectCoercible(this); 2589 var matcher = regexp == undefined ? undefined : regexp[MATCH]; 2590 return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); 2591 }, 2592 // `RegExp.prototype[@@match]` method 2593 // https://tc39.es/ecma262/#sec-regexp.prototype-@@match 2594 function (regexp) { 2595 var res = maybeCallNative(nativeMatch, regexp, this); 2596 if (res.done) return res.value; 2597 2598 var rx = anObject(regexp); 2599 var S = String(this); 2600 2601 if (!rx.global) return regexpExecAbstract(rx, S); 2602 2603 var fullUnicode = rx.unicode; 2604 rx.lastIndex = 0; 2605 var A = []; 2606 var n = 0; 2607 var result; 2608 while ((result = regexpExecAbstract(rx, S)) !== null) { 2609 var matchStr = String(result[0]); 2610 A[n] = matchStr; 2611 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); 2612 n++; 2613 } 2614 return n === 0 ? null : A; 2615 } 2616 ]; 2617 }); 2618 2619 var floor$1 = Math.floor; 2620 var replace = ''.replace; 2621 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g; 2622 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g; 2623 2624 // https://tc39.es/ecma262/#sec-getsubstitution 2625 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 2626 var tailPos = position + matched.length; 2627 var m = captures.length; 2628 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 2629 if (namedCaptures !== undefined) { 2630 namedCaptures = toObject(namedCaptures); 2631 symbols = SUBSTITUTION_SYMBOLS; 2632 } 2633 return replace.call(replacement, symbols, function (match, ch) { 2634 var capture; 2635 switch (ch.charAt(0)) { 2636 case '$': return '$'; 2637 case '&': return matched; 2638 case '`': return str.slice(0, position); 2639 case "'": return str.slice(tailPos); 2640 case '<': 2641 capture = namedCaptures[ch.slice(1, -1)]; 2642 break; 2643 default: // \d\d? 2644 var n = +ch; 2645 if (n === 0) return match; 2646 if (n > m) { 2647 var f = floor$1(n / 10); 2648 if (f === 0) return match; 2649 if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); 2650 return match; 2651 } 2652 capture = captures[n - 1]; 2653 } 2654 return capture === undefined ? '' : capture; 2655 }); 2656 }; 2657 2658 var max$2 = Math.max; 2659 var min$3 = Math.min; 2660 2661 var maybeToString = function (it) { 2662 return it === undefined ? it : String(it); 2663 }; 2664 2665 // @@replace logic 2666 fixRegexpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) { 2667 var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE; 2668 var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0; 2669 var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; 2670 2671 return [ 2672 // `String.prototype.replace` method 2673 // https://tc39.es/ecma262/#sec-string.prototype.replace 2674 function replace(searchValue, replaceValue) { 2675 var O = requireObjectCoercible(this); 2676 var replacer = searchValue == undefined ? undefined : searchValue[REPLACE]; 2677 return replacer !== undefined 2678 ? replacer.call(searchValue, O, replaceValue) 2679 : nativeReplace.call(String(O), searchValue, replaceValue); 2680 }, 2681 // `RegExp.prototype[@@replace]` method 2682 // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace 2683 function (regexp, replaceValue) { 2684 if ( 2685 (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) || 2686 (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1) 2687 ) { 2688 var res = maybeCallNative(nativeReplace, regexp, this, replaceValue); 2689 if (res.done) return res.value; 2690 } 2691 2692 var rx = anObject(regexp); 2693 var S = String(this); 2694 2695 var functionalReplace = typeof replaceValue === 'function'; 2696 if (!functionalReplace) replaceValue = String(replaceValue); 2697 2698 var global = rx.global; 2699 if (global) { 2700 var fullUnicode = rx.unicode; 2701 rx.lastIndex = 0; 2702 } 2703 var results = []; 2704 while (true) { 2705 var result = regexpExecAbstract(rx, S); 2706 if (result === null) break; 2707 2708 results.push(result); 2709 if (!global) break; 2710 2711 var matchStr = String(result[0]); 2712 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); 2713 } 2714 2715 var accumulatedResult = ''; 2716 var nextSourcePosition = 0; 2717 for (var i = 0; i < results.length; i++) { 2718 result = results[i]; 2719 2720 var matched = String(result[0]); 2721 var position = max$2(min$3(toInteger(result.index), S.length), 0); 2722 var captures = []; 2723 // NOTE: This is equivalent to 2724 // captures = result.slice(1).map(maybeToString) 2725 // but for some reason `nativeSlice.call(result, 1, result.length)` (called in 2726 // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and 2727 // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. 2728 for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); 2729 var namedCaptures = result.groups; 2730 if (functionalReplace) { 2731 var replacerArgs = [matched].concat(captures, position, S); 2732 if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); 2733 var replacement = String(replaceValue.apply(undefined, replacerArgs)); 2734 } else { 2735 replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); 2736 } 2737 if (position >= nextSourcePosition) { 2738 accumulatedResult += S.slice(nextSourcePosition, position) + replacement; 2739 nextSourcePosition = position + matched.length; 2740 } 2741 } 2742 return accumulatedResult + S.slice(nextSourcePosition); 2743 } 2744 ]; 2745 }); 2746 2747 var SPECIES$4 = wellKnownSymbol('species'); 2748 2749 // `SpeciesConstructor` abstract operation 2750 // https://tc39.es/ecma262/#sec-speciesconstructor 2751 var speciesConstructor = function (O, defaultConstructor) { 2752 var C = anObject(O).constructor; 2753 var S; 2754 return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aFunction$1(S); 2755 }; 2756 2757 var arrayPush = [].push; 2758 var min$4 = Math.min; 2759 var MAX_UINT32 = 0xFFFFFFFF; 2760 2761 // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError 2762 var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); }); 2763 2764 // @@split logic 2765 fixRegexpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) { 2766 var internalSplit; 2767 if ( 2768 'abbc'.split(/(b)*/)[1] == 'c' || 2769 'test'.split(/(?:)/, -1).length != 4 || 2770 'ab'.split(/(?:ab)*/).length != 2 || 2771 '.'.split(/(.?)(.?)/).length != 4 || 2772 '.'.split(/()()/).length > 1 || 2773 ''.split(/.?/).length 2774 ) { 2775 // based on es5-shim implementation, need to rework it 2776 internalSplit = function (separator, limit) { 2777 var string = String(requireObjectCoercible(this)); 2778 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; 2779 if (lim === 0) return []; 2780 if (separator === undefined) return [string]; 2781 // If `separator` is not a regex, use native split 2782 if (!isRegexp(separator)) { 2783 return nativeSplit.call(string, separator, lim); 2784 } 2785 var output = []; 2786 var flags = (separator.ignoreCase ? 'i' : '') + 2787 (separator.multiline ? 'm' : '') + 2788 (separator.unicode ? 'u' : '') + 2789 (separator.sticky ? 'y' : ''); 2790 var lastLastIndex = 0; 2791 // Make `global` and avoid `lastIndex` issues by working with a copy 2792 var separatorCopy = new RegExp(separator.source, flags + 'g'); 2793 var match, lastIndex, lastLength; 2794 while (match = regexpExec.call(separatorCopy, string)) { 2795 lastIndex = separatorCopy.lastIndex; 2796 if (lastIndex > lastLastIndex) { 2797 output.push(string.slice(lastLastIndex, match.index)); 2798 if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1)); 2799 lastLength = match[0].length; 2800 lastLastIndex = lastIndex; 2801 if (output.length >= lim) break; 2802 } 2803 if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop 2804 } 2805 if (lastLastIndex === string.length) { 2806 if (lastLength || !separatorCopy.test('')) output.push(''); 2807 } else output.push(string.slice(lastLastIndex)); 2808 return output.length > lim ? output.slice(0, lim) : output; 2809 }; 2810 // Chakra, V8 2811 } else if ('0'.split(undefined, 0).length) { 2812 internalSplit = function (separator, limit) { 2813 return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit); 2814 }; 2815 } else internalSplit = nativeSplit; 2816 2817 return [ 2818 // `String.prototype.split` method 2819 // https://tc39.es/ecma262/#sec-string.prototype.split 2820 function split(separator, limit) { 2821 var O = requireObjectCoercible(this); 2822 var splitter = separator == undefined ? undefined : separator[SPLIT]; 2823 return splitter !== undefined 2824 ? splitter.call(separator, O, limit) 2825 : internalSplit.call(String(O), separator, limit); 2826 }, 2827 // `RegExp.prototype[@@split]` method 2828 // https://tc39.es/ecma262/#sec-regexp.prototype-@@split 2829 // 2830 // NOTE: This cannot be properly polyfilled in engines that don't support 2831 // the 'y' flag. 2832 function (regexp, limit) { 2833 var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit); 2834 if (res.done) return res.value; 2835 2836 var rx = anObject(regexp); 2837 var S = String(this); 2838 var C = speciesConstructor(rx, RegExp); 2839 2840 var unicodeMatching = rx.unicode; 2841 var flags = (rx.ignoreCase ? 'i' : '') + 2842 (rx.multiline ? 'm' : '') + 2843 (rx.unicode ? 'u' : '') + 2844 (SUPPORTS_Y ? 'y' : 'g'); 2845 2846 // ^(? + rx + ) is needed, in combination with some S slicing, to 2847 // simulate the 'y' flag. 2848 var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags); 2849 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; 2850 if (lim === 0) return []; 2851 if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : []; 2852 var p = 0; 2853 var q = 0; 2854 var A = []; 2855 while (q < S.length) { 2856 splitter.lastIndex = SUPPORTS_Y ? q : 0; 2857 var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q)); 2858 var e; 2859 if ( 2860 z === null || 2861 (e = min$4(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p 2862 ) { 2863 q = advanceStringIndex(S, q, unicodeMatching); 2864 } else { 2865 A.push(S.slice(p, q)); 2866 if (A.length === lim) return A; 2867 for (var i = 1; i <= z.length - 1; i++) { 2868 A.push(z[i]); 2869 if (A.length === lim) return A; 2870 } 2871 q = p = e; 2872 } 2873 } 2874 A.push(S.slice(p)); 2875 return A; 2876 } 2877 ]; 2878 }, !SUPPORTS_Y); 2879 2880 function _typeof(obj) { 2881 "@babel/helpers - typeof"; 2882 2883 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 2884 _typeof = function (obj) { 2885 return typeof obj; 2886 }; 2887 } else { 2888 _typeof = function (obj) { 2889 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 2890 }; 2891 } 2892 2893 return _typeof(obj); 2894 } 2895 2896 function _asyncIterator(iterable) { 2897 var method; 2898 2899 if (typeof Symbol !== "undefined") { 2900 if (Symbol.asyncIterator) { 2901 method = iterable[Symbol.asyncIterator]; 2902 if (method != null) return method.call(iterable); 2903 } 2904 2905 if (Symbol.iterator) { 2906 method = iterable[Symbol.iterator]; 2907 if (method != null) return method.call(iterable); 2908 } 2909 } 2910 2911 throw new TypeError("Object is not async iterable"); 2912 } 2913 2914 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 2915 try { 2916 var info = gen[key](arg); 2917 var value = info.value; 2918 } catch (error) { 2919 reject(error); 2920 return; 2921 } 2922 2923 if (info.done) { 2924 resolve(value); 2925 } else { 2926 Promise.resolve(value).then(_next, _throw); 2927 } 2928 } 2929 2930 function _asyncToGenerator(fn) { 2931 return function () { 2932 var self = this, 2933 args = arguments; 2934 return new Promise(function (resolve, reject) { 2935 var gen = fn.apply(self, args); 2936 2937 function _next(value) { 2938 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 2939 } 2940 2941 function _throw(err) { 2942 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 2943 } 2944 2945 _next(undefined); 2946 }); 2947 }; 2948 } 2949 2950 function _classCallCheck(instance, Constructor) { 2951 if (!(instance instanceof Constructor)) { 2952 throw new TypeError("Cannot call a class as a function"); 2953 } 2954 } 2955 2956 function _defineProperty(obj, key, value) { 2957 if (key in obj) { 2958 Object.defineProperty(obj, key, { 2959 value: value, 2960 enumerable: true, 2961 configurable: true, 2962 writable: true 2963 }); 2964 } else { 2965 obj[key] = value; 2966 } 2967 2968 return obj; 2969 } 2970 2971 function ownKeys$1(object, enumerableOnly) { 2972 var keys = Object.keys(object); 2973 2974 if (Object.getOwnPropertySymbols) { 2975 var symbols = Object.getOwnPropertySymbols(object); 2976 if (enumerableOnly) symbols = symbols.filter(function (sym) { 2977 return Object.getOwnPropertyDescriptor(object, sym).enumerable; 2978 }); 2979 keys.push.apply(keys, symbols); 2980 } 2981 2982 return keys; 2983 } 2984 2985 function _objectSpread2(target) { 2986 for (var i = 1; i < arguments.length; i++) { 2987 var source = arguments[i] != null ? arguments[i] : {}; 2988 2989 if (i % 2) { 2990 ownKeys$1(Object(source), true).forEach(function (key) { 2991 _defineProperty(target, key, source[key]); 2992 }); 2993 } else if (Object.getOwnPropertyDescriptors) { 2994 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); 2995 } else { 2996 ownKeys$1(Object(source)).forEach(function (key) { 2997 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); 2998 }); 2999 } 3000 } 3001 3002 return target; 3003 } 3004 3005 function _inherits(subClass, superClass) { 3006 if (typeof superClass !== "function" && superClass !== null) { 3007 throw new TypeError("Super expression must either be null or a function"); 3008 } 3009 3010 subClass.prototype = Object.create(superClass && superClass.prototype, { 3011 constructor: { 3012 value: subClass, 3013 writable: true, 3014 configurable: true 3015 } 3016 }); 3017 if (superClass) _setPrototypeOf(subClass, superClass); 3018 } 3019 3020 function _getPrototypeOf(o) { 3021 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 3022 return o.__proto__ || Object.getPrototypeOf(o); 3023 }; 3024 return _getPrototypeOf(o); 3025 } 3026 3027 function _setPrototypeOf(o, p) { 3028 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 3029 o.__proto__ = p; 3030 return o; 3031 }; 3032 3033 return _setPrototypeOf(o, p); 3034 } 3035 3036 function _isNativeReflectConstruct() { 3037 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 3038 if (Reflect.construct.sham) return false; 3039 if (typeof Proxy === "function") return true; 3040 3041 try { 3042 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 3043 return true; 3044 } catch (e) { 3045 return false; 3046 } 3047 } 3048 3049 function _assertThisInitialized(self) { 3050 if (self === void 0) { 3051 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 3052 } 3053 3054 return self; 3055 } 3056 3057 function _possibleConstructorReturn(self, call) { 3058 if (call && (typeof call === "object" || typeof call === "function")) { 3059 return call; 3060 } 3061 3062 return _assertThisInitialized(self); 3063 } 3064 3065 function _createSuper(Derived) { 3066 var hasNativeReflectConstruct = _isNativeReflectConstruct(); 3067 3068 return function _createSuperInternal() { 3069 var Super = _getPrototypeOf(Derived), 3070 result; 3071 3072 if (hasNativeReflectConstruct) { 3073 var NewTarget = _getPrototypeOf(this).constructor; 3074 3075 result = Reflect.construct(Super, arguments, NewTarget); 3076 } else { 3077 result = Super.apply(this, arguments); 3078 } 3079 3080 return _possibleConstructorReturn(this, result); 3081 }; 3082 } 3083 3084 function _toConsumableArray(arr) { 3085 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); 3086 } 3087 3088 function _arrayWithoutHoles(arr) { 3089 if (Array.isArray(arr)) return _arrayLikeToArray(arr); 3090 } 3091 3092 function _iterableToArray(iter) { 3093 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 3094 } 3095 3096 function _unsupportedIterableToArray(o, minLen) { 3097 if (!o) return; 3098 if (typeof o === "string") return _arrayLikeToArray(o, minLen); 3099 var n = Object.prototype.toString.call(o).slice(8, -1); 3100 if (n === "Object" && o.constructor) n = o.constructor.name; 3101 if (n === "Map" || n === "Set") return Array.from(o); 3102 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); 3103 } 3104 3105 function _arrayLikeToArray(arr, len) { 3106 if (len == null || len > arr.length) len = arr.length; 3107 3108 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; 3109 3110 return arr2; 3111 } 3112 3113 function _nonIterableSpread() { 3114 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 3115 } 3116 3117 var f$6 = wellKnownSymbol; 3118 3119 var wellKnownSymbolWrapped = { 3120 f: f$6 3121 }; 3122 3123 var defineProperty$5 = objectDefineProperty.f; 3124 3125 var defineWellKnownSymbol = function (NAME) { 3126 var Symbol = path.Symbol || (path.Symbol = {}); 3127 if (!has(Symbol, NAME)) defineProperty$5(Symbol, NAME, { 3128 value: wellKnownSymbolWrapped.f(NAME) 3129 }); 3130 }; 3131 3132 var defineProperty$6 = objectDefineProperty.f; 3133 3134 3135 3136 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 3137 3138 var setToStringTag = function (it, TAG, STATIC) { 3139 if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG$2)) { 3140 defineProperty$6(it, TO_STRING_TAG$2, { configurable: true, value: TAG }); 3141 } 3142 }; 3143 3144 var $forEach$1 = arrayIteration.forEach; 3145 3146 var HIDDEN = sharedKey('hidden'); 3147 var SYMBOL = 'Symbol'; 3148 var PROTOTYPE$1 = 'prototype'; 3149 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); 3150 var setInternalState$1 = internalState.set; 3151 var getInternalState = internalState.getterFor(SYMBOL); 3152 var ObjectPrototype$1 = Object[PROTOTYPE$1]; 3153 var $Symbol = global_1.Symbol; 3154 var $stringify = getBuiltIn('JSON', 'stringify'); 3155 var nativeGetOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 3156 var nativeDefineProperty$1 = objectDefineProperty.f; 3157 var nativeGetOwnPropertyNames$2 = objectGetOwnPropertyNamesExternal.f; 3158 var nativePropertyIsEnumerable$1 = objectPropertyIsEnumerable.f; 3159 var AllSymbols = shared('symbols'); 3160 var ObjectPrototypeSymbols = shared('op-symbols'); 3161 var StringToSymbolRegistry = shared('string-to-symbol-registry'); 3162 var SymbolToStringRegistry = shared('symbol-to-string-registry'); 3163 var WellKnownSymbolsStore$1 = shared('wks'); 3164 var QObject = global_1.QObject; 3165 // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 3166 var USE_SETTER = !QObject || !QObject[PROTOTYPE$1] || !QObject[PROTOTYPE$1].findChild; 3167 3168 // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 3169 var setSymbolDescriptor = descriptors && fails(function () { 3170 return objectCreate(nativeDefineProperty$1({}, 'a', { 3171 get: function () { return nativeDefineProperty$1(this, 'a', { value: 7 }).a; } 3172 })).a != 7; 3173 }) ? function (O, P, Attributes) { 3174 var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$2(ObjectPrototype$1, P); 3175 if (ObjectPrototypeDescriptor) delete ObjectPrototype$1[P]; 3176 nativeDefineProperty$1(O, P, Attributes); 3177 if (ObjectPrototypeDescriptor && O !== ObjectPrototype$1) { 3178 nativeDefineProperty$1(ObjectPrototype$1, P, ObjectPrototypeDescriptor); 3179 } 3180 } : nativeDefineProperty$1; 3181 3182 var wrap = function (tag, description) { 3183 var symbol = AllSymbols[tag] = objectCreate($Symbol[PROTOTYPE$1]); 3184 setInternalState$1(symbol, { 3185 type: SYMBOL, 3186 tag: tag, 3187 description: description 3188 }); 3189 if (!descriptors) symbol.description = description; 3190 return symbol; 3191 }; 3192 3193 var isSymbol = useSymbolAsUid ? function (it) { 3194 return typeof it == 'symbol'; 3195 } : function (it) { 3196 return Object(it) instanceof $Symbol; 3197 }; 3198 3199 var $defineProperty = function defineProperty(O, P, Attributes) { 3200 if (O === ObjectPrototype$1) $defineProperty(ObjectPrototypeSymbols, P, Attributes); 3201 anObject(O); 3202 var key = toPrimitive(P, true); 3203 anObject(Attributes); 3204 if (has(AllSymbols, key)) { 3205 if (!Attributes.enumerable) { 3206 if (!has(O, HIDDEN)) nativeDefineProperty$1(O, HIDDEN, createPropertyDescriptor(1, {})); 3207 O[HIDDEN][key] = true; 3208 } else { 3209 if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false; 3210 Attributes = objectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) }); 3211 } return setSymbolDescriptor(O, key, Attributes); 3212 } return nativeDefineProperty$1(O, key, Attributes); 3213 }; 3214 3215 var $defineProperties = function defineProperties(O, Properties) { 3216 anObject(O); 3217 var properties = toIndexedObject(Properties); 3218 var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties)); 3219 $forEach$1(keys, function (key) { 3220 if (!descriptors || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]); 3221 }); 3222 return O; 3223 }; 3224 3225 var $create = function create(O, Properties) { 3226 return Properties === undefined ? objectCreate(O) : $defineProperties(objectCreate(O), Properties); 3227 }; 3228 3229 var $propertyIsEnumerable = function propertyIsEnumerable(V) { 3230 var P = toPrimitive(V, true); 3231 var enumerable = nativePropertyIsEnumerable$1.call(this, P); 3232 if (this === ObjectPrototype$1 && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false; 3233 return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true; 3234 }; 3235 3236 var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) { 3237 var it = toIndexedObject(O); 3238 var key = toPrimitive(P, true); 3239 if (it === ObjectPrototype$1 && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return; 3240 var descriptor = nativeGetOwnPropertyDescriptor$2(it, key); 3241 if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) { 3242 descriptor.enumerable = true; 3243 } 3244 return descriptor; 3245 }; 3246 3247 var $getOwnPropertyNames = function getOwnPropertyNames(O) { 3248 var names = nativeGetOwnPropertyNames$2(toIndexedObject(O)); 3249 var result = []; 3250 $forEach$1(names, function (key) { 3251 if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key); 3252 }); 3253 return result; 3254 }; 3255 3256 var $getOwnPropertySymbols = function getOwnPropertySymbols(O) { 3257 var IS_OBJECT_PROTOTYPE = O === ObjectPrototype$1; 3258 var names = nativeGetOwnPropertyNames$2(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O)); 3259 var result = []; 3260 $forEach$1(names, function (key) { 3261 if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype$1, key))) { 3262 result.push(AllSymbols[key]); 3263 } 3264 }); 3265 return result; 3266 }; 3267 3268 // `Symbol` constructor 3269 // https://tc39.es/ecma262/#sec-symbol-constructor 3270 if (!nativeSymbol) { 3271 $Symbol = function Symbol() { 3272 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor'); 3273 var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]); 3274 var tag = uid(description); 3275 var setter = function (value) { 3276 if (this === ObjectPrototype$1) setter.call(ObjectPrototypeSymbols, value); 3277 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; 3278 setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value)); 3279 }; 3280 if (descriptors && USE_SETTER) setSymbolDescriptor(ObjectPrototype$1, tag, { configurable: true, set: setter }); 3281 return wrap(tag, description); 3282 }; 3283 3284 redefine($Symbol[PROTOTYPE$1], 'toString', function toString() { 3285 return getInternalState(this).tag; 3286 }); 3287 3288 redefine($Symbol, 'withoutSetter', function (description) { 3289 return wrap(uid(description), description); 3290 }); 3291 3292 objectPropertyIsEnumerable.f = $propertyIsEnumerable; 3293 objectDefineProperty.f = $defineProperty; 3294 objectGetOwnPropertyDescriptor.f = $getOwnPropertyDescriptor; 3295 objectGetOwnPropertyNames.f = objectGetOwnPropertyNamesExternal.f = $getOwnPropertyNames; 3296 objectGetOwnPropertySymbols.f = $getOwnPropertySymbols; 3297 3298 wellKnownSymbolWrapped.f = function (name) { 3299 return wrap(wellKnownSymbol(name), name); 3300 }; 3301 3302 if (descriptors) { 3303 // https://github.com/tc39/proposal-Symbol-description 3304 nativeDefineProperty$1($Symbol[PROTOTYPE$1], 'description', { 3305 configurable: true, 3306 get: function description() { 3307 return getInternalState(this).description; 3308 } 3309 }); 3310 { 3311 redefine(ObjectPrototype$1, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true }); 3312 } 3313 } 3314 } 3315 3316 _export({ global: true, wrap: true, forced: !nativeSymbol, sham: !nativeSymbol }, { 3317 Symbol: $Symbol 3318 }); 3319 3320 $forEach$1(objectKeys(WellKnownSymbolsStore$1), function (name) { 3321 defineWellKnownSymbol(name); 3322 }); 3323 3324 _export({ target: SYMBOL, stat: true, forced: !nativeSymbol }, { 3325 // `Symbol.for` method 3326 // https://tc39.es/ecma262/#sec-symbol.for 3327 'for': function (key) { 3328 var string = String(key); 3329 if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string]; 3330 var symbol = $Symbol(string); 3331 StringToSymbolRegistry[string] = symbol; 3332 SymbolToStringRegistry[symbol] = string; 3333 return symbol; 3334 }, 3335 // `Symbol.keyFor` method 3336 // https://tc39.es/ecma262/#sec-symbol.keyfor 3337 keyFor: function keyFor(sym) { 3338 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol'); 3339 if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym]; 3340 }, 3341 useSetter: function () { USE_SETTER = true; }, 3342 useSimple: function () { USE_SETTER = false; } 3343 }); 3344 3345 _export({ target: 'Object', stat: true, forced: !nativeSymbol, sham: !descriptors }, { 3346 // `Object.create` method 3347 // https://tc39.es/ecma262/#sec-object.create 3348 create: $create, 3349 // `Object.defineProperty` method 3350 // https://tc39.es/ecma262/#sec-object.defineproperty 3351 defineProperty: $defineProperty, 3352 // `Object.defineProperties` method 3353 // https://tc39.es/ecma262/#sec-object.defineproperties 3354 defineProperties: $defineProperties, 3355 // `Object.getOwnPropertyDescriptor` method 3356 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors 3357 getOwnPropertyDescriptor: $getOwnPropertyDescriptor 3358 }); 3359 3360 _export({ target: 'Object', stat: true, forced: !nativeSymbol }, { 3361 // `Object.getOwnPropertyNames` method 3362 // https://tc39.es/ecma262/#sec-object.getownpropertynames 3363 getOwnPropertyNames: $getOwnPropertyNames, 3364 // `Object.getOwnPropertySymbols` method 3365 // https://tc39.es/ecma262/#sec-object.getownpropertysymbols 3366 getOwnPropertySymbols: $getOwnPropertySymbols 3367 }); 3368 3369 // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives 3370 // https://bugs.chromium.org/p/v8/issues/detail?id=3443 3371 _export({ target: 'Object', stat: true, forced: fails(function () { objectGetOwnPropertySymbols.f(1); }) }, { 3372 getOwnPropertySymbols: function getOwnPropertySymbols(it) { 3373 return objectGetOwnPropertySymbols.f(toObject(it)); 3374 } 3375 }); 3376 3377 // `JSON.stringify` method behavior with symbols 3378 // https://tc39.es/ecma262/#sec-json.stringify 3379 if ($stringify) { 3380 var FORCED_JSON_STRINGIFY = !nativeSymbol || fails(function () { 3381 var symbol = $Symbol(); 3382 // MS Edge converts symbol values to JSON as {} 3383 return $stringify([symbol]) != '[null]' 3384 // WebKit converts symbol values to JSON as null 3385 || $stringify({ a: symbol }) != '{}' 3386 // V8 throws on boxed symbols 3387 || $stringify(Object(symbol)) != '{}'; 3388 }); 3389 3390 _export({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, { 3391 // eslint-disable-next-line no-unused-vars 3392 stringify: function stringify(it, replacer, space) { 3393 var args = [it]; 3394 var index = 1; 3395 var $replacer; 3396 while (arguments.length > index) args.push(arguments[index++]); 3397 $replacer = replacer; 3398 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined 3399 if (!isArray(replacer)) replacer = function (key, value) { 3400 if (typeof $replacer == 'function') value = $replacer.call(this, key, value); 3401 if (!isSymbol(value)) return value; 3402 }; 3403 args[1] = replacer; 3404 return $stringify.apply(null, args); 3405 } 3406 }); 3407 } 3408 3409 // `Symbol.prototype[@@toPrimitive]` method 3410 // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive 3411 if (!$Symbol[PROTOTYPE$1][TO_PRIMITIVE]) { 3412 createNonEnumerableProperty($Symbol[PROTOTYPE$1], TO_PRIMITIVE, $Symbol[PROTOTYPE$1].valueOf); 3413 } 3414 // `Symbol.prototype[@@toStringTag]` property 3415 // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag 3416 setToStringTag($Symbol, SYMBOL); 3417 3418 hiddenKeys[HIDDEN] = true; 3419 3420 var defineProperty$7 = objectDefineProperty.f; 3421 3422 3423 var NativeSymbol = global_1.Symbol; 3424 3425 if (descriptors && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) || 3426 // Safari 12 bug 3427 NativeSymbol().description !== undefined 3428 )) { 3429 var EmptyStringDescriptionStore = {}; 3430 // wrap Symbol constructor for correct work with undefined description 3431 var SymbolWrapper = function Symbol() { 3432 var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]); 3433 var result = this instanceof SymbolWrapper 3434 ? new NativeSymbol(description) 3435 // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)' 3436 : description === undefined ? NativeSymbol() : NativeSymbol(description); 3437 if (description === '') EmptyStringDescriptionStore[result] = true; 3438 return result; 3439 }; 3440 copyConstructorProperties(SymbolWrapper, NativeSymbol); 3441 var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype; 3442 symbolPrototype.constructor = SymbolWrapper; 3443 3444 var symbolToString = symbolPrototype.toString; 3445 var native = String(NativeSymbol('test')) == 'Symbol(test)'; 3446 var regexp = /^Symbol\((.*)\)[^)]+$/; 3447 defineProperty$7(symbolPrototype, 'description', { 3448 configurable: true, 3449 get: function description() { 3450 var symbol = isObject(this) ? this.valueOf() : this; 3451 var string = symbolToString.call(symbol); 3452 if (has(EmptyStringDescriptionStore, symbol)) return ''; 3453 var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1'); 3454 return desc === '' ? undefined : desc; 3455 } 3456 }); 3457 3458 _export({ global: true, forced: true }, { 3459 Symbol: SymbolWrapper 3460 }); 3461 } 3462 3463 // `Symbol.species` well-known symbol 3464 // https://tc39.es/ecma262/#sec-symbol.species 3465 defineWellKnownSymbol('species'); 3466 3467 // `Array.prototype.fill` method implementation 3468 // https://tc39.es/ecma262/#sec-array.prototype.fill 3469 var arrayFill = function fill(value /* , start = 0, end = @length */) { 3470 var O = toObject(this); 3471 var length = toLength(O.length); 3472 var argumentsLength = arguments.length; 3473 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3474 var end = argumentsLength > 2 ? arguments[2] : undefined; 3475 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3476 while (endPos > index) O[index++] = value; 3477 return O; 3478 }; 3479 3480 var UNSCOPABLES = wellKnownSymbol('unscopables'); 3481 var ArrayPrototype = Array.prototype; 3482 3483 // Array.prototype[@@unscopables] 3484 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 3485 if (ArrayPrototype[UNSCOPABLES] == undefined) { 3486 objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, { 3487 configurable: true, 3488 value: objectCreate(null) 3489 }); 3490 } 3491 3492 // add a key to Array.prototype[@@unscopables] 3493 var addToUnscopables = function (key) { 3494 ArrayPrototype[UNSCOPABLES][key] = true; 3495 }; 3496 3497 // `Array.prototype.fill` method 3498 // https://tc39.es/ecma262/#sec-array.prototype.fill 3499 _export({ target: 'Array', proto: true }, { 3500 fill: arrayFill 3501 }); 3502 3503 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 3504 addToUnscopables('fill'); 3505 3506 var $includes = arrayIncludes.includes; 3507 3508 3509 3510 var USES_TO_LENGTH$4 = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 }); 3511 3512 // `Array.prototype.includes` method 3513 // https://tc39.es/ecma262/#sec-array.prototype.includes 3514 _export({ target: 'Array', proto: true, forced: !USES_TO_LENGTH$4 }, { 3515 includes: function includes(el /* , fromIndex = 0 */) { 3516 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); 3517 } 3518 }); 3519 3520 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 3521 addToUnscopables('includes'); 3522 3523 var iterators = {}; 3524 3525 var ITERATOR = wellKnownSymbol('iterator'); 3526 var BUGGY_SAFARI_ITERATORS = false; 3527 3528 var returnThis = function () { return this; }; 3529 3530 // `%IteratorPrototype%` object 3531 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3532 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3533 3534 if ([].keys) { 3535 arrayIterator = [].keys(); 3536 // Safari 8 has buggy iterators w/o `next` 3537 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true; 3538 else { 3539 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3540 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3541 } 3542 } 3543 3544 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3545 var test = {}; 3546 // FF44- legacy iterators case 3547 return IteratorPrototype[ITERATOR].call(test) !== test; 3548 }); 3549 3550 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; 3551 3552 // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() 3553 if ( !has(IteratorPrototype, ITERATOR)) { 3554 createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis); 3555 } 3556 3557 var iteratorsCore = { 3558 IteratorPrototype: IteratorPrototype, 3559 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3560 }; 3561 3562 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3563 3564 3565 3566 3567 3568 var returnThis$1 = function () { return this; }; 3569 3570 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3571 var TO_STRING_TAG = NAME + ' Iterator'; 3572 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) }); 3573 setToStringTag(IteratorConstructor, TO_STRING_TAG, false); 3574 iterators[TO_STRING_TAG] = returnThis$1; 3575 return IteratorConstructor; 3576 }; 3577 3578 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 3579 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 3580 var ITERATOR$1 = wellKnownSymbol('iterator'); 3581 var KEYS = 'keys'; 3582 var VALUES = 'values'; 3583 var ENTRIES = 'entries'; 3584 3585 var returnThis$2 = function () { return this; }; 3586 3587 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 3588 createIteratorConstructor(IteratorConstructor, NAME, next); 3589 3590 var getIterationMethod = function (KIND) { 3591 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 3592 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 3593 switch (KIND) { 3594 case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; 3595 case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; 3596 case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; 3597 } return function () { return new IteratorConstructor(this); }; 3598 }; 3599 3600 var TO_STRING_TAG = NAME + ' Iterator'; 3601 var INCORRECT_VALUES_NAME = false; 3602 var IterablePrototype = Iterable.prototype; 3603 var nativeIterator = IterablePrototype[ITERATOR$1] 3604 || IterablePrototype['@@iterator'] 3605 || DEFAULT && IterablePrototype[DEFAULT]; 3606 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 3607 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 3608 var CurrentIteratorPrototype, methods, KEY; 3609 3610 // fix native 3611 if (anyNativeIterator) { 3612 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 3613 if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) { 3614 if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 3615 if (objectSetPrototypeOf) { 3616 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 3617 } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') { 3618 createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR$1, returnThis$2); 3619 } 3620 } 3621 // Set @@toStringTag to native iterators 3622 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); 3623 } 3624 } 3625 3626 // fix Array#{values, @@iterator}.name in V8 / FF 3627 if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 3628 INCORRECT_VALUES_NAME = true; 3629 defaultIterator = function values() { return nativeIterator.call(this); }; 3630 } 3631 3632 // define iterator 3633 if ( IterablePrototype[ITERATOR$1] !== defaultIterator) { 3634 createNonEnumerableProperty(IterablePrototype, ITERATOR$1, defaultIterator); 3635 } 3636 iterators[NAME] = defaultIterator; 3637 3638 // export additional methods 3639 if (DEFAULT) { 3640 methods = { 3641 values: getIterationMethod(VALUES), 3642 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 3643 entries: getIterationMethod(ENTRIES) 3644 }; 3645 if (FORCED) for (KEY in methods) { 3646 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 3647 redefine(IterablePrototype, KEY, methods[KEY]); 3648 } 3649 } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods); 3650 } 3651 3652 return methods; 3653 }; 3654 3655 var ARRAY_ITERATOR = 'Array Iterator'; 3656 var setInternalState$2 = internalState.set; 3657 var getInternalState$1 = internalState.getterFor(ARRAY_ITERATOR); 3658 3659 // `Array.prototype.entries` method 3660 // https://tc39.es/ecma262/#sec-array.prototype.entries 3661 // `Array.prototype.keys` method 3662 // https://tc39.es/ecma262/#sec-array.prototype.keys 3663 // `Array.prototype.values` method 3664 // https://tc39.es/ecma262/#sec-array.prototype.values 3665 // `Array.prototype[@@iterator]` method 3666 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 3667 // `CreateArrayIterator` internal method 3668 // https://tc39.es/ecma262/#sec-createarrayiterator 3669 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 3670 setInternalState$2(this, { 3671 type: ARRAY_ITERATOR, 3672 target: toIndexedObject(iterated), // target 3673 index: 0, // next index 3674 kind: kind // kind 3675 }); 3676 // `%ArrayIteratorPrototype%.next` method 3677 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 3678 }, function () { 3679 var state = getInternalState$1(this); 3680 var target = state.target; 3681 var kind = state.kind; 3682 var index = state.index++; 3683 if (!target || index >= target.length) { 3684 state.target = undefined; 3685 return { value: undefined, done: true }; 3686 } 3687 if (kind == 'keys') return { value: index, done: false }; 3688 if (kind == 'values') return { value: target[index], done: false }; 3689 return { value: [index, target[index]], done: false }; 3690 }, 'values'); 3691 3692 // argumentsList[@@iterator] is %ArrayProto_values% 3693 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 3694 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 3695 iterators.Arguments = iterators.Array; 3696 3697 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 3698 addToUnscopables('keys'); 3699 addToUnscopables('values'); 3700 addToUnscopables('entries'); 3701 3702 var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('slice'); 3703 var USES_TO_LENGTH$5 = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 }); 3704 3705 var SPECIES$5 = wellKnownSymbol('species'); 3706 var nativeSlice = [].slice; 3707 var max$3 = Math.max; 3708 3709 // `Array.prototype.slice` method 3710 // https://tc39.es/ecma262/#sec-array.prototype.slice 3711 // fallback for not array-like ES3 strings and DOM objects 3712 _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 || !USES_TO_LENGTH$5 }, { 3713 slice: function slice(start, end) { 3714 var O = toIndexedObject(this); 3715 var length = toLength(O.length); 3716 var k = toAbsoluteIndex(start, length); 3717 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3718 // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible 3719 var Constructor, result, n; 3720 if (isArray(O)) { 3721 Constructor = O.constructor; 3722 // cross-realm fallback 3723 if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) { 3724 Constructor = undefined; 3725 } else if (isObject(Constructor)) { 3726 Constructor = Constructor[SPECIES$5]; 3727 if (Constructor === null) Constructor = undefined; 3728 } 3729 if (Constructor === Array || Constructor === undefined) { 3730 return nativeSlice.call(O, k, fin); 3731 } 3732 } 3733 result = new (Constructor === undefined ? Array : Constructor)(max$3(fin - k, 0)); 3734 for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]); 3735 result.length = n; 3736 return result; 3737 } 3738 }); 3739 3740 // `Array[@@species]` getter 3741 // https://tc39.es/ecma262/#sec-get-array-@@species 3742 setSpecies('Array'); 3743 3744 var arrayBufferNative = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined'; 3745 3746 var redefineAll = function (target, src, options) { 3747 for (var key in src) redefine(target, key, src[key], options); 3748 return target; 3749 }; 3750 3751 var anInstance = function (it, Constructor, name) { 3752 if (!(it instanceof Constructor)) { 3753 throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation'); 3754 } return it; 3755 }; 3756 3757 // `ToIndex` abstract operation 3758 // https://tc39.es/ecma262/#sec-toindex 3759 var toIndex = function (it) { 3760 if (it === undefined) return 0; 3761 var number = toInteger(it); 3762 var length = toLength(number); 3763 if (number !== length) throw RangeError('Wrong length or index'); 3764 return length; 3765 }; 3766 3767 // IEEE754 conversions based on https://github.com/feross/ieee754 3768 // eslint-disable-next-line no-shadow-restricted-names 3769 var Infinity$1 = 1 / 0; 3770 var abs = Math.abs; 3771 var pow = Math.pow; 3772 var floor$2 = Math.floor; 3773 var log = Math.log; 3774 var LN2 = Math.LN2; 3775 3776 var pack = function (number, mantissaLength, bytes) { 3777 var buffer = new Array(bytes); 3778 var exponentLength = bytes * 8 - mantissaLength - 1; 3779 var eMax = (1 << exponentLength) - 1; 3780 var eBias = eMax >> 1; 3781 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3782 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3783 var index = 0; 3784 var exponent, mantissa, c; 3785 number = abs(number); 3786 // eslint-disable-next-line no-self-compare 3787 if (number != number || number === Infinity$1) { 3788 // eslint-disable-next-line no-self-compare 3789 mantissa = number != number ? 1 : 0; 3790 exponent = eMax; 3791 } else { 3792 exponent = floor$2(log(number) / LN2); 3793 if (number * (c = pow(2, -exponent)) < 1) { 3794 exponent--; 3795 c *= 2; 3796 } 3797 if (exponent + eBias >= 1) { 3798 number += rt / c; 3799 } else { 3800 number += rt * pow(2, 1 - eBias); 3801 } 3802 if (number * c >= 2) { 3803 exponent++; 3804 c /= 2; 3805 } 3806 if (exponent + eBias >= eMax) { 3807 mantissa = 0; 3808 exponent = eMax; 3809 } else if (exponent + eBias >= 1) { 3810 mantissa = (number * c - 1) * pow(2, mantissaLength); 3811 exponent = exponent + eBias; 3812 } else { 3813 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3814 exponent = 0; 3815 } 3816 } 3817 for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8); 3818 exponent = exponent << mantissaLength | mantissa; 3819 exponentLength += mantissaLength; 3820 for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8); 3821 buffer[--index] |= sign * 128; 3822 return buffer; 3823 }; 3824 3825 var unpack = function (buffer, mantissaLength) { 3826 var bytes = buffer.length; 3827 var exponentLength = bytes * 8 - mantissaLength - 1; 3828 var eMax = (1 << exponentLength) - 1; 3829 var eBias = eMax >> 1; 3830 var nBits = exponentLength - 7; 3831 var index = bytes - 1; 3832 var sign = buffer[index--]; 3833 var exponent = sign & 127; 3834 var mantissa; 3835 sign >>= 7; 3836 for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8); 3837 mantissa = exponent & (1 << -nBits) - 1; 3838 exponent >>= -nBits; 3839 nBits += mantissaLength; 3840 for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8); 3841 if (exponent === 0) { 3842 exponent = 1 - eBias; 3843 } else if (exponent === eMax) { 3844 return mantissa ? NaN : sign ? -Infinity$1 : Infinity$1; 3845 } else { 3846 mantissa = mantissa + pow(2, mantissaLength); 3847 exponent = exponent - eBias; 3848 } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3849 }; 3850 3851 var ieee754 = { 3852 pack: pack, 3853 unpack: unpack 3854 }; 3855 3856 var getOwnPropertyNames$2 = objectGetOwnPropertyNames.f; 3857 var defineProperty$8 = objectDefineProperty.f; 3858 3859 3860 3861 3862 var getInternalState$2 = internalState.get; 3863 var setInternalState$3 = internalState.set; 3864 var ARRAY_BUFFER = 'ArrayBuffer'; 3865 var DATA_VIEW = 'DataView'; 3866 var PROTOTYPE$2 = 'prototype'; 3867 var WRONG_LENGTH = 'Wrong length'; 3868 var WRONG_INDEX = 'Wrong index'; 3869 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3870 var $ArrayBuffer = NativeArrayBuffer; 3871 var $DataView = global_1[DATA_VIEW]; 3872 var $DataViewPrototype = $DataView && $DataView[PROTOTYPE$2]; 3873 var ObjectPrototype$2 = Object.prototype; 3874 var RangeError$1 = global_1.RangeError; 3875 3876 var packIEEE754 = ieee754.pack; 3877 var unpackIEEE754 = ieee754.unpack; 3878 3879 var packInt8 = function (number) { 3880 return [number & 0xFF]; 3881 }; 3882 3883 var packInt16 = function (number) { 3884 return [number & 0xFF, number >> 8 & 0xFF]; 3885 }; 3886 3887 var packInt32 = function (number) { 3888 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3889 }; 3890 3891 var unpackInt32 = function (buffer) { 3892 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3893 }; 3894 3895 var packFloat32 = function (number) { 3896 return packIEEE754(number, 23, 4); 3897 }; 3898 3899 var packFloat64 = function (number) { 3900 return packIEEE754(number, 52, 8); 3901 }; 3902 3903 var addGetter = function (Constructor, key) { 3904 defineProperty$8(Constructor[PROTOTYPE$2], key, { get: function () { return getInternalState$2(this)[key]; } }); 3905 }; 3906 3907 var get$1 = function (view, count, index, isLittleEndian) { 3908 var intIndex = toIndex(index); 3909 var store = getInternalState$2(view); 3910 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3911 var bytes = getInternalState$2(store.buffer).bytes; 3912 var start = intIndex + store.byteOffset; 3913 var pack = bytes.slice(start, start + count); 3914 return isLittleEndian ? pack : pack.reverse(); 3915 }; 3916 3917 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3918 var intIndex = toIndex(index); 3919 var store = getInternalState$2(view); 3920 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3921 var bytes = getInternalState$2(store.buffer).bytes; 3922 var start = intIndex + store.byteOffset; 3923 var pack = conversion(+value); 3924 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3925 }; 3926 3927 if (!arrayBufferNative) { 3928 $ArrayBuffer = function ArrayBuffer(length) { 3929 anInstance(this, $ArrayBuffer, ARRAY_BUFFER); 3930 var byteLength = toIndex(length); 3931 setInternalState$3(this, { 3932 bytes: arrayFill.call(new Array(byteLength), 0), 3933 byteLength: byteLength 3934 }); 3935 if (!descriptors) this.byteLength = byteLength; 3936 }; 3937 3938 $DataView = function DataView(buffer, byteOffset, byteLength) { 3939 anInstance(this, $DataView, DATA_VIEW); 3940 anInstance(buffer, $ArrayBuffer, DATA_VIEW); 3941 var bufferLength = getInternalState$2(buffer).byteLength; 3942 var offset = toInteger(byteOffset); 3943 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3944 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3945 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3946 setInternalState$3(this, { 3947 buffer: buffer, 3948 byteLength: byteLength, 3949 byteOffset: offset 3950 }); 3951 if (!descriptors) { 3952 this.buffer = buffer; 3953 this.byteLength = byteLength; 3954 this.byteOffset = offset; 3955 } 3956 }; 3957 3958 if (descriptors) { 3959 addGetter($ArrayBuffer, 'byteLength'); 3960 addGetter($DataView, 'buffer'); 3961 addGetter($DataView, 'byteLength'); 3962 addGetter($DataView, 'byteOffset'); 3963 } 3964 3965 redefineAll($DataView[PROTOTYPE$2], { 3966 getInt8: function getInt8(byteOffset) { 3967 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3968 }, 3969 getUint8: function getUint8(byteOffset) { 3970 return get$1(this, 1, byteOffset)[0]; 3971 }, 3972 getInt16: function getInt16(byteOffset /* , littleEndian */) { 3973 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3974 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3975 }, 3976 getUint16: function getUint16(byteOffset /* , littleEndian */) { 3977 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3978 return bytes[1] << 8 | bytes[0]; 3979 }, 3980 getInt32: function getInt32(byteOffset /* , littleEndian */) { 3981 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3982 }, 3983 getUint32: function getUint32(byteOffset /* , littleEndian */) { 3984 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3985 }, 3986 getFloat32: function getFloat32(byteOffset /* , littleEndian */) { 3987 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3988 }, 3989 getFloat64: function getFloat64(byteOffset /* , littleEndian */) { 3990 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3991 }, 3992 setInt8: function setInt8(byteOffset, value) { 3993 set$1(this, 1, byteOffset, packInt8, value); 3994 }, 3995 setUint8: function setUint8(byteOffset, value) { 3996 set$1(this, 1, byteOffset, packInt8, value); 3997 }, 3998 setInt16: function setInt16(byteOffset, value /* , littleEndian */) { 3999 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 4000 }, 4001 setUint16: function setUint16(byteOffset, value /* , littleEndian */) { 4002 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 4003 }, 4004 setInt32: function setInt32(byteOffset, value /* , littleEndian */) { 4005 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 4006 }, 4007 setUint32: function setUint32(byteOffset, value /* , littleEndian */) { 4008 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 4009 }, 4010 setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { 4011 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 4012 }, 4013 setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { 4014 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 4015 } 4016 }); 4017 } else { 4018 if (!fails(function () { 4019 NativeArrayBuffer(1); 4020 }) || !fails(function () { 4021 new NativeArrayBuffer(-1); // eslint-disable-line no-new 4022 }) || fails(function () { 4023 new NativeArrayBuffer(); // eslint-disable-line no-new 4024 new NativeArrayBuffer(1.5); // eslint-disable-line no-new 4025 new NativeArrayBuffer(NaN); // eslint-disable-line no-new 4026 return NativeArrayBuffer.name != ARRAY_BUFFER; 4027 })) { 4028 $ArrayBuffer = function ArrayBuffer(length) { 4029 anInstance(this, $ArrayBuffer); 4030 return new NativeArrayBuffer(toIndex(length)); 4031 }; 4032 var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$2] = NativeArrayBuffer[PROTOTYPE$2]; 4033 for (var keys$3 = getOwnPropertyNames$2(NativeArrayBuffer), j$1 = 0, key$1; keys$3.length > j$1;) { 4034 if (!((key$1 = keys$3[j$1++]) in $ArrayBuffer)) { 4035 createNonEnumerableProperty($ArrayBuffer, key$1, NativeArrayBuffer[key$1]); 4036 } 4037 } 4038 ArrayBufferPrototype.constructor = $ArrayBuffer; 4039 } 4040 4041 // WebKit bug - the same parent prototype for typed arrays and data view 4042 if (objectSetPrototypeOf && objectGetPrototypeOf($DataViewPrototype) !== ObjectPrototype$2) { 4043 objectSetPrototypeOf($DataViewPrototype, ObjectPrototype$2); 4044 } 4045 4046 // iOS Safari 7.x bug 4047 var testView = new $DataView(new $ArrayBuffer(2)); 4048 var nativeSetInt8 = $DataViewPrototype.setInt8; 4049 testView.setInt8(0, 2147483648); 4050 testView.setInt8(1, 2147483649); 4051 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, { 4052 setInt8: function setInt8(byteOffset, value) { 4053 nativeSetInt8.call(this, byteOffset, value << 24 >> 24); 4054 }, 4055 setUint8: function setUint8(byteOffset, value) { 4056 nativeSetInt8.call(this, byteOffset, value << 24 >> 24); 4057 } 4058 }, { unsafe: true }); 4059 } 4060 4061 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 4062 setToStringTag($DataView, DATA_VIEW); 4063 4064 var arrayBuffer = { 4065 ArrayBuffer: $ArrayBuffer, 4066 DataView: $DataView 4067 }; 4068 4069 var ARRAY_BUFFER$1 = 'ArrayBuffer'; 4070 var ArrayBuffer$1 = arrayBuffer[ARRAY_BUFFER$1]; 4071 var NativeArrayBuffer$1 = global_1[ARRAY_BUFFER$1]; 4072 4073 // `ArrayBuffer` constructor 4074 // https://tc39.es/ecma262/#sec-arraybuffer-constructor 4075 _export({ global: true, forced: NativeArrayBuffer$1 !== ArrayBuffer$1 }, { 4076 ArrayBuffer: ArrayBuffer$1 4077 }); 4078 4079 setSpecies(ARRAY_BUFFER$1); 4080 4081 var notARegexp = function (it) { 4082 if (isRegexp(it)) { 4083 throw TypeError("The method doesn't accept regular expressions"); 4084 } return it; 4085 }; 4086 4087 var MATCH$2 = wellKnownSymbol('match'); 4088 4089 var correctIsRegexpLogic = function (METHOD_NAME) { 4090 var regexp = /./; 4091 try { 4092 '/./'[METHOD_NAME](regexp); 4093 } catch (error1) { 4094 try { 4095 regexp[MATCH$2] = false; 4096 return '/./'[METHOD_NAME](regexp); 4097 } catch (error2) { /* empty */ } 4098 } return false; 4099 }; 4100 4101 // `String.prototype.includes` method 4102 // https://tc39.es/ecma262/#sec-string.prototype.includes 4103 _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes') }, { 4104 includes: function includes(searchString /* , position = 0 */) { 4105 return !!~String(requireObjectCoercible(this)) 4106 .indexOf(notARegexp(searchString), arguments.length > 1 ? arguments[1] : undefined); 4107 } 4108 }); 4109 4110 var non = '\u200B\u0085\u180E'; 4111 4112 // check that a method works with the correct list 4113 // of whitespaces and has a correct name 4114 var stringTrimForced = function (METHOD_NAME) { 4115 return fails(function () { 4116 return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME; 4117 }); 4118 }; 4119 4120 var $trim = stringTrim.trim; 4121 4122 4123 // `String.prototype.trim` method 4124 // https://tc39.es/ecma262/#sec-string.prototype.trim 4125 _export({ target: 'String', proto: true, forced: stringTrimForced('trim') }, { 4126 trim: function trim() { 4127 return $trim(this); 4128 } 4129 }); 4130 4131 var ITERATOR$2 = wellKnownSymbol('iterator'); 4132 var SAFE_CLOSING = false; 4133 4134 try { 4135 var called = 0; 4136 var iteratorWithReturn = { 4137 next: function () { 4138 return { done: !!called++ }; 4139 }, 4140 'return': function () { 4141 SAFE_CLOSING = true; 4142 } 4143 }; 4144 iteratorWithReturn[ITERATOR$2] = function () { 4145 return this; 4146 }; 4147 // eslint-disable-next-line no-throw-literal 4148 Array.from(iteratorWithReturn, function () { throw 2; }); 4149 } catch (error) { /* empty */ } 4150 4151 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4152 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4153 var ITERATION_SUPPORT = false; 4154 try { 4155 var object = {}; 4156 object[ITERATOR$2] = function () { 4157 return { 4158 next: function () { 4159 return { done: ITERATION_SUPPORT = true }; 4160 } 4161 }; 4162 }; 4163 exec(object); 4164 } catch (error) { /* empty */ } 4165 return ITERATION_SUPPORT; 4166 }; 4167 4168 var defineProperty$9 = objectDefineProperty.f; 4169 4170 4171 4172 4173 4174 var Int8Array$1 = global_1.Int8Array; 4175 var Int8ArrayPrototype = Int8Array$1 && Int8Array$1.prototype; 4176 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4177 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4178 var TypedArray = Int8Array$1 && objectGetPrototypeOf(Int8Array$1); 4179 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4180 var ObjectPrototype$3 = Object.prototype; 4181 var isPrototypeOf = ObjectPrototype$3.isPrototypeOf; 4182 4183 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 4184 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4185 // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4186 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4187 var TYPED_ARRAY_TAG_REQIRED = false; 4188 var NAME$1; 4189 4190 var TypedArrayConstructorsList = { 4191 Int8Array: 1, 4192 Uint8Array: 1, 4193 Uint8ClampedArray: 1, 4194 Int16Array: 2, 4195 Uint16Array: 2, 4196 Int32Array: 4, 4197 Uint32Array: 4, 4198 Float32Array: 4, 4199 Float64Array: 8 4200 }; 4201 4202 var BigIntArrayConstructorsList = { 4203 BigInt64Array: 8, 4204 BigUint64Array: 8 4205 }; 4206 4207 var isView = function isView(it) { 4208 if (!isObject(it)) return false; 4209 var klass = classof(it); 4210 return klass === 'DataView' 4211 || has(TypedArrayConstructorsList, klass) 4212 || has(BigIntArrayConstructorsList, klass); 4213 }; 4214 4215 var isTypedArray = function (it) { 4216 if (!isObject(it)) return false; 4217 var klass = classof(it); 4218 return has(TypedArrayConstructorsList, klass) 4219 || has(BigIntArrayConstructorsList, klass); 4220 }; 4221 4222 var aTypedArray = function (it) { 4223 if (isTypedArray(it)) return it; 4224 throw TypeError('Target is not a typed array'); 4225 }; 4226 4227 var aTypedArrayConstructor = function (C) { 4228 if (objectSetPrototypeOf) { 4229 if (isPrototypeOf.call(TypedArray, C)) return C; 4230 } else for (var ARRAY in TypedArrayConstructorsList) if (has(TypedArrayConstructorsList, NAME$1)) { 4231 var TypedArrayConstructor = global_1[ARRAY]; 4232 if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) { 4233 return C; 4234 } 4235 } throw TypeError('Target is not a typed array constructor'); 4236 }; 4237 4238 var exportTypedArrayMethod = function (KEY, property, forced) { 4239 if (!descriptors) return; 4240 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4241 var TypedArrayConstructor = global_1[ARRAY]; 4242 if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) { 4243 delete TypedArrayConstructor.prototype[KEY]; 4244 } 4245 } 4246 if (!TypedArrayPrototype[KEY] || forced) { 4247 redefine(TypedArrayPrototype, KEY, forced ? property 4248 : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4249 } 4250 }; 4251 4252 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4253 var ARRAY, TypedArrayConstructor; 4254 if (!descriptors) return; 4255 if (objectSetPrototypeOf) { 4256 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4257 TypedArrayConstructor = global_1[ARRAY]; 4258 if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) { 4259 delete TypedArrayConstructor[KEY]; 4260 } 4261 } 4262 if (!TypedArray[KEY] || forced) { 4263 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4264 try { 4265 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array$1[KEY] || property); 4266 } catch (error) { /* empty */ } 4267 } else return; 4268 } 4269 for (ARRAY in TypedArrayConstructorsList) { 4270 TypedArrayConstructor = global_1[ARRAY]; 4271 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4272 redefine(TypedArrayConstructor, KEY, property); 4273 } 4274 } 4275 }; 4276 4277 for (NAME$1 in TypedArrayConstructorsList) { 4278 if (!global_1[NAME$1]) NATIVE_ARRAY_BUFFER_VIEWS = false; 4279 } 4280 4281 // WebKit bug - typed arrays constructors prototype is Object.prototype 4282 if (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) { 4283 // eslint-disable-next-line no-shadow 4284 TypedArray = function TypedArray() { 4285 throw TypeError('Incorrect invocation'); 4286 }; 4287 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME$1 in TypedArrayConstructorsList) { 4288 if (global_1[NAME$1]) objectSetPrototypeOf(global_1[NAME$1], TypedArray); 4289 } 4290 } 4291 4292 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$3) { 4293 TypedArrayPrototype = TypedArray.prototype; 4294 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME$1 in TypedArrayConstructorsList) { 4295 if (global_1[NAME$1]) objectSetPrototypeOf(global_1[NAME$1].prototype, TypedArrayPrototype); 4296 } 4297 } 4298 4299 // WebKit bug - one more object in Uint8ClampedArray prototype chain 4300 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4301 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4302 } 4303 4304 if (descriptors && !has(TypedArrayPrototype, TO_STRING_TAG$3)) { 4305 TYPED_ARRAY_TAG_REQIRED = true; 4306 defineProperty$9(TypedArrayPrototype, TO_STRING_TAG$3, { get: function () { 4307 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4308 } }); 4309 for (NAME$1 in TypedArrayConstructorsList) if (global_1[NAME$1]) { 4310 createNonEnumerableProperty(global_1[NAME$1], TYPED_ARRAY_TAG, NAME$1); 4311 } 4312 } 4313 4314 var arrayBufferViewCore = { 4315 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4316 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4317 aTypedArray: aTypedArray, 4318 aTypedArrayConstructor: aTypedArrayConstructor, 4319 exportTypedArrayMethod: exportTypedArrayMethod, 4320 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4321 isView: isView, 4322 isTypedArray: isTypedArray, 4323 TypedArray: TypedArray, 4324 TypedArrayPrototype: TypedArrayPrototype 4325 }; 4326 4327 /* eslint-disable no-new */ 4328 4329 4330 4331 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4332 4333 var ArrayBuffer$2 = global_1.ArrayBuffer; 4334 var Int8Array$2 = global_1.Int8Array; 4335 4336 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4337 Int8Array$2(1); 4338 }) || !fails(function () { 4339 new Int8Array$2(-1); 4340 }) || !checkCorrectnessOfIteration(function (iterable) { 4341 new Int8Array$2(); 4342 new Int8Array$2(null); 4343 new Int8Array$2(1.5); 4344 new Int8Array$2(iterable); 4345 }, true) || fails(function () { 4346 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4347 return new Int8Array$2(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4348 }); 4349 4350 var toPositiveInteger = function (it) { 4351 var result = toInteger(it); 4352 if (result < 0) throw RangeError("The argument can't be less than 0"); 4353 return result; 4354 }; 4355 4356 var toOffset = function (it, BYTES) { 4357 var offset = toPositiveInteger(it); 4358 if (offset % BYTES) throw RangeError('Wrong offset'); 4359 return offset; 4360 }; 4361 4362 var ITERATOR$3 = wellKnownSymbol('iterator'); 4363 4364 var getIteratorMethod = function (it) { 4365 if (it != undefined) return it[ITERATOR$3] 4366 || it['@@iterator'] 4367 || iterators[classof(it)]; 4368 }; 4369 4370 var ITERATOR$4 = wellKnownSymbol('iterator'); 4371 var ArrayPrototype$1 = Array.prototype; 4372 4373 // check on default Array iterator 4374 var isArrayIteratorMethod = function (it) { 4375 return it !== undefined && (iterators.Array === it || ArrayPrototype$1[ITERATOR$4] === it); 4376 }; 4377 4378 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4379 4380 var typedArrayFrom = function from(source /* , mapfn, thisArg */) { 4381 var O = toObject(source); 4382 var argumentsLength = arguments.length; 4383 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4384 var mapping = mapfn !== undefined; 4385 var iteratorMethod = getIteratorMethod(O); 4386 var i, length, result, step, iterator, next; 4387 if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) { 4388 iterator = iteratorMethod.call(O); 4389 next = iterator.next; 4390 O = []; 4391 while (!(step = next.call(iterator)).done) { 4392 O.push(step.value); 4393 } 4394 } 4395 if (mapping && argumentsLength > 2) { 4396 mapfn = functionBindContext(mapfn, arguments[2], 2); 4397 } 4398 length = toLength(O.length); 4399 result = new (aTypedArrayConstructor$1(this))(length); 4400 for (i = 0; length > i; i++) { 4401 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4402 } 4403 return result; 4404 }; 4405 4406 var typedArrayConstructor = createCommonjsModule(function (module) { 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4426 4427 var forEach = arrayIteration.forEach; 4428 4429 4430 4431 4432 4433 4434 var getInternalState = internalState.get; 4435 var setInternalState = internalState.set; 4436 var nativeDefineProperty = objectDefineProperty.f; 4437 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4438 var round = Math.round; 4439 var RangeError = global_1.RangeError; 4440 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4441 var DataView = arrayBuffer.DataView; 4442 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4443 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4444 var TypedArray = arrayBufferViewCore.TypedArray; 4445 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4446 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4447 var isTypedArray = arrayBufferViewCore.isTypedArray; 4448 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4449 var WRONG_LENGTH = 'Wrong length'; 4450 4451 var fromList = function (C, list) { 4452 var index = 0; 4453 var length = list.length; 4454 var result = new (aTypedArrayConstructor(C))(length); 4455 while (length > index) result[index] = list[index++]; 4456 return result; 4457 }; 4458 4459 var addGetter = function (it, key) { 4460 nativeDefineProperty(it, key, { get: function () { 4461 return getInternalState(this)[key]; 4462 } }); 4463 }; 4464 4465 var isArrayBuffer = function (it) { 4466 var klass; 4467 return it instanceof ArrayBuffer || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4468 }; 4469 4470 var isTypedArrayIndex = function (target, key) { 4471 return isTypedArray(target) 4472 && typeof key != 'symbol' 4473 && key in target 4474 && String(+key) == String(key); 4475 }; 4476 4477 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4478 return isTypedArrayIndex(target, key = toPrimitive(key, true)) 4479 ? createPropertyDescriptor(2, target[key]) 4480 : nativeGetOwnPropertyDescriptor(target, key); 4481 }; 4482 4483 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4484 if (isTypedArrayIndex(target, key = toPrimitive(key, true)) 4485 && isObject(descriptor) 4486 && has(descriptor, 'value') 4487 && !has(descriptor, 'get') 4488 && !has(descriptor, 'set') 4489 // TODO: add validation descriptor w/o calling accessors 4490 && !descriptor.configurable 4491 && (!has(descriptor, 'writable') || descriptor.writable) 4492 && (!has(descriptor, 'enumerable') || descriptor.enumerable) 4493 ) { 4494 target[key] = descriptor.value; 4495 return target; 4496 } return nativeDefineProperty(target, key, descriptor); 4497 }; 4498 4499 if (descriptors) { 4500 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4501 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4502 objectDefineProperty.f = wrappedDefineProperty; 4503 addGetter(TypedArrayPrototype, 'buffer'); 4504 addGetter(TypedArrayPrototype, 'byteOffset'); 4505 addGetter(TypedArrayPrototype, 'byteLength'); 4506 addGetter(TypedArrayPrototype, 'length'); 4507 } 4508 4509 _export({ target: 'Object', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, { 4510 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4511 defineProperty: wrappedDefineProperty 4512 }); 4513 4514 module.exports = function (TYPE, wrapper, CLAMPED) { 4515 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4516 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4517 var GETTER = 'get' + TYPE; 4518 var SETTER = 'set' + TYPE; 4519 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4520 var TypedArrayConstructor = NativeTypedArrayConstructor; 4521 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4522 var exported = {}; 4523 4524 var getter = function (that, index) { 4525 var data = getInternalState(that); 4526 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4527 }; 4528 4529 var setter = function (that, index, value) { 4530 var data = getInternalState(that); 4531 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4532 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4533 }; 4534 4535 var addElement = function (that, index) { 4536 nativeDefineProperty(that, index, { 4537 get: function () { 4538 return getter(this, index); 4539 }, 4540 set: function (value) { 4541 return setter(this, index, value); 4542 }, 4543 enumerable: true 4544 }); 4545 }; 4546 4547 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4548 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4549 anInstance(that, TypedArrayConstructor, CONSTRUCTOR_NAME); 4550 var index = 0; 4551 var byteOffset = 0; 4552 var buffer, byteLength, length; 4553 if (!isObject(data)) { 4554 length = toIndex(data); 4555 byteLength = length * BYTES; 4556 buffer = new ArrayBuffer(byteLength); 4557 } else if (isArrayBuffer(data)) { 4558 buffer = data; 4559 byteOffset = toOffset(offset, BYTES); 4560 var $len = data.byteLength; 4561 if ($length === undefined) { 4562 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4563 byteLength = $len - byteOffset; 4564 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 4565 } else { 4566 byteLength = toLength($length) * BYTES; 4567 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 4568 } 4569 length = byteLength / BYTES; 4570 } else if (isTypedArray(data)) { 4571 return fromList(TypedArrayConstructor, data); 4572 } else { 4573 return typedArrayFrom.call(TypedArrayConstructor, data); 4574 } 4575 setInternalState(that, { 4576 buffer: buffer, 4577 byteOffset: byteOffset, 4578 byteLength: byteLength, 4579 length: length, 4580 view: new DataView(buffer) 4581 }); 4582 while (index < length) addElement(that, index++); 4583 }); 4584 4585 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 4586 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 4587 } else if (typedArrayConstructorsRequireWrappers) { 4588 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 4589 anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME); 4590 return inheritIfRequired(function () { 4591 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 4592 if (isArrayBuffer(data)) return $length !== undefined 4593 ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) 4594 : typedArrayOffset !== undefined 4595 ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) 4596 : new NativeTypedArrayConstructor(data); 4597 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 4598 return typedArrayFrom.call(TypedArrayConstructor, data); 4599 }(), dummy, TypedArrayConstructor); 4600 }); 4601 4602 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 4603 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 4604 if (!(key in TypedArrayConstructor)) { 4605 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 4606 } 4607 }); 4608 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 4609 } 4610 4611 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 4612 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 4613 } 4614 4615 if (TYPED_ARRAY_TAG) { 4616 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 4617 } 4618 4619 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 4620 4621 _export({ 4622 global: true, forced: TypedArrayConstructor != NativeTypedArrayConstructor, sham: !NATIVE_ARRAY_BUFFER_VIEWS 4623 }, exported); 4624 4625 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 4626 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 4627 } 4628 4629 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 4630 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 4631 } 4632 4633 setSpecies(CONSTRUCTOR_NAME); 4634 }; 4635 } else module.exports = function () { /* empty */ }; 4636 }); 4637 4638 // `Uint8Array` constructor 4639 // https://tc39.es/ecma262/#sec-typedarray-objects 4640 typedArrayConstructor('Uint8', function (init) { 4641 return function Uint8Array(data, byteOffset, length) { 4642 return init(this, data, byteOffset, length); 4643 }; 4644 }); 4645 4646 var min$5 = Math.min; 4647 4648 // `Array.prototype.copyWithin` method implementation 4649 // https://tc39.es/ecma262/#sec-array.prototype.copywithin 4650 var arrayCopyWithin = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) { 4651 var O = toObject(this); 4652 var len = toLength(O.length); 4653 var to = toAbsoluteIndex(target, len); 4654 var from = toAbsoluteIndex(start, len); 4655 var end = arguments.length > 2 ? arguments[2] : undefined; 4656 var count = min$5((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to); 4657 var inc = 1; 4658 if (from < to && to < from + count) { 4659 inc = -1; 4660 from += count - 1; 4661 to += count - 1; 4662 } 4663 while (count-- > 0) { 4664 if (from in O) O[to] = O[from]; 4665 else delete O[to]; 4666 to += inc; 4667 from += inc; 4668 } return O; 4669 }; 4670 4671 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 4672 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; 4673 4674 // `%TypedArray%.prototype.copyWithin` method 4675 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin 4676 exportTypedArrayMethod$1('copyWithin', function copyWithin(target, start /* , end */) { 4677 return arrayCopyWithin.call(aTypedArray$1(this), target, start, arguments.length > 2 ? arguments[2] : undefined); 4678 }); 4679 4680 var $every = arrayIteration.every; 4681 4682 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 4683 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 4684 4685 // `%TypedArray%.prototype.every` method 4686 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.every 4687 exportTypedArrayMethod$2('every', function every(callbackfn /* , thisArg */) { 4688 return $every(aTypedArray$2(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 4689 }); 4690 4691 var aTypedArray$3 = arrayBufferViewCore.aTypedArray; 4692 var exportTypedArrayMethod$3 = arrayBufferViewCore.exportTypedArrayMethod; 4693 4694 // `%TypedArray%.prototype.fill` method 4695 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill 4696 // eslint-disable-next-line no-unused-vars 4697 exportTypedArrayMethod$3('fill', function fill(value /* , start, end */) { 4698 return arrayFill.apply(aTypedArray$3(this), arguments); 4699 }); 4700 4701 var $filter$1 = arrayIteration.filter; 4702 4703 4704 var aTypedArray$4 = arrayBufferViewCore.aTypedArray; 4705 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 4706 var exportTypedArrayMethod$4 = arrayBufferViewCore.exportTypedArrayMethod; 4707 4708 // `%TypedArray%.prototype.filter` method 4709 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter 4710 exportTypedArrayMethod$4('filter', function filter(callbackfn /* , thisArg */) { 4711 var list = $filter$1(aTypedArray$4(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 4712 var C = speciesConstructor(this, this.constructor); 4713 var index = 0; 4714 var length = list.length; 4715 var result = new (aTypedArrayConstructor$2(C))(length); 4716 while (length > index) result[index] = list[index++]; 4717 return result; 4718 }); 4719 4720 var $find = arrayIteration.find; 4721 4722 var aTypedArray$5 = arrayBufferViewCore.aTypedArray; 4723 var exportTypedArrayMethod$5 = arrayBufferViewCore.exportTypedArrayMethod; 4724 4725 // `%TypedArray%.prototype.find` method 4726 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.find 4727 exportTypedArrayMethod$5('find', function find(predicate /* , thisArg */) { 4728 return $find(aTypedArray$5(this), predicate, arguments.length > 1 ? arguments[1] : undefined); 4729 }); 4730 4731 var $findIndex = arrayIteration.findIndex; 4732 4733 var aTypedArray$6 = arrayBufferViewCore.aTypedArray; 4734 var exportTypedArrayMethod$6 = arrayBufferViewCore.exportTypedArrayMethod; 4735 4736 // `%TypedArray%.prototype.findIndex` method 4737 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex 4738 exportTypedArrayMethod$6('findIndex', function findIndex(predicate /* , thisArg */) { 4739 return $findIndex(aTypedArray$6(this), predicate, arguments.length > 1 ? arguments[1] : undefined); 4740 }); 4741 4742 var $forEach$2 = arrayIteration.forEach; 4743 4744 var aTypedArray$7 = arrayBufferViewCore.aTypedArray; 4745 var exportTypedArrayMethod$7 = arrayBufferViewCore.exportTypedArrayMethod; 4746 4747 // `%TypedArray%.prototype.forEach` method 4748 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach 4749 exportTypedArrayMethod$7('forEach', function forEach(callbackfn /* , thisArg */) { 4750 $forEach$2(aTypedArray$7(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 4751 }); 4752 4753 var $includes$1 = arrayIncludes.includes; 4754 4755 var aTypedArray$8 = arrayBufferViewCore.aTypedArray; 4756 var exportTypedArrayMethod$8 = arrayBufferViewCore.exportTypedArrayMethod; 4757 4758 // `%TypedArray%.prototype.includes` method 4759 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes 4760 exportTypedArrayMethod$8('includes', function includes(searchElement /* , fromIndex */) { 4761 return $includes$1(aTypedArray$8(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); 4762 }); 4763 4764 var $indexOf = arrayIncludes.indexOf; 4765 4766 var aTypedArray$9 = arrayBufferViewCore.aTypedArray; 4767 var exportTypedArrayMethod$9 = arrayBufferViewCore.exportTypedArrayMethod; 4768 4769 // `%TypedArray%.prototype.indexOf` method 4770 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof 4771 exportTypedArrayMethod$9('indexOf', function indexOf(searchElement /* , fromIndex */) { 4772 return $indexOf(aTypedArray$9(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); 4773 }); 4774 4775 var ITERATOR$5 = wellKnownSymbol('iterator'); 4776 var Uint8Array$1 = global_1.Uint8Array; 4777 var arrayValues = es_array_iterator.values; 4778 var arrayKeys = es_array_iterator.keys; 4779 var arrayEntries = es_array_iterator.entries; 4780 var aTypedArray$a = arrayBufferViewCore.aTypedArray; 4781 var exportTypedArrayMethod$a = arrayBufferViewCore.exportTypedArrayMethod; 4782 var nativeTypedArrayIterator = Uint8Array$1 && Uint8Array$1.prototype[ITERATOR$5]; 4783 4784 var CORRECT_ITER_NAME = !!nativeTypedArrayIterator 4785 && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined); 4786 4787 var typedArrayValues = function values() { 4788 return arrayValues.call(aTypedArray$a(this)); 4789 }; 4790 4791 // `%TypedArray%.prototype.entries` method 4792 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries 4793 exportTypedArrayMethod$a('entries', function entries() { 4794 return arrayEntries.call(aTypedArray$a(this)); 4795 }); 4796 // `%TypedArray%.prototype.keys` method 4797 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys 4798 exportTypedArrayMethod$a('keys', function keys() { 4799 return arrayKeys.call(aTypedArray$a(this)); 4800 }); 4801 // `%TypedArray%.prototype.values` method 4802 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.values 4803 exportTypedArrayMethod$a('values', typedArrayValues, !CORRECT_ITER_NAME); 4804 // `%TypedArray%.prototype[@@iterator]` method 4805 // https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator 4806 exportTypedArrayMethod$a(ITERATOR$5, typedArrayValues, !CORRECT_ITER_NAME); 4807 4808 var aTypedArray$b = arrayBufferViewCore.aTypedArray; 4809 var exportTypedArrayMethod$b = arrayBufferViewCore.exportTypedArrayMethod; 4810 var $join = [].join; 4811 4812 // `%TypedArray%.prototype.join` method 4813 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.join 4814 // eslint-disable-next-line no-unused-vars 4815 exportTypedArrayMethod$b('join', function join(separator) { 4816 return $join.apply(aTypedArray$b(this), arguments); 4817 }); 4818 4819 var min$6 = Math.min; 4820 var nativeLastIndexOf = [].lastIndexOf; 4821 var NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0; 4822 var STRICT_METHOD$2 = arrayMethodIsStrict('lastIndexOf'); 4823 // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method 4824 var USES_TO_LENGTH$6 = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 }); 4825 var FORCED$3 = NEGATIVE_ZERO || !STRICT_METHOD$2 || !USES_TO_LENGTH$6; 4826 4827 // `Array.prototype.lastIndexOf` method implementation 4828 // https://tc39.es/ecma262/#sec-array.prototype.lastindexof 4829 var arrayLastIndexOf = FORCED$3 ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { 4830 // convert -0 to +0 4831 if (NEGATIVE_ZERO) return nativeLastIndexOf.apply(this, arguments) || 0; 4832 var O = toIndexedObject(this); 4833 var length = toLength(O.length); 4834 var index = length - 1; 4835 if (arguments.length > 1) index = min$6(index, toInteger(arguments[1])); 4836 if (index < 0) index = length + index; 4837 for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0; 4838 return -1; 4839 } : nativeLastIndexOf; 4840 4841 var aTypedArray$c = arrayBufferViewCore.aTypedArray; 4842 var exportTypedArrayMethod$c = arrayBufferViewCore.exportTypedArrayMethod; 4843 4844 // `%TypedArray%.prototype.lastIndexOf` method 4845 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof 4846 // eslint-disable-next-line no-unused-vars 4847 exportTypedArrayMethod$c('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) { 4848 return arrayLastIndexOf.apply(aTypedArray$c(this), arguments); 4849 }); 4850 4851 var $map$1 = arrayIteration.map; 4852 4853 4854 var aTypedArray$d = arrayBufferViewCore.aTypedArray; 4855 var aTypedArrayConstructor$3 = arrayBufferViewCore.aTypedArrayConstructor; 4856 var exportTypedArrayMethod$d = arrayBufferViewCore.exportTypedArrayMethod; 4857 4858 // `%TypedArray%.prototype.map` method 4859 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.map 4860 exportTypedArrayMethod$d('map', function map(mapfn /* , thisArg */) { 4861 return $map$1(aTypedArray$d(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) { 4862 return new (aTypedArrayConstructor$3(speciesConstructor(O, O.constructor)))(length); 4863 }); 4864 }); 4865 4866 // `Array.prototype.{ reduce, reduceRight }` methods implementation 4867 var createMethod$4 = function (IS_RIGHT) { 4868 return function (that, callbackfn, argumentsLength, memo) { 4869 aFunction$1(callbackfn); 4870 var O = toObject(that); 4871 var self = indexedObject(O); 4872 var length = toLength(O.length); 4873 var index = IS_RIGHT ? length - 1 : 0; 4874 var i = IS_RIGHT ? -1 : 1; 4875 if (argumentsLength < 2) while (true) { 4876 if (index in self) { 4877 memo = self[index]; 4878 index += i; 4879 break; 4880 } 4881 index += i; 4882 if (IS_RIGHT ? index < 0 : length <= index) { 4883 throw TypeError('Reduce of empty array with no initial value'); 4884 } 4885 } 4886 for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) { 4887 memo = callbackfn(memo, self[index], index, O); 4888 } 4889 return memo; 4890 }; 4891 }; 4892 4893 var arrayReduce = { 4894 // `Array.prototype.reduce` method 4895 // https://tc39.es/ecma262/#sec-array.prototype.reduce 4896 left: createMethod$4(false), 4897 // `Array.prototype.reduceRight` method 4898 // https://tc39.es/ecma262/#sec-array.prototype.reduceright 4899 right: createMethod$4(true) 4900 }; 4901 4902 var $reduce = arrayReduce.left; 4903 4904 var aTypedArray$e = arrayBufferViewCore.aTypedArray; 4905 var exportTypedArrayMethod$e = arrayBufferViewCore.exportTypedArrayMethod; 4906 4907 // `%TypedArray%.prototype.reduce` method 4908 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce 4909 exportTypedArrayMethod$e('reduce', function reduce(callbackfn /* , initialValue */) { 4910 return $reduce(aTypedArray$e(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); 4911 }); 4912 4913 var $reduceRight = arrayReduce.right; 4914 4915 var aTypedArray$f = arrayBufferViewCore.aTypedArray; 4916 var exportTypedArrayMethod$f = arrayBufferViewCore.exportTypedArrayMethod; 4917 4918 // `%TypedArray%.prototype.reduceRicht` method 4919 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduceright 4920 exportTypedArrayMethod$f('reduceRight', function reduceRight(callbackfn /* , initialValue */) { 4921 return $reduceRight(aTypedArray$f(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); 4922 }); 4923 4924 var aTypedArray$g = arrayBufferViewCore.aTypedArray; 4925 var exportTypedArrayMethod$g = arrayBufferViewCore.exportTypedArrayMethod; 4926 var floor$3 = Math.floor; 4927 4928 // `%TypedArray%.prototype.reverse` method 4929 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse 4930 exportTypedArrayMethod$g('reverse', function reverse() { 4931 var that = this; 4932 var length = aTypedArray$g(that).length; 4933 var middle = floor$3(length / 2); 4934 var index = 0; 4935 var value; 4936 while (index < middle) { 4937 value = that[index]; 4938 that[index++] = that[--length]; 4939 that[length] = value; 4940 } return that; 4941 }); 4942 4943 var aTypedArray$h = arrayBufferViewCore.aTypedArray; 4944 var exportTypedArrayMethod$h = arrayBufferViewCore.exportTypedArrayMethod; 4945 4946 var FORCED$4 = fails(function () { 4947 // eslint-disable-next-line no-undef 4948 new Int8Array(1).set({}); 4949 }); 4950 4951 // `%TypedArray%.prototype.set` method 4952 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.set 4953 exportTypedArrayMethod$h('set', function set(arrayLike /* , offset */) { 4954 aTypedArray$h(this); 4955 var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1); 4956 var length = this.length; 4957 var src = toObject(arrayLike); 4958 var len = toLength(src.length); 4959 var index = 0; 4960 if (len + offset > length) throw RangeError('Wrong length'); 4961 while (index < len) this[offset + index] = src[index++]; 4962 }, FORCED$4); 4963 4964 var aTypedArray$i = arrayBufferViewCore.aTypedArray; 4965 var aTypedArrayConstructor$4 = arrayBufferViewCore.aTypedArrayConstructor; 4966 var exportTypedArrayMethod$i = arrayBufferViewCore.exportTypedArrayMethod; 4967 var $slice = [].slice; 4968 4969 var FORCED$5 = fails(function () { 4970 // eslint-disable-next-line no-undef 4971 new Int8Array(1).slice(); 4972 }); 4973 4974 // `%TypedArray%.prototype.slice` method 4975 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice 4976 exportTypedArrayMethod$i('slice', function slice(start, end) { 4977 var list = $slice.call(aTypedArray$i(this), start, end); 4978 var C = speciesConstructor(this, this.constructor); 4979 var index = 0; 4980 var length = list.length; 4981 var result = new (aTypedArrayConstructor$4(C))(length); 4982 while (length > index) result[index] = list[index++]; 4983 return result; 4984 }, FORCED$5); 4985 4986 var $some = arrayIteration.some; 4987 4988 var aTypedArray$j = arrayBufferViewCore.aTypedArray; 4989 var exportTypedArrayMethod$j = arrayBufferViewCore.exportTypedArrayMethod; 4990 4991 // `%TypedArray%.prototype.some` method 4992 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.some 4993 exportTypedArrayMethod$j('some', function some(callbackfn /* , thisArg */) { 4994 return $some(aTypedArray$j(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); 4995 }); 4996 4997 var aTypedArray$k = arrayBufferViewCore.aTypedArray; 4998 var exportTypedArrayMethod$k = arrayBufferViewCore.exportTypedArrayMethod; 4999 var $sort = [].sort; 5000 5001 // `%TypedArray%.prototype.sort` method 5002 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5003 exportTypedArrayMethod$k('sort', function sort(comparefn) { 5004 return $sort.call(aTypedArray$k(this), comparefn); 5005 }); 5006 5007 var aTypedArray$l = arrayBufferViewCore.aTypedArray; 5008 var exportTypedArrayMethod$l = arrayBufferViewCore.exportTypedArrayMethod; 5009 5010 // `%TypedArray%.prototype.subarray` method 5011 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray 5012 exportTypedArrayMethod$l('subarray', function subarray(begin, end) { 5013 var O = aTypedArray$l(this); 5014 var length = O.length; 5015 var beginIndex = toAbsoluteIndex(begin, length); 5016 return new (speciesConstructor(O, O.constructor))( 5017 O.buffer, 5018 O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT, 5019 toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex) 5020 ); 5021 }); 5022 5023 var Int8Array$3 = global_1.Int8Array; 5024 var aTypedArray$m = arrayBufferViewCore.aTypedArray; 5025 var exportTypedArrayMethod$m = arrayBufferViewCore.exportTypedArrayMethod; 5026 var $toLocaleString = [].toLocaleString; 5027 var $slice$1 = [].slice; 5028 5029 // iOS Safari 6.x fails here 5030 var TO_LOCALE_STRING_BUG = !!Int8Array$3 && fails(function () { 5031 $toLocaleString.call(new Int8Array$3(1)); 5032 }); 5033 5034 var FORCED$6 = fails(function () { 5035 return [1, 2].toLocaleString() != new Int8Array$3([1, 2]).toLocaleString(); 5036 }) || !fails(function () { 5037 Int8Array$3.prototype.toLocaleString.call([1, 2]); 5038 }); 5039 5040 // `%TypedArray%.prototype.toLocaleString` method 5041 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring 5042 exportTypedArrayMethod$m('toLocaleString', function toLocaleString() { 5043 return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice$1.call(aTypedArray$m(this)) : aTypedArray$m(this), arguments); 5044 }, FORCED$6); 5045 5046 var exportTypedArrayMethod$n = arrayBufferViewCore.exportTypedArrayMethod; 5047 5048 5049 5050 var Uint8Array$2 = global_1.Uint8Array; 5051 var Uint8ArrayPrototype = Uint8Array$2 && Uint8Array$2.prototype || {}; 5052 var arrayToString = [].toString; 5053 var arrayJoin = [].join; 5054 5055 if (fails(function () { arrayToString.call({}); })) { 5056 arrayToString = function toString() { 5057 return arrayJoin.call(this); 5058 }; 5059 } 5060 5061 var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString; 5062 5063 // `%TypedArray%.prototype.toString` method 5064 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring 5065 exportTypedArrayMethod$n('toString', arrayToString, IS_NOT_ARRAY_METHOD); 5066 5067 // `URL.prototype.toJSON` method 5068 // https://url.spec.whatwg.org/#dom-url-tojson 5069 _export({ target: 'URL', proto: true, enumerable: true }, { 5070 toJSON: function toJSON() { 5071 return URL.prototype.toString.call(this); 5072 } 5073 }); 5074 5075 var lookup = []; 5076 var revLookup = []; 5077 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; 5078 var inited = false; 5079 5080 function init() { 5081 inited = true; 5082 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 5083 5084 for (var i = 0, len = code.length; i < len; ++i) { 5085 lookup[i] = code[i]; 5086 revLookup[code.charCodeAt(i)] = i; 5087 } 5088 5089 revLookup['-'.charCodeAt(0)] = 62; 5090 revLookup['_'.charCodeAt(0)] = 63; 5091 } 5092 5093 function toByteArray(b64) { 5094 if (!inited) { 5095 init(); 5096 } 5097 5098 var i, j, l, tmp, placeHolders, arr; 5099 var len = b64.length; 5100 5101 if (len % 4 > 0) { 5102 throw new Error('Invalid string. Length must be a multiple of 4'); 5103 } // the number of equal signs (place holders) 5104 // if there are two placeholders, than the two characters before it 5105 // represent one byte 5106 // if there is only one, then the three characters before it represent 2 bytes 5107 // this is just a cheap hack to not do indexOf twice 5108 5109 5110 placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; // base64 is 4/3 + up to two characters of the original data 5111 5112 arr = new Arr(len * 3 / 4 - placeHolders); // if there are placeholders, only get up to the last complete 4 chars 5113 5114 l = placeHolders > 0 ? len - 4 : len; 5115 var L = 0; 5116 5117 for (i = 0, j = 0; i < l; i += 4, j += 3) { 5118 tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; 5119 arr[L++] = tmp >> 16 & 0xFF; 5120 arr[L++] = tmp >> 8 & 0xFF; 5121 arr[L++] = tmp & 0xFF; 5122 } 5123 5124 if (placeHolders === 2) { 5125 tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; 5126 arr[L++] = tmp & 0xFF; 5127 } else if (placeHolders === 1) { 5128 tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; 5129 arr[L++] = tmp >> 8 & 0xFF; 5130 arr[L++] = tmp & 0xFF; 5131 } 5132 5133 return arr; 5134 } 5135 5136 function tripletToBase64(num) { 5137 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; 5138 } 5139 5140 function encodeChunk(uint8, start, end) { 5141 var tmp; 5142 var output = []; 5143 5144 for (var i = start; i < end; i += 3) { 5145 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2]; 5146 output.push(tripletToBase64(tmp)); 5147 } 5148 5149 return output.join(''); 5150 } 5151 5152 function fromByteArray(uint8) { 5153 if (!inited) { 5154 init(); 5155 } 5156 5157 var tmp; 5158 var len = uint8.length; 5159 var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes 5160 5161 var output = ''; 5162 var parts = []; 5163 var maxChunkLength = 16383; // must be multiple of 3 5164 // go through the array every three bytes, we'll deal with trailing stuff later 5165 5166 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { 5167 parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); 5168 } // pad the end with zeros, but make sure to not forget the extra bytes 5169 5170 5171 if (extraBytes === 1) { 5172 tmp = uint8[len - 1]; 5173 output += lookup[tmp >> 2]; 5174 output += lookup[tmp << 4 & 0x3F]; 5175 output += '=='; 5176 } else if (extraBytes === 2) { 5177 tmp = (uint8[len - 2] << 8) + uint8[len - 1]; 5178 output += lookup[tmp >> 10]; 5179 output += lookup[tmp >> 4 & 0x3F]; 5180 output += lookup[tmp << 2 & 0x3F]; 5181 output += '='; 5182 } 5183 5184 parts.push(output); 5185 return parts.join(''); 5186 } 5187 5188 function read(buffer, offset, isLE, mLen, nBytes) { 5189 var e, m; 5190 var eLen = nBytes * 8 - mLen - 1; 5191 var eMax = (1 << eLen) - 1; 5192 var eBias = eMax >> 1; 5193 var nBits = -7; 5194 var i = isLE ? nBytes - 1 : 0; 5195 var d = isLE ? -1 : 1; 5196 var s = buffer[offset + i]; 5197 i += d; 5198 e = s & (1 << -nBits) - 1; 5199 s >>= -nBits; 5200 nBits += eLen; 5201 5202 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} 5203 5204 m = e & (1 << -nBits) - 1; 5205 e >>= -nBits; 5206 nBits += mLen; 5207 5208 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} 5209 5210 if (e === 0) { 5211 e = 1 - eBias; 5212 } else if (e === eMax) { 5213 return m ? NaN : (s ? -1 : 1) * Infinity; 5214 } else { 5215 m = m + Math.pow(2, mLen); 5216 e = e - eBias; 5217 } 5218 5219 return (s ? -1 : 1) * m * Math.pow(2, e - mLen); 5220 } 5221 function write(buffer, value, offset, isLE, mLen, nBytes) { 5222 var e, m, c; 5223 var eLen = nBytes * 8 - mLen - 1; 5224 var eMax = (1 << eLen) - 1; 5225 var eBias = eMax >> 1; 5226 var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; 5227 var i = isLE ? 0 : nBytes - 1; 5228 var d = isLE ? 1 : -1; 5229 var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; 5230 value = Math.abs(value); 5231 5232 if (isNaN(value) || value === Infinity) { 5233 m = isNaN(value) ? 1 : 0; 5234 e = eMax; 5235 } else { 5236 e = Math.floor(Math.log(value) / Math.LN2); 5237 5238 if (value * (c = Math.pow(2, -e)) < 1) { 5239 e--; 5240 c *= 2; 5241 } 5242 5243 if (e + eBias >= 1) { 5244 value += rt / c; 5245 } else { 5246 value += rt * Math.pow(2, 1 - eBias); 5247 } 5248 5249 if (value * c >= 2) { 5250 e++; 5251 c /= 2; 5252 } 5253 5254 if (e + eBias >= eMax) { 5255 m = 0; 5256 e = eMax; 5257 } else if (e + eBias >= 1) { 5258 m = (value * c - 1) * Math.pow(2, mLen); 5259 e = e + eBias; 5260 } else { 5261 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); 5262 e = 0; 5263 } 5264 } 5265 5266 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 5267 5268 e = e << mLen | m; 5269 eLen += mLen; 5270 5271 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 5272 5273 buffer[offset + i - d] |= s * 128; 5274 } 5275 5276 var toString$2 = {}.toString; 5277 var isArray$1 = Array.isArray || function (arr) { 5278 return toString$2.call(arr) == '[object Array]'; 5279 }; 5280 5281 var INSPECT_MAX_BYTES = 50; 5282 /** 5283 * If `Buffer.TYPED_ARRAY_SUPPORT`: 5284 * === true Use Uint8Array implementation (fastest) 5285 * === false Use Object implementation (most compatible, even IE6) 5286 * 5287 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 5288 * Opera 11.6+, iOS 4.2+. 5289 * 5290 * Due to various browser bugs, sometimes the Object implementation will be used even 5291 * when the browser supports typed arrays. 5292 * 5293 * Note: 5294 * 5295 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 5296 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 5297 * 5298 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 5299 * 5300 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 5301 * incorrect length in some situations. 5302 5303 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 5304 * get the Object implementation, which is slower but behaves correctly. 5305 */ 5306 5307 Buffer.TYPED_ARRAY_SUPPORT = global$2.TYPED_ARRAY_SUPPORT !== undefined ? global$2.TYPED_ARRAY_SUPPORT : true; 5308 5309 function kMaxLength() { 5310 return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff; 5311 } 5312 5313 function createBuffer(that, length) { 5314 if (kMaxLength() < length) { 5315 throw new RangeError('Invalid typed array length'); 5316 } 5317 5318 if (Buffer.TYPED_ARRAY_SUPPORT) { 5319 // Return an augmented `Uint8Array` instance, for best performance 5320 that = new Uint8Array(length); 5321 that.__proto__ = Buffer.prototype; 5322 } else { 5323 // Fallback: Return an object instance of the Buffer class 5324 if (that === null) { 5325 that = new Buffer(length); 5326 } 5327 5328 that.length = length; 5329 } 5330 5331 return that; 5332 } 5333 /** 5334 * The Buffer constructor returns instances of `Uint8Array` that have their 5335 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 5336 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 5337 * and the `Uint8Array` methods. Square bracket notation works as expected -- it 5338 * returns a single octet. 5339 * 5340 * The `Uint8Array` prototype remains unmodified. 5341 */ 5342 5343 5344 function Buffer(arg, encodingOrOffset, length) { 5345 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { 5346 return new Buffer(arg, encodingOrOffset, length); 5347 } // Common case. 5348 5349 5350 if (typeof arg === 'number') { 5351 if (typeof encodingOrOffset === 'string') { 5352 throw new Error('If encoding is specified then the first argument must be a string'); 5353 } 5354 5355 return allocUnsafe(this, arg); 5356 } 5357 5358 return from(this, arg, encodingOrOffset, length); 5359 } 5360 Buffer.poolSize = 8192; // not used by this implementation 5361 // TODO: Legacy, not needed anymore. Remove in next major version. 5362 5363 Buffer._augment = function (arr) { 5364 arr.__proto__ = Buffer.prototype; 5365 return arr; 5366 }; 5367 5368 function from(that, value, encodingOrOffset, length) { 5369 if (typeof value === 'number') { 5370 throw new TypeError('"value" argument must not be a number'); 5371 } 5372 5373 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { 5374 return fromArrayBuffer(that, value, encodingOrOffset, length); 5375 } 5376 5377 if (typeof value === 'string') { 5378 return fromString(that, value, encodingOrOffset); 5379 } 5380 5381 return fromObject(that, value); 5382 } 5383 /** 5384 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 5385 * if value is a number. 5386 * Buffer.from(str[, encoding]) 5387 * Buffer.from(array) 5388 * Buffer.from(buffer) 5389 * Buffer.from(arrayBuffer[, byteOffset[, length]]) 5390 **/ 5391 5392 5393 Buffer.from = function (value, encodingOrOffset, length) { 5394 return from(null, value, encodingOrOffset, length); 5395 }; 5396 5397 if (Buffer.TYPED_ARRAY_SUPPORT) { 5398 Buffer.prototype.__proto__ = Uint8Array.prototype; 5399 Buffer.__proto__ = Uint8Array; 5400 } 5401 5402 function assertSize(size) { 5403 if (typeof size !== 'number') { 5404 throw new TypeError('"size" argument must be a number'); 5405 } else if (size < 0) { 5406 throw new RangeError('"size" argument must not be negative'); 5407 } 5408 } 5409 5410 function alloc(that, size, fill, encoding) { 5411 assertSize(size); 5412 5413 if (size <= 0) { 5414 return createBuffer(that, size); 5415 } 5416 5417 if (fill !== undefined) { 5418 // Only pay attention to encoding if it's a string. This 5419 // prevents accidentally sending in a number that would 5420 // be interpretted as a start offset. 5421 return typeof encoding === 'string' ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill); 5422 } 5423 5424 return createBuffer(that, size); 5425 } 5426 /** 5427 * Creates a new filled Buffer instance. 5428 * alloc(size[, fill[, encoding]]) 5429 **/ 5430 5431 5432 Buffer.alloc = function (size, fill, encoding) { 5433 return alloc(null, size, fill, encoding); 5434 }; 5435 5436 function allocUnsafe(that, size) { 5437 assertSize(size); 5438 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0); 5439 5440 if (!Buffer.TYPED_ARRAY_SUPPORT) { 5441 for (var i = 0; i < size; ++i) { 5442 that[i] = 0; 5443 } 5444 } 5445 5446 return that; 5447 } 5448 /** 5449 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 5450 * */ 5451 5452 5453 Buffer.allocUnsafe = function (size) { 5454 return allocUnsafe(null, size); 5455 }; 5456 /** 5457 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 5458 */ 5459 5460 5461 Buffer.allocUnsafeSlow = function (size) { 5462 return allocUnsafe(null, size); 5463 }; 5464 5465 function fromString(that, string, encoding) { 5466 if (typeof encoding !== 'string' || encoding === '') { 5467 encoding = 'utf8'; 5468 } 5469 5470 if (!Buffer.isEncoding(encoding)) { 5471 throw new TypeError('"encoding" must be a valid string encoding'); 5472 } 5473 5474 var length = byteLength(string, encoding) | 0; 5475 that = createBuffer(that, length); 5476 var actual = that.write(string, encoding); 5477 5478 if (actual !== length) { 5479 // Writing a hex string, for example, that contains invalid characters will 5480 // cause everything after the first invalid character to be ignored. (e.g. 5481 // 'abxxcd' will be treated as 'ab') 5482 that = that.slice(0, actual); 5483 } 5484 5485 return that; 5486 } 5487 5488 function fromArrayLike(that, array) { 5489 var length = array.length < 0 ? 0 : checked(array.length) | 0; 5490 that = createBuffer(that, length); 5491 5492 for (var i = 0; i < length; i += 1) { 5493 that[i] = array[i] & 255; 5494 } 5495 5496 return that; 5497 } 5498 5499 function fromArrayBuffer(that, array, byteOffset, length) { 5500 array.byteLength; // this throws if `array` is not a valid ArrayBuffer 5501 5502 if (byteOffset < 0 || array.byteLength < byteOffset) { 5503 throw new RangeError('\'offset\' is out of bounds'); 5504 } 5505 5506 if (array.byteLength < byteOffset + (length || 0)) { 5507 throw new RangeError('\'length\' is out of bounds'); 5508 } 5509 5510 if (byteOffset === undefined && length === undefined) { 5511 array = new Uint8Array(array); 5512 } else if (length === undefined) { 5513 array = new Uint8Array(array, byteOffset); 5514 } else { 5515 array = new Uint8Array(array, byteOffset, length); 5516 } 5517 5518 if (Buffer.TYPED_ARRAY_SUPPORT) { 5519 // Return an augmented `Uint8Array` instance, for best performance 5520 that = array; 5521 that.__proto__ = Buffer.prototype; 5522 } else { 5523 // Fallback: Return an object instance of the Buffer class 5524 that = fromArrayLike(that, array); 5525 } 5526 5527 return that; 5528 } 5529 5530 function fromObject(that, obj) { 5531 if (internalIsBuffer(obj)) { 5532 var len = checked(obj.length) | 0; 5533 that = createBuffer(that, len); 5534 5535 if (that.length === 0) { 5536 return that; 5537 } 5538 5539 obj.copy(that, 0, 0, len); 5540 return that; 5541 } 5542 5543 if (obj) { 5544 if (typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer || 'length' in obj) { 5545 if (typeof obj.length !== 'number' || isnan(obj.length)) { 5546 return createBuffer(that, 0); 5547 } 5548 5549 return fromArrayLike(that, obj); 5550 } 5551 5552 if (obj.type === 'Buffer' && isArray$1(obj.data)) { 5553 return fromArrayLike(that, obj.data); 5554 } 5555 } 5556 5557 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.'); 5558 } 5559 5560 function checked(length) { 5561 // Note: cannot use `length < kMaxLength()` here because that fails when 5562 // length is NaN (which is otherwise coerced to zero.) 5563 if (length >= kMaxLength()) { 5564 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes'); 5565 } 5566 5567 return length | 0; 5568 } 5569 Buffer.isBuffer = isBuffer; 5570 5571 function internalIsBuffer(b) { 5572 return !!(b != null && b._isBuffer); 5573 } 5574 5575 Buffer.compare = function compare(a, b) { 5576 if (!internalIsBuffer(a) || !internalIsBuffer(b)) { 5577 throw new TypeError('Arguments must be Buffers'); 5578 } 5579 5580 if (a === b) return 0; 5581 var x = a.length; 5582 var y = b.length; 5583 5584 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 5585 if (a[i] !== b[i]) { 5586 x = a[i]; 5587 y = b[i]; 5588 break; 5589 } 5590 } 5591 5592 if (x < y) return -1; 5593 if (y < x) return 1; 5594 return 0; 5595 }; 5596 5597 Buffer.isEncoding = function isEncoding(encoding) { 5598 switch (String(encoding).toLowerCase()) { 5599 case 'hex': 5600 case 'utf8': 5601 case 'utf-8': 5602 case 'ascii': 5603 case 'latin1': 5604 case 'binary': 5605 case 'base64': 5606 case 'ucs2': 5607 case 'ucs-2': 5608 case 'utf16le': 5609 case 'utf-16le': 5610 return true; 5611 5612 default: 5613 return false; 5614 } 5615 }; 5616 5617 Buffer.concat = function concat(list, length) { 5618 if (!isArray$1(list)) { 5619 throw new TypeError('"list" argument must be an Array of Buffers'); 5620 } 5621 5622 if (list.length === 0) { 5623 return Buffer.alloc(0); 5624 } 5625 5626 var i; 5627 5628 if (length === undefined) { 5629 length = 0; 5630 5631 for (i = 0; i < list.length; ++i) { 5632 length += list[i].length; 5633 } 5634 } 5635 5636 var buffer = Buffer.allocUnsafe(length); 5637 var pos = 0; 5638 5639 for (i = 0; i < list.length; ++i) { 5640 var buf = list[i]; 5641 5642 if (!internalIsBuffer(buf)) { 5643 throw new TypeError('"list" argument must be an Array of Buffers'); 5644 } 5645 5646 buf.copy(buffer, pos); 5647 pos += buf.length; 5648 } 5649 5650 return buffer; 5651 }; 5652 5653 function byteLength(string, encoding) { 5654 if (internalIsBuffer(string)) { 5655 return string.length; 5656 } 5657 5658 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { 5659 return string.byteLength; 5660 } 5661 5662 if (typeof string !== 'string') { 5663 string = '' + string; 5664 } 5665 5666 var len = string.length; 5667 if (len === 0) return 0; // Use a for loop to avoid recursion 5668 5669 var loweredCase = false; 5670 5671 for (;;) { 5672 switch (encoding) { 5673 case 'ascii': 5674 case 'latin1': 5675 case 'binary': 5676 return len; 5677 5678 case 'utf8': 5679 case 'utf-8': 5680 case undefined: 5681 return utf8ToBytes(string).length; 5682 5683 case 'ucs2': 5684 case 'ucs-2': 5685 case 'utf16le': 5686 case 'utf-16le': 5687 return len * 2; 5688 5689 case 'hex': 5690 return len >>> 1; 5691 5692 case 'base64': 5693 return base64ToBytes(string).length; 5694 5695 default: 5696 if (loweredCase) return utf8ToBytes(string).length; // assume utf8 5697 5698 encoding = ('' + encoding).toLowerCase(); 5699 loweredCase = true; 5700 } 5701 } 5702 } 5703 5704 Buffer.byteLength = byteLength; 5705 5706 function slowToString(encoding, start, end) { 5707 var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 5708 // property of a typed array. 5709 // This behaves neither like String nor Uint8Array in that we set start/end 5710 // to their upper/lower bounds if the value passed is out of range. 5711 // undefined is handled specially as per ECMA-262 6th Edition, 5712 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 5713 5714 if (start === undefined || start < 0) { 5715 start = 0; 5716 } // Return early if start > this.length. Done here to prevent potential uint32 5717 // coercion fail below. 5718 5719 5720 if (start > this.length) { 5721 return ''; 5722 } 5723 5724 if (end === undefined || end > this.length) { 5725 end = this.length; 5726 } 5727 5728 if (end <= 0) { 5729 return ''; 5730 } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 5731 5732 5733 end >>>= 0; 5734 start >>>= 0; 5735 5736 if (end <= start) { 5737 return ''; 5738 } 5739 5740 if (!encoding) encoding = 'utf8'; 5741 5742 while (true) { 5743 switch (encoding) { 5744 case 'hex': 5745 return hexSlice(this, start, end); 5746 5747 case 'utf8': 5748 case 'utf-8': 5749 return utf8Slice(this, start, end); 5750 5751 case 'ascii': 5752 return asciiSlice(this, start, end); 5753 5754 case 'latin1': 5755 case 'binary': 5756 return latin1Slice(this, start, end); 5757 5758 case 'base64': 5759 return base64Slice(this, start, end); 5760 5761 case 'ucs2': 5762 case 'ucs-2': 5763 case 'utf16le': 5764 case 'utf-16le': 5765 return utf16leSlice(this, start, end); 5766 5767 default: 5768 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); 5769 encoding = (encoding + '').toLowerCase(); 5770 loweredCase = true; 5771 } 5772 } 5773 } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect 5774 // Buffer instances. 5775 5776 5777 Buffer.prototype._isBuffer = true; 5778 5779 function swap(b, n, m) { 5780 var i = b[n]; 5781 b[n] = b[m]; 5782 b[m] = i; 5783 } 5784 5785 Buffer.prototype.swap16 = function swap16() { 5786 var len = this.length; 5787 5788 if (len % 2 !== 0) { 5789 throw new RangeError('Buffer size must be a multiple of 16-bits'); 5790 } 5791 5792 for (var i = 0; i < len; i += 2) { 5793 swap(this, i, i + 1); 5794 } 5795 5796 return this; 5797 }; 5798 5799 Buffer.prototype.swap32 = function swap32() { 5800 var len = this.length; 5801 5802 if (len % 4 !== 0) { 5803 throw new RangeError('Buffer size must be a multiple of 32-bits'); 5804 } 5805 5806 for (var i = 0; i < len; i += 4) { 5807 swap(this, i, i + 3); 5808 swap(this, i + 1, i + 2); 5809 } 5810 5811 return this; 5812 }; 5813 5814 Buffer.prototype.swap64 = function swap64() { 5815 var len = this.length; 5816 5817 if (len % 8 !== 0) { 5818 throw new RangeError('Buffer size must be a multiple of 64-bits'); 5819 } 5820 5821 for (var i = 0; i < len; i += 8) { 5822 swap(this, i, i + 7); 5823 swap(this, i + 1, i + 6); 5824 swap(this, i + 2, i + 5); 5825 swap(this, i + 3, i + 4); 5826 } 5827 5828 return this; 5829 }; 5830 5831 Buffer.prototype.toString = function toString() { 5832 var length = this.length | 0; 5833 if (length === 0) return ''; 5834 if (arguments.length === 0) return utf8Slice(this, 0, length); 5835 return slowToString.apply(this, arguments); 5836 }; 5837 5838 Buffer.prototype.equals = function equals(b) { 5839 if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer'); 5840 if (this === b) return true; 5841 return Buffer.compare(this, b) === 0; 5842 }; 5843 5844 Buffer.prototype.inspect = function inspect() { 5845 var str = ''; 5846 var max = INSPECT_MAX_BYTES; 5847 5848 if (this.length > 0) { 5849 str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); 5850 if (this.length > max) str += ' ... '; 5851 } 5852 5853 return '<Buffer ' + str + '>'; 5854 }; 5855 5856 Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { 5857 if (!internalIsBuffer(target)) { 5858 throw new TypeError('Argument must be a Buffer'); 5859 } 5860 5861 if (start === undefined) { 5862 start = 0; 5863 } 5864 5865 if (end === undefined) { 5866 end = target ? target.length : 0; 5867 } 5868 5869 if (thisStart === undefined) { 5870 thisStart = 0; 5871 } 5872 5873 if (thisEnd === undefined) { 5874 thisEnd = this.length; 5875 } 5876 5877 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 5878 throw new RangeError('out of range index'); 5879 } 5880 5881 if (thisStart >= thisEnd && start >= end) { 5882 return 0; 5883 } 5884 5885 if (thisStart >= thisEnd) { 5886 return -1; 5887 } 5888 5889 if (start >= end) { 5890 return 1; 5891 } 5892 5893 start >>>= 0; 5894 end >>>= 0; 5895 thisStart >>>= 0; 5896 thisEnd >>>= 0; 5897 if (this === target) return 0; 5898 var x = thisEnd - thisStart; 5899 var y = end - start; 5900 var len = Math.min(x, y); 5901 var thisCopy = this.slice(thisStart, thisEnd); 5902 var targetCopy = target.slice(start, end); 5903 5904 for (var i = 0; i < len; ++i) { 5905 if (thisCopy[i] !== targetCopy[i]) { 5906 x = thisCopy[i]; 5907 y = targetCopy[i]; 5908 break; 5909 } 5910 } 5911 5912 if (x < y) return -1; 5913 if (y < x) return 1; 5914 return 0; 5915 }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 5916 // OR the last index of `val` in `buffer` at offset <= `byteOffset`. 5917 // 5918 // Arguments: 5919 // - buffer - a Buffer to search 5920 // - val - a string, Buffer, or number 5921 // - byteOffset - an index into `buffer`; will be clamped to an int32 5922 // - encoding - an optional encoding, relevant is val is a string 5923 // - dir - true for indexOf, false for lastIndexOf 5924 5925 5926 function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { 5927 // Empty buffer means no match 5928 if (buffer.length === 0) return -1; // Normalize byteOffset 5929 5930 if (typeof byteOffset === 'string') { 5931 encoding = byteOffset; 5932 byteOffset = 0; 5933 } else if (byteOffset > 0x7fffffff) { 5934 byteOffset = 0x7fffffff; 5935 } else if (byteOffset < -0x80000000) { 5936 byteOffset = -0x80000000; 5937 } 5938 5939 byteOffset = +byteOffset; // Coerce to Number. 5940 5941 if (isNaN(byteOffset)) { 5942 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 5943 byteOffset = dir ? 0 : buffer.length - 1; 5944 } // Normalize byteOffset: negative offsets start from the end of the buffer 5945 5946 5947 if (byteOffset < 0) byteOffset = buffer.length + byteOffset; 5948 5949 if (byteOffset >= buffer.length) { 5950 if (dir) return -1;else byteOffset = buffer.length - 1; 5951 } else if (byteOffset < 0) { 5952 if (dir) byteOffset = 0;else return -1; 5953 } // Normalize val 5954 5955 5956 if (typeof val === 'string') { 5957 val = Buffer.from(val, encoding); 5958 } // Finally, search either indexOf (if dir is true) or lastIndexOf 5959 5960 5961 if (internalIsBuffer(val)) { 5962 // Special case: looking for empty string/buffer always fails 5963 if (val.length === 0) { 5964 return -1; 5965 } 5966 5967 return arrayIndexOf(buffer, val, byteOffset, encoding, dir); 5968 } else if (typeof val === 'number') { 5969 val = val & 0xFF; // Search for a byte value [0-255] 5970 5971 if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') { 5972 if (dir) { 5973 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); 5974 } else { 5975 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); 5976 } 5977 } 5978 5979 return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); 5980 } 5981 5982 throw new TypeError('val must be string, number or Buffer'); 5983 } 5984 5985 function arrayIndexOf(arr, val, byteOffset, encoding, dir) { 5986 var indexSize = 1; 5987 var arrLength = arr.length; 5988 var valLength = val.length; 5989 5990 if (encoding !== undefined) { 5991 encoding = String(encoding).toLowerCase(); 5992 5993 if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { 5994 if (arr.length < 2 || val.length < 2) { 5995 return -1; 5996 } 5997 5998 indexSize = 2; 5999 arrLength /= 2; 6000 valLength /= 2; 6001 byteOffset /= 2; 6002 } 6003 } 6004 6005 function read(buf, i) { 6006 if (indexSize === 1) { 6007 return buf[i]; 6008 } else { 6009 return buf.readUInt16BE(i * indexSize); 6010 } 6011 } 6012 6013 var i; 6014 6015 if (dir) { 6016 var foundIndex = -1; 6017 6018 for (i = byteOffset; i < arrLength; i++) { 6019 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 6020 if (foundIndex === -1) foundIndex = i; 6021 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; 6022 } else { 6023 if (foundIndex !== -1) i -= i - foundIndex; 6024 foundIndex = -1; 6025 } 6026 } 6027 } else { 6028 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; 6029 6030 for (i = byteOffset; i >= 0; i--) { 6031 var found = true; 6032 6033 for (var j = 0; j < valLength; j++) { 6034 if (read(arr, i + j) !== read(val, j)) { 6035 found = false; 6036 break; 6037 } 6038 } 6039 6040 if (found) return i; 6041 } 6042 } 6043 6044 return -1; 6045 } 6046 6047 Buffer.prototype.includes = function includes(val, byteOffset, encoding) { 6048 return this.indexOf(val, byteOffset, encoding) !== -1; 6049 }; 6050 6051 Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { 6052 return bidirectionalIndexOf(this, val, byteOffset, encoding, true); 6053 }; 6054 6055 Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { 6056 return bidirectionalIndexOf(this, val, byteOffset, encoding, false); 6057 }; 6058 6059 function hexWrite(buf, string, offset, length) { 6060 offset = Number(offset) || 0; 6061 var remaining = buf.length - offset; 6062 6063 if (!length) { 6064 length = remaining; 6065 } else { 6066 length = Number(length); 6067 6068 if (length > remaining) { 6069 length = remaining; 6070 } 6071 } // must be an even number of digits 6072 6073 6074 var strLen = string.length; 6075 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string'); 6076 6077 if (length > strLen / 2) { 6078 length = strLen / 2; 6079 } 6080 6081 for (var i = 0; i < length; ++i) { 6082 var parsed = parseInt(string.substr(i * 2, 2), 16); 6083 if (isNaN(parsed)) return i; 6084 buf[offset + i] = parsed; 6085 } 6086 6087 return i; 6088 } 6089 6090 function utf8Write(buf, string, offset, length) { 6091 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); 6092 } 6093 6094 function asciiWrite(buf, string, offset, length) { 6095 return blitBuffer(asciiToBytes(string), buf, offset, length); 6096 } 6097 6098 function latin1Write(buf, string, offset, length) { 6099 return asciiWrite(buf, string, offset, length); 6100 } 6101 6102 function base64Write(buf, string, offset, length) { 6103 return blitBuffer(base64ToBytes(string), buf, offset, length); 6104 } 6105 6106 function ucs2Write(buf, string, offset, length) { 6107 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); 6108 } 6109 6110 Buffer.prototype.write = function write(string, offset, length, encoding) { 6111 // Buffer#write(string) 6112 if (offset === undefined) { 6113 encoding = 'utf8'; 6114 length = this.length; 6115 offset = 0; // Buffer#write(string, encoding) 6116 } else if (length === undefined && typeof offset === 'string') { 6117 encoding = offset; 6118 length = this.length; 6119 offset = 0; // Buffer#write(string, offset[, length][, encoding]) 6120 } else if (isFinite(offset)) { 6121 offset = offset | 0; 6122 6123 if (isFinite(length)) { 6124 length = length | 0; 6125 if (encoding === undefined) encoding = 'utf8'; 6126 } else { 6127 encoding = length; 6128 length = undefined; 6129 } // legacy write(string, encoding, offset, length) - remove in v0.13 6130 6131 } else { 6132 throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); 6133 } 6134 6135 var remaining = this.length - offset; 6136 if (length === undefined || length > remaining) length = remaining; 6137 6138 if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { 6139 throw new RangeError('Attempt to write outside buffer bounds'); 6140 } 6141 6142 if (!encoding) encoding = 'utf8'; 6143 var loweredCase = false; 6144 6145 for (;;) { 6146 switch (encoding) { 6147 case 'hex': 6148 return hexWrite(this, string, offset, length); 6149 6150 case 'utf8': 6151 case 'utf-8': 6152 return utf8Write(this, string, offset, length); 6153 6154 case 'ascii': 6155 return asciiWrite(this, string, offset, length); 6156 6157 case 'latin1': 6158 case 'binary': 6159 return latin1Write(this, string, offset, length); 6160 6161 case 'base64': 6162 // Warning: maxLength not taken into account in base64Write 6163 return base64Write(this, string, offset, length); 6164 6165 case 'ucs2': 6166 case 'ucs-2': 6167 case 'utf16le': 6168 case 'utf-16le': 6169 return ucs2Write(this, string, offset, length); 6170 6171 default: 6172 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); 6173 encoding = ('' + encoding).toLowerCase(); 6174 loweredCase = true; 6175 } 6176 } 6177 }; 6178 6179 Buffer.prototype.toJSON = function toJSON() { 6180 return { 6181 type: 'Buffer', 6182 data: Array.prototype.slice.call(this._arr || this, 0) 6183 }; 6184 }; 6185 6186 function base64Slice(buf, start, end) { 6187 if (start === 0 && end === buf.length) { 6188 return fromByteArray(buf); 6189 } else { 6190 return fromByteArray(buf.slice(start, end)); 6191 } 6192 } 6193 6194 function utf8Slice(buf, start, end) { 6195 end = Math.min(buf.length, end); 6196 var res = []; 6197 var i = start; 6198 6199 while (i < end) { 6200 var firstByte = buf[i]; 6201 var codePoint = null; 6202 var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; 6203 6204 if (i + bytesPerSequence <= end) { 6205 var secondByte, thirdByte, fourthByte, tempCodePoint; 6206 6207 switch (bytesPerSequence) { 6208 case 1: 6209 if (firstByte < 0x80) { 6210 codePoint = firstByte; 6211 } 6212 6213 break; 6214 6215 case 2: 6216 secondByte = buf[i + 1]; 6217 6218 if ((secondByte & 0xC0) === 0x80) { 6219 tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; 6220 6221 if (tempCodePoint > 0x7F) { 6222 codePoint = tempCodePoint; 6223 } 6224 } 6225 6226 break; 6227 6228 case 3: 6229 secondByte = buf[i + 1]; 6230 thirdByte = buf[i + 2]; 6231 6232 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 6233 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; 6234 6235 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 6236 codePoint = tempCodePoint; 6237 } 6238 } 6239 6240 break; 6241 6242 case 4: 6243 secondByte = buf[i + 1]; 6244 thirdByte = buf[i + 2]; 6245 fourthByte = buf[i + 3]; 6246 6247 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 6248 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; 6249 6250 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 6251 codePoint = tempCodePoint; 6252 } 6253 } 6254 6255 } 6256 } 6257 6258 if (codePoint === null) { 6259 // we did not generate a valid codePoint so insert a 6260 // replacement char (U+FFFD) and advance only 1 byte 6261 codePoint = 0xFFFD; 6262 bytesPerSequence = 1; 6263 } else if (codePoint > 0xFFFF) { 6264 // encode to utf16 (surrogate pair dance) 6265 codePoint -= 0x10000; 6266 res.push(codePoint >>> 10 & 0x3FF | 0xD800); 6267 codePoint = 0xDC00 | codePoint & 0x3FF; 6268 } 6269 6270 res.push(codePoint); 6271 i += bytesPerSequence; 6272 } 6273 6274 return decodeCodePointsArray(res); 6275 } // Based on http://stackoverflow.com/a/22747272/680742, the browser with 6276 // the lowest limit is Chrome, with 0x10000 args. 6277 // We go 1 magnitude less, for safety 6278 6279 6280 var MAX_ARGUMENTS_LENGTH = 0x1000; 6281 6282 function decodeCodePointsArray(codePoints) { 6283 var len = codePoints.length; 6284 6285 if (len <= MAX_ARGUMENTS_LENGTH) { 6286 return String.fromCharCode.apply(String, codePoints); // avoid extra slice() 6287 } // Decode in chunks to avoid "call stack size exceeded". 6288 6289 6290 var res = ''; 6291 var i = 0; 6292 6293 while (i < len) { 6294 res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); 6295 } 6296 6297 return res; 6298 } 6299 6300 function asciiSlice(buf, start, end) { 6301 var ret = ''; 6302 end = Math.min(buf.length, end); 6303 6304 for (var i = start; i < end; ++i) { 6305 ret += String.fromCharCode(buf[i] & 0x7F); 6306 } 6307 6308 return ret; 6309 } 6310 6311 function latin1Slice(buf, start, end) { 6312 var ret = ''; 6313 end = Math.min(buf.length, end); 6314 6315 for (var i = start; i < end; ++i) { 6316 ret += String.fromCharCode(buf[i]); 6317 } 6318 6319 return ret; 6320 } 6321 6322 function hexSlice(buf, start, end) { 6323 var len = buf.length; 6324 if (!start || start < 0) start = 0; 6325 if (!end || end < 0 || end > len) end = len; 6326 var out = ''; 6327 6328 for (var i = start; i < end; ++i) { 6329 out += toHex(buf[i]); 6330 } 6331 6332 return out; 6333 } 6334 6335 function utf16leSlice(buf, start, end) { 6336 var bytes = buf.slice(start, end); 6337 var res = ''; 6338 6339 for (var i = 0; i < bytes.length; i += 2) { 6340 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); 6341 } 6342 6343 return res; 6344 } 6345 6346 Buffer.prototype.slice = function slice(start, end) { 6347 var len = this.length; 6348 start = ~~start; 6349 end = end === undefined ? len : ~~end; 6350 6351 if (start < 0) { 6352 start += len; 6353 if (start < 0) start = 0; 6354 } else if (start > len) { 6355 start = len; 6356 } 6357 6358 if (end < 0) { 6359 end += len; 6360 if (end < 0) end = 0; 6361 } else if (end > len) { 6362 end = len; 6363 } 6364 6365 if (end < start) end = start; 6366 var newBuf; 6367 6368 if (Buffer.TYPED_ARRAY_SUPPORT) { 6369 newBuf = this.subarray(start, end); 6370 newBuf.__proto__ = Buffer.prototype; 6371 } else { 6372 var sliceLen = end - start; 6373 newBuf = new Buffer(sliceLen, undefined); 6374 6375 for (var i = 0; i < sliceLen; ++i) { 6376 newBuf[i] = this[i + start]; 6377 } 6378 } 6379 6380 return newBuf; 6381 }; 6382 /* 6383 * Need to make sure that buffer isn't trying to write out of bounds. 6384 */ 6385 6386 6387 function checkOffset(offset, ext, length) { 6388 if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); 6389 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); 6390 } 6391 6392 Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { 6393 offset = offset | 0; 6394 byteLength = byteLength | 0; 6395 if (!noAssert) checkOffset(offset, byteLength, this.length); 6396 var val = this[offset]; 6397 var mul = 1; 6398 var i = 0; 6399 6400 while (++i < byteLength && (mul *= 0x100)) { 6401 val += this[offset + i] * mul; 6402 } 6403 6404 return val; 6405 }; 6406 6407 Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { 6408 offset = offset | 0; 6409 byteLength = byteLength | 0; 6410 6411 if (!noAssert) { 6412 checkOffset(offset, byteLength, this.length); 6413 } 6414 6415 var val = this[offset + --byteLength]; 6416 var mul = 1; 6417 6418 while (byteLength > 0 && (mul *= 0x100)) { 6419 val += this[offset + --byteLength] * mul; 6420 } 6421 6422 return val; 6423 }; 6424 6425 Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { 6426 if (!noAssert) checkOffset(offset, 1, this.length); 6427 return this[offset]; 6428 }; 6429 6430 Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { 6431 if (!noAssert) checkOffset(offset, 2, this.length); 6432 return this[offset] | this[offset + 1] << 8; 6433 }; 6434 6435 Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { 6436 if (!noAssert) checkOffset(offset, 2, this.length); 6437 return this[offset] << 8 | this[offset + 1]; 6438 }; 6439 6440 Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { 6441 if (!noAssert) checkOffset(offset, 4, this.length); 6442 return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; 6443 }; 6444 6445 Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { 6446 if (!noAssert) checkOffset(offset, 4, this.length); 6447 return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); 6448 }; 6449 6450 Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { 6451 offset = offset | 0; 6452 byteLength = byteLength | 0; 6453 if (!noAssert) checkOffset(offset, byteLength, this.length); 6454 var val = this[offset]; 6455 var mul = 1; 6456 var i = 0; 6457 6458 while (++i < byteLength && (mul *= 0x100)) { 6459 val += this[offset + i] * mul; 6460 } 6461 6462 mul *= 0x80; 6463 if (val >= mul) val -= Math.pow(2, 8 * byteLength); 6464 return val; 6465 }; 6466 6467 Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { 6468 offset = offset | 0; 6469 byteLength = byteLength | 0; 6470 if (!noAssert) checkOffset(offset, byteLength, this.length); 6471 var i = byteLength; 6472 var mul = 1; 6473 var val = this[offset + --i]; 6474 6475 while (i > 0 && (mul *= 0x100)) { 6476 val += this[offset + --i] * mul; 6477 } 6478 6479 mul *= 0x80; 6480 if (val >= mul) val -= Math.pow(2, 8 * byteLength); 6481 return val; 6482 }; 6483 6484 Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { 6485 if (!noAssert) checkOffset(offset, 1, this.length); 6486 if (!(this[offset] & 0x80)) return this[offset]; 6487 return (0xff - this[offset] + 1) * -1; 6488 }; 6489 6490 Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { 6491 if (!noAssert) checkOffset(offset, 2, this.length); 6492 var val = this[offset] | this[offset + 1] << 8; 6493 return val & 0x8000 ? val | 0xFFFF0000 : val; 6494 }; 6495 6496 Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { 6497 if (!noAssert) checkOffset(offset, 2, this.length); 6498 var val = this[offset + 1] | this[offset] << 8; 6499 return val & 0x8000 ? val | 0xFFFF0000 : val; 6500 }; 6501 6502 Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { 6503 if (!noAssert) checkOffset(offset, 4, this.length); 6504 return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; 6505 }; 6506 6507 Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { 6508 if (!noAssert) checkOffset(offset, 4, this.length); 6509 return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; 6510 }; 6511 6512 Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { 6513 if (!noAssert) checkOffset(offset, 4, this.length); 6514 return read(this, offset, true, 23, 4); 6515 }; 6516 6517 Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { 6518 if (!noAssert) checkOffset(offset, 4, this.length); 6519 return read(this, offset, false, 23, 4); 6520 }; 6521 6522 Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { 6523 if (!noAssert) checkOffset(offset, 8, this.length); 6524 return read(this, offset, true, 52, 8); 6525 }; 6526 6527 Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { 6528 if (!noAssert) checkOffset(offset, 8, this.length); 6529 return read(this, offset, false, 52, 8); 6530 }; 6531 6532 function checkInt(buf, value, offset, ext, max, min) { 6533 if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); 6534 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); 6535 if (offset + ext > buf.length) throw new RangeError('Index out of range'); 6536 } 6537 6538 Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { 6539 value = +value; 6540 offset = offset | 0; 6541 byteLength = byteLength | 0; 6542 6543 if (!noAssert) { 6544 var maxBytes = Math.pow(2, 8 * byteLength) - 1; 6545 checkInt(this, value, offset, byteLength, maxBytes, 0); 6546 } 6547 6548 var mul = 1; 6549 var i = 0; 6550 this[offset] = value & 0xFF; 6551 6552 while (++i < byteLength && (mul *= 0x100)) { 6553 this[offset + i] = value / mul & 0xFF; 6554 } 6555 6556 return offset + byteLength; 6557 }; 6558 6559 Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { 6560 value = +value; 6561 offset = offset | 0; 6562 byteLength = byteLength | 0; 6563 6564 if (!noAssert) { 6565 var maxBytes = Math.pow(2, 8 * byteLength) - 1; 6566 checkInt(this, value, offset, byteLength, maxBytes, 0); 6567 } 6568 6569 var i = byteLength - 1; 6570 var mul = 1; 6571 this[offset + i] = value & 0xFF; 6572 6573 while (--i >= 0 && (mul *= 0x100)) { 6574 this[offset + i] = value / mul & 0xFF; 6575 } 6576 6577 return offset + byteLength; 6578 }; 6579 6580 Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { 6581 value = +value; 6582 offset = offset | 0; 6583 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); 6584 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); 6585 this[offset] = value & 0xff; 6586 return offset + 1; 6587 }; 6588 6589 function objectWriteUInt16(buf, value, offset, littleEndian) { 6590 if (value < 0) value = 0xffff + value + 1; 6591 6592 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { 6593 buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8; 6594 } 6595 } 6596 6597 Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { 6598 value = +value; 6599 offset = offset | 0; 6600 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); 6601 6602 if (Buffer.TYPED_ARRAY_SUPPORT) { 6603 this[offset] = value & 0xff; 6604 this[offset + 1] = value >>> 8; 6605 } else { 6606 objectWriteUInt16(this, value, offset, true); 6607 } 6608 6609 return offset + 2; 6610 }; 6611 6612 Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { 6613 value = +value; 6614 offset = offset | 0; 6615 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); 6616 6617 if (Buffer.TYPED_ARRAY_SUPPORT) { 6618 this[offset] = value >>> 8; 6619 this[offset + 1] = value & 0xff; 6620 } else { 6621 objectWriteUInt16(this, value, offset, false); 6622 } 6623 6624 return offset + 2; 6625 }; 6626 6627 function objectWriteUInt32(buf, value, offset, littleEndian) { 6628 if (value < 0) value = 0xffffffff + value + 1; 6629 6630 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { 6631 buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff; 6632 } 6633 } 6634 6635 Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { 6636 value = +value; 6637 offset = offset | 0; 6638 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); 6639 6640 if (Buffer.TYPED_ARRAY_SUPPORT) { 6641 this[offset + 3] = value >>> 24; 6642 this[offset + 2] = value >>> 16; 6643 this[offset + 1] = value >>> 8; 6644 this[offset] = value & 0xff; 6645 } else { 6646 objectWriteUInt32(this, value, offset, true); 6647 } 6648 6649 return offset + 4; 6650 }; 6651 6652 Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { 6653 value = +value; 6654 offset = offset | 0; 6655 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); 6656 6657 if (Buffer.TYPED_ARRAY_SUPPORT) { 6658 this[offset] = value >>> 24; 6659 this[offset + 1] = value >>> 16; 6660 this[offset + 2] = value >>> 8; 6661 this[offset + 3] = value & 0xff; 6662 } else { 6663 objectWriteUInt32(this, value, offset, false); 6664 } 6665 6666 return offset + 4; 6667 }; 6668 6669 Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { 6670 value = +value; 6671 offset = offset | 0; 6672 6673 if (!noAssert) { 6674 var limit = Math.pow(2, 8 * byteLength - 1); 6675 checkInt(this, value, offset, byteLength, limit - 1, -limit); 6676 } 6677 6678 var i = 0; 6679 var mul = 1; 6680 var sub = 0; 6681 this[offset] = value & 0xFF; 6682 6683 while (++i < byteLength && (mul *= 0x100)) { 6684 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 6685 sub = 1; 6686 } 6687 6688 this[offset + i] = (value / mul >> 0) - sub & 0xFF; 6689 } 6690 6691 return offset + byteLength; 6692 }; 6693 6694 Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { 6695 value = +value; 6696 offset = offset | 0; 6697 6698 if (!noAssert) { 6699 var limit = Math.pow(2, 8 * byteLength - 1); 6700 checkInt(this, value, offset, byteLength, limit - 1, -limit); 6701 } 6702 6703 var i = byteLength - 1; 6704 var mul = 1; 6705 var sub = 0; 6706 this[offset + i] = value & 0xFF; 6707 6708 while (--i >= 0 && (mul *= 0x100)) { 6709 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 6710 sub = 1; 6711 } 6712 6713 this[offset + i] = (value / mul >> 0) - sub & 0xFF; 6714 } 6715 6716 return offset + byteLength; 6717 }; 6718 6719 Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { 6720 value = +value; 6721 offset = offset | 0; 6722 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); 6723 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); 6724 if (value < 0) value = 0xff + value + 1; 6725 this[offset] = value & 0xff; 6726 return offset + 1; 6727 }; 6728 6729 Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { 6730 value = +value; 6731 offset = offset | 0; 6732 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); 6733 6734 if (Buffer.TYPED_ARRAY_SUPPORT) { 6735 this[offset] = value & 0xff; 6736 this[offset + 1] = value >>> 8; 6737 } else { 6738 objectWriteUInt16(this, value, offset, true); 6739 } 6740 6741 return offset + 2; 6742 }; 6743 6744 Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { 6745 value = +value; 6746 offset = offset | 0; 6747 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); 6748 6749 if (Buffer.TYPED_ARRAY_SUPPORT) { 6750 this[offset] = value >>> 8; 6751 this[offset + 1] = value & 0xff; 6752 } else { 6753 objectWriteUInt16(this, value, offset, false); 6754 } 6755 6756 return offset + 2; 6757 }; 6758 6759 Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { 6760 value = +value; 6761 offset = offset | 0; 6762 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); 6763 6764 if (Buffer.TYPED_ARRAY_SUPPORT) { 6765 this[offset] = value & 0xff; 6766 this[offset + 1] = value >>> 8; 6767 this[offset + 2] = value >>> 16; 6768 this[offset + 3] = value >>> 24; 6769 } else { 6770 objectWriteUInt32(this, value, offset, true); 6771 } 6772 6773 return offset + 4; 6774 }; 6775 6776 Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { 6777 value = +value; 6778 offset = offset | 0; 6779 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); 6780 if (value < 0) value = 0xffffffff + value + 1; 6781 6782 if (Buffer.TYPED_ARRAY_SUPPORT) { 6783 this[offset] = value >>> 24; 6784 this[offset + 1] = value >>> 16; 6785 this[offset + 2] = value >>> 8; 6786 this[offset + 3] = value & 0xff; 6787 } else { 6788 objectWriteUInt32(this, value, offset, false); 6789 } 6790 6791 return offset + 4; 6792 }; 6793 6794 function checkIEEE754(buf, value, offset, ext, max, min) { 6795 if (offset + ext > buf.length) throw new RangeError('Index out of range'); 6796 if (offset < 0) throw new RangeError('Index out of range'); 6797 } 6798 6799 function writeFloat(buf, value, offset, littleEndian, noAssert) { 6800 if (!noAssert) { 6801 checkIEEE754(buf, value, offset, 4); 6802 } 6803 6804 write(buf, value, offset, littleEndian, 23, 4); 6805 return offset + 4; 6806 } 6807 6808 Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { 6809 return writeFloat(this, value, offset, true, noAssert); 6810 }; 6811 6812 Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { 6813 return writeFloat(this, value, offset, false, noAssert); 6814 }; 6815 6816 function writeDouble(buf, value, offset, littleEndian, noAssert) { 6817 if (!noAssert) { 6818 checkIEEE754(buf, value, offset, 8); 6819 } 6820 6821 write(buf, value, offset, littleEndian, 52, 8); 6822 return offset + 8; 6823 } 6824 6825 Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { 6826 return writeDouble(this, value, offset, true, noAssert); 6827 }; 6828 6829 Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { 6830 return writeDouble(this, value, offset, false, noAssert); 6831 }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 6832 6833 6834 Buffer.prototype.copy = function copy(target, targetStart, start, end) { 6835 if (!start) start = 0; 6836 if (!end && end !== 0) end = this.length; 6837 if (targetStart >= target.length) targetStart = target.length; 6838 if (!targetStart) targetStart = 0; 6839 if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done 6840 6841 if (end === start) return 0; 6842 if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions 6843 6844 if (targetStart < 0) { 6845 throw new RangeError('targetStart out of bounds'); 6846 } 6847 6848 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds'); 6849 if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? 6850 6851 if (end > this.length) end = this.length; 6852 6853 if (target.length - targetStart < end - start) { 6854 end = target.length - targetStart + start; 6855 } 6856 6857 var len = end - start; 6858 var i; 6859 6860 if (this === target && start < targetStart && targetStart < end) { 6861 // descending copy from end 6862 for (i = len - 1; i >= 0; --i) { 6863 target[i + targetStart] = this[i + start]; 6864 } 6865 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { 6866 // ascending copy from start 6867 for (i = 0; i < len; ++i) { 6868 target[i + targetStart] = this[i + start]; 6869 } 6870 } else { 6871 Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart); 6872 } 6873 6874 return len; 6875 }; // Usage: 6876 // buffer.fill(number[, offset[, end]]) 6877 // buffer.fill(buffer[, offset[, end]]) 6878 // buffer.fill(string[, offset[, end]][, encoding]) 6879 6880 6881 Buffer.prototype.fill = function fill(val, start, end, encoding) { 6882 // Handle string cases: 6883 if (typeof val === 'string') { 6884 if (typeof start === 'string') { 6885 encoding = start; 6886 start = 0; 6887 end = this.length; 6888 } else if (typeof end === 'string') { 6889 encoding = end; 6890 end = this.length; 6891 } 6892 6893 if (val.length === 1) { 6894 var code = val.charCodeAt(0); 6895 6896 if (code < 256) { 6897 val = code; 6898 } 6899 } 6900 6901 if (encoding !== undefined && typeof encoding !== 'string') { 6902 throw new TypeError('encoding must be a string'); 6903 } 6904 6905 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { 6906 throw new TypeError('Unknown encoding: ' + encoding); 6907 } 6908 } else if (typeof val === 'number') { 6909 val = val & 255; 6910 } // Invalid ranges are not set to a default, so can range check early. 6911 6912 6913 if (start < 0 || this.length < start || this.length < end) { 6914 throw new RangeError('Out of range index'); 6915 } 6916 6917 if (end <= start) { 6918 return this; 6919 } 6920 6921 start = start >>> 0; 6922 end = end === undefined ? this.length : end >>> 0; 6923 if (!val) val = 0; 6924 var i; 6925 6926 if (typeof val === 'number') { 6927 for (i = start; i < end; ++i) { 6928 this[i] = val; 6929 } 6930 } else { 6931 var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString()); 6932 var len = bytes.length; 6933 6934 for (i = 0; i < end - start; ++i) { 6935 this[i + start] = bytes[i % len]; 6936 } 6937 } 6938 6939 return this; 6940 }; // HELPER FUNCTIONS 6941 // ================ 6942 6943 6944 var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g; 6945 6946 function base64clean(str) { 6947 // Node strips out invalid characters like \n and \t from the string, base64-js does not 6948 str = stringtrim(str).replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' 6949 6950 if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 6951 6952 while (str.length % 4 !== 0) { 6953 str = str + '='; 6954 } 6955 6956 return str; 6957 } 6958 6959 function stringtrim(str) { 6960 if (str.trim) return str.trim(); 6961 return str.replace(/^\s+|\s+$/g, ''); 6962 } 6963 6964 function toHex(n) { 6965 if (n < 16) return '0' + n.toString(16); 6966 return n.toString(16); 6967 } 6968 6969 function utf8ToBytes(string, units) { 6970 units = units || Infinity; 6971 var codePoint; 6972 var length = string.length; 6973 var leadSurrogate = null; 6974 var bytes = []; 6975 6976 for (var i = 0; i < length; ++i) { 6977 codePoint = string.charCodeAt(i); // is surrogate component 6978 6979 if (codePoint > 0xD7FF && codePoint < 0xE000) { 6980 // last char was a lead 6981 if (!leadSurrogate) { 6982 // no lead yet 6983 if (codePoint > 0xDBFF) { 6984 // unexpected trail 6985 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 6986 continue; 6987 } else if (i + 1 === length) { 6988 // unpaired lead 6989 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 6990 continue; 6991 } // valid lead 6992 6993 6994 leadSurrogate = codePoint; 6995 continue; 6996 } // 2 leads in a row 6997 6998 6999 if (codePoint < 0xDC00) { 7000 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 7001 leadSurrogate = codePoint; 7002 continue; 7003 } // valid surrogate pair 7004 7005 7006 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; 7007 } else if (leadSurrogate) { 7008 // valid bmp char, but last char was a lead 7009 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 7010 } 7011 7012 leadSurrogate = null; // encode utf8 7013 7014 if (codePoint < 0x80) { 7015 if ((units -= 1) < 0) break; 7016 bytes.push(codePoint); 7017 } else if (codePoint < 0x800) { 7018 if ((units -= 2) < 0) break; 7019 bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); 7020 } else if (codePoint < 0x10000) { 7021 if ((units -= 3) < 0) break; 7022 bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); 7023 } else if (codePoint < 0x110000) { 7024 if ((units -= 4) < 0) break; 7025 bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); 7026 } else { 7027 throw new Error('Invalid code point'); 7028 } 7029 } 7030 7031 return bytes; 7032 } 7033 7034 function asciiToBytes(str) { 7035 var byteArray = []; 7036 7037 for (var i = 0; i < str.length; ++i) { 7038 // Node's code seems to be doing this and not & 0x7F.. 7039 byteArray.push(str.charCodeAt(i) & 0xFF); 7040 } 7041 7042 return byteArray; 7043 } 7044 7045 function utf16leToBytes(str, units) { 7046 var c, hi, lo; 7047 var byteArray = []; 7048 7049 for (var i = 0; i < str.length; ++i) { 7050 if ((units -= 2) < 0) break; 7051 c = str.charCodeAt(i); 7052 hi = c >> 8; 7053 lo = c % 256; 7054 byteArray.push(lo); 7055 byteArray.push(hi); 7056 } 7057 7058 return byteArray; 7059 } 7060 7061 function base64ToBytes(str) { 7062 return toByteArray(base64clean(str)); 7063 } 7064 7065 function blitBuffer(src, dst, offset, length) { 7066 for (var i = 0; i < length; ++i) { 7067 if (i + offset >= dst.length || i >= src.length) break; 7068 dst[i + offset] = src[i]; 7069 } 7070 7071 return i; 7072 } 7073 7074 function isnan(val) { 7075 return val !== val; // eslint-disable-line no-self-compare 7076 } // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence 7077 // The _isBuffer check is for Safari 5-7 support, because it's missing 7078 // Object.prototype.constructor. Remove this eventually 7079 7080 7081 function isBuffer(obj) { 7082 return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj)); 7083 } 7084 7085 function isFastBuffer(obj) { 7086 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj); 7087 } // For Node v0.10 support. Remove this eventually. 7088 7089 7090 function isSlowBuffer(obj) { 7091 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0)); 7092 } 7093 7094 // based off https://github.com/defunctzombie/node-process/blob/master/browser.js 7095 7096 function defaultSetTimout$1() { 7097 throw new Error('setTimeout has not been defined'); 7098 } 7099 7100 function defaultClearTimeout$1() { 7101 throw new Error('clearTimeout has not been defined'); 7102 } 7103 7104 var cachedSetTimeout$1 = defaultSetTimout$1; 7105 var cachedClearTimeout$1 = defaultClearTimeout$1; 7106 7107 if (typeof global$2.setTimeout === 'function') { 7108 cachedSetTimeout$1 = setTimeout; 7109 } 7110 7111 if (typeof global$2.clearTimeout === 'function') { 7112 cachedClearTimeout$1 = clearTimeout; 7113 } 7114 7115 function runTimeout$1(fun) { 7116 if (cachedSetTimeout$1 === setTimeout) { 7117 //normal enviroments in sane situations 7118 return setTimeout(fun, 0); 7119 } // if setTimeout wasn't available but was latter defined 7120 7121 7122 if ((cachedSetTimeout$1 === defaultSetTimout$1 || !cachedSetTimeout$1) && setTimeout) { 7123 cachedSetTimeout$1 = setTimeout; 7124 return setTimeout(fun, 0); 7125 } 7126 7127 try { 7128 // when when somebody has screwed with setTimeout but no I.E. maddness 7129 return cachedSetTimeout$1(fun, 0); 7130 } catch (e) { 7131 try { 7132 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 7133 return cachedSetTimeout$1.call(null, fun, 0); 7134 } catch (e) { 7135 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 7136 return cachedSetTimeout$1.call(this, fun, 0); 7137 } 7138 } 7139 } 7140 7141 function runClearTimeout$1(marker) { 7142 if (cachedClearTimeout$1 === clearTimeout) { 7143 //normal enviroments in sane situations 7144 return clearTimeout(marker); 7145 } // if clearTimeout wasn't available but was latter defined 7146 7147 7148 if ((cachedClearTimeout$1 === defaultClearTimeout$1 || !cachedClearTimeout$1) && clearTimeout) { 7149 cachedClearTimeout$1 = clearTimeout; 7150 return clearTimeout(marker); 7151 } 7152 7153 try { 7154 // when when somebody has screwed with setTimeout but no I.E. maddness 7155 return cachedClearTimeout$1(marker); 7156 } catch (e) { 7157 try { 7158 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 7159 return cachedClearTimeout$1.call(null, marker); 7160 } catch (e) { 7161 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 7162 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 7163 return cachedClearTimeout$1.call(this, marker); 7164 } 7165 } 7166 } 7167 7168 var queue$1 = []; 7169 var draining$1 = false; 7170 var currentQueue$1; 7171 var queueIndex$1 = -1; 7172 7173 function cleanUpNextTick$1() { 7174 if (!draining$1 || !currentQueue$1) { 7175 return; 7176 } 7177 7178 draining$1 = false; 7179 7180 if (currentQueue$1.length) { 7181 queue$1 = currentQueue$1.concat(queue$1); 7182 } else { 7183 queueIndex$1 = -1; 7184 } 7185 7186 if (queue$1.length) { 7187 drainQueue$1(); 7188 } 7189 } 7190 7191 function drainQueue$1() { 7192 if (draining$1) { 7193 return; 7194 } 7195 7196 var timeout = runTimeout$1(cleanUpNextTick$1); 7197 draining$1 = true; 7198 var len = queue$1.length; 7199 7200 while (len) { 7201 currentQueue$1 = queue$1; 7202 queue$1 = []; 7203 7204 while (++queueIndex$1 < len) { 7205 if (currentQueue$1) { 7206 currentQueue$1[queueIndex$1].run(); 7207 } 7208 } 7209 7210 queueIndex$1 = -1; 7211 len = queue$1.length; 7212 } 7213 7214 currentQueue$1 = null; 7215 draining$1 = false; 7216 runClearTimeout$1(timeout); 7217 } 7218 7219 function nextTick$1(fun) { 7220 var args = new Array(arguments.length - 1); 7221 7222 if (arguments.length > 1) { 7223 for (var i = 1; i < arguments.length; i++) { 7224 args[i - 1] = arguments[i]; 7225 } 7226 } 7227 7228 queue$1.push(new Item$1(fun, args)); 7229 7230 if (queue$1.length === 1 && !draining$1) { 7231 runTimeout$1(drainQueue$1); 7232 } 7233 } // v8 likes predictible objects 7234 7235 7236 function Item$1(fun, array) { 7237 this.fun = fun; 7238 this.array = array; 7239 } 7240 7241 Item$1.prototype.run = function () { 7242 this.fun.apply(null, this.array); 7243 }; 7244 7245 7246 var performance$1 = global$2.performance || {}; 7247 7248 performance$1.now || performance$1.mozNow || performance$1.msNow || performance$1.oNow || performance$1.webkitNow || function () { 7249 return new Date().getTime(); 7250 }; // generate timestamp or delta 7251 7252 var inherits; 7253 7254 if (typeof Object.create === 'function') { 7255 inherits = function inherits(ctor, superCtor) { 7256 // implementation from standard node.js 'util' module 7257 ctor.super_ = superCtor; 7258 ctor.prototype = Object.create(superCtor.prototype, { 7259 constructor: { 7260 value: ctor, 7261 enumerable: false, 7262 writable: true, 7263 configurable: true 7264 } 7265 }); 7266 }; 7267 } else { 7268 inherits = function inherits(ctor, superCtor) { 7269 ctor.super_ = superCtor; 7270 7271 var TempCtor = function TempCtor() {}; 7272 7273 TempCtor.prototype = superCtor.prototype; 7274 ctor.prototype = new TempCtor(); 7275 ctor.prototype.constructor = ctor; 7276 }; 7277 } 7278 7279 var inherits$1 = inherits; 7280 7281 var formatRegExp = /%[sdj%]/g; 7282 function format(f) { 7283 if (!isString(f)) { 7284 var objects = []; 7285 7286 for (var i = 0; i < arguments.length; i++) { 7287 objects.push(inspect(arguments[i])); 7288 } 7289 7290 return objects.join(' '); 7291 } 7292 7293 var i = 1; 7294 var args = arguments; 7295 var len = args.length; 7296 var str = String(f).replace(formatRegExp, function (x) { 7297 if (x === '%%') return '%'; 7298 if (i >= len) return x; 7299 7300 switch (x) { 7301 case '%s': 7302 return String(args[i++]); 7303 7304 case '%d': 7305 return Number(args[i++]); 7306 7307 case '%j': 7308 try { 7309 return JSON.stringify(args[i++]); 7310 } catch (_) { 7311 return '[Circular]'; 7312 } 7313 7314 default: 7315 return x; 7316 } 7317 }); 7318 7319 for (var x = args[i]; i < len; x = args[++i]) { 7320 if (isNull(x) || !isObject$1(x)) { 7321 str += ' ' + x; 7322 } else { 7323 str += ' ' + inspect(x); 7324 } 7325 } 7326 7327 return str; 7328 } 7329 // Returns a modified function which warns once by default. 7330 // If --no-deprecation is set, then it is a no-op. 7331 7332 function deprecate(fn, msg) { 7333 // Allow for deprecating things in the process of starting up. 7334 if (isUndefined(global$2.process)) { 7335 return function () { 7336 return deprecate(fn, msg).apply(this, arguments); 7337 }; 7338 } 7339 7340 var warned = false; 7341 7342 function deprecated() { 7343 if (!warned) { 7344 { 7345 console.error(msg); 7346 } 7347 7348 warned = true; 7349 } 7350 7351 return fn.apply(this, arguments); 7352 } 7353 7354 return deprecated; 7355 } 7356 var debugs = {}; 7357 var debugEnviron; 7358 function debuglog(set) { 7359 if (isUndefined(debugEnviron)) debugEnviron = ''; 7360 set = set.toUpperCase(); 7361 7362 if (!debugs[set]) { 7363 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { 7364 var pid = 0; 7365 7366 debugs[set] = function () { 7367 var msg = format.apply(null, arguments); 7368 console.error('%s %d: %s', set, pid, msg); 7369 }; 7370 } else { 7371 debugs[set] = function () {}; 7372 } 7373 } 7374 7375 return debugs[set]; 7376 } 7377 /** 7378 * Echos the value of a value. Trys to print the value out 7379 * in the best way possible given the different types. 7380 * 7381 * @param {Object} obj The object to print out. 7382 * @param {Object} opts Optional options object that alters the output. 7383 */ 7384 7385 /* legacy: obj, showHidden, depth, colors*/ 7386 7387 function inspect(obj, opts) { 7388 // default options 7389 var ctx = { 7390 seen: [], 7391 stylize: stylizeNoColor 7392 }; // legacy... 7393 7394 if (arguments.length >= 3) ctx.depth = arguments[2]; 7395 if (arguments.length >= 4) ctx.colors = arguments[3]; 7396 7397 if (isBoolean(opts)) { 7398 // legacy... 7399 ctx.showHidden = opts; 7400 } else if (opts) { 7401 // got an "options" object 7402 _extend(ctx, opts); 7403 } // set default options 7404 7405 7406 if (isUndefined(ctx.showHidden)) ctx.showHidden = false; 7407 if (isUndefined(ctx.depth)) ctx.depth = 2; 7408 if (isUndefined(ctx.colors)) ctx.colors = false; 7409 if (isUndefined(ctx.customInspect)) ctx.customInspect = true; 7410 if (ctx.colors) ctx.stylize = stylizeWithColor; 7411 return formatValue(ctx, obj, ctx.depth); 7412 } // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics 7413 7414 inspect.colors = { 7415 'bold': [1, 22], 7416 'italic': [3, 23], 7417 'underline': [4, 24], 7418 'inverse': [7, 27], 7419 'white': [37, 39], 7420 'grey': [90, 39], 7421 'black': [30, 39], 7422 'blue': [34, 39], 7423 'cyan': [36, 39], 7424 'green': [32, 39], 7425 'magenta': [35, 39], 7426 'red': [31, 39], 7427 'yellow': [33, 39] 7428 }; // Don't use 'blue' not visible on cmd.exe 7429 7430 inspect.styles = { 7431 'special': 'cyan', 7432 'number': 'yellow', 7433 'boolean': 'yellow', 7434 'undefined': 'grey', 7435 'null': 'bold', 7436 'string': 'green', 7437 'date': 'magenta', 7438 // "name": intentionally not styling 7439 'regexp': 'red' 7440 }; 7441 7442 function stylizeWithColor(str, styleType) { 7443 var style = inspect.styles[styleType]; 7444 7445 if (style) { 7446 return "\x1B[" + inspect.colors[style][0] + 'm' + str + "\x1B[" + inspect.colors[style][1] + 'm'; 7447 } else { 7448 return str; 7449 } 7450 } 7451 7452 function stylizeNoColor(str, styleType) { 7453 return str; 7454 } 7455 7456 function arrayToHash(array) { 7457 var hash = {}; 7458 array.forEach(function (val, idx) { 7459 hash[val] = true; 7460 }); 7461 return hash; 7462 } 7463 7464 function formatValue(ctx, value, recurseTimes) { 7465 // Provide a hook for user-specified inspect functions. 7466 // Check that value is an object with an inspect function on it 7467 if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special 7468 value.inspect !== inspect && // Also filter out any prototype objects using the circular check. 7469 !(value.constructor && value.constructor.prototype === value)) { 7470 var ret = value.inspect(recurseTimes, ctx); 7471 7472 if (!isString(ret)) { 7473 ret = formatValue(ctx, ret, recurseTimes); 7474 } 7475 7476 return ret; 7477 } // Primitive types cannot have properties 7478 7479 7480 var primitive = formatPrimitive(ctx, value); 7481 7482 if (primitive) { 7483 return primitive; 7484 } // Look up the keys of the object. 7485 7486 7487 var keys = Object.keys(value); 7488 var visibleKeys = arrayToHash(keys); 7489 7490 if (ctx.showHidden) { 7491 keys = Object.getOwnPropertyNames(value); 7492 } // IE doesn't make error fields non-enumerable 7493 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx 7494 7495 7496 if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { 7497 return formatError(value); 7498 } // Some type of object without properties can be shortcutted. 7499 7500 7501 if (keys.length === 0) { 7502 if (isFunction(value)) { 7503 var name = value.name ? ': ' + value.name : ''; 7504 return ctx.stylize('[Function' + name + ']', 'special'); 7505 } 7506 7507 if (isRegExp(value)) { 7508 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); 7509 } 7510 7511 if (isDate(value)) { 7512 return ctx.stylize(Date.prototype.toString.call(value), 'date'); 7513 } 7514 7515 if (isError(value)) { 7516 return formatError(value); 7517 } 7518 } 7519 7520 var base = '', 7521 array = false, 7522 braces = ['{', '}']; // Make Array say that they are Array 7523 7524 if (isArray$2(value)) { 7525 array = true; 7526 braces = ['[', ']']; 7527 } // Make functions say that they are functions 7528 7529 7530 if (isFunction(value)) { 7531 var n = value.name ? ': ' + value.name : ''; 7532 base = ' [Function' + n + ']'; 7533 } // Make RegExps say that they are RegExps 7534 7535 7536 if (isRegExp(value)) { 7537 base = ' ' + RegExp.prototype.toString.call(value); 7538 } // Make dates with properties first say the date 7539 7540 7541 if (isDate(value)) { 7542 base = ' ' + Date.prototype.toUTCString.call(value); 7543 } // Make error with message first say the error 7544 7545 7546 if (isError(value)) { 7547 base = ' ' + formatError(value); 7548 } 7549 7550 if (keys.length === 0 && (!array || value.length == 0)) { 7551 return braces[0] + base + braces[1]; 7552 } 7553 7554 if (recurseTimes < 0) { 7555 if (isRegExp(value)) { 7556 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); 7557 } else { 7558 return ctx.stylize('[Object]', 'special'); 7559 } 7560 } 7561 7562 ctx.seen.push(value); 7563 var output; 7564 7565 if (array) { 7566 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); 7567 } else { 7568 output = keys.map(function (key) { 7569 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); 7570 }); 7571 } 7572 7573 ctx.seen.pop(); 7574 return reduceToSingleString(output, base, braces); 7575 } 7576 7577 function formatPrimitive(ctx, value) { 7578 if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); 7579 7580 if (isString(value)) { 7581 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\''; 7582 return ctx.stylize(simple, 'string'); 7583 } 7584 7585 if (isNumber(value)) return ctx.stylize('' + value, 'number'); 7586 if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here. 7587 7588 if (isNull(value)) return ctx.stylize('null', 'null'); 7589 } 7590 7591 function formatError(value) { 7592 return '[' + Error.prototype.toString.call(value) + ']'; 7593 } 7594 7595 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { 7596 var output = []; 7597 7598 for (var i = 0, l = value.length; i < l; ++i) { 7599 if (hasOwnProperty$1(value, String(i))) { 7600 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); 7601 } else { 7602 output.push(''); 7603 } 7604 } 7605 7606 keys.forEach(function (key) { 7607 if (!key.match(/^\d+$/)) { 7608 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); 7609 } 7610 }); 7611 return output; 7612 } 7613 7614 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { 7615 var name, str, desc; 7616 desc = Object.getOwnPropertyDescriptor(value, key) || { 7617 value: value[key] 7618 }; 7619 7620 if (desc.get) { 7621 if (desc.set) { 7622 str = ctx.stylize('[Getter/Setter]', 'special'); 7623 } else { 7624 str = ctx.stylize('[Getter]', 'special'); 7625 } 7626 } else { 7627 if (desc.set) { 7628 str = ctx.stylize('[Setter]', 'special'); 7629 } 7630 } 7631 7632 if (!hasOwnProperty$1(visibleKeys, key)) { 7633 name = '[' + key + ']'; 7634 } 7635 7636 if (!str) { 7637 if (ctx.seen.indexOf(desc.value) < 0) { 7638 if (isNull(recurseTimes)) { 7639 str = formatValue(ctx, desc.value, null); 7640 } else { 7641 str = formatValue(ctx, desc.value, recurseTimes - 1); 7642 } 7643 7644 if (str.indexOf('\n') > -1) { 7645 if (array) { 7646 str = str.split('\n').map(function (line) { 7647 return ' ' + line; 7648 }).join('\n').substr(2); 7649 } else { 7650 str = '\n' + str.split('\n').map(function (line) { 7651 return ' ' + line; 7652 }).join('\n'); 7653 } 7654 } 7655 } else { 7656 str = ctx.stylize('[Circular]', 'special'); 7657 } 7658 } 7659 7660 if (isUndefined(name)) { 7661 if (array && key.match(/^\d+$/)) { 7662 return str; 7663 } 7664 7665 name = JSON.stringify('' + key); 7666 7667 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { 7668 name = name.substr(1, name.length - 2); 7669 name = ctx.stylize(name, 'name'); 7670 } else { 7671 name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"); 7672 name = ctx.stylize(name, 'string'); 7673 } 7674 } 7675 7676 return name + ': ' + str; 7677 } 7678 7679 function reduceToSingleString(output, base, braces) { 7680 var length = output.reduce(function (prev, cur) { 7681 if (cur.indexOf('\n') >= 0) ; 7682 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; 7683 }, 0); 7684 7685 if (length > 60) { 7686 return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1]; 7687 } 7688 7689 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; 7690 } // NOTE: These type checking functions intentionally don't use `instanceof` 7691 // because it is fragile and can be easily faked with `Object.create()`. 7692 7693 7694 function isArray$2(ar) { 7695 return Array.isArray(ar); 7696 } 7697 function isBoolean(arg) { 7698 return typeof arg === 'boolean'; 7699 } 7700 function isNull(arg) { 7701 return arg === null; 7702 } 7703 function isNullOrUndefined(arg) { 7704 return arg == null; 7705 } 7706 function isNumber(arg) { 7707 return typeof arg === 'number'; 7708 } 7709 function isString(arg) { 7710 return typeof arg === 'string'; 7711 } 7712 function isSymbol$1(arg) { 7713 return _typeof(arg) === 'symbol'; 7714 } 7715 function isUndefined(arg) { 7716 return arg === void 0; 7717 } 7718 function isRegExp(re) { 7719 return isObject$1(re) && objectToString$1(re) === '[object RegExp]'; 7720 } 7721 function isObject$1(arg) { 7722 return _typeof(arg) === 'object' && arg !== null; 7723 } 7724 function isDate(d) { 7725 return isObject$1(d) && objectToString$1(d) === '[object Date]'; 7726 } 7727 function isError(e) { 7728 return isObject$1(e) && (objectToString$1(e) === '[object Error]' || e instanceof Error); 7729 } 7730 function isFunction(arg) { 7731 return typeof arg === 'function'; 7732 } 7733 function isPrimitive(arg) { 7734 return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || _typeof(arg) === 'symbol' || // ES6 symbol 7735 typeof arg === 'undefined'; 7736 } 7737 function isBuffer$1(maybeBuf) { 7738 return isBuffer(maybeBuf); 7739 } 7740 7741 function objectToString$1(o) { 7742 return Object.prototype.toString.call(o); 7743 } 7744 7745 function pad(n) { 7746 return n < 10 ? '0' + n.toString(10) : n.toString(10); 7747 } 7748 7749 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // 26 Feb 16:19:34 7750 7751 function timestamp() { 7752 var d = new Date(); 7753 var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); 7754 return [d.getDate(), months[d.getMonth()], time].join(' '); 7755 } // log is just a thin wrapper to console.log that prepends a timestamp 7756 7757 7758 function log$1() { 7759 console.log('%s - %s', timestamp(), format.apply(null, arguments)); 7760 } 7761 function _extend(origin, add) { 7762 // Don't do anything if add isn't an object 7763 if (!add || !isObject$1(add)) return origin; 7764 var keys = Object.keys(add); 7765 var i = keys.length; 7766 7767 while (i--) { 7768 origin[keys[i]] = add[keys[i]]; 7769 } 7770 7771 return origin; 7772 } 7773 7774 function hasOwnProperty$1(obj, prop) { 7775 return Object.prototype.hasOwnProperty.call(obj, prop); 7776 } 7777 7778 var util = { 7779 inherits: inherits$1, 7780 _extend: _extend, 7781 log: log$1, 7782 isBuffer: isBuffer$1, 7783 isPrimitive: isPrimitive, 7784 isFunction: isFunction, 7785 isError: isError, 7786 isDate: isDate, 7787 isObject: isObject$1, 7788 isRegExp: isRegExp, 7789 isUndefined: isUndefined, 7790 isSymbol: isSymbol$1, 7791 isString: isString, 7792 isNumber: isNumber, 7793 isNullOrUndefined: isNullOrUndefined, 7794 isNull: isNull, 7795 isBoolean: isBoolean, 7796 isArray: isArray$2, 7797 inspect: inspect, 7798 deprecate: deprecate, 7799 format: format, 7800 debuglog: debuglog 7801 }; 7802 7803 var lookup$1 = []; 7804 var revLookup$1 = []; 7805 var Arr$1 = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; 7806 var inited$1 = false; 7807 7808 function init$1() { 7809 inited$1 = true; 7810 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 7811 7812 for (var i = 0, len = code.length; i < len; ++i) { 7813 lookup$1[i] = code[i]; 7814 revLookup$1[code.charCodeAt(i)] = i; 7815 } 7816 7817 revLookup$1['-'.charCodeAt(0)] = 62; 7818 revLookup$1['_'.charCodeAt(0)] = 63; 7819 } 7820 7821 function toByteArray$1(b64) { 7822 if (!inited$1) { 7823 init$1(); 7824 } 7825 7826 var i, j, l, tmp, placeHolders, arr; 7827 var len = b64.length; 7828 7829 if (len % 4 > 0) { 7830 throw new Error('Invalid string. Length must be a multiple of 4'); 7831 } // the number of equal signs (place holders) 7832 // if there are two placeholders, than the two characters before it 7833 // represent one byte 7834 // if there is only one, then the three characters before it represent 2 bytes 7835 // this is just a cheap hack to not do indexOf twice 7836 7837 7838 placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; // base64 is 4/3 + up to two characters of the original data 7839 7840 arr = new Arr$1(len * 3 / 4 - placeHolders); // if there are placeholders, only get up to the last complete 4 chars 7841 7842 l = placeHolders > 0 ? len - 4 : len; 7843 var L = 0; 7844 7845 for (i = 0, j = 0; i < l; i += 4, j += 3) { 7846 tmp = revLookup$1[b64.charCodeAt(i)] << 18 | revLookup$1[b64.charCodeAt(i + 1)] << 12 | revLookup$1[b64.charCodeAt(i + 2)] << 6 | revLookup$1[b64.charCodeAt(i + 3)]; 7847 arr[L++] = tmp >> 16 & 0xFF; 7848 arr[L++] = tmp >> 8 & 0xFF; 7849 arr[L++] = tmp & 0xFF; 7850 } 7851 7852 if (placeHolders === 2) { 7853 tmp = revLookup$1[b64.charCodeAt(i)] << 2 | revLookup$1[b64.charCodeAt(i + 1)] >> 4; 7854 arr[L++] = tmp & 0xFF; 7855 } else if (placeHolders === 1) { 7856 tmp = revLookup$1[b64.charCodeAt(i)] << 10 | revLookup$1[b64.charCodeAt(i + 1)] << 4 | revLookup$1[b64.charCodeAt(i + 2)] >> 2; 7857 arr[L++] = tmp >> 8 & 0xFF; 7858 arr[L++] = tmp & 0xFF; 7859 } 7860 7861 return arr; 7862 } 7863 7864 function tripletToBase64$1(num) { 7865 return lookup$1[num >> 18 & 0x3F] + lookup$1[num >> 12 & 0x3F] + lookup$1[num >> 6 & 0x3F] + lookup$1[num & 0x3F]; 7866 } 7867 7868 function encodeChunk$1(uint8, start, end) { 7869 var tmp; 7870 var output = []; 7871 7872 for (var i = start; i < end; i += 3) { 7873 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2]; 7874 output.push(tripletToBase64$1(tmp)); 7875 } 7876 7877 return output.join(''); 7878 } 7879 7880 function fromByteArray$1(uint8) { 7881 if (!inited$1) { 7882 init$1(); 7883 } 7884 7885 var tmp; 7886 var len = uint8.length; 7887 var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes 7888 7889 var output = ''; 7890 var parts = []; 7891 var maxChunkLength = 16383; // must be multiple of 3 7892 // go through the array every three bytes, we'll deal with trailing stuff later 7893 7894 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { 7895 parts.push(encodeChunk$1(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); 7896 } // pad the end with zeros, but make sure to not forget the extra bytes 7897 7898 7899 if (extraBytes === 1) { 7900 tmp = uint8[len - 1]; 7901 output += lookup$1[tmp >> 2]; 7902 output += lookup$1[tmp << 4 & 0x3F]; 7903 output += '=='; 7904 } else if (extraBytes === 2) { 7905 tmp = (uint8[len - 2] << 8) + uint8[len - 1]; 7906 output += lookup$1[tmp >> 10]; 7907 output += lookup$1[tmp >> 4 & 0x3F]; 7908 output += lookup$1[tmp << 2 & 0x3F]; 7909 output += '='; 7910 } 7911 7912 parts.push(output); 7913 return parts.join(''); 7914 } 7915 7916 function read$1(buffer, offset, isLE, mLen, nBytes) { 7917 var e, m; 7918 var eLen = nBytes * 8 - mLen - 1; 7919 var eMax = (1 << eLen) - 1; 7920 var eBias = eMax >> 1; 7921 var nBits = -7; 7922 var i = isLE ? nBytes - 1 : 0; 7923 var d = isLE ? -1 : 1; 7924 var s = buffer[offset + i]; 7925 i += d; 7926 e = s & (1 << -nBits) - 1; 7927 s >>= -nBits; 7928 nBits += eLen; 7929 7930 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} 7931 7932 m = e & (1 << -nBits) - 1; 7933 e >>= -nBits; 7934 nBits += mLen; 7935 7936 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} 7937 7938 if (e === 0) { 7939 e = 1 - eBias; 7940 } else if (e === eMax) { 7941 return m ? NaN : (s ? -1 : 1) * Infinity; 7942 } else { 7943 m = m + Math.pow(2, mLen); 7944 e = e - eBias; 7945 } 7946 7947 return (s ? -1 : 1) * m * Math.pow(2, e - mLen); 7948 } 7949 7950 function write$1(buffer, value, offset, isLE, mLen, nBytes) { 7951 var e, m, c; 7952 var eLen = nBytes * 8 - mLen - 1; 7953 var eMax = (1 << eLen) - 1; 7954 var eBias = eMax >> 1; 7955 var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; 7956 var i = isLE ? 0 : nBytes - 1; 7957 var d = isLE ? 1 : -1; 7958 var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; 7959 value = Math.abs(value); 7960 7961 if (isNaN(value) || value === Infinity) { 7962 m = isNaN(value) ? 1 : 0; 7963 e = eMax; 7964 } else { 7965 e = Math.floor(Math.log(value) / Math.LN2); 7966 7967 if (value * (c = Math.pow(2, -e)) < 1) { 7968 e--; 7969 c *= 2; 7970 } 7971 7972 if (e + eBias >= 1) { 7973 value += rt / c; 7974 } else { 7975 value += rt * Math.pow(2, 1 - eBias); 7976 } 7977 7978 if (value * c >= 2) { 7979 e++; 7980 c /= 2; 7981 } 7982 7983 if (e + eBias >= eMax) { 7984 m = 0; 7985 e = eMax; 7986 } else if (e + eBias >= 1) { 7987 m = (value * c - 1) * Math.pow(2, mLen); 7988 e = e + eBias; 7989 } else { 7990 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); 7991 e = 0; 7992 } 7993 } 7994 7995 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 7996 7997 e = e << mLen | m; 7998 eLen += mLen; 7999 8000 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 8001 8002 buffer[offset + i - d] |= s * 128; 8003 } 8004 8005 var toString$3 = {}.toString; 8006 8007 var isArray$3 = Array.isArray || function (arr) { 8008 return toString$3.call(arr) == '[object Array]'; 8009 }; 8010 /*! 8011 * The buffer module from node.js, for the browser. 8012 * 8013 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> 8014 * @license MIT 8015 */ 8016 8017 8018 var INSPECT_MAX_BYTES$1 = 50; 8019 /** 8020 * If `Buffer.TYPED_ARRAY_SUPPORT`: 8021 * === true Use Uint8Array implementation (fastest) 8022 * === false Use Object implementation (most compatible, even IE6) 8023 * 8024 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 8025 * Opera 11.6+, iOS 4.2+. 8026 * 8027 * Due to various browser bugs, sometimes the Object implementation will be used even 8028 * when the browser supports typed arrays. 8029 * 8030 * Note: 8031 * 8032 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 8033 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 8034 * 8035 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 8036 * 8037 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 8038 * incorrect length in some situations. 8039 8040 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 8041 * get the Object implementation, which is slower but behaves correctly. 8042 */ 8043 8044 Buffer$1.TYPED_ARRAY_SUPPORT = global$2.TYPED_ARRAY_SUPPORT !== undefined ? global$2.TYPED_ARRAY_SUPPORT : true; 8045 8046 function kMaxLength$1() { 8047 return Buffer$1.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff; 8048 } 8049 8050 function createBuffer$1(that, length) { 8051 if (kMaxLength$1() < length) { 8052 throw new RangeError('Invalid typed array length'); 8053 } 8054 8055 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 8056 // Return an augmented `Uint8Array` instance, for best performance 8057 that = new Uint8Array(length); 8058 that.__proto__ = Buffer$1.prototype; 8059 } else { 8060 // Fallback: Return an object instance of the Buffer class 8061 if (that === null) { 8062 that = new Buffer$1(length); 8063 } 8064 8065 that.length = length; 8066 } 8067 8068 return that; 8069 } 8070 /** 8071 * The Buffer constructor returns instances of `Uint8Array` that have their 8072 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 8073 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 8074 * and the `Uint8Array` methods. Square bracket notation works as expected -- it 8075 * returns a single octet. 8076 * 8077 * The `Uint8Array` prototype remains unmodified. 8078 */ 8079 8080 8081 function Buffer$1(arg, encodingOrOffset, length) { 8082 if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) { 8083 return new Buffer$1(arg, encodingOrOffset, length); 8084 } // Common case. 8085 8086 8087 if (typeof arg === 'number') { 8088 if (typeof encodingOrOffset === 'string') { 8089 throw new Error('If encoding is specified then the first argument must be a string'); 8090 } 8091 8092 return allocUnsafe$1(this, arg); 8093 } 8094 8095 return from$1(this, arg, encodingOrOffset, length); 8096 } 8097 8098 Buffer$1.poolSize = 8192; // not used by this implementation 8099 // TODO: Legacy, not needed anymore. Remove in next major version. 8100 8101 Buffer$1._augment = function (arr) { 8102 arr.__proto__ = Buffer$1.prototype; 8103 return arr; 8104 }; 8105 8106 function from$1(that, value, encodingOrOffset, length) { 8107 if (typeof value === 'number') { 8108 throw new TypeError('"value" argument must not be a number'); 8109 } 8110 8111 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { 8112 return fromArrayBuffer$1(that, value, encodingOrOffset, length); 8113 } 8114 8115 if (typeof value === 'string') { 8116 return fromString$1(that, value, encodingOrOffset); 8117 } 8118 8119 return fromObject$1(that, value); 8120 } 8121 /** 8122 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 8123 * if value is a number. 8124 * Buffer.from(str[, encoding]) 8125 * Buffer.from(array) 8126 * Buffer.from(buffer) 8127 * Buffer.from(arrayBuffer[, byteOffset[, length]]) 8128 **/ 8129 8130 8131 Buffer$1.from = function (value, encodingOrOffset, length) { 8132 return from$1(null, value, encodingOrOffset, length); 8133 }; 8134 8135 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 8136 Buffer$1.prototype.__proto__ = Uint8Array.prototype; 8137 Buffer$1.__proto__ = Uint8Array; 8138 } 8139 8140 function assertSize$1(size) { 8141 if (typeof size !== 'number') { 8142 throw new TypeError('"size" argument must be a number'); 8143 } else if (size < 0) { 8144 throw new RangeError('"size" argument must not be negative'); 8145 } 8146 } 8147 8148 function alloc$1(that, size, fill, encoding) { 8149 assertSize$1(size); 8150 8151 if (size <= 0) { 8152 return createBuffer$1(that, size); 8153 } 8154 8155 if (fill !== undefined) { 8156 // Only pay attention to encoding if it's a string. This 8157 // prevents accidentally sending in a number that would 8158 // be interpretted as a start offset. 8159 return typeof encoding === 'string' ? createBuffer$1(that, size).fill(fill, encoding) : createBuffer$1(that, size).fill(fill); 8160 } 8161 8162 return createBuffer$1(that, size); 8163 } 8164 /** 8165 * Creates a new filled Buffer instance. 8166 * alloc(size[, fill[, encoding]]) 8167 **/ 8168 8169 8170 Buffer$1.alloc = function (size, fill, encoding) { 8171 return alloc$1(null, size, fill, encoding); 8172 }; 8173 8174 function allocUnsafe$1(that, size) { 8175 assertSize$1(size); 8176 that = createBuffer$1(that, size < 0 ? 0 : checked$1(size) | 0); 8177 8178 if (!Buffer$1.TYPED_ARRAY_SUPPORT) { 8179 for (var i = 0; i < size; ++i) { 8180 that[i] = 0; 8181 } 8182 } 8183 8184 return that; 8185 } 8186 /** 8187 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 8188 * */ 8189 8190 8191 Buffer$1.allocUnsafe = function (size) { 8192 return allocUnsafe$1(null, size); 8193 }; 8194 /** 8195 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 8196 */ 8197 8198 8199 Buffer$1.allocUnsafeSlow = function (size) { 8200 return allocUnsafe$1(null, size); 8201 }; 8202 8203 function fromString$1(that, string, encoding) { 8204 if (typeof encoding !== 'string' || encoding === '') { 8205 encoding = 'utf8'; 8206 } 8207 8208 if (!Buffer$1.isEncoding(encoding)) { 8209 throw new TypeError('"encoding" must be a valid string encoding'); 8210 } 8211 8212 var length = byteLength$1(string, encoding) | 0; 8213 that = createBuffer$1(that, length); 8214 var actual = that.write(string, encoding); 8215 8216 if (actual !== length) { 8217 // Writing a hex string, for example, that contains invalid characters will 8218 // cause everything after the first invalid character to be ignored. (e.g. 8219 // 'abxxcd' will be treated as 'ab') 8220 that = that.slice(0, actual); 8221 } 8222 8223 return that; 8224 } 8225 8226 function fromArrayLike$1(that, array) { 8227 var length = array.length < 0 ? 0 : checked$1(array.length) | 0; 8228 that = createBuffer$1(that, length); 8229 8230 for (var i = 0; i < length; i += 1) { 8231 that[i] = array[i] & 255; 8232 } 8233 8234 return that; 8235 } 8236 8237 function fromArrayBuffer$1(that, array, byteOffset, length) { 8238 array.byteLength; // this throws if `array` is not a valid ArrayBuffer 8239 8240 if (byteOffset < 0 || array.byteLength < byteOffset) { 8241 throw new RangeError('\'offset\' is out of bounds'); 8242 } 8243 8244 if (array.byteLength < byteOffset + (length || 0)) { 8245 throw new RangeError('\'length\' is out of bounds'); 8246 } 8247 8248 if (byteOffset === undefined && length === undefined) { 8249 array = new Uint8Array(array); 8250 } else if (length === undefined) { 8251 array = new Uint8Array(array, byteOffset); 8252 } else { 8253 array = new Uint8Array(array, byteOffset, length); 8254 } 8255 8256 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 8257 // Return an augmented `Uint8Array` instance, for best performance 8258 that = array; 8259 that.__proto__ = Buffer$1.prototype; 8260 } else { 8261 // Fallback: Return an object instance of the Buffer class 8262 that = fromArrayLike$1(that, array); 8263 } 8264 8265 return that; 8266 } 8267 8268 function fromObject$1(that, obj) { 8269 if (internalIsBuffer$1(obj)) { 8270 var len = checked$1(obj.length) | 0; 8271 that = createBuffer$1(that, len); 8272 8273 if (that.length === 0) { 8274 return that; 8275 } 8276 8277 obj.copy(that, 0, 0, len); 8278 return that; 8279 } 8280 8281 if (obj) { 8282 if (typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer || 'length' in obj) { 8283 if (typeof obj.length !== 'number' || isnan$1(obj.length)) { 8284 return createBuffer$1(that, 0); 8285 } 8286 8287 return fromArrayLike$1(that, obj); 8288 } 8289 8290 if (obj.type === 'Buffer' && isArray$3(obj.data)) { 8291 return fromArrayLike$1(that, obj.data); 8292 } 8293 } 8294 8295 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.'); 8296 } 8297 8298 function checked$1(length) { 8299 // Note: cannot use `length < kMaxLength()` here because that fails when 8300 // length is NaN (which is otherwise coerced to zero.) 8301 if (length >= kMaxLength$1()) { 8302 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength$1().toString(16) + ' bytes'); 8303 } 8304 8305 return length | 0; 8306 } 8307 8308 Buffer$1.isBuffer = isBuffer$2; 8309 8310 function internalIsBuffer$1(b) { 8311 return !!(b != null && b._isBuffer); 8312 } 8313 8314 Buffer$1.compare = function compare(a, b) { 8315 if (!internalIsBuffer$1(a) || !internalIsBuffer$1(b)) { 8316 throw new TypeError('Arguments must be Buffers'); 8317 } 8318 8319 if (a === b) return 0; 8320 var x = a.length; 8321 var y = b.length; 8322 8323 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 8324 if (a[i] !== b[i]) { 8325 x = a[i]; 8326 y = b[i]; 8327 break; 8328 } 8329 } 8330 8331 if (x < y) return -1; 8332 if (y < x) return 1; 8333 return 0; 8334 }; 8335 8336 Buffer$1.isEncoding = function isEncoding(encoding) { 8337 switch (String(encoding).toLowerCase()) { 8338 case 'hex': 8339 case 'utf8': 8340 case 'utf-8': 8341 case 'ascii': 8342 case 'latin1': 8343 case 'binary': 8344 case 'base64': 8345 case 'ucs2': 8346 case 'ucs-2': 8347 case 'utf16le': 8348 case 'utf-16le': 8349 return true; 8350 8351 default: 8352 return false; 8353 } 8354 }; 8355 8356 Buffer$1.concat = function concat(list, length) { 8357 if (!isArray$3(list)) { 8358 throw new TypeError('"list" argument must be an Array of Buffers'); 8359 } 8360 8361 if (list.length === 0) { 8362 return Buffer$1.alloc(0); 8363 } 8364 8365 var i; 8366 8367 if (length === undefined) { 8368 length = 0; 8369 8370 for (i = 0; i < list.length; ++i) { 8371 length += list[i].length; 8372 } 8373 } 8374 8375 var buffer = Buffer$1.allocUnsafe(length); 8376 var pos = 0; 8377 8378 for (i = 0; i < list.length; ++i) { 8379 var buf = list[i]; 8380 8381 if (!internalIsBuffer$1(buf)) { 8382 throw new TypeError('"list" argument must be an Array of Buffers'); 8383 } 8384 8385 buf.copy(buffer, pos); 8386 pos += buf.length; 8387 } 8388 8389 return buffer; 8390 }; 8391 8392 function byteLength$1(string, encoding) { 8393 if (internalIsBuffer$1(string)) { 8394 return string.length; 8395 } 8396 8397 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { 8398 return string.byteLength; 8399 } 8400 8401 if (typeof string !== 'string') { 8402 string = '' + string; 8403 } 8404 8405 var len = string.length; 8406 if (len === 0) return 0; // Use a for loop to avoid recursion 8407 8408 var loweredCase = false; 8409 8410 for (;;) { 8411 switch (encoding) { 8412 case 'ascii': 8413 case 'latin1': 8414 case 'binary': 8415 return len; 8416 8417 case 'utf8': 8418 case 'utf-8': 8419 case undefined: 8420 return utf8ToBytes$1(string).length; 8421 8422 case 'ucs2': 8423 case 'ucs-2': 8424 case 'utf16le': 8425 case 'utf-16le': 8426 return len * 2; 8427 8428 case 'hex': 8429 return len >>> 1; 8430 8431 case 'base64': 8432 return base64ToBytes$1(string).length; 8433 8434 default: 8435 if (loweredCase) return utf8ToBytes$1(string).length; // assume utf8 8436 8437 encoding = ('' + encoding).toLowerCase(); 8438 loweredCase = true; 8439 } 8440 } 8441 } 8442 8443 Buffer$1.byteLength = byteLength$1; 8444 8445 function slowToString$1(encoding, start, end) { 8446 var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 8447 // property of a typed array. 8448 // This behaves neither like String nor Uint8Array in that we set start/end 8449 // to their upper/lower bounds if the value passed is out of range. 8450 // undefined is handled specially as per ECMA-262 6th Edition, 8451 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 8452 8453 if (start === undefined || start < 0) { 8454 start = 0; 8455 } // Return early if start > this.length. Done here to prevent potential uint32 8456 // coercion fail below. 8457 8458 8459 if (start > this.length) { 8460 return ''; 8461 } 8462 8463 if (end === undefined || end > this.length) { 8464 end = this.length; 8465 } 8466 8467 if (end <= 0) { 8468 return ''; 8469 } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 8470 8471 8472 end >>>= 0; 8473 start >>>= 0; 8474 8475 if (end <= start) { 8476 return ''; 8477 } 8478 8479 if (!encoding) encoding = 'utf8'; 8480 8481 while (true) { 8482 switch (encoding) { 8483 case 'hex': 8484 return hexSlice$1(this, start, end); 8485 8486 case 'utf8': 8487 case 'utf-8': 8488 return utf8Slice$1(this, start, end); 8489 8490 case 'ascii': 8491 return asciiSlice$1(this, start, end); 8492 8493 case 'latin1': 8494 case 'binary': 8495 return latin1Slice$1(this, start, end); 8496 8497 case 'base64': 8498 return base64Slice$1(this, start, end); 8499 8500 case 'ucs2': 8501 case 'ucs-2': 8502 case 'utf16le': 8503 case 'utf-16le': 8504 return utf16leSlice$1(this, start, end); 8505 8506 default: 8507 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); 8508 encoding = (encoding + '').toLowerCase(); 8509 loweredCase = true; 8510 } 8511 } 8512 } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect 8513 // Buffer instances. 8514 8515 8516 Buffer$1.prototype._isBuffer = true; 8517 8518 function swap$1(b, n, m) { 8519 var i = b[n]; 8520 b[n] = b[m]; 8521 b[m] = i; 8522 } 8523 8524 Buffer$1.prototype.swap16 = function swap16() { 8525 var len = this.length; 8526 8527 if (len % 2 !== 0) { 8528 throw new RangeError('Buffer size must be a multiple of 16-bits'); 8529 } 8530 8531 for (var i = 0; i < len; i += 2) { 8532 swap$1(this, i, i + 1); 8533 } 8534 8535 return this; 8536 }; 8537 8538 Buffer$1.prototype.swap32 = function swap32() { 8539 var len = this.length; 8540 8541 if (len % 4 !== 0) { 8542 throw new RangeError('Buffer size must be a multiple of 32-bits'); 8543 } 8544 8545 for (var i = 0; i < len; i += 4) { 8546 swap$1(this, i, i + 3); 8547 swap$1(this, i + 1, i + 2); 8548 } 8549 8550 return this; 8551 }; 8552 8553 Buffer$1.prototype.swap64 = function swap64() { 8554 var len = this.length; 8555 8556 if (len % 8 !== 0) { 8557 throw new RangeError('Buffer size must be a multiple of 64-bits'); 8558 } 8559 8560 for (var i = 0; i < len; i += 8) { 8561 swap$1(this, i, i + 7); 8562 swap$1(this, i + 1, i + 6); 8563 swap$1(this, i + 2, i + 5); 8564 swap$1(this, i + 3, i + 4); 8565 } 8566 8567 return this; 8568 }; 8569 8570 Buffer$1.prototype.toString = function toString() { 8571 var length = this.length | 0; 8572 if (length === 0) return ''; 8573 if (arguments.length === 0) return utf8Slice$1(this, 0, length); 8574 return slowToString$1.apply(this, arguments); 8575 }; 8576 8577 Buffer$1.prototype.equals = function equals(b) { 8578 if (!internalIsBuffer$1(b)) throw new TypeError('Argument must be a Buffer'); 8579 if (this === b) return true; 8580 return Buffer$1.compare(this, b) === 0; 8581 }; 8582 8583 Buffer$1.prototype.inspect = function inspect() { 8584 var str = ''; 8585 var max = INSPECT_MAX_BYTES$1; 8586 8587 if (this.length > 0) { 8588 str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); 8589 if (this.length > max) str += ' ... '; 8590 } 8591 8592 return '<Buffer ' + str + '>'; 8593 }; 8594 8595 Buffer$1.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { 8596 if (!internalIsBuffer$1(target)) { 8597 throw new TypeError('Argument must be a Buffer'); 8598 } 8599 8600 if (start === undefined) { 8601 start = 0; 8602 } 8603 8604 if (end === undefined) { 8605 end = target ? target.length : 0; 8606 } 8607 8608 if (thisStart === undefined) { 8609 thisStart = 0; 8610 } 8611 8612 if (thisEnd === undefined) { 8613 thisEnd = this.length; 8614 } 8615 8616 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 8617 throw new RangeError('out of range index'); 8618 } 8619 8620 if (thisStart >= thisEnd && start >= end) { 8621 return 0; 8622 } 8623 8624 if (thisStart >= thisEnd) { 8625 return -1; 8626 } 8627 8628 if (start >= end) { 8629 return 1; 8630 } 8631 8632 start >>>= 0; 8633 end >>>= 0; 8634 thisStart >>>= 0; 8635 thisEnd >>>= 0; 8636 if (this === target) return 0; 8637 var x = thisEnd - thisStart; 8638 var y = end - start; 8639 var len = Math.min(x, y); 8640 var thisCopy = this.slice(thisStart, thisEnd); 8641 var targetCopy = target.slice(start, end); 8642 8643 for (var i = 0; i < len; ++i) { 8644 if (thisCopy[i] !== targetCopy[i]) { 8645 x = thisCopy[i]; 8646 y = targetCopy[i]; 8647 break; 8648 } 8649 } 8650 8651 if (x < y) return -1; 8652 if (y < x) return 1; 8653 return 0; 8654 }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 8655 // OR the last index of `val` in `buffer` at offset <= `byteOffset`. 8656 // 8657 // Arguments: 8658 // - buffer - a Buffer to search 8659 // - val - a string, Buffer, or number 8660 // - byteOffset - an index into `buffer`; will be clamped to an int32 8661 // - encoding - an optional encoding, relevant is val is a string 8662 // - dir - true for indexOf, false for lastIndexOf 8663 8664 8665 function bidirectionalIndexOf$1(buffer, val, byteOffset, encoding, dir) { 8666 // Empty buffer means no match 8667 if (buffer.length === 0) return -1; // Normalize byteOffset 8668 8669 if (typeof byteOffset === 'string') { 8670 encoding = byteOffset; 8671 byteOffset = 0; 8672 } else if (byteOffset > 0x7fffffff) { 8673 byteOffset = 0x7fffffff; 8674 } else if (byteOffset < -0x80000000) { 8675 byteOffset = -0x80000000; 8676 } 8677 8678 byteOffset = +byteOffset; // Coerce to Number. 8679 8680 if (isNaN(byteOffset)) { 8681 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 8682 byteOffset = dir ? 0 : buffer.length - 1; 8683 } // Normalize byteOffset: negative offsets start from the end of the buffer 8684 8685 8686 if (byteOffset < 0) byteOffset = buffer.length + byteOffset; 8687 8688 if (byteOffset >= buffer.length) { 8689 if (dir) return -1;else byteOffset = buffer.length - 1; 8690 } else if (byteOffset < 0) { 8691 if (dir) byteOffset = 0;else return -1; 8692 } // Normalize val 8693 8694 8695 if (typeof val === 'string') { 8696 val = Buffer$1.from(val, encoding); 8697 } // Finally, search either indexOf (if dir is true) or lastIndexOf 8698 8699 8700 if (internalIsBuffer$1(val)) { 8701 // Special case: looking for empty string/buffer always fails 8702 if (val.length === 0) { 8703 return -1; 8704 } 8705 8706 return arrayIndexOf$1(buffer, val, byteOffset, encoding, dir); 8707 } else if (typeof val === 'number') { 8708 val = val & 0xFF; // Search for a byte value [0-255] 8709 8710 if (Buffer$1.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') { 8711 if (dir) { 8712 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); 8713 } else { 8714 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); 8715 } 8716 } 8717 8718 return arrayIndexOf$1(buffer, [val], byteOffset, encoding, dir); 8719 } 8720 8721 throw new TypeError('val must be string, number or Buffer'); 8722 } 8723 8724 function arrayIndexOf$1(arr, val, byteOffset, encoding, dir) { 8725 var indexSize = 1; 8726 var arrLength = arr.length; 8727 var valLength = val.length; 8728 8729 if (encoding !== undefined) { 8730 encoding = String(encoding).toLowerCase(); 8731 8732 if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { 8733 if (arr.length < 2 || val.length < 2) { 8734 return -1; 8735 } 8736 8737 indexSize = 2; 8738 arrLength /= 2; 8739 valLength /= 2; 8740 byteOffset /= 2; 8741 } 8742 } 8743 8744 function read(buf, i) { 8745 if (indexSize === 1) { 8746 return buf[i]; 8747 } else { 8748 return buf.readUInt16BE(i * indexSize); 8749 } 8750 } 8751 8752 var i; 8753 8754 if (dir) { 8755 var foundIndex = -1; 8756 8757 for (i = byteOffset; i < arrLength; i++) { 8758 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 8759 if (foundIndex === -1) foundIndex = i; 8760 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; 8761 } else { 8762 if (foundIndex !== -1) i -= i - foundIndex; 8763 foundIndex = -1; 8764 } 8765 } 8766 } else { 8767 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; 8768 8769 for (i = byteOffset; i >= 0; i--) { 8770 var found = true; 8771 8772 for (var j = 0; j < valLength; j++) { 8773 if (read(arr, i + j) !== read(val, j)) { 8774 found = false; 8775 break; 8776 } 8777 } 8778 8779 if (found) return i; 8780 } 8781 } 8782 8783 return -1; 8784 } 8785 8786 Buffer$1.prototype.includes = function includes(val, byteOffset, encoding) { 8787 return this.indexOf(val, byteOffset, encoding) !== -1; 8788 }; 8789 8790 Buffer$1.prototype.indexOf = function indexOf(val, byteOffset, encoding) { 8791 return bidirectionalIndexOf$1(this, val, byteOffset, encoding, true); 8792 }; 8793 8794 Buffer$1.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { 8795 return bidirectionalIndexOf$1(this, val, byteOffset, encoding, false); 8796 }; 8797 8798 function hexWrite$1(buf, string, offset, length) { 8799 offset = Number(offset) || 0; 8800 var remaining = buf.length - offset; 8801 8802 if (!length) { 8803 length = remaining; 8804 } else { 8805 length = Number(length); 8806 8807 if (length > remaining) { 8808 length = remaining; 8809 } 8810 } // must be an even number of digits 8811 8812 8813 var strLen = string.length; 8814 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string'); 8815 8816 if (length > strLen / 2) { 8817 length = strLen / 2; 8818 } 8819 8820 for (var i = 0; i < length; ++i) { 8821 var parsed = parseInt(string.substr(i * 2, 2), 16); 8822 if (isNaN(parsed)) return i; 8823 buf[offset + i] = parsed; 8824 } 8825 8826 return i; 8827 } 8828 8829 function utf8Write$1(buf, string, offset, length) { 8830 return blitBuffer$1(utf8ToBytes$1(string, buf.length - offset), buf, offset, length); 8831 } 8832 8833 function asciiWrite$1(buf, string, offset, length) { 8834 return blitBuffer$1(asciiToBytes$1(string), buf, offset, length); 8835 } 8836 8837 function latin1Write$1(buf, string, offset, length) { 8838 return asciiWrite$1(buf, string, offset, length); 8839 } 8840 8841 function base64Write$1(buf, string, offset, length) { 8842 return blitBuffer$1(base64ToBytes$1(string), buf, offset, length); 8843 } 8844 8845 function ucs2Write$1(buf, string, offset, length) { 8846 return blitBuffer$1(utf16leToBytes$1(string, buf.length - offset), buf, offset, length); 8847 } 8848 8849 Buffer$1.prototype.write = function write(string, offset, length, encoding) { 8850 // Buffer#write(string) 8851 if (offset === undefined) { 8852 encoding = 'utf8'; 8853 length = this.length; 8854 offset = 0; // Buffer#write(string, encoding) 8855 } else if (length === undefined && typeof offset === 'string') { 8856 encoding = offset; 8857 length = this.length; 8858 offset = 0; // Buffer#write(string, offset[, length][, encoding]) 8859 } else if (isFinite(offset)) { 8860 offset = offset | 0; 8861 8862 if (isFinite(length)) { 8863 length = length | 0; 8864 if (encoding === undefined) encoding = 'utf8'; 8865 } else { 8866 encoding = length; 8867 length = undefined; 8868 } // legacy write(string, encoding, offset, length) - remove in v0.13 8869 8870 } else { 8871 throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); 8872 } 8873 8874 var remaining = this.length - offset; 8875 if (length === undefined || length > remaining) length = remaining; 8876 8877 if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { 8878 throw new RangeError('Attempt to write outside buffer bounds'); 8879 } 8880 8881 if (!encoding) encoding = 'utf8'; 8882 var loweredCase = false; 8883 8884 for (;;) { 8885 switch (encoding) { 8886 case 'hex': 8887 return hexWrite$1(this, string, offset, length); 8888 8889 case 'utf8': 8890 case 'utf-8': 8891 return utf8Write$1(this, string, offset, length); 8892 8893 case 'ascii': 8894 return asciiWrite$1(this, string, offset, length); 8895 8896 case 'latin1': 8897 case 'binary': 8898 return latin1Write$1(this, string, offset, length); 8899 8900 case 'base64': 8901 // Warning: maxLength not taken into account in base64Write 8902 return base64Write$1(this, string, offset, length); 8903 8904 case 'ucs2': 8905 case 'ucs-2': 8906 case 'utf16le': 8907 case 'utf-16le': 8908 return ucs2Write$1(this, string, offset, length); 8909 8910 default: 8911 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); 8912 encoding = ('' + encoding).toLowerCase(); 8913 loweredCase = true; 8914 } 8915 } 8916 }; 8917 8918 Buffer$1.prototype.toJSON = function toJSON() { 8919 return { 8920 type: 'Buffer', 8921 data: Array.prototype.slice.call(this._arr || this, 0) 8922 }; 8923 }; 8924 8925 function base64Slice$1(buf, start, end) { 8926 if (start === 0 && end === buf.length) { 8927 return fromByteArray$1(buf); 8928 } else { 8929 return fromByteArray$1(buf.slice(start, end)); 8930 } 8931 } 8932 8933 function utf8Slice$1(buf, start, end) { 8934 end = Math.min(buf.length, end); 8935 var res = []; 8936 var i = start; 8937 8938 while (i < end) { 8939 var firstByte = buf[i]; 8940 var codePoint = null; 8941 var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; 8942 8943 if (i + bytesPerSequence <= end) { 8944 var secondByte, thirdByte, fourthByte, tempCodePoint; 8945 8946 switch (bytesPerSequence) { 8947 case 1: 8948 if (firstByte < 0x80) { 8949 codePoint = firstByte; 8950 } 8951 8952 break; 8953 8954 case 2: 8955 secondByte = buf[i + 1]; 8956 8957 if ((secondByte & 0xC0) === 0x80) { 8958 tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; 8959 8960 if (tempCodePoint > 0x7F) { 8961 codePoint = tempCodePoint; 8962 } 8963 } 8964 8965 break; 8966 8967 case 3: 8968 secondByte = buf[i + 1]; 8969 thirdByte = buf[i + 2]; 8970 8971 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 8972 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; 8973 8974 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 8975 codePoint = tempCodePoint; 8976 } 8977 } 8978 8979 break; 8980 8981 case 4: 8982 secondByte = buf[i + 1]; 8983 thirdByte = buf[i + 2]; 8984 fourthByte = buf[i + 3]; 8985 8986 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 8987 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; 8988 8989 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 8990 codePoint = tempCodePoint; 8991 } 8992 } 8993 8994 } 8995 } 8996 8997 if (codePoint === null) { 8998 // we did not generate a valid codePoint so insert a 8999 // replacement char (U+FFFD) and advance only 1 byte 9000 codePoint = 0xFFFD; 9001 bytesPerSequence = 1; 9002 } else if (codePoint > 0xFFFF) { 9003 // encode to utf16 (surrogate pair dance) 9004 codePoint -= 0x10000; 9005 res.push(codePoint >>> 10 & 0x3FF | 0xD800); 9006 codePoint = 0xDC00 | codePoint & 0x3FF; 9007 } 9008 9009 res.push(codePoint); 9010 i += bytesPerSequence; 9011 } 9012 9013 return decodeCodePointsArray$1(res); 9014 } // Based on http://stackoverflow.com/a/22747272/680742, the browser with 9015 // the lowest limit is Chrome, with 0x10000 args. 9016 // We go 1 magnitude less, for safety 9017 9018 9019 var MAX_ARGUMENTS_LENGTH$1 = 0x1000; 9020 9021 function decodeCodePointsArray$1(codePoints) { 9022 var len = codePoints.length; 9023 9024 if (len <= MAX_ARGUMENTS_LENGTH$1) { 9025 return String.fromCharCode.apply(String, codePoints); // avoid extra slice() 9026 } // Decode in chunks to avoid "call stack size exceeded". 9027 9028 9029 var res = ''; 9030 var i = 0; 9031 9032 while (i < len) { 9033 res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH$1)); 9034 } 9035 9036 return res; 9037 } 9038 9039 function asciiSlice$1(buf, start, end) { 9040 var ret = ''; 9041 end = Math.min(buf.length, end); 9042 9043 for (var i = start; i < end; ++i) { 9044 ret += String.fromCharCode(buf[i] & 0x7F); 9045 } 9046 9047 return ret; 9048 } 9049 9050 function latin1Slice$1(buf, start, end) { 9051 var ret = ''; 9052 end = Math.min(buf.length, end); 9053 9054 for (var i = start; i < end; ++i) { 9055 ret += String.fromCharCode(buf[i]); 9056 } 9057 9058 return ret; 9059 } 9060 9061 function hexSlice$1(buf, start, end) { 9062 var len = buf.length; 9063 if (!start || start < 0) start = 0; 9064 if (!end || end < 0 || end > len) end = len; 9065 var out = ''; 9066 9067 for (var i = start; i < end; ++i) { 9068 out += toHex$1(buf[i]); 9069 } 9070 9071 return out; 9072 } 9073 9074 function utf16leSlice$1(buf, start, end) { 9075 var bytes = buf.slice(start, end); 9076 var res = ''; 9077 9078 for (var i = 0; i < bytes.length; i += 2) { 9079 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); 9080 } 9081 9082 return res; 9083 } 9084 9085 Buffer$1.prototype.slice = function slice(start, end) { 9086 var len = this.length; 9087 start = ~~start; 9088 end = end === undefined ? len : ~~end; 9089 9090 if (start < 0) { 9091 start += len; 9092 if (start < 0) start = 0; 9093 } else if (start > len) { 9094 start = len; 9095 } 9096 9097 if (end < 0) { 9098 end += len; 9099 if (end < 0) end = 0; 9100 } else if (end > len) { 9101 end = len; 9102 } 9103 9104 if (end < start) end = start; 9105 var newBuf; 9106 9107 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9108 newBuf = this.subarray(start, end); 9109 newBuf.__proto__ = Buffer$1.prototype; 9110 } else { 9111 var sliceLen = end - start; 9112 newBuf = new Buffer$1(sliceLen, undefined); 9113 9114 for (var i = 0; i < sliceLen; ++i) { 9115 newBuf[i] = this[i + start]; 9116 } 9117 } 9118 9119 return newBuf; 9120 }; 9121 /* 9122 * Need to make sure that buffer isn't trying to write out of bounds. 9123 */ 9124 9125 9126 function checkOffset$1(offset, ext, length) { 9127 if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); 9128 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); 9129 } 9130 9131 Buffer$1.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { 9132 offset = offset | 0; 9133 byteLength = byteLength | 0; 9134 if (!noAssert) checkOffset$1(offset, byteLength, this.length); 9135 var val = this[offset]; 9136 var mul = 1; 9137 var i = 0; 9138 9139 while (++i < byteLength && (mul *= 0x100)) { 9140 val += this[offset + i] * mul; 9141 } 9142 9143 return val; 9144 }; 9145 9146 Buffer$1.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { 9147 offset = offset | 0; 9148 byteLength = byteLength | 0; 9149 9150 if (!noAssert) { 9151 checkOffset$1(offset, byteLength, this.length); 9152 } 9153 9154 var val = this[offset + --byteLength]; 9155 var mul = 1; 9156 9157 while (byteLength > 0 && (mul *= 0x100)) { 9158 val += this[offset + --byteLength] * mul; 9159 } 9160 9161 return val; 9162 }; 9163 9164 Buffer$1.prototype.readUInt8 = function readUInt8(offset, noAssert) { 9165 if (!noAssert) checkOffset$1(offset, 1, this.length); 9166 return this[offset]; 9167 }; 9168 9169 Buffer$1.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { 9170 if (!noAssert) checkOffset$1(offset, 2, this.length); 9171 return this[offset] | this[offset + 1] << 8; 9172 }; 9173 9174 Buffer$1.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { 9175 if (!noAssert) checkOffset$1(offset, 2, this.length); 9176 return this[offset] << 8 | this[offset + 1]; 9177 }; 9178 9179 Buffer$1.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { 9180 if (!noAssert) checkOffset$1(offset, 4, this.length); 9181 return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; 9182 }; 9183 9184 Buffer$1.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { 9185 if (!noAssert) checkOffset$1(offset, 4, this.length); 9186 return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); 9187 }; 9188 9189 Buffer$1.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { 9190 offset = offset | 0; 9191 byteLength = byteLength | 0; 9192 if (!noAssert) checkOffset$1(offset, byteLength, this.length); 9193 var val = this[offset]; 9194 var mul = 1; 9195 var i = 0; 9196 9197 while (++i < byteLength && (mul *= 0x100)) { 9198 val += this[offset + i] * mul; 9199 } 9200 9201 mul *= 0x80; 9202 if (val >= mul) val -= Math.pow(2, 8 * byteLength); 9203 return val; 9204 }; 9205 9206 Buffer$1.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { 9207 offset = offset | 0; 9208 byteLength = byteLength | 0; 9209 if (!noAssert) checkOffset$1(offset, byteLength, this.length); 9210 var i = byteLength; 9211 var mul = 1; 9212 var val = this[offset + --i]; 9213 9214 while (i > 0 && (mul *= 0x100)) { 9215 val += this[offset + --i] * mul; 9216 } 9217 9218 mul *= 0x80; 9219 if (val >= mul) val -= Math.pow(2, 8 * byteLength); 9220 return val; 9221 }; 9222 9223 Buffer$1.prototype.readInt8 = function readInt8(offset, noAssert) { 9224 if (!noAssert) checkOffset$1(offset, 1, this.length); 9225 if (!(this[offset] & 0x80)) return this[offset]; 9226 return (0xff - this[offset] + 1) * -1; 9227 }; 9228 9229 Buffer$1.prototype.readInt16LE = function readInt16LE(offset, noAssert) { 9230 if (!noAssert) checkOffset$1(offset, 2, this.length); 9231 var val = this[offset] | this[offset + 1] << 8; 9232 return val & 0x8000 ? val | 0xFFFF0000 : val; 9233 }; 9234 9235 Buffer$1.prototype.readInt16BE = function readInt16BE(offset, noAssert) { 9236 if (!noAssert) checkOffset$1(offset, 2, this.length); 9237 var val = this[offset + 1] | this[offset] << 8; 9238 return val & 0x8000 ? val | 0xFFFF0000 : val; 9239 }; 9240 9241 Buffer$1.prototype.readInt32LE = function readInt32LE(offset, noAssert) { 9242 if (!noAssert) checkOffset$1(offset, 4, this.length); 9243 return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; 9244 }; 9245 9246 Buffer$1.prototype.readInt32BE = function readInt32BE(offset, noAssert) { 9247 if (!noAssert) checkOffset$1(offset, 4, this.length); 9248 return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; 9249 }; 9250 9251 Buffer$1.prototype.readFloatLE = function readFloatLE(offset, noAssert) { 9252 if (!noAssert) checkOffset$1(offset, 4, this.length); 9253 return read$1(this, offset, true, 23, 4); 9254 }; 9255 9256 Buffer$1.prototype.readFloatBE = function readFloatBE(offset, noAssert) { 9257 if (!noAssert) checkOffset$1(offset, 4, this.length); 9258 return read$1(this, offset, false, 23, 4); 9259 }; 9260 9261 Buffer$1.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { 9262 if (!noAssert) checkOffset$1(offset, 8, this.length); 9263 return read$1(this, offset, true, 52, 8); 9264 }; 9265 9266 Buffer$1.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { 9267 if (!noAssert) checkOffset$1(offset, 8, this.length); 9268 return read$1(this, offset, false, 52, 8); 9269 }; 9270 9271 function checkInt$1(buf, value, offset, ext, max, min) { 9272 if (!internalIsBuffer$1(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); 9273 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); 9274 if (offset + ext > buf.length) throw new RangeError('Index out of range'); 9275 } 9276 9277 Buffer$1.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { 9278 value = +value; 9279 offset = offset | 0; 9280 byteLength = byteLength | 0; 9281 9282 if (!noAssert) { 9283 var maxBytes = Math.pow(2, 8 * byteLength) - 1; 9284 checkInt$1(this, value, offset, byteLength, maxBytes, 0); 9285 } 9286 9287 var mul = 1; 9288 var i = 0; 9289 this[offset] = value & 0xFF; 9290 9291 while (++i < byteLength && (mul *= 0x100)) { 9292 this[offset + i] = value / mul & 0xFF; 9293 } 9294 9295 return offset + byteLength; 9296 }; 9297 9298 Buffer$1.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { 9299 value = +value; 9300 offset = offset | 0; 9301 byteLength = byteLength | 0; 9302 9303 if (!noAssert) { 9304 var maxBytes = Math.pow(2, 8 * byteLength) - 1; 9305 checkInt$1(this, value, offset, byteLength, maxBytes, 0); 9306 } 9307 9308 var i = byteLength - 1; 9309 var mul = 1; 9310 this[offset + i] = value & 0xFF; 9311 9312 while (--i >= 0 && (mul *= 0x100)) { 9313 this[offset + i] = value / mul & 0xFF; 9314 } 9315 9316 return offset + byteLength; 9317 }; 9318 9319 Buffer$1.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { 9320 value = +value; 9321 offset = offset | 0; 9322 if (!noAssert) checkInt$1(this, value, offset, 1, 0xff, 0); 9323 if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value); 9324 this[offset] = value & 0xff; 9325 return offset + 1; 9326 }; 9327 9328 function objectWriteUInt16$1(buf, value, offset, littleEndian) { 9329 if (value < 0) value = 0xffff + value + 1; 9330 9331 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { 9332 buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8; 9333 } 9334 } 9335 9336 Buffer$1.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { 9337 value = +value; 9338 offset = offset | 0; 9339 if (!noAssert) checkInt$1(this, value, offset, 2, 0xffff, 0); 9340 9341 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9342 this[offset] = value & 0xff; 9343 this[offset + 1] = value >>> 8; 9344 } else { 9345 objectWriteUInt16$1(this, value, offset, true); 9346 } 9347 9348 return offset + 2; 9349 }; 9350 9351 Buffer$1.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { 9352 value = +value; 9353 offset = offset | 0; 9354 if (!noAssert) checkInt$1(this, value, offset, 2, 0xffff, 0); 9355 9356 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9357 this[offset] = value >>> 8; 9358 this[offset + 1] = value & 0xff; 9359 } else { 9360 objectWriteUInt16$1(this, value, offset, false); 9361 } 9362 9363 return offset + 2; 9364 }; 9365 9366 function objectWriteUInt32$1(buf, value, offset, littleEndian) { 9367 if (value < 0) value = 0xffffffff + value + 1; 9368 9369 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { 9370 buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff; 9371 } 9372 } 9373 9374 Buffer$1.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { 9375 value = +value; 9376 offset = offset | 0; 9377 if (!noAssert) checkInt$1(this, value, offset, 4, 0xffffffff, 0); 9378 9379 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9380 this[offset + 3] = value >>> 24; 9381 this[offset + 2] = value >>> 16; 9382 this[offset + 1] = value >>> 8; 9383 this[offset] = value & 0xff; 9384 } else { 9385 objectWriteUInt32$1(this, value, offset, true); 9386 } 9387 9388 return offset + 4; 9389 }; 9390 9391 Buffer$1.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { 9392 value = +value; 9393 offset = offset | 0; 9394 if (!noAssert) checkInt$1(this, value, offset, 4, 0xffffffff, 0); 9395 9396 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9397 this[offset] = value >>> 24; 9398 this[offset + 1] = value >>> 16; 9399 this[offset + 2] = value >>> 8; 9400 this[offset + 3] = value & 0xff; 9401 } else { 9402 objectWriteUInt32$1(this, value, offset, false); 9403 } 9404 9405 return offset + 4; 9406 }; 9407 9408 Buffer$1.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { 9409 value = +value; 9410 offset = offset | 0; 9411 9412 if (!noAssert) { 9413 var limit = Math.pow(2, 8 * byteLength - 1); 9414 checkInt$1(this, value, offset, byteLength, limit - 1, -limit); 9415 } 9416 9417 var i = 0; 9418 var mul = 1; 9419 var sub = 0; 9420 this[offset] = value & 0xFF; 9421 9422 while (++i < byteLength && (mul *= 0x100)) { 9423 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 9424 sub = 1; 9425 } 9426 9427 this[offset + i] = (value / mul >> 0) - sub & 0xFF; 9428 } 9429 9430 return offset + byteLength; 9431 }; 9432 9433 Buffer$1.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { 9434 value = +value; 9435 offset = offset | 0; 9436 9437 if (!noAssert) { 9438 var limit = Math.pow(2, 8 * byteLength - 1); 9439 checkInt$1(this, value, offset, byteLength, limit - 1, -limit); 9440 } 9441 9442 var i = byteLength - 1; 9443 var mul = 1; 9444 var sub = 0; 9445 this[offset + i] = value & 0xFF; 9446 9447 while (--i >= 0 && (mul *= 0x100)) { 9448 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 9449 sub = 1; 9450 } 9451 9452 this[offset + i] = (value / mul >> 0) - sub & 0xFF; 9453 } 9454 9455 return offset + byteLength; 9456 }; 9457 9458 Buffer$1.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { 9459 value = +value; 9460 offset = offset | 0; 9461 if (!noAssert) checkInt$1(this, value, offset, 1, 0x7f, -0x80); 9462 if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value); 9463 if (value < 0) value = 0xff + value + 1; 9464 this[offset] = value & 0xff; 9465 return offset + 1; 9466 }; 9467 9468 Buffer$1.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { 9469 value = +value; 9470 offset = offset | 0; 9471 if (!noAssert) checkInt$1(this, value, offset, 2, 0x7fff, -0x8000); 9472 9473 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9474 this[offset] = value & 0xff; 9475 this[offset + 1] = value >>> 8; 9476 } else { 9477 objectWriteUInt16$1(this, value, offset, true); 9478 } 9479 9480 return offset + 2; 9481 }; 9482 9483 Buffer$1.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { 9484 value = +value; 9485 offset = offset | 0; 9486 if (!noAssert) checkInt$1(this, value, offset, 2, 0x7fff, -0x8000); 9487 9488 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9489 this[offset] = value >>> 8; 9490 this[offset + 1] = value & 0xff; 9491 } else { 9492 objectWriteUInt16$1(this, value, offset, false); 9493 } 9494 9495 return offset + 2; 9496 }; 9497 9498 Buffer$1.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { 9499 value = +value; 9500 offset = offset | 0; 9501 if (!noAssert) checkInt$1(this, value, offset, 4, 0x7fffffff, -0x80000000); 9502 9503 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9504 this[offset] = value & 0xff; 9505 this[offset + 1] = value >>> 8; 9506 this[offset + 2] = value >>> 16; 9507 this[offset + 3] = value >>> 24; 9508 } else { 9509 objectWriteUInt32$1(this, value, offset, true); 9510 } 9511 9512 return offset + 4; 9513 }; 9514 9515 Buffer$1.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { 9516 value = +value; 9517 offset = offset | 0; 9518 if (!noAssert) checkInt$1(this, value, offset, 4, 0x7fffffff, -0x80000000); 9519 if (value < 0) value = 0xffffffff + value + 1; 9520 9521 if (Buffer$1.TYPED_ARRAY_SUPPORT) { 9522 this[offset] = value >>> 24; 9523 this[offset + 1] = value >>> 16; 9524 this[offset + 2] = value >>> 8; 9525 this[offset + 3] = value & 0xff; 9526 } else { 9527 objectWriteUInt32$1(this, value, offset, false); 9528 } 9529 9530 return offset + 4; 9531 }; 9532 9533 function checkIEEE754$1(buf, value, offset, ext, max, min) { 9534 if (offset + ext > buf.length) throw new RangeError('Index out of range'); 9535 if (offset < 0) throw new RangeError('Index out of range'); 9536 } 9537 9538 function writeFloat$1(buf, value, offset, littleEndian, noAssert) { 9539 if (!noAssert) { 9540 checkIEEE754$1(buf, value, offset, 4); 9541 } 9542 9543 write$1(buf, value, offset, littleEndian, 23, 4); 9544 return offset + 4; 9545 } 9546 9547 Buffer$1.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { 9548 return writeFloat$1(this, value, offset, true, noAssert); 9549 }; 9550 9551 Buffer$1.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { 9552 return writeFloat$1(this, value, offset, false, noAssert); 9553 }; 9554 9555 function writeDouble$1(buf, value, offset, littleEndian, noAssert) { 9556 if (!noAssert) { 9557 checkIEEE754$1(buf, value, offset, 8); 9558 } 9559 9560 write$1(buf, value, offset, littleEndian, 52, 8); 9561 return offset + 8; 9562 } 9563 9564 Buffer$1.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { 9565 return writeDouble$1(this, value, offset, true, noAssert); 9566 }; 9567 9568 Buffer$1.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { 9569 return writeDouble$1(this, value, offset, false, noAssert); 9570 }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 9571 9572 9573 Buffer$1.prototype.copy = function copy(target, targetStart, start, end) { 9574 if (!start) start = 0; 9575 if (!end && end !== 0) end = this.length; 9576 if (targetStart >= target.length) targetStart = target.length; 9577 if (!targetStart) targetStart = 0; 9578 if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done 9579 9580 if (end === start) return 0; 9581 if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions 9582 9583 if (targetStart < 0) { 9584 throw new RangeError('targetStart out of bounds'); 9585 } 9586 9587 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds'); 9588 if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? 9589 9590 if (end > this.length) end = this.length; 9591 9592 if (target.length - targetStart < end - start) { 9593 end = target.length - targetStart + start; 9594 } 9595 9596 var len = end - start; 9597 var i; 9598 9599 if (this === target && start < targetStart && targetStart < end) { 9600 // descending copy from end 9601 for (i = len - 1; i >= 0; --i) { 9602 target[i + targetStart] = this[i + start]; 9603 } 9604 } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) { 9605 // ascending copy from start 9606 for (i = 0; i < len; ++i) { 9607 target[i + targetStart] = this[i + start]; 9608 } 9609 } else { 9610 Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart); 9611 } 9612 9613 return len; 9614 }; // Usage: 9615 // buffer.fill(number[, offset[, end]]) 9616 // buffer.fill(buffer[, offset[, end]]) 9617 // buffer.fill(string[, offset[, end]][, encoding]) 9618 9619 9620 Buffer$1.prototype.fill = function fill(val, start, end, encoding) { 9621 // Handle string cases: 9622 if (typeof val === 'string') { 9623 if (typeof start === 'string') { 9624 encoding = start; 9625 start = 0; 9626 end = this.length; 9627 } else if (typeof end === 'string') { 9628 encoding = end; 9629 end = this.length; 9630 } 9631 9632 if (val.length === 1) { 9633 var code = val.charCodeAt(0); 9634 9635 if (code < 256) { 9636 val = code; 9637 } 9638 } 9639 9640 if (encoding !== undefined && typeof encoding !== 'string') { 9641 throw new TypeError('encoding must be a string'); 9642 } 9643 9644 if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) { 9645 throw new TypeError('Unknown encoding: ' + encoding); 9646 } 9647 } else if (typeof val === 'number') { 9648 val = val & 255; 9649 } // Invalid ranges are not set to a default, so can range check early. 9650 9651 9652 if (start < 0 || this.length < start || this.length < end) { 9653 throw new RangeError('Out of range index'); 9654 } 9655 9656 if (end <= start) { 9657 return this; 9658 } 9659 9660 start = start >>> 0; 9661 end = end === undefined ? this.length : end >>> 0; 9662 if (!val) val = 0; 9663 var i; 9664 9665 if (typeof val === 'number') { 9666 for (i = start; i < end; ++i) { 9667 this[i] = val; 9668 } 9669 } else { 9670 var bytes = internalIsBuffer$1(val) ? val : utf8ToBytes$1(new Buffer$1(val, encoding).toString()); 9671 var len = bytes.length; 9672 9673 for (i = 0; i < end - start; ++i) { 9674 this[i + start] = bytes[i % len]; 9675 } 9676 } 9677 9678 return this; 9679 }; // HELPER FUNCTIONS 9680 // ================ 9681 9682 9683 var INVALID_BASE64_RE$1 = /[^+\/0-9A-Za-z-_]/g; 9684 9685 function base64clean$1(str) { 9686 // Node strips out invalid characters like \n and \t from the string, base64-js does not 9687 str = stringtrim$1(str).replace(INVALID_BASE64_RE$1, ''); // Node converts strings with length < 2 to '' 9688 9689 if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 9690 9691 while (str.length % 4 !== 0) { 9692 str = str + '='; 9693 } 9694 9695 return str; 9696 } 9697 9698 function stringtrim$1(str) { 9699 if (str.trim) return str.trim(); 9700 return str.replace(/^\s+|\s+$/g, ''); 9701 } 9702 9703 function toHex$1(n) { 9704 if (n < 16) return '0' + n.toString(16); 9705 return n.toString(16); 9706 } 9707 9708 function utf8ToBytes$1(string, units) { 9709 units = units || Infinity; 9710 var codePoint; 9711 var length = string.length; 9712 var leadSurrogate = null; 9713 var bytes = []; 9714 9715 for (var i = 0; i < length; ++i) { 9716 codePoint = string.charCodeAt(i); // is surrogate component 9717 9718 if (codePoint > 0xD7FF && codePoint < 0xE000) { 9719 // last char was a lead 9720 if (!leadSurrogate) { 9721 // no lead yet 9722 if (codePoint > 0xDBFF) { 9723 // unexpected trail 9724 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 9725 continue; 9726 } else if (i + 1 === length) { 9727 // unpaired lead 9728 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 9729 continue; 9730 } // valid lead 9731 9732 9733 leadSurrogate = codePoint; 9734 continue; 9735 } // 2 leads in a row 9736 9737 9738 if (codePoint < 0xDC00) { 9739 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 9740 leadSurrogate = codePoint; 9741 continue; 9742 } // valid surrogate pair 9743 9744 9745 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; 9746 } else if (leadSurrogate) { 9747 // valid bmp char, but last char was a lead 9748 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 9749 } 9750 9751 leadSurrogate = null; // encode utf8 9752 9753 if (codePoint < 0x80) { 9754 if ((units -= 1) < 0) break; 9755 bytes.push(codePoint); 9756 } else if (codePoint < 0x800) { 9757 if ((units -= 2) < 0) break; 9758 bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); 9759 } else if (codePoint < 0x10000) { 9760 if ((units -= 3) < 0) break; 9761 bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); 9762 } else if (codePoint < 0x110000) { 9763 if ((units -= 4) < 0) break; 9764 bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); 9765 } else { 9766 throw new Error('Invalid code point'); 9767 } 9768 } 9769 9770 return bytes; 9771 } 9772 9773 function asciiToBytes$1(str) { 9774 var byteArray = []; 9775 9776 for (var i = 0; i < str.length; ++i) { 9777 // Node's code seems to be doing this and not & 0x7F.. 9778 byteArray.push(str.charCodeAt(i) & 0xFF); 9779 } 9780 9781 return byteArray; 9782 } 9783 9784 function utf16leToBytes$1(str, units) { 9785 var c, hi, lo; 9786 var byteArray = []; 9787 9788 for (var i = 0; i < str.length; ++i) { 9789 if ((units -= 2) < 0) break; 9790 c = str.charCodeAt(i); 9791 hi = c >> 8; 9792 lo = c % 256; 9793 byteArray.push(lo); 9794 byteArray.push(hi); 9795 } 9796 9797 return byteArray; 9798 } 9799 9800 function base64ToBytes$1(str) { 9801 return toByteArray$1(base64clean$1(str)); 9802 } 9803 9804 function blitBuffer$1(src, dst, offset, length) { 9805 for (var i = 0; i < length; ++i) { 9806 if (i + offset >= dst.length || i >= src.length) break; 9807 dst[i + offset] = src[i]; 9808 } 9809 9810 return i; 9811 } 9812 9813 function isnan$1(val) { 9814 return val !== val; // eslint-disable-line no-self-compare 9815 } // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence 9816 // The _isBuffer check is for Safari 5-7 support, because it's missing 9817 // Object.prototype.constructor. Remove this eventually 9818 9819 9820 function isBuffer$2(obj) { 9821 return obj != null && (!!obj._isBuffer || isFastBuffer$1(obj) || isSlowBuffer$1(obj)); 9822 } 9823 9824 function isFastBuffer$1(obj) { 9825 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj); 9826 } // For Node v0.10 support. Remove this eventually. 9827 9828 9829 function isSlowBuffer$1(obj) { 9830 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer$1(obj.slice(0, 0)); 9831 } 9832 9833 function BufferList() { 9834 this.head = null; 9835 this.tail = null; 9836 this.length = 0; 9837 } 9838 9839 BufferList.prototype.push = function (v) { 9840 var entry = { 9841 data: v, 9842 next: null 9843 }; 9844 if (this.length > 0) this.tail.next = entry;else this.head = entry; 9845 this.tail = entry; 9846 ++this.length; 9847 }; 9848 9849 BufferList.prototype.unshift = function (v) { 9850 var entry = { 9851 data: v, 9852 next: this.head 9853 }; 9854 if (this.length === 0) this.tail = entry; 9855 this.head = entry; 9856 ++this.length; 9857 }; 9858 9859 BufferList.prototype.shift = function () { 9860 if (this.length === 0) return; 9861 var ret = this.head.data; 9862 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; 9863 --this.length; 9864 return ret; 9865 }; 9866 9867 BufferList.prototype.clear = function () { 9868 this.head = this.tail = null; 9869 this.length = 0; 9870 }; 9871 9872 BufferList.prototype.join = function (s) { 9873 if (this.length === 0) return ''; 9874 var p = this.head; 9875 var ret = '' + p.data; 9876 9877 while (p = p.next) { 9878 ret += s + p.data; 9879 } 9880 9881 return ret; 9882 }; 9883 9884 BufferList.prototype.concat = function (n) { 9885 if (this.length === 0) return Buffer$1.alloc(0); 9886 if (this.length === 1) return this.head.data; 9887 var ret = Buffer$1.allocUnsafe(n >>> 0); 9888 var p = this.head; 9889 var i = 0; 9890 9891 while (p) { 9892 p.data.copy(ret, i); 9893 i += p.data.length; 9894 p = p.next; 9895 } 9896 9897 return ret; 9898 }; 9899 9900 var isBufferEncoding = Buffer$1.isEncoding || function (encoding) { 9901 switch (encoding && encoding.toLowerCase()) { 9902 case 'hex': 9903 case 'utf8': 9904 case 'utf-8': 9905 case 'ascii': 9906 case 'binary': 9907 case 'base64': 9908 case 'ucs2': 9909 case 'ucs-2': 9910 case 'utf16le': 9911 case 'utf-16le': 9912 case 'raw': 9913 return true; 9914 9915 default: 9916 return false; 9917 } 9918 }; 9919 9920 function assertEncoding(encoding) { 9921 if (encoding && !isBufferEncoding(encoding)) { 9922 throw new Error('Unknown encoding: ' + encoding); 9923 } 9924 } // StringDecoder provides an interface for efficiently splitting a series of 9925 // buffers into a series of JS strings without breaking apart multi-byte 9926 // characters. CESU-8 is handled as part of the UTF-8 encoding. 9927 // 9928 // @TODO Handling all encodings inside a single object makes it very difficult 9929 // to reason about this code, so it should be split up in the future. 9930 // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code 9931 // points as used by CESU-8. 9932 9933 9934 function StringDecoder(encoding) { 9935 this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); 9936 assertEncoding(encoding); 9937 9938 switch (this.encoding) { 9939 case 'utf8': 9940 // CESU-8 represents each of Surrogate Pair by 3-bytes 9941 this.surrogateSize = 3; 9942 break; 9943 9944 case 'ucs2': 9945 case 'utf16le': 9946 // UTF-16 represents each of Surrogate Pair by 2-bytes 9947 this.surrogateSize = 2; 9948 this.detectIncompleteChar = utf16DetectIncompleteChar; 9949 break; 9950 9951 case 'base64': 9952 // Base-64 stores 3 bytes in 4 chars, and pads the remainder. 9953 this.surrogateSize = 3; 9954 this.detectIncompleteChar = base64DetectIncompleteChar; 9955 break; 9956 9957 default: 9958 this.write = passThroughWrite; 9959 return; 9960 } // Enough space to store all bytes of a single character. UTF-8 needs 4 9961 // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). 9962 9963 9964 this.charBuffer = new Buffer$1(6); // Number of bytes received for the current incomplete multi-byte character. 9965 9966 this.charReceived = 0; // Number of bytes expected for the current incomplete multi-byte character. 9967 9968 this.charLength = 0; 9969 } 9970 // guaranteed to not contain any partial multi-byte characters. Any partial 9971 // character found at the end of the buffer is buffered up, and will be 9972 // returned when calling write again with the remaining bytes. 9973 // 9974 // Note: Converting a Buffer containing an orphan surrogate to a String 9975 // currently works, but converting a String to a Buffer (via `new Buffer`, or 9976 // Buffer#write) will replace incomplete surrogates with the unicode 9977 // replacement character. See https://codereview.chromium.org/121173009/ . 9978 9979 StringDecoder.prototype.write = function (buffer) { 9980 var charStr = ''; // if our last write ended with an incomplete multibyte character 9981 9982 while (this.charLength) { 9983 // determine how many remaining bytes this buffer has to offer for this char 9984 var available = buffer.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : buffer.length; // add the new bytes to the char buffer 9985 9986 buffer.copy(this.charBuffer, this.charReceived, 0, available); 9987 this.charReceived += available; 9988 9989 if (this.charReceived < this.charLength) { 9990 // still not enough chars in this buffer? wait for more ... 9991 return ''; 9992 } // remove bytes belonging to the current character from the buffer 9993 9994 9995 buffer = buffer.slice(available, buffer.length); // get the character that was split 9996 9997 charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character 9998 9999 var charCode = charStr.charCodeAt(charStr.length - 1); 10000 10001 if (charCode >= 0xD800 && charCode <= 0xDBFF) { 10002 this.charLength += this.surrogateSize; 10003 charStr = ''; 10004 continue; 10005 } 10006 10007 this.charReceived = this.charLength = 0; // if there are no more bytes in this buffer, just emit our char 10008 10009 if (buffer.length === 0) { 10010 return charStr; 10011 } 10012 10013 break; 10014 } // determine and set charLength / charReceived 10015 10016 10017 this.detectIncompleteChar(buffer); 10018 var end = buffer.length; 10019 10020 if (this.charLength) { 10021 // buffer the incomplete character bytes we got 10022 buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); 10023 end -= this.charReceived; 10024 } 10025 10026 charStr += buffer.toString(this.encoding, 0, end); 10027 var end = charStr.length - 1; 10028 var charCode = charStr.charCodeAt(end); // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character 10029 10030 if (charCode >= 0xD800 && charCode <= 0xDBFF) { 10031 var size = this.surrogateSize; 10032 this.charLength += size; 10033 this.charReceived += size; 10034 this.charBuffer.copy(this.charBuffer, size, 0, size); 10035 buffer.copy(this.charBuffer, 0, 0, size); 10036 return charStr.substring(0, end); 10037 } // or just emit the charStr 10038 10039 10040 return charStr; 10041 }; // detectIncompleteChar determines if there is an incomplete UTF-8 character at 10042 // the end of the given buffer. If so, it sets this.charLength to the byte 10043 // length that character, and sets this.charReceived to the number of bytes 10044 // that are available for this character. 10045 10046 10047 StringDecoder.prototype.detectIncompleteChar = function (buffer) { 10048 // determine how many bytes we have to check at the end of this buffer 10049 var i = buffer.length >= 3 ? 3 : buffer.length; // Figure out if one of the last i bytes of our buffer announces an 10050 // incomplete char. 10051 10052 for (; i > 0; i--) { 10053 var c = buffer[buffer.length - i]; // See http://en.wikipedia.org/wiki/UTF-8#Description 10054 // 110XXXXX 10055 10056 if (i == 1 && c >> 5 == 0x06) { 10057 this.charLength = 2; 10058 break; 10059 } // 1110XXXX 10060 10061 10062 if (i <= 2 && c >> 4 == 0x0E) { 10063 this.charLength = 3; 10064 break; 10065 } // 11110XXX 10066 10067 10068 if (i <= 3 && c >> 3 == 0x1E) { 10069 this.charLength = 4; 10070 break; 10071 } 10072 } 10073 10074 this.charReceived = i; 10075 }; 10076 10077 StringDecoder.prototype.end = function (buffer) { 10078 var res = ''; 10079 if (buffer && buffer.length) res = this.write(buffer); 10080 10081 if (this.charReceived) { 10082 var cr = this.charReceived; 10083 var buf = this.charBuffer; 10084 var enc = this.encoding; 10085 res += buf.slice(0, cr).toString(enc); 10086 } 10087 10088 return res; 10089 }; 10090 10091 function passThroughWrite(buffer) { 10092 return buffer.toString(this.encoding); 10093 } 10094 10095 function utf16DetectIncompleteChar(buffer) { 10096 this.charReceived = buffer.length % 2; 10097 this.charLength = this.charReceived ? 2 : 0; 10098 } 10099 10100 function base64DetectIncompleteChar(buffer) { 10101 this.charReceived = buffer.length % 3; 10102 this.charLength = this.charReceived ? 3 : 0; 10103 } 10104 10105 Readable.ReadableState = ReadableState; 10106 var debug = debuglog('stream'); 10107 inherits$1(Readable, EventEmitter); 10108 10109 function prependListener(emitter, event, fn) { 10110 // Sadly this is not cacheable as some libraries bundle their own 10111 // event emitter implementation with them. 10112 if (typeof emitter.prependListener === 'function') { 10113 return emitter.prependListener(event, fn); 10114 } else { 10115 // This is a hack to make sure that our error handler is attached before any 10116 // userland ones. NEVER DO THIS. This is here only because this code needs 10117 // to continue to work with older versions of Node.js that do not include 10118 // the prependListener() method. The goal is to eventually remove this hack. 10119 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; 10120 } 10121 } 10122 10123 function listenerCount$1(emitter, type) { 10124 return emitter.listeners(type).length; 10125 } 10126 10127 function ReadableState(options, stream) { 10128 options = options || {}; // object stream flag. Used to make read(n) ignore n and to 10129 // make all the buffer merging and length checks go away 10130 10131 this.objectMode = !!options.objectMode; 10132 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer 10133 // Note: 0 is a valid value, means "don't call _read preemptively ever" 10134 10135 var hwm = options.highWaterMark; 10136 var defaultHwm = this.objectMode ? 16 : 16 * 1024; 10137 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. 10138 10139 this.highWaterMark = ~~this.highWaterMark; // A linked list is used to store data chunks instead of an array because the 10140 // linked list can remove elements from the beginning faster than 10141 // array.shift() 10142 10143 this.buffer = new BufferList(); 10144 this.length = 0; 10145 this.pipes = null; 10146 this.pipesCount = 0; 10147 this.flowing = null; 10148 this.ended = false; 10149 this.endEmitted = false; 10150 this.reading = false; // a flag to be able to tell if the onwrite cb is called immediately, 10151 // or on a later tick. We set this to true at first, because any 10152 // actions that shouldn't happen until "later" should generally also 10153 // not happen before the first write call. 10154 10155 this.sync = true; // whenever we return null, then we set a flag to say 10156 // that we're awaiting a 'readable' event emission. 10157 10158 this.needReadable = false; 10159 this.emittedReadable = false; 10160 this.readableListening = false; 10161 this.resumeScheduled = false; // Crypto is kind of old and crusty. Historically, its default string 10162 // encoding is 'binary' so we have to make this configurable. 10163 // Everything else in the universe uses 'utf8', though. 10164 10165 this.defaultEncoding = options.defaultEncoding || 'utf8'; // when piping, we only care about 'readable' events that happen 10166 // after read()ing all the bytes and not getting any pushback. 10167 10168 this.ranOut = false; // the number of writers that are awaiting a drain event in .pipe()s 10169 10170 this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled 10171 10172 this.readingMore = false; 10173 this.decoder = null; 10174 this.encoding = null; 10175 10176 if (options.encoding) { 10177 this.decoder = new StringDecoder(options.encoding); 10178 this.encoding = options.encoding; 10179 } 10180 } 10181 function Readable(options) { 10182 if (!(this instanceof Readable)) return new Readable(options); 10183 this._readableState = new ReadableState(options, this); // legacy 10184 10185 this.readable = true; 10186 if (options && typeof options.read === 'function') this._read = options.read; 10187 EventEmitter.call(this); 10188 } // Manually shove something into the read() buffer. 10189 // This returns true if the highWaterMark has not been hit yet, 10190 // similar to how Writable.write() returns true if you should 10191 // write() some more. 10192 10193 Readable.prototype.push = function (chunk, encoding) { 10194 var state = this._readableState; 10195 10196 if (!state.objectMode && typeof chunk === 'string') { 10197 encoding = encoding || state.defaultEncoding; 10198 10199 if (encoding !== state.encoding) { 10200 chunk = Buffer.from(chunk, encoding); 10201 encoding = ''; 10202 } 10203 } 10204 10205 return readableAddChunk(this, state, chunk, encoding, false); 10206 }; // Unshift should *always* be something directly out of read() 10207 10208 10209 Readable.prototype.unshift = function (chunk) { 10210 var state = this._readableState; 10211 return readableAddChunk(this, state, chunk, '', true); 10212 }; 10213 10214 Readable.prototype.isPaused = function () { 10215 return this._readableState.flowing === false; 10216 }; 10217 10218 function readableAddChunk(stream, state, chunk, encoding, addToFront) { 10219 var er = chunkInvalid(state, chunk); 10220 10221 if (er) { 10222 stream.emit('error', er); 10223 } else if (chunk === null) { 10224 state.reading = false; 10225 onEofChunk(stream, state); 10226 } else if (state.objectMode || chunk && chunk.length > 0) { 10227 if (state.ended && !addToFront) { 10228 var e = new Error('stream.push() after EOF'); 10229 stream.emit('error', e); 10230 } else if (state.endEmitted && addToFront) { 10231 var _e = new Error('stream.unshift() after end event'); 10232 10233 stream.emit('error', _e); 10234 } else { 10235 var skipAdd; 10236 10237 if (state.decoder && !addToFront && !encoding) { 10238 chunk = state.decoder.write(chunk); 10239 skipAdd = !state.objectMode && chunk.length === 0; 10240 } 10241 10242 if (!addToFront) state.reading = false; // Don't add to the buffer if we've decoded to an empty string chunk and 10243 // we're not in object mode 10244 10245 if (!skipAdd) { 10246 // if we want the data now, just emit it. 10247 if (state.flowing && state.length === 0 && !state.sync) { 10248 stream.emit('data', chunk); 10249 stream.read(0); 10250 } else { 10251 // update the buffer info. 10252 state.length += state.objectMode ? 1 : chunk.length; 10253 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); 10254 if (state.needReadable) emitReadable(stream); 10255 } 10256 } 10257 10258 maybeReadMore(stream, state); 10259 } 10260 } else if (!addToFront) { 10261 state.reading = false; 10262 } 10263 10264 return needMoreData(state); 10265 } // if it's past the high water mark, we can push in some more. 10266 // Also, if we have no data yet, we can stand some 10267 // more bytes. This is to work around cases where hwm=0, 10268 // such as the repl. Also, if the push() triggered a 10269 // readable event, and the user called read(largeNumber) such that 10270 // needReadable was set, then we ought to push more, so that another 10271 // 'readable' event will be triggered. 10272 10273 10274 function needMoreData(state) { 10275 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); 10276 } // backwards compatibility. 10277 10278 10279 Readable.prototype.setEncoding = function (enc) { 10280 this._readableState.decoder = new StringDecoder(enc); 10281 this._readableState.encoding = enc; 10282 return this; 10283 }; // Don't raise the hwm > 8MB 10284 10285 10286 var MAX_HWM = 0x800000; 10287 10288 function computeNewHighWaterMark(n) { 10289 if (n >= MAX_HWM) { 10290 n = MAX_HWM; 10291 } else { 10292 // Get the next highest power of 2 to prevent increasing hwm excessively in 10293 // tiny amounts 10294 n--; 10295 n |= n >>> 1; 10296 n |= n >>> 2; 10297 n |= n >>> 4; 10298 n |= n >>> 8; 10299 n |= n >>> 16; 10300 n++; 10301 } 10302 10303 return n; 10304 } // This function is designed to be inlinable, so please take care when making 10305 // changes to the function body. 10306 10307 10308 function howMuchToRead(n, state) { 10309 if (n <= 0 || state.length === 0 && state.ended) return 0; 10310 if (state.objectMode) return 1; 10311 10312 if (n !== n) { 10313 // Only flow one buffer at a time 10314 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; 10315 } // If we're asking for more than the current hwm, then raise the hwm. 10316 10317 10318 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); 10319 if (n <= state.length) return n; // Don't have enough 10320 10321 if (!state.ended) { 10322 state.needReadable = true; 10323 return 0; 10324 } 10325 10326 return state.length; 10327 } // you can override either this method, or the async _read(n) below. 10328 10329 10330 Readable.prototype.read = function (n) { 10331 debug('read', n); 10332 n = parseInt(n, 10); 10333 var state = this._readableState; 10334 var nOrig = n; 10335 if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we 10336 // already have a bunch of data in the buffer, then just trigger 10337 // the 'readable' event and move on. 10338 10339 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { 10340 debug('read: emitReadable', state.length, state.ended); 10341 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); 10342 return null; 10343 } 10344 10345 n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. 10346 10347 if (n === 0 && state.ended) { 10348 if (state.length === 0) endReadable(this); 10349 return null; 10350 } // All the actual chunk generation logic needs to be 10351 // *below* the call to _read. The reason is that in certain 10352 // synthetic stream cases, such as passthrough streams, _read 10353 // may be a completely synchronous operation which may change 10354 // the state of the read buffer, providing enough data when 10355 // before there was *not* enough. 10356 // 10357 // So, the steps are: 10358 // 1. Figure out what the state of things will be after we do 10359 // a read from the buffer. 10360 // 10361 // 2. If that resulting state will trigger a _read, then call _read. 10362 // Note that this may be asynchronous, or synchronous. Yes, it is 10363 // deeply ugly to write APIs this way, but that still doesn't mean 10364 // that the Readable class should behave improperly, as streams are 10365 // designed to be sync/async agnostic. 10366 // Take note if the _read call is sync or async (ie, if the read call 10367 // has returned yet), so that we know whether or not it's safe to emit 10368 // 'readable' etc. 10369 // 10370 // 3. Actually pull the requested chunks out of the buffer and return. 10371 // if we need a readable event, then we need to do some reading. 10372 10373 10374 var doRead = state.needReadable; 10375 debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some 10376 10377 if (state.length === 0 || state.length - n < state.highWaterMark) { 10378 doRead = true; 10379 debug('length less than watermark', doRead); 10380 } // however, if we've ended, then there's no point, and if we're already 10381 // reading, then it's unnecessary. 10382 10383 10384 if (state.ended || state.reading) { 10385 doRead = false; 10386 debug('reading or ended', doRead); 10387 } else if (doRead) { 10388 debug('do read'); 10389 state.reading = true; 10390 state.sync = true; // if the length is currently zero, then we *need* a readable event. 10391 10392 if (state.length === 0) state.needReadable = true; // call internal read method 10393 10394 this._read(state.highWaterMark); 10395 10396 state.sync = false; // If _read pushed data synchronously, then `reading` will be false, 10397 // and we need to re-evaluate how much data we can return to the user. 10398 10399 if (!state.reading) n = howMuchToRead(nOrig, state); 10400 } 10401 10402 var ret; 10403 if (n > 0) ret = fromList(n, state);else ret = null; 10404 10405 if (ret === null) { 10406 state.needReadable = true; 10407 n = 0; 10408 } else { 10409 state.length -= n; 10410 } 10411 10412 if (state.length === 0) { 10413 // If we have nothing in the buffer, then we want to know 10414 // as soon as we *do* get something into the buffer. 10415 if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. 10416 10417 if (nOrig !== n && state.ended) endReadable(this); 10418 } 10419 10420 if (ret !== null) this.emit('data', ret); 10421 return ret; 10422 }; 10423 10424 function chunkInvalid(state, chunk) { 10425 var er = null; 10426 10427 if (!isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { 10428 er = new TypeError('Invalid non-string/buffer chunk'); 10429 } 10430 10431 return er; 10432 } 10433 10434 function onEofChunk(stream, state) { 10435 if (state.ended) return; 10436 10437 if (state.decoder) { 10438 var chunk = state.decoder.end(); 10439 10440 if (chunk && chunk.length) { 10441 state.buffer.push(chunk); 10442 state.length += state.objectMode ? 1 : chunk.length; 10443 } 10444 } 10445 10446 state.ended = true; // emit 'readable' now to make sure it gets picked up. 10447 10448 emitReadable(stream); 10449 } // Don't emit readable right away in sync mode, because this can trigger 10450 // another read() call => stack overflow. This way, it might trigger 10451 // a nextTick recursion warning, but that's not so bad. 10452 10453 10454 function emitReadable(stream) { 10455 var state = stream._readableState; 10456 state.needReadable = false; 10457 10458 if (!state.emittedReadable) { 10459 debug('emitReadable', state.flowing); 10460 state.emittedReadable = true; 10461 if (state.sync) nextTick$1(emitReadable_, stream);else emitReadable_(stream); 10462 } 10463 } 10464 10465 function emitReadable_(stream) { 10466 debug('emit readable'); 10467 stream.emit('readable'); 10468 flow(stream); 10469 } // at this point, the user has presumably seen the 'readable' event, 10470 // and called read() to consume some data. that may have triggered 10471 // in turn another _read(n) call, in which case reading = true if 10472 // it's in progress. 10473 // However, if we're not ended, or reading, and the length < hwm, 10474 // then go ahead and try to read some more preemptively. 10475 10476 10477 function maybeReadMore(stream, state) { 10478 if (!state.readingMore) { 10479 state.readingMore = true; 10480 nextTick$1(maybeReadMore_, stream, state); 10481 } 10482 } 10483 10484 function maybeReadMore_(stream, state) { 10485 var len = state.length; 10486 10487 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { 10488 debug('maybeReadMore read 0'); 10489 stream.read(0); 10490 if (len === state.length) // didn't get any data, stop spinning. 10491 break;else len = state.length; 10492 } 10493 10494 state.readingMore = false; 10495 } // abstract method. to be overridden in specific implementation classes. 10496 // call cb(er, data) where data is <= n in length. 10497 // for virtual (non-string, non-buffer) streams, "length" is somewhat 10498 // arbitrary, and perhaps not very meaningful. 10499 10500 10501 Readable.prototype._read = function (n) { 10502 this.emit('error', new Error('not implemented')); 10503 }; 10504 10505 Readable.prototype.pipe = function (dest, pipeOpts) { 10506 var src = this; 10507 var state = this._readableState; 10508 10509 switch (state.pipesCount) { 10510 case 0: 10511 state.pipes = dest; 10512 break; 10513 10514 case 1: 10515 state.pipes = [state.pipes, dest]; 10516 break; 10517 10518 default: 10519 state.pipes.push(dest); 10520 break; 10521 } 10522 10523 state.pipesCount += 1; 10524 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); 10525 var doEnd = !pipeOpts || pipeOpts.end !== false; 10526 var endFn = doEnd ? onend : cleanup; 10527 if (state.endEmitted) nextTick$1(endFn);else src.once('end', endFn); 10528 dest.on('unpipe', onunpipe); 10529 10530 function onunpipe(readable) { 10531 debug('onunpipe'); 10532 10533 if (readable === src) { 10534 cleanup(); 10535 } 10536 } 10537 10538 function onend() { 10539 debug('onend'); 10540 dest.end(); 10541 } // when the dest drains, it reduces the awaitDrain counter 10542 // on the source. This would be more elegant with a .once() 10543 // handler in flow(), but adding and removing repeatedly is 10544 // too slow. 10545 10546 10547 var ondrain = pipeOnDrain(src); 10548 dest.on('drain', ondrain); 10549 var cleanedUp = false; 10550 10551 function cleanup() { 10552 debug('cleanup'); // cleanup event handlers once the pipe is broken 10553 10554 dest.removeListener('close', onclose); 10555 dest.removeListener('finish', onfinish); 10556 dest.removeListener('drain', ondrain); 10557 dest.removeListener('error', onerror); 10558 dest.removeListener('unpipe', onunpipe); 10559 src.removeListener('end', onend); 10560 src.removeListener('end', cleanup); 10561 src.removeListener('data', ondata); 10562 cleanedUp = true; // if the reader is waiting for a drain event from this 10563 // specific writer, then it would cause it to never start 10564 // flowing again. 10565 // So, if this is awaiting a drain, then we just call it now. 10566 // If we don't know, then assume that we are waiting for one. 10567 10568 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); 10569 } // If the user pushes more data while we're writing to dest then we'll end up 10570 // in ondata again. However, we only want to increase awaitDrain once because 10571 // dest will only emit one 'drain' event for the multiple writes. 10572 // => Introduce a guard on increasing awaitDrain. 10573 10574 10575 var increasedAwaitDrain = false; 10576 src.on('data', ondata); 10577 10578 function ondata(chunk) { 10579 debug('ondata'); 10580 increasedAwaitDrain = false; 10581 var ret = dest.write(chunk); 10582 10583 if (false === ret && !increasedAwaitDrain) { 10584 // If the user unpiped during `dest.write()`, it is possible 10585 // to get stuck in a permanently paused state if that write 10586 // also returned false. 10587 // => Check whether `dest` is still a piping destination. 10588 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf$1(state.pipes, dest) !== -1) && !cleanedUp) { 10589 debug('false write response, pause', src._readableState.awaitDrain); 10590 src._readableState.awaitDrain++; 10591 increasedAwaitDrain = true; 10592 } 10593 10594 src.pause(); 10595 } 10596 } // if the dest has an error, then stop piping into it. 10597 // however, don't suppress the throwing behavior for this. 10598 10599 10600 function onerror(er) { 10601 debug('onerror', er); 10602 unpipe(); 10603 dest.removeListener('error', onerror); 10604 if (listenerCount$1(dest, 'error') === 0) dest.emit('error', er); 10605 } // Make sure our error handler is attached before userland ones. 10606 10607 10608 prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. 10609 10610 function onclose() { 10611 dest.removeListener('finish', onfinish); 10612 unpipe(); 10613 } 10614 10615 dest.once('close', onclose); 10616 10617 function onfinish() { 10618 debug('onfinish'); 10619 dest.removeListener('close', onclose); 10620 unpipe(); 10621 } 10622 10623 dest.once('finish', onfinish); 10624 10625 function unpipe() { 10626 debug('unpipe'); 10627 src.unpipe(dest); 10628 } // tell the dest that it's being piped to 10629 10630 10631 dest.emit('pipe', src); // start the flow if it hasn't been started already. 10632 10633 if (!state.flowing) { 10634 debug('pipe resume'); 10635 src.resume(); 10636 } 10637 10638 return dest; 10639 }; 10640 10641 function pipeOnDrain(src) { 10642 return function () { 10643 var state = src._readableState; 10644 debug('pipeOnDrain', state.awaitDrain); 10645 if (state.awaitDrain) state.awaitDrain--; 10646 10647 if (state.awaitDrain === 0 && src.listeners('data').length) { 10648 state.flowing = true; 10649 flow(src); 10650 } 10651 }; 10652 } 10653 10654 Readable.prototype.unpipe = function (dest) { 10655 var state = this._readableState; // if we're not piping anywhere, then do nothing. 10656 10657 if (state.pipesCount === 0) return this; // just one destination. most common case. 10658 10659 if (state.pipesCount === 1) { 10660 // passed in one, but it's not the right one. 10661 if (dest && dest !== state.pipes) return this; 10662 if (!dest) dest = state.pipes; // got a match. 10663 10664 state.pipes = null; 10665 state.pipesCount = 0; 10666 state.flowing = false; 10667 if (dest) dest.emit('unpipe', this); 10668 return this; 10669 } // slow case. multiple pipe destinations. 10670 10671 10672 if (!dest) { 10673 // remove all. 10674 var dests = state.pipes; 10675 var len = state.pipesCount; 10676 state.pipes = null; 10677 state.pipesCount = 0; 10678 state.flowing = false; 10679 10680 for (var _i = 0; _i < len; _i++) { 10681 dests[_i].emit('unpipe', this); 10682 } 10683 10684 return this; 10685 } // try to find the right one. 10686 10687 10688 var i = indexOf$1(state.pipes, dest); 10689 if (i === -1) return this; 10690 state.pipes.splice(i, 1); 10691 state.pipesCount -= 1; 10692 if (state.pipesCount === 1) state.pipes = state.pipes[0]; 10693 dest.emit('unpipe', this); 10694 return this; 10695 }; // set up data events if they are asked for 10696 // Ensure readable listeners eventually get something 10697 10698 10699 Readable.prototype.on = function (ev, fn) { 10700 var res = EventEmitter.prototype.on.call(this, ev, fn); 10701 10702 if (ev === 'data') { 10703 // Start flowing on next tick if stream isn't explicitly paused 10704 if (this._readableState.flowing !== false) this.resume(); 10705 } else if (ev === 'readable') { 10706 var state = this._readableState; 10707 10708 if (!state.endEmitted && !state.readableListening) { 10709 state.readableListening = state.needReadable = true; 10710 state.emittedReadable = false; 10711 10712 if (!state.reading) { 10713 nextTick$1(nReadingNextTick, this); 10714 } else if (state.length) { 10715 emitReadable(this); 10716 } 10717 } 10718 } 10719 10720 return res; 10721 }; 10722 10723 Readable.prototype.addListener = Readable.prototype.on; 10724 10725 function nReadingNextTick(self) { 10726 debug('readable nexttick read 0'); 10727 self.read(0); 10728 } // pause() and resume() are remnants of the legacy readable stream API 10729 // If the user uses them, then switch into old mode. 10730 10731 10732 Readable.prototype.resume = function () { 10733 var state = this._readableState; 10734 10735 if (!state.flowing) { 10736 debug('resume'); 10737 state.flowing = true; 10738 resume(this, state); 10739 } 10740 10741 return this; 10742 }; 10743 10744 function resume(stream, state) { 10745 if (!state.resumeScheduled) { 10746 state.resumeScheduled = true; 10747 nextTick$1(resume_, stream, state); 10748 } 10749 } 10750 10751 function resume_(stream, state) { 10752 if (!state.reading) { 10753 debug('resume read 0'); 10754 stream.read(0); 10755 } 10756 10757 state.resumeScheduled = false; 10758 state.awaitDrain = 0; 10759 stream.emit('resume'); 10760 flow(stream); 10761 if (state.flowing && !state.reading) stream.read(0); 10762 } 10763 10764 Readable.prototype.pause = function () { 10765 debug('call pause flowing=%j', this._readableState.flowing); 10766 10767 if (false !== this._readableState.flowing) { 10768 debug('pause'); 10769 this._readableState.flowing = false; 10770 this.emit('pause'); 10771 } 10772 10773 return this; 10774 }; 10775 10776 function flow(stream) { 10777 var state = stream._readableState; 10778 debug('flow', state.flowing); 10779 10780 while (state.flowing && stream.read() !== null) {} 10781 } // wrap an old-style stream as the async data source. 10782 // This is *not* part of the readable stream interface. 10783 // It is an ugly unfortunate mess of history. 10784 10785 10786 Readable.prototype.wrap = function (stream) { 10787 var state = this._readableState; 10788 var paused = false; 10789 var self = this; 10790 stream.on('end', function () { 10791 debug('wrapped end'); 10792 10793 if (state.decoder && !state.ended) { 10794 var chunk = state.decoder.end(); 10795 if (chunk && chunk.length) self.push(chunk); 10796 } 10797 10798 self.push(null); 10799 }); 10800 stream.on('data', function (chunk) { 10801 debug('wrapped data'); 10802 if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode 10803 10804 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; 10805 var ret = self.push(chunk); 10806 10807 if (!ret) { 10808 paused = true; 10809 stream.pause(); 10810 } 10811 }); // proxy all the other methods. 10812 // important when wrapping filters and duplexes. 10813 10814 for (var i in stream) { 10815 if (this[i] === undefined && typeof stream[i] === 'function') { 10816 this[i] = function (method) { 10817 return function () { 10818 return stream[method].apply(stream, arguments); 10819 }; 10820 }(i); 10821 } 10822 } // proxy certain important events. 10823 10824 10825 var events = ['error', 'close', 'destroy', 'pause', 'resume']; 10826 forEach(events, function (ev) { 10827 stream.on(ev, self.emit.bind(self, ev)); 10828 }); // when we try to consume some more bytes, simply unpause the 10829 // underlying stream. 10830 10831 self._read = function (n) { 10832 debug('wrapped _read', n); 10833 10834 if (paused) { 10835 paused = false; 10836 stream.resume(); 10837 } 10838 }; 10839 10840 return self; 10841 }; // exposed for testing purposes only. 10842 10843 10844 Readable._fromList = fromList; // Pluck off n bytes from an array of buffers. 10845 // Length is the combined lengths of all the buffers in the list. 10846 // This function is designed to be inlinable, so please take care when making 10847 // changes to the function body. 10848 10849 function fromList(n, state) { 10850 // nothing buffered 10851 if (state.length === 0) return null; 10852 var ret; 10853 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { 10854 // read it all, truncate the list 10855 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); 10856 state.buffer.clear(); 10857 } else { 10858 // read part of list 10859 ret = fromListPartial(n, state.buffer, state.decoder); 10860 } 10861 return ret; 10862 } // Extracts only enough buffered data to satisfy the amount requested. 10863 // This function is designed to be inlinable, so please take care when making 10864 // changes to the function body. 10865 10866 10867 function fromListPartial(n, list, hasStrings) { 10868 var ret; 10869 10870 if (n < list.head.data.length) { 10871 // slice is the same for buffers and strings 10872 ret = list.head.data.slice(0, n); 10873 list.head.data = list.head.data.slice(n); 10874 } else if (n === list.head.data.length) { 10875 // first chunk is a perfect match 10876 ret = list.shift(); 10877 } else { 10878 // result spans more than one buffer 10879 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); 10880 } 10881 10882 return ret; 10883 } // Copies a specified amount of characters from the list of buffered data 10884 // chunks. 10885 // This function is designed to be inlinable, so please take care when making 10886 // changes to the function body. 10887 10888 10889 function copyFromBufferString(n, list) { 10890 var p = list.head; 10891 var c = 1; 10892 var ret = p.data; 10893 n -= ret.length; 10894 10895 while (p = p.next) { 10896 var str = p.data; 10897 var nb = n > str.length ? str.length : n; 10898 if (nb === str.length) ret += str;else ret += str.slice(0, n); 10899 n -= nb; 10900 10901 if (n === 0) { 10902 if (nb === str.length) { 10903 ++c; 10904 if (p.next) list.head = p.next;else list.head = list.tail = null; 10905 } else { 10906 list.head = p; 10907 p.data = str.slice(nb); 10908 } 10909 10910 break; 10911 } 10912 10913 ++c; 10914 } 10915 10916 list.length -= c; 10917 return ret; 10918 } // Copies a specified amount of bytes from the list of buffered data chunks. 10919 // This function is designed to be inlinable, so please take care when making 10920 // changes to the function body. 10921 10922 10923 function copyFromBuffer(n, list) { 10924 var ret = Buffer.allocUnsafe(n); 10925 var p = list.head; 10926 var c = 1; 10927 p.data.copy(ret); 10928 n -= p.data.length; 10929 10930 while (p = p.next) { 10931 var buf = p.data; 10932 var nb = n > buf.length ? buf.length : n; 10933 buf.copy(ret, ret.length - n, 0, nb); 10934 n -= nb; 10935 10936 if (n === 0) { 10937 if (nb === buf.length) { 10938 ++c; 10939 if (p.next) list.head = p.next;else list.head = list.tail = null; 10940 } else { 10941 list.head = p; 10942 p.data = buf.slice(nb); 10943 } 10944 10945 break; 10946 } 10947 10948 ++c; 10949 } 10950 10951 list.length -= c; 10952 return ret; 10953 } 10954 10955 function endReadable(stream) { 10956 var state = stream._readableState; // If we get here before consuming all the bytes, then that is a 10957 // bug in node. Should never happen. 10958 10959 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); 10960 10961 if (!state.endEmitted) { 10962 state.ended = true; 10963 nextTick$1(endReadableNT, state, stream); 10964 } 10965 } 10966 10967 function endReadableNT(state, stream) { 10968 // Check that we didn't get one last unshift. 10969 if (!state.endEmitted && state.length === 0) { 10970 state.endEmitted = true; 10971 stream.readable = false; 10972 stream.emit('end'); 10973 } 10974 } 10975 10976 function forEach(xs, f) { 10977 for (var i = 0, l = xs.length; i < l; i++) { 10978 f(xs[i], i); 10979 } 10980 } 10981 10982 function indexOf$1(xs, x) { 10983 for (var i = 0, l = xs.length; i < l; i++) { 10984 if (xs[i] === x) return i; 10985 } 10986 10987 return -1; 10988 } 10989 10990 // A bit simpler than readable streams. 10991 Writable.WritableState = WritableState; 10992 inherits$1(Writable, EventEmitter); 10993 10994 function nop() {} 10995 10996 function WriteReq(chunk, encoding, cb) { 10997 this.chunk = chunk; 10998 this.encoding = encoding; 10999 this.callback = cb; 11000 this.next = null; 11001 } 11002 11003 function WritableState(options, stream) { 11004 Object.defineProperty(this, 'buffer', { 11005 get: deprecate(function () { 11006 return this.getBuffer(); 11007 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') 11008 }); 11009 options = options || {}; // object stream flag to indicate whether or not this stream 11010 // contains buffers or objects. 11011 11012 this.objectMode = !!options.objectMode; 11013 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false 11014 // Note: 0 is a valid value, means that we always return false if 11015 // the entire buffer is not flushed immediately on write() 11016 11017 var hwm = options.highWaterMark; 11018 var defaultHwm = this.objectMode ? 16 : 16 * 1024; 11019 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. 11020 11021 this.highWaterMark = ~~this.highWaterMark; 11022 this.needDrain = false; // at the start of calling end() 11023 11024 this.ending = false; // when end() has been called, and returned 11025 11026 this.ended = false; // when 'finish' is emitted 11027 11028 this.finished = false; // should we decode strings into buffers before passing to _write? 11029 // this is here so that some node-core streams can optimize string 11030 // handling at a lower level. 11031 11032 var noDecode = options.decodeStrings === false; 11033 this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string 11034 // encoding is 'binary' so we have to make this configurable. 11035 // Everything else in the universe uses 'utf8', though. 11036 11037 this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement 11038 // of how much we're waiting to get pushed to some underlying 11039 // socket or file. 11040 11041 this.length = 0; // a flag to see when we're in the middle of a write. 11042 11043 this.writing = false; // when true all writes will be buffered until .uncork() call 11044 11045 this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, 11046 // or on a later tick. We set this to true at first, because any 11047 // actions that shouldn't happen until "later" should generally also 11048 // not happen before the first write call. 11049 11050 this.sync = true; // a flag to know if we're processing previously buffered items, which 11051 // may call the _write() callback in the same tick, so that we don't 11052 // end up in an overlapped onwrite situation. 11053 11054 this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) 11055 11056 this.onwrite = function (er) { 11057 onwrite(stream, er); 11058 }; // the callback that the user supplies to write(chunk,encoding,cb) 11059 11060 11061 this.writecb = null; // the amount that is being written when _write is called. 11062 11063 this.writelen = 0; 11064 this.bufferedRequest = null; 11065 this.lastBufferedRequest = null; // number of pending user-supplied write callbacks 11066 // this must be 0 before 'finish' can be emitted 11067 11068 this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs 11069 // This is relevant for synchronous Transform streams 11070 11071 this.prefinished = false; // True if the error was already emitted and should not be thrown again 11072 11073 this.errorEmitted = false; // count buffered requests 11074 11075 this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always 11076 // one allocated and free to use, and we maintain at most two 11077 11078 this.corkedRequestsFree = new CorkedRequest(this); 11079 } 11080 11081 WritableState.prototype.getBuffer = function writableStateGetBuffer() { 11082 var current = this.bufferedRequest; 11083 var out = []; 11084 11085 while (current) { 11086 out.push(current); 11087 current = current.next; 11088 } 11089 11090 return out; 11091 }; 11092 function Writable(options) { 11093 // Writable ctor is applied to Duplexes, though they're not 11094 // instanceof Writable, they're instanceof Readable. 11095 if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); 11096 this._writableState = new WritableState(options, this); // legacy. 11097 11098 this.writable = true; 11099 11100 if (options) { 11101 if (typeof options.write === 'function') this._write = options.write; 11102 if (typeof options.writev === 'function') this._writev = options.writev; 11103 } 11104 11105 EventEmitter.call(this); 11106 } // Otherwise people can pipe Writable streams, which is just wrong. 11107 11108 Writable.prototype.pipe = function () { 11109 this.emit('error', new Error('Cannot pipe, not readable')); 11110 }; 11111 11112 function writeAfterEnd(stream, cb) { 11113 var er = new Error('write after end'); // TODO: defer error events consistently everywhere, not just the cb 11114 11115 stream.emit('error', er); 11116 nextTick$1(cb, er); 11117 } // If we get something that is not a buffer, string, null, or undefined, 11118 // and we're not in objectMode, then that's an error. 11119 // Otherwise stream chunks are all considered to be of length=1, and the 11120 // watermarks determine how many objects to keep in the buffer, rather than 11121 // how many bytes or characters. 11122 11123 11124 function validChunk(stream, state, chunk, cb) { 11125 var valid = true; 11126 var er = false; // Always throw error if a null is written 11127 // if we are not in object mode then throw 11128 // if it is not a buffer, string, or undefined. 11129 11130 if (chunk === null) { 11131 er = new TypeError('May not write null values to stream'); 11132 } else if (!Buffer$1.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { 11133 er = new TypeError('Invalid non-string/buffer chunk'); 11134 } 11135 11136 if (er) { 11137 stream.emit('error', er); 11138 nextTick$1(cb, er); 11139 valid = false; 11140 } 11141 11142 return valid; 11143 } 11144 11145 Writable.prototype.write = function (chunk, encoding, cb) { 11146 var state = this._writableState; 11147 var ret = false; 11148 11149 if (typeof encoding === 'function') { 11150 cb = encoding; 11151 encoding = null; 11152 } 11153 11154 if (Buffer$1.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; 11155 if (typeof cb !== 'function') cb = nop; 11156 if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { 11157 state.pendingcb++; 11158 ret = writeOrBuffer(this, state, chunk, encoding, cb); 11159 } 11160 return ret; 11161 }; 11162 11163 Writable.prototype.cork = function () { 11164 var state = this._writableState; 11165 state.corked++; 11166 }; 11167 11168 Writable.prototype.uncork = function () { 11169 var state = this._writableState; 11170 11171 if (state.corked) { 11172 state.corked--; 11173 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); 11174 } 11175 }; 11176 11177 Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { 11178 // node::ParseEncoding() requires lower case. 11179 if (typeof encoding === 'string') encoding = encoding.toLowerCase(); 11180 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); 11181 this._writableState.defaultEncoding = encoding; 11182 return this; 11183 }; 11184 11185 function decodeChunk(state, chunk, encoding) { 11186 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { 11187 chunk = Buffer$1.from(chunk, encoding); 11188 } 11189 11190 return chunk; 11191 } // if we're already writing something, then just put this 11192 // in the queue, and wait our turn. Otherwise, call _write 11193 // If we return false, then we need a drain event, so set that flag. 11194 11195 11196 function writeOrBuffer(stream, state, chunk, encoding, cb) { 11197 chunk = decodeChunk(state, chunk, encoding); 11198 if (Buffer$1.isBuffer(chunk)) encoding = 'buffer'; 11199 var len = state.objectMode ? 1 : chunk.length; 11200 state.length += len; 11201 var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. 11202 11203 if (!ret) state.needDrain = true; 11204 11205 if (state.writing || state.corked) { 11206 var last = state.lastBufferedRequest; 11207 state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); 11208 11209 if (last) { 11210 last.next = state.lastBufferedRequest; 11211 } else { 11212 state.bufferedRequest = state.lastBufferedRequest; 11213 } 11214 11215 state.bufferedRequestCount += 1; 11216 } else { 11217 doWrite(stream, state, false, len, chunk, encoding, cb); 11218 } 11219 11220 return ret; 11221 } 11222 11223 function doWrite(stream, state, writev, len, chunk, encoding, cb) { 11224 state.writelen = len; 11225 state.writecb = cb; 11226 state.writing = true; 11227 state.sync = true; 11228 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); 11229 state.sync = false; 11230 } 11231 11232 function onwriteError(stream, state, sync, er, cb) { 11233 --state.pendingcb; 11234 if (sync) nextTick$1(cb, er);else cb(er); 11235 stream._writableState.errorEmitted = true; 11236 stream.emit('error', er); 11237 } 11238 11239 function onwriteStateUpdate(state) { 11240 state.writing = false; 11241 state.writecb = null; 11242 state.length -= state.writelen; 11243 state.writelen = 0; 11244 } 11245 11246 function onwrite(stream, er) { 11247 var state = stream._writableState; 11248 var sync = state.sync; 11249 var cb = state.writecb; 11250 onwriteStateUpdate(state); 11251 if (er) onwriteError(stream, state, sync, er, cb);else { 11252 // Check if we're actually ready to finish, but don't emit yet 11253 var finished = needFinish(state); 11254 11255 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { 11256 clearBuffer(stream, state); 11257 } 11258 11259 if (sync) { 11260 /*<replacement>*/ 11261 nextTick$1(afterWrite, stream, state, finished, cb); 11262 /*</replacement>*/ 11263 } else { 11264 afterWrite(stream, state, finished, cb); 11265 } 11266 } 11267 } 11268 11269 function afterWrite(stream, state, finished, cb) { 11270 if (!finished) onwriteDrain(stream, state); 11271 state.pendingcb--; 11272 cb(); 11273 finishMaybe(stream, state); 11274 } // Must force callback to be called on nextTick, so that we don't 11275 // emit 'drain' before the write() consumer gets the 'false' return 11276 // value, and has a chance to attach a 'drain' listener. 11277 11278 11279 function onwriteDrain(stream, state) { 11280 if (state.length === 0 && state.needDrain) { 11281 state.needDrain = false; 11282 stream.emit('drain'); 11283 } 11284 } // if there's something in the buffer waiting, then process it 11285 11286 11287 function clearBuffer(stream, state) { 11288 state.bufferProcessing = true; 11289 var entry = state.bufferedRequest; 11290 11291 if (stream._writev && entry && entry.next) { 11292 // Fast case, write everything using _writev() 11293 var l = state.bufferedRequestCount; 11294 var buffer = new Array(l); 11295 var holder = state.corkedRequestsFree; 11296 holder.entry = entry; 11297 var count = 0; 11298 11299 while (entry) { 11300 buffer[count] = entry; 11301 entry = entry.next; 11302 count += 1; 11303 } 11304 11305 doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time 11306 // as the hot path ends with doWrite 11307 11308 state.pendingcb++; 11309 state.lastBufferedRequest = null; 11310 11311 if (holder.next) { 11312 state.corkedRequestsFree = holder.next; 11313 holder.next = null; 11314 } else { 11315 state.corkedRequestsFree = new CorkedRequest(state); 11316 } 11317 } else { 11318 // Slow case, write chunks one-by-one 11319 while (entry) { 11320 var chunk = entry.chunk; 11321 var encoding = entry.encoding; 11322 var cb = entry.callback; 11323 var len = state.objectMode ? 1 : chunk.length; 11324 doWrite(stream, state, false, len, chunk, encoding, cb); 11325 entry = entry.next; // if we didn't call the onwrite immediately, then 11326 // it means that we need to wait until it does. 11327 // also, that means that the chunk and cb are currently 11328 // being processed, so move the buffer counter past them. 11329 11330 if (state.writing) { 11331 break; 11332 } 11333 } 11334 11335 if (entry === null) state.lastBufferedRequest = null; 11336 } 11337 11338 state.bufferedRequestCount = 0; 11339 state.bufferedRequest = entry; 11340 state.bufferProcessing = false; 11341 } 11342 11343 Writable.prototype._write = function (chunk, encoding, cb) { 11344 cb(new Error('not implemented')); 11345 }; 11346 11347 Writable.prototype._writev = null; 11348 11349 Writable.prototype.end = function (chunk, encoding, cb) { 11350 var state = this._writableState; 11351 11352 if (typeof chunk === 'function') { 11353 cb = chunk; 11354 chunk = null; 11355 encoding = null; 11356 } else if (typeof encoding === 'function') { 11357 cb = encoding; 11358 encoding = null; 11359 } 11360 11361 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks 11362 11363 if (state.corked) { 11364 state.corked = 1; 11365 this.uncork(); 11366 } // ignore unnecessary end() calls. 11367 11368 11369 if (!state.ending && !state.finished) endWritable(this, state, cb); 11370 }; 11371 11372 function needFinish(state) { 11373 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; 11374 } 11375 11376 function prefinish(stream, state) { 11377 if (!state.prefinished) { 11378 state.prefinished = true; 11379 stream.emit('prefinish'); 11380 } 11381 } 11382 11383 function finishMaybe(stream, state) { 11384 var need = needFinish(state); 11385 11386 if (need) { 11387 if (state.pendingcb === 0) { 11388 prefinish(stream, state); 11389 state.finished = true; 11390 stream.emit('finish'); 11391 } else { 11392 prefinish(stream, state); 11393 } 11394 } 11395 11396 return need; 11397 } 11398 11399 function endWritable(stream, state, cb) { 11400 state.ending = true; 11401 finishMaybe(stream, state); 11402 11403 if (cb) { 11404 if (state.finished) nextTick$1(cb);else stream.once('finish', cb); 11405 } 11406 11407 state.ended = true; 11408 stream.writable = false; 11409 } // It seems a linked list but it is not 11410 // there will be only 2 of these for each stream 11411 11412 11413 function CorkedRequest(state) { 11414 var _this = this; 11415 11416 this.next = null; 11417 this.entry = null; 11418 11419 this.finish = function (err) { 11420 var entry = _this.entry; 11421 _this.entry = null; 11422 11423 while (entry) { 11424 var cb = entry.callback; 11425 state.pendingcb--; 11426 cb(err); 11427 entry = entry.next; 11428 } 11429 11430 if (state.corkedRequestsFree) { 11431 state.corkedRequestsFree.next = _this; 11432 } else { 11433 state.corkedRequestsFree = _this; 11434 } 11435 }; 11436 } 11437 11438 inherits$1(Duplex, Readable); 11439 var keys$4 = Object.keys(Writable.prototype); 11440 11441 for (var v = 0; v < keys$4.length; v++) { 11442 var method = keys$4[v]; 11443 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; 11444 } 11445 function Duplex(options) { 11446 if (!(this instanceof Duplex)) return new Duplex(options); 11447 Readable.call(this, options); 11448 Writable.call(this, options); 11449 if (options && options.readable === false) this.readable = false; 11450 if (options && options.writable === false) this.writable = false; 11451 this.allowHalfOpen = true; 11452 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; 11453 this.once('end', onend); 11454 } // the no-half-open enforcer 11455 11456 function onend() { 11457 // if we allow half-open state, or if the writable side ended, 11458 // then we're ok. 11459 if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written. 11460 // But allow more writes to happen in this tick. 11461 11462 nextTick$1(onEndNT, this); 11463 } 11464 11465 function onEndNT(self) { 11466 self.end(); 11467 } 11468 11469 // a transform stream is a readable/writable stream where you do 11470 inherits$1(Transform, Duplex); 11471 11472 function TransformState(stream) { 11473 this.afterTransform = function (er, data) { 11474 return afterTransform(stream, er, data); 11475 }; 11476 11477 this.needTransform = false; 11478 this.transforming = false; 11479 this.writecb = null; 11480 this.writechunk = null; 11481 this.writeencoding = null; 11482 } 11483 11484 function afterTransform(stream, er, data) { 11485 var ts = stream._transformState; 11486 ts.transforming = false; 11487 var cb = ts.writecb; 11488 if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); 11489 ts.writechunk = null; 11490 ts.writecb = null; 11491 if (data !== null && data !== undefined) stream.push(data); 11492 cb(er); 11493 var rs = stream._readableState; 11494 rs.reading = false; 11495 11496 if (rs.needReadable || rs.length < rs.highWaterMark) { 11497 stream._read(rs.highWaterMark); 11498 } 11499 } 11500 function Transform(options) { 11501 if (!(this instanceof Transform)) return new Transform(options); 11502 Duplex.call(this, options); 11503 this._transformState = new TransformState(this); // when the writable side finishes, then flush out anything remaining. 11504 11505 var stream = this; // start out asking for a readable event once data is transformed. 11506 11507 this._readableState.needReadable = true; // we have implemented the _read method, and done the other things 11508 // that Readable wants before the first _read call, so unset the 11509 // sync guard flag. 11510 11511 this._readableState.sync = false; 11512 11513 if (options) { 11514 if (typeof options.transform === 'function') this._transform = options.transform; 11515 if (typeof options.flush === 'function') this._flush = options.flush; 11516 } 11517 11518 this.once('prefinish', function () { 11519 if (typeof this._flush === 'function') this._flush(function (er) { 11520 done(stream, er); 11521 });else done(stream); 11522 }); 11523 } 11524 11525 Transform.prototype.push = function (chunk, encoding) { 11526 this._transformState.needTransform = false; 11527 return Duplex.prototype.push.call(this, chunk, encoding); 11528 }; // This is the part where you do stuff! 11529 // override this function in implementation classes. 11530 // 'chunk' is an input chunk. 11531 // 11532 // Call `push(newChunk)` to pass along transformed output 11533 // to the readable side. You may call 'push' zero or more times. 11534 // 11535 // Call `cb(err)` when you are done with this chunk. If you pass 11536 // an error, then that'll put the hurt on the whole operation. If you 11537 // never call cb(), then you'll never get another chunk. 11538 11539 11540 Transform.prototype._transform = function (chunk, encoding, cb) { 11541 throw new Error('Not implemented'); 11542 }; 11543 11544 Transform.prototype._write = function (chunk, encoding, cb) { 11545 var ts = this._transformState; 11546 ts.writecb = cb; 11547 ts.writechunk = chunk; 11548 ts.writeencoding = encoding; 11549 11550 if (!ts.transforming) { 11551 var rs = this._readableState; 11552 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); 11553 } 11554 }; // Doesn't matter what the args are here. 11555 // _transform does all the work. 11556 // That we got here means that the readable side wants more data. 11557 11558 11559 Transform.prototype._read = function (n) { 11560 var ts = this._transformState; 11561 11562 if (ts.writechunk !== null && ts.writecb && !ts.transforming) { 11563 ts.transforming = true; 11564 11565 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); 11566 } else { 11567 // mark that we need a transform, so that any data that comes in 11568 // will get processed, now that we've asked for it. 11569 ts.needTransform = true; 11570 } 11571 }; 11572 11573 function done(stream, er) { 11574 if (er) return stream.emit('error', er); // if there's nothing in the write buffer, then that means 11575 // that nothing more will ever be provided 11576 11577 var ws = stream._writableState; 11578 var ts = stream._transformState; 11579 if (ws.length) throw new Error('Calling transform done when ws.length != 0'); 11580 if (ts.transforming) throw new Error('Calling transform done when still transforming'); 11581 return stream.push(null); 11582 } 11583 11584 inherits$1(PassThrough, Transform); 11585 function PassThrough(options) { 11586 if (!(this instanceof PassThrough)) return new PassThrough(options); 11587 Transform.call(this, options); 11588 } 11589 11590 PassThrough.prototype._transform = function (chunk, encoding, cb) { 11591 cb(null, chunk); 11592 }; 11593 11594 inherits$1(Stream, EventEmitter); 11595 Stream.Readable = Readable; 11596 Stream.Writable = Writable; 11597 Stream.Duplex = Duplex; 11598 Stream.Transform = Transform; 11599 Stream.PassThrough = PassThrough; // Backwards-compat with node 0.4.x 11600 11601 Stream.Stream = Stream; 11602 // part of this class) is overridden in the Readable class. 11603 11604 function Stream() { 11605 EventEmitter.call(this); 11606 } 11607 11608 Stream.prototype.pipe = function (dest, options) { 11609 var source = this; 11610 11611 function ondata(chunk) { 11612 if (dest.writable) { 11613 if (false === dest.write(chunk) && source.pause) { 11614 source.pause(); 11615 } 11616 } 11617 } 11618 11619 source.on('data', ondata); 11620 11621 function ondrain() { 11622 if (source.readable && source.resume) { 11623 source.resume(); 11624 } 11625 } 11626 11627 dest.on('drain', ondrain); // If the 'end' option is not supplied, dest.end() will be called when 11628 // source gets the 'end' or 'close' events. Only dest.end() once. 11629 11630 if (!dest._isStdio && (!options || options.end !== false)) { 11631 source.on('end', onend); 11632 source.on('close', onclose); 11633 } 11634 11635 var didOnEnd = false; 11636 11637 function onend() { 11638 if (didOnEnd) return; 11639 didOnEnd = true; 11640 dest.end(); 11641 } 11642 11643 function onclose() { 11644 if (didOnEnd) return; 11645 didOnEnd = true; 11646 if (typeof dest.destroy === 'function') dest.destroy(); 11647 } // don't leave dangling pipes when there are errors. 11648 11649 11650 function onerror(er) { 11651 cleanup(); 11652 11653 if (EventEmitter.listenerCount(this, 'error') === 0) { 11654 throw er; // Unhandled stream error in pipe. 11655 } 11656 } 11657 11658 source.on('error', onerror); 11659 dest.on('error', onerror); // remove all the event listeners that were added. 11660 11661 function cleanup() { 11662 source.removeListener('data', ondata); 11663 dest.removeListener('drain', ondrain); 11664 source.removeListener('end', onend); 11665 source.removeListener('close', onclose); 11666 source.removeListener('error', onerror); 11667 dest.removeListener('error', onerror); 11668 source.removeListener('end', cleanup); 11669 source.removeListener('close', cleanup); 11670 dest.removeListener('close', cleanup); 11671 } 11672 11673 source.on('end', cleanup); 11674 source.on('close', cleanup); 11675 dest.on('close', cleanup); 11676 dest.emit('pipe', source); // Allow for unix-like usage: A.pipe(B).pipe(C) 11677 11678 return dest; 11679 }; 11680 11681 var WritableStream = Stream.Writable; 11682 var inherits$2 = util.inherits; 11683 var browserStdout = BrowserStdout; 11684 inherits$2(BrowserStdout, WritableStream); 11685 11686 function BrowserStdout(opts) { 11687 if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts); 11688 opts = opts || {}; 11689 WritableStream.call(this, opts); 11690 this.label = opts.label !== undefined ? opts.label : 'stdout'; 11691 } 11692 11693 BrowserStdout.prototype._write = function (chunks, encoding, cb) { 11694 var output = chunks.toString ? chunks.toString() : chunks; 11695 11696 if (this.label === false) { 11697 console.log(output); 11698 } else { 11699 console.log(this.label + ':', output); 11700 } 11701 11702 nextTick(cb); 11703 }; 11704 11705 var parseQuery = function parseQuery(qs) { 11706 return qs.replace('?', '').split('&').reduce(function (obj, pair) { 11707 var i = pair.indexOf('='); 11708 var key = pair.slice(0, i); 11709 var val = pair.slice(++i); // Due to how the URLSearchParams API treats spaces 11710 11711 obj[key] = decodeURIComponent(val.replace(/\+/g, '%20')); 11712 return obj; 11713 }, {}); 11714 }; 11715 11716 function highlight(js) { 11717 return js.replace(/</g, '<').replace(/>/g, '>').replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>').replace(/('.*?')/gm, '<span class="string">$1</span>').replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>').replace(/(\d+)/gm, '<span class="number">$1</span>').replace(/\bnew[ \t]+(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>').replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>'); 11718 } 11719 /** 11720 * Highlight the contents of tag `name`. 11721 * 11722 * @private 11723 * @param {string} name 11724 */ 11725 11726 11727 var highlightTags = function highlightTags(name) { 11728 var code = document.getElementById('mocha').getElementsByTagName(name); 11729 11730 for (var i = 0, len = code.length; i < len; ++i) { 11731 code[i].innerHTML = highlight(code[i].innerHTML); 11732 } 11733 }; 11734 11735 var nativePromiseConstructor = global_1.Promise; 11736 11737 var iteratorClose = function (iterator) { 11738 var returnMethod = iterator['return']; 11739 if (returnMethod !== undefined) { 11740 return anObject(returnMethod.call(iterator)).value; 11741 } 11742 }; 11743 11744 var Result = function (stopped, result) { 11745 this.stopped = stopped; 11746 this.result = result; 11747 }; 11748 11749 var iterate = function (iterable, unboundFunction, options) { 11750 var that = options && options.that; 11751 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 11752 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 11753 var INTERRUPTED = !!(options && options.INTERRUPTED); 11754 var fn = functionBindContext(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED); 11755 var iterator, iterFn, index, length, result, next, step; 11756 11757 var stop = function (condition) { 11758 if (iterator) iteratorClose(iterator); 11759 return new Result(true, condition); 11760 }; 11761 11762 var callFn = function (value) { 11763 if (AS_ENTRIES) { 11764 anObject(value); 11765 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 11766 } return INTERRUPTED ? fn(value, stop) : fn(value); 11767 }; 11768 11769 if (IS_ITERATOR) { 11770 iterator = iterable; 11771 } else { 11772 iterFn = getIteratorMethod(iterable); 11773 if (typeof iterFn != 'function') throw TypeError('Target is not iterable'); 11774 // optimisation for array iterators 11775 if (isArrayIteratorMethod(iterFn)) { 11776 for (index = 0, length = toLength(iterable.length); length > index; index++) { 11777 result = callFn(iterable[index]); 11778 if (result && result instanceof Result) return result; 11779 } return new Result(false); 11780 } 11781 iterator = iterFn.call(iterable); 11782 } 11783 11784 next = iterator.next; 11785 while (!(step = next.call(iterator)).done) { 11786 try { 11787 result = callFn(step.value); 11788 } catch (error) { 11789 iteratorClose(iterator); 11790 throw error; 11791 } 11792 if (typeof result == 'object' && result && result instanceof Result) return result; 11793 } return new Result(false); 11794 }; 11795 11796 var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(engineUserAgent); 11797 11798 var engineIsNode = classofRaw(global_1.process) == 'process'; 11799 11800 var location$1 = global_1.location; 11801 var set$2 = global_1.setImmediate; 11802 var clear = global_1.clearImmediate; 11803 var process$2 = global_1.process; 11804 var MessageChannel = global_1.MessageChannel; 11805 var Dispatch = global_1.Dispatch; 11806 var counter = 0; 11807 var queue$2 = {}; 11808 var ONREADYSTATECHANGE = 'onreadystatechange'; 11809 var defer, channel, port; 11810 11811 var run = function (id) { 11812 // eslint-disable-next-line no-prototype-builtins 11813 if (queue$2.hasOwnProperty(id)) { 11814 var fn = queue$2[id]; 11815 delete queue$2[id]; 11816 fn(); 11817 } 11818 }; 11819 11820 var runner = function (id) { 11821 return function () { 11822 run(id); 11823 }; 11824 }; 11825 11826 var listener = function (event) { 11827 run(event.data); 11828 }; 11829 11830 var post = function (id) { 11831 // old engines have not location.origin 11832 global_1.postMessage(id + '', location$1.protocol + '//' + location$1.host); 11833 }; 11834 11835 // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 11836 if (!set$2 || !clear) { 11837 set$2 = function setImmediate(fn) { 11838 var args = []; 11839 var i = 1; 11840 while (arguments.length > i) args.push(arguments[i++]); 11841 queue$2[++counter] = function () { 11842 // eslint-disable-next-line no-new-func 11843 (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args); 11844 }; 11845 defer(counter); 11846 return counter; 11847 }; 11848 clear = function clearImmediate(id) { 11849 delete queue$2[id]; 11850 }; 11851 // Node.js 0.8- 11852 if (engineIsNode) { 11853 defer = function (id) { 11854 process$2.nextTick(runner(id)); 11855 }; 11856 // Sphere (JS game engine) Dispatch API 11857 } else if (Dispatch && Dispatch.now) { 11858 defer = function (id) { 11859 Dispatch.now(runner(id)); 11860 }; 11861 // Browsers with MessageChannel, includes WebWorkers 11862 // except iOS - https://github.com/zloirock/core-js/issues/624 11863 } else if (MessageChannel && !engineIsIos) { 11864 channel = new MessageChannel(); 11865 port = channel.port2; 11866 channel.port1.onmessage = listener; 11867 defer = functionBindContext(port.postMessage, port, 1); 11868 // Browsers with postMessage, skip WebWorkers 11869 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 11870 } else if ( 11871 global_1.addEventListener && 11872 typeof postMessage == 'function' && 11873 !global_1.importScripts && 11874 location$1 && location$1.protocol !== 'file:' && 11875 !fails(post) 11876 ) { 11877 defer = post; 11878 global_1.addEventListener('message', listener, false); 11879 // IE8- 11880 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 11881 defer = function (id) { 11882 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 11883 html.removeChild(this); 11884 run(id); 11885 }; 11886 }; 11887 // Rest old browsers 11888 } else { 11889 defer = function (id) { 11890 setTimeout(runner(id), 0); 11891 }; 11892 } 11893 } 11894 11895 var task = { 11896 set: set$2, 11897 clear: clear 11898 }; 11899 11900 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 11901 11902 var getOwnPropertyDescriptor$3 = objectGetOwnPropertyDescriptor.f; 11903 var macrotask = task.set; 11904 11905 11906 11907 11908 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 11909 var document$2 = global_1.document; 11910 var process$3 = global_1.process; 11911 var Promise$1 = global_1.Promise; 11912 // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 11913 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$3(global_1, 'queueMicrotask'); 11914 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 11915 11916 var flush, head, last, notify, toggle, node, promise, then; 11917 11918 // modern engines have queueMicrotask method 11919 if (!queueMicrotask) { 11920 flush = function () { 11921 var parent, fn; 11922 if (engineIsNode && (parent = process$3.domain)) parent.exit(); 11923 while (head) { 11924 fn = head.fn; 11925 head = head.next; 11926 try { 11927 fn(); 11928 } catch (error) { 11929 if (head) notify(); 11930 else last = undefined; 11931 throw error; 11932 } 11933 } last = undefined; 11934 if (parent) parent.enter(); 11935 }; 11936 11937 // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 11938 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 11939 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 11940 toggle = true; 11941 node = document$2.createTextNode(''); 11942 new MutationObserver(flush).observe(node, { characterData: true }); 11943 notify = function () { 11944 node.data = toggle = !toggle; 11945 }; 11946 // environments with maybe non-completely correct, but existent Promise 11947 } else if (Promise$1 && Promise$1.resolve) { 11948 // Promise.resolve without an argument throws an error in LG WebOS 2 11949 promise = Promise$1.resolve(undefined); 11950 then = promise.then; 11951 notify = function () { 11952 then.call(promise, flush); 11953 }; 11954 // Node.js without promises 11955 } else if (engineIsNode) { 11956 notify = function () { 11957 process$3.nextTick(flush); 11958 }; 11959 // for other environments - macrotask based on: 11960 // - setImmediate 11961 // - MessageChannel 11962 // - window.postMessag 11963 // - onreadystatechange 11964 // - setTimeout 11965 } else { 11966 notify = function () { 11967 // strange IE + webpack dev server bug - use .call(global) 11968 macrotask.call(global_1, flush); 11969 }; 11970 } 11971 } 11972 11973 var microtask = queueMicrotask || function (fn) { 11974 var task = { fn: fn, next: undefined }; 11975 if (last) last.next = task; 11976 if (!head) { 11977 head = task; 11978 notify(); 11979 } last = task; 11980 }; 11981 11982 var PromiseCapability = function (C) { 11983 var resolve, reject; 11984 this.promise = new C(function ($$resolve, $$reject) { 11985 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 11986 resolve = $$resolve; 11987 reject = $$reject; 11988 }); 11989 this.resolve = aFunction$1(resolve); 11990 this.reject = aFunction$1(reject); 11991 }; 11992 11993 // 25.4.1.5 NewPromiseCapability(C) 11994 var f$7 = function (C) { 11995 return new PromiseCapability(C); 11996 }; 11997 11998 var newPromiseCapability = { 11999 f: f$7 12000 }; 12001 12002 var promiseResolve = function (C, x) { 12003 anObject(C); 12004 if (isObject(x) && x.constructor === C) return x; 12005 var promiseCapability = newPromiseCapability.f(C); 12006 var resolve = promiseCapability.resolve; 12007 resolve(x); 12008 return promiseCapability.promise; 12009 }; 12010 12011 var hostReportErrors = function (a, b) { 12012 var console = global_1.console; 12013 if (console && console.error) { 12014 arguments.length === 1 ? console.error(a) : console.error(a, b); 12015 } 12016 }; 12017 12018 var perform = function (exec) { 12019 try { 12020 return { error: false, value: exec() }; 12021 } catch (error) { 12022 return { error: true, value: error }; 12023 } 12024 }; 12025 12026 var task$1 = task.set; 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 var SPECIES$6 = wellKnownSymbol('species'); 12039 var PROMISE = 'Promise'; 12040 var getInternalState$3 = internalState.get; 12041 var setInternalState$4 = internalState.set; 12042 var getInternalPromiseState = internalState.getterFor(PROMISE); 12043 var PromiseConstructor = nativePromiseConstructor; 12044 var TypeError$1 = global_1.TypeError; 12045 var document$3 = global_1.document; 12046 var process$4 = global_1.process; 12047 var $fetch = getBuiltIn('fetch'); 12048 var newPromiseCapability$1 = newPromiseCapability.f; 12049 var newGenericPromiseCapability = newPromiseCapability$1; 12050 var DISPATCH_EVENT = !!(document$3 && document$3.createEvent && global_1.dispatchEvent); 12051 var NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function'; 12052 var UNHANDLED_REJECTION = 'unhandledrejection'; 12053 var REJECTION_HANDLED = 'rejectionhandled'; 12054 var PENDING = 0; 12055 var FULFILLED = 1; 12056 var REJECTED = 2; 12057 var HANDLED = 1; 12058 var UNHANDLED = 2; 12059 var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen; 12060 12061 var FORCED$7 = isForced_1(PROMISE, function () { 12062 var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor); 12063 if (!GLOBAL_CORE_JS_PROMISE) { 12064 // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables 12065 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 12066 // We can't detect it synchronously, so just check versions 12067 if (engineV8Version === 66) return true; 12068 // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test 12069 if (!engineIsNode && !NATIVE_REJECTION_EVENT) return true; 12070 } 12071 // We can't use @@species feature detection in V8 since it causes 12072 // deoptimization and performance degradation 12073 // https://github.com/zloirock/core-js/issues/679 12074 if (engineV8Version >= 51 && /native code/.test(PromiseConstructor)) return false; 12075 // Detect correctness of subclassing with @@species support 12076 var promise = PromiseConstructor.resolve(1); 12077 var FakePromise = function (exec) { 12078 exec(function () { /* empty */ }, function () { /* empty */ }); 12079 }; 12080 var constructor = promise.constructor = {}; 12081 constructor[SPECIES$6] = FakePromise; 12082 return !(promise.then(function () { /* empty */ }) instanceof FakePromise); 12083 }); 12084 12085 var INCORRECT_ITERATION = FORCED$7 || !checkCorrectnessOfIteration(function (iterable) { 12086 PromiseConstructor.all(iterable)['catch'](function () { /* empty */ }); 12087 }); 12088 12089 // helpers 12090 var isThenable = function (it) { 12091 var then; 12092 return isObject(it) && typeof (then = it.then) == 'function' ? then : false; 12093 }; 12094 12095 var notify$1 = function (state, isReject) { 12096 if (state.notified) return; 12097 state.notified = true; 12098 var chain = state.reactions; 12099 microtask(function () { 12100 var value = state.value; 12101 var ok = state.state == FULFILLED; 12102 var index = 0; 12103 // variable length - can't use forEach 12104 while (chain.length > index) { 12105 var reaction = chain[index++]; 12106 var handler = ok ? reaction.ok : reaction.fail; 12107 var resolve = reaction.resolve; 12108 var reject = reaction.reject; 12109 var domain = reaction.domain; 12110 var result, then, exited; 12111 try { 12112 if (handler) { 12113 if (!ok) { 12114 if (state.rejection === UNHANDLED) onHandleUnhandled(state); 12115 state.rejection = HANDLED; 12116 } 12117 if (handler === true) result = value; 12118 else { 12119 if (domain) domain.enter(); 12120 result = handler(value); // can throw 12121 if (domain) { 12122 domain.exit(); 12123 exited = true; 12124 } 12125 } 12126 if (result === reaction.promise) { 12127 reject(TypeError$1('Promise-chain cycle')); 12128 } else if (then = isThenable(result)) { 12129 then.call(result, resolve, reject); 12130 } else resolve(result); 12131 } else reject(value); 12132 } catch (error) { 12133 if (domain && !exited) domain.exit(); 12134 reject(error); 12135 } 12136 } 12137 state.reactions = []; 12138 state.notified = false; 12139 if (isReject && !state.rejection) onUnhandled(state); 12140 }); 12141 }; 12142 12143 var dispatchEvent = function (name, promise, reason) { 12144 var event, handler; 12145 if (DISPATCH_EVENT) { 12146 event = document$3.createEvent('Event'); 12147 event.promise = promise; 12148 event.reason = reason; 12149 event.initEvent(name, false, true); 12150 global_1.dispatchEvent(event); 12151 } else event = { promise: promise, reason: reason }; 12152 if (!NATIVE_REJECTION_EVENT && (handler = global_1['on' + name])) handler(event); 12153 else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason); 12154 }; 12155 12156 var onUnhandled = function (state) { 12157 task$1.call(global_1, function () { 12158 var promise = state.facade; 12159 var value = state.value; 12160 var IS_UNHANDLED = isUnhandled(state); 12161 var result; 12162 if (IS_UNHANDLED) { 12163 result = perform(function () { 12164 if (engineIsNode) { 12165 process$4.emit('unhandledRejection', value, promise); 12166 } else dispatchEvent(UNHANDLED_REJECTION, promise, value); 12167 }); 12168 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should 12169 state.rejection = engineIsNode || isUnhandled(state) ? UNHANDLED : HANDLED; 12170 if (result.error) throw result.value; 12171 } 12172 }); 12173 }; 12174 12175 var isUnhandled = function (state) { 12176 return state.rejection !== HANDLED && !state.parent; 12177 }; 12178 12179 var onHandleUnhandled = function (state) { 12180 task$1.call(global_1, function () { 12181 var promise = state.facade; 12182 if (engineIsNode) { 12183 process$4.emit('rejectionHandled', promise); 12184 } else dispatchEvent(REJECTION_HANDLED, promise, state.value); 12185 }); 12186 }; 12187 12188 var bind = function (fn, state, unwrap) { 12189 return function (value) { 12190 fn(state, value, unwrap); 12191 }; 12192 }; 12193 12194 var internalReject = function (state, value, unwrap) { 12195 if (state.done) return; 12196 state.done = true; 12197 if (unwrap) state = unwrap; 12198 state.value = value; 12199 state.state = REJECTED; 12200 notify$1(state, true); 12201 }; 12202 12203 var internalResolve = function (state, value, unwrap) { 12204 if (state.done) return; 12205 state.done = true; 12206 if (unwrap) state = unwrap; 12207 try { 12208 if (state.facade === value) throw TypeError$1("Promise can't be resolved itself"); 12209 var then = isThenable(value); 12210 if (then) { 12211 microtask(function () { 12212 var wrapper = { done: false }; 12213 try { 12214 then.call(value, 12215 bind(internalResolve, wrapper, state), 12216 bind(internalReject, wrapper, state) 12217 ); 12218 } catch (error) { 12219 internalReject(wrapper, error, state); 12220 } 12221 }); 12222 } else { 12223 state.value = value; 12224 state.state = FULFILLED; 12225 notify$1(state, false); 12226 } 12227 } catch (error) { 12228 internalReject({ done: false }, error, state); 12229 } 12230 }; 12231 12232 // constructor polyfill 12233 if (FORCED$7) { 12234 // 25.4.3.1 Promise(executor) 12235 PromiseConstructor = function Promise(executor) { 12236 anInstance(this, PromiseConstructor, PROMISE); 12237 aFunction$1(executor); 12238 Internal.call(this); 12239 var state = getInternalState$3(this); 12240 try { 12241 executor(bind(internalResolve, state), bind(internalReject, state)); 12242 } catch (error) { 12243 internalReject(state, error); 12244 } 12245 }; 12246 // eslint-disable-next-line no-unused-vars 12247 Internal = function Promise(executor) { 12248 setInternalState$4(this, { 12249 type: PROMISE, 12250 done: false, 12251 notified: false, 12252 parent: false, 12253 reactions: [], 12254 rejection: false, 12255 state: PENDING, 12256 value: undefined 12257 }); 12258 }; 12259 Internal.prototype = redefineAll(PromiseConstructor.prototype, { 12260 // `Promise.prototype.then` method 12261 // https://tc39.es/ecma262/#sec-promise.prototype.then 12262 then: function then(onFulfilled, onRejected) { 12263 var state = getInternalPromiseState(this); 12264 var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor)); 12265 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; 12266 reaction.fail = typeof onRejected == 'function' && onRejected; 12267 reaction.domain = engineIsNode ? process$4.domain : undefined; 12268 state.parent = true; 12269 state.reactions.push(reaction); 12270 if (state.state != PENDING) notify$1(state, false); 12271 return reaction.promise; 12272 }, 12273 // `Promise.prototype.catch` method 12274 // https://tc39.es/ecma262/#sec-promise.prototype.catch 12275 'catch': function (onRejected) { 12276 return this.then(undefined, onRejected); 12277 } 12278 }); 12279 OwnPromiseCapability = function () { 12280 var promise = new Internal(); 12281 var state = getInternalState$3(promise); 12282 this.promise = promise; 12283 this.resolve = bind(internalResolve, state); 12284 this.reject = bind(internalReject, state); 12285 }; 12286 newPromiseCapability.f = newPromiseCapability$1 = function (C) { 12287 return C === PromiseConstructor || C === PromiseWrapper 12288 ? new OwnPromiseCapability(C) 12289 : newGenericPromiseCapability(C); 12290 }; 12291 12292 if ( typeof nativePromiseConstructor == 'function') { 12293 nativeThen = nativePromiseConstructor.prototype.then; 12294 12295 // wrap native Promise#then for native async functions 12296 redefine(nativePromiseConstructor.prototype, 'then', function then(onFulfilled, onRejected) { 12297 var that = this; 12298 return new PromiseConstructor(function (resolve, reject) { 12299 nativeThen.call(that, resolve, reject); 12300 }).then(onFulfilled, onRejected); 12301 // https://github.com/zloirock/core-js/issues/640 12302 }, { unsafe: true }); 12303 12304 // wrap fetch result 12305 if (typeof $fetch == 'function') _export({ global: true, enumerable: true, forced: true }, { 12306 // eslint-disable-next-line no-unused-vars 12307 fetch: function fetch(input /* , init */) { 12308 return promiseResolve(PromiseConstructor, $fetch.apply(global_1, arguments)); 12309 } 12310 }); 12311 } 12312 } 12313 12314 _export({ global: true, wrap: true, forced: FORCED$7 }, { 12315 Promise: PromiseConstructor 12316 }); 12317 12318 setToStringTag(PromiseConstructor, PROMISE, false); 12319 setSpecies(PROMISE); 12320 12321 PromiseWrapper = getBuiltIn(PROMISE); 12322 12323 // statics 12324 _export({ target: PROMISE, stat: true, forced: FORCED$7 }, { 12325 // `Promise.reject` method 12326 // https://tc39.es/ecma262/#sec-promise.reject 12327 reject: function reject(r) { 12328 var capability = newPromiseCapability$1(this); 12329 capability.reject.call(undefined, r); 12330 return capability.promise; 12331 } 12332 }); 12333 12334 _export({ target: PROMISE, stat: true, forced: FORCED$7 }, { 12335 // `Promise.resolve` method 12336 // https://tc39.es/ecma262/#sec-promise.resolve 12337 resolve: function resolve(x) { 12338 return promiseResolve( this, x); 12339 } 12340 }); 12341 12342 _export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, { 12343 // `Promise.all` method 12344 // https://tc39.es/ecma262/#sec-promise.all 12345 all: function all(iterable) { 12346 var C = this; 12347 var capability = newPromiseCapability$1(C); 12348 var resolve = capability.resolve; 12349 var reject = capability.reject; 12350 var result = perform(function () { 12351 var $promiseResolve = aFunction$1(C.resolve); 12352 var values = []; 12353 var counter = 0; 12354 var remaining = 1; 12355 iterate(iterable, function (promise) { 12356 var index = counter++; 12357 var alreadyCalled = false; 12358 values.push(undefined); 12359 remaining++; 12360 $promiseResolve.call(C, promise).then(function (value) { 12361 if (alreadyCalled) return; 12362 alreadyCalled = true; 12363 values[index] = value; 12364 --remaining || resolve(values); 12365 }, reject); 12366 }); 12367 --remaining || resolve(values); 12368 }); 12369 if (result.error) reject(result.value); 12370 return capability.promise; 12371 }, 12372 // `Promise.race` method 12373 // https://tc39.es/ecma262/#sec-promise.race 12374 race: function race(iterable) { 12375 var C = this; 12376 var capability = newPromiseCapability$1(C); 12377 var reject = capability.reject; 12378 var result = perform(function () { 12379 var $promiseResolve = aFunction$1(C.resolve); 12380 iterate(iterable, function (promise) { 12381 $promiseResolve.call(C, promise).then(capability.resolve, reject); 12382 }); 12383 }); 12384 if (result.error) reject(result.value); 12385 return capability.promise; 12386 } 12387 }); 12388 12389 // `Symbol.asyncIterator` well-known symbol 12390 // https://tc39.es/ecma262/#sec-symbol.asynciterator 12391 defineWellKnownSymbol('asyncIterator'); 12392 12393 // `Symbol.iterator` well-known symbol 12394 // https://tc39.es/ecma262/#sec-symbol.iterator 12395 defineWellKnownSymbol('iterator'); 12396 12397 // `Symbol.toStringTag` well-known symbol 12398 // https://tc39.es/ecma262/#sec-symbol.tostringtag 12399 defineWellKnownSymbol('toStringTag'); 12400 12401 // JSON[@@toStringTag] property 12402 // https://tc39.es/ecma262/#sec-json-@@tostringtag 12403 setToStringTag(global_1.JSON, 'JSON', true); 12404 12405 // Math[@@toStringTag] property 12406 // https://tc39.es/ecma262/#sec-math-@@tostringtag 12407 setToStringTag(Math, 'Math', true); 12408 12409 var charAt$1 = stringMultibyte.charAt; 12410 12411 12412 12413 var STRING_ITERATOR = 'String Iterator'; 12414 var setInternalState$5 = internalState.set; 12415 var getInternalState$4 = internalState.getterFor(STRING_ITERATOR); 12416 12417 // `String.prototype[@@iterator]` method 12418 // https://tc39.es/ecma262/#sec-string.prototype-@@iterator 12419 defineIterator(String, 'String', function (iterated) { 12420 setInternalState$5(this, { 12421 type: STRING_ITERATOR, 12422 string: String(iterated), 12423 index: 0 12424 }); 12425 // `%StringIteratorPrototype%.next` method 12426 // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next 12427 }, function next() { 12428 var state = getInternalState$4(this); 12429 var string = state.string; 12430 var index = state.index; 12431 var point; 12432 if (index >= string.length) return { value: undefined, done: true }; 12433 point = charAt$1(string, index); 12434 state.index += point.length; 12435 return { value: point, done: false }; 12436 }); 12437 12438 var ITERATOR$6 = wellKnownSymbol('iterator'); 12439 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 12440 var ArrayValues = es_array_iterator.values; 12441 12442 for (var COLLECTION_NAME$1 in domIterables) { 12443 var Collection$1 = global_1[COLLECTION_NAME$1]; 12444 var CollectionPrototype$1 = Collection$1 && Collection$1.prototype; 12445 if (CollectionPrototype$1) { 12446 // some Chrome versions have non-configurable methods on DOMTokenList 12447 if (CollectionPrototype$1[ITERATOR$6] !== ArrayValues) try { 12448 createNonEnumerableProperty(CollectionPrototype$1, ITERATOR$6, ArrayValues); 12449 } catch (error) { 12450 CollectionPrototype$1[ITERATOR$6] = ArrayValues; 12451 } 12452 if (!CollectionPrototype$1[TO_STRING_TAG$4]) { 12453 createNonEnumerableProperty(CollectionPrototype$1, TO_STRING_TAG$4, COLLECTION_NAME$1); 12454 } 12455 if (domIterables[COLLECTION_NAME$1]) for (var METHOD_NAME in es_array_iterator) { 12456 // some Chrome versions have non-configurable methods on DOMTokenList 12457 if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 12458 createNonEnumerableProperty(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]); 12459 } catch (error) { 12460 CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 12461 } 12462 } 12463 } 12464 } 12465 12466 createCommonjsModule(function (module) { 12467 /** 12468 * Copyright (c) 2014-present, Facebook, Inc. 12469 * 12470 * This source code is licensed under the MIT license found in the 12471 * LICENSE file in the root directory of this source tree. 12472 */ 12473 var runtime = function (exports) { 12474 12475 var Op = Object.prototype; 12476 var hasOwn = Op.hasOwnProperty; 12477 var undefined$1; // More compressible than void 0. 12478 12479 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 12480 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 12481 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 12482 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 12483 12484 function define(obj, key, value) { 12485 Object.defineProperty(obj, key, { 12486 value: value, 12487 enumerable: true, 12488 configurable: true, 12489 writable: true 12490 }); 12491 return obj[key]; 12492 } 12493 12494 try { 12495 // IE 8 has a broken Object.defineProperty that only works on DOM objects. 12496 define({}, ""); 12497 } catch (err) { 12498 define = function define(obj, key, value) { 12499 return obj[key] = value; 12500 }; 12501 } 12502 12503 function wrap(innerFn, outerFn, self, tryLocsList) { 12504 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 12505 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 12506 var generator = Object.create(protoGenerator.prototype); 12507 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, 12508 // .throw, and .return methods. 12509 12510 generator._invoke = makeInvokeMethod(innerFn, self, context); 12511 return generator; 12512 } 12513 12514 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion 12515 // record like context.tryEntries[i].completion. This interface could 12516 // have been (and was previously) designed to take a closure to be 12517 // invoked without arguments, but in all the cases we care about we 12518 // already have an existing method we want to call, so there's no need 12519 // to create a new function object. We can even get away with assuming 12520 // the method takes exactly one argument, since that happens to be true 12521 // in every case, so we don't have to touch the arguments object. The 12522 // only additional allocation required is the completion record, which 12523 // has a stable shape and so hopefully should be cheap to allocate. 12524 12525 function tryCatch(fn, obj, arg) { 12526 try { 12527 return { 12528 type: "normal", 12529 arg: fn.call(obj, arg) 12530 }; 12531 } catch (err) { 12532 return { 12533 type: "throw", 12534 arg: err 12535 }; 12536 } 12537 } 12538 12539 var GenStateSuspendedStart = "suspendedStart"; 12540 var GenStateSuspendedYield = "suspendedYield"; 12541 var GenStateExecuting = "executing"; 12542 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as 12543 // breaking out of the dispatch switch statement. 12544 12545 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and 12546 // .constructor.prototype properties for functions that return Generator 12547 // objects. For full spec compliance, you may wish to configure your 12548 // minifier not to mangle the names of these two functions. 12549 12550 function Generator() {} 12551 12552 function GeneratorFunction() {} 12553 12554 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that 12555 // don't natively support it. 12556 12557 12558 var IteratorPrototype = {}; 12559 12560 IteratorPrototype[iteratorSymbol] = function () { 12561 return this; 12562 }; 12563 12564 var getProto = Object.getPrototypeOf; 12565 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 12566 12567 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 12568 // This environment has a native %IteratorPrototype%; use it instead 12569 // of the polyfill. 12570 IteratorPrototype = NativeIteratorPrototype; 12571 } 12572 12573 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); 12574 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 12575 GeneratorFunctionPrototype.constructor = GeneratorFunction; 12576 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the 12577 // Iterator interface in terms of a single ._invoke method. 12578 12579 function defineIteratorMethods(prototype) { 12580 ["next", "throw", "return"].forEach(function (method) { 12581 define(prototype, method, function (arg) { 12582 return this._invoke(method, arg); 12583 }); 12584 }); 12585 } 12586 12587 exports.isGeneratorFunction = function (genFun) { 12588 var ctor = typeof genFun === "function" && genFun.constructor; 12589 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can 12590 // do is to check its .name property. 12591 (ctor.displayName || ctor.name) === "GeneratorFunction" : false; 12592 }; 12593 12594 exports.mark = function (genFun) { 12595 if (Object.setPrototypeOf) { 12596 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 12597 } else { 12598 genFun.__proto__ = GeneratorFunctionPrototype; 12599 define(genFun, toStringTagSymbol, "GeneratorFunction"); 12600 } 12601 12602 genFun.prototype = Object.create(Gp); 12603 return genFun; 12604 }; // Within the body of any async function, `await x` is transformed to 12605 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 12606 // `hasOwn.call(value, "__await")` to determine if the yielded value is 12607 // meant to be awaited. 12608 12609 12610 exports.awrap = function (arg) { 12611 return { 12612 __await: arg 12613 }; 12614 }; 12615 12616 function AsyncIterator(generator, PromiseImpl) { 12617 function invoke(method, arg, resolve, reject) { 12618 var record = tryCatch(generator[method], generator, arg); 12619 12620 if (record.type === "throw") { 12621 reject(record.arg); 12622 } else { 12623 var result = record.arg; 12624 var value = result.value; 12625 12626 if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) { 12627 return PromiseImpl.resolve(value.__await).then(function (value) { 12628 invoke("next", value, resolve, reject); 12629 }, function (err) { 12630 invoke("throw", err, resolve, reject); 12631 }); 12632 } 12633 12634 return PromiseImpl.resolve(value).then(function (unwrapped) { 12635 // When a yielded Promise is resolved, its final value becomes 12636 // the .value of the Promise<{value,done}> result for the 12637 // current iteration. 12638 result.value = unwrapped; 12639 resolve(result); 12640 }, function (error) { 12641 // If a rejected Promise was yielded, throw the rejection back 12642 // into the async generator function so it can be handled there. 12643 return invoke("throw", error, resolve, reject); 12644 }); 12645 } 12646 } 12647 12648 var previousPromise; 12649 12650 function enqueue(method, arg) { 12651 function callInvokeWithMethodAndArg() { 12652 return new PromiseImpl(function (resolve, reject) { 12653 invoke(method, arg, resolve, reject); 12654 }); 12655 } 12656 12657 return previousPromise = // If enqueue has been called before, then we want to wait until 12658 // all previous Promises have been resolved before calling invoke, 12659 // so that results are always delivered in the correct order. If 12660 // enqueue has not been called before, then it is important to 12661 // call invoke immediately, without waiting on a callback to fire, 12662 // so that the async generator function has the opportunity to do 12663 // any necessary setup in a predictable way. This predictability 12664 // is why the Promise constructor synchronously invokes its 12665 // executor callback, and why async functions synchronously 12666 // execute code before the first await. Since we implement simple 12667 // async functions in terms of async generators, it is especially 12668 // important to get this right, even though it requires care. 12669 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later 12670 // invocations of the iterator. 12671 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); 12672 } // Define the unified helper method that is used to implement .next, 12673 // .throw, and .return (see defineIteratorMethods). 12674 12675 12676 this._invoke = enqueue; 12677 } 12678 12679 defineIteratorMethods(AsyncIterator.prototype); 12680 12681 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 12682 return this; 12683 }; 12684 12685 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of 12686 // AsyncIterator objects; they just return a Promise for the value of 12687 // the final result produced by the iterator. 12688 12689 exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { 12690 if (PromiseImpl === void 0) PromiseImpl = Promise; 12691 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); 12692 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. 12693 : iter.next().then(function (result) { 12694 return result.done ? result.value : iter.next(); 12695 }); 12696 }; 12697 12698 function makeInvokeMethod(innerFn, self, context) { 12699 var state = GenStateSuspendedStart; 12700 return function invoke(method, arg) { 12701 if (state === GenStateExecuting) { 12702 throw new Error("Generator is already running"); 12703 } 12704 12705 if (state === GenStateCompleted) { 12706 if (method === "throw") { 12707 throw arg; 12708 } // Be forgiving, per 25.3.3.3.3 of the spec: 12709 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 12710 12711 12712 return doneResult(); 12713 } 12714 12715 context.method = method; 12716 context.arg = arg; 12717 12718 while (true) { 12719 var delegate = context.delegate; 12720 12721 if (delegate) { 12722 var delegateResult = maybeInvokeDelegate(delegate, context); 12723 12724 if (delegateResult) { 12725 if (delegateResult === ContinueSentinel) continue; 12726 return delegateResult; 12727 } 12728 } 12729 12730 if (context.method === "next") { 12731 // Setting context._sent for legacy support of Babel's 12732 // function.sent implementation. 12733 context.sent = context._sent = context.arg; 12734 } else if (context.method === "throw") { 12735 if (state === GenStateSuspendedStart) { 12736 state = GenStateCompleted; 12737 throw context.arg; 12738 } 12739 12740 context.dispatchException(context.arg); 12741 } else if (context.method === "return") { 12742 context.abrupt("return", context.arg); 12743 } 12744 12745 state = GenStateExecuting; 12746 var record = tryCatch(innerFn, self, context); 12747 12748 if (record.type === "normal") { 12749 // If an exception is thrown from innerFn, we leave state === 12750 // GenStateExecuting and loop back for another invocation. 12751 state = context.done ? GenStateCompleted : GenStateSuspendedYield; 12752 12753 if (record.arg === ContinueSentinel) { 12754 continue; 12755 } 12756 12757 return { 12758 value: record.arg, 12759 done: context.done 12760 }; 12761 } else if (record.type === "throw") { 12762 state = GenStateCompleted; // Dispatch the exception by looping back around to the 12763 // context.dispatchException(context.arg) call above. 12764 12765 context.method = "throw"; 12766 context.arg = record.arg; 12767 } 12768 } 12769 }; 12770 } // Call delegate.iterator[context.method](context.arg) and handle the 12771 // result, either by returning a { value, done } result from the 12772 // delegate iterator, or by modifying context.method and context.arg, 12773 // setting context.delegate to null, and returning the ContinueSentinel. 12774 12775 12776 function maybeInvokeDelegate(delegate, context) { 12777 var method = delegate.iterator[context.method]; 12778 12779 if (method === undefined$1) { 12780 // A .throw or .return when the delegate iterator has no .throw 12781 // method always terminates the yield* loop. 12782 context.delegate = null; 12783 12784 if (context.method === "throw") { 12785 // Note: ["return"] must be used for ES3 parsing compatibility. 12786 if (delegate.iterator["return"]) { 12787 // If the delegate iterator has a return method, give it a 12788 // chance to clean up. 12789 context.method = "return"; 12790 context.arg = undefined$1; 12791 maybeInvokeDelegate(delegate, context); 12792 12793 if (context.method === "throw") { 12794 // If maybeInvokeDelegate(context) changed context.method from 12795 // "return" to "throw", let that override the TypeError below. 12796 return ContinueSentinel; 12797 } 12798 } 12799 12800 context.method = "throw"; 12801 context.arg = new TypeError("The iterator does not provide a 'throw' method"); 12802 } 12803 12804 return ContinueSentinel; 12805 } 12806 12807 var record = tryCatch(method, delegate.iterator, context.arg); 12808 12809 if (record.type === "throw") { 12810 context.method = "throw"; 12811 context.arg = record.arg; 12812 context.delegate = null; 12813 return ContinueSentinel; 12814 } 12815 12816 var info = record.arg; 12817 12818 if (!info) { 12819 context.method = "throw"; 12820 context.arg = new TypeError("iterator result is not an object"); 12821 context.delegate = null; 12822 return ContinueSentinel; 12823 } 12824 12825 if (info.done) { 12826 // Assign the result of the finished delegate to the temporary 12827 // variable specified by delegate.resultName (see delegateYield). 12828 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). 12829 12830 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the 12831 // exception, let the outer generator proceed normally. If 12832 // context.method was "next", forget context.arg since it has been 12833 // "consumed" by the delegate iterator. If context.method was 12834 // "return", allow the original .return call to continue in the 12835 // outer generator. 12836 12837 if (context.method !== "return") { 12838 context.method = "next"; 12839 context.arg = undefined$1; 12840 } 12841 } else { 12842 // Re-yield the result returned by the delegate method. 12843 return info; 12844 } // The delegate iterator is finished, so forget it and continue with 12845 // the outer generator. 12846 12847 12848 context.delegate = null; 12849 return ContinueSentinel; 12850 } // Define Generator.prototype.{next,throw,return} in terms of the 12851 // unified ._invoke helper method. 12852 12853 12854 defineIteratorMethods(Gp); 12855 define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the 12856 // @@iterator function is called on it. Some browsers' implementations of the 12857 // iterator prototype chain incorrectly implement this, causing the Generator 12858 // object to not be returned from this call. This ensures that doesn't happen. 12859 // See https://github.com/facebook/regenerator/issues/274 for more details. 12860 12861 Gp[iteratorSymbol] = function () { 12862 return this; 12863 }; 12864 12865 Gp.toString = function () { 12866 return "[object Generator]"; 12867 }; 12868 12869 function pushTryEntry(locs) { 12870 var entry = { 12871 tryLoc: locs[0] 12872 }; 12873 12874 if (1 in locs) { 12875 entry.catchLoc = locs[1]; 12876 } 12877 12878 if (2 in locs) { 12879 entry.finallyLoc = locs[2]; 12880 entry.afterLoc = locs[3]; 12881 } 12882 12883 this.tryEntries.push(entry); 12884 } 12885 12886 function resetTryEntry(entry) { 12887 var record = entry.completion || {}; 12888 record.type = "normal"; 12889 delete record.arg; 12890 entry.completion = record; 12891 } 12892 12893 function Context(tryLocsList) { 12894 // The root entry object (effectively a try statement without a catch 12895 // or a finally block) gives us a place to store values thrown from 12896 // locations where there is no enclosing try statement. 12897 this.tryEntries = [{ 12898 tryLoc: "root" 12899 }]; 12900 tryLocsList.forEach(pushTryEntry, this); 12901 this.reset(true); 12902 } 12903 12904 exports.keys = function (object) { 12905 var keys = []; 12906 12907 for (var key in object) { 12908 keys.push(key); 12909 } 12910 12911 keys.reverse(); // Rather than returning an object with a next method, we keep 12912 // things simple and return the next function itself. 12913 12914 return function next() { 12915 while (keys.length) { 12916 var key = keys.pop(); 12917 12918 if (key in object) { 12919 next.value = key; 12920 next.done = false; 12921 return next; 12922 } 12923 } // To avoid creating an additional object, we just hang the .value 12924 // and .done properties off the next function object itself. This 12925 // also ensures that the minifier will not anonymize the function. 12926 12927 12928 next.done = true; 12929 return next; 12930 }; 12931 }; 12932 12933 function values(iterable) { 12934 if (iterable) { 12935 var iteratorMethod = iterable[iteratorSymbol]; 12936 12937 if (iteratorMethod) { 12938 return iteratorMethod.call(iterable); 12939 } 12940 12941 if (typeof iterable.next === "function") { 12942 return iterable; 12943 } 12944 12945 if (!isNaN(iterable.length)) { 12946 var i = -1, 12947 next = function next() { 12948 while (++i < iterable.length) { 12949 if (hasOwn.call(iterable, i)) { 12950 next.value = iterable[i]; 12951 next.done = false; 12952 return next; 12953 } 12954 } 12955 12956 next.value = undefined$1; 12957 next.done = true; 12958 return next; 12959 }; 12960 12961 return next.next = next; 12962 } 12963 } // Return an iterator with no values. 12964 12965 12966 return { 12967 next: doneResult 12968 }; 12969 } 12970 12971 exports.values = values; 12972 12973 function doneResult() { 12974 return { 12975 value: undefined$1, 12976 done: true 12977 }; 12978 } 12979 12980 Context.prototype = { 12981 constructor: Context, 12982 reset: function reset(skipTempReset) { 12983 this.prev = 0; 12984 this.next = 0; // Resetting context._sent for legacy support of Babel's 12985 // function.sent implementation. 12986 12987 this.sent = this._sent = undefined$1; 12988 this.done = false; 12989 this.delegate = null; 12990 this.method = "next"; 12991 this.arg = undefined$1; 12992 this.tryEntries.forEach(resetTryEntry); 12993 12994 if (!skipTempReset) { 12995 for (var name in this) { 12996 // Not sure about the optimal order of these conditions: 12997 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { 12998 this[name] = undefined$1; 12999 } 13000 } 13001 } 13002 }, 13003 stop: function stop() { 13004 this.done = true; 13005 var rootEntry = this.tryEntries[0]; 13006 var rootRecord = rootEntry.completion; 13007 13008 if (rootRecord.type === "throw") { 13009 throw rootRecord.arg; 13010 } 13011 13012 return this.rval; 13013 }, 13014 dispatchException: function dispatchException(exception) { 13015 if (this.done) { 13016 throw exception; 13017 } 13018 13019 var context = this; 13020 13021 function handle(loc, caught) { 13022 record.type = "throw"; 13023 record.arg = exception; 13024 context.next = loc; 13025 13026 if (caught) { 13027 // If the dispatched exception was caught by a catch block, 13028 // then let that catch block handle the exception normally. 13029 context.method = "next"; 13030 context.arg = undefined$1; 13031 } 13032 13033 return !!caught; 13034 } 13035 13036 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 13037 var entry = this.tryEntries[i]; 13038 var record = entry.completion; 13039 13040 if (entry.tryLoc === "root") { 13041 // Exception thrown outside of any try block that could handle 13042 // it, so set the completion value of the entire function to 13043 // throw the exception. 13044 return handle("end"); 13045 } 13046 13047 if (entry.tryLoc <= this.prev) { 13048 var hasCatch = hasOwn.call(entry, "catchLoc"); 13049 var hasFinally = hasOwn.call(entry, "finallyLoc"); 13050 13051 if (hasCatch && hasFinally) { 13052 if (this.prev < entry.catchLoc) { 13053 return handle(entry.catchLoc, true); 13054 } else if (this.prev < entry.finallyLoc) { 13055 return handle(entry.finallyLoc); 13056 } 13057 } else if (hasCatch) { 13058 if (this.prev < entry.catchLoc) { 13059 return handle(entry.catchLoc, true); 13060 } 13061 } else if (hasFinally) { 13062 if (this.prev < entry.finallyLoc) { 13063 return handle(entry.finallyLoc); 13064 } 13065 } else { 13066 throw new Error("try statement without catch or finally"); 13067 } 13068 } 13069 } 13070 }, 13071 abrupt: function abrupt(type, arg) { 13072 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 13073 var entry = this.tryEntries[i]; 13074 13075 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { 13076 var finallyEntry = entry; 13077 break; 13078 } 13079 } 13080 13081 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { 13082 // Ignore the finally entry if control is not jumping to a 13083 // location outside the try/catch block. 13084 finallyEntry = null; 13085 } 13086 13087 var record = finallyEntry ? finallyEntry.completion : {}; 13088 record.type = type; 13089 record.arg = arg; 13090 13091 if (finallyEntry) { 13092 this.method = "next"; 13093 this.next = finallyEntry.finallyLoc; 13094 return ContinueSentinel; 13095 } 13096 13097 return this.complete(record); 13098 }, 13099 complete: function complete(record, afterLoc) { 13100 if (record.type === "throw") { 13101 throw record.arg; 13102 } 13103 13104 if (record.type === "break" || record.type === "continue") { 13105 this.next = record.arg; 13106 } else if (record.type === "return") { 13107 this.rval = this.arg = record.arg; 13108 this.method = "return"; 13109 this.next = "end"; 13110 } else if (record.type === "normal" && afterLoc) { 13111 this.next = afterLoc; 13112 } 13113 13114 return ContinueSentinel; 13115 }, 13116 finish: function finish(finallyLoc) { 13117 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 13118 var entry = this.tryEntries[i]; 13119 13120 if (entry.finallyLoc === finallyLoc) { 13121 this.complete(entry.completion, entry.afterLoc); 13122 resetTryEntry(entry); 13123 return ContinueSentinel; 13124 } 13125 } 13126 }, 13127 "catch": function _catch(tryLoc) { 13128 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 13129 var entry = this.tryEntries[i]; 13130 13131 if (entry.tryLoc === tryLoc) { 13132 var record = entry.completion; 13133 13134 if (record.type === "throw") { 13135 var thrown = record.arg; 13136 resetTryEntry(entry); 13137 } 13138 13139 return thrown; 13140 } 13141 } // The context.catch method must only be called with a location 13142 // argument that corresponds to a known catch block. 13143 13144 13145 throw new Error("illegal catch attempt"); 13146 }, 13147 delegateYield: function delegateYield(iterable, resultName, nextLoc) { 13148 this.delegate = { 13149 iterator: values(iterable), 13150 resultName: resultName, 13151 nextLoc: nextLoc 13152 }; 13153 13154 if (this.method === "next") { 13155 // Deliberately forget the last sent value so that we don't 13156 // accidentally pass it on to the delegate. 13157 this.arg = undefined$1; 13158 } 13159 13160 return ContinueSentinel; 13161 } 13162 }; // Regardless of whether this script is executing as a CommonJS module 13163 // or not, return the runtime object so that we can declare the variable 13164 // regeneratorRuntime in the outer scope, which allows this module to be 13165 // injected easily by `bin/regenerator --include-runtime script.js`. 13166 13167 return exports; 13168 }( // If this script is executing as a CommonJS module, use module.exports 13169 // as the regeneratorRuntime namespace. Otherwise create a new empty 13170 // object. Either way, the resulting object will be used to initialize 13171 // the regeneratorRuntime variable at the top of this file. 13172 module.exports ); 13173 13174 try { 13175 regeneratorRuntime = runtime; 13176 } catch (accidentalStrictMode) { 13177 // This module should not be running in strict mode, so the above 13178 // assignment should always work unless something is misconfigured. Just 13179 // in case runtime.js accidentally runs in strict mode, we can escape 13180 // strict mode using a global Function call. This could conceivably fail 13181 // if a Content Security Policy forbids using Function, but in that case 13182 // the proper solution is to fix the accidental strict mode problem. If 13183 // you've misconfigured your bundler to force strict mode and applied a 13184 // CSP to forbid Function, and you're not willing to fix either of those 13185 // problems, please detail your unique predicament in a GitHub issue. 13186 Function("r", "regeneratorRuntime = r")(runtime); 13187 } 13188 }); 13189 13190 var escapeStringRegexp = function escapeStringRegexp(string) { 13191 if (typeof string !== 'string') { 13192 throw new TypeError('Expected a string'); 13193 } // Escape characters with special meaning either inside or outside character sets. 13194 // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. 13195 13196 13197 return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d'); 13198 }; 13199 13200 // Copyright Joyent, Inc. and other Node contributors. 13201 // 13202 // Permission is hereby granted, free of charge, to any person obtaining a 13203 // copy of this software and associated documentation files (the 13204 // "Software"), to deal in the Software without restriction, including 13205 // without limitation the rights to use, copy, modify, merge, publish, 13206 // distribute, sublicense, and/or sell copies of the Software, and to permit 13207 // persons to whom the Software is furnished to do so, subject to the 13208 // following conditions: 13209 // 13210 // The above copyright notice and this permission notice shall be included 13211 // in all copies or substantial portions of the Software. 13212 // 13213 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 13214 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13215 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 13216 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 13217 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 13218 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 13219 // USE OR OTHER DEALINGS IN THE SOFTWARE. 13220 // resolves . and .. elements in a path array with directory names there 13221 // must be no slashes, empty elements, or device names (c:\) in the array 13222 // (so also no leading and trailing slashes - it does not distinguish 13223 // relative and absolute paths) 13224 function normalizeArray(parts, allowAboveRoot) { 13225 // if the path tries to go above the root, `up` ends up > 0 13226 var up = 0; 13227 13228 for (var i = parts.length - 1; i >= 0; i--) { 13229 var last = parts[i]; 13230 13231 if (last === '.') { 13232 parts.splice(i, 1); 13233 } else if (last === '..') { 13234 parts.splice(i, 1); 13235 up++; 13236 } else if (up) { 13237 parts.splice(i, 1); 13238 up--; 13239 } 13240 } // if the path is allowed to go above the root, restore leading ..s 13241 13242 13243 if (allowAboveRoot) { 13244 for (; up--; up) { 13245 parts.unshift('..'); 13246 } 13247 } 13248 13249 return parts; 13250 } // Split a filename into [root, dir, basename, ext], unix version 13251 // 'root' is just a slash, or nothing. 13252 13253 13254 var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; 13255 13256 var splitPath = function splitPath(filename) { 13257 return splitPathRe.exec(filename).slice(1); 13258 }; // path.resolve([from ...], to) 13259 // posix version 13260 13261 13262 function resolve() { 13263 var resolvedPath = '', 13264 resolvedAbsolute = false; 13265 13266 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { 13267 var path = i >= 0 ? arguments[i] : '/'; // Skip empty and invalid entries 13268 13269 if (typeof path !== 'string') { 13270 throw new TypeError('Arguments to path.resolve must be strings'); 13271 } else if (!path) { 13272 continue; 13273 } 13274 13275 resolvedPath = path + '/' + resolvedPath; 13276 resolvedAbsolute = path.charAt(0) === '/'; 13277 } // At this point the path should be resolved to a full absolute path, but 13278 // handle relative paths to be safe (might happen when process.cwd() fails) 13279 // Normalize the path 13280 13281 13282 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) { 13283 return !!p; 13284 }), !resolvedAbsolute).join('/'); 13285 return (resolvedAbsolute ? '/' : '') + resolvedPath || '.'; 13286 } 13287 // posix version 13288 13289 function normalize$1(path) { 13290 var isPathAbsolute = isAbsolute(path), 13291 trailingSlash = substr(path, -1) === '/'; // Normalize the path 13292 13293 path = normalizeArray(filter(path.split('/'), function (p) { 13294 return !!p; 13295 }), !isPathAbsolute).join('/'); 13296 13297 if (!path && !isPathAbsolute) { 13298 path = '.'; 13299 } 13300 13301 if (path && trailingSlash) { 13302 path += '/'; 13303 } 13304 13305 return (isPathAbsolute ? '/' : '') + path; 13306 } 13307 13308 function isAbsolute(path) { 13309 return path.charAt(0) === '/'; 13310 } // posix version 13311 13312 function join() { 13313 var paths = Array.prototype.slice.call(arguments, 0); 13314 return normalize$1(filter(paths, function (p, index) { 13315 if (typeof p !== 'string') { 13316 throw new TypeError('Arguments to path.join must be strings'); 13317 } 13318 13319 return p; 13320 }).join('/')); 13321 } // path.relative(from, to) 13322 // posix version 13323 13324 function relative(from, to) { 13325 from = resolve(from).substr(1); 13326 to = resolve(to).substr(1); 13327 13328 function trim(arr) { 13329 var start = 0; 13330 13331 for (; start < arr.length; start++) { 13332 if (arr[start] !== '') break; 13333 } 13334 13335 var end = arr.length - 1; 13336 13337 for (; end >= 0; end--) { 13338 if (arr[end] !== '') break; 13339 } 13340 13341 if (start > end) return []; 13342 return arr.slice(start, end - start + 1); 13343 } 13344 13345 var fromParts = trim(from.split('/')); 13346 var toParts = trim(to.split('/')); 13347 var length = Math.min(fromParts.length, toParts.length); 13348 var samePartsLength = length; 13349 13350 for (var i = 0; i < length; i++) { 13351 if (fromParts[i] !== toParts[i]) { 13352 samePartsLength = i; 13353 break; 13354 } 13355 } 13356 13357 var outputParts = []; 13358 13359 for (var i = samePartsLength; i < fromParts.length; i++) { 13360 outputParts.push('..'); 13361 } 13362 13363 outputParts = outputParts.concat(toParts.slice(samePartsLength)); 13364 return outputParts.join('/'); 13365 } 13366 var sep = '/'; 13367 var delimiter = ':'; 13368 function dirname(path) { 13369 var result = splitPath(path), 13370 root = result[0], 13371 dir = result[1]; 13372 13373 if (!root && !dir) { 13374 // No dirname whatsoever 13375 return '.'; 13376 } 13377 13378 if (dir) { 13379 // It has a dirname, strip trailing slash 13380 dir = dir.substr(0, dir.length - 1); 13381 } 13382 13383 return root + dir; 13384 } 13385 function basename(path, ext) { 13386 var f = splitPath(path)[2]; // TODO: make this comparison case-insensitive on windows? 13387 13388 if (ext && f.substr(-1 * ext.length) === ext) { 13389 f = f.substr(0, f.length - ext.length); 13390 } 13391 13392 return f; 13393 } 13394 function extname(path) { 13395 return splitPath(path)[3]; 13396 } 13397 var path$1 = { 13398 extname: extname, 13399 basename: basename, 13400 dirname: dirname, 13401 sep: sep, 13402 delimiter: delimiter, 13403 relative: relative, 13404 join: join, 13405 isAbsolute: isAbsolute, 13406 normalize: normalize$1, 13407 resolve: resolve 13408 }; 13409 13410 function filter(xs, f) { 13411 if (xs.filter) return xs.filter(f); 13412 var res = []; 13413 13414 for (var i = 0; i < xs.length; i++) { 13415 if (f(xs[i], i, xs)) res.push(xs[i]); 13416 } 13417 13418 return res; 13419 } // String.prototype.substr - negative index don't work in IE8 13420 13421 13422 var substr = 'ab'.substr(-1) === 'b' ? function (str, start, len) { 13423 return str.substr(start, len); 13424 } : function (str, start, len) { 13425 if (start < 0) start = str.length + start; 13426 return str.substr(start, len); 13427 }; 13428 13429 // call something on iterator step with safe closing on error 13430 var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) { 13431 try { 13432 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); 13433 // 7.4.6 IteratorClose(iterator, completion) 13434 } catch (error) { 13435 iteratorClose(iterator); 13436 throw error; 13437 } 13438 }; 13439 13440 // `Array.from` method implementation 13441 // https://tc39.es/ecma262/#sec-array.from 13442 var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { 13443 var O = toObject(arrayLike); 13444 var C = typeof this == 'function' ? this : Array; 13445 var argumentsLength = arguments.length; 13446 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 13447 var mapping = mapfn !== undefined; 13448 var iteratorMethod = getIteratorMethod(O); 13449 var index = 0; 13450 var length, result, step, iterator, next, value; 13451 if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); 13452 // if the target is not iterable or it's an array with the default iterator - use a simple case 13453 if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) { 13454 iterator = iteratorMethod.call(O); 13455 next = iterator.next; 13456 result = new C(); 13457 for (;!(step = next.call(iterator)).done; index++) { 13458 value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value; 13459 createProperty(result, index, value); 13460 } 13461 } else { 13462 length = toLength(O.length); 13463 result = new C(length); 13464 for (;length > index; index++) { 13465 value = mapping ? mapfn(O[index], index) : O[index]; 13466 createProperty(result, index, value); 13467 } 13468 } 13469 result.length = index; 13470 return result; 13471 }; 13472 13473 var INCORRECT_ITERATION$1 = !checkCorrectnessOfIteration(function (iterable) { 13474 Array.from(iterable); 13475 }); 13476 13477 // `Array.from` method 13478 // https://tc39.es/ecma262/#sec-array.from 13479 _export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION$1 }, { 13480 from: arrayFrom 13481 }); 13482 13483 var diff = createCommonjsModule(function (module, exports) { 13484 (function (global, factory) { 13485 factory(exports) ; 13486 })(commonjsGlobal, function (exports) { 13487 13488 function Diff() {} 13489 13490 Diff.prototype = { 13491 diff: function diff(oldString, newString) { 13492 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 13493 var callback = options.callback; 13494 13495 if (typeof options === 'function') { 13496 callback = options; 13497 options = {}; 13498 } 13499 13500 this.options = options; 13501 var self = this; 13502 13503 function done(value) { 13504 if (callback) { 13505 setTimeout(function () { 13506 callback(undefined, value); 13507 }, 0); 13508 return true; 13509 } else { 13510 return value; 13511 } 13512 } // Allow subclasses to massage the input prior to running 13513 13514 13515 oldString = this.castInput(oldString); 13516 newString = this.castInput(newString); 13517 oldString = this.removeEmpty(this.tokenize(oldString)); 13518 newString = this.removeEmpty(this.tokenize(newString)); 13519 var newLen = newString.length, 13520 oldLen = oldString.length; 13521 var editLength = 1; 13522 var maxEditLength = newLen + oldLen; 13523 var bestPath = [{ 13524 newPos: -1, 13525 components: [] 13526 }]; // Seed editLength = 0, i.e. the content starts with the same values 13527 13528 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); 13529 13530 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { 13531 // Identity per the equality and tokenizer 13532 return done([{ 13533 value: this.join(newString), 13534 count: newString.length 13535 }]); 13536 } // Main worker method. checks all permutations of a given edit length for acceptance. 13537 13538 13539 function execEditLength() { 13540 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { 13541 var basePath = void 0; 13542 13543 var addPath = bestPath[diagonalPath - 1], 13544 removePath = bestPath[diagonalPath + 1], 13545 _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; 13546 13547 if (addPath) { 13548 // No one else is going to attempt to use this value, clear it 13549 bestPath[diagonalPath - 1] = undefined; 13550 } 13551 13552 var canAdd = addPath && addPath.newPos + 1 < newLen, 13553 canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; 13554 13555 if (!canAdd && !canRemove) { 13556 // If this path is a terminal then prune 13557 bestPath[diagonalPath] = undefined; 13558 continue; 13559 } // Select the diagonal that we want to branch from. We select the prior 13560 // path whose position in the new string is the farthest from the origin 13561 // and does not pass the bounds of the diff graph 13562 13563 13564 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { 13565 basePath = clonePath(removePath); 13566 self.pushComponent(basePath.components, undefined, true); 13567 } else { 13568 basePath = addPath; // No need to clone, we've pulled it from the list 13569 13570 basePath.newPos++; 13571 self.pushComponent(basePath.components, true, undefined); 13572 } 13573 13574 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done 13575 13576 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { 13577 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); 13578 } else { 13579 // Otherwise track this path as a potential candidate and continue. 13580 bestPath[diagonalPath] = basePath; 13581 } 13582 } 13583 13584 editLength++; 13585 } // Performs the length of edit iteration. Is a bit fugly as this has to support the 13586 // sync and async mode which is never fun. Loops over execEditLength until a value 13587 // is produced. 13588 13589 13590 if (callback) { 13591 (function exec() { 13592 setTimeout(function () { 13593 // This should not happen, but we want to be safe. 13594 13595 /* istanbul ignore next */ 13596 if (editLength > maxEditLength) { 13597 return callback(); 13598 } 13599 13600 if (!execEditLength()) { 13601 exec(); 13602 } 13603 }, 0); 13604 })(); 13605 } else { 13606 while (editLength <= maxEditLength) { 13607 var ret = execEditLength(); 13608 13609 if (ret) { 13610 return ret; 13611 } 13612 } 13613 } 13614 }, 13615 pushComponent: function pushComponent(components, added, removed) { 13616 var last = components[components.length - 1]; 13617 13618 if (last && last.added === added && last.removed === removed) { 13619 // We need to clone here as the component clone operation is just 13620 // as shallow array clone 13621 components[components.length - 1] = { 13622 count: last.count + 1, 13623 added: added, 13624 removed: removed 13625 }; 13626 } else { 13627 components.push({ 13628 count: 1, 13629 added: added, 13630 removed: removed 13631 }); 13632 } 13633 }, 13634 extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { 13635 var newLen = newString.length, 13636 oldLen = oldString.length, 13637 newPos = basePath.newPos, 13638 oldPos = newPos - diagonalPath, 13639 commonCount = 0; 13640 13641 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { 13642 newPos++; 13643 oldPos++; 13644 commonCount++; 13645 } 13646 13647 if (commonCount) { 13648 basePath.components.push({ 13649 count: commonCount 13650 }); 13651 } 13652 13653 basePath.newPos = newPos; 13654 return oldPos; 13655 }, 13656 equals: function equals(left, right) { 13657 if (this.options.comparator) { 13658 return this.options.comparator(left, right); 13659 } else { 13660 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); 13661 } 13662 }, 13663 removeEmpty: function removeEmpty(array) { 13664 var ret = []; 13665 13666 for (var i = 0; i < array.length; i++) { 13667 if (array[i]) { 13668 ret.push(array[i]); 13669 } 13670 } 13671 13672 return ret; 13673 }, 13674 castInput: function castInput(value) { 13675 return value; 13676 }, 13677 tokenize: function tokenize(value) { 13678 return value.split(''); 13679 }, 13680 join: function join(chars) { 13681 return chars.join(''); 13682 } 13683 }; 13684 13685 function buildValues(diff, components, newString, oldString, useLongestToken) { 13686 var componentPos = 0, 13687 componentLen = components.length, 13688 newPos = 0, 13689 oldPos = 0; 13690 13691 for (; componentPos < componentLen; componentPos++) { 13692 var component = components[componentPos]; 13693 13694 if (!component.removed) { 13695 if (!component.added && useLongestToken) { 13696 var value = newString.slice(newPos, newPos + component.count); 13697 value = value.map(function (value, i) { 13698 var oldValue = oldString[oldPos + i]; 13699 return oldValue.length > value.length ? oldValue : value; 13700 }); 13701 component.value = diff.join(value); 13702 } else { 13703 component.value = diff.join(newString.slice(newPos, newPos + component.count)); 13704 } 13705 13706 newPos += component.count; // Common case 13707 13708 if (!component.added) { 13709 oldPos += component.count; 13710 } 13711 } else { 13712 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); 13713 oldPos += component.count; // Reverse add and remove so removes are output first to match common convention 13714 // The diffing algorithm is tied to add then remove output and this is the simplest 13715 // route to get the desired output with minimal overhead. 13716 13717 if (componentPos && components[componentPos - 1].added) { 13718 var tmp = components[componentPos - 1]; 13719 components[componentPos - 1] = components[componentPos]; 13720 components[componentPos] = tmp; 13721 } 13722 } 13723 } // Special case handle for when one terminal is ignored (i.e. whitespace). 13724 // For this case we merge the terminal into the prior string and drop the change. 13725 // This is only available for string mode. 13726 13727 13728 var lastComponent = components[componentLen - 1]; 13729 13730 if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { 13731 components[componentLen - 2].value += lastComponent.value; 13732 components.pop(); 13733 } 13734 13735 return components; 13736 } 13737 13738 function clonePath(path) { 13739 return { 13740 newPos: path.newPos, 13741 components: path.components.slice(0) 13742 }; 13743 } 13744 13745 var characterDiff = new Diff(); 13746 13747 function diffChars(oldStr, newStr, options) { 13748 return characterDiff.diff(oldStr, newStr, options); 13749 } 13750 13751 function generateOptions(options, defaults) { 13752 if (typeof options === 'function') { 13753 defaults.callback = options; 13754 } else if (options) { 13755 for (var name in options) { 13756 /* istanbul ignore else */ 13757 if (options.hasOwnProperty(name)) { 13758 defaults[name] = options[name]; 13759 } 13760 } 13761 } 13762 13763 return defaults; 13764 } // 13765 // Ranges and exceptions: 13766 // Latin-1 Supplement, 0080–00FF 13767 // - U+00D7 × Multiplication sign 13768 // - U+00F7 ÷ Division sign 13769 // Latin Extended-A, 0100–017F 13770 // Latin Extended-B, 0180–024F 13771 // IPA Extensions, 0250–02AF 13772 // Spacing Modifier Letters, 02B0–02FF 13773 // - U+02C7 ˇ ˇ Caron 13774 // - U+02D8 ˘ ˘ Breve 13775 // - U+02D9 ˙ ˙ Dot Above 13776 // - U+02DA ˚ ˚ Ring Above 13777 // - U+02DB ˛ ˛ Ogonek 13778 // - U+02DC ˜ ˜ Small Tilde 13779 // - U+02DD ˝ ˝ Double Acute Accent 13780 // Latin Extended Additional, 1E00–1EFF 13781 13782 13783 var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; 13784 var reWhitespace = /\S/; 13785 var wordDiff = new Diff(); 13786 13787 wordDiff.equals = function (left, right) { 13788 if (this.options.ignoreCase) { 13789 left = left.toLowerCase(); 13790 right = right.toLowerCase(); 13791 } 13792 13793 return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); 13794 }; 13795 13796 wordDiff.tokenize = function (value) { 13797 // All whitespace symbols except newline group into one token, each newline - in separate token 13798 var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. 13799 13800 for (var i = 0; i < tokens.length - 1; i++) { 13801 // If we have an empty string in the next field and we have only word chars before and after, merge 13802 if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { 13803 tokens[i] += tokens[i + 2]; 13804 tokens.splice(i + 1, 2); 13805 i--; 13806 } 13807 } 13808 13809 return tokens; 13810 }; 13811 13812 function diffWords(oldStr, newStr, options) { 13813 options = generateOptions(options, { 13814 ignoreWhitespace: true 13815 }); 13816 return wordDiff.diff(oldStr, newStr, options); 13817 } 13818 13819 function diffWordsWithSpace(oldStr, newStr, options) { 13820 return wordDiff.diff(oldStr, newStr, options); 13821 } 13822 13823 var lineDiff = new Diff(); 13824 13825 lineDiff.tokenize = function (value) { 13826 var retLines = [], 13827 linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line 13828 13829 if (!linesAndNewlines[linesAndNewlines.length - 1]) { 13830 linesAndNewlines.pop(); 13831 } // Merge the content and line separators into single tokens 13832 13833 13834 for (var i = 0; i < linesAndNewlines.length; i++) { 13835 var line = linesAndNewlines[i]; 13836 13837 if (i % 2 && !this.options.newlineIsToken) { 13838 retLines[retLines.length - 1] += line; 13839 } else { 13840 if (this.options.ignoreWhitespace) { 13841 line = line.trim(); 13842 } 13843 13844 retLines.push(line); 13845 } 13846 } 13847 13848 return retLines; 13849 }; 13850 13851 function diffLines(oldStr, newStr, callback) { 13852 return lineDiff.diff(oldStr, newStr, callback); 13853 } 13854 13855 function diffTrimmedLines(oldStr, newStr, callback) { 13856 var options = generateOptions(callback, { 13857 ignoreWhitespace: true 13858 }); 13859 return lineDiff.diff(oldStr, newStr, options); 13860 } 13861 13862 var sentenceDiff = new Diff(); 13863 13864 sentenceDiff.tokenize = function (value) { 13865 return value.split(/(\S.+?[.!?])(?=\s+|$)/); 13866 }; 13867 13868 function diffSentences(oldStr, newStr, callback) { 13869 return sentenceDiff.diff(oldStr, newStr, callback); 13870 } 13871 13872 var cssDiff = new Diff(); 13873 13874 cssDiff.tokenize = function (value) { 13875 return value.split(/([{}:;,]|\s+)/); 13876 }; 13877 13878 function diffCss(oldStr, newStr, callback) { 13879 return cssDiff.diff(oldStr, newStr, callback); 13880 } 13881 13882 function _typeof(obj) { 13883 "@babel/helpers - typeof"; 13884 13885 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 13886 _typeof = function _typeof(obj) { 13887 return typeof obj; 13888 }; 13889 } else { 13890 _typeof = function _typeof(obj) { 13891 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 13892 }; 13893 } 13894 13895 return _typeof(obj); 13896 } 13897 13898 function _toConsumableArray(arr) { 13899 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); 13900 } 13901 13902 function _arrayWithoutHoles(arr) { 13903 if (Array.isArray(arr)) return _arrayLikeToArray(arr); 13904 } 13905 13906 function _iterableToArray(iter) { 13907 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 13908 } 13909 13910 function _unsupportedIterableToArray(o, minLen) { 13911 if (!o) return; 13912 if (typeof o === "string") return _arrayLikeToArray(o, minLen); 13913 var n = Object.prototype.toString.call(o).slice(8, -1); 13914 if (n === "Object" && o.constructor) n = o.constructor.name; 13915 if (n === "Map" || n === "Set") return Array.from(o); 13916 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); 13917 } 13918 13919 function _arrayLikeToArray(arr, len) { 13920 if (len == null || len > arr.length) len = arr.length; 13921 13922 for (var i = 0, arr2 = new Array(len); i < len; i++) { 13923 arr2[i] = arr[i]; 13924 } 13925 13926 return arr2; 13927 } 13928 13929 function _nonIterableSpread() { 13930 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 13931 } 13932 13933 var objectPrototypeToString = Object.prototype.toString; 13934 var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a 13935 // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: 13936 13937 jsonDiff.useLongestToken = true; 13938 jsonDiff.tokenize = lineDiff.tokenize; 13939 13940 jsonDiff.castInput = function (value) { 13941 var _this$options = this.options, 13942 undefinedReplacement = _this$options.undefinedReplacement, 13943 _this$options$stringi = _this$options.stringifyReplacer, 13944 stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) { 13945 return typeof v === 'undefined' ? undefinedReplacement : v; 13946 } : _this$options$stringi; 13947 return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); 13948 }; 13949 13950 jsonDiff.equals = function (left, right) { 13951 return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')); 13952 }; 13953 13954 function diffJson(oldObj, newObj, options) { 13955 return jsonDiff.diff(oldObj, newObj, options); 13956 } // This function handles the presence of circular references by bailing out when encountering an 13957 // object that is already on the "stack" of items being processed. Accepts an optional replacer 13958 13959 13960 function canonicalize(obj, stack, replacementStack, replacer, key) { 13961 stack = stack || []; 13962 replacementStack = replacementStack || []; 13963 13964 if (replacer) { 13965 obj = replacer(key, obj); 13966 } 13967 13968 var i; 13969 13970 for (i = 0; i < stack.length; i += 1) { 13971 if (stack[i] === obj) { 13972 return replacementStack[i]; 13973 } 13974 } 13975 13976 var canonicalizedObj; 13977 13978 if ('[object Array]' === objectPrototypeToString.call(obj)) { 13979 stack.push(obj); 13980 canonicalizedObj = new Array(obj.length); 13981 replacementStack.push(canonicalizedObj); 13982 13983 for (i = 0; i < obj.length; i += 1) { 13984 canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); 13985 } 13986 13987 stack.pop(); 13988 replacementStack.pop(); 13989 return canonicalizedObj; 13990 } 13991 13992 if (obj && obj.toJSON) { 13993 obj = obj.toJSON(); 13994 } 13995 13996 if (_typeof(obj) === 'object' && obj !== null) { 13997 stack.push(obj); 13998 canonicalizedObj = {}; 13999 replacementStack.push(canonicalizedObj); 14000 14001 var sortedKeys = [], 14002 _key; 14003 14004 for (_key in obj) { 14005 /* istanbul ignore else */ 14006 if (obj.hasOwnProperty(_key)) { 14007 sortedKeys.push(_key); 14008 } 14009 } 14010 14011 sortedKeys.sort(); 14012 14013 for (i = 0; i < sortedKeys.length; i += 1) { 14014 _key = sortedKeys[i]; 14015 canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); 14016 } 14017 14018 stack.pop(); 14019 replacementStack.pop(); 14020 } else { 14021 canonicalizedObj = obj; 14022 } 14023 14024 return canonicalizedObj; 14025 } 14026 14027 var arrayDiff = new Diff(); 14028 14029 arrayDiff.tokenize = function (value) { 14030 return value.slice(); 14031 }; 14032 14033 arrayDiff.join = arrayDiff.removeEmpty = function (value) { 14034 return value; 14035 }; 14036 14037 function diffArrays(oldArr, newArr, callback) { 14038 return arrayDiff.diff(oldArr, newArr, callback); 14039 } 14040 14041 function parsePatch(uniDiff) { 14042 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 14043 var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), 14044 delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], 14045 list = [], 14046 i = 0; 14047 14048 function parseIndex() { 14049 var index = {}; 14050 list.push(index); // Parse diff metadata 14051 14052 while (i < diffstr.length) { 14053 var line = diffstr[i]; // File header found, end parsing diff metadata 14054 14055 if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { 14056 break; 14057 } // Diff index 14058 14059 14060 var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); 14061 14062 if (header) { 14063 index.index = header[1]; 14064 } 14065 14066 i++; 14067 } // Parse file headers if they are defined. Unified diff requires them, but 14068 // there's no technical issues to have an isolated hunk without file header 14069 14070 14071 parseFileHeader(index); 14072 parseFileHeader(index); // Parse hunks 14073 14074 index.hunks = []; 14075 14076 while (i < diffstr.length) { 14077 var _line = diffstr[i]; 14078 14079 if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { 14080 break; 14081 } else if (/^@@/.test(_line)) { 14082 index.hunks.push(parseHunk()); 14083 } else if (_line && options.strict) { 14084 // Ignore unexpected content unless in strict mode 14085 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); 14086 } else { 14087 i++; 14088 } 14089 } 14090 } // Parses the --- and +++ headers, if none are found, no lines 14091 // are consumed. 14092 14093 14094 function parseFileHeader(index) { 14095 var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]); 14096 14097 if (fileHeader) { 14098 var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; 14099 var data = fileHeader[2].split('\t', 2); 14100 var fileName = data[0].replace(/\\\\/g, '\\'); 14101 14102 if (/^".*"$/.test(fileName)) { 14103 fileName = fileName.substr(1, fileName.length - 2); 14104 } 14105 14106 index[keyPrefix + 'FileName'] = fileName; 14107 index[keyPrefix + 'Header'] = (data[1] || '').trim(); 14108 i++; 14109 } 14110 } // Parses a hunk 14111 // This assumes that we are at the start of a hunk. 14112 14113 14114 function parseHunk() { 14115 var chunkHeaderIndex = i, 14116 chunkHeaderLine = diffstr[i++], 14117 chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); 14118 var hunk = { 14119 oldStart: +chunkHeader[1], 14120 oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2], 14121 newStart: +chunkHeader[3], 14122 newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4], 14123 lines: [], 14124 linedelimiters: [] 14125 }; // Unified Diff Format quirk: If the chunk size is 0, 14126 // the first number is one lower than one would expect. 14127 // https://www.artima.com/weblogs/viewpost.jsp?thread=164293 14128 14129 if (hunk.oldLines === 0) { 14130 hunk.oldStart += 1; 14131 } 14132 14133 if (hunk.newLines === 0) { 14134 hunk.newStart += 1; 14135 } 14136 14137 var addCount = 0, 14138 removeCount = 0; 14139 14140 for (; i < diffstr.length; i++) { 14141 // Lines starting with '---' could be mistaken for the "remove line" operation 14142 // But they could be the header for the next file. Therefore prune such cases out. 14143 if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { 14144 break; 14145 } 14146 14147 var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; 14148 14149 if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { 14150 hunk.lines.push(diffstr[i]); 14151 hunk.linedelimiters.push(delimiters[i] || '\n'); 14152 14153 if (operation === '+') { 14154 addCount++; 14155 } else if (operation === '-') { 14156 removeCount++; 14157 } else if (operation === ' ') { 14158 addCount++; 14159 removeCount++; 14160 } 14161 } else { 14162 break; 14163 } 14164 } // Handle the empty block count case 14165 14166 14167 if (!addCount && hunk.newLines === 1) { 14168 hunk.newLines = 0; 14169 } 14170 14171 if (!removeCount && hunk.oldLines === 1) { 14172 hunk.oldLines = 0; 14173 } // Perform optional sanity checking 14174 14175 14176 if (options.strict) { 14177 if (addCount !== hunk.newLines) { 14178 throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); 14179 } 14180 14181 if (removeCount !== hunk.oldLines) { 14182 throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); 14183 } 14184 } 14185 14186 return hunk; 14187 } 14188 14189 while (i < diffstr.length) { 14190 parseIndex(); 14191 } 14192 14193 return list; 14194 } // Iterator that traverses in the range of [min, max], stepping 14195 // by distance from a given start position. I.e. for [0, 4], with 14196 // start of 2, this will iterate 2, 3, 1, 4, 0. 14197 14198 14199 function distanceIterator(start, minLine, maxLine) { 14200 var wantForward = true, 14201 backwardExhausted = false, 14202 forwardExhausted = false, 14203 localOffset = 1; 14204 return function iterator() { 14205 if (wantForward && !forwardExhausted) { 14206 if (backwardExhausted) { 14207 localOffset++; 14208 } else { 14209 wantForward = false; 14210 } // Check if trying to fit beyond text length, and if not, check it fits 14211 // after offset location (or desired location on first iteration) 14212 14213 14214 if (start + localOffset <= maxLine) { 14215 return localOffset; 14216 } 14217 14218 forwardExhausted = true; 14219 } 14220 14221 if (!backwardExhausted) { 14222 if (!forwardExhausted) { 14223 wantForward = true; 14224 } // Check if trying to fit before text beginning, and if not, check it fits 14225 // before offset location 14226 14227 14228 if (minLine <= start - localOffset) { 14229 return -localOffset++; 14230 } 14231 14232 backwardExhausted = true; 14233 return iterator(); 14234 } // We tried to fit hunk before text beginning and beyond text length, then 14235 // hunk can't fit on the text. Return undefined 14236 14237 }; 14238 } 14239 14240 function applyPatch(source, uniDiff) { 14241 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 14242 14243 if (typeof uniDiff === 'string') { 14244 uniDiff = parsePatch(uniDiff); 14245 } 14246 14247 if (Array.isArray(uniDiff)) { 14248 if (uniDiff.length > 1) { 14249 throw new Error('applyPatch only works with a single input.'); 14250 } 14251 14252 uniDiff = uniDiff[0]; 14253 } // Apply the diff to the input 14254 14255 14256 var lines = source.split(/\r\n|[\n\v\f\r\x85]/), 14257 delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], 14258 hunks = uniDiff.hunks, 14259 compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) { 14260 return line === patchContent; 14261 }, 14262 errorCount = 0, 14263 fuzzFactor = options.fuzzFactor || 0, 14264 minLine = 0, 14265 offset = 0, 14266 removeEOFNL, 14267 addEOFNL; 14268 /** 14269 * Checks if the hunk exactly fits on the provided location 14270 */ 14271 14272 14273 function hunkFits(hunk, toPos) { 14274 for (var j = 0; j < hunk.lines.length; j++) { 14275 var line = hunk.lines[j], 14276 operation = line.length > 0 ? line[0] : ' ', 14277 content = line.length > 0 ? line.substr(1) : line; 14278 14279 if (operation === ' ' || operation === '-') { 14280 // Context sanity check 14281 if (!compareLine(toPos + 1, lines[toPos], operation, content)) { 14282 errorCount++; 14283 14284 if (errorCount > fuzzFactor) { 14285 return false; 14286 } 14287 } 14288 14289 toPos++; 14290 } 14291 } 14292 14293 return true; 14294 } // Search best fit offsets for each hunk based on the previous ones 14295 14296 14297 for (var i = 0; i < hunks.length; i++) { 14298 var hunk = hunks[i], 14299 maxLine = lines.length - hunk.oldLines, 14300 localOffset = 0, 14301 toPos = offset + hunk.oldStart - 1; 14302 var iterator = distanceIterator(toPos, minLine, maxLine); 14303 14304 for (; localOffset !== undefined; localOffset = iterator()) { 14305 if (hunkFits(hunk, toPos + localOffset)) { 14306 hunk.offset = offset += localOffset; 14307 break; 14308 } 14309 } 14310 14311 if (localOffset === undefined) { 14312 return false; 14313 } // Set lower text limit to end of the current hunk, so next ones don't try 14314 // to fit over already patched text 14315 14316 14317 minLine = hunk.offset + hunk.oldStart + hunk.oldLines; 14318 } // Apply patch hunks 14319 14320 14321 var diffOffset = 0; 14322 14323 for (var _i = 0; _i < hunks.length; _i++) { 14324 var _hunk = hunks[_i], 14325 _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; 14326 14327 diffOffset += _hunk.newLines - _hunk.oldLines; 14328 14329 for (var j = 0; j < _hunk.lines.length; j++) { 14330 var line = _hunk.lines[j], 14331 operation = line.length > 0 ? line[0] : ' ', 14332 content = line.length > 0 ? line.substr(1) : line, 14333 delimiter = _hunk.linedelimiters[j]; 14334 14335 if (operation === ' ') { 14336 _toPos++; 14337 } else if (operation === '-') { 14338 lines.splice(_toPos, 1); 14339 delimiters.splice(_toPos, 1); 14340 /* istanbul ignore else */ 14341 } else if (operation === '+') { 14342 lines.splice(_toPos, 0, content); 14343 delimiters.splice(_toPos, 0, delimiter); 14344 _toPos++; 14345 } else if (operation === '\\') { 14346 var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; 14347 14348 if (previousOperation === '+') { 14349 removeEOFNL = true; 14350 } else if (previousOperation === '-') { 14351 addEOFNL = true; 14352 } 14353 } 14354 } 14355 } // Handle EOFNL insertion/removal 14356 14357 14358 if (removeEOFNL) { 14359 while (!lines[lines.length - 1]) { 14360 lines.pop(); 14361 delimiters.pop(); 14362 } 14363 } else if (addEOFNL) { 14364 lines.push(''); 14365 delimiters.push('\n'); 14366 } 14367 14368 for (var _k = 0; _k < lines.length - 1; _k++) { 14369 lines[_k] = lines[_k] + delimiters[_k]; 14370 } 14371 14372 return lines.join(''); 14373 } // Wrapper that supports multiple file patches via callbacks. 14374 14375 14376 function applyPatches(uniDiff, options) { 14377 if (typeof uniDiff === 'string') { 14378 uniDiff = parsePatch(uniDiff); 14379 } 14380 14381 var currentIndex = 0; 14382 14383 function processIndex() { 14384 var index = uniDiff[currentIndex++]; 14385 14386 if (!index) { 14387 return options.complete(); 14388 } 14389 14390 options.loadFile(index, function (err, data) { 14391 if (err) { 14392 return options.complete(err); 14393 } 14394 14395 var updatedContent = applyPatch(data, index, options); 14396 options.patched(index, updatedContent, function (err) { 14397 if (err) { 14398 return options.complete(err); 14399 } 14400 14401 processIndex(); 14402 }); 14403 }); 14404 } 14405 14406 processIndex(); 14407 } 14408 14409 function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { 14410 if (!options) { 14411 options = {}; 14412 } 14413 14414 if (typeof options.context === 'undefined') { 14415 options.context = 4; 14416 } 14417 14418 var diff = diffLines(oldStr, newStr, options); 14419 diff.push({ 14420 value: '', 14421 lines: [] 14422 }); // Append an empty value to make cleanup easier 14423 14424 function contextLines(lines) { 14425 return lines.map(function (entry) { 14426 return ' ' + entry; 14427 }); 14428 } 14429 14430 var hunks = []; 14431 var oldRangeStart = 0, 14432 newRangeStart = 0, 14433 curRange = [], 14434 oldLine = 1, 14435 newLine = 1; 14436 14437 var _loop = function _loop(i) { 14438 var current = diff[i], 14439 lines = current.lines || current.value.replace(/\n$/, '').split('\n'); 14440 current.lines = lines; 14441 14442 if (current.added || current.removed) { 14443 var _curRange; // If we have previous context, start with that 14444 14445 14446 if (!oldRangeStart) { 14447 var prev = diff[i - 1]; 14448 oldRangeStart = oldLine; 14449 newRangeStart = newLine; 14450 14451 if (prev) { 14452 curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; 14453 oldRangeStart -= curRange.length; 14454 newRangeStart -= curRange.length; 14455 } 14456 } // Output our changes 14457 14458 14459 (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) { 14460 return (current.added ? '+' : '-') + entry; 14461 }))); // Track the updated file position 14462 14463 14464 if (current.added) { 14465 newLine += lines.length; 14466 } else { 14467 oldLine += lines.length; 14468 } 14469 } else { 14470 // Identical context lines. Track line changes 14471 if (oldRangeStart) { 14472 // Close out any changes that have been output (or join overlapping) 14473 if (lines.length <= options.context * 2 && i < diff.length - 2) { 14474 var _curRange2; // Overlapping 14475 14476 14477 (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines))); 14478 } else { 14479 var _curRange3; // end the range and output 14480 14481 14482 var contextSize = Math.min(lines.length, options.context); 14483 14484 (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize)))); 14485 14486 var hunk = { 14487 oldStart: oldRangeStart, 14488 oldLines: oldLine - oldRangeStart + contextSize, 14489 newStart: newRangeStart, 14490 newLines: newLine - newRangeStart + contextSize, 14491 lines: curRange 14492 }; 14493 14494 if (i >= diff.length - 2 && lines.length <= options.context) { 14495 // EOF is inside this hunk 14496 var oldEOFNewline = /\n$/.test(oldStr); 14497 var newEOFNewline = /\n$/.test(newStr); 14498 var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; 14499 14500 if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) { 14501 // special case: old has no eol and no trailing context; no-nl can end up before adds 14502 // however, if the old file is empty, do not output the no-nl line 14503 curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); 14504 } 14505 14506 if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { 14507 curRange.push('\\ No newline at end of file'); 14508 } 14509 } 14510 14511 hunks.push(hunk); 14512 oldRangeStart = 0; 14513 newRangeStart = 0; 14514 curRange = []; 14515 } 14516 } 14517 14518 oldLine += lines.length; 14519 newLine += lines.length; 14520 } 14521 }; 14522 14523 for (var i = 0; i < diff.length; i++) { 14524 _loop(i); 14525 } 14526 14527 return { 14528 oldFileName: oldFileName, 14529 newFileName: newFileName, 14530 oldHeader: oldHeader, 14531 newHeader: newHeader, 14532 hunks: hunks 14533 }; 14534 } 14535 14536 function formatPatch(diff) { 14537 var ret = []; 14538 14539 if (diff.oldFileName == diff.newFileName) { 14540 ret.push('Index: ' + diff.oldFileName); 14541 } 14542 14543 ret.push('==================================================================='); 14544 ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); 14545 ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); 14546 14547 for (var i = 0; i < diff.hunks.length; i++) { 14548 var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0, 14549 // the first number is one lower than one would expect. 14550 // https://www.artima.com/weblogs/viewpost.jsp?thread=164293 14551 14552 if (hunk.oldLines === 0) { 14553 hunk.oldStart -= 1; 14554 } 14555 14556 if (hunk.newLines === 0) { 14557 hunk.newStart -= 1; 14558 } 14559 14560 ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); 14561 ret.push.apply(ret, hunk.lines); 14562 } 14563 14564 return ret.join('\n') + '\n'; 14565 } 14566 14567 function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { 14568 return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options)); 14569 } 14570 14571 function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { 14572 return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); 14573 } 14574 14575 function arrayEqual(a, b) { 14576 if (a.length !== b.length) { 14577 return false; 14578 } 14579 14580 return arrayStartsWith(a, b); 14581 } 14582 14583 function arrayStartsWith(array, start) { 14584 if (start.length > array.length) { 14585 return false; 14586 } 14587 14588 for (var i = 0; i < start.length; i++) { 14589 if (start[i] !== array[i]) { 14590 return false; 14591 } 14592 } 14593 14594 return true; 14595 } 14596 14597 function calcLineCount(hunk) { 14598 var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines), 14599 oldLines = _calcOldNewLineCount.oldLines, 14600 newLines = _calcOldNewLineCount.newLines; 14601 14602 if (oldLines !== undefined) { 14603 hunk.oldLines = oldLines; 14604 } else { 14605 delete hunk.oldLines; 14606 } 14607 14608 if (newLines !== undefined) { 14609 hunk.newLines = newLines; 14610 } else { 14611 delete hunk.newLines; 14612 } 14613 } 14614 14615 function merge(mine, theirs, base) { 14616 mine = loadPatch(mine, base); 14617 theirs = loadPatch(theirs, base); 14618 var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning. 14619 // Leaving sanity checks on this to the API consumer that may know more about the 14620 // meaning in their own context. 14621 14622 if (mine.index || theirs.index) { 14623 ret.index = mine.index || theirs.index; 14624 } 14625 14626 if (mine.newFileName || theirs.newFileName) { 14627 if (!fileNameChanged(mine)) { 14628 // No header or no change in ours, use theirs (and ours if theirs does not exist) 14629 ret.oldFileName = theirs.oldFileName || mine.oldFileName; 14630 ret.newFileName = theirs.newFileName || mine.newFileName; 14631 ret.oldHeader = theirs.oldHeader || mine.oldHeader; 14632 ret.newHeader = theirs.newHeader || mine.newHeader; 14633 } else if (!fileNameChanged(theirs)) { 14634 // No header or no change in theirs, use ours 14635 ret.oldFileName = mine.oldFileName; 14636 ret.newFileName = mine.newFileName; 14637 ret.oldHeader = mine.oldHeader; 14638 ret.newHeader = mine.newHeader; 14639 } else { 14640 // Both changed... figure it out 14641 ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); 14642 ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); 14643 ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); 14644 ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); 14645 } 14646 } 14647 14648 ret.hunks = []; 14649 var mineIndex = 0, 14650 theirsIndex = 0, 14651 mineOffset = 0, 14652 theirsOffset = 0; 14653 14654 while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { 14655 var mineCurrent = mine.hunks[mineIndex] || { 14656 oldStart: Infinity 14657 }, 14658 theirsCurrent = theirs.hunks[theirsIndex] || { 14659 oldStart: Infinity 14660 }; 14661 14662 if (hunkBefore(mineCurrent, theirsCurrent)) { 14663 // This patch does not overlap with any of the others, yay. 14664 ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); 14665 mineIndex++; 14666 theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; 14667 } else if (hunkBefore(theirsCurrent, mineCurrent)) { 14668 // This patch does not overlap with any of the others, yay. 14669 ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); 14670 theirsIndex++; 14671 mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; 14672 } else { 14673 // Overlap, merge as best we can 14674 var mergedHunk = { 14675 oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), 14676 oldLines: 0, 14677 newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), 14678 newLines: 0, 14679 lines: [] 14680 }; 14681 mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); 14682 theirsIndex++; 14683 mineIndex++; 14684 ret.hunks.push(mergedHunk); 14685 } 14686 } 14687 14688 return ret; 14689 } 14690 14691 function loadPatch(param, base) { 14692 if (typeof param === 'string') { 14693 if (/^@@/m.test(param) || /^Index:/m.test(param)) { 14694 return parsePatch(param)[0]; 14695 } 14696 14697 if (!base) { 14698 throw new Error('Must provide a base reference or pass in a patch'); 14699 } 14700 14701 return structuredPatch(undefined, undefined, base, param); 14702 } 14703 14704 return param; 14705 } 14706 14707 function fileNameChanged(patch) { 14708 return patch.newFileName && patch.newFileName !== patch.oldFileName; 14709 } 14710 14711 function selectField(index, mine, theirs) { 14712 if (mine === theirs) { 14713 return mine; 14714 } else { 14715 index.conflict = true; 14716 return { 14717 mine: mine, 14718 theirs: theirs 14719 }; 14720 } 14721 } 14722 14723 function hunkBefore(test, check) { 14724 return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; 14725 } 14726 14727 function cloneHunk(hunk, offset) { 14728 return { 14729 oldStart: hunk.oldStart, 14730 oldLines: hunk.oldLines, 14731 newStart: hunk.newStart + offset, 14732 newLines: hunk.newLines, 14733 lines: hunk.lines 14734 }; 14735 } 14736 14737 function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { 14738 // This will generally result in a conflicted hunk, but there are cases where the context 14739 // is the only overlap where we can successfully merge the content here. 14740 var mine = { 14741 offset: mineOffset, 14742 lines: mineLines, 14743 index: 0 14744 }, 14745 their = { 14746 offset: theirOffset, 14747 lines: theirLines, 14748 index: 0 14749 }; // Handle any leading content 14750 14751 insertLeading(hunk, mine, their); 14752 insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each. 14753 14754 while (mine.index < mine.lines.length && their.index < their.lines.length) { 14755 var mineCurrent = mine.lines[mine.index], 14756 theirCurrent = their.lines[their.index]; 14757 14758 if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { 14759 // Both modified ... 14760 mutualChange(hunk, mine, their); 14761 } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { 14762 var _hunk$lines; // Mine inserted 14763 14764 14765 (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine))); 14766 } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { 14767 var _hunk$lines2; // Theirs inserted 14768 14769 14770 (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their))); 14771 } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { 14772 // Mine removed or edited 14773 removal(hunk, mine, their); 14774 } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { 14775 // Their removed or edited 14776 removal(hunk, their, mine, true); 14777 } else if (mineCurrent === theirCurrent) { 14778 // Context identity 14779 hunk.lines.push(mineCurrent); 14780 mine.index++; 14781 their.index++; 14782 } else { 14783 // Context mismatch 14784 conflict(hunk, collectChange(mine), collectChange(their)); 14785 } 14786 } // Now push anything that may be remaining 14787 14788 14789 insertTrailing(hunk, mine); 14790 insertTrailing(hunk, their); 14791 calcLineCount(hunk); 14792 } 14793 14794 function mutualChange(hunk, mine, their) { 14795 var myChanges = collectChange(mine), 14796 theirChanges = collectChange(their); 14797 14798 if (allRemoves(myChanges) && allRemoves(theirChanges)) { 14799 // Special case for remove changes that are supersets of one another 14800 if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { 14801 var _hunk$lines3; 14802 14803 (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges)); 14804 14805 return; 14806 } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { 14807 var _hunk$lines4; 14808 14809 (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges)); 14810 14811 return; 14812 } 14813 } else if (arrayEqual(myChanges, theirChanges)) { 14814 var _hunk$lines5; 14815 14816 (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges)); 14817 14818 return; 14819 } 14820 14821 conflict(hunk, myChanges, theirChanges); 14822 } 14823 14824 function removal(hunk, mine, their, swap) { 14825 var myChanges = collectChange(mine), 14826 theirChanges = collectContext(their, myChanges); 14827 14828 if (theirChanges.merged) { 14829 var _hunk$lines6; 14830 14831 (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged)); 14832 } else { 14833 conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); 14834 } 14835 } 14836 14837 function conflict(hunk, mine, their) { 14838 hunk.conflict = true; 14839 hunk.lines.push({ 14840 conflict: true, 14841 mine: mine, 14842 theirs: their 14843 }); 14844 } 14845 14846 function insertLeading(hunk, insert, their) { 14847 while (insert.offset < their.offset && insert.index < insert.lines.length) { 14848 var line = insert.lines[insert.index++]; 14849 hunk.lines.push(line); 14850 insert.offset++; 14851 } 14852 } 14853 14854 function insertTrailing(hunk, insert) { 14855 while (insert.index < insert.lines.length) { 14856 var line = insert.lines[insert.index++]; 14857 hunk.lines.push(line); 14858 } 14859 } 14860 14861 function collectChange(state) { 14862 var ret = [], 14863 operation = state.lines[state.index][0]; 14864 14865 while (state.index < state.lines.length) { 14866 var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. 14867 14868 if (operation === '-' && line[0] === '+') { 14869 operation = '+'; 14870 } 14871 14872 if (operation === line[0]) { 14873 ret.push(line); 14874 state.index++; 14875 } else { 14876 break; 14877 } 14878 } 14879 14880 return ret; 14881 } 14882 14883 function collectContext(state, matchChanges) { 14884 var changes = [], 14885 merged = [], 14886 matchIndex = 0, 14887 contextChanges = false, 14888 conflicted = false; 14889 14890 while (matchIndex < matchChanges.length && state.index < state.lines.length) { 14891 var change = state.lines[state.index], 14892 match = matchChanges[matchIndex]; // Once we've hit our add, then we are done 14893 14894 if (match[0] === '+') { 14895 break; 14896 } 14897 14898 contextChanges = contextChanges || change[0] !== ' '; 14899 merged.push(match); 14900 matchIndex++; // Consume any additions in the other block as a conflict to attempt 14901 // to pull in the remaining context after this 14902 14903 if (change[0] === '+') { 14904 conflicted = true; 14905 14906 while (change[0] === '+') { 14907 changes.push(change); 14908 change = state.lines[++state.index]; 14909 } 14910 } 14911 14912 if (match.substr(1) === change.substr(1)) { 14913 changes.push(change); 14914 state.index++; 14915 } else { 14916 conflicted = true; 14917 } 14918 } 14919 14920 if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { 14921 conflicted = true; 14922 } 14923 14924 if (conflicted) { 14925 return changes; 14926 } 14927 14928 while (matchIndex < matchChanges.length) { 14929 merged.push(matchChanges[matchIndex++]); 14930 } 14931 14932 return { 14933 merged: merged, 14934 changes: changes 14935 }; 14936 } 14937 14938 function allRemoves(changes) { 14939 return changes.reduce(function (prev, change) { 14940 return prev && change[0] === '-'; 14941 }, true); 14942 } 14943 14944 function skipRemoveSuperset(state, removeChanges, delta) { 14945 for (var i = 0; i < delta; i++) { 14946 var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); 14947 14948 if (state.lines[state.index + i] !== ' ' + changeContent) { 14949 return false; 14950 } 14951 } 14952 14953 state.index += delta; 14954 return true; 14955 } 14956 14957 function calcOldNewLineCount(lines) { 14958 var oldLines = 0; 14959 var newLines = 0; 14960 lines.forEach(function (line) { 14961 if (typeof line !== 'string') { 14962 var myCount = calcOldNewLineCount(line.mine); 14963 var theirCount = calcOldNewLineCount(line.theirs); 14964 14965 if (oldLines !== undefined) { 14966 if (myCount.oldLines === theirCount.oldLines) { 14967 oldLines += myCount.oldLines; 14968 } else { 14969 oldLines = undefined; 14970 } 14971 } 14972 14973 if (newLines !== undefined) { 14974 if (myCount.newLines === theirCount.newLines) { 14975 newLines += myCount.newLines; 14976 } else { 14977 newLines = undefined; 14978 } 14979 } 14980 } else { 14981 if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { 14982 newLines++; 14983 } 14984 14985 if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { 14986 oldLines++; 14987 } 14988 } 14989 }); 14990 return { 14991 oldLines: oldLines, 14992 newLines: newLines 14993 }; 14994 } // See: http://code.google.com/p/google-diff-match-patch/wiki/API 14995 14996 14997 function convertChangesToDMP(changes) { 14998 var ret = [], 14999 change, 15000 operation; 15001 15002 for (var i = 0; i < changes.length; i++) { 15003 change = changes[i]; 15004 15005 if (change.added) { 15006 operation = 1; 15007 } else if (change.removed) { 15008 operation = -1; 15009 } else { 15010 operation = 0; 15011 } 15012 15013 ret.push([operation, change.value]); 15014 } 15015 15016 return ret; 15017 } 15018 15019 function convertChangesToXML(changes) { 15020 var ret = []; 15021 15022 for (var i = 0; i < changes.length; i++) { 15023 var change = changes[i]; 15024 15025 if (change.added) { 15026 ret.push('<ins>'); 15027 } else if (change.removed) { 15028 ret.push('<del>'); 15029 } 15030 15031 ret.push(escapeHTML(change.value)); 15032 15033 if (change.added) { 15034 ret.push('</ins>'); 15035 } else if (change.removed) { 15036 ret.push('</del>'); 15037 } 15038 } 15039 15040 return ret.join(''); 15041 } 15042 15043 function escapeHTML(s) { 15044 var n = s; 15045 n = n.replace(/&/g, '&'); 15046 n = n.replace(/</g, '<'); 15047 n = n.replace(/>/g, '>'); 15048 n = n.replace(/"/g, '"'); 15049 return n; 15050 } 15051 15052 exports.Diff = Diff; 15053 exports.applyPatch = applyPatch; 15054 exports.applyPatches = applyPatches; 15055 exports.canonicalize = canonicalize; 15056 exports.convertChangesToDMP = convertChangesToDMP; 15057 exports.convertChangesToXML = convertChangesToXML; 15058 exports.createPatch = createPatch; 15059 exports.createTwoFilesPatch = createTwoFilesPatch; 15060 exports.diffArrays = diffArrays; 15061 exports.diffChars = diffChars; 15062 exports.diffCss = diffCss; 15063 exports.diffJson = diffJson; 15064 exports.diffLines = diffLines; 15065 exports.diffSentences = diffSentences; 15066 exports.diffTrimmedLines = diffTrimmedLines; 15067 exports.diffWords = diffWords; 15068 exports.diffWordsWithSpace = diffWordsWithSpace; 15069 exports.merge = merge; 15070 exports.parsePatch = parsePatch; 15071 exports.structuredPatch = structuredPatch; 15072 Object.defineProperty(exports, '__esModule', { 15073 value: true 15074 }); 15075 }); 15076 }); 15077 15078 /** 15079 * Helpers. 15080 */ 15081 var s = 1000; 15082 var m = s * 60; 15083 var h = m * 60; 15084 var d = h * 24; 15085 var w = d * 7; 15086 var y = d * 365.25; 15087 /** 15088 * Parse or format the given `val`. 15089 * 15090 * Options: 15091 * 15092 * - `long` verbose formatting [false] 15093 * 15094 * @param {String|Number} val 15095 * @param {Object} [options] 15096 * @throws {Error} throw an error if val is not a non-empty string or a number 15097 * @return {String|Number} 15098 * @api public 15099 */ 15100 15101 var ms = function ms(val, options) { 15102 options = options || {}; 15103 15104 var type = _typeof(val); 15105 15106 if (type === 'string' && val.length > 0) { 15107 return parse(val); 15108 } else if (type === 'number' && isFinite(val)) { 15109 return options["long"] ? fmtLong(val) : fmtShort(val); 15110 } 15111 15112 throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)); 15113 }; 15114 /** 15115 * Parse the given `str` and return milliseconds. 15116 * 15117 * @param {String} str 15118 * @return {Number} 15119 * @api private 15120 */ 15121 15122 15123 function parse(str) { 15124 str = String(str); 15125 15126 if (str.length > 100) { 15127 return; 15128 } 15129 15130 var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); 15131 15132 if (!match) { 15133 return; 15134 } 15135 15136 var n = parseFloat(match[1]); 15137 var type = (match[2] || 'ms').toLowerCase(); 15138 15139 switch (type) { 15140 case 'years': 15141 case 'year': 15142 case 'yrs': 15143 case 'yr': 15144 case 'y': 15145 return n * y; 15146 15147 case 'weeks': 15148 case 'week': 15149 case 'w': 15150 return n * w; 15151 15152 case 'days': 15153 case 'day': 15154 case 'd': 15155 return n * d; 15156 15157 case 'hours': 15158 case 'hour': 15159 case 'hrs': 15160 case 'hr': 15161 case 'h': 15162 return n * h; 15163 15164 case 'minutes': 15165 case 'minute': 15166 case 'mins': 15167 case 'min': 15168 case 'm': 15169 return n * m; 15170 15171 case 'seconds': 15172 case 'second': 15173 case 'secs': 15174 case 'sec': 15175 case 's': 15176 return n * s; 15177 15178 case 'milliseconds': 15179 case 'millisecond': 15180 case 'msecs': 15181 case 'msec': 15182 case 'ms': 15183 return n; 15184 15185 default: 15186 return undefined; 15187 } 15188 } 15189 /** 15190 * Short format for `ms`. 15191 * 15192 * @param {Number} ms 15193 * @return {String} 15194 * @api private 15195 */ 15196 15197 15198 function fmtShort(ms) { 15199 var msAbs = Math.abs(ms); 15200 15201 if (msAbs >= d) { 15202 return Math.round(ms / d) + 'd'; 15203 } 15204 15205 if (msAbs >= h) { 15206 return Math.round(ms / h) + 'h'; 15207 } 15208 15209 if (msAbs >= m) { 15210 return Math.round(ms / m) + 'm'; 15211 } 15212 15213 if (msAbs >= s) { 15214 return Math.round(ms / s) + 's'; 15215 } 15216 15217 return ms + 'ms'; 15218 } 15219 /** 15220 * Long format for `ms`. 15221 * 15222 * @param {Number} ms 15223 * @return {String} 15224 * @api private 15225 */ 15226 15227 15228 function fmtLong(ms) { 15229 var msAbs = Math.abs(ms); 15230 15231 if (msAbs >= d) { 15232 return plural(ms, msAbs, d, 'day'); 15233 } 15234 15235 if (msAbs >= h) { 15236 return plural(ms, msAbs, h, 'hour'); 15237 } 15238 15239 if (msAbs >= m) { 15240 return plural(ms, msAbs, m, 'minute'); 15241 } 15242 15243 if (msAbs >= s) { 15244 return plural(ms, msAbs, s, 'second'); 15245 } 15246 15247 return ms + ' ms'; 15248 } 15249 /** 15250 * Pluralization helper. 15251 */ 15252 15253 15254 function plural(ms, msAbs, n, name) { 15255 var isPlural = msAbs >= n * 1.5; 15256 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); 15257 } 15258 15259 var freezing = !fails(function () { 15260 return Object.isExtensible(Object.preventExtensions({})); 15261 }); 15262 15263 var internalMetadata = createCommonjsModule(function (module) { 15264 var defineProperty = objectDefineProperty.f; 15265 15266 15267 15268 var METADATA = uid('meta'); 15269 var id = 0; 15270 15271 var isExtensible = Object.isExtensible || function () { 15272 return true; 15273 }; 15274 15275 var setMetadata = function (it) { 15276 defineProperty(it, METADATA, { value: { 15277 objectID: 'O' + ++id, // object ID 15278 weakData: {} // weak collections IDs 15279 } }); 15280 }; 15281 15282 var fastKey = function (it, create) { 15283 // return a primitive with prefix 15284 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; 15285 if (!has(it, METADATA)) { 15286 // can't set metadata to uncaught frozen object 15287 if (!isExtensible(it)) return 'F'; 15288 // not necessary to add metadata 15289 if (!create) return 'E'; 15290 // add missing metadata 15291 setMetadata(it); 15292 // return object ID 15293 } return it[METADATA].objectID; 15294 }; 15295 15296 var getWeakData = function (it, create) { 15297 if (!has(it, METADATA)) { 15298 // can't set metadata to uncaught frozen object 15299 if (!isExtensible(it)) return true; 15300 // not necessary to add metadata 15301 if (!create) return false; 15302 // add missing metadata 15303 setMetadata(it); 15304 // return the store of weak collections IDs 15305 } return it[METADATA].weakData; 15306 }; 15307 15308 // add metadata on freeze-family methods calling 15309 var onFreeze = function (it) { 15310 if (freezing && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it); 15311 return it; 15312 }; 15313 15314 var meta = module.exports = { 15315 REQUIRED: false, 15316 fastKey: fastKey, 15317 getWeakData: getWeakData, 15318 onFreeze: onFreeze 15319 }; 15320 15321 hiddenKeys[METADATA] = true; 15322 }); 15323 15324 var onFreeze = internalMetadata.onFreeze; 15325 15326 var nativeFreeze = Object.freeze; 15327 var FAILS_ON_PRIMITIVES$4 = fails(function () { nativeFreeze(1); }); 15328 15329 // `Object.freeze` method 15330 // https://tc39.es/ecma262/#sec-object.freeze 15331 _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$4, sham: !freezing }, { 15332 freeze: function freeze(it) { 15333 return nativeFreeze && isObject(it) ? nativeFreeze(onFreeze(it)) : it; 15334 } 15335 }); 15336 15337 var collection = function (CONSTRUCTOR_NAME, wrapper, common) { 15338 var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1; 15339 var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1; 15340 var ADDER = IS_MAP ? 'set' : 'add'; 15341 var NativeConstructor = global_1[CONSTRUCTOR_NAME]; 15342 var NativePrototype = NativeConstructor && NativeConstructor.prototype; 15343 var Constructor = NativeConstructor; 15344 var exported = {}; 15345 15346 var fixMethod = function (KEY) { 15347 var nativeMethod = NativePrototype[KEY]; 15348 redefine(NativePrototype, KEY, 15349 KEY == 'add' ? function add(value) { 15350 nativeMethod.call(this, value === 0 ? 0 : value); 15351 return this; 15352 } : KEY == 'delete' ? function (key) { 15353 return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key); 15354 } : KEY == 'get' ? function get(key) { 15355 return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key); 15356 } : KEY == 'has' ? function has(key) { 15357 return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key); 15358 } : function set(key, value) { 15359 nativeMethod.call(this, key === 0 ? 0 : key, value); 15360 return this; 15361 } 15362 ); 15363 }; 15364 15365 // eslint-disable-next-line max-len 15366 if (isForced_1(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () { 15367 new NativeConstructor().entries().next(); 15368 })))) { 15369 // create collection constructor 15370 Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER); 15371 internalMetadata.REQUIRED = true; 15372 } else if (isForced_1(CONSTRUCTOR_NAME, true)) { 15373 var instance = new Constructor(); 15374 // early implementations not supports chaining 15375 var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; 15376 // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false 15377 var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); }); 15378 // most early implementations doesn't supports iterables, most modern - not close it correctly 15379 // eslint-disable-next-line no-new 15380 var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); }); 15381 // for early implementations -0 and +0 not the same 15382 var BUGGY_ZERO = !IS_WEAK && fails(function () { 15383 // V8 ~ Chromium 42- fails only with 5+ elements 15384 var $instance = new NativeConstructor(); 15385 var index = 5; 15386 while (index--) $instance[ADDER](index, index); 15387 return !$instance.has(-0); 15388 }); 15389 15390 if (!ACCEPT_ITERABLES) { 15391 Constructor = wrapper(function (dummy, iterable) { 15392 anInstance(dummy, Constructor, CONSTRUCTOR_NAME); 15393 var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor); 15394 if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); 15395 return that; 15396 }); 15397 Constructor.prototype = NativePrototype; 15398 NativePrototype.constructor = Constructor; 15399 } 15400 15401 if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { 15402 fixMethod('delete'); 15403 fixMethod('has'); 15404 IS_MAP && fixMethod('get'); 15405 } 15406 15407 if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); 15408 15409 // weak collections should not contains .clear method 15410 if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear; 15411 } 15412 15413 exported[CONSTRUCTOR_NAME] = Constructor; 15414 _export({ global: true, forced: Constructor != NativeConstructor }, exported); 15415 15416 setToStringTag(Constructor, CONSTRUCTOR_NAME); 15417 15418 if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP); 15419 15420 return Constructor; 15421 }; 15422 15423 var defineProperty$a = objectDefineProperty.f; 15424 15425 15426 15427 15428 15429 15430 15431 15432 var fastKey = internalMetadata.fastKey; 15433 15434 15435 var setInternalState$6 = internalState.set; 15436 var internalStateGetterFor = internalState.getterFor; 15437 15438 var collectionStrong = { 15439 getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) { 15440 var C = wrapper(function (that, iterable) { 15441 anInstance(that, C, CONSTRUCTOR_NAME); 15442 setInternalState$6(that, { 15443 type: CONSTRUCTOR_NAME, 15444 index: objectCreate(null), 15445 first: undefined, 15446 last: undefined, 15447 size: 0 15448 }); 15449 if (!descriptors) that.size = 0; 15450 if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); 15451 }); 15452 15453 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME); 15454 15455 var define = function (that, key, value) { 15456 var state = getInternalState(that); 15457 var entry = getEntry(that, key); 15458 var previous, index; 15459 // change existing entry 15460 if (entry) { 15461 entry.value = value; 15462 // create new entry 15463 } else { 15464 state.last = entry = { 15465 index: index = fastKey(key, true), 15466 key: key, 15467 value: value, 15468 previous: previous = state.last, 15469 next: undefined, 15470 removed: false 15471 }; 15472 if (!state.first) state.first = entry; 15473 if (previous) previous.next = entry; 15474 if (descriptors) state.size++; 15475 else that.size++; 15476 // add to index 15477 if (index !== 'F') state.index[index] = entry; 15478 } return that; 15479 }; 15480 15481 var getEntry = function (that, key) { 15482 var state = getInternalState(that); 15483 // fast case 15484 var index = fastKey(key); 15485 var entry; 15486 if (index !== 'F') return state.index[index]; 15487 // frozen object case 15488 for (entry = state.first; entry; entry = entry.next) { 15489 if (entry.key == key) return entry; 15490 } 15491 }; 15492 15493 redefineAll(C.prototype, { 15494 // 23.1.3.1 Map.prototype.clear() 15495 // 23.2.3.2 Set.prototype.clear() 15496 clear: function clear() { 15497 var that = this; 15498 var state = getInternalState(that); 15499 var data = state.index; 15500 var entry = state.first; 15501 while (entry) { 15502 entry.removed = true; 15503 if (entry.previous) entry.previous = entry.previous.next = undefined; 15504 delete data[entry.index]; 15505 entry = entry.next; 15506 } 15507 state.first = state.last = undefined; 15508 if (descriptors) state.size = 0; 15509 else that.size = 0; 15510 }, 15511 // 23.1.3.3 Map.prototype.delete(key) 15512 // 23.2.3.4 Set.prototype.delete(value) 15513 'delete': function (key) { 15514 var that = this; 15515 var state = getInternalState(that); 15516 var entry = getEntry(that, key); 15517 if (entry) { 15518 var next = entry.next; 15519 var prev = entry.previous; 15520 delete state.index[entry.index]; 15521 entry.removed = true; 15522 if (prev) prev.next = next; 15523 if (next) next.previous = prev; 15524 if (state.first == entry) state.first = next; 15525 if (state.last == entry) state.last = prev; 15526 if (descriptors) state.size--; 15527 else that.size--; 15528 } return !!entry; 15529 }, 15530 // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) 15531 // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) 15532 forEach: function forEach(callbackfn /* , that = undefined */) { 15533 var state = getInternalState(this); 15534 var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); 15535 var entry; 15536 while (entry = entry ? entry.next : state.first) { 15537 boundFunction(entry.value, entry.key, this); 15538 // revert to the last existing entry 15539 while (entry && entry.removed) entry = entry.previous; 15540 } 15541 }, 15542 // 23.1.3.7 Map.prototype.has(key) 15543 // 23.2.3.7 Set.prototype.has(value) 15544 has: function has(key) { 15545 return !!getEntry(this, key); 15546 } 15547 }); 15548 15549 redefineAll(C.prototype, IS_MAP ? { 15550 // 23.1.3.6 Map.prototype.get(key) 15551 get: function get(key) { 15552 var entry = getEntry(this, key); 15553 return entry && entry.value; 15554 }, 15555 // 23.1.3.9 Map.prototype.set(key, value) 15556 set: function set(key, value) { 15557 return define(this, key === 0 ? 0 : key, value); 15558 } 15559 } : { 15560 // 23.2.3.1 Set.prototype.add(value) 15561 add: function add(value) { 15562 return define(this, value = value === 0 ? 0 : value, value); 15563 } 15564 }); 15565 if (descriptors) defineProperty$a(C.prototype, 'size', { 15566 get: function () { 15567 return getInternalState(this).size; 15568 } 15569 }); 15570 return C; 15571 }, 15572 setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) { 15573 var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator'; 15574 var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME); 15575 var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); 15576 // add .keys, .values, .entries, [@@iterator] 15577 // 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 15578 defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) { 15579 setInternalState$6(this, { 15580 type: ITERATOR_NAME, 15581 target: iterated, 15582 state: getInternalCollectionState(iterated), 15583 kind: kind, 15584 last: undefined 15585 }); 15586 }, function () { 15587 var state = getInternalIteratorState(this); 15588 var kind = state.kind; 15589 var entry = state.last; 15590 // revert to the last existing entry 15591 while (entry && entry.removed) entry = entry.previous; 15592 // get next entry 15593 if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) { 15594 // or finish the iteration 15595 state.target = undefined; 15596 return { value: undefined, done: true }; 15597 } 15598 // return step by kind 15599 if (kind == 'keys') return { value: entry.key, done: false }; 15600 if (kind == 'values') return { value: entry.value, done: false }; 15601 return { value: [entry.key, entry.value], done: false }; 15602 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); 15603 15604 // add [@@species], 23.1.2.2, 23.2.2.2 15605 setSpecies(CONSTRUCTOR_NAME); 15606 } 15607 }; 15608 15609 // `Set` constructor 15610 // https://tc39.es/ecma262/#sec-set-objects 15611 collection('Set', function (init) { 15612 return function Set() { return init(this, arguments.length ? arguments[0] : undefined); }; 15613 }, collectionStrong); 15614 15615 var browser$1 = true; 15616 15617 // This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped 15618 // optimize the gzip compression for this alphabet. 15619 var urlAlphabet = 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'; 15620 15621 var customAlphabet = function customAlphabet(alphabet, size) { 15622 return function () { 15623 var id = ''; // A compact alternative for `for (var i = 0; i < step; i++)`. 15624 15625 var i = size; 15626 15627 while (i--) { 15628 // `| 0` is more compact and faster than `Math.floor()`. 15629 id += alphabet[Math.random() * alphabet.length | 0]; 15630 } 15631 15632 return id; 15633 }; 15634 }; 15635 15636 var nanoid = function nanoid() { 15637 var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21; 15638 var id = ''; // A compact alternative for `for (var i = 0; i < step; i++)`. 15639 15640 var i = size; 15641 15642 while (i--) { 15643 // `| 0` is more compact and faster than `Math.floor()`. 15644 id += urlAlphabet[Math.random() * 64 | 0]; 15645 } 15646 15647 return id; 15648 }; 15649 15650 var nonSecure = /*#__PURE__*/Object.freeze({ 15651 __proto__: null, 15652 nanoid: nanoid, 15653 customAlphabet: customAlphabet 15654 }); 15655 15656 var he = createCommonjsModule(function (module, exports) { 15657 15658 (function (root) { 15659 // Detect free variables `exports`. 15660 var freeExports = exports; // Detect free variable `module`. 15661 15662 var freeModule = module && module.exports == freeExports && module; // Detect free variable `global`, from Node.js or Browserified code, 15663 // and use it as `root`. 15664 15665 var freeGlobal = _typeof(commonjsGlobal) == 'object' && commonjsGlobal; 15666 15667 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { 15668 root = freeGlobal; 15669 } 15670 /*--------------------------------------------------------------------------*/ 15671 // All astral symbols. 15672 15673 15674 var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; // All ASCII symbols (not just printable ASCII) except those listed in the 15675 // first column of the overrides table. 15676 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides 15677 15678 var regexAsciiWhitelist = /[\x01-\x7F]/g; // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or 15679 // code points listed in the first column of the overrides table on 15680 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides. 15681 15682 var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g; 15683 var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g; 15684 var encodeMap = { 15685 '\xAD': 'shy', 15686 "\u200C": 'zwnj', 15687 "\u200D": 'zwj', 15688 "\u200E": 'lrm', 15689 "\u2063": 'ic', 15690 "\u2062": 'it', 15691 "\u2061": 'af', 15692 "\u200F": 'rlm', 15693 "\u200B": 'ZeroWidthSpace', 15694 "\u2060": 'NoBreak', 15695 "\u0311": 'DownBreve', 15696 "\u20DB": 'tdot', 15697 "\u20DC": 'DotDot', 15698 '\t': 'Tab', 15699 '\n': 'NewLine', 15700 "\u2008": 'puncsp', 15701 "\u205F": 'MediumSpace', 15702 "\u2009": 'thinsp', 15703 "\u200A": 'hairsp', 15704 "\u2004": 'emsp13', 15705 "\u2002": 'ensp', 15706 "\u2005": 'emsp14', 15707 "\u2003": 'emsp', 15708 "\u2007": 'numsp', 15709 '\xA0': 'nbsp', 15710 "\u205F\u200A": 'ThickSpace', 15711 "\u203E": 'oline', 15712 '_': 'lowbar', 15713 "\u2010": 'dash', 15714 "\u2013": 'ndash', 15715 "\u2014": 'mdash', 15716 "\u2015": 'horbar', 15717 ',': 'comma', 15718 ';': 'semi', 15719 "\u204F": 'bsemi', 15720 ':': 'colon', 15721 "\u2A74": 'Colone', 15722 '!': 'excl', 15723 '\xA1': 'iexcl', 15724 '?': 'quest', 15725 '\xBF': 'iquest', 15726 '.': 'period', 15727 "\u2025": 'nldr', 15728 "\u2026": 'mldr', 15729 '\xB7': 'middot', 15730 '\'': 'apos', 15731 "\u2018": 'lsquo', 15732 "\u2019": 'rsquo', 15733 "\u201A": 'sbquo', 15734 "\u2039": 'lsaquo', 15735 "\u203A": 'rsaquo', 15736 '"': 'quot', 15737 "\u201C": 'ldquo', 15738 "\u201D": 'rdquo', 15739 "\u201E": 'bdquo', 15740 '\xAB': 'laquo', 15741 '\xBB': 'raquo', 15742 '(': 'lpar', 15743 ')': 'rpar', 15744 '[': 'lsqb', 15745 ']': 'rsqb', 15746 '{': 'lcub', 15747 '}': 'rcub', 15748 "\u2308": 'lceil', 15749 "\u2309": 'rceil', 15750 "\u230A": 'lfloor', 15751 "\u230B": 'rfloor', 15752 "\u2985": 'lopar', 15753 "\u2986": 'ropar', 15754 "\u298B": 'lbrke', 15755 "\u298C": 'rbrke', 15756 "\u298D": 'lbrkslu', 15757 "\u298E": 'rbrksld', 15758 "\u298F": 'lbrksld', 15759 "\u2990": 'rbrkslu', 15760 "\u2991": 'langd', 15761 "\u2992": 'rangd', 15762 "\u2993": 'lparlt', 15763 "\u2994": 'rpargt', 15764 "\u2995": 'gtlPar', 15765 "\u2996": 'ltrPar', 15766 "\u27E6": 'lobrk', 15767 "\u27E7": 'robrk', 15768 "\u27E8": 'lang', 15769 "\u27E9": 'rang', 15770 "\u27EA": 'Lang', 15771 "\u27EB": 'Rang', 15772 "\u27EC": 'loang', 15773 "\u27ED": 'roang', 15774 "\u2772": 'lbbrk', 15775 "\u2773": 'rbbrk', 15776 "\u2016": 'Vert', 15777 '\xA7': 'sect', 15778 '\xB6': 'para', 15779 '@': 'commat', 15780 '*': 'ast', 15781 '/': 'sol', 15782 'undefined': null, 15783 '&': 'amp', 15784 '#': 'num', 15785 '%': 'percnt', 15786 "\u2030": 'permil', 15787 "\u2031": 'pertenk', 15788 "\u2020": 'dagger', 15789 "\u2021": 'Dagger', 15790 "\u2022": 'bull', 15791 "\u2043": 'hybull', 15792 "\u2032": 'prime', 15793 "\u2033": 'Prime', 15794 "\u2034": 'tprime', 15795 "\u2057": 'qprime', 15796 "\u2035": 'bprime', 15797 "\u2041": 'caret', 15798 '`': 'grave', 15799 '\xB4': 'acute', 15800 "\u02DC": 'tilde', 15801 '^': 'Hat', 15802 '\xAF': 'macr', 15803 "\u02D8": 'breve', 15804 "\u02D9": 'dot', 15805 '\xA8': 'die', 15806 "\u02DA": 'ring', 15807 "\u02DD": 'dblac', 15808 '\xB8': 'cedil', 15809 "\u02DB": 'ogon', 15810 "\u02C6": 'circ', 15811 "\u02C7": 'caron', 15812 '\xB0': 'deg', 15813 '\xA9': 'copy', 15814 '\xAE': 'reg', 15815 "\u2117": 'copysr', 15816 "\u2118": 'wp', 15817 "\u211E": 'rx', 15818 "\u2127": 'mho', 15819 "\u2129": 'iiota', 15820 "\u2190": 'larr', 15821 "\u219A": 'nlarr', 15822 "\u2192": 'rarr', 15823 "\u219B": 'nrarr', 15824 "\u2191": 'uarr', 15825 "\u2193": 'darr', 15826 "\u2194": 'harr', 15827 "\u21AE": 'nharr', 15828 "\u2195": 'varr', 15829 "\u2196": 'nwarr', 15830 "\u2197": 'nearr', 15831 "\u2198": 'searr', 15832 "\u2199": 'swarr', 15833 "\u219D": 'rarrw', 15834 "\u219D\u0338": 'nrarrw', 15835 "\u219E": 'Larr', 15836 "\u219F": 'Uarr', 15837 "\u21A0": 'Rarr', 15838 "\u21A1": 'Darr', 15839 "\u21A2": 'larrtl', 15840 "\u21A3": 'rarrtl', 15841 "\u21A4": 'mapstoleft', 15842 "\u21A5": 'mapstoup', 15843 "\u21A6": 'map', 15844 "\u21A7": 'mapstodown', 15845 "\u21A9": 'larrhk', 15846 "\u21AA": 'rarrhk', 15847 "\u21AB": 'larrlp', 15848 "\u21AC": 'rarrlp', 15849 "\u21AD": 'harrw', 15850 "\u21B0": 'lsh', 15851 "\u21B1": 'rsh', 15852 "\u21B2": 'ldsh', 15853 "\u21B3": 'rdsh', 15854 "\u21B5": 'crarr', 15855 "\u21B6": 'cularr', 15856 "\u21B7": 'curarr', 15857 "\u21BA": 'olarr', 15858 "\u21BB": 'orarr', 15859 "\u21BC": 'lharu', 15860 "\u21BD": 'lhard', 15861 "\u21BE": 'uharr', 15862 "\u21BF": 'uharl', 15863 "\u21C0": 'rharu', 15864 "\u21C1": 'rhard', 15865 "\u21C2": 'dharr', 15866 "\u21C3": 'dharl', 15867 "\u21C4": 'rlarr', 15868 "\u21C5": 'udarr', 15869 "\u21C6": 'lrarr', 15870 "\u21C7": 'llarr', 15871 "\u21C8": 'uuarr', 15872 "\u21C9": 'rrarr', 15873 "\u21CA": 'ddarr', 15874 "\u21CB": 'lrhar', 15875 "\u21CC": 'rlhar', 15876 "\u21D0": 'lArr', 15877 "\u21CD": 'nlArr', 15878 "\u21D1": 'uArr', 15879 "\u21D2": 'rArr', 15880 "\u21CF": 'nrArr', 15881 "\u21D3": 'dArr', 15882 "\u21D4": 'iff', 15883 "\u21CE": 'nhArr', 15884 "\u21D5": 'vArr', 15885 "\u21D6": 'nwArr', 15886 "\u21D7": 'neArr', 15887 "\u21D8": 'seArr', 15888 "\u21D9": 'swArr', 15889 "\u21DA": 'lAarr', 15890 "\u21DB": 'rAarr', 15891 "\u21DD": 'zigrarr', 15892 "\u21E4": 'larrb', 15893 "\u21E5": 'rarrb', 15894 "\u21F5": 'duarr', 15895 "\u21FD": 'loarr', 15896 "\u21FE": 'roarr', 15897 "\u21FF": 'hoarr', 15898 "\u2200": 'forall', 15899 "\u2201": 'comp', 15900 "\u2202": 'part', 15901 "\u2202\u0338": 'npart', 15902 "\u2203": 'exist', 15903 "\u2204": 'nexist', 15904 "\u2205": 'empty', 15905 "\u2207": 'Del', 15906 "\u2208": 'in', 15907 "\u2209": 'notin', 15908 "\u220B": 'ni', 15909 "\u220C": 'notni', 15910 "\u03F6": 'bepsi', 15911 "\u220F": 'prod', 15912 "\u2210": 'coprod', 15913 "\u2211": 'sum', 15914 '+': 'plus', 15915 '\xB1': 'pm', 15916 '\xF7': 'div', 15917 '\xD7': 'times', 15918 '<': 'lt', 15919 "\u226E": 'nlt', 15920 "<\u20D2": 'nvlt', 15921 '=': 'equals', 15922 "\u2260": 'ne', 15923 "=\u20E5": 'bne', 15924 "\u2A75": 'Equal', 15925 '>': 'gt', 15926 "\u226F": 'ngt', 15927 ">\u20D2": 'nvgt', 15928 '\xAC': 'not', 15929 '|': 'vert', 15930 '\xA6': 'brvbar', 15931 "\u2212": 'minus', 15932 "\u2213": 'mp', 15933 "\u2214": 'plusdo', 15934 "\u2044": 'frasl', 15935 "\u2216": 'setmn', 15936 "\u2217": 'lowast', 15937 "\u2218": 'compfn', 15938 "\u221A": 'Sqrt', 15939 "\u221D": 'prop', 15940 "\u221E": 'infin', 15941 "\u221F": 'angrt', 15942 "\u2220": 'ang', 15943 "\u2220\u20D2": 'nang', 15944 "\u2221": 'angmsd', 15945 "\u2222": 'angsph', 15946 "\u2223": 'mid', 15947 "\u2224": 'nmid', 15948 "\u2225": 'par', 15949 "\u2226": 'npar', 15950 "\u2227": 'and', 15951 "\u2228": 'or', 15952 "\u2229": 'cap', 15953 "\u2229\uFE00": 'caps', 15954 "\u222A": 'cup', 15955 "\u222A\uFE00": 'cups', 15956 "\u222B": 'int', 15957 "\u222C": 'Int', 15958 "\u222D": 'tint', 15959 "\u2A0C": 'qint', 15960 "\u222E": 'oint', 15961 "\u222F": 'Conint', 15962 "\u2230": 'Cconint', 15963 "\u2231": 'cwint', 15964 "\u2232": 'cwconint', 15965 "\u2233": 'awconint', 15966 "\u2234": 'there4', 15967 "\u2235": 'becaus', 15968 "\u2236": 'ratio', 15969 "\u2237": 'Colon', 15970 "\u2238": 'minusd', 15971 "\u223A": 'mDDot', 15972 "\u223B": 'homtht', 15973 "\u223C": 'sim', 15974 "\u2241": 'nsim', 15975 "\u223C\u20D2": 'nvsim', 15976 "\u223D": 'bsim', 15977 "\u223D\u0331": 'race', 15978 "\u223E": 'ac', 15979 "\u223E\u0333": 'acE', 15980 "\u223F": 'acd', 15981 "\u2240": 'wr', 15982 "\u2242": 'esim', 15983 "\u2242\u0338": 'nesim', 15984 "\u2243": 'sime', 15985 "\u2244": 'nsime', 15986 "\u2245": 'cong', 15987 "\u2247": 'ncong', 15988 "\u2246": 'simne', 15989 "\u2248": 'ap', 15990 "\u2249": 'nap', 15991 "\u224A": 'ape', 15992 "\u224B": 'apid', 15993 "\u224B\u0338": 'napid', 15994 "\u224C": 'bcong', 15995 "\u224D": 'CupCap', 15996 "\u226D": 'NotCupCap', 15997 "\u224D\u20D2": 'nvap', 15998 "\u224E": 'bump', 15999 "\u224E\u0338": 'nbump', 16000 "\u224F": 'bumpe', 16001 "\u224F\u0338": 'nbumpe', 16002 "\u2250": 'doteq', 16003 "\u2250\u0338": 'nedot', 16004 "\u2251": 'eDot', 16005 "\u2252": 'efDot', 16006 "\u2253": 'erDot', 16007 "\u2254": 'colone', 16008 "\u2255": 'ecolon', 16009 "\u2256": 'ecir', 16010 "\u2257": 'cire', 16011 "\u2259": 'wedgeq', 16012 "\u225A": 'veeeq', 16013 "\u225C": 'trie', 16014 "\u225F": 'equest', 16015 "\u2261": 'equiv', 16016 "\u2262": 'nequiv', 16017 "\u2261\u20E5": 'bnequiv', 16018 "\u2264": 'le', 16019 "\u2270": 'nle', 16020 "\u2264\u20D2": 'nvle', 16021 "\u2265": 'ge', 16022 "\u2271": 'nge', 16023 "\u2265\u20D2": 'nvge', 16024 "\u2266": 'lE', 16025 "\u2266\u0338": 'nlE', 16026 "\u2267": 'gE', 16027 "\u2267\u0338": 'ngE', 16028 "\u2268\uFE00": 'lvnE', 16029 "\u2268": 'lnE', 16030 "\u2269": 'gnE', 16031 "\u2269\uFE00": 'gvnE', 16032 "\u226A": 'll', 16033 "\u226A\u0338": 'nLtv', 16034 "\u226A\u20D2": 'nLt', 16035 "\u226B": 'gg', 16036 "\u226B\u0338": 'nGtv', 16037 "\u226B\u20D2": 'nGt', 16038 "\u226C": 'twixt', 16039 "\u2272": 'lsim', 16040 "\u2274": 'nlsim', 16041 "\u2273": 'gsim', 16042 "\u2275": 'ngsim', 16043 "\u2276": 'lg', 16044 "\u2278": 'ntlg', 16045 "\u2277": 'gl', 16046 "\u2279": 'ntgl', 16047 "\u227A": 'pr', 16048 "\u2280": 'npr', 16049 "\u227B": 'sc', 16050 "\u2281": 'nsc', 16051 "\u227C": 'prcue', 16052 "\u22E0": 'nprcue', 16053 "\u227D": 'sccue', 16054 "\u22E1": 'nsccue', 16055 "\u227E": 'prsim', 16056 "\u227F": 'scsim', 16057 "\u227F\u0338": 'NotSucceedsTilde', 16058 "\u2282": 'sub', 16059 "\u2284": 'nsub', 16060 "\u2282\u20D2": 'vnsub', 16061 "\u2283": 'sup', 16062 "\u2285": 'nsup', 16063 "\u2283\u20D2": 'vnsup', 16064 "\u2286": 'sube', 16065 "\u2288": 'nsube', 16066 "\u2287": 'supe', 16067 "\u2289": 'nsupe', 16068 "\u228A\uFE00": 'vsubne', 16069 "\u228A": 'subne', 16070 "\u228B\uFE00": 'vsupne', 16071 "\u228B": 'supne', 16072 "\u228D": 'cupdot', 16073 "\u228E": 'uplus', 16074 "\u228F": 'sqsub', 16075 "\u228F\u0338": 'NotSquareSubset', 16076 "\u2290": 'sqsup', 16077 "\u2290\u0338": 'NotSquareSuperset', 16078 "\u2291": 'sqsube', 16079 "\u22E2": 'nsqsube', 16080 "\u2292": 'sqsupe', 16081 "\u22E3": 'nsqsupe', 16082 "\u2293": 'sqcap', 16083 "\u2293\uFE00": 'sqcaps', 16084 "\u2294": 'sqcup', 16085 "\u2294\uFE00": 'sqcups', 16086 "\u2295": 'oplus', 16087 "\u2296": 'ominus', 16088 "\u2297": 'otimes', 16089 "\u2298": 'osol', 16090 "\u2299": 'odot', 16091 "\u229A": 'ocir', 16092 "\u229B": 'oast', 16093 "\u229D": 'odash', 16094 "\u229E": 'plusb', 16095 "\u229F": 'minusb', 16096 "\u22A0": 'timesb', 16097 "\u22A1": 'sdotb', 16098 "\u22A2": 'vdash', 16099 "\u22AC": 'nvdash', 16100 "\u22A3": 'dashv', 16101 "\u22A4": 'top', 16102 "\u22A5": 'bot', 16103 "\u22A7": 'models', 16104 "\u22A8": 'vDash', 16105 "\u22AD": 'nvDash', 16106 "\u22A9": 'Vdash', 16107 "\u22AE": 'nVdash', 16108 "\u22AA": 'Vvdash', 16109 "\u22AB": 'VDash', 16110 "\u22AF": 'nVDash', 16111 "\u22B0": 'prurel', 16112 "\u22B2": 'vltri', 16113 "\u22EA": 'nltri', 16114 "\u22B3": 'vrtri', 16115 "\u22EB": 'nrtri', 16116 "\u22B4": 'ltrie', 16117 "\u22EC": 'nltrie', 16118 "\u22B4\u20D2": 'nvltrie', 16119 "\u22B5": 'rtrie', 16120 "\u22ED": 'nrtrie', 16121 "\u22B5\u20D2": 'nvrtrie', 16122 "\u22B6": 'origof', 16123 "\u22B7": 'imof', 16124 "\u22B8": 'mumap', 16125 "\u22B9": 'hercon', 16126 "\u22BA": 'intcal', 16127 "\u22BB": 'veebar', 16128 "\u22BD": 'barvee', 16129 "\u22BE": 'angrtvb', 16130 "\u22BF": 'lrtri', 16131 "\u22C0": 'Wedge', 16132 "\u22C1": 'Vee', 16133 "\u22C2": 'xcap', 16134 "\u22C3": 'xcup', 16135 "\u22C4": 'diam', 16136 "\u22C5": 'sdot', 16137 "\u22C6": 'Star', 16138 "\u22C7": 'divonx', 16139 "\u22C8": 'bowtie', 16140 "\u22C9": 'ltimes', 16141 "\u22CA": 'rtimes', 16142 "\u22CB": 'lthree', 16143 "\u22CC": 'rthree', 16144 "\u22CD": 'bsime', 16145 "\u22CE": 'cuvee', 16146 "\u22CF": 'cuwed', 16147 "\u22D0": 'Sub', 16148 "\u22D1": 'Sup', 16149 "\u22D2": 'Cap', 16150 "\u22D3": 'Cup', 16151 "\u22D4": 'fork', 16152 "\u22D5": 'epar', 16153 "\u22D6": 'ltdot', 16154 "\u22D7": 'gtdot', 16155 "\u22D8": 'Ll', 16156 "\u22D8\u0338": 'nLl', 16157 "\u22D9": 'Gg', 16158 "\u22D9\u0338": 'nGg', 16159 "\u22DA\uFE00": 'lesg', 16160 "\u22DA": 'leg', 16161 "\u22DB": 'gel', 16162 "\u22DB\uFE00": 'gesl', 16163 "\u22DE": 'cuepr', 16164 "\u22DF": 'cuesc', 16165 "\u22E6": 'lnsim', 16166 "\u22E7": 'gnsim', 16167 "\u22E8": 'prnsim', 16168 "\u22E9": 'scnsim', 16169 "\u22EE": 'vellip', 16170 "\u22EF": 'ctdot', 16171 "\u22F0": 'utdot', 16172 "\u22F1": 'dtdot', 16173 "\u22F2": 'disin', 16174 "\u22F3": 'isinsv', 16175 "\u22F4": 'isins', 16176 "\u22F5": 'isindot', 16177 "\u22F5\u0338": 'notindot', 16178 "\u22F6": 'notinvc', 16179 "\u22F7": 'notinvb', 16180 "\u22F9": 'isinE', 16181 "\u22F9\u0338": 'notinE', 16182 "\u22FA": 'nisd', 16183 "\u22FB": 'xnis', 16184 "\u22FC": 'nis', 16185 "\u22FD": 'notnivc', 16186 "\u22FE": 'notnivb', 16187 "\u2305": 'barwed', 16188 "\u2306": 'Barwed', 16189 "\u230C": 'drcrop', 16190 "\u230D": 'dlcrop', 16191 "\u230E": 'urcrop', 16192 "\u230F": 'ulcrop', 16193 "\u2310": 'bnot', 16194 "\u2312": 'profline', 16195 "\u2313": 'profsurf', 16196 "\u2315": 'telrec', 16197 "\u2316": 'target', 16198 "\u231C": 'ulcorn', 16199 "\u231D": 'urcorn', 16200 "\u231E": 'dlcorn', 16201 "\u231F": 'drcorn', 16202 "\u2322": 'frown', 16203 "\u2323": 'smile', 16204 "\u232D": 'cylcty', 16205 "\u232E": 'profalar', 16206 "\u2336": 'topbot', 16207 "\u233D": 'ovbar', 16208 "\u233F": 'solbar', 16209 "\u237C": 'angzarr', 16210 "\u23B0": 'lmoust', 16211 "\u23B1": 'rmoust', 16212 "\u23B4": 'tbrk', 16213 "\u23B5": 'bbrk', 16214 "\u23B6": 'bbrktbrk', 16215 "\u23DC": 'OverParenthesis', 16216 "\u23DD": 'UnderParenthesis', 16217 "\u23DE": 'OverBrace', 16218 "\u23DF": 'UnderBrace', 16219 "\u23E2": 'trpezium', 16220 "\u23E7": 'elinters', 16221 "\u2423": 'blank', 16222 "\u2500": 'boxh', 16223 "\u2502": 'boxv', 16224 "\u250C": 'boxdr', 16225 "\u2510": 'boxdl', 16226 "\u2514": 'boxur', 16227 "\u2518": 'boxul', 16228 "\u251C": 'boxvr', 16229 "\u2524": 'boxvl', 16230 "\u252C": 'boxhd', 16231 "\u2534": 'boxhu', 16232 "\u253C": 'boxvh', 16233 "\u2550": 'boxH', 16234 "\u2551": 'boxV', 16235 "\u2552": 'boxdR', 16236 "\u2553": 'boxDr', 16237 "\u2554": 'boxDR', 16238 "\u2555": 'boxdL', 16239 "\u2556": 'boxDl', 16240 "\u2557": 'boxDL', 16241 "\u2558": 'boxuR', 16242 "\u2559": 'boxUr', 16243 "\u255A": 'boxUR', 16244 "\u255B": 'boxuL', 16245 "\u255C": 'boxUl', 16246 "\u255D": 'boxUL', 16247 "\u255E": 'boxvR', 16248 "\u255F": 'boxVr', 16249 "\u2560": 'boxVR', 16250 "\u2561": 'boxvL', 16251 "\u2562": 'boxVl', 16252 "\u2563": 'boxVL', 16253 "\u2564": 'boxHd', 16254 "\u2565": 'boxhD', 16255 "\u2566": 'boxHD', 16256 "\u2567": 'boxHu', 16257 "\u2568": 'boxhU', 16258 "\u2569": 'boxHU', 16259 "\u256A": 'boxvH', 16260 "\u256B": 'boxVh', 16261 "\u256C": 'boxVH', 16262 "\u2580": 'uhblk', 16263 "\u2584": 'lhblk', 16264 "\u2588": 'block', 16265 "\u2591": 'blk14', 16266 "\u2592": 'blk12', 16267 "\u2593": 'blk34', 16268 "\u25A1": 'squ', 16269 "\u25AA": 'squf', 16270 "\u25AB": 'EmptyVerySmallSquare', 16271 "\u25AD": 'rect', 16272 "\u25AE": 'marker', 16273 "\u25B1": 'fltns', 16274 "\u25B3": 'xutri', 16275 "\u25B4": 'utrif', 16276 "\u25B5": 'utri', 16277 "\u25B8": 'rtrif', 16278 "\u25B9": 'rtri', 16279 "\u25BD": 'xdtri', 16280 "\u25BE": 'dtrif', 16281 "\u25BF": 'dtri', 16282 "\u25C2": 'ltrif', 16283 "\u25C3": 'ltri', 16284 "\u25CA": 'loz', 16285 "\u25CB": 'cir', 16286 "\u25EC": 'tridot', 16287 "\u25EF": 'xcirc', 16288 "\u25F8": 'ultri', 16289 "\u25F9": 'urtri', 16290 "\u25FA": 'lltri', 16291 "\u25FB": 'EmptySmallSquare', 16292 "\u25FC": 'FilledSmallSquare', 16293 "\u2605": 'starf', 16294 "\u2606": 'star', 16295 "\u260E": 'phone', 16296 "\u2640": 'female', 16297 "\u2642": 'male', 16298 "\u2660": 'spades', 16299 "\u2663": 'clubs', 16300 "\u2665": 'hearts', 16301 "\u2666": 'diams', 16302 "\u266A": 'sung', 16303 "\u2713": 'check', 16304 "\u2717": 'cross', 16305 "\u2720": 'malt', 16306 "\u2736": 'sext', 16307 "\u2758": 'VerticalSeparator', 16308 "\u27C8": 'bsolhsub', 16309 "\u27C9": 'suphsol', 16310 "\u27F5": 'xlarr', 16311 "\u27F6": 'xrarr', 16312 "\u27F7": 'xharr', 16313 "\u27F8": 'xlArr', 16314 "\u27F9": 'xrArr', 16315 "\u27FA": 'xhArr', 16316 "\u27FC": 'xmap', 16317 "\u27FF": 'dzigrarr', 16318 "\u2902": 'nvlArr', 16319 "\u2903": 'nvrArr', 16320 "\u2904": 'nvHarr', 16321 "\u2905": 'Map', 16322 "\u290C": 'lbarr', 16323 "\u290D": 'rbarr', 16324 "\u290E": 'lBarr', 16325 "\u290F": 'rBarr', 16326 "\u2910": 'RBarr', 16327 "\u2911": 'DDotrahd', 16328 "\u2912": 'UpArrowBar', 16329 "\u2913": 'DownArrowBar', 16330 "\u2916": 'Rarrtl', 16331 "\u2919": 'latail', 16332 "\u291A": 'ratail', 16333 "\u291B": 'lAtail', 16334 "\u291C": 'rAtail', 16335 "\u291D": 'larrfs', 16336 "\u291E": 'rarrfs', 16337 "\u291F": 'larrbfs', 16338 "\u2920": 'rarrbfs', 16339 "\u2923": 'nwarhk', 16340 "\u2924": 'nearhk', 16341 "\u2925": 'searhk', 16342 "\u2926": 'swarhk', 16343 "\u2927": 'nwnear', 16344 "\u2928": 'toea', 16345 "\u2929": 'tosa', 16346 "\u292A": 'swnwar', 16347 "\u2933": 'rarrc', 16348 "\u2933\u0338": 'nrarrc', 16349 "\u2935": 'cudarrr', 16350 "\u2936": 'ldca', 16351 "\u2937": 'rdca', 16352 "\u2938": 'cudarrl', 16353 "\u2939": 'larrpl', 16354 "\u293C": 'curarrm', 16355 "\u293D": 'cularrp', 16356 "\u2945": 'rarrpl', 16357 "\u2948": 'harrcir', 16358 "\u2949": 'Uarrocir', 16359 "\u294A": 'lurdshar', 16360 "\u294B": 'ldrushar', 16361 "\u294E": 'LeftRightVector', 16362 "\u294F": 'RightUpDownVector', 16363 "\u2950": 'DownLeftRightVector', 16364 "\u2951": 'LeftUpDownVector', 16365 "\u2952": 'LeftVectorBar', 16366 "\u2953": 'RightVectorBar', 16367 "\u2954": 'RightUpVectorBar', 16368 "\u2955": 'RightDownVectorBar', 16369 "\u2956": 'DownLeftVectorBar', 16370 "\u2957": 'DownRightVectorBar', 16371 "\u2958": 'LeftUpVectorBar', 16372 "\u2959": 'LeftDownVectorBar', 16373 "\u295A": 'LeftTeeVector', 16374 "\u295B": 'RightTeeVector', 16375 "\u295C": 'RightUpTeeVector', 16376 "\u295D": 'RightDownTeeVector', 16377 "\u295E": 'DownLeftTeeVector', 16378 "\u295F": 'DownRightTeeVector', 16379 "\u2960": 'LeftUpTeeVector', 16380 "\u2961": 'LeftDownTeeVector', 16381 "\u2962": 'lHar', 16382 "\u2963": 'uHar', 16383 "\u2964": 'rHar', 16384 "\u2965": 'dHar', 16385 "\u2966": 'luruhar', 16386 "\u2967": 'ldrdhar', 16387 "\u2968": 'ruluhar', 16388 "\u2969": 'rdldhar', 16389 "\u296A": 'lharul', 16390 "\u296B": 'llhard', 16391 "\u296C": 'rharul', 16392 "\u296D": 'lrhard', 16393 "\u296E": 'udhar', 16394 "\u296F": 'duhar', 16395 "\u2970": 'RoundImplies', 16396 "\u2971": 'erarr', 16397 "\u2972": 'simrarr', 16398 "\u2973": 'larrsim', 16399 "\u2974": 'rarrsim', 16400 "\u2975": 'rarrap', 16401 "\u2976": 'ltlarr', 16402 "\u2978": 'gtrarr', 16403 "\u2979": 'subrarr', 16404 "\u297B": 'suplarr', 16405 "\u297C": 'lfisht', 16406 "\u297D": 'rfisht', 16407 "\u297E": 'ufisht', 16408 "\u297F": 'dfisht', 16409 "\u299A": 'vzigzag', 16410 "\u299C": 'vangrt', 16411 "\u299D": 'angrtvbd', 16412 "\u29A4": 'ange', 16413 "\u29A5": 'range', 16414 "\u29A6": 'dwangle', 16415 "\u29A7": 'uwangle', 16416 "\u29A8": 'angmsdaa', 16417 "\u29A9": 'angmsdab', 16418 "\u29AA": 'angmsdac', 16419 "\u29AB": 'angmsdad', 16420 "\u29AC": 'angmsdae', 16421 "\u29AD": 'angmsdaf', 16422 "\u29AE": 'angmsdag', 16423 "\u29AF": 'angmsdah', 16424 "\u29B0": 'bemptyv', 16425 "\u29B1": 'demptyv', 16426 "\u29B2": 'cemptyv', 16427 "\u29B3": 'raemptyv', 16428 "\u29B4": 'laemptyv', 16429 "\u29B5": 'ohbar', 16430 "\u29B6": 'omid', 16431 "\u29B7": 'opar', 16432 "\u29B9": 'operp', 16433 "\u29BB": 'olcross', 16434 "\u29BC": 'odsold', 16435 "\u29BE": 'olcir', 16436 "\u29BF": 'ofcir', 16437 "\u29C0": 'olt', 16438 "\u29C1": 'ogt', 16439 "\u29C2": 'cirscir', 16440 "\u29C3": 'cirE', 16441 "\u29C4": 'solb', 16442 "\u29C5": 'bsolb', 16443 "\u29C9": 'boxbox', 16444 "\u29CD": 'trisb', 16445 "\u29CE": 'rtriltri', 16446 "\u29CF": 'LeftTriangleBar', 16447 "\u29CF\u0338": 'NotLeftTriangleBar', 16448 "\u29D0": 'RightTriangleBar', 16449 "\u29D0\u0338": 'NotRightTriangleBar', 16450 "\u29DC": 'iinfin', 16451 "\u29DD": 'infintie', 16452 "\u29DE": 'nvinfin', 16453 "\u29E3": 'eparsl', 16454 "\u29E4": 'smeparsl', 16455 "\u29E5": 'eqvparsl', 16456 "\u29EB": 'lozf', 16457 "\u29F4": 'RuleDelayed', 16458 "\u29F6": 'dsol', 16459 "\u2A00": 'xodot', 16460 "\u2A01": 'xoplus', 16461 "\u2A02": 'xotime', 16462 "\u2A04": 'xuplus', 16463 "\u2A06": 'xsqcup', 16464 "\u2A0D": 'fpartint', 16465 "\u2A10": 'cirfnint', 16466 "\u2A11": 'awint', 16467 "\u2A12": 'rppolint', 16468 "\u2A13": 'scpolint', 16469 "\u2A14": 'npolint', 16470 "\u2A15": 'pointint', 16471 "\u2A16": 'quatint', 16472 "\u2A17": 'intlarhk', 16473 "\u2A22": 'pluscir', 16474 "\u2A23": 'plusacir', 16475 "\u2A24": 'simplus', 16476 "\u2A25": 'plusdu', 16477 "\u2A26": 'plussim', 16478 "\u2A27": 'plustwo', 16479 "\u2A29": 'mcomma', 16480 "\u2A2A": 'minusdu', 16481 "\u2A2D": 'loplus', 16482 "\u2A2E": 'roplus', 16483 "\u2A2F": 'Cross', 16484 "\u2A30": 'timesd', 16485 "\u2A31": 'timesbar', 16486 "\u2A33": 'smashp', 16487 "\u2A34": 'lotimes', 16488 "\u2A35": 'rotimes', 16489 "\u2A36": 'otimesas', 16490 "\u2A37": 'Otimes', 16491 "\u2A38": 'odiv', 16492 "\u2A39": 'triplus', 16493 "\u2A3A": 'triminus', 16494 "\u2A3B": 'tritime', 16495 "\u2A3C": 'iprod', 16496 "\u2A3F": 'amalg', 16497 "\u2A40": 'capdot', 16498 "\u2A42": 'ncup', 16499 "\u2A43": 'ncap', 16500 "\u2A44": 'capand', 16501 "\u2A45": 'cupor', 16502 "\u2A46": 'cupcap', 16503 "\u2A47": 'capcup', 16504 "\u2A48": 'cupbrcap', 16505 "\u2A49": 'capbrcup', 16506 "\u2A4A": 'cupcup', 16507 "\u2A4B": 'capcap', 16508 "\u2A4C": 'ccups', 16509 "\u2A4D": 'ccaps', 16510 "\u2A50": 'ccupssm', 16511 "\u2A53": 'And', 16512 "\u2A54": 'Or', 16513 "\u2A55": 'andand', 16514 "\u2A56": 'oror', 16515 "\u2A57": 'orslope', 16516 "\u2A58": 'andslope', 16517 "\u2A5A": 'andv', 16518 "\u2A5B": 'orv', 16519 "\u2A5C": 'andd', 16520 "\u2A5D": 'ord', 16521 "\u2A5F": 'wedbar', 16522 "\u2A66": 'sdote', 16523 "\u2A6A": 'simdot', 16524 "\u2A6D": 'congdot', 16525 "\u2A6D\u0338": 'ncongdot', 16526 "\u2A6E": 'easter', 16527 "\u2A6F": 'apacir', 16528 "\u2A70": 'apE', 16529 "\u2A70\u0338": 'napE', 16530 "\u2A71": 'eplus', 16531 "\u2A72": 'pluse', 16532 "\u2A73": 'Esim', 16533 "\u2A77": 'eDDot', 16534 "\u2A78": 'equivDD', 16535 "\u2A79": 'ltcir', 16536 "\u2A7A": 'gtcir', 16537 "\u2A7B": 'ltquest', 16538 "\u2A7C": 'gtquest', 16539 "\u2A7D": 'les', 16540 "\u2A7D\u0338": 'nles', 16541 "\u2A7E": 'ges', 16542 "\u2A7E\u0338": 'nges', 16543 "\u2A7F": 'lesdot', 16544 "\u2A80": 'gesdot', 16545 "\u2A81": 'lesdoto', 16546 "\u2A82": 'gesdoto', 16547 "\u2A83": 'lesdotor', 16548 "\u2A84": 'gesdotol', 16549 "\u2A85": 'lap', 16550 "\u2A86": 'gap', 16551 "\u2A87": 'lne', 16552 "\u2A88": 'gne', 16553 "\u2A89": 'lnap', 16554 "\u2A8A": 'gnap', 16555 "\u2A8B": 'lEg', 16556 "\u2A8C": 'gEl', 16557 "\u2A8D": 'lsime', 16558 "\u2A8E": 'gsime', 16559 "\u2A8F": 'lsimg', 16560 "\u2A90": 'gsiml', 16561 "\u2A91": 'lgE', 16562 "\u2A92": 'glE', 16563 "\u2A93": 'lesges', 16564 "\u2A94": 'gesles', 16565 "\u2A95": 'els', 16566 "\u2A96": 'egs', 16567 "\u2A97": 'elsdot', 16568 "\u2A98": 'egsdot', 16569 "\u2A99": 'el', 16570 "\u2A9A": 'eg', 16571 "\u2A9D": 'siml', 16572 "\u2A9E": 'simg', 16573 "\u2A9F": 'simlE', 16574 "\u2AA0": 'simgE', 16575 "\u2AA1": 'LessLess', 16576 "\u2AA1\u0338": 'NotNestedLessLess', 16577 "\u2AA2": 'GreaterGreater', 16578 "\u2AA2\u0338": 'NotNestedGreaterGreater', 16579 "\u2AA4": 'glj', 16580 "\u2AA5": 'gla', 16581 "\u2AA6": 'ltcc', 16582 "\u2AA7": 'gtcc', 16583 "\u2AA8": 'lescc', 16584 "\u2AA9": 'gescc', 16585 "\u2AAA": 'smt', 16586 "\u2AAB": 'lat', 16587 "\u2AAC": 'smte', 16588 "\u2AAC\uFE00": 'smtes', 16589 "\u2AAD": 'late', 16590 "\u2AAD\uFE00": 'lates', 16591 "\u2AAE": 'bumpE', 16592 "\u2AAF": 'pre', 16593 "\u2AAF\u0338": 'npre', 16594 "\u2AB0": 'sce', 16595 "\u2AB0\u0338": 'nsce', 16596 "\u2AB3": 'prE', 16597 "\u2AB4": 'scE', 16598 "\u2AB5": 'prnE', 16599 "\u2AB6": 'scnE', 16600 "\u2AB7": 'prap', 16601 "\u2AB8": 'scap', 16602 "\u2AB9": 'prnap', 16603 "\u2ABA": 'scnap', 16604 "\u2ABB": 'Pr', 16605 "\u2ABC": 'Sc', 16606 "\u2ABD": 'subdot', 16607 "\u2ABE": 'supdot', 16608 "\u2ABF": 'subplus', 16609 "\u2AC0": 'supplus', 16610 "\u2AC1": 'submult', 16611 "\u2AC2": 'supmult', 16612 "\u2AC3": 'subedot', 16613 "\u2AC4": 'supedot', 16614 "\u2AC5": 'subE', 16615 "\u2AC5\u0338": 'nsubE', 16616 "\u2AC6": 'supE', 16617 "\u2AC6\u0338": 'nsupE', 16618 "\u2AC7": 'subsim', 16619 "\u2AC8": 'supsim', 16620 "\u2ACB\uFE00": 'vsubnE', 16621 "\u2ACB": 'subnE', 16622 "\u2ACC\uFE00": 'vsupnE', 16623 "\u2ACC": 'supnE', 16624 "\u2ACF": 'csub', 16625 "\u2AD0": 'csup', 16626 "\u2AD1": 'csube', 16627 "\u2AD2": 'csupe', 16628 "\u2AD3": 'subsup', 16629 "\u2AD4": 'supsub', 16630 "\u2AD5": 'subsub', 16631 "\u2AD6": 'supsup', 16632 "\u2AD7": 'suphsub', 16633 "\u2AD8": 'supdsub', 16634 "\u2AD9": 'forkv', 16635 "\u2ADA": 'topfork', 16636 "\u2ADB": 'mlcp', 16637 "\u2AE4": 'Dashv', 16638 "\u2AE6": 'Vdashl', 16639 "\u2AE7": 'Barv', 16640 "\u2AE8": 'vBar', 16641 "\u2AE9": 'vBarv', 16642 "\u2AEB": 'Vbar', 16643 "\u2AEC": 'Not', 16644 "\u2AED": 'bNot', 16645 "\u2AEE": 'rnmid', 16646 "\u2AEF": 'cirmid', 16647 "\u2AF0": 'midcir', 16648 "\u2AF1": 'topcir', 16649 "\u2AF2": 'nhpar', 16650 "\u2AF3": 'parsim', 16651 "\u2AFD": 'parsl', 16652 "\u2AFD\u20E5": 'nparsl', 16653 "\u266D": 'flat', 16654 "\u266E": 'natur', 16655 "\u266F": 'sharp', 16656 '\xA4': 'curren', 16657 '\xA2': 'cent', 16658 '$': 'dollar', 16659 '\xA3': 'pound', 16660 '\xA5': 'yen', 16661 "\u20AC": 'euro', 16662 '\xB9': 'sup1', 16663 '\xBD': 'half', 16664 "\u2153": 'frac13', 16665 '\xBC': 'frac14', 16666 "\u2155": 'frac15', 16667 "\u2159": 'frac16', 16668 "\u215B": 'frac18', 16669 '\xB2': 'sup2', 16670 "\u2154": 'frac23', 16671 "\u2156": 'frac25', 16672 '\xB3': 'sup3', 16673 '\xBE': 'frac34', 16674 "\u2157": 'frac35', 16675 "\u215C": 'frac38', 16676 "\u2158": 'frac45', 16677 "\u215A": 'frac56', 16678 "\u215D": 'frac58', 16679 "\u215E": 'frac78', 16680 "\uD835\uDCB6": 'ascr', 16681 "\uD835\uDD52": 'aopf', 16682 "\uD835\uDD1E": 'afr', 16683 "\uD835\uDD38": 'Aopf', 16684 "\uD835\uDD04": 'Afr', 16685 "\uD835\uDC9C": 'Ascr', 16686 '\xAA': 'ordf', 16687 '\xE1': 'aacute', 16688 '\xC1': 'Aacute', 16689 '\xE0': 'agrave', 16690 '\xC0': 'Agrave', 16691 "\u0103": 'abreve', 16692 "\u0102": 'Abreve', 16693 '\xE2': 'acirc', 16694 '\xC2': 'Acirc', 16695 '\xE5': 'aring', 16696 '\xC5': 'angst', 16697 '\xE4': 'auml', 16698 '\xC4': 'Auml', 16699 '\xE3': 'atilde', 16700 '\xC3': 'Atilde', 16701 "\u0105": 'aogon', 16702 "\u0104": 'Aogon', 16703 "\u0101": 'amacr', 16704 "\u0100": 'Amacr', 16705 '\xE6': 'aelig', 16706 '\xC6': 'AElig', 16707 "\uD835\uDCB7": 'bscr', 16708 "\uD835\uDD53": 'bopf', 16709 "\uD835\uDD1F": 'bfr', 16710 "\uD835\uDD39": 'Bopf', 16711 "\u212C": 'Bscr', 16712 "\uD835\uDD05": 'Bfr', 16713 "\uD835\uDD20": 'cfr', 16714 "\uD835\uDCB8": 'cscr', 16715 "\uD835\uDD54": 'copf', 16716 "\u212D": 'Cfr', 16717 "\uD835\uDC9E": 'Cscr', 16718 "\u2102": 'Copf', 16719 "\u0107": 'cacute', 16720 "\u0106": 'Cacute', 16721 "\u0109": 'ccirc', 16722 "\u0108": 'Ccirc', 16723 "\u010D": 'ccaron', 16724 "\u010C": 'Ccaron', 16725 "\u010B": 'cdot', 16726 "\u010A": 'Cdot', 16727 '\xE7': 'ccedil', 16728 '\xC7': 'Ccedil', 16729 "\u2105": 'incare', 16730 "\uD835\uDD21": 'dfr', 16731 "\u2146": 'dd', 16732 "\uD835\uDD55": 'dopf', 16733 "\uD835\uDCB9": 'dscr', 16734 "\uD835\uDC9F": 'Dscr', 16735 "\uD835\uDD07": 'Dfr', 16736 "\u2145": 'DD', 16737 "\uD835\uDD3B": 'Dopf', 16738 "\u010F": 'dcaron', 16739 "\u010E": 'Dcaron', 16740 "\u0111": 'dstrok', 16741 "\u0110": 'Dstrok', 16742 '\xF0': 'eth', 16743 '\xD0': 'ETH', 16744 "\u2147": 'ee', 16745 "\u212F": 'escr', 16746 "\uD835\uDD22": 'efr', 16747 "\uD835\uDD56": 'eopf', 16748 "\u2130": 'Escr', 16749 "\uD835\uDD08": 'Efr', 16750 "\uD835\uDD3C": 'Eopf', 16751 '\xE9': 'eacute', 16752 '\xC9': 'Eacute', 16753 '\xE8': 'egrave', 16754 '\xC8': 'Egrave', 16755 '\xEA': 'ecirc', 16756 '\xCA': 'Ecirc', 16757 "\u011B": 'ecaron', 16758 "\u011A": 'Ecaron', 16759 '\xEB': 'euml', 16760 '\xCB': 'Euml', 16761 "\u0117": 'edot', 16762 "\u0116": 'Edot', 16763 "\u0119": 'eogon', 16764 "\u0118": 'Eogon', 16765 "\u0113": 'emacr', 16766 "\u0112": 'Emacr', 16767 "\uD835\uDD23": 'ffr', 16768 "\uD835\uDD57": 'fopf', 16769 "\uD835\uDCBB": 'fscr', 16770 "\uD835\uDD09": 'Ffr', 16771 "\uD835\uDD3D": 'Fopf', 16772 "\u2131": 'Fscr', 16773 "\uFB00": 'fflig', 16774 "\uFB03": 'ffilig', 16775 "\uFB04": 'ffllig', 16776 "\uFB01": 'filig', 16777 'fj': 'fjlig', 16778 "\uFB02": 'fllig', 16779 "\u0192": 'fnof', 16780 "\u210A": 'gscr', 16781 "\uD835\uDD58": 'gopf', 16782 "\uD835\uDD24": 'gfr', 16783 "\uD835\uDCA2": 'Gscr', 16784 "\uD835\uDD3E": 'Gopf', 16785 "\uD835\uDD0A": 'Gfr', 16786 "\u01F5": 'gacute', 16787 "\u011F": 'gbreve', 16788 "\u011E": 'Gbreve', 16789 "\u011D": 'gcirc', 16790 "\u011C": 'Gcirc', 16791 "\u0121": 'gdot', 16792 "\u0120": 'Gdot', 16793 "\u0122": 'Gcedil', 16794 "\uD835\uDD25": 'hfr', 16795 "\u210E": 'planckh', 16796 "\uD835\uDCBD": 'hscr', 16797 "\uD835\uDD59": 'hopf', 16798 "\u210B": 'Hscr', 16799 "\u210C": 'Hfr', 16800 "\u210D": 'Hopf', 16801 "\u0125": 'hcirc', 16802 "\u0124": 'Hcirc', 16803 "\u210F": 'hbar', 16804 "\u0127": 'hstrok', 16805 "\u0126": 'Hstrok', 16806 "\uD835\uDD5A": 'iopf', 16807 "\uD835\uDD26": 'ifr', 16808 "\uD835\uDCBE": 'iscr', 16809 "\u2148": 'ii', 16810 "\uD835\uDD40": 'Iopf', 16811 "\u2110": 'Iscr', 16812 "\u2111": 'Im', 16813 '\xED': 'iacute', 16814 '\xCD': 'Iacute', 16815 '\xEC': 'igrave', 16816 '\xCC': 'Igrave', 16817 '\xEE': 'icirc', 16818 '\xCE': 'Icirc', 16819 '\xEF': 'iuml', 16820 '\xCF': 'Iuml', 16821 "\u0129": 'itilde', 16822 "\u0128": 'Itilde', 16823 "\u0130": 'Idot', 16824 "\u012F": 'iogon', 16825 "\u012E": 'Iogon', 16826 "\u012B": 'imacr', 16827 "\u012A": 'Imacr', 16828 "\u0133": 'ijlig', 16829 "\u0132": 'IJlig', 16830 "\u0131": 'imath', 16831 "\uD835\uDCBF": 'jscr', 16832 "\uD835\uDD5B": 'jopf', 16833 "\uD835\uDD27": 'jfr', 16834 "\uD835\uDCA5": 'Jscr', 16835 "\uD835\uDD0D": 'Jfr', 16836 "\uD835\uDD41": 'Jopf', 16837 "\u0135": 'jcirc', 16838 "\u0134": 'Jcirc', 16839 "\u0237": 'jmath', 16840 "\uD835\uDD5C": 'kopf', 16841 "\uD835\uDCC0": 'kscr', 16842 "\uD835\uDD28": 'kfr', 16843 "\uD835\uDCA6": 'Kscr', 16844 "\uD835\uDD42": 'Kopf', 16845 "\uD835\uDD0E": 'Kfr', 16846 "\u0137": 'kcedil', 16847 "\u0136": 'Kcedil', 16848 "\uD835\uDD29": 'lfr', 16849 "\uD835\uDCC1": 'lscr', 16850 "\u2113": 'ell', 16851 "\uD835\uDD5D": 'lopf', 16852 "\u2112": 'Lscr', 16853 "\uD835\uDD0F": 'Lfr', 16854 "\uD835\uDD43": 'Lopf', 16855 "\u013A": 'lacute', 16856 "\u0139": 'Lacute', 16857 "\u013E": 'lcaron', 16858 "\u013D": 'Lcaron', 16859 "\u013C": 'lcedil', 16860 "\u013B": 'Lcedil', 16861 "\u0142": 'lstrok', 16862 "\u0141": 'Lstrok', 16863 "\u0140": 'lmidot', 16864 "\u013F": 'Lmidot', 16865 "\uD835\uDD2A": 'mfr', 16866 "\uD835\uDD5E": 'mopf', 16867 "\uD835\uDCC2": 'mscr', 16868 "\uD835\uDD10": 'Mfr', 16869 "\uD835\uDD44": 'Mopf', 16870 "\u2133": 'Mscr', 16871 "\uD835\uDD2B": 'nfr', 16872 "\uD835\uDD5F": 'nopf', 16873 "\uD835\uDCC3": 'nscr', 16874 "\u2115": 'Nopf', 16875 "\uD835\uDCA9": 'Nscr', 16876 "\uD835\uDD11": 'Nfr', 16877 "\u0144": 'nacute', 16878 "\u0143": 'Nacute', 16879 "\u0148": 'ncaron', 16880 "\u0147": 'Ncaron', 16881 '\xF1': 'ntilde', 16882 '\xD1': 'Ntilde', 16883 "\u0146": 'ncedil', 16884 "\u0145": 'Ncedil', 16885 "\u2116": 'numero', 16886 "\u014B": 'eng', 16887 "\u014A": 'ENG', 16888 "\uD835\uDD60": 'oopf', 16889 "\uD835\uDD2C": 'ofr', 16890 "\u2134": 'oscr', 16891 "\uD835\uDCAA": 'Oscr', 16892 "\uD835\uDD12": 'Ofr', 16893 "\uD835\uDD46": 'Oopf', 16894 '\xBA': 'ordm', 16895 '\xF3': 'oacute', 16896 '\xD3': 'Oacute', 16897 '\xF2': 'ograve', 16898 '\xD2': 'Ograve', 16899 '\xF4': 'ocirc', 16900 '\xD4': 'Ocirc', 16901 '\xF6': 'ouml', 16902 '\xD6': 'Ouml', 16903 "\u0151": 'odblac', 16904 "\u0150": 'Odblac', 16905 '\xF5': 'otilde', 16906 '\xD5': 'Otilde', 16907 '\xF8': 'oslash', 16908 '\xD8': 'Oslash', 16909 "\u014D": 'omacr', 16910 "\u014C": 'Omacr', 16911 "\u0153": 'oelig', 16912 "\u0152": 'OElig', 16913 "\uD835\uDD2D": 'pfr', 16914 "\uD835\uDCC5": 'pscr', 16915 "\uD835\uDD61": 'popf', 16916 "\u2119": 'Popf', 16917 "\uD835\uDD13": 'Pfr', 16918 "\uD835\uDCAB": 'Pscr', 16919 "\uD835\uDD62": 'qopf', 16920 "\uD835\uDD2E": 'qfr', 16921 "\uD835\uDCC6": 'qscr', 16922 "\uD835\uDCAC": 'Qscr', 16923 "\uD835\uDD14": 'Qfr', 16924 "\u211A": 'Qopf', 16925 "\u0138": 'kgreen', 16926 "\uD835\uDD2F": 'rfr', 16927 "\uD835\uDD63": 'ropf', 16928 "\uD835\uDCC7": 'rscr', 16929 "\u211B": 'Rscr', 16930 "\u211C": 'Re', 16931 "\u211D": 'Ropf', 16932 "\u0155": 'racute', 16933 "\u0154": 'Racute', 16934 "\u0159": 'rcaron', 16935 "\u0158": 'Rcaron', 16936 "\u0157": 'rcedil', 16937 "\u0156": 'Rcedil', 16938 "\uD835\uDD64": 'sopf', 16939 "\uD835\uDCC8": 'sscr', 16940 "\uD835\uDD30": 'sfr', 16941 "\uD835\uDD4A": 'Sopf', 16942 "\uD835\uDD16": 'Sfr', 16943 "\uD835\uDCAE": 'Sscr', 16944 "\u24C8": 'oS', 16945 "\u015B": 'sacute', 16946 "\u015A": 'Sacute', 16947 "\u015D": 'scirc', 16948 "\u015C": 'Scirc', 16949 "\u0161": 'scaron', 16950 "\u0160": 'Scaron', 16951 "\u015F": 'scedil', 16952 "\u015E": 'Scedil', 16953 '\xDF': 'szlig', 16954 "\uD835\uDD31": 'tfr', 16955 "\uD835\uDCC9": 'tscr', 16956 "\uD835\uDD65": 'topf', 16957 "\uD835\uDCAF": 'Tscr', 16958 "\uD835\uDD17": 'Tfr', 16959 "\uD835\uDD4B": 'Topf', 16960 "\u0165": 'tcaron', 16961 "\u0164": 'Tcaron', 16962 "\u0163": 'tcedil', 16963 "\u0162": 'Tcedil', 16964 "\u2122": 'trade', 16965 "\u0167": 'tstrok', 16966 "\u0166": 'Tstrok', 16967 "\uD835\uDCCA": 'uscr', 16968 "\uD835\uDD66": 'uopf', 16969 "\uD835\uDD32": 'ufr', 16970 "\uD835\uDD4C": 'Uopf', 16971 "\uD835\uDD18": 'Ufr', 16972 "\uD835\uDCB0": 'Uscr', 16973 '\xFA': 'uacute', 16974 '\xDA': 'Uacute', 16975 '\xF9': 'ugrave', 16976 '\xD9': 'Ugrave', 16977 "\u016D": 'ubreve', 16978 "\u016C": 'Ubreve', 16979 '\xFB': 'ucirc', 16980 '\xDB': 'Ucirc', 16981 "\u016F": 'uring', 16982 "\u016E": 'Uring', 16983 '\xFC': 'uuml', 16984 '\xDC': 'Uuml', 16985 "\u0171": 'udblac', 16986 "\u0170": 'Udblac', 16987 "\u0169": 'utilde', 16988 "\u0168": 'Utilde', 16989 "\u0173": 'uogon', 16990 "\u0172": 'Uogon', 16991 "\u016B": 'umacr', 16992 "\u016A": 'Umacr', 16993 "\uD835\uDD33": 'vfr', 16994 "\uD835\uDD67": 'vopf', 16995 "\uD835\uDCCB": 'vscr', 16996 "\uD835\uDD19": 'Vfr', 16997 "\uD835\uDD4D": 'Vopf', 16998 "\uD835\uDCB1": 'Vscr', 16999 "\uD835\uDD68": 'wopf', 17000 "\uD835\uDCCC": 'wscr', 17001 "\uD835\uDD34": 'wfr', 17002 "\uD835\uDCB2": 'Wscr', 17003 "\uD835\uDD4E": 'Wopf', 17004 "\uD835\uDD1A": 'Wfr', 17005 "\u0175": 'wcirc', 17006 "\u0174": 'Wcirc', 17007 "\uD835\uDD35": 'xfr', 17008 "\uD835\uDCCD": 'xscr', 17009 "\uD835\uDD69": 'xopf', 17010 "\uD835\uDD4F": 'Xopf', 17011 "\uD835\uDD1B": 'Xfr', 17012 "\uD835\uDCB3": 'Xscr', 17013 "\uD835\uDD36": 'yfr', 17014 "\uD835\uDCCE": 'yscr', 17015 "\uD835\uDD6A": 'yopf', 17016 "\uD835\uDCB4": 'Yscr', 17017 "\uD835\uDD1C": 'Yfr', 17018 "\uD835\uDD50": 'Yopf', 17019 '\xFD': 'yacute', 17020 '\xDD': 'Yacute', 17021 "\u0177": 'ycirc', 17022 "\u0176": 'Ycirc', 17023 '\xFF': 'yuml', 17024 "\u0178": 'Yuml', 17025 "\uD835\uDCCF": 'zscr', 17026 "\uD835\uDD37": 'zfr', 17027 "\uD835\uDD6B": 'zopf', 17028 "\u2128": 'Zfr', 17029 "\u2124": 'Zopf', 17030 "\uD835\uDCB5": 'Zscr', 17031 "\u017A": 'zacute', 17032 "\u0179": 'Zacute', 17033 "\u017E": 'zcaron', 17034 "\u017D": 'Zcaron', 17035 "\u017C": 'zdot', 17036 "\u017B": 'Zdot', 17037 "\u01B5": 'imped', 17038 '\xFE': 'thorn', 17039 '\xDE': 'THORN', 17040 "\u0149": 'napos', 17041 "\u03B1": 'alpha', 17042 "\u0391": 'Alpha', 17043 "\u03B2": 'beta', 17044 "\u0392": 'Beta', 17045 "\u03B3": 'gamma', 17046 "\u0393": 'Gamma', 17047 "\u03B4": 'delta', 17048 "\u0394": 'Delta', 17049 "\u03B5": 'epsi', 17050 "\u03F5": 'epsiv', 17051 "\u0395": 'Epsilon', 17052 "\u03DD": 'gammad', 17053 "\u03DC": 'Gammad', 17054 "\u03B6": 'zeta', 17055 "\u0396": 'Zeta', 17056 "\u03B7": 'eta', 17057 "\u0397": 'Eta', 17058 "\u03B8": 'theta', 17059 "\u03D1": 'thetav', 17060 "\u0398": 'Theta', 17061 "\u03B9": 'iota', 17062 "\u0399": 'Iota', 17063 "\u03BA": 'kappa', 17064 "\u03F0": 'kappav', 17065 "\u039A": 'Kappa', 17066 "\u03BB": 'lambda', 17067 "\u039B": 'Lambda', 17068 "\u03BC": 'mu', 17069 '\xB5': 'micro', 17070 "\u039C": 'Mu', 17071 "\u03BD": 'nu', 17072 "\u039D": 'Nu', 17073 "\u03BE": 'xi', 17074 "\u039E": 'Xi', 17075 "\u03BF": 'omicron', 17076 "\u039F": 'Omicron', 17077 "\u03C0": 'pi', 17078 "\u03D6": 'piv', 17079 "\u03A0": 'Pi', 17080 "\u03C1": 'rho', 17081 "\u03F1": 'rhov', 17082 "\u03A1": 'Rho', 17083 "\u03C3": 'sigma', 17084 "\u03A3": 'Sigma', 17085 "\u03C2": 'sigmaf', 17086 "\u03C4": 'tau', 17087 "\u03A4": 'Tau', 17088 "\u03C5": 'upsi', 17089 "\u03A5": 'Upsilon', 17090 "\u03D2": 'Upsi', 17091 "\u03C6": 'phi', 17092 "\u03D5": 'phiv', 17093 "\u03A6": 'Phi', 17094 "\u03C7": 'chi', 17095 "\u03A7": 'Chi', 17096 "\u03C8": 'psi', 17097 "\u03A8": 'Psi', 17098 "\u03C9": 'omega', 17099 "\u03A9": 'ohm', 17100 "\u0430": 'acy', 17101 "\u0410": 'Acy', 17102 "\u0431": 'bcy', 17103 "\u0411": 'Bcy', 17104 "\u0432": 'vcy', 17105 "\u0412": 'Vcy', 17106 "\u0433": 'gcy', 17107 "\u0413": 'Gcy', 17108 "\u0453": 'gjcy', 17109 "\u0403": 'GJcy', 17110 "\u0434": 'dcy', 17111 "\u0414": 'Dcy', 17112 "\u0452": 'djcy', 17113 "\u0402": 'DJcy', 17114 "\u0435": 'iecy', 17115 "\u0415": 'IEcy', 17116 "\u0451": 'iocy', 17117 "\u0401": 'IOcy', 17118 "\u0454": 'jukcy', 17119 "\u0404": 'Jukcy', 17120 "\u0436": 'zhcy', 17121 "\u0416": 'ZHcy', 17122 "\u0437": 'zcy', 17123 "\u0417": 'Zcy', 17124 "\u0455": 'dscy', 17125 "\u0405": 'DScy', 17126 "\u0438": 'icy', 17127 "\u0418": 'Icy', 17128 "\u0456": 'iukcy', 17129 "\u0406": 'Iukcy', 17130 "\u0457": 'yicy', 17131 "\u0407": 'YIcy', 17132 "\u0439": 'jcy', 17133 "\u0419": 'Jcy', 17134 "\u0458": 'jsercy', 17135 "\u0408": 'Jsercy', 17136 "\u043A": 'kcy', 17137 "\u041A": 'Kcy', 17138 "\u045C": 'kjcy', 17139 "\u040C": 'KJcy', 17140 "\u043B": 'lcy', 17141 "\u041B": 'Lcy', 17142 "\u0459": 'ljcy', 17143 "\u0409": 'LJcy', 17144 "\u043C": 'mcy', 17145 "\u041C": 'Mcy', 17146 "\u043D": 'ncy', 17147 "\u041D": 'Ncy', 17148 "\u045A": 'njcy', 17149 "\u040A": 'NJcy', 17150 "\u043E": 'ocy', 17151 "\u041E": 'Ocy', 17152 "\u043F": 'pcy', 17153 "\u041F": 'Pcy', 17154 "\u0440": 'rcy', 17155 "\u0420": 'Rcy', 17156 "\u0441": 'scy', 17157 "\u0421": 'Scy', 17158 "\u0442": 'tcy', 17159 "\u0422": 'Tcy', 17160 "\u045B": 'tshcy', 17161 "\u040B": 'TSHcy', 17162 "\u0443": 'ucy', 17163 "\u0423": 'Ucy', 17164 "\u045E": 'ubrcy', 17165 "\u040E": 'Ubrcy', 17166 "\u0444": 'fcy', 17167 "\u0424": 'Fcy', 17168 "\u0445": 'khcy', 17169 "\u0425": 'KHcy', 17170 "\u0446": 'tscy', 17171 "\u0426": 'TScy', 17172 "\u0447": 'chcy', 17173 "\u0427": 'CHcy', 17174 "\u045F": 'dzcy', 17175 "\u040F": 'DZcy', 17176 "\u0448": 'shcy', 17177 "\u0428": 'SHcy', 17178 "\u0449": 'shchcy', 17179 "\u0429": 'SHCHcy', 17180 "\u044A": 'hardcy', 17181 "\u042A": 'HARDcy', 17182 "\u044B": 'ycy', 17183 "\u042B": 'Ycy', 17184 "\u044C": 'softcy', 17185 "\u042C": 'SOFTcy', 17186 "\u044D": 'ecy', 17187 "\u042D": 'Ecy', 17188 "\u044E": 'yucy', 17189 "\u042E": 'YUcy', 17190 "\u044F": 'yacy', 17191 "\u042F": 'YAcy', 17192 "\u2135": 'aleph', 17193 "\u2136": 'beth', 17194 "\u2137": 'gimel', 17195 "\u2138": 'daleth' 17196 }; 17197 var regexEscape = /["&'<>`]/g; 17198 var escapeMap = { 17199 '"': '"', 17200 '&': '&', 17201 '\'': ''', 17202 '<': '<', 17203 // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the 17204 // following is not strictly necessary unless it’s part of a tag or an 17205 // unquoted attribute value. We’re only escaping it to support those 17206 // situations, and for XML support. 17207 '>': '>', 17208 // In Internet Explorer ≤ 8, the backtick character can be used 17209 // to break out of (un)quoted attribute values or HTML comments. 17210 // See http://html5sec.org/#102, http://html5sec.org/#108, and 17211 // http://html5sec.org/#133. 17212 '`': '`' 17213 }; 17214 var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/; 17215 var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; 17216 var regexDecode = /&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g; 17217 var decodeMap = { 17218 'aacute': '\xE1', 17219 'Aacute': '\xC1', 17220 'abreve': "\u0103", 17221 'Abreve': "\u0102", 17222 'ac': "\u223E", 17223 'acd': "\u223F", 17224 'acE': "\u223E\u0333", 17225 'acirc': '\xE2', 17226 'Acirc': '\xC2', 17227 'acute': '\xB4', 17228 'acy': "\u0430", 17229 'Acy': "\u0410", 17230 'aelig': '\xE6', 17231 'AElig': '\xC6', 17232 'af': "\u2061", 17233 'afr': "\uD835\uDD1E", 17234 'Afr': "\uD835\uDD04", 17235 'agrave': '\xE0', 17236 'Agrave': '\xC0', 17237 'alefsym': "\u2135", 17238 'aleph': "\u2135", 17239 'alpha': "\u03B1", 17240 'Alpha': "\u0391", 17241 'amacr': "\u0101", 17242 'Amacr': "\u0100", 17243 'amalg': "\u2A3F", 17244 'amp': '&', 17245 'AMP': '&', 17246 'and': "\u2227", 17247 'And': "\u2A53", 17248 'andand': "\u2A55", 17249 'andd': "\u2A5C", 17250 'andslope': "\u2A58", 17251 'andv': "\u2A5A", 17252 'ang': "\u2220", 17253 'ange': "\u29A4", 17254 'angle': "\u2220", 17255 'angmsd': "\u2221", 17256 'angmsdaa': "\u29A8", 17257 'angmsdab': "\u29A9", 17258 'angmsdac': "\u29AA", 17259 'angmsdad': "\u29AB", 17260 'angmsdae': "\u29AC", 17261 'angmsdaf': "\u29AD", 17262 'angmsdag': "\u29AE", 17263 'angmsdah': "\u29AF", 17264 'angrt': "\u221F", 17265 'angrtvb': "\u22BE", 17266 'angrtvbd': "\u299D", 17267 'angsph': "\u2222", 17268 'angst': '\xC5', 17269 'angzarr': "\u237C", 17270 'aogon': "\u0105", 17271 'Aogon': "\u0104", 17272 'aopf': "\uD835\uDD52", 17273 'Aopf': "\uD835\uDD38", 17274 'ap': "\u2248", 17275 'apacir': "\u2A6F", 17276 'ape': "\u224A", 17277 'apE': "\u2A70", 17278 'apid': "\u224B", 17279 'apos': '\'', 17280 'ApplyFunction': "\u2061", 17281 'approx': "\u2248", 17282 'approxeq': "\u224A", 17283 'aring': '\xE5', 17284 'Aring': '\xC5', 17285 'ascr': "\uD835\uDCB6", 17286 'Ascr': "\uD835\uDC9C", 17287 'Assign': "\u2254", 17288 'ast': '*', 17289 'asymp': "\u2248", 17290 'asympeq': "\u224D", 17291 'atilde': '\xE3', 17292 'Atilde': '\xC3', 17293 'auml': '\xE4', 17294 'Auml': '\xC4', 17295 'awconint': "\u2233", 17296 'awint': "\u2A11", 17297 'backcong': "\u224C", 17298 'backepsilon': "\u03F6", 17299 'backprime': "\u2035", 17300 'backsim': "\u223D", 17301 'backsimeq': "\u22CD", 17302 'Backslash': "\u2216", 17303 'Barv': "\u2AE7", 17304 'barvee': "\u22BD", 17305 'barwed': "\u2305", 17306 'Barwed': "\u2306", 17307 'barwedge': "\u2305", 17308 'bbrk': "\u23B5", 17309 'bbrktbrk': "\u23B6", 17310 'bcong': "\u224C", 17311 'bcy': "\u0431", 17312 'Bcy': "\u0411", 17313 'bdquo': "\u201E", 17314 'becaus': "\u2235", 17315 'because': "\u2235", 17316 'Because': "\u2235", 17317 'bemptyv': "\u29B0", 17318 'bepsi': "\u03F6", 17319 'bernou': "\u212C", 17320 'Bernoullis': "\u212C", 17321 'beta': "\u03B2", 17322 'Beta': "\u0392", 17323 'beth': "\u2136", 17324 'between': "\u226C", 17325 'bfr': "\uD835\uDD1F", 17326 'Bfr': "\uD835\uDD05", 17327 'bigcap': "\u22C2", 17328 'bigcirc': "\u25EF", 17329 'bigcup': "\u22C3", 17330 'bigodot': "\u2A00", 17331 'bigoplus': "\u2A01", 17332 'bigotimes': "\u2A02", 17333 'bigsqcup': "\u2A06", 17334 'bigstar': "\u2605", 17335 'bigtriangledown': "\u25BD", 17336 'bigtriangleup': "\u25B3", 17337 'biguplus': "\u2A04", 17338 'bigvee': "\u22C1", 17339 'bigwedge': "\u22C0", 17340 'bkarow': "\u290D", 17341 'blacklozenge': "\u29EB", 17342 'blacksquare': "\u25AA", 17343 'blacktriangle': "\u25B4", 17344 'blacktriangledown': "\u25BE", 17345 'blacktriangleleft': "\u25C2", 17346 'blacktriangleright': "\u25B8", 17347 'blank': "\u2423", 17348 'blk12': "\u2592", 17349 'blk14': "\u2591", 17350 'blk34': "\u2593", 17351 'block': "\u2588", 17352 'bne': "=\u20E5", 17353 'bnequiv': "\u2261\u20E5", 17354 'bnot': "\u2310", 17355 'bNot': "\u2AED", 17356 'bopf': "\uD835\uDD53", 17357 'Bopf': "\uD835\uDD39", 17358 'bot': "\u22A5", 17359 'bottom': "\u22A5", 17360 'bowtie': "\u22C8", 17361 'boxbox': "\u29C9", 17362 'boxdl': "\u2510", 17363 'boxdL': "\u2555", 17364 'boxDl': "\u2556", 17365 'boxDL': "\u2557", 17366 'boxdr': "\u250C", 17367 'boxdR': "\u2552", 17368 'boxDr': "\u2553", 17369 'boxDR': "\u2554", 17370 'boxh': "\u2500", 17371 'boxH': "\u2550", 17372 'boxhd': "\u252C", 17373 'boxhD': "\u2565", 17374 'boxHd': "\u2564", 17375 'boxHD': "\u2566", 17376 'boxhu': "\u2534", 17377 'boxhU': "\u2568", 17378 'boxHu': "\u2567", 17379 'boxHU': "\u2569", 17380 'boxminus': "\u229F", 17381 'boxplus': "\u229E", 17382 'boxtimes': "\u22A0", 17383 'boxul': "\u2518", 17384 'boxuL': "\u255B", 17385 'boxUl': "\u255C", 17386 'boxUL': "\u255D", 17387 'boxur': "\u2514", 17388 'boxuR': "\u2558", 17389 'boxUr': "\u2559", 17390 'boxUR': "\u255A", 17391 'boxv': "\u2502", 17392 'boxV': "\u2551", 17393 'boxvh': "\u253C", 17394 'boxvH': "\u256A", 17395 'boxVh': "\u256B", 17396 'boxVH': "\u256C", 17397 'boxvl': "\u2524", 17398 'boxvL': "\u2561", 17399 'boxVl': "\u2562", 17400 'boxVL': "\u2563", 17401 'boxvr': "\u251C", 17402 'boxvR': "\u255E", 17403 'boxVr': "\u255F", 17404 'boxVR': "\u2560", 17405 'bprime': "\u2035", 17406 'breve': "\u02D8", 17407 'Breve': "\u02D8", 17408 'brvbar': '\xA6', 17409 'bscr': "\uD835\uDCB7", 17410 'Bscr': "\u212C", 17411 'bsemi': "\u204F", 17412 'bsim': "\u223D", 17413 'bsime': "\u22CD", 17414 'bsol': '\\', 17415 'bsolb': "\u29C5", 17416 'bsolhsub': "\u27C8", 17417 'bull': "\u2022", 17418 'bullet': "\u2022", 17419 'bump': "\u224E", 17420 'bumpe': "\u224F", 17421 'bumpE': "\u2AAE", 17422 'bumpeq': "\u224F", 17423 'Bumpeq': "\u224E", 17424 'cacute': "\u0107", 17425 'Cacute': "\u0106", 17426 'cap': "\u2229", 17427 'Cap': "\u22D2", 17428 'capand': "\u2A44", 17429 'capbrcup': "\u2A49", 17430 'capcap': "\u2A4B", 17431 'capcup': "\u2A47", 17432 'capdot': "\u2A40", 17433 'CapitalDifferentialD': "\u2145", 17434 'caps': "\u2229\uFE00", 17435 'caret': "\u2041", 17436 'caron': "\u02C7", 17437 'Cayleys': "\u212D", 17438 'ccaps': "\u2A4D", 17439 'ccaron': "\u010D", 17440 'Ccaron': "\u010C", 17441 'ccedil': '\xE7', 17442 'Ccedil': '\xC7', 17443 'ccirc': "\u0109", 17444 'Ccirc': "\u0108", 17445 'Cconint': "\u2230", 17446 'ccups': "\u2A4C", 17447 'ccupssm': "\u2A50", 17448 'cdot': "\u010B", 17449 'Cdot': "\u010A", 17450 'cedil': '\xB8', 17451 'Cedilla': '\xB8', 17452 'cemptyv': "\u29B2", 17453 'cent': '\xA2', 17454 'centerdot': '\xB7', 17455 'CenterDot': '\xB7', 17456 'cfr': "\uD835\uDD20", 17457 'Cfr': "\u212D", 17458 'chcy': "\u0447", 17459 'CHcy': "\u0427", 17460 'check': "\u2713", 17461 'checkmark': "\u2713", 17462 'chi': "\u03C7", 17463 'Chi': "\u03A7", 17464 'cir': "\u25CB", 17465 'circ': "\u02C6", 17466 'circeq': "\u2257", 17467 'circlearrowleft': "\u21BA", 17468 'circlearrowright': "\u21BB", 17469 'circledast': "\u229B", 17470 'circledcirc': "\u229A", 17471 'circleddash': "\u229D", 17472 'CircleDot': "\u2299", 17473 'circledR': '\xAE', 17474 'circledS': "\u24C8", 17475 'CircleMinus': "\u2296", 17476 'CirclePlus': "\u2295", 17477 'CircleTimes': "\u2297", 17478 'cire': "\u2257", 17479 'cirE': "\u29C3", 17480 'cirfnint': "\u2A10", 17481 'cirmid': "\u2AEF", 17482 'cirscir': "\u29C2", 17483 'ClockwiseContourIntegral': "\u2232", 17484 'CloseCurlyDoubleQuote': "\u201D", 17485 'CloseCurlyQuote': "\u2019", 17486 'clubs': "\u2663", 17487 'clubsuit': "\u2663", 17488 'colon': ':', 17489 'Colon': "\u2237", 17490 'colone': "\u2254", 17491 'Colone': "\u2A74", 17492 'coloneq': "\u2254", 17493 'comma': ',', 17494 'commat': '@', 17495 'comp': "\u2201", 17496 'compfn': "\u2218", 17497 'complement': "\u2201", 17498 'complexes': "\u2102", 17499 'cong': "\u2245", 17500 'congdot': "\u2A6D", 17501 'Congruent': "\u2261", 17502 'conint': "\u222E", 17503 'Conint': "\u222F", 17504 'ContourIntegral': "\u222E", 17505 'copf': "\uD835\uDD54", 17506 'Copf': "\u2102", 17507 'coprod': "\u2210", 17508 'Coproduct': "\u2210", 17509 'copy': '\xA9', 17510 'COPY': '\xA9', 17511 'copysr': "\u2117", 17512 'CounterClockwiseContourIntegral': "\u2233", 17513 'crarr': "\u21B5", 17514 'cross': "\u2717", 17515 'Cross': "\u2A2F", 17516 'cscr': "\uD835\uDCB8", 17517 'Cscr': "\uD835\uDC9E", 17518 'csub': "\u2ACF", 17519 'csube': "\u2AD1", 17520 'csup': "\u2AD0", 17521 'csupe': "\u2AD2", 17522 'ctdot': "\u22EF", 17523 'cudarrl': "\u2938", 17524 'cudarrr': "\u2935", 17525 'cuepr': "\u22DE", 17526 'cuesc': "\u22DF", 17527 'cularr': "\u21B6", 17528 'cularrp': "\u293D", 17529 'cup': "\u222A", 17530 'Cup': "\u22D3", 17531 'cupbrcap': "\u2A48", 17532 'cupcap': "\u2A46", 17533 'CupCap': "\u224D", 17534 'cupcup': "\u2A4A", 17535 'cupdot': "\u228D", 17536 'cupor': "\u2A45", 17537 'cups': "\u222A\uFE00", 17538 'curarr': "\u21B7", 17539 'curarrm': "\u293C", 17540 'curlyeqprec': "\u22DE", 17541 'curlyeqsucc': "\u22DF", 17542 'curlyvee': "\u22CE", 17543 'curlywedge': "\u22CF", 17544 'curren': '\xA4', 17545 'curvearrowleft': "\u21B6", 17546 'curvearrowright': "\u21B7", 17547 'cuvee': "\u22CE", 17548 'cuwed': "\u22CF", 17549 'cwconint': "\u2232", 17550 'cwint': "\u2231", 17551 'cylcty': "\u232D", 17552 'dagger': "\u2020", 17553 'Dagger': "\u2021", 17554 'daleth': "\u2138", 17555 'darr': "\u2193", 17556 'dArr': "\u21D3", 17557 'Darr': "\u21A1", 17558 'dash': "\u2010", 17559 'dashv': "\u22A3", 17560 'Dashv': "\u2AE4", 17561 'dbkarow': "\u290F", 17562 'dblac': "\u02DD", 17563 'dcaron': "\u010F", 17564 'Dcaron': "\u010E", 17565 'dcy': "\u0434", 17566 'Dcy': "\u0414", 17567 'dd': "\u2146", 17568 'DD': "\u2145", 17569 'ddagger': "\u2021", 17570 'ddarr': "\u21CA", 17571 'DDotrahd': "\u2911", 17572 'ddotseq': "\u2A77", 17573 'deg': '\xB0', 17574 'Del': "\u2207", 17575 'delta': "\u03B4", 17576 'Delta': "\u0394", 17577 'demptyv': "\u29B1", 17578 'dfisht': "\u297F", 17579 'dfr': "\uD835\uDD21", 17580 'Dfr': "\uD835\uDD07", 17581 'dHar': "\u2965", 17582 'dharl': "\u21C3", 17583 'dharr': "\u21C2", 17584 'DiacriticalAcute': '\xB4', 17585 'DiacriticalDot': "\u02D9", 17586 'DiacriticalDoubleAcute': "\u02DD", 17587 'DiacriticalGrave': '`', 17588 'DiacriticalTilde': "\u02DC", 17589 'diam': "\u22C4", 17590 'diamond': "\u22C4", 17591 'Diamond': "\u22C4", 17592 'diamondsuit': "\u2666", 17593 'diams': "\u2666", 17594 'die': '\xA8', 17595 'DifferentialD': "\u2146", 17596 'digamma': "\u03DD", 17597 'disin': "\u22F2", 17598 'div': '\xF7', 17599 'divide': '\xF7', 17600 'divideontimes': "\u22C7", 17601 'divonx': "\u22C7", 17602 'djcy': "\u0452", 17603 'DJcy': "\u0402", 17604 'dlcorn': "\u231E", 17605 'dlcrop': "\u230D", 17606 'dollar': '$', 17607 'dopf': "\uD835\uDD55", 17608 'Dopf': "\uD835\uDD3B", 17609 'dot': "\u02D9", 17610 'Dot': '\xA8', 17611 'DotDot': "\u20DC", 17612 'doteq': "\u2250", 17613 'doteqdot': "\u2251", 17614 'DotEqual': "\u2250", 17615 'dotminus': "\u2238", 17616 'dotplus': "\u2214", 17617 'dotsquare': "\u22A1", 17618 'doublebarwedge': "\u2306", 17619 'DoubleContourIntegral': "\u222F", 17620 'DoubleDot': '\xA8', 17621 'DoubleDownArrow': "\u21D3", 17622 'DoubleLeftArrow': "\u21D0", 17623 'DoubleLeftRightArrow': "\u21D4", 17624 'DoubleLeftTee': "\u2AE4", 17625 'DoubleLongLeftArrow': "\u27F8", 17626 'DoubleLongLeftRightArrow': "\u27FA", 17627 'DoubleLongRightArrow': "\u27F9", 17628 'DoubleRightArrow': "\u21D2", 17629 'DoubleRightTee': "\u22A8", 17630 'DoubleUpArrow': "\u21D1", 17631 'DoubleUpDownArrow': "\u21D5", 17632 'DoubleVerticalBar': "\u2225", 17633 'downarrow': "\u2193", 17634 'Downarrow': "\u21D3", 17635 'DownArrow': "\u2193", 17636 'DownArrowBar': "\u2913", 17637 'DownArrowUpArrow': "\u21F5", 17638 'DownBreve': "\u0311", 17639 'downdownarrows': "\u21CA", 17640 'downharpoonleft': "\u21C3", 17641 'downharpoonright': "\u21C2", 17642 'DownLeftRightVector': "\u2950", 17643 'DownLeftTeeVector': "\u295E", 17644 'DownLeftVector': "\u21BD", 17645 'DownLeftVectorBar': "\u2956", 17646 'DownRightTeeVector': "\u295F", 17647 'DownRightVector': "\u21C1", 17648 'DownRightVectorBar': "\u2957", 17649 'DownTee': "\u22A4", 17650 'DownTeeArrow': "\u21A7", 17651 'drbkarow': "\u2910", 17652 'drcorn': "\u231F", 17653 'drcrop': "\u230C", 17654 'dscr': "\uD835\uDCB9", 17655 'Dscr': "\uD835\uDC9F", 17656 'dscy': "\u0455", 17657 'DScy': "\u0405", 17658 'dsol': "\u29F6", 17659 'dstrok': "\u0111", 17660 'Dstrok': "\u0110", 17661 'dtdot': "\u22F1", 17662 'dtri': "\u25BF", 17663 'dtrif': "\u25BE", 17664 'duarr': "\u21F5", 17665 'duhar': "\u296F", 17666 'dwangle': "\u29A6", 17667 'dzcy': "\u045F", 17668 'DZcy': "\u040F", 17669 'dzigrarr': "\u27FF", 17670 'eacute': '\xE9', 17671 'Eacute': '\xC9', 17672 'easter': "\u2A6E", 17673 'ecaron': "\u011B", 17674 'Ecaron': "\u011A", 17675 'ecir': "\u2256", 17676 'ecirc': '\xEA', 17677 'Ecirc': '\xCA', 17678 'ecolon': "\u2255", 17679 'ecy': "\u044D", 17680 'Ecy': "\u042D", 17681 'eDDot': "\u2A77", 17682 'edot': "\u0117", 17683 'eDot': "\u2251", 17684 'Edot': "\u0116", 17685 'ee': "\u2147", 17686 'efDot': "\u2252", 17687 'efr': "\uD835\uDD22", 17688 'Efr': "\uD835\uDD08", 17689 'eg': "\u2A9A", 17690 'egrave': '\xE8', 17691 'Egrave': '\xC8', 17692 'egs': "\u2A96", 17693 'egsdot': "\u2A98", 17694 'el': "\u2A99", 17695 'Element': "\u2208", 17696 'elinters': "\u23E7", 17697 'ell': "\u2113", 17698 'els': "\u2A95", 17699 'elsdot': "\u2A97", 17700 'emacr': "\u0113", 17701 'Emacr': "\u0112", 17702 'empty': "\u2205", 17703 'emptyset': "\u2205", 17704 'EmptySmallSquare': "\u25FB", 17705 'emptyv': "\u2205", 17706 'EmptyVerySmallSquare': "\u25AB", 17707 'emsp': "\u2003", 17708 'emsp13': "\u2004", 17709 'emsp14': "\u2005", 17710 'eng': "\u014B", 17711 'ENG': "\u014A", 17712 'ensp': "\u2002", 17713 'eogon': "\u0119", 17714 'Eogon': "\u0118", 17715 'eopf': "\uD835\uDD56", 17716 'Eopf': "\uD835\uDD3C", 17717 'epar': "\u22D5", 17718 'eparsl': "\u29E3", 17719 'eplus': "\u2A71", 17720 'epsi': "\u03B5", 17721 'epsilon': "\u03B5", 17722 'Epsilon': "\u0395", 17723 'epsiv': "\u03F5", 17724 'eqcirc': "\u2256", 17725 'eqcolon': "\u2255", 17726 'eqsim': "\u2242", 17727 'eqslantgtr': "\u2A96", 17728 'eqslantless': "\u2A95", 17729 'Equal': "\u2A75", 17730 'equals': '=', 17731 'EqualTilde': "\u2242", 17732 'equest': "\u225F", 17733 'Equilibrium': "\u21CC", 17734 'equiv': "\u2261", 17735 'equivDD': "\u2A78", 17736 'eqvparsl': "\u29E5", 17737 'erarr': "\u2971", 17738 'erDot': "\u2253", 17739 'escr': "\u212F", 17740 'Escr': "\u2130", 17741 'esdot': "\u2250", 17742 'esim': "\u2242", 17743 'Esim': "\u2A73", 17744 'eta': "\u03B7", 17745 'Eta': "\u0397", 17746 'eth': '\xF0', 17747 'ETH': '\xD0', 17748 'euml': '\xEB', 17749 'Euml': '\xCB', 17750 'euro': "\u20AC", 17751 'excl': '!', 17752 'exist': "\u2203", 17753 'Exists': "\u2203", 17754 'expectation': "\u2130", 17755 'exponentiale': "\u2147", 17756 'ExponentialE': "\u2147", 17757 'fallingdotseq': "\u2252", 17758 'fcy': "\u0444", 17759 'Fcy': "\u0424", 17760 'female': "\u2640", 17761 'ffilig': "\uFB03", 17762 'fflig': "\uFB00", 17763 'ffllig': "\uFB04", 17764 'ffr': "\uD835\uDD23", 17765 'Ffr': "\uD835\uDD09", 17766 'filig': "\uFB01", 17767 'FilledSmallSquare': "\u25FC", 17768 'FilledVerySmallSquare': "\u25AA", 17769 'fjlig': 'fj', 17770 'flat': "\u266D", 17771 'fllig': "\uFB02", 17772 'fltns': "\u25B1", 17773 'fnof': "\u0192", 17774 'fopf': "\uD835\uDD57", 17775 'Fopf': "\uD835\uDD3D", 17776 'forall': "\u2200", 17777 'ForAll': "\u2200", 17778 'fork': "\u22D4", 17779 'forkv': "\u2AD9", 17780 'Fouriertrf': "\u2131", 17781 'fpartint': "\u2A0D", 17782 'frac12': '\xBD', 17783 'frac13': "\u2153", 17784 'frac14': '\xBC', 17785 'frac15': "\u2155", 17786 'frac16': "\u2159", 17787 'frac18': "\u215B", 17788 'frac23': "\u2154", 17789 'frac25': "\u2156", 17790 'frac34': '\xBE', 17791 'frac35': "\u2157", 17792 'frac38': "\u215C", 17793 'frac45': "\u2158", 17794 'frac56': "\u215A", 17795 'frac58': "\u215D", 17796 'frac78': "\u215E", 17797 'frasl': "\u2044", 17798 'frown': "\u2322", 17799 'fscr': "\uD835\uDCBB", 17800 'Fscr': "\u2131", 17801 'gacute': "\u01F5", 17802 'gamma': "\u03B3", 17803 'Gamma': "\u0393", 17804 'gammad': "\u03DD", 17805 'Gammad': "\u03DC", 17806 'gap': "\u2A86", 17807 'gbreve': "\u011F", 17808 'Gbreve': "\u011E", 17809 'Gcedil': "\u0122", 17810 'gcirc': "\u011D", 17811 'Gcirc': "\u011C", 17812 'gcy': "\u0433", 17813 'Gcy': "\u0413", 17814 'gdot': "\u0121", 17815 'Gdot': "\u0120", 17816 'ge': "\u2265", 17817 'gE': "\u2267", 17818 'gel': "\u22DB", 17819 'gEl': "\u2A8C", 17820 'geq': "\u2265", 17821 'geqq': "\u2267", 17822 'geqslant': "\u2A7E", 17823 'ges': "\u2A7E", 17824 'gescc': "\u2AA9", 17825 'gesdot': "\u2A80", 17826 'gesdoto': "\u2A82", 17827 'gesdotol': "\u2A84", 17828 'gesl': "\u22DB\uFE00", 17829 'gesles': "\u2A94", 17830 'gfr': "\uD835\uDD24", 17831 'Gfr': "\uD835\uDD0A", 17832 'gg': "\u226B", 17833 'Gg': "\u22D9", 17834 'ggg': "\u22D9", 17835 'gimel': "\u2137", 17836 'gjcy': "\u0453", 17837 'GJcy': "\u0403", 17838 'gl': "\u2277", 17839 'gla': "\u2AA5", 17840 'glE': "\u2A92", 17841 'glj': "\u2AA4", 17842 'gnap': "\u2A8A", 17843 'gnapprox': "\u2A8A", 17844 'gne': "\u2A88", 17845 'gnE': "\u2269", 17846 'gneq': "\u2A88", 17847 'gneqq': "\u2269", 17848 'gnsim': "\u22E7", 17849 'gopf': "\uD835\uDD58", 17850 'Gopf': "\uD835\uDD3E", 17851 'grave': '`', 17852 'GreaterEqual': "\u2265", 17853 'GreaterEqualLess': "\u22DB", 17854 'GreaterFullEqual': "\u2267", 17855 'GreaterGreater': "\u2AA2", 17856 'GreaterLess': "\u2277", 17857 'GreaterSlantEqual': "\u2A7E", 17858 'GreaterTilde': "\u2273", 17859 'gscr': "\u210A", 17860 'Gscr': "\uD835\uDCA2", 17861 'gsim': "\u2273", 17862 'gsime': "\u2A8E", 17863 'gsiml': "\u2A90", 17864 'gt': '>', 17865 'Gt': "\u226B", 17866 'GT': '>', 17867 'gtcc': "\u2AA7", 17868 'gtcir': "\u2A7A", 17869 'gtdot': "\u22D7", 17870 'gtlPar': "\u2995", 17871 'gtquest': "\u2A7C", 17872 'gtrapprox': "\u2A86", 17873 'gtrarr': "\u2978", 17874 'gtrdot': "\u22D7", 17875 'gtreqless': "\u22DB", 17876 'gtreqqless': "\u2A8C", 17877 'gtrless': "\u2277", 17878 'gtrsim': "\u2273", 17879 'gvertneqq': "\u2269\uFE00", 17880 'gvnE': "\u2269\uFE00", 17881 'Hacek': "\u02C7", 17882 'hairsp': "\u200A", 17883 'half': '\xBD', 17884 'hamilt': "\u210B", 17885 'hardcy': "\u044A", 17886 'HARDcy': "\u042A", 17887 'harr': "\u2194", 17888 'hArr': "\u21D4", 17889 'harrcir': "\u2948", 17890 'harrw': "\u21AD", 17891 'Hat': '^', 17892 'hbar': "\u210F", 17893 'hcirc': "\u0125", 17894 'Hcirc': "\u0124", 17895 'hearts': "\u2665", 17896 'heartsuit': "\u2665", 17897 'hellip': "\u2026", 17898 'hercon': "\u22B9", 17899 'hfr': "\uD835\uDD25", 17900 'Hfr': "\u210C", 17901 'HilbertSpace': "\u210B", 17902 'hksearow': "\u2925", 17903 'hkswarow': "\u2926", 17904 'hoarr': "\u21FF", 17905 'homtht': "\u223B", 17906 'hookleftarrow': "\u21A9", 17907 'hookrightarrow': "\u21AA", 17908 'hopf': "\uD835\uDD59", 17909 'Hopf': "\u210D", 17910 'horbar': "\u2015", 17911 'HorizontalLine': "\u2500", 17912 'hscr': "\uD835\uDCBD", 17913 'Hscr': "\u210B", 17914 'hslash': "\u210F", 17915 'hstrok': "\u0127", 17916 'Hstrok': "\u0126", 17917 'HumpDownHump': "\u224E", 17918 'HumpEqual': "\u224F", 17919 'hybull': "\u2043", 17920 'hyphen': "\u2010", 17921 'iacute': '\xED', 17922 'Iacute': '\xCD', 17923 'ic': "\u2063", 17924 'icirc': '\xEE', 17925 'Icirc': '\xCE', 17926 'icy': "\u0438", 17927 'Icy': "\u0418", 17928 'Idot': "\u0130", 17929 'iecy': "\u0435", 17930 'IEcy': "\u0415", 17931 'iexcl': '\xA1', 17932 'iff': "\u21D4", 17933 'ifr': "\uD835\uDD26", 17934 'Ifr': "\u2111", 17935 'igrave': '\xEC', 17936 'Igrave': '\xCC', 17937 'ii': "\u2148", 17938 'iiiint': "\u2A0C", 17939 'iiint': "\u222D", 17940 'iinfin': "\u29DC", 17941 'iiota': "\u2129", 17942 'ijlig': "\u0133", 17943 'IJlig': "\u0132", 17944 'Im': "\u2111", 17945 'imacr': "\u012B", 17946 'Imacr': "\u012A", 17947 'image': "\u2111", 17948 'ImaginaryI': "\u2148", 17949 'imagline': "\u2110", 17950 'imagpart': "\u2111", 17951 'imath': "\u0131", 17952 'imof': "\u22B7", 17953 'imped': "\u01B5", 17954 'Implies': "\u21D2", 17955 'in': "\u2208", 17956 'incare': "\u2105", 17957 'infin': "\u221E", 17958 'infintie': "\u29DD", 17959 'inodot': "\u0131", 17960 'int': "\u222B", 17961 'Int': "\u222C", 17962 'intcal': "\u22BA", 17963 'integers': "\u2124", 17964 'Integral': "\u222B", 17965 'intercal': "\u22BA", 17966 'Intersection': "\u22C2", 17967 'intlarhk': "\u2A17", 17968 'intprod': "\u2A3C", 17969 'InvisibleComma': "\u2063", 17970 'InvisibleTimes': "\u2062", 17971 'iocy': "\u0451", 17972 'IOcy': "\u0401", 17973 'iogon': "\u012F", 17974 'Iogon': "\u012E", 17975 'iopf': "\uD835\uDD5A", 17976 'Iopf': "\uD835\uDD40", 17977 'iota': "\u03B9", 17978 'Iota': "\u0399", 17979 'iprod': "\u2A3C", 17980 'iquest': '\xBF', 17981 'iscr': "\uD835\uDCBE", 17982 'Iscr': "\u2110", 17983 'isin': "\u2208", 17984 'isindot': "\u22F5", 17985 'isinE': "\u22F9", 17986 'isins': "\u22F4", 17987 'isinsv': "\u22F3", 17988 'isinv': "\u2208", 17989 'it': "\u2062", 17990 'itilde': "\u0129", 17991 'Itilde': "\u0128", 17992 'iukcy': "\u0456", 17993 'Iukcy': "\u0406", 17994 'iuml': '\xEF', 17995 'Iuml': '\xCF', 17996 'jcirc': "\u0135", 17997 'Jcirc': "\u0134", 17998 'jcy': "\u0439", 17999 'Jcy': "\u0419", 18000 'jfr': "\uD835\uDD27", 18001 'Jfr': "\uD835\uDD0D", 18002 'jmath': "\u0237", 18003 'jopf': "\uD835\uDD5B", 18004 'Jopf': "\uD835\uDD41", 18005 'jscr': "\uD835\uDCBF", 18006 'Jscr': "\uD835\uDCA5", 18007 'jsercy': "\u0458", 18008 'Jsercy': "\u0408", 18009 'jukcy': "\u0454", 18010 'Jukcy': "\u0404", 18011 'kappa': "\u03BA", 18012 'Kappa': "\u039A", 18013 'kappav': "\u03F0", 18014 'kcedil': "\u0137", 18015 'Kcedil': "\u0136", 18016 'kcy': "\u043A", 18017 'Kcy': "\u041A", 18018 'kfr': "\uD835\uDD28", 18019 'Kfr': "\uD835\uDD0E", 18020 'kgreen': "\u0138", 18021 'khcy': "\u0445", 18022 'KHcy': "\u0425", 18023 'kjcy': "\u045C", 18024 'KJcy': "\u040C", 18025 'kopf': "\uD835\uDD5C", 18026 'Kopf': "\uD835\uDD42", 18027 'kscr': "\uD835\uDCC0", 18028 'Kscr': "\uD835\uDCA6", 18029 'lAarr': "\u21DA", 18030 'lacute': "\u013A", 18031 'Lacute': "\u0139", 18032 'laemptyv': "\u29B4", 18033 'lagran': "\u2112", 18034 'lambda': "\u03BB", 18035 'Lambda': "\u039B", 18036 'lang': "\u27E8", 18037 'Lang': "\u27EA", 18038 'langd': "\u2991", 18039 'langle': "\u27E8", 18040 'lap': "\u2A85", 18041 'Laplacetrf': "\u2112", 18042 'laquo': '\xAB', 18043 'larr': "\u2190", 18044 'lArr': "\u21D0", 18045 'Larr': "\u219E", 18046 'larrb': "\u21E4", 18047 'larrbfs': "\u291F", 18048 'larrfs': "\u291D", 18049 'larrhk': "\u21A9", 18050 'larrlp': "\u21AB", 18051 'larrpl': "\u2939", 18052 'larrsim': "\u2973", 18053 'larrtl': "\u21A2", 18054 'lat': "\u2AAB", 18055 'latail': "\u2919", 18056 'lAtail': "\u291B", 18057 'late': "\u2AAD", 18058 'lates': "\u2AAD\uFE00", 18059 'lbarr': "\u290C", 18060 'lBarr': "\u290E", 18061 'lbbrk': "\u2772", 18062 'lbrace': '{', 18063 'lbrack': '[', 18064 'lbrke': "\u298B", 18065 'lbrksld': "\u298F", 18066 'lbrkslu': "\u298D", 18067 'lcaron': "\u013E", 18068 'Lcaron': "\u013D", 18069 'lcedil': "\u013C", 18070 'Lcedil': "\u013B", 18071 'lceil': "\u2308", 18072 'lcub': '{', 18073 'lcy': "\u043B", 18074 'Lcy': "\u041B", 18075 'ldca': "\u2936", 18076 'ldquo': "\u201C", 18077 'ldquor': "\u201E", 18078 'ldrdhar': "\u2967", 18079 'ldrushar': "\u294B", 18080 'ldsh': "\u21B2", 18081 'le': "\u2264", 18082 'lE': "\u2266", 18083 'LeftAngleBracket': "\u27E8", 18084 'leftarrow': "\u2190", 18085 'Leftarrow': "\u21D0", 18086 'LeftArrow': "\u2190", 18087 'LeftArrowBar': "\u21E4", 18088 'LeftArrowRightArrow': "\u21C6", 18089 'leftarrowtail': "\u21A2", 18090 'LeftCeiling': "\u2308", 18091 'LeftDoubleBracket': "\u27E6", 18092 'LeftDownTeeVector': "\u2961", 18093 'LeftDownVector': "\u21C3", 18094 'LeftDownVectorBar': "\u2959", 18095 'LeftFloor': "\u230A", 18096 'leftharpoondown': "\u21BD", 18097 'leftharpoonup': "\u21BC", 18098 'leftleftarrows': "\u21C7", 18099 'leftrightarrow': "\u2194", 18100 'Leftrightarrow': "\u21D4", 18101 'LeftRightArrow': "\u2194", 18102 'leftrightarrows': "\u21C6", 18103 'leftrightharpoons': "\u21CB", 18104 'leftrightsquigarrow': "\u21AD", 18105 'LeftRightVector': "\u294E", 18106 'LeftTee': "\u22A3", 18107 'LeftTeeArrow': "\u21A4", 18108 'LeftTeeVector': "\u295A", 18109 'leftthreetimes': "\u22CB", 18110 'LeftTriangle': "\u22B2", 18111 'LeftTriangleBar': "\u29CF", 18112 'LeftTriangleEqual': "\u22B4", 18113 'LeftUpDownVector': "\u2951", 18114 'LeftUpTeeVector': "\u2960", 18115 'LeftUpVector': "\u21BF", 18116 'LeftUpVectorBar': "\u2958", 18117 'LeftVector': "\u21BC", 18118 'LeftVectorBar': "\u2952", 18119 'leg': "\u22DA", 18120 'lEg': "\u2A8B", 18121 'leq': "\u2264", 18122 'leqq': "\u2266", 18123 'leqslant': "\u2A7D", 18124 'les': "\u2A7D", 18125 'lescc': "\u2AA8", 18126 'lesdot': "\u2A7F", 18127 'lesdoto': "\u2A81", 18128 'lesdotor': "\u2A83", 18129 'lesg': "\u22DA\uFE00", 18130 'lesges': "\u2A93", 18131 'lessapprox': "\u2A85", 18132 'lessdot': "\u22D6", 18133 'lesseqgtr': "\u22DA", 18134 'lesseqqgtr': "\u2A8B", 18135 'LessEqualGreater': "\u22DA", 18136 'LessFullEqual': "\u2266", 18137 'LessGreater': "\u2276", 18138 'lessgtr': "\u2276", 18139 'LessLess': "\u2AA1", 18140 'lesssim': "\u2272", 18141 'LessSlantEqual': "\u2A7D", 18142 'LessTilde': "\u2272", 18143 'lfisht': "\u297C", 18144 'lfloor': "\u230A", 18145 'lfr': "\uD835\uDD29", 18146 'Lfr': "\uD835\uDD0F", 18147 'lg': "\u2276", 18148 'lgE': "\u2A91", 18149 'lHar': "\u2962", 18150 'lhard': "\u21BD", 18151 'lharu': "\u21BC", 18152 'lharul': "\u296A", 18153 'lhblk': "\u2584", 18154 'ljcy': "\u0459", 18155 'LJcy': "\u0409", 18156 'll': "\u226A", 18157 'Ll': "\u22D8", 18158 'llarr': "\u21C7", 18159 'llcorner': "\u231E", 18160 'Lleftarrow': "\u21DA", 18161 'llhard': "\u296B", 18162 'lltri': "\u25FA", 18163 'lmidot': "\u0140", 18164 'Lmidot': "\u013F", 18165 'lmoust': "\u23B0", 18166 'lmoustache': "\u23B0", 18167 'lnap': "\u2A89", 18168 'lnapprox': "\u2A89", 18169 'lne': "\u2A87", 18170 'lnE': "\u2268", 18171 'lneq': "\u2A87", 18172 'lneqq': "\u2268", 18173 'lnsim': "\u22E6", 18174 'loang': "\u27EC", 18175 'loarr': "\u21FD", 18176 'lobrk': "\u27E6", 18177 'longleftarrow': "\u27F5", 18178 'Longleftarrow': "\u27F8", 18179 'LongLeftArrow': "\u27F5", 18180 'longleftrightarrow': "\u27F7", 18181 'Longleftrightarrow': "\u27FA", 18182 'LongLeftRightArrow': "\u27F7", 18183 'longmapsto': "\u27FC", 18184 'longrightarrow': "\u27F6", 18185 'Longrightarrow': "\u27F9", 18186 'LongRightArrow': "\u27F6", 18187 'looparrowleft': "\u21AB", 18188 'looparrowright': "\u21AC", 18189 'lopar': "\u2985", 18190 'lopf': "\uD835\uDD5D", 18191 'Lopf': "\uD835\uDD43", 18192 'loplus': "\u2A2D", 18193 'lotimes': "\u2A34", 18194 'lowast': "\u2217", 18195 'lowbar': '_', 18196 'LowerLeftArrow': "\u2199", 18197 'LowerRightArrow': "\u2198", 18198 'loz': "\u25CA", 18199 'lozenge': "\u25CA", 18200 'lozf': "\u29EB", 18201 'lpar': '(', 18202 'lparlt': "\u2993", 18203 'lrarr': "\u21C6", 18204 'lrcorner': "\u231F", 18205 'lrhar': "\u21CB", 18206 'lrhard': "\u296D", 18207 'lrm': "\u200E", 18208 'lrtri': "\u22BF", 18209 'lsaquo': "\u2039", 18210 'lscr': "\uD835\uDCC1", 18211 'Lscr': "\u2112", 18212 'lsh': "\u21B0", 18213 'Lsh': "\u21B0", 18214 'lsim': "\u2272", 18215 'lsime': "\u2A8D", 18216 'lsimg': "\u2A8F", 18217 'lsqb': '[', 18218 'lsquo': "\u2018", 18219 'lsquor': "\u201A", 18220 'lstrok': "\u0142", 18221 'Lstrok': "\u0141", 18222 'lt': '<', 18223 'Lt': "\u226A", 18224 'LT': '<', 18225 'ltcc': "\u2AA6", 18226 'ltcir': "\u2A79", 18227 'ltdot': "\u22D6", 18228 'lthree': "\u22CB", 18229 'ltimes': "\u22C9", 18230 'ltlarr': "\u2976", 18231 'ltquest': "\u2A7B", 18232 'ltri': "\u25C3", 18233 'ltrie': "\u22B4", 18234 'ltrif': "\u25C2", 18235 'ltrPar': "\u2996", 18236 'lurdshar': "\u294A", 18237 'luruhar': "\u2966", 18238 'lvertneqq': "\u2268\uFE00", 18239 'lvnE': "\u2268\uFE00", 18240 'macr': '\xAF', 18241 'male': "\u2642", 18242 'malt': "\u2720", 18243 'maltese': "\u2720", 18244 'map': "\u21A6", 18245 'Map': "\u2905", 18246 'mapsto': "\u21A6", 18247 'mapstodown': "\u21A7", 18248 'mapstoleft': "\u21A4", 18249 'mapstoup': "\u21A5", 18250 'marker': "\u25AE", 18251 'mcomma': "\u2A29", 18252 'mcy': "\u043C", 18253 'Mcy': "\u041C", 18254 'mdash': "\u2014", 18255 'mDDot': "\u223A", 18256 'measuredangle': "\u2221", 18257 'MediumSpace': "\u205F", 18258 'Mellintrf': "\u2133", 18259 'mfr': "\uD835\uDD2A", 18260 'Mfr': "\uD835\uDD10", 18261 'mho': "\u2127", 18262 'micro': '\xB5', 18263 'mid': "\u2223", 18264 'midast': '*', 18265 'midcir': "\u2AF0", 18266 'middot': '\xB7', 18267 'minus': "\u2212", 18268 'minusb': "\u229F", 18269 'minusd': "\u2238", 18270 'minusdu': "\u2A2A", 18271 'MinusPlus': "\u2213", 18272 'mlcp': "\u2ADB", 18273 'mldr': "\u2026", 18274 'mnplus': "\u2213", 18275 'models': "\u22A7", 18276 'mopf': "\uD835\uDD5E", 18277 'Mopf': "\uD835\uDD44", 18278 'mp': "\u2213", 18279 'mscr': "\uD835\uDCC2", 18280 'Mscr': "\u2133", 18281 'mstpos': "\u223E", 18282 'mu': "\u03BC", 18283 'Mu': "\u039C", 18284 'multimap': "\u22B8", 18285 'mumap': "\u22B8", 18286 'nabla': "\u2207", 18287 'nacute': "\u0144", 18288 'Nacute': "\u0143", 18289 'nang': "\u2220\u20D2", 18290 'nap': "\u2249", 18291 'napE': "\u2A70\u0338", 18292 'napid': "\u224B\u0338", 18293 'napos': "\u0149", 18294 'napprox': "\u2249", 18295 'natur': "\u266E", 18296 'natural': "\u266E", 18297 'naturals': "\u2115", 18298 'nbsp': '\xA0', 18299 'nbump': "\u224E\u0338", 18300 'nbumpe': "\u224F\u0338", 18301 'ncap': "\u2A43", 18302 'ncaron': "\u0148", 18303 'Ncaron': "\u0147", 18304 'ncedil': "\u0146", 18305 'Ncedil': "\u0145", 18306 'ncong': "\u2247", 18307 'ncongdot': "\u2A6D\u0338", 18308 'ncup': "\u2A42", 18309 'ncy': "\u043D", 18310 'Ncy': "\u041D", 18311 'ndash': "\u2013", 18312 'ne': "\u2260", 18313 'nearhk': "\u2924", 18314 'nearr': "\u2197", 18315 'neArr': "\u21D7", 18316 'nearrow': "\u2197", 18317 'nedot': "\u2250\u0338", 18318 'NegativeMediumSpace': "\u200B", 18319 'NegativeThickSpace': "\u200B", 18320 'NegativeThinSpace': "\u200B", 18321 'NegativeVeryThinSpace': "\u200B", 18322 'nequiv': "\u2262", 18323 'nesear': "\u2928", 18324 'nesim': "\u2242\u0338", 18325 'NestedGreaterGreater': "\u226B", 18326 'NestedLessLess': "\u226A", 18327 'NewLine': '\n', 18328 'nexist': "\u2204", 18329 'nexists': "\u2204", 18330 'nfr': "\uD835\uDD2B", 18331 'Nfr': "\uD835\uDD11", 18332 'nge': "\u2271", 18333 'ngE': "\u2267\u0338", 18334 'ngeq': "\u2271", 18335 'ngeqq': "\u2267\u0338", 18336 'ngeqslant': "\u2A7E\u0338", 18337 'nges': "\u2A7E\u0338", 18338 'nGg': "\u22D9\u0338", 18339 'ngsim': "\u2275", 18340 'ngt': "\u226F", 18341 'nGt': "\u226B\u20D2", 18342 'ngtr': "\u226F", 18343 'nGtv': "\u226B\u0338", 18344 'nharr': "\u21AE", 18345 'nhArr': "\u21CE", 18346 'nhpar': "\u2AF2", 18347 'ni': "\u220B", 18348 'nis': "\u22FC", 18349 'nisd': "\u22FA", 18350 'niv': "\u220B", 18351 'njcy': "\u045A", 18352 'NJcy': "\u040A", 18353 'nlarr': "\u219A", 18354 'nlArr': "\u21CD", 18355 'nldr': "\u2025", 18356 'nle': "\u2270", 18357 'nlE': "\u2266\u0338", 18358 'nleftarrow': "\u219A", 18359 'nLeftarrow': "\u21CD", 18360 'nleftrightarrow': "\u21AE", 18361 'nLeftrightarrow': "\u21CE", 18362 'nleq': "\u2270", 18363 'nleqq': "\u2266\u0338", 18364 'nleqslant': "\u2A7D\u0338", 18365 'nles': "\u2A7D\u0338", 18366 'nless': "\u226E", 18367 'nLl': "\u22D8\u0338", 18368 'nlsim': "\u2274", 18369 'nlt': "\u226E", 18370 'nLt': "\u226A\u20D2", 18371 'nltri': "\u22EA", 18372 'nltrie': "\u22EC", 18373 'nLtv': "\u226A\u0338", 18374 'nmid': "\u2224", 18375 'NoBreak': "\u2060", 18376 'NonBreakingSpace': '\xA0', 18377 'nopf': "\uD835\uDD5F", 18378 'Nopf': "\u2115", 18379 'not': '\xAC', 18380 'Not': "\u2AEC", 18381 'NotCongruent': "\u2262", 18382 'NotCupCap': "\u226D", 18383 'NotDoubleVerticalBar': "\u2226", 18384 'NotElement': "\u2209", 18385 'NotEqual': "\u2260", 18386 'NotEqualTilde': "\u2242\u0338", 18387 'NotExists': "\u2204", 18388 'NotGreater': "\u226F", 18389 'NotGreaterEqual': "\u2271", 18390 'NotGreaterFullEqual': "\u2267\u0338", 18391 'NotGreaterGreater': "\u226B\u0338", 18392 'NotGreaterLess': "\u2279", 18393 'NotGreaterSlantEqual': "\u2A7E\u0338", 18394 'NotGreaterTilde': "\u2275", 18395 'NotHumpDownHump': "\u224E\u0338", 18396 'NotHumpEqual': "\u224F\u0338", 18397 'notin': "\u2209", 18398 'notindot': "\u22F5\u0338", 18399 'notinE': "\u22F9\u0338", 18400 'notinva': "\u2209", 18401 'notinvb': "\u22F7", 18402 'notinvc': "\u22F6", 18403 'NotLeftTriangle': "\u22EA", 18404 'NotLeftTriangleBar': "\u29CF\u0338", 18405 'NotLeftTriangleEqual': "\u22EC", 18406 'NotLess': "\u226E", 18407 'NotLessEqual': "\u2270", 18408 'NotLessGreater': "\u2278", 18409 'NotLessLess': "\u226A\u0338", 18410 'NotLessSlantEqual': "\u2A7D\u0338", 18411 'NotLessTilde': "\u2274", 18412 'NotNestedGreaterGreater': "\u2AA2\u0338", 18413 'NotNestedLessLess': "\u2AA1\u0338", 18414 'notni': "\u220C", 18415 'notniva': "\u220C", 18416 'notnivb': "\u22FE", 18417 'notnivc': "\u22FD", 18418 'NotPrecedes': "\u2280", 18419 'NotPrecedesEqual': "\u2AAF\u0338", 18420 'NotPrecedesSlantEqual': "\u22E0", 18421 'NotReverseElement': "\u220C", 18422 'NotRightTriangle': "\u22EB", 18423 'NotRightTriangleBar': "\u29D0\u0338", 18424 'NotRightTriangleEqual': "\u22ED", 18425 'NotSquareSubset': "\u228F\u0338", 18426 'NotSquareSubsetEqual': "\u22E2", 18427 'NotSquareSuperset': "\u2290\u0338", 18428 'NotSquareSupersetEqual': "\u22E3", 18429 'NotSubset': "\u2282\u20D2", 18430 'NotSubsetEqual': "\u2288", 18431 'NotSucceeds': "\u2281", 18432 'NotSucceedsEqual': "\u2AB0\u0338", 18433 'NotSucceedsSlantEqual': "\u22E1", 18434 'NotSucceedsTilde': "\u227F\u0338", 18435 'NotSuperset': "\u2283\u20D2", 18436 'NotSupersetEqual': "\u2289", 18437 'NotTilde': "\u2241", 18438 'NotTildeEqual': "\u2244", 18439 'NotTildeFullEqual': "\u2247", 18440 'NotTildeTilde': "\u2249", 18441 'NotVerticalBar': "\u2224", 18442 'npar': "\u2226", 18443 'nparallel': "\u2226", 18444 'nparsl': "\u2AFD\u20E5", 18445 'npart': "\u2202\u0338", 18446 'npolint': "\u2A14", 18447 'npr': "\u2280", 18448 'nprcue': "\u22E0", 18449 'npre': "\u2AAF\u0338", 18450 'nprec': "\u2280", 18451 'npreceq': "\u2AAF\u0338", 18452 'nrarr': "\u219B", 18453 'nrArr': "\u21CF", 18454 'nrarrc': "\u2933\u0338", 18455 'nrarrw': "\u219D\u0338", 18456 'nrightarrow': "\u219B", 18457 'nRightarrow': "\u21CF", 18458 'nrtri': "\u22EB", 18459 'nrtrie': "\u22ED", 18460 'nsc': "\u2281", 18461 'nsccue': "\u22E1", 18462 'nsce': "\u2AB0\u0338", 18463 'nscr': "\uD835\uDCC3", 18464 'Nscr': "\uD835\uDCA9", 18465 'nshortmid': "\u2224", 18466 'nshortparallel': "\u2226", 18467 'nsim': "\u2241", 18468 'nsime': "\u2244", 18469 'nsimeq': "\u2244", 18470 'nsmid': "\u2224", 18471 'nspar': "\u2226", 18472 'nsqsube': "\u22E2", 18473 'nsqsupe': "\u22E3", 18474 'nsub': "\u2284", 18475 'nsube': "\u2288", 18476 'nsubE': "\u2AC5\u0338", 18477 'nsubset': "\u2282\u20D2", 18478 'nsubseteq': "\u2288", 18479 'nsubseteqq': "\u2AC5\u0338", 18480 'nsucc': "\u2281", 18481 'nsucceq': "\u2AB0\u0338", 18482 'nsup': "\u2285", 18483 'nsupe': "\u2289", 18484 'nsupE': "\u2AC6\u0338", 18485 'nsupset': "\u2283\u20D2", 18486 'nsupseteq': "\u2289", 18487 'nsupseteqq': "\u2AC6\u0338", 18488 'ntgl': "\u2279", 18489 'ntilde': '\xF1', 18490 'Ntilde': '\xD1', 18491 'ntlg': "\u2278", 18492 'ntriangleleft': "\u22EA", 18493 'ntrianglelefteq': "\u22EC", 18494 'ntriangleright': "\u22EB", 18495 'ntrianglerighteq': "\u22ED", 18496 'nu': "\u03BD", 18497 'Nu': "\u039D", 18498 'num': '#', 18499 'numero': "\u2116", 18500 'numsp': "\u2007", 18501 'nvap': "\u224D\u20D2", 18502 'nvdash': "\u22AC", 18503 'nvDash': "\u22AD", 18504 'nVdash': "\u22AE", 18505 'nVDash': "\u22AF", 18506 'nvge': "\u2265\u20D2", 18507 'nvgt': ">\u20D2", 18508 'nvHarr': "\u2904", 18509 'nvinfin': "\u29DE", 18510 'nvlArr': "\u2902", 18511 'nvle': "\u2264\u20D2", 18512 'nvlt': "<\u20D2", 18513 'nvltrie': "\u22B4\u20D2", 18514 'nvrArr': "\u2903", 18515 'nvrtrie': "\u22B5\u20D2", 18516 'nvsim': "\u223C\u20D2", 18517 'nwarhk': "\u2923", 18518 'nwarr': "\u2196", 18519 'nwArr': "\u21D6", 18520 'nwarrow': "\u2196", 18521 'nwnear': "\u2927", 18522 'oacute': '\xF3', 18523 'Oacute': '\xD3', 18524 'oast': "\u229B", 18525 'ocir': "\u229A", 18526 'ocirc': '\xF4', 18527 'Ocirc': '\xD4', 18528 'ocy': "\u043E", 18529 'Ocy': "\u041E", 18530 'odash': "\u229D", 18531 'odblac': "\u0151", 18532 'Odblac': "\u0150", 18533 'odiv': "\u2A38", 18534 'odot': "\u2299", 18535 'odsold': "\u29BC", 18536 'oelig': "\u0153", 18537 'OElig': "\u0152", 18538 'ofcir': "\u29BF", 18539 'ofr': "\uD835\uDD2C", 18540 'Ofr': "\uD835\uDD12", 18541 'ogon': "\u02DB", 18542 'ograve': '\xF2', 18543 'Ograve': '\xD2', 18544 'ogt': "\u29C1", 18545 'ohbar': "\u29B5", 18546 'ohm': "\u03A9", 18547 'oint': "\u222E", 18548 'olarr': "\u21BA", 18549 'olcir': "\u29BE", 18550 'olcross': "\u29BB", 18551 'oline': "\u203E", 18552 'olt': "\u29C0", 18553 'omacr': "\u014D", 18554 'Omacr': "\u014C", 18555 'omega': "\u03C9", 18556 'Omega': "\u03A9", 18557 'omicron': "\u03BF", 18558 'Omicron': "\u039F", 18559 'omid': "\u29B6", 18560 'ominus': "\u2296", 18561 'oopf': "\uD835\uDD60", 18562 'Oopf': "\uD835\uDD46", 18563 'opar': "\u29B7", 18564 'OpenCurlyDoubleQuote': "\u201C", 18565 'OpenCurlyQuote': "\u2018", 18566 'operp': "\u29B9", 18567 'oplus': "\u2295", 18568 'or': "\u2228", 18569 'Or': "\u2A54", 18570 'orarr': "\u21BB", 18571 'ord': "\u2A5D", 18572 'order': "\u2134", 18573 'orderof': "\u2134", 18574 'ordf': '\xAA', 18575 'ordm': '\xBA', 18576 'origof': "\u22B6", 18577 'oror': "\u2A56", 18578 'orslope': "\u2A57", 18579 'orv': "\u2A5B", 18580 'oS': "\u24C8", 18581 'oscr': "\u2134", 18582 'Oscr': "\uD835\uDCAA", 18583 'oslash': '\xF8', 18584 'Oslash': '\xD8', 18585 'osol': "\u2298", 18586 'otilde': '\xF5', 18587 'Otilde': '\xD5', 18588 'otimes': "\u2297", 18589 'Otimes': "\u2A37", 18590 'otimesas': "\u2A36", 18591 'ouml': '\xF6', 18592 'Ouml': '\xD6', 18593 'ovbar': "\u233D", 18594 'OverBar': "\u203E", 18595 'OverBrace': "\u23DE", 18596 'OverBracket': "\u23B4", 18597 'OverParenthesis': "\u23DC", 18598 'par': "\u2225", 18599 'para': '\xB6', 18600 'parallel': "\u2225", 18601 'parsim': "\u2AF3", 18602 'parsl': "\u2AFD", 18603 'part': "\u2202", 18604 'PartialD': "\u2202", 18605 'pcy': "\u043F", 18606 'Pcy': "\u041F", 18607 'percnt': '%', 18608 'period': '.', 18609 'permil': "\u2030", 18610 'perp': "\u22A5", 18611 'pertenk': "\u2031", 18612 'pfr': "\uD835\uDD2D", 18613 'Pfr': "\uD835\uDD13", 18614 'phi': "\u03C6", 18615 'Phi': "\u03A6", 18616 'phiv': "\u03D5", 18617 'phmmat': "\u2133", 18618 'phone': "\u260E", 18619 'pi': "\u03C0", 18620 'Pi': "\u03A0", 18621 'pitchfork': "\u22D4", 18622 'piv': "\u03D6", 18623 'planck': "\u210F", 18624 'planckh': "\u210E", 18625 'plankv': "\u210F", 18626 'plus': '+', 18627 'plusacir': "\u2A23", 18628 'plusb': "\u229E", 18629 'pluscir': "\u2A22", 18630 'plusdo': "\u2214", 18631 'plusdu': "\u2A25", 18632 'pluse': "\u2A72", 18633 'PlusMinus': '\xB1', 18634 'plusmn': '\xB1', 18635 'plussim': "\u2A26", 18636 'plustwo': "\u2A27", 18637 'pm': '\xB1', 18638 'Poincareplane': "\u210C", 18639 'pointint': "\u2A15", 18640 'popf': "\uD835\uDD61", 18641 'Popf': "\u2119", 18642 'pound': '\xA3', 18643 'pr': "\u227A", 18644 'Pr': "\u2ABB", 18645 'prap': "\u2AB7", 18646 'prcue': "\u227C", 18647 'pre': "\u2AAF", 18648 'prE': "\u2AB3", 18649 'prec': "\u227A", 18650 'precapprox': "\u2AB7", 18651 'preccurlyeq': "\u227C", 18652 'Precedes': "\u227A", 18653 'PrecedesEqual': "\u2AAF", 18654 'PrecedesSlantEqual': "\u227C", 18655 'PrecedesTilde': "\u227E", 18656 'preceq': "\u2AAF", 18657 'precnapprox': "\u2AB9", 18658 'precneqq': "\u2AB5", 18659 'precnsim': "\u22E8", 18660 'precsim': "\u227E", 18661 'prime': "\u2032", 18662 'Prime': "\u2033", 18663 'primes': "\u2119", 18664 'prnap': "\u2AB9", 18665 'prnE': "\u2AB5", 18666 'prnsim': "\u22E8", 18667 'prod': "\u220F", 18668 'Product': "\u220F", 18669 'profalar': "\u232E", 18670 'profline': "\u2312", 18671 'profsurf': "\u2313", 18672 'prop': "\u221D", 18673 'Proportion': "\u2237", 18674 'Proportional': "\u221D", 18675 'propto': "\u221D", 18676 'prsim': "\u227E", 18677 'prurel': "\u22B0", 18678 'pscr': "\uD835\uDCC5", 18679 'Pscr': "\uD835\uDCAB", 18680 'psi': "\u03C8", 18681 'Psi': "\u03A8", 18682 'puncsp': "\u2008", 18683 'qfr': "\uD835\uDD2E", 18684 'Qfr': "\uD835\uDD14", 18685 'qint': "\u2A0C", 18686 'qopf': "\uD835\uDD62", 18687 'Qopf': "\u211A", 18688 'qprime': "\u2057", 18689 'qscr': "\uD835\uDCC6", 18690 'Qscr': "\uD835\uDCAC", 18691 'quaternions': "\u210D", 18692 'quatint': "\u2A16", 18693 'quest': '?', 18694 'questeq': "\u225F", 18695 'quot': '"', 18696 'QUOT': '"', 18697 'rAarr': "\u21DB", 18698 'race': "\u223D\u0331", 18699 'racute': "\u0155", 18700 'Racute': "\u0154", 18701 'radic': "\u221A", 18702 'raemptyv': "\u29B3", 18703 'rang': "\u27E9", 18704 'Rang': "\u27EB", 18705 'rangd': "\u2992", 18706 'range': "\u29A5", 18707 'rangle': "\u27E9", 18708 'raquo': '\xBB', 18709 'rarr': "\u2192", 18710 'rArr': "\u21D2", 18711 'Rarr': "\u21A0", 18712 'rarrap': "\u2975", 18713 'rarrb': "\u21E5", 18714 'rarrbfs': "\u2920", 18715 'rarrc': "\u2933", 18716 'rarrfs': "\u291E", 18717 'rarrhk': "\u21AA", 18718 'rarrlp': "\u21AC", 18719 'rarrpl': "\u2945", 18720 'rarrsim': "\u2974", 18721 'rarrtl': "\u21A3", 18722 'Rarrtl': "\u2916", 18723 'rarrw': "\u219D", 18724 'ratail': "\u291A", 18725 'rAtail': "\u291C", 18726 'ratio': "\u2236", 18727 'rationals': "\u211A", 18728 'rbarr': "\u290D", 18729 'rBarr': "\u290F", 18730 'RBarr': "\u2910", 18731 'rbbrk': "\u2773", 18732 'rbrace': '}', 18733 'rbrack': ']', 18734 'rbrke': "\u298C", 18735 'rbrksld': "\u298E", 18736 'rbrkslu': "\u2990", 18737 'rcaron': "\u0159", 18738 'Rcaron': "\u0158", 18739 'rcedil': "\u0157", 18740 'Rcedil': "\u0156", 18741 'rceil': "\u2309", 18742 'rcub': '}', 18743 'rcy': "\u0440", 18744 'Rcy': "\u0420", 18745 'rdca': "\u2937", 18746 'rdldhar': "\u2969", 18747 'rdquo': "\u201D", 18748 'rdquor': "\u201D", 18749 'rdsh': "\u21B3", 18750 'Re': "\u211C", 18751 'real': "\u211C", 18752 'realine': "\u211B", 18753 'realpart': "\u211C", 18754 'reals': "\u211D", 18755 'rect': "\u25AD", 18756 'reg': '\xAE', 18757 'REG': '\xAE', 18758 'ReverseElement': "\u220B", 18759 'ReverseEquilibrium': "\u21CB", 18760 'ReverseUpEquilibrium': "\u296F", 18761 'rfisht': "\u297D", 18762 'rfloor': "\u230B", 18763 'rfr': "\uD835\uDD2F", 18764 'Rfr': "\u211C", 18765 'rHar': "\u2964", 18766 'rhard': "\u21C1", 18767 'rharu': "\u21C0", 18768 'rharul': "\u296C", 18769 'rho': "\u03C1", 18770 'Rho': "\u03A1", 18771 'rhov': "\u03F1", 18772 'RightAngleBracket': "\u27E9", 18773 'rightarrow': "\u2192", 18774 'Rightarrow': "\u21D2", 18775 'RightArrow': "\u2192", 18776 'RightArrowBar': "\u21E5", 18777 'RightArrowLeftArrow': "\u21C4", 18778 'rightarrowtail': "\u21A3", 18779 'RightCeiling': "\u2309", 18780 'RightDoubleBracket': "\u27E7", 18781 'RightDownTeeVector': "\u295D", 18782 'RightDownVector': "\u21C2", 18783 'RightDownVectorBar': "\u2955", 18784 'RightFloor': "\u230B", 18785 'rightharpoondown': "\u21C1", 18786 'rightharpoonup': "\u21C0", 18787 'rightleftarrows': "\u21C4", 18788 'rightleftharpoons': "\u21CC", 18789 'rightrightarrows': "\u21C9", 18790 'rightsquigarrow': "\u219D", 18791 'RightTee': "\u22A2", 18792 'RightTeeArrow': "\u21A6", 18793 'RightTeeVector': "\u295B", 18794 'rightthreetimes': "\u22CC", 18795 'RightTriangle': "\u22B3", 18796 'RightTriangleBar': "\u29D0", 18797 'RightTriangleEqual': "\u22B5", 18798 'RightUpDownVector': "\u294F", 18799 'RightUpTeeVector': "\u295C", 18800 'RightUpVector': "\u21BE", 18801 'RightUpVectorBar': "\u2954", 18802 'RightVector': "\u21C0", 18803 'RightVectorBar': "\u2953", 18804 'ring': "\u02DA", 18805 'risingdotseq': "\u2253", 18806 'rlarr': "\u21C4", 18807 'rlhar': "\u21CC", 18808 'rlm': "\u200F", 18809 'rmoust': "\u23B1", 18810 'rmoustache': "\u23B1", 18811 'rnmid': "\u2AEE", 18812 'roang': "\u27ED", 18813 'roarr': "\u21FE", 18814 'robrk': "\u27E7", 18815 'ropar': "\u2986", 18816 'ropf': "\uD835\uDD63", 18817 'Ropf': "\u211D", 18818 'roplus': "\u2A2E", 18819 'rotimes': "\u2A35", 18820 'RoundImplies': "\u2970", 18821 'rpar': ')', 18822 'rpargt': "\u2994", 18823 'rppolint': "\u2A12", 18824 'rrarr': "\u21C9", 18825 'Rrightarrow': "\u21DB", 18826 'rsaquo': "\u203A", 18827 'rscr': "\uD835\uDCC7", 18828 'Rscr': "\u211B", 18829 'rsh': "\u21B1", 18830 'Rsh': "\u21B1", 18831 'rsqb': ']', 18832 'rsquo': "\u2019", 18833 'rsquor': "\u2019", 18834 'rthree': "\u22CC", 18835 'rtimes': "\u22CA", 18836 'rtri': "\u25B9", 18837 'rtrie': "\u22B5", 18838 'rtrif': "\u25B8", 18839 'rtriltri': "\u29CE", 18840 'RuleDelayed': "\u29F4", 18841 'ruluhar': "\u2968", 18842 'rx': "\u211E", 18843 'sacute': "\u015B", 18844 'Sacute': "\u015A", 18845 'sbquo': "\u201A", 18846 'sc': "\u227B", 18847 'Sc': "\u2ABC", 18848 'scap': "\u2AB8", 18849 'scaron': "\u0161", 18850 'Scaron': "\u0160", 18851 'sccue': "\u227D", 18852 'sce': "\u2AB0", 18853 'scE': "\u2AB4", 18854 'scedil': "\u015F", 18855 'Scedil': "\u015E", 18856 'scirc': "\u015D", 18857 'Scirc': "\u015C", 18858 'scnap': "\u2ABA", 18859 'scnE': "\u2AB6", 18860 'scnsim': "\u22E9", 18861 'scpolint': "\u2A13", 18862 'scsim': "\u227F", 18863 'scy': "\u0441", 18864 'Scy': "\u0421", 18865 'sdot': "\u22C5", 18866 'sdotb': "\u22A1", 18867 'sdote': "\u2A66", 18868 'searhk': "\u2925", 18869 'searr': "\u2198", 18870 'seArr': "\u21D8", 18871 'searrow': "\u2198", 18872 'sect': '\xA7', 18873 'semi': ';', 18874 'seswar': "\u2929", 18875 'setminus': "\u2216", 18876 'setmn': "\u2216", 18877 'sext': "\u2736", 18878 'sfr': "\uD835\uDD30", 18879 'Sfr': "\uD835\uDD16", 18880 'sfrown': "\u2322", 18881 'sharp': "\u266F", 18882 'shchcy': "\u0449", 18883 'SHCHcy': "\u0429", 18884 'shcy': "\u0448", 18885 'SHcy': "\u0428", 18886 'ShortDownArrow': "\u2193", 18887 'ShortLeftArrow': "\u2190", 18888 'shortmid': "\u2223", 18889 'shortparallel': "\u2225", 18890 'ShortRightArrow': "\u2192", 18891 'ShortUpArrow': "\u2191", 18892 'shy': '\xAD', 18893 'sigma': "\u03C3", 18894 'Sigma': "\u03A3", 18895 'sigmaf': "\u03C2", 18896 'sigmav': "\u03C2", 18897 'sim': "\u223C", 18898 'simdot': "\u2A6A", 18899 'sime': "\u2243", 18900 'simeq': "\u2243", 18901 'simg': "\u2A9E", 18902 'simgE': "\u2AA0", 18903 'siml': "\u2A9D", 18904 'simlE': "\u2A9F", 18905 'simne': "\u2246", 18906 'simplus': "\u2A24", 18907 'simrarr': "\u2972", 18908 'slarr': "\u2190", 18909 'SmallCircle': "\u2218", 18910 'smallsetminus': "\u2216", 18911 'smashp': "\u2A33", 18912 'smeparsl': "\u29E4", 18913 'smid': "\u2223", 18914 'smile': "\u2323", 18915 'smt': "\u2AAA", 18916 'smte': "\u2AAC", 18917 'smtes': "\u2AAC\uFE00", 18918 'softcy': "\u044C", 18919 'SOFTcy': "\u042C", 18920 'sol': '/', 18921 'solb': "\u29C4", 18922 'solbar': "\u233F", 18923 'sopf': "\uD835\uDD64", 18924 'Sopf': "\uD835\uDD4A", 18925 'spades': "\u2660", 18926 'spadesuit': "\u2660", 18927 'spar': "\u2225", 18928 'sqcap': "\u2293", 18929 'sqcaps': "\u2293\uFE00", 18930 'sqcup': "\u2294", 18931 'sqcups': "\u2294\uFE00", 18932 'Sqrt': "\u221A", 18933 'sqsub': "\u228F", 18934 'sqsube': "\u2291", 18935 'sqsubset': "\u228F", 18936 'sqsubseteq': "\u2291", 18937 'sqsup': "\u2290", 18938 'sqsupe': "\u2292", 18939 'sqsupset': "\u2290", 18940 'sqsupseteq': "\u2292", 18941 'squ': "\u25A1", 18942 'square': "\u25A1", 18943 'Square': "\u25A1", 18944 'SquareIntersection': "\u2293", 18945 'SquareSubset': "\u228F", 18946 'SquareSubsetEqual': "\u2291", 18947 'SquareSuperset': "\u2290", 18948 'SquareSupersetEqual': "\u2292", 18949 'SquareUnion': "\u2294", 18950 'squarf': "\u25AA", 18951 'squf': "\u25AA", 18952 'srarr': "\u2192", 18953 'sscr': "\uD835\uDCC8", 18954 'Sscr': "\uD835\uDCAE", 18955 'ssetmn': "\u2216", 18956 'ssmile': "\u2323", 18957 'sstarf': "\u22C6", 18958 'star': "\u2606", 18959 'Star': "\u22C6", 18960 'starf': "\u2605", 18961 'straightepsilon': "\u03F5", 18962 'straightphi': "\u03D5", 18963 'strns': '\xAF', 18964 'sub': "\u2282", 18965 'Sub': "\u22D0", 18966 'subdot': "\u2ABD", 18967 'sube': "\u2286", 18968 'subE': "\u2AC5", 18969 'subedot': "\u2AC3", 18970 'submult': "\u2AC1", 18971 'subne': "\u228A", 18972 'subnE': "\u2ACB", 18973 'subplus': "\u2ABF", 18974 'subrarr': "\u2979", 18975 'subset': "\u2282", 18976 'Subset': "\u22D0", 18977 'subseteq': "\u2286", 18978 'subseteqq': "\u2AC5", 18979 'SubsetEqual': "\u2286", 18980 'subsetneq': "\u228A", 18981 'subsetneqq': "\u2ACB", 18982 'subsim': "\u2AC7", 18983 'subsub': "\u2AD5", 18984 'subsup': "\u2AD3", 18985 'succ': "\u227B", 18986 'succapprox': "\u2AB8", 18987 'succcurlyeq': "\u227D", 18988 'Succeeds': "\u227B", 18989 'SucceedsEqual': "\u2AB0", 18990 'SucceedsSlantEqual': "\u227D", 18991 'SucceedsTilde': "\u227F", 18992 'succeq': "\u2AB0", 18993 'succnapprox': "\u2ABA", 18994 'succneqq': "\u2AB6", 18995 'succnsim': "\u22E9", 18996 'succsim': "\u227F", 18997 'SuchThat': "\u220B", 18998 'sum': "\u2211", 18999 'Sum': "\u2211", 19000 'sung': "\u266A", 19001 'sup': "\u2283", 19002 'Sup': "\u22D1", 19003 'sup1': '\xB9', 19004 'sup2': '\xB2', 19005 'sup3': '\xB3', 19006 'supdot': "\u2ABE", 19007 'supdsub': "\u2AD8", 19008 'supe': "\u2287", 19009 'supE': "\u2AC6", 19010 'supedot': "\u2AC4", 19011 'Superset': "\u2283", 19012 'SupersetEqual': "\u2287", 19013 'suphsol': "\u27C9", 19014 'suphsub': "\u2AD7", 19015 'suplarr': "\u297B", 19016 'supmult': "\u2AC2", 19017 'supne': "\u228B", 19018 'supnE': "\u2ACC", 19019 'supplus': "\u2AC0", 19020 'supset': "\u2283", 19021 'Supset': "\u22D1", 19022 'supseteq': "\u2287", 19023 'supseteqq': "\u2AC6", 19024 'supsetneq': "\u228B", 19025 'supsetneqq': "\u2ACC", 19026 'supsim': "\u2AC8", 19027 'supsub': "\u2AD4", 19028 'supsup': "\u2AD6", 19029 'swarhk': "\u2926", 19030 'swarr': "\u2199", 19031 'swArr': "\u21D9", 19032 'swarrow': "\u2199", 19033 'swnwar': "\u292A", 19034 'szlig': '\xDF', 19035 'Tab': '\t', 19036 'target': "\u2316", 19037 'tau': "\u03C4", 19038 'Tau': "\u03A4", 19039 'tbrk': "\u23B4", 19040 'tcaron': "\u0165", 19041 'Tcaron': "\u0164", 19042 'tcedil': "\u0163", 19043 'Tcedil': "\u0162", 19044 'tcy': "\u0442", 19045 'Tcy': "\u0422", 19046 'tdot': "\u20DB", 19047 'telrec': "\u2315", 19048 'tfr': "\uD835\uDD31", 19049 'Tfr': "\uD835\uDD17", 19050 'there4': "\u2234", 19051 'therefore': "\u2234", 19052 'Therefore': "\u2234", 19053 'theta': "\u03B8", 19054 'Theta': "\u0398", 19055 'thetasym': "\u03D1", 19056 'thetav': "\u03D1", 19057 'thickapprox': "\u2248", 19058 'thicksim': "\u223C", 19059 'ThickSpace': "\u205F\u200A", 19060 'thinsp': "\u2009", 19061 'ThinSpace': "\u2009", 19062 'thkap': "\u2248", 19063 'thksim': "\u223C", 19064 'thorn': '\xFE', 19065 'THORN': '\xDE', 19066 'tilde': "\u02DC", 19067 'Tilde': "\u223C", 19068 'TildeEqual': "\u2243", 19069 'TildeFullEqual': "\u2245", 19070 'TildeTilde': "\u2248", 19071 'times': '\xD7', 19072 'timesb': "\u22A0", 19073 'timesbar': "\u2A31", 19074 'timesd': "\u2A30", 19075 'tint': "\u222D", 19076 'toea': "\u2928", 19077 'top': "\u22A4", 19078 'topbot': "\u2336", 19079 'topcir': "\u2AF1", 19080 'topf': "\uD835\uDD65", 19081 'Topf': "\uD835\uDD4B", 19082 'topfork': "\u2ADA", 19083 'tosa': "\u2929", 19084 'tprime': "\u2034", 19085 'trade': "\u2122", 19086 'TRADE': "\u2122", 19087 'triangle': "\u25B5", 19088 'triangledown': "\u25BF", 19089 'triangleleft': "\u25C3", 19090 'trianglelefteq': "\u22B4", 19091 'triangleq': "\u225C", 19092 'triangleright': "\u25B9", 19093 'trianglerighteq': "\u22B5", 19094 'tridot': "\u25EC", 19095 'trie': "\u225C", 19096 'triminus': "\u2A3A", 19097 'TripleDot': "\u20DB", 19098 'triplus': "\u2A39", 19099 'trisb': "\u29CD", 19100 'tritime': "\u2A3B", 19101 'trpezium': "\u23E2", 19102 'tscr': "\uD835\uDCC9", 19103 'Tscr': "\uD835\uDCAF", 19104 'tscy': "\u0446", 19105 'TScy': "\u0426", 19106 'tshcy': "\u045B", 19107 'TSHcy': "\u040B", 19108 'tstrok': "\u0167", 19109 'Tstrok': "\u0166", 19110 'twixt': "\u226C", 19111 'twoheadleftarrow': "\u219E", 19112 'twoheadrightarrow': "\u21A0", 19113 'uacute': '\xFA', 19114 'Uacute': '\xDA', 19115 'uarr': "\u2191", 19116 'uArr': "\u21D1", 19117 'Uarr': "\u219F", 19118 'Uarrocir': "\u2949", 19119 'ubrcy': "\u045E", 19120 'Ubrcy': "\u040E", 19121 'ubreve': "\u016D", 19122 'Ubreve': "\u016C", 19123 'ucirc': '\xFB', 19124 'Ucirc': '\xDB', 19125 'ucy': "\u0443", 19126 'Ucy': "\u0423", 19127 'udarr': "\u21C5", 19128 'udblac': "\u0171", 19129 'Udblac': "\u0170", 19130 'udhar': "\u296E", 19131 'ufisht': "\u297E", 19132 'ufr': "\uD835\uDD32", 19133 'Ufr': "\uD835\uDD18", 19134 'ugrave': '\xF9', 19135 'Ugrave': '\xD9', 19136 'uHar': "\u2963", 19137 'uharl': "\u21BF", 19138 'uharr': "\u21BE", 19139 'uhblk': "\u2580", 19140 'ulcorn': "\u231C", 19141 'ulcorner': "\u231C", 19142 'ulcrop': "\u230F", 19143 'ultri': "\u25F8", 19144 'umacr': "\u016B", 19145 'Umacr': "\u016A", 19146 'uml': '\xA8', 19147 'UnderBar': '_', 19148 'UnderBrace': "\u23DF", 19149 'UnderBracket': "\u23B5", 19150 'UnderParenthesis': "\u23DD", 19151 'Union': "\u22C3", 19152 'UnionPlus': "\u228E", 19153 'uogon': "\u0173", 19154 'Uogon': "\u0172", 19155 'uopf': "\uD835\uDD66", 19156 'Uopf': "\uD835\uDD4C", 19157 'uparrow': "\u2191", 19158 'Uparrow': "\u21D1", 19159 'UpArrow': "\u2191", 19160 'UpArrowBar': "\u2912", 19161 'UpArrowDownArrow': "\u21C5", 19162 'updownarrow': "\u2195", 19163 'Updownarrow': "\u21D5", 19164 'UpDownArrow': "\u2195", 19165 'UpEquilibrium': "\u296E", 19166 'upharpoonleft': "\u21BF", 19167 'upharpoonright': "\u21BE", 19168 'uplus': "\u228E", 19169 'UpperLeftArrow': "\u2196", 19170 'UpperRightArrow': "\u2197", 19171 'upsi': "\u03C5", 19172 'Upsi': "\u03D2", 19173 'upsih': "\u03D2", 19174 'upsilon': "\u03C5", 19175 'Upsilon': "\u03A5", 19176 'UpTee': "\u22A5", 19177 'UpTeeArrow': "\u21A5", 19178 'upuparrows': "\u21C8", 19179 'urcorn': "\u231D", 19180 'urcorner': "\u231D", 19181 'urcrop': "\u230E", 19182 'uring': "\u016F", 19183 'Uring': "\u016E", 19184 'urtri': "\u25F9", 19185 'uscr': "\uD835\uDCCA", 19186 'Uscr': "\uD835\uDCB0", 19187 'utdot': "\u22F0", 19188 'utilde': "\u0169", 19189 'Utilde': "\u0168", 19190 'utri': "\u25B5", 19191 'utrif': "\u25B4", 19192 'uuarr': "\u21C8", 19193 'uuml': '\xFC', 19194 'Uuml': '\xDC', 19195 'uwangle': "\u29A7", 19196 'vangrt': "\u299C", 19197 'varepsilon': "\u03F5", 19198 'varkappa': "\u03F0", 19199 'varnothing': "\u2205", 19200 'varphi': "\u03D5", 19201 'varpi': "\u03D6", 19202 'varpropto': "\u221D", 19203 'varr': "\u2195", 19204 'vArr': "\u21D5", 19205 'varrho': "\u03F1", 19206 'varsigma': "\u03C2", 19207 'varsubsetneq': "\u228A\uFE00", 19208 'varsubsetneqq': "\u2ACB\uFE00", 19209 'varsupsetneq': "\u228B\uFE00", 19210 'varsupsetneqq': "\u2ACC\uFE00", 19211 'vartheta': "\u03D1", 19212 'vartriangleleft': "\u22B2", 19213 'vartriangleright': "\u22B3", 19214 'vBar': "\u2AE8", 19215 'Vbar': "\u2AEB", 19216 'vBarv': "\u2AE9", 19217 'vcy': "\u0432", 19218 'Vcy': "\u0412", 19219 'vdash': "\u22A2", 19220 'vDash': "\u22A8", 19221 'Vdash': "\u22A9", 19222 'VDash': "\u22AB", 19223 'Vdashl': "\u2AE6", 19224 'vee': "\u2228", 19225 'Vee': "\u22C1", 19226 'veebar': "\u22BB", 19227 'veeeq': "\u225A", 19228 'vellip': "\u22EE", 19229 'verbar': '|', 19230 'Verbar': "\u2016", 19231 'vert': '|', 19232 'Vert': "\u2016", 19233 'VerticalBar': "\u2223", 19234 'VerticalLine': '|', 19235 'VerticalSeparator': "\u2758", 19236 'VerticalTilde': "\u2240", 19237 'VeryThinSpace': "\u200A", 19238 'vfr': "\uD835\uDD33", 19239 'Vfr': "\uD835\uDD19", 19240 'vltri': "\u22B2", 19241 'vnsub': "\u2282\u20D2", 19242 'vnsup': "\u2283\u20D2", 19243 'vopf': "\uD835\uDD67", 19244 'Vopf': "\uD835\uDD4D", 19245 'vprop': "\u221D", 19246 'vrtri': "\u22B3", 19247 'vscr': "\uD835\uDCCB", 19248 'Vscr': "\uD835\uDCB1", 19249 'vsubne': "\u228A\uFE00", 19250 'vsubnE': "\u2ACB\uFE00", 19251 'vsupne': "\u228B\uFE00", 19252 'vsupnE': "\u2ACC\uFE00", 19253 'Vvdash': "\u22AA", 19254 'vzigzag': "\u299A", 19255 'wcirc': "\u0175", 19256 'Wcirc': "\u0174", 19257 'wedbar': "\u2A5F", 19258 'wedge': "\u2227", 19259 'Wedge': "\u22C0", 19260 'wedgeq': "\u2259", 19261 'weierp': "\u2118", 19262 'wfr': "\uD835\uDD34", 19263 'Wfr': "\uD835\uDD1A", 19264 'wopf': "\uD835\uDD68", 19265 'Wopf': "\uD835\uDD4E", 19266 'wp': "\u2118", 19267 'wr': "\u2240", 19268 'wreath': "\u2240", 19269 'wscr': "\uD835\uDCCC", 19270 'Wscr': "\uD835\uDCB2", 19271 'xcap': "\u22C2", 19272 'xcirc': "\u25EF", 19273 'xcup': "\u22C3", 19274 'xdtri': "\u25BD", 19275 'xfr': "\uD835\uDD35", 19276 'Xfr': "\uD835\uDD1B", 19277 'xharr': "\u27F7", 19278 'xhArr': "\u27FA", 19279 'xi': "\u03BE", 19280 'Xi': "\u039E", 19281 'xlarr': "\u27F5", 19282 'xlArr': "\u27F8", 19283 'xmap': "\u27FC", 19284 'xnis': "\u22FB", 19285 'xodot': "\u2A00", 19286 'xopf': "\uD835\uDD69", 19287 'Xopf': "\uD835\uDD4F", 19288 'xoplus': "\u2A01", 19289 'xotime': "\u2A02", 19290 'xrarr': "\u27F6", 19291 'xrArr': "\u27F9", 19292 'xscr': "\uD835\uDCCD", 19293 'Xscr': "\uD835\uDCB3", 19294 'xsqcup': "\u2A06", 19295 'xuplus': "\u2A04", 19296 'xutri': "\u25B3", 19297 'xvee': "\u22C1", 19298 'xwedge': "\u22C0", 19299 'yacute': '\xFD', 19300 'Yacute': '\xDD', 19301 'yacy': "\u044F", 19302 'YAcy': "\u042F", 19303 'ycirc': "\u0177", 19304 'Ycirc': "\u0176", 19305 'ycy': "\u044B", 19306 'Ycy': "\u042B", 19307 'yen': '\xA5', 19308 'yfr': "\uD835\uDD36", 19309 'Yfr': "\uD835\uDD1C", 19310 'yicy': "\u0457", 19311 'YIcy': "\u0407", 19312 'yopf': "\uD835\uDD6A", 19313 'Yopf': "\uD835\uDD50", 19314 'yscr': "\uD835\uDCCE", 19315 'Yscr': "\uD835\uDCB4", 19316 'yucy': "\u044E", 19317 'YUcy': "\u042E", 19318 'yuml': '\xFF', 19319 'Yuml': "\u0178", 19320 'zacute': "\u017A", 19321 'Zacute': "\u0179", 19322 'zcaron': "\u017E", 19323 'Zcaron': "\u017D", 19324 'zcy': "\u0437", 19325 'Zcy': "\u0417", 19326 'zdot': "\u017C", 19327 'Zdot': "\u017B", 19328 'zeetrf': "\u2128", 19329 'ZeroWidthSpace': "\u200B", 19330 'zeta': "\u03B6", 19331 'Zeta': "\u0396", 19332 'zfr': "\uD835\uDD37", 19333 'Zfr': "\u2128", 19334 'zhcy': "\u0436", 19335 'ZHcy': "\u0416", 19336 'zigrarr': "\u21DD", 19337 'zopf': "\uD835\uDD6B", 19338 'Zopf': "\u2124", 19339 'zscr': "\uD835\uDCCF", 19340 'Zscr': "\uD835\uDCB5", 19341 'zwj': "\u200D", 19342 'zwnj': "\u200C" 19343 }; 19344 var decodeMapLegacy = { 19345 'aacute': '\xE1', 19346 'Aacute': '\xC1', 19347 'acirc': '\xE2', 19348 'Acirc': '\xC2', 19349 'acute': '\xB4', 19350 'aelig': '\xE6', 19351 'AElig': '\xC6', 19352 'agrave': '\xE0', 19353 'Agrave': '\xC0', 19354 'amp': '&', 19355 'AMP': '&', 19356 'aring': '\xE5', 19357 'Aring': '\xC5', 19358 'atilde': '\xE3', 19359 'Atilde': '\xC3', 19360 'auml': '\xE4', 19361 'Auml': '\xC4', 19362 'brvbar': '\xA6', 19363 'ccedil': '\xE7', 19364 'Ccedil': '\xC7', 19365 'cedil': '\xB8', 19366 'cent': '\xA2', 19367 'copy': '\xA9', 19368 'COPY': '\xA9', 19369 'curren': '\xA4', 19370 'deg': '\xB0', 19371 'divide': '\xF7', 19372 'eacute': '\xE9', 19373 'Eacute': '\xC9', 19374 'ecirc': '\xEA', 19375 'Ecirc': '\xCA', 19376 'egrave': '\xE8', 19377 'Egrave': '\xC8', 19378 'eth': '\xF0', 19379 'ETH': '\xD0', 19380 'euml': '\xEB', 19381 'Euml': '\xCB', 19382 'frac12': '\xBD', 19383 'frac14': '\xBC', 19384 'frac34': '\xBE', 19385 'gt': '>', 19386 'GT': '>', 19387 'iacute': '\xED', 19388 'Iacute': '\xCD', 19389 'icirc': '\xEE', 19390 'Icirc': '\xCE', 19391 'iexcl': '\xA1', 19392 'igrave': '\xEC', 19393 'Igrave': '\xCC', 19394 'iquest': '\xBF', 19395 'iuml': '\xEF', 19396 'Iuml': '\xCF', 19397 'laquo': '\xAB', 19398 'lt': '<', 19399 'LT': '<', 19400 'macr': '\xAF', 19401 'micro': '\xB5', 19402 'middot': '\xB7', 19403 'nbsp': '\xA0', 19404 'not': '\xAC', 19405 'ntilde': '\xF1', 19406 'Ntilde': '\xD1', 19407 'oacute': '\xF3', 19408 'Oacute': '\xD3', 19409 'ocirc': '\xF4', 19410 'Ocirc': '\xD4', 19411 'ograve': '\xF2', 19412 'Ograve': '\xD2', 19413 'ordf': '\xAA', 19414 'ordm': '\xBA', 19415 'oslash': '\xF8', 19416 'Oslash': '\xD8', 19417 'otilde': '\xF5', 19418 'Otilde': '\xD5', 19419 'ouml': '\xF6', 19420 'Ouml': '\xD6', 19421 'para': '\xB6', 19422 'plusmn': '\xB1', 19423 'pound': '\xA3', 19424 'quot': '"', 19425 'QUOT': '"', 19426 'raquo': '\xBB', 19427 'reg': '\xAE', 19428 'REG': '\xAE', 19429 'sect': '\xA7', 19430 'shy': '\xAD', 19431 'sup1': '\xB9', 19432 'sup2': '\xB2', 19433 'sup3': '\xB3', 19434 'szlig': '\xDF', 19435 'thorn': '\xFE', 19436 'THORN': '\xDE', 19437 'times': '\xD7', 19438 'uacute': '\xFA', 19439 'Uacute': '\xDA', 19440 'ucirc': '\xFB', 19441 'Ucirc': '\xDB', 19442 'ugrave': '\xF9', 19443 'Ugrave': '\xD9', 19444 'uml': '\xA8', 19445 'uuml': '\xFC', 19446 'Uuml': '\xDC', 19447 'yacute': '\xFD', 19448 'Yacute': '\xDD', 19449 'yen': '\xA5', 19450 'yuml': '\xFF' 19451 }; 19452 var decodeMapNumeric = { 19453 '0': "\uFFFD", 19454 '128': "\u20AC", 19455 '130': "\u201A", 19456 '131': "\u0192", 19457 '132': "\u201E", 19458 '133': "\u2026", 19459 '134': "\u2020", 19460 '135': "\u2021", 19461 '136': "\u02C6", 19462 '137': "\u2030", 19463 '138': "\u0160", 19464 '139': "\u2039", 19465 '140': "\u0152", 19466 '142': "\u017D", 19467 '145': "\u2018", 19468 '146': "\u2019", 19469 '147': "\u201C", 19470 '148': "\u201D", 19471 '149': "\u2022", 19472 '150': "\u2013", 19473 '151': "\u2014", 19474 '152': "\u02DC", 19475 '153': "\u2122", 19476 '154': "\u0161", 19477 '155': "\u203A", 19478 '156': "\u0153", 19479 '158': "\u017E", 19480 '159': "\u0178" 19481 }; 19482 var invalidReferenceCodePoints = [1, 2, 3, 4, 5, 6, 7, 8, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 64976, 64977, 64978, 64979, 64980, 64981, 64982, 64983, 64984, 64985, 64986, 64987, 64988, 64989, 64990, 64991, 64992, 64993, 64994, 64995, 64996, 64997, 64998, 64999, 65000, 65001, 65002, 65003, 65004, 65005, 65006, 65007, 65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214, 393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894, 720895, 786430, 786431, 851966, 851967, 917502, 917503, 983038, 983039, 1048574, 1048575, 1114110, 1114111]; 19483 /*--------------------------------------------------------------------------*/ 19484 19485 var stringFromCharCode = String.fromCharCode; 19486 var object = {}; 19487 var hasOwnProperty = object.hasOwnProperty; 19488 19489 var has = function has(object, propertyName) { 19490 return hasOwnProperty.call(object, propertyName); 19491 }; 19492 19493 var contains = function contains(array, value) { 19494 var index = -1; 19495 var length = array.length; 19496 19497 while (++index < length) { 19498 if (array[index] == value) { 19499 return true; 19500 } 19501 } 19502 19503 return false; 19504 }; 19505 19506 var merge = function merge(options, defaults) { 19507 if (!options) { 19508 return defaults; 19509 } 19510 19511 var result = {}; 19512 var key; 19513 19514 for (key in defaults) { 19515 // A `hasOwnProperty` check is not needed here, since only recognized 19516 // option names are used anyway. Any others are ignored. 19517 result[key] = has(options, key) ? options[key] : defaults[key]; 19518 } 19519 19520 return result; 19521 }; // Modified version of `ucs2encode`; see https://mths.be/punycode. 19522 19523 19524 var codePointToSymbol = function codePointToSymbol(codePoint, strict) { 19525 var output = ''; 19526 19527 if (codePoint >= 0xD800 && codePoint <= 0xDFFF || codePoint > 0x10FFFF) { 19528 // See issue #4: 19529 // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is 19530 // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD 19531 // REPLACEMENT CHARACTER.” 19532 if (strict) { 19533 parseError('character reference outside the permissible Unicode range'); 19534 } 19535 19536 return "\uFFFD"; 19537 } 19538 19539 if (has(decodeMapNumeric, codePoint)) { 19540 if (strict) { 19541 parseError('disallowed character reference'); 19542 } 19543 19544 return decodeMapNumeric[codePoint]; 19545 } 19546 19547 if (strict && contains(invalidReferenceCodePoints, codePoint)) { 19548 parseError('disallowed character reference'); 19549 } 19550 19551 if (codePoint > 0xFFFF) { 19552 codePoint -= 0x10000; 19553 output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800); 19554 codePoint = 0xDC00 | codePoint & 0x3FF; 19555 } 19556 19557 output += stringFromCharCode(codePoint); 19558 return output; 19559 }; 19560 19561 var hexEscape = function hexEscape(codePoint) { 19562 return '&#x' + codePoint.toString(16).toUpperCase() + ';'; 19563 }; 19564 19565 var decEscape = function decEscape(codePoint) { 19566 return '&#' + codePoint + ';'; 19567 }; 19568 19569 var parseError = function parseError(message) { 19570 throw Error('Parse error: ' + message); 19571 }; 19572 /*--------------------------------------------------------------------------*/ 19573 19574 19575 var encode = function encode(string, options) { 19576 options = merge(options, encode.options); 19577 var strict = options.strict; 19578 19579 if (strict && regexInvalidRawCodePoint.test(string)) { 19580 parseError('forbidden code point'); 19581 } 19582 19583 var encodeEverything = options.encodeEverything; 19584 var useNamedReferences = options.useNamedReferences; 19585 var allowUnsafeSymbols = options.allowUnsafeSymbols; 19586 var escapeCodePoint = options.decimal ? decEscape : hexEscape; 19587 19588 var escapeBmpSymbol = function escapeBmpSymbol(symbol) { 19589 return escapeCodePoint(symbol.charCodeAt(0)); 19590 }; 19591 19592 if (encodeEverything) { 19593 // Encode ASCII symbols. 19594 string = string.replace(regexAsciiWhitelist, function (symbol) { 19595 // Use named references if requested & possible. 19596 if (useNamedReferences && has(encodeMap, symbol)) { 19597 return '&' + encodeMap[symbol] + ';'; 19598 } 19599 19600 return escapeBmpSymbol(symbol); 19601 }); // Shorten a few escapes that represent two symbols, of which at least one 19602 // is within the ASCII range. 19603 19604 if (useNamedReferences) { 19605 string = string.replace(/>\u20D2/g, '>⃒').replace(/<\u20D2/g, '<⃒').replace(/fj/g, 'fj'); 19606 } // Encode non-ASCII symbols. 19607 19608 19609 if (useNamedReferences) { 19610 // Encode non-ASCII symbols that can be replaced with a named reference. 19611 string = string.replace(regexEncodeNonAscii, function (string) { 19612 // Note: there is no need to check `has(encodeMap, string)` here. 19613 return '&' + encodeMap[string] + ';'; 19614 }); 19615 } // Note: any remaining non-ASCII symbols are handled outside of the `if`. 19616 19617 } else if (useNamedReferences) { 19618 // Apply named character references. 19619 // Encode `<>"'&` using named character references. 19620 if (!allowUnsafeSymbols) { 19621 string = string.replace(regexEscape, function (string) { 19622 return '&' + encodeMap[string] + ';'; // no need to check `has()` here 19623 }); 19624 } // Shorten escapes that represent two symbols, of which at least one is 19625 // `<>"'&`. 19626 19627 19628 string = string.replace(/>\u20D2/g, '>⃒').replace(/<\u20D2/g, '<⃒'); // Encode non-ASCII symbols that can be replaced with a named reference. 19629 19630 string = string.replace(regexEncodeNonAscii, function (string) { 19631 // Note: there is no need to check `has(encodeMap, string)` here. 19632 return '&' + encodeMap[string] + ';'; 19633 }); 19634 } else if (!allowUnsafeSymbols) { 19635 // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled 19636 // using named character references. 19637 string = string.replace(regexEscape, escapeBmpSymbol); 19638 } 19639 19640 return string // Encode astral symbols. 19641 .replace(regexAstralSymbols, function ($0) { 19642 // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae 19643 var high = $0.charCodeAt(0); 19644 var low = $0.charCodeAt(1); 19645 var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000; 19646 return escapeCodePoint(codePoint); 19647 }) // Encode any remaining BMP symbols that are not printable ASCII symbols 19648 // using a hexadecimal escape. 19649 .replace(regexBmpWhitelist, escapeBmpSymbol); 19650 }; // Expose default options (so they can be overridden globally). 19651 19652 19653 encode.options = { 19654 'allowUnsafeSymbols': false, 19655 'encodeEverything': false, 19656 'strict': false, 19657 'useNamedReferences': false, 19658 'decimal': false 19659 }; 19660 19661 var decode = function decode(html, options) { 19662 options = merge(options, decode.options); 19663 var strict = options.strict; 19664 19665 if (strict && regexInvalidEntity.test(html)) { 19666 parseError('malformed character reference'); 19667 } 19668 19669 return html.replace(regexDecode, function ($0, $1, $2, $3, $4, $5, $6, $7, $8) { 19670 var codePoint; 19671 var semicolon; 19672 var decDigits; 19673 var hexDigits; 19674 var reference; 19675 var next; 19676 19677 if ($1) { 19678 reference = $1; // Note: there is no need to check `has(decodeMap, reference)`. 19679 19680 return decodeMap[reference]; 19681 } 19682 19683 if ($2) { 19684 // Decode named character references without trailing `;`, e.g. `&`. 19685 // This is only a parse error if it gets converted to `&`, or if it is 19686 // followed by `=` in an attribute context. 19687 reference = $2; 19688 next = $3; 19689 19690 if (next && options.isAttributeValue) { 19691 if (strict && next == '=') { 19692 parseError('`&` did not start a character reference'); 19693 } 19694 19695 return $0; 19696 } else { 19697 if (strict) { 19698 parseError('named character reference was not terminated by a semicolon'); 19699 } // Note: there is no need to check `has(decodeMapLegacy, reference)`. 19700 19701 19702 return decodeMapLegacy[reference] + (next || ''); 19703 } 19704 } 19705 19706 if ($4) { 19707 // Decode decimal escapes, e.g. `𝌆`. 19708 decDigits = $4; 19709 semicolon = $5; 19710 19711 if (strict && !semicolon) { 19712 parseError('character reference was not terminated by a semicolon'); 19713 } 19714 19715 codePoint = parseInt(decDigits, 10); 19716 return codePointToSymbol(codePoint, strict); 19717 } 19718 19719 if ($6) { 19720 // Decode hexadecimal escapes, e.g. `𝌆`. 19721 hexDigits = $6; 19722 semicolon = $7; 19723 19724 if (strict && !semicolon) { 19725 parseError('character reference was not terminated by a semicolon'); 19726 } 19727 19728 codePoint = parseInt(hexDigits, 16); 19729 return codePointToSymbol(codePoint, strict); 19730 } // If we’re still here, `if ($7)` is implied; it’s an ambiguous 19731 // ampersand for sure. https://mths.be/notes/ambiguous-ampersands 19732 19733 19734 if (strict) { 19735 parseError('named character reference was not terminated by a semicolon'); 19736 } 19737 19738 return $0; 19739 }); 19740 }; // Expose default options (so they can be overridden globally). 19741 19742 19743 decode.options = { 19744 'isAttributeValue': false, 19745 'strict': false 19746 }; 19747 19748 var escape = function escape(string) { 19749 return string.replace(regexEscape, function ($0) { 19750 // Note: there is no need to check `has(escapeMap, $0)` here. 19751 return escapeMap[$0]; 19752 }); 19753 }; 19754 /*--------------------------------------------------------------------------*/ 19755 19756 19757 var he = { 19758 'version': '1.2.0', 19759 'encode': encode, 19760 'decode': decode, 19761 'escape': escape, 19762 'unescape': decode 19763 }; // Some AMD build optimizers, like r.js, check for specific condition patterns 19764 // like the following: 19765 19766 if (freeExports && !freeExports.nodeType) { 19767 if (freeModule) { 19768 // in Node.js, io.js, or RingoJS v0.8.0+ 19769 freeModule.exports = he; 19770 } else { 19771 // in Narwhal or RingoJS v0.7.0- 19772 for (var key in he) { 19773 has(he, key) && (freeExports[key] = he[key]); 19774 } 19775 } 19776 } else { 19777 // in Rhino or a web browser 19778 root.he = he; 19779 } 19780 })(commonjsGlobal); 19781 }); 19782 19783 var propertyIsEnumerable = objectPropertyIsEnumerable.f; 19784 19785 // `Object.{ entries, values }` methods implementation 19786 var createMethod$5 = function (TO_ENTRIES) { 19787 return function (it) { 19788 var O = toIndexedObject(it); 19789 var keys = objectKeys(O); 19790 var length = keys.length; 19791 var i = 0; 19792 var result = []; 19793 var key; 19794 while (length > i) { 19795 key = keys[i++]; 19796 if (!descriptors || propertyIsEnumerable.call(O, key)) { 19797 result.push(TO_ENTRIES ? [key, O[key]] : O[key]); 19798 } 19799 } 19800 return result; 19801 }; 19802 }; 19803 19804 var objectToArray = { 19805 // `Object.entries` method 19806 // https://tc39.es/ecma262/#sec-object.entries 19807 entries: createMethod$5(true), 19808 // `Object.values` method 19809 // https://tc39.es/ecma262/#sec-object.values 19810 values: createMethod$5(false) 19811 }; 19812 19813 var $values = objectToArray.values; 19814 19815 // `Object.values` method 19816 // https://tc39.es/ecma262/#sec-object.values 19817 _export({ target: 'Object', stat: true }, { 19818 values: function values(O) { 19819 return $values(O); 19820 } 19821 }); 19822 19823 var format$1 = util.format; 19824 /** 19825 * Contains error codes, factory functions to create throwable error objects, 19826 * and warning/deprecation functions. 19827 * @module 19828 */ 19829 19830 /** 19831 * process.emitWarning or a polyfill 19832 * @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options 19833 * @ignore 19834 */ 19835 19836 var emitWarning$1 = function emitWarning(msg, type) { 19837 if (process$1.emitWarning) { 19838 process$1.emitWarning(msg, type); 19839 } else { 19840 /* istanbul ignore next */ 19841 nextTick(function () { 19842 console.warn(type + ': ' + msg); 19843 }); 19844 } 19845 }; 19846 /** 19847 * Show a deprecation warning. Each distinct message is only displayed once. 19848 * Ignores empty messages. 19849 * 19850 * @param {string} [msg] - Warning to print 19851 * @private 19852 */ 19853 19854 19855 var deprecate$1 = function deprecate(msg) { 19856 msg = String(msg); 19857 19858 if (msg && !deprecate.cache[msg]) { 19859 deprecate.cache[msg] = true; 19860 emitWarning$1(msg, 'DeprecationWarning'); 19861 } 19862 }; 19863 19864 deprecate$1.cache = {}; 19865 /** 19866 * Show a generic warning. 19867 * Ignores empty messages. 19868 * 19869 * @param {string} [msg] - Warning to print 19870 * @private 19871 */ 19872 19873 var warn = function warn(msg) { 19874 if (msg) { 19875 emitWarning$1(msg); 19876 } 19877 }; 19878 /** 19879 * When Mocha throws exceptions (or rejects `Promise`s), it attempts to assign a `code` property to the `Error` object, for easier handling. These are the potential values of `code`. 19880 * @public 19881 * @namespace 19882 * @memberof module:lib/errors 19883 */ 19884 19885 19886 var constants = { 19887 /** 19888 * An unrecoverable error. 19889 * @constant 19890 * @default 19891 */ 19892 FATAL: 'ERR_MOCHA_FATAL', 19893 19894 /** 19895 * The type of an argument to a function call is invalid 19896 * @constant 19897 * @default 19898 */ 19899 INVALID_ARG_TYPE: 'ERR_MOCHA_INVALID_ARG_TYPE', 19900 19901 /** 19902 * The value of an argument to a function call is invalid 19903 * @constant 19904 * @default 19905 */ 19906 INVALID_ARG_VALUE: 'ERR_MOCHA_INVALID_ARG_VALUE', 19907 19908 /** 19909 * Something was thrown, but it wasn't an `Error` 19910 * @constant 19911 * @default 19912 */ 19913 INVALID_EXCEPTION: 'ERR_MOCHA_INVALID_EXCEPTION', 19914 19915 /** 19916 * An interface (e.g., `Mocha.interfaces`) is unknown or invalid 19917 * @constant 19918 * @default 19919 */ 19920 INVALID_INTERFACE: 'ERR_MOCHA_INVALID_INTERFACE', 19921 19922 /** 19923 * A reporter (.e.g, `Mocha.reporters`) is unknown or invalid 19924 * @constant 19925 * @default 19926 */ 19927 INVALID_REPORTER: 'ERR_MOCHA_INVALID_REPORTER', 19928 19929 /** 19930 * `done()` was called twice in a `Test` or `Hook` callback 19931 * @constant 19932 * @default 19933 */ 19934 MULTIPLE_DONE: 'ERR_MOCHA_MULTIPLE_DONE', 19935 19936 /** 19937 * No files matched the pattern provided by the user 19938 * @constant 19939 * @default 19940 */ 19941 NO_FILES_MATCH_PATTERN: 'ERR_MOCHA_NO_FILES_MATCH_PATTERN', 19942 19943 /** 19944 * Known, but unsupported behavior of some kind 19945 * @constant 19946 * @default 19947 */ 19948 UNSUPPORTED: 'ERR_MOCHA_UNSUPPORTED', 19949 19950 /** 19951 * Invalid state transition occurring in `Mocha` instance 19952 * @constant 19953 * @default 19954 */ 19955 INSTANCE_ALREADY_RUNNING: 'ERR_MOCHA_INSTANCE_ALREADY_RUNNING', 19956 19957 /** 19958 * Invalid state transition occurring in `Mocha` instance 19959 * @constant 19960 * @default 19961 */ 19962 INSTANCE_ALREADY_DISPOSED: 'ERR_MOCHA_INSTANCE_ALREADY_DISPOSED', 19963 19964 /** 19965 * Use of `only()` w/ `--forbid-only` results in this error. 19966 * @constant 19967 * @default 19968 */ 19969 FORBIDDEN_EXCLUSIVITY: 'ERR_MOCHA_FORBIDDEN_EXCLUSIVITY', 19970 19971 /** 19972 * To be thrown when a user-defined plugin implementation (e.g., `mochaHooks`) is invalid 19973 * @constant 19974 * @default 19975 */ 19976 INVALID_PLUGIN_IMPLEMENTATION: 'ERR_MOCHA_INVALID_PLUGIN_IMPLEMENTATION', 19977 19978 /** 19979 * To be thrown when a builtin or third-party plugin definition (the _definition_ of `mochaHooks`) is invalid 19980 * @constant 19981 * @default 19982 */ 19983 INVALID_PLUGIN_DEFINITION: 'ERR_MOCHA_INVALID_PLUGIN_DEFINITION', 19984 19985 /** 19986 * When a runnable exceeds its allowed run time. 19987 * @constant 19988 * @default 19989 */ 19990 TIMEOUT: 'ERR_MOCHA_TIMEOUT' 19991 }; 19992 /** 19993 * A set containing all string values of all Mocha error constants, for use by {@link isMochaError}. 19994 * @private 19995 */ 19996 19997 var MOCHA_ERRORS = new Set(Object.values(constants)); 19998 /** 19999 * Creates an error object to be thrown when no files to be tested could be found using specified pattern. 20000 * 20001 * @public 20002 * @static 20003 * @param {string} message - Error message to be displayed. 20004 * @param {string} pattern - User-specified argument value. 20005 * @returns {Error} instance detailing the error condition 20006 */ 20007 20008 function createNoFilesMatchPatternError(message, pattern) { 20009 var err = new Error(message); 20010 err.code = constants.NO_FILES_MATCH_PATTERN; 20011 err.pattern = pattern; 20012 return err; 20013 } 20014 /** 20015 * Creates an error object to be thrown when the reporter specified in the options was not found. 20016 * 20017 * @public 20018 * @param {string} message - Error message to be displayed. 20019 * @param {string} reporter - User-specified reporter value. 20020 * @returns {Error} instance detailing the error condition 20021 */ 20022 20023 20024 function createInvalidReporterError(message, reporter) { 20025 var err = new TypeError(message); 20026 err.code = constants.INVALID_REPORTER; 20027 err.reporter = reporter; 20028 return err; 20029 } 20030 /** 20031 * Creates an error object to be thrown when the interface specified in the options was not found. 20032 * 20033 * @public 20034 * @static 20035 * @param {string} message - Error message to be displayed. 20036 * @param {string} ui - User-specified interface value. 20037 * @returns {Error} instance detailing the error condition 20038 */ 20039 20040 20041 function createInvalidInterfaceError(message, ui) { 20042 var err = new Error(message); 20043 err.code = constants.INVALID_INTERFACE; 20044 err["interface"] = ui; 20045 return err; 20046 } 20047 /** 20048 * Creates an error object to be thrown when a behavior, option, or parameter is unsupported. 20049 * 20050 * @public 20051 * @static 20052 * @param {string} message - Error message to be displayed. 20053 * @returns {Error} instance detailing the error condition 20054 */ 20055 20056 20057 function createUnsupportedError(message) { 20058 var err = new Error(message); 20059 err.code = constants.UNSUPPORTED; 20060 return err; 20061 } 20062 /** 20063 * Creates an error object to be thrown when an argument is missing. 20064 * 20065 * @public 20066 * @static 20067 * @param {string} message - Error message to be displayed. 20068 * @param {string} argument - Argument name. 20069 * @param {string} expected - Expected argument datatype. 20070 * @returns {Error} instance detailing the error condition 20071 */ 20072 20073 20074 function createMissingArgumentError(message, argument, expected) { 20075 return createInvalidArgumentTypeError(message, argument, expected); 20076 } 20077 /** 20078 * Creates an error object to be thrown when an argument did not use the supported type 20079 * 20080 * @public 20081 * @static 20082 * @param {string} message - Error message to be displayed. 20083 * @param {string} argument - Argument name. 20084 * @param {string} expected - Expected argument datatype. 20085 * @returns {Error} instance detailing the error condition 20086 */ 20087 20088 20089 function createInvalidArgumentTypeError(message, argument, expected) { 20090 var err = new TypeError(message); 20091 err.code = constants.INVALID_ARG_TYPE; 20092 err.argument = argument; 20093 err.expected = expected; 20094 err.actual = _typeof(argument); 20095 return err; 20096 } 20097 /** 20098 * Creates an error object to be thrown when an argument did not use the supported value 20099 * 20100 * @public 20101 * @static 20102 * @param {string} message - Error message to be displayed. 20103 * @param {string} argument - Argument name. 20104 * @param {string} value - Argument value. 20105 * @param {string} [reason] - Why value is invalid. 20106 * @returns {Error} instance detailing the error condition 20107 */ 20108 20109 20110 function createInvalidArgumentValueError(message, argument, value, reason) { 20111 var err = new TypeError(message); 20112 err.code = constants.INVALID_ARG_VALUE; 20113 err.argument = argument; 20114 err.value = value; 20115 err.reason = typeof reason !== 'undefined' ? reason : 'is invalid'; 20116 return err; 20117 } 20118 /** 20119 * Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined. 20120 * 20121 * @public 20122 * @static 20123 * @param {string} message - Error message to be displayed. 20124 * @returns {Error} instance detailing the error condition 20125 */ 20126 20127 20128 function createInvalidExceptionError(message, value) { 20129 var err = new Error(message); 20130 err.code = constants.INVALID_EXCEPTION; 20131 err.valueType = _typeof(value); 20132 err.value = value; 20133 return err; 20134 } 20135 /** 20136 * Creates an error object to be thrown when an unrecoverable error occurs. 20137 * 20138 * @public 20139 * @static 20140 * @param {string} message - Error message to be displayed. 20141 * @returns {Error} instance detailing the error condition 20142 */ 20143 20144 20145 function createFatalError(message, value) { 20146 var err = new Error(message); 20147 err.code = constants.FATAL; 20148 err.valueType = _typeof(value); 20149 err.value = value; 20150 return err; 20151 } 20152 /** 20153 * Dynamically creates a plugin-type-specific error based on plugin type 20154 * @param {string} message - Error message 20155 * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed 20156 * @param {string} [pluginId] - Name/path of plugin, if any 20157 * @throws When `pluginType` is not known 20158 * @public 20159 * @static 20160 * @returns {Error} 20161 */ 20162 20163 20164 function createInvalidLegacyPluginError(message, pluginType, pluginId) { 20165 switch (pluginType) { 20166 case 'reporter': 20167 return createInvalidReporterError(message, pluginId); 20168 20169 case 'interface': 20170 return createInvalidInterfaceError(message, pluginId); 20171 20172 default: 20173 throw new Error('unknown pluginType "' + pluginType + '"'); 20174 } 20175 } 20176 /** 20177 * **DEPRECATED**. Use {@link createInvalidLegacyPluginError} instead Dynamically creates a plugin-type-specific error based on plugin type 20178 * @deprecated 20179 * @param {string} message - Error message 20180 * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed 20181 * @param {string} [pluginId] - Name/path of plugin, if any 20182 * @throws When `pluginType` is not known 20183 * @public 20184 * @static 20185 * @returns {Error} 20186 */ 20187 20188 20189 function createInvalidPluginError() { 20190 deprecate$1('Use createInvalidLegacyPluginError() instead'); 20191 return createInvalidLegacyPluginError.apply(void 0, arguments); 20192 } 20193 /** 20194 * Creates an error object to be thrown when a mocha object's `run` method is executed while it is already disposed. 20195 * @param {string} message The error message to be displayed. 20196 * @param {boolean} cleanReferencesAfterRun the value of `cleanReferencesAfterRun` 20197 * @param {Mocha} instance the mocha instance that throw this error 20198 * @static 20199 */ 20200 20201 20202 function createMochaInstanceAlreadyDisposedError(message, cleanReferencesAfterRun, instance) { 20203 var err = new Error(message); 20204 err.code = constants.INSTANCE_ALREADY_DISPOSED; 20205 err.cleanReferencesAfterRun = cleanReferencesAfterRun; 20206 err.instance = instance; 20207 return err; 20208 } 20209 /** 20210 * Creates an error object to be thrown when a mocha object's `run` method is called while a test run is in progress. 20211 * @param {string} message The error message to be displayed. 20212 * @static 20213 * @public 20214 */ 20215 20216 20217 function createMochaInstanceAlreadyRunningError(message, instance) { 20218 var err = new Error(message); 20219 err.code = constants.INSTANCE_ALREADY_RUNNING; 20220 err.instance = instance; 20221 return err; 20222 } 20223 /** 20224 * Creates an error object to be thrown when done() is called multiple times in a test 20225 * 20226 * @public 20227 * @param {Runnable} runnable - Original runnable 20228 * @param {Error} [originalErr] - Original error, if any 20229 * @returns {Error} instance detailing the error condition 20230 * @static 20231 */ 20232 20233 20234 function createMultipleDoneError(runnable, originalErr) { 20235 var title; 20236 20237 try { 20238 title = format$1('<%s>', runnable.fullTitle()); 20239 20240 if (runnable.parent.root) { 20241 title += ' (of root suite)'; 20242 } 20243 } catch (ignored) { 20244 title = format$1('<%s> (of unknown suite)', runnable.title); 20245 } 20246 20247 var message = format$1('done() called multiple times in %s %s', runnable.type ? runnable.type : 'unknown runnable', title); 20248 20249 if (runnable.file) { 20250 message += format$1(' of file %s', runnable.file); 20251 } 20252 20253 if (originalErr) { 20254 message += format$1('; in addition, done() received error: %s', originalErr); 20255 } 20256 20257 var err = new Error(message); 20258 err.code = constants.MULTIPLE_DONE; 20259 err.valueType = _typeof(originalErr); 20260 err.value = originalErr; 20261 return err; 20262 } 20263 /** 20264 * Creates an error object to be thrown when `.only()` is used with 20265 * `--forbid-only`. 20266 * @static 20267 * @public 20268 * @param {Mocha} mocha - Mocha instance 20269 * @returns {Error} Error with code {@link constants.FORBIDDEN_EXCLUSIVITY} 20270 */ 20271 20272 20273 function createForbiddenExclusivityError(mocha) { 20274 var err = new Error(mocha.isWorker ? '`.only` is not supported in parallel mode' : '`.only` forbidden by --forbid-only'); 20275 err.code = constants.FORBIDDEN_EXCLUSIVITY; 20276 return err; 20277 } 20278 /** 20279 * Creates an error object to be thrown when a plugin definition is invalid 20280 * @static 20281 * @param {string} msg - Error message 20282 * @param {PluginDefinition} [pluginDef] - Problematic plugin definition 20283 * @public 20284 * @returns {Error} Error with code {@link constants.INVALID_PLUGIN_DEFINITION} 20285 */ 20286 20287 20288 function createInvalidPluginDefinitionError(msg, pluginDef) { 20289 var err = new Error(msg); 20290 err.code = constants.INVALID_PLUGIN_DEFINITION; 20291 err.pluginDef = pluginDef; 20292 return err; 20293 } 20294 /** 20295 * Creates an error object to be thrown when a plugin implementation (user code) is invalid 20296 * @static 20297 * @param {string} msg - Error message 20298 * @param {Object} [opts] - Plugin definition and user-supplied implementation 20299 * @param {PluginDefinition} [opts.pluginDef] - Plugin Definition 20300 * @param {*} [opts.pluginImpl] - Plugin Implementation (user-supplied) 20301 * @public 20302 * @returns {Error} Error with code {@link constants.INVALID_PLUGIN_DEFINITION} 20303 */ 20304 20305 20306 function createInvalidPluginImplementationError(msg) { 20307 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, 20308 pluginDef = _ref.pluginDef, 20309 pluginImpl = _ref.pluginImpl; 20310 20311 var err = new Error(msg); 20312 err.code = constants.INVALID_PLUGIN_IMPLEMENTATION; 20313 err.pluginDef = pluginDef; 20314 err.pluginImpl = pluginImpl; 20315 return err; 20316 } 20317 /** 20318 * Creates an error object to be thrown when a runnable exceeds its allowed run time. 20319 * @static 20320 * @param {string} msg - Error message 20321 * @param {number} [timeout] - Timeout in ms 20322 * @param {string} [file] - File, if given 20323 * @returns {MochaTimeoutError} 20324 */ 20325 20326 20327 function createTimeoutError(msg, timeout, file) { 20328 var err = new Error(msg); 20329 err.code = constants.TIMEOUT; 20330 err.timeout = timeout; 20331 err.file = file; 20332 return err; 20333 } 20334 /** 20335 * Returns `true` if an error came out of Mocha. 20336 * _Can suffer from false negatives, but not false positives._ 20337 * @static 20338 * @public 20339 * @param {*} err - Error, or anything 20340 * @returns {boolean} 20341 */ 20342 20343 20344 var isMochaError = function isMochaError(err) { 20345 return Boolean(err && _typeof(err) === 'object' && MOCHA_ERRORS.has(err.code)); 20346 }; 20347 20348 var errors = { 20349 constants: constants, 20350 createFatalError: createFatalError, 20351 createForbiddenExclusivityError: createForbiddenExclusivityError, 20352 createInvalidArgumentTypeError: createInvalidArgumentTypeError, 20353 createInvalidArgumentValueError: createInvalidArgumentValueError, 20354 createInvalidExceptionError: createInvalidExceptionError, 20355 createInvalidInterfaceError: createInvalidInterfaceError, 20356 createInvalidLegacyPluginError: createInvalidLegacyPluginError, 20357 createInvalidPluginDefinitionError: createInvalidPluginDefinitionError, 20358 createInvalidPluginError: createInvalidPluginError, 20359 createInvalidPluginImplementationError: createInvalidPluginImplementationError, 20360 createInvalidReporterError: createInvalidReporterError, 20361 createMissingArgumentError: createMissingArgumentError, 20362 createMochaInstanceAlreadyDisposedError: createMochaInstanceAlreadyDisposedError, 20363 createMochaInstanceAlreadyRunningError: createMochaInstanceAlreadyRunningError, 20364 createMultipleDoneError: createMultipleDoneError, 20365 createNoFilesMatchPatternError: createNoFilesMatchPatternError, 20366 createTimeoutError: createTimeoutError, 20367 createUnsupportedError: createUnsupportedError, 20368 deprecate: deprecate$1, 20369 isMochaError: isMochaError, 20370 warn: warn 20371 }; 20372 20373 var _nodeResolve_empty = {}; 20374 20375 var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({ 20376 __proto__: null, 20377 'default': _nodeResolve_empty 20378 }); 20379 20380 var require$$11 = getCjsExportFromNamespace(_nodeResolve_empty$1); 20381 20382 var utils = createCommonjsModule(function (module, exports) { 20383 /** 20384 * Various utility functions used throughout Mocha's codebase. 20385 * @module utils 20386 */ 20387 20388 /** 20389 * Module dependencies. 20390 */ 20391 20392 var nanoid = nonSecure.nanoid; 20393 var MOCHA_ID_PROP_NAME = '__mocha_id__'; 20394 /** 20395 * Inherit the prototype methods from one constructor into another. 20396 * 20397 * @param {function} ctor - Constructor function which needs to inherit the 20398 * prototype. 20399 * @param {function} superCtor - Constructor function to inherit prototype from. 20400 * @throws {TypeError} if either constructor is null, or if super constructor 20401 * lacks a prototype. 20402 */ 20403 20404 exports.inherits = util.inherits; 20405 /** 20406 * Escape special characters in the given string of html. 20407 * 20408 * @private 20409 * @param {string} html 20410 * @return {string} 20411 */ 20412 20413 exports.escape = function (html) { 20414 return he.encode(String(html), { 20415 useNamedReferences: false 20416 }); 20417 }; 20418 /** 20419 * Test if the given obj is type of string. 20420 * 20421 * @private 20422 * @param {Object} obj 20423 * @return {boolean} 20424 */ 20425 20426 20427 exports.isString = function (obj) { 20428 return typeof obj === 'string'; 20429 }; 20430 /** 20431 * Compute a slug from the given `str`. 20432 * 20433 * @private 20434 * @param {string} str 20435 * @return {string} 20436 */ 20437 20438 20439 exports.slug = function (str) { 20440 return str.toLowerCase().replace(/\s+/g, '-').replace(/[^-\w]/g, '').replace(/-{2,}/g, '-'); 20441 }; 20442 /** 20443 * Strip the function definition from `str`, and re-indent for pre whitespace. 20444 * 20445 * @param {string} str 20446 * @return {string} 20447 */ 20448 20449 20450 exports.clean = function (str) { 20451 str = str.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '') // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content 20452 .replace(/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/, '$1$2$3'); 20453 var spaces = str.match(/^\n?( *)/)[1].length; 20454 var tabs = str.match(/^\n?(\t*)/)[1].length; 20455 var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm'); 20456 str = str.replace(re, ''); 20457 return str.trim(); 20458 }; 20459 /** 20460 * If a value could have properties, and has none, this function is called, 20461 * which returns a string representation of the empty value. 20462 * 20463 * Functions w/ no properties return `'[Function]'` 20464 * Arrays w/ length === 0 return `'[]'` 20465 * Objects w/ no properties return `'{}'` 20466 * All else: return result of `value.toString()` 20467 * 20468 * @private 20469 * @param {*} value The value to inspect. 20470 * @param {string} typeHint The type of the value 20471 * @returns {string} 20472 */ 20473 20474 20475 function emptyRepresentation(value, typeHint) { 20476 switch (typeHint) { 20477 case 'function': 20478 return '[Function]'; 20479 20480 case 'object': 20481 return '{}'; 20482 20483 case 'array': 20484 return '[]'; 20485 20486 default: 20487 return value.toString(); 20488 } 20489 } 20490 /** 20491 * Takes some variable and asks `Object.prototype.toString()` what it thinks it 20492 * is. 20493 * 20494 * @private 20495 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString 20496 * @param {*} value The value to test. 20497 * @returns {string} Computed type 20498 * @example 20499 * canonicalType({}) // 'object' 20500 * canonicalType([]) // 'array' 20501 * canonicalType(1) // 'number' 20502 * canonicalType(false) // 'boolean' 20503 * canonicalType(Infinity) // 'number' 20504 * canonicalType(null) // 'null' 20505 * canonicalType(new Date()) // 'date' 20506 * canonicalType(/foo/) // 'regexp' 20507 * canonicalType('type') // 'string' 20508 * canonicalType(global) // 'global' 20509 * canonicalType(new String('foo') // 'object' 20510 * canonicalType(async function() {}) // 'asyncfunction' 20511 * canonicalType(await import(name)) // 'module' 20512 */ 20513 20514 20515 var canonicalType = exports.canonicalType = function canonicalType(value) { 20516 if (value === undefined) { 20517 return 'undefined'; 20518 } else if (value === null) { 20519 return 'null'; 20520 } else if (isBuffer(value)) { 20521 return 'buffer'; 20522 } 20523 20524 return Object.prototype.toString.call(value).replace(/^\[.+\s(.+?)]$/, '$1').toLowerCase(); 20525 }; 20526 /** 20527 * 20528 * Returns a general type or data structure of a variable 20529 * @private 20530 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures 20531 * @param {*} value The value to test. 20532 * @returns {string} One of undefined, boolean, number, string, bigint, symbol, object 20533 * @example 20534 * type({}) // 'object' 20535 * type([]) // 'array' 20536 * type(1) // 'number' 20537 * type(false) // 'boolean' 20538 * type(Infinity) // 'number' 20539 * type(null) // 'null' 20540 * type(new Date()) // 'object' 20541 * type(/foo/) // 'object' 20542 * type('type') // 'string' 20543 * type(global) // 'object' 20544 * type(new String('foo') // 'string' 20545 */ 20546 20547 20548 exports.type = function type(value) { 20549 // Null is special 20550 if (value === null) return 'null'; 20551 var primitives = new Set(['undefined', 'boolean', 'number', 'string', 'bigint', 'symbol']); 20552 20553 var _type = _typeof(value); 20554 20555 if (_type === 'function') return _type; 20556 if (primitives.has(_type)) return _type; 20557 if (value instanceof String) return 'string'; 20558 if (value instanceof Error) return 'error'; 20559 if (Array.isArray(value)) return 'array'; 20560 return _type; 20561 }; 20562 /** 20563 * Stringify `value`. Different behavior depending on type of value: 20564 * 20565 * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. 20566 * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. 20567 * - If `value` is an *empty* object, function, or array, return result of function 20568 * {@link emptyRepresentation}. 20569 * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of 20570 * JSON.stringify(). 20571 * 20572 * @private 20573 * @see exports.type 20574 * @param {*} value 20575 * @return {string} 20576 */ 20577 20578 20579 exports.stringify = function (value) { 20580 var typeHint = canonicalType(value); 20581 20582 if (!~['object', 'array', 'function'].indexOf(typeHint)) { 20583 if (typeHint === 'buffer') { 20584 var json = Buffer.prototype.toJSON.call(value); // Based on the toJSON result 20585 20586 return jsonStringify(json.data && json.type ? json.data : json, 2).replace(/,(\n|$)/g, '$1'); 20587 } // IE7/IE8 has a bizarre String constructor; needs to be coerced 20588 // into an array and back to obj. 20589 20590 20591 if (typeHint === 'string' && _typeof(value) === 'object') { 20592 value = value.split('').reduce(function (acc, _char, idx) { 20593 acc[idx] = _char; 20594 return acc; 20595 }, {}); 20596 typeHint = 'object'; 20597 } else { 20598 return jsonStringify(value); 20599 } 20600 } 20601 20602 for (var prop in value) { 20603 if (Object.prototype.hasOwnProperty.call(value, prop)) { 20604 return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, '$1'); 20605 } 20606 } 20607 20608 return emptyRepresentation(value, typeHint); 20609 }; 20610 /** 20611 * like JSON.stringify but more sense. 20612 * 20613 * @private 20614 * @param {Object} object 20615 * @param {number=} spaces 20616 * @param {number=} depth 20617 * @returns {*} 20618 */ 20619 20620 20621 function jsonStringify(object, spaces, depth) { 20622 if (typeof spaces === 'undefined') { 20623 // primitive types 20624 return _stringify(object); 20625 } 20626 20627 depth = depth || 1; 20628 var space = spaces * depth; 20629 var str = Array.isArray(object) ? '[' : '{'; 20630 var end = Array.isArray(object) ? ']' : '}'; 20631 var length = typeof object.length === 'number' ? object.length : Object.keys(object).length; // `.repeat()` polyfill 20632 20633 function repeat(s, n) { 20634 return new Array(n).join(s); 20635 } 20636 20637 function _stringify(val) { 20638 switch (canonicalType(val)) { 20639 case 'null': 20640 case 'undefined': 20641 val = '[' + val + ']'; 20642 break; 20643 20644 case 'array': 20645 case 'object': 20646 val = jsonStringify(val, spaces, depth + 1); 20647 break; 20648 20649 case 'boolean': 20650 case 'regexp': 20651 case 'symbol': 20652 case 'number': 20653 val = val === 0 && 1 / val === -Infinity // `-0` 20654 ? '-0' : val.toString(); 20655 break; 20656 20657 case 'bigint': 20658 val = val.toString() + 'n'; 20659 break; 20660 20661 case 'date': 20662 var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString(); 20663 val = '[Date: ' + sDate + ']'; 20664 break; 20665 20666 case 'buffer': 20667 var json = val.toJSON(); // Based on the toJSON result 20668 20669 json = json.data && json.type ? json.data : json; 20670 val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']'; 20671 break; 20672 20673 default: 20674 val = val === '[Function]' || val === '[Circular]' ? val : JSON.stringify(val); 20675 // string 20676 } 20677 20678 return val; 20679 } 20680 20681 for (var i in object) { 20682 if (!Object.prototype.hasOwnProperty.call(object, i)) { 20683 continue; // not my business 20684 } 20685 20686 --length; 20687 str += '\n ' + repeat(' ', space) + (Array.isArray(object) ? '' : '"' + i + '": ') + // key 20688 _stringify(object[i]) + ( // value 20689 length ? ',' : ''); // comma 20690 } 20691 20692 return str + ( // [], {} 20693 str.length !== 1 ? '\n' + repeat(' ', --space) + end : end); 20694 } 20695 /** 20696 * Return a new Thing that has the keys in sorted order. Recursive. 20697 * 20698 * If the Thing... 20699 * - has already been seen, return string `'[Circular]'` 20700 * - is `undefined`, return string `'[undefined]'` 20701 * - is `null`, return value `null` 20702 * - is some other primitive, return the value 20703 * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method 20704 * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. 20705 * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()` 20706 * 20707 * @private 20708 * @see {@link exports.stringify} 20709 * @param {*} value Thing to inspect. May or may not have properties. 20710 * @param {Array} [stack=[]] Stack of seen values 20711 * @param {string} [typeHint] Type hint 20712 * @return {(Object|Array|Function|string|undefined)} 20713 */ 20714 20715 20716 exports.canonicalize = function canonicalize(value, stack, typeHint) { 20717 var canonicalizedObj; 20718 /* eslint-disable no-unused-vars */ 20719 20720 var prop; 20721 /* eslint-enable no-unused-vars */ 20722 20723 typeHint = typeHint || canonicalType(value); 20724 20725 function withStack(value, fn) { 20726 stack.push(value); 20727 fn(); 20728 stack.pop(); 20729 } 20730 20731 stack = stack || []; 20732 20733 if (stack.indexOf(value) !== -1) { 20734 return '[Circular]'; 20735 } 20736 20737 switch (typeHint) { 20738 case 'undefined': 20739 case 'buffer': 20740 case 'null': 20741 canonicalizedObj = value; 20742 break; 20743 20744 case 'array': 20745 withStack(value, function () { 20746 canonicalizedObj = value.map(function (item) { 20747 return exports.canonicalize(item, stack); 20748 }); 20749 }); 20750 break; 20751 20752 case 'function': 20753 /* eslint-disable-next-line no-unused-vars */ 20754 for (prop in value) { 20755 canonicalizedObj = {}; 20756 break; 20757 } 20758 /* eslint-enable guard-for-in */ 20759 20760 20761 if (!canonicalizedObj) { 20762 canonicalizedObj = emptyRepresentation(value, typeHint); 20763 break; 20764 } 20765 20766 /* falls through */ 20767 20768 case 'object': 20769 canonicalizedObj = canonicalizedObj || {}; 20770 withStack(value, function () { 20771 Object.keys(value).sort().forEach(function (key) { 20772 canonicalizedObj[key] = exports.canonicalize(value[key], stack); 20773 }); 20774 }); 20775 break; 20776 20777 case 'date': 20778 case 'number': 20779 case 'regexp': 20780 case 'boolean': 20781 case 'symbol': 20782 canonicalizedObj = value; 20783 break; 20784 20785 default: 20786 canonicalizedObj = value + ''; 20787 } 20788 20789 return canonicalizedObj; 20790 }; 20791 /** 20792 * @summary 20793 * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`) 20794 * @description 20795 * When invoking this function you get a filter function that get the Error.stack as an input, 20796 * and return a prettify output. 20797 * (i.e: strip Mocha and internal node functions from stack trace). 20798 * @returns {Function} 20799 */ 20800 20801 20802 exports.stackTraceFilter = function () { 20803 // TODO: Replace with `process.browser` 20804 var is = typeof document === 'undefined' ? { 20805 node: true 20806 } : { 20807 browser: true 20808 }; 20809 var slash = path$1.sep; 20810 var cwd; 20811 20812 if (is.node) { 20813 cwd = exports.cwd() + slash; 20814 } else { 20815 cwd = (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^/]*$/, '/'); 20816 slash = '/'; 20817 } 20818 20819 function isMochaInternal(line) { 20820 return ~line.indexOf('node_modules' + slash + 'mocha' + slash) || ~line.indexOf(slash + 'mocha.js') || ~line.indexOf(slash + 'mocha.min.js'); 20821 } 20822 20823 function isNodeInternal(line) { 20824 return ~line.indexOf('(timers.js:') || ~line.indexOf('(events.js:') || ~line.indexOf('(node.js:') || ~line.indexOf('(module.js:') || ~line.indexOf('GeneratorFunctionPrototype.next (native)') || false; 20825 } 20826 20827 return function (stack) { 20828 stack = stack.split('\n'); 20829 stack = stack.reduce(function (list, line) { 20830 if (isMochaInternal(line)) { 20831 return list; 20832 } 20833 20834 if (is.node && isNodeInternal(line)) { 20835 return list; 20836 } // Clean up cwd(absolute) 20837 20838 20839 if (/:\d+:\d+\)?$/.test(line)) { 20840 line = line.replace('(' + cwd, '('); 20841 } 20842 20843 list.push(line); 20844 return list; 20845 }, []); 20846 return stack.join('\n'); 20847 }; 20848 }; 20849 /** 20850 * Crude, but effective. 20851 * @public 20852 * @param {*} value 20853 * @returns {boolean} Whether or not `value` is a Promise 20854 */ 20855 20856 20857 exports.isPromise = function isPromise(value) { 20858 return _typeof(value) === 'object' && value !== null && typeof value.then === 'function'; 20859 }; 20860 /** 20861 * Clamps a numeric value to an inclusive range. 20862 * 20863 * @param {number} value - Value to be clamped. 20864 * @param {number[]} range - Two element array specifying [min, max] range. 20865 * @returns {number} clamped value 20866 */ 20867 20868 20869 exports.clamp = function clamp(value, range) { 20870 return Math.min(Math.max(value, range[0]), range[1]); 20871 }; 20872 /** 20873 * Single quote text by combining with undirectional ASCII quotation marks. 20874 * 20875 * @description 20876 * Provides a simple means of markup for quoting text to be used in output. 20877 * Use this to quote names of variables, methods, and packages. 20878 * 20879 * <samp>package 'foo' cannot be found</samp> 20880 * 20881 * @private 20882 * @param {string} str - Value to be quoted. 20883 * @returns {string} quoted value 20884 * @example 20885 * sQuote('n') // => 'n' 20886 */ 20887 20888 20889 exports.sQuote = function (str) { 20890 return "'" + str + "'"; 20891 }; 20892 /** 20893 * Double quote text by combining with undirectional ASCII quotation marks. 20894 * 20895 * @description 20896 * Provides a simple means of markup for quoting text to be used in output. 20897 * Use this to quote names of datatypes, classes, pathnames, and strings. 20898 * 20899 * <samp>argument 'value' must be "string" or "number"</samp> 20900 * 20901 * @private 20902 * @param {string} str - Value to be quoted. 20903 * @returns {string} quoted value 20904 * @example 20905 * dQuote('number') // => "number" 20906 */ 20907 20908 20909 exports.dQuote = function (str) { 20910 return '"' + str + '"'; 20911 }; 20912 /** 20913 * It's a noop. 20914 * @public 20915 */ 20916 20917 20918 exports.noop = function () {}; 20919 /** 20920 * Creates a map-like object. 20921 * 20922 * @description 20923 * A "map" is an object with no prototype, for our purposes. In some cases 20924 * this would be more appropriate than a `Map`, especially if your environment 20925 * doesn't support it. Recommended for use in Mocha's public APIs. 20926 * 20927 * @public 20928 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Custom_and_Null_objects|MDN:Map} 20929 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects|MDN:Object.create - Custom objects} 20930 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Custom_and_Null_objects|MDN:Object.assign} 20931 * @param {...*} [obj] - Arguments to `Object.assign()`. 20932 * @returns {Object} An object with no prototype, having `...obj` properties 20933 */ 20934 20935 20936 exports.createMap = function (obj) { 20937 return Object.assign.apply(null, [Object.create(null)].concat(Array.prototype.slice.call(arguments))); 20938 }; 20939 /** 20940 * Creates a read-only map-like object. 20941 * 20942 * @description 20943 * This differs from {@link module:utils.createMap createMap} only in that 20944 * the argument must be non-empty, because the result is frozen. 20945 * 20946 * @see {@link module:utils.createMap createMap} 20947 * @param {...*} [obj] - Arguments to `Object.assign()`. 20948 * @returns {Object} A frozen object with no prototype, having `...obj` properties 20949 * @throws {TypeError} if argument is not a non-empty object. 20950 */ 20951 20952 20953 exports.defineConstants = function (obj) { 20954 if (canonicalType(obj) !== 'object' || !Object.keys(obj).length) { 20955 throw new TypeError('Invalid argument; expected a non-empty object'); 20956 } 20957 20958 return Object.freeze(exports.createMap(obj)); 20959 }; 20960 /** 20961 * Whether current version of Node support ES modules 20962 * 20963 * @description 20964 * Versions prior to 10 did not support ES Modules, and version 10 has an old incompatible version of ESM. 20965 * This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs, 20966 * which is version >=12.11. 20967 * 20968 * @param {partialSupport} whether the full Node.js ESM support is available (>= 12) or just something that supports the runtime (>= 10) 20969 * 20970 * @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatible with Mocha 20971 */ 20972 20973 20974 exports.supportsEsModules = function (partialSupport) { 20975 if (!exports.isBrowser() && process$1.versions && process$1.versions.node) { 20976 var versionFields = process$1.versions.node.split('.'); 20977 var major = +versionFields[0]; 20978 var minor = +versionFields[1]; 20979 20980 if (!partialSupport) { 20981 return major >= 13 || major === 12 && minor >= 11; 20982 } else { 20983 return major >= 10; 20984 } 20985 } 20986 }; 20987 /** 20988 * Returns current working directory 20989 * 20990 * Wrapper around `process.cwd()` for isolation 20991 * @private 20992 */ 20993 20994 20995 exports.cwd = function cwd() { 20996 return process$1.cwd(); 20997 }; 20998 /** 20999 * Returns `true` if Mocha is running in a browser. 21000 * Checks for `process.browser`. 21001 * @returns {boolean} 21002 * @private 21003 */ 21004 21005 21006 exports.isBrowser = function isBrowser() { 21007 return Boolean(browser$1); 21008 }; 21009 /** 21010 * Lookup file names at the given `path`. 21011 * 21012 * @description 21013 * Filenames are returned in _traversal_ order by the OS/filesystem. 21014 * **Make no assumption that the names will be sorted in any fashion.** 21015 * 21016 * @public 21017 * @alias module:lib/cli.lookupFiles 21018 * @param {string} filepath - Base path to start searching from. 21019 * @param {string[]} [extensions=[]] - File extensions to look for. 21020 * @param {boolean} [recursive=false] - Whether to recurse into subdirectories. 21021 * @return {string[]} An array of paths. 21022 * @throws {Error} if no files match pattern. 21023 * @throws {TypeError} if `filepath` is directory and `extensions` not provided. 21024 * @deprecated Moved to {@link module:lib/cli.lookupFiles} 21025 */ 21026 21027 21028 exports.lookupFiles = function () { 21029 if (exports.isBrowser()) { 21030 throw errors.createUnsupportedError('lookupFiles() is only supported in Node.js!'); 21031 } 21032 21033 errors.deprecate('`lookupFiles()` in module `mocha/lib/utils` has moved to module `mocha/lib/cli` and will be removed in the next major revision of Mocha'); 21034 return require$$11.lookupFiles.apply(require$$11, arguments); 21035 }; 21036 /* 21037 * Casts `value` to an array; useful for optionally accepting array parameters 21038 * 21039 * It follows these rules, depending on `value`. If `value` is... 21040 * 1. `undefined`: return an empty Array 21041 * 2. `null`: return an array with a single `null` element 21042 * 3. Any other object: return the value of `Array.from()` _if_ the object is iterable 21043 * 4. otherwise: return an array with a single element, `value` 21044 * @param {*} value - Something to cast to an Array 21045 * @returns {Array<*>} 21046 */ 21047 21048 21049 exports.castArray = function castArray(value) { 21050 if (value === undefined) { 21051 return []; 21052 } 21053 21054 if (value === null) { 21055 return [null]; 21056 } 21057 21058 if (_typeof(value) === 'object' && (typeof value[Symbol.iterator] === 'function' || value.length !== undefined)) { 21059 return Array.from(value); 21060 } 21061 21062 return [value]; 21063 }; 21064 21065 exports.constants = exports.defineConstants({ 21066 MOCHA_ID_PROP_NAME: MOCHA_ID_PROP_NAME 21067 }); 21068 /** 21069 * Creates a new unique identifier 21070 * @returns {string} Unique identifier 21071 */ 21072 21073 exports.uniqueID = function () { 21074 return nanoid(); 21075 }; 21076 21077 exports.assignNewMochaID = function (obj) { 21078 var id = exports.uniqueID(); 21079 Object.defineProperty(obj, MOCHA_ID_PROP_NAME, { 21080 get: function get() { 21081 return id; 21082 } 21083 }); 21084 return obj; 21085 }; 21086 /** 21087 * Retrieves a Mocha ID from an object, if present. 21088 * @param {*} [obj] - Object 21089 * @returns {string|void} 21090 */ 21091 21092 21093 exports.getMochaID = function (obj) { 21094 return obj && _typeof(obj) === 'object' ? obj[MOCHA_ID_PROP_NAME] : undefined; 21095 }; 21096 }); 21097 21098 // `Map` constructor 21099 // https://tc39.es/ecma262/#sec-map-objects 21100 collection('Map', function (init) { 21101 return function Map() { return init(this, arguments.length ? arguments[0] : undefined); }; 21102 }, collectionStrong); 21103 21104 /** 21105 @module Pending 21106 */ 21107 21108 var pending = Pending; 21109 /** 21110 * Initialize a new `Pending` error with the given message. 21111 * 21112 * @param {string} message 21113 */ 21114 21115 function Pending(message) { 21116 this.message = message; 21117 } 21118 21119 /** 21120 * Helpers. 21121 */ 21122 var s$1 = 1000; 21123 var m$1 = s$1 * 60; 21124 var h$1 = m$1 * 60; 21125 var d$1 = h$1 * 24; 21126 var w$1 = d$1 * 7; 21127 var y$1 = d$1 * 365.25; 21128 /** 21129 * Parse or format the given `val`. 21130 * 21131 * Options: 21132 * 21133 * - `long` verbose formatting [false] 21134 * 21135 * @param {String|Number} val 21136 * @param {Object} [options] 21137 * @throws {Error} throw an error if val is not a non-empty string or a number 21138 * @return {String|Number} 21139 * @api public 21140 */ 21141 21142 var ms$1 = function ms(val, options) { 21143 options = options || {}; 21144 21145 var type = _typeof(val); 21146 21147 if (type === 'string' && val.length > 0) { 21148 return parse$1(val); 21149 } else if (type === 'number' && isFinite(val)) { 21150 return options["long"] ? fmtLong$1(val) : fmtShort$1(val); 21151 } 21152 21153 throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)); 21154 }; 21155 /** 21156 * Parse the given `str` and return milliseconds. 21157 * 21158 * @param {String} str 21159 * @return {Number} 21160 * @api private 21161 */ 21162 21163 21164 function parse$1(str) { 21165 str = String(str); 21166 21167 if (str.length > 100) { 21168 return; 21169 } 21170 21171 var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); 21172 21173 if (!match) { 21174 return; 21175 } 21176 21177 var n = parseFloat(match[1]); 21178 var type = (match[2] || 'ms').toLowerCase(); 21179 21180 switch (type) { 21181 case 'years': 21182 case 'year': 21183 case 'yrs': 21184 case 'yr': 21185 case 'y': 21186 return n * y$1; 21187 21188 case 'weeks': 21189 case 'week': 21190 case 'w': 21191 return n * w$1; 21192 21193 case 'days': 21194 case 'day': 21195 case 'd': 21196 return n * d$1; 21197 21198 case 'hours': 21199 case 'hour': 21200 case 'hrs': 21201 case 'hr': 21202 case 'h': 21203 return n * h$1; 21204 21205 case 'minutes': 21206 case 'minute': 21207 case 'mins': 21208 case 'min': 21209 case 'm': 21210 return n * m$1; 21211 21212 case 'seconds': 21213 case 'second': 21214 case 'secs': 21215 case 'sec': 21216 case 's': 21217 return n * s$1; 21218 21219 case 'milliseconds': 21220 case 'millisecond': 21221 case 'msecs': 21222 case 'msec': 21223 case 'ms': 21224 return n; 21225 21226 default: 21227 return undefined; 21228 } 21229 } 21230 /** 21231 * Short format for `ms`. 21232 * 21233 * @param {Number} ms 21234 * @return {String} 21235 * @api private 21236 */ 21237 21238 21239 function fmtShort$1(ms) { 21240 var msAbs = Math.abs(ms); 21241 21242 if (msAbs >= d$1) { 21243 return Math.round(ms / d$1) + 'd'; 21244 } 21245 21246 if (msAbs >= h$1) { 21247 return Math.round(ms / h$1) + 'h'; 21248 } 21249 21250 if (msAbs >= m$1) { 21251 return Math.round(ms / m$1) + 'm'; 21252 } 21253 21254 if (msAbs >= s$1) { 21255 return Math.round(ms / s$1) + 's'; 21256 } 21257 21258 return ms + 'ms'; 21259 } 21260 /** 21261 * Long format for `ms`. 21262 * 21263 * @param {Number} ms 21264 * @return {String} 21265 * @api private 21266 */ 21267 21268 21269 function fmtLong$1(ms) { 21270 var msAbs = Math.abs(ms); 21271 21272 if (msAbs >= d$1) { 21273 return plural$1(ms, msAbs, d$1, 'day'); 21274 } 21275 21276 if (msAbs >= h$1) { 21277 return plural$1(ms, msAbs, h$1, 'hour'); 21278 } 21279 21280 if (msAbs >= m$1) { 21281 return plural$1(ms, msAbs, m$1, 'minute'); 21282 } 21283 21284 if (msAbs >= s$1) { 21285 return plural$1(ms, msAbs, s$1, 'second'); 21286 } 21287 21288 return ms + ' ms'; 21289 } 21290 /** 21291 * Pluralization helper. 21292 */ 21293 21294 21295 function plural$1(ms, msAbs, n, name) { 21296 var isPlural = msAbs >= n * 1.5; 21297 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); 21298 } 21299 21300 /** 21301 * This is the common logic for both the Node.js and web browser 21302 * implementations of `debug()`. 21303 */ 21304 21305 function setup(env) { 21306 createDebug.debug = createDebug; 21307 createDebug["default"] = createDebug; 21308 createDebug.coerce = coerce; 21309 createDebug.disable = disable; 21310 createDebug.enable = enable; 21311 createDebug.enabled = enabled; 21312 createDebug.humanize = ms$1; 21313 createDebug.destroy = destroy; 21314 Object.keys(env).forEach(function (key) { 21315 createDebug[key] = env[key]; 21316 }); 21317 /** 21318 * The currently active debug mode names, and names to skip. 21319 */ 21320 21321 createDebug.names = []; 21322 createDebug.skips = []; 21323 /** 21324 * Map of special "%n" handling functions, for the debug "format" argument. 21325 * 21326 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". 21327 */ 21328 21329 createDebug.formatters = {}; 21330 /** 21331 * Selects a color for a debug namespace 21332 * @param {String} namespace The namespace string for the for the debug instance to be colored 21333 * @return {Number|String} An ANSI color code for the given namespace 21334 * @api private 21335 */ 21336 21337 function selectColor(namespace) { 21338 var hash = 0; 21339 21340 for (var i = 0; i < namespace.length; i++) { 21341 hash = (hash << 5) - hash + namespace.charCodeAt(i); 21342 hash |= 0; // Convert to 32bit integer 21343 } 21344 21345 return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; 21346 } 21347 21348 createDebug.selectColor = selectColor; 21349 /** 21350 * Create a debugger with the given `namespace`. 21351 * 21352 * @param {String} namespace 21353 * @return {Function} 21354 * @api public 21355 */ 21356 21357 function createDebug(namespace) { 21358 var prevTime; 21359 var enableOverride = null; 21360 21361 function debug() { 21362 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 21363 args[_key] = arguments[_key]; 21364 } 21365 21366 // Disabled? 21367 if (!debug.enabled) { 21368 return; 21369 } 21370 21371 var self = debug; // Set `diff` timestamp 21372 21373 var curr = Number(new Date()); 21374 var ms = curr - (prevTime || curr); 21375 self.diff = ms; 21376 self.prev = prevTime; 21377 self.curr = curr; 21378 prevTime = curr; 21379 args[0] = createDebug.coerce(args[0]); 21380 21381 if (typeof args[0] !== 'string') { 21382 // Anything else let's inspect with %O 21383 args.unshift('%O'); 21384 } // Apply any `formatters` transformations 21385 21386 21387 var index = 0; 21388 args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) { 21389 // If we encounter an escaped % then don't increase the array index 21390 if (match === '%%') { 21391 return '%'; 21392 } 21393 21394 index++; 21395 var formatter = createDebug.formatters[format]; 21396 21397 if (typeof formatter === 'function') { 21398 var val = args[index]; 21399 match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format` 21400 21401 args.splice(index, 1); 21402 index--; 21403 } 21404 21405 return match; 21406 }); // Apply env-specific formatting (colors, etc.) 21407 21408 createDebug.formatArgs.call(self, args); 21409 var logFn = self.log || createDebug.log; 21410 logFn.apply(self, args); 21411 } 21412 21413 debug.namespace = namespace; 21414 debug.useColors = createDebug.useColors(); 21415 debug.color = createDebug.selectColor(namespace); 21416 debug.extend = extend; 21417 debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. 21418 21419 Object.defineProperty(debug, 'enabled', { 21420 enumerable: true, 21421 configurable: false, 21422 get: function get() { 21423 return enableOverride === null ? createDebug.enabled(namespace) : enableOverride; 21424 }, 21425 set: function set(v) { 21426 enableOverride = v; 21427 } 21428 }); // Env-specific initialization logic for debug instances 21429 21430 if (typeof createDebug.init === 'function') { 21431 createDebug.init(debug); 21432 } 21433 21434 return debug; 21435 } 21436 21437 function extend(namespace, delimiter) { 21438 var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); 21439 newDebug.log = this.log; 21440 return newDebug; 21441 } 21442 /** 21443 * Enables a debug mode by namespaces. This can include modes 21444 * separated by a colon and wildcards. 21445 * 21446 * @param {String} namespaces 21447 * @api public 21448 */ 21449 21450 21451 function enable(namespaces) { 21452 createDebug.save(namespaces); 21453 createDebug.names = []; 21454 createDebug.skips = []; 21455 var i; 21456 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); 21457 var len = split.length; 21458 21459 for (i = 0; i < len; i++) { 21460 if (!split[i]) { 21461 // ignore empty strings 21462 continue; 21463 } 21464 21465 namespaces = split[i].replace(/\*/g, '.*?'); 21466 21467 if (namespaces[0] === '-') { 21468 createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); 21469 } else { 21470 createDebug.names.push(new RegExp('^' + namespaces + '$')); 21471 } 21472 } 21473 } 21474 /** 21475 * Disable debug output. 21476 * 21477 * @return {String} namespaces 21478 * @api public 21479 */ 21480 21481 21482 function disable() { 21483 var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) { 21484 return '-' + namespace; 21485 }))).join(','); 21486 createDebug.enable(''); 21487 return namespaces; 21488 } 21489 /** 21490 * Returns true if the given mode name is enabled, false otherwise. 21491 * 21492 * @param {String} name 21493 * @return {Boolean} 21494 * @api public 21495 */ 21496 21497 21498 function enabled(name) { 21499 if (name[name.length - 1] === '*') { 21500 return true; 21501 } 21502 21503 var i; 21504 var len; 21505 21506 for (i = 0, len = createDebug.skips.length; i < len; i++) { 21507 if (createDebug.skips[i].test(name)) { 21508 return false; 21509 } 21510 } 21511 21512 for (i = 0, len = createDebug.names.length; i < len; i++) { 21513 if (createDebug.names[i].test(name)) { 21514 return true; 21515 } 21516 } 21517 21518 return false; 21519 } 21520 /** 21521 * Convert regexp to namespace 21522 * 21523 * @param {RegExp} regxep 21524 * @return {String} namespace 21525 * @api private 21526 */ 21527 21528 21529 function toNamespace(regexp) { 21530 return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*'); 21531 } 21532 /** 21533 * Coerce `val`. 21534 * 21535 * @param {Mixed} val 21536 * @return {Mixed} 21537 * @api private 21538 */ 21539 21540 21541 function coerce(val) { 21542 if (val instanceof Error) { 21543 return val.stack || val.message; 21544 } 21545 21546 return val; 21547 } 21548 /** 21549 * XXX DO NOT USE. This is a temporary stub function. 21550 * XXX It WILL be removed in the next major release. 21551 */ 21552 21553 21554 function destroy() { 21555 console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); 21556 } 21557 21558 createDebug.enable(createDebug.load()); 21559 return createDebug; 21560 } 21561 21562 var common = setup; 21563 21564 var browser$2 = createCommonjsModule(function (module, exports) { 21565 /* eslint-env browser */ 21566 21567 /** 21568 * This is the web browser implementation of `debug()`. 21569 */ 21570 exports.formatArgs = formatArgs; 21571 exports.save = save; 21572 exports.load = load; 21573 exports.useColors = useColors; 21574 exports.storage = localstorage(); 21575 21576 exports.destroy = function () { 21577 var warned = false; 21578 return function () { 21579 if (!warned) { 21580 warned = true; 21581 console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); 21582 } 21583 }; 21584 }(); 21585 /** 21586 * Colors. 21587 */ 21588 21589 21590 exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33']; 21591 /** 21592 * Currently only WebKit-based Web Inspectors, Firefox >= v31, 21593 * and the Firebug extension (any Firefox version) are known 21594 * to support "%c" CSS customizations. 21595 * 21596 * TODO: add a `localStorage` variable to explicitly enable/disable colors 21597 */ 21598 // eslint-disable-next-line complexity 21599 21600 function useColors() { 21601 // NB: In an Electron preload script, document will be defined but not fully 21602 // initialized. Since we know we're in Chrome, we'll just detect this case 21603 // explicitly 21604 if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { 21605 return true; 21606 } // Internet Explorer and Edge do not support colors. 21607 21608 21609 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { 21610 return false; 21611 } // Is webkit? http://stackoverflow.com/a/16459606/376773 21612 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 21613 21614 21615 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 21616 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? 21617 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages 21618 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker 21619 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); 21620 } 21621 /** 21622 * Colorize log arguments if enabled. 21623 * 21624 * @api public 21625 */ 21626 21627 21628 function formatArgs(args) { 21629 args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); 21630 21631 if (!this.useColors) { 21632 return; 21633 } 21634 21635 var c = 'color: ' + this.color; 21636 args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other 21637 // arguments passed either before or after the %c, so we need to 21638 // figure out the correct index to insert the CSS into 21639 21640 var index = 0; 21641 var lastC = 0; 21642 args[0].replace(/%[a-zA-Z%]/g, function (match) { 21643 if (match === '%%') { 21644 return; 21645 } 21646 21647 index++; 21648 21649 if (match === '%c') { 21650 // We only are interested in the *last* %c 21651 // (the user may have provided their own) 21652 lastC = index; 21653 } 21654 }); 21655 args.splice(lastC, 0, c); 21656 } 21657 /** 21658 * Invokes `console.debug()` when available. 21659 * No-op when `console.debug` is not a "function". 21660 * If `console.debug` is not available, falls back 21661 * to `console.log`. 21662 * 21663 * @api public 21664 */ 21665 21666 21667 exports.log = console.debug || console.log || function () {}; 21668 /** 21669 * Save `namespaces`. 21670 * 21671 * @param {String} namespaces 21672 * @api private 21673 */ 21674 21675 21676 function save(namespaces) { 21677 try { 21678 if (namespaces) { 21679 exports.storage.setItem('debug', namespaces); 21680 } else { 21681 exports.storage.removeItem('debug'); 21682 } 21683 } catch (error) {// Swallow 21684 // XXX (@Qix-) should we be logging these? 21685 } 21686 } 21687 /** 21688 * Load `namespaces`. 21689 * 21690 * @return {String} returns the previously persisted debug modes 21691 * @api private 21692 */ 21693 21694 21695 function load() { 21696 var r; 21697 21698 try { 21699 r = exports.storage.getItem('debug'); 21700 } catch (error) {// Swallow 21701 // XXX (@Qix-) should we be logging these? 21702 } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG 21703 21704 21705 if (!r && typeof process$1 !== 'undefined' && 'env' in process$1) { 21706 r = process$1.env.DEBUG; 21707 } 21708 21709 return r; 21710 } 21711 /** 21712 * Localstorage attempts to return the localstorage. 21713 * 21714 * This is necessary because safari throws 21715 * when a user disables cookies/localstorage 21716 * and you attempt to access it. 21717 * 21718 * @return {LocalStorage} 21719 * @api private 21720 */ 21721 21722 21723 function localstorage() { 21724 try { 21725 // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context 21726 // The Browser also has localStorage in the global context. 21727 return localStorage; 21728 } catch (error) {// Swallow 21729 // XXX (@Qix-) should we be logging these? 21730 } 21731 } 21732 21733 module.exports = common(exports); 21734 var formatters = module.exports.formatters; 21735 /** 21736 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. 21737 */ 21738 21739 formatters.j = function (v) { 21740 try { 21741 return JSON.stringify(v); 21742 } catch (error) { 21743 return '[UnexpectedJSONParseError]: ' + error.message; 21744 } 21745 }; 21746 }); 21747 21748 var EventEmitter$1 = EventEmitter.EventEmitter; 21749 var debug$1 = browser$2('mocha:runnable'); 21750 var createInvalidExceptionError$1 = errors.createInvalidExceptionError, 21751 createMultipleDoneError$1 = errors.createMultipleDoneError, 21752 createTimeoutError$1 = errors.createTimeoutError; 21753 /** 21754 * Save timer references to avoid Sinon interfering (see GH-237). 21755 * @private 21756 */ 21757 21758 var Date$1 = commonjsGlobal.Date; 21759 var setTimeout$1 = commonjsGlobal.setTimeout; 21760 var clearTimeout$1 = commonjsGlobal.clearTimeout; 21761 var toString$4 = Object.prototype.toString; 21762 var runnable = Runnable; 21763 /** 21764 * Initialize a new `Runnable` with the given `title` and callback `fn`. 21765 * 21766 * @class 21767 * @extends external:EventEmitter 21768 * @public 21769 * @param {String} title 21770 * @param {Function} fn 21771 */ 21772 21773 function Runnable(title, fn) { 21774 this.title = title; 21775 this.fn = fn; 21776 this.body = (fn || '').toString(); 21777 this.async = fn && fn.length; 21778 this.sync = !this.async; 21779 this._timeout = 2000; 21780 this._slow = 75; 21781 this._retries = -1; 21782 utils.assignNewMochaID(this); 21783 Object.defineProperty(this, 'id', { 21784 get: function get() { 21785 return utils.getMochaID(this); 21786 } 21787 }); 21788 this.reset(); 21789 } 21790 /** 21791 * Inherit from `EventEmitter.prototype`. 21792 */ 21793 21794 21795 utils.inherits(Runnable, EventEmitter$1); 21796 /** 21797 * Resets the state initially or for a next run. 21798 */ 21799 21800 Runnable.prototype.reset = function () { 21801 this.timedOut = false; 21802 this._currentRetry = 0; 21803 this.pending = false; 21804 delete this.state; 21805 delete this.err; 21806 }; 21807 /** 21808 * Get current timeout value in msecs. 21809 * 21810 * @private 21811 * @returns {number} current timeout threshold value 21812 */ 21813 21814 /** 21815 * @summary 21816 * Set timeout threshold value (msecs). 21817 * 21818 * @description 21819 * A string argument can use shorthand (e.g., "2s") and will be converted. 21820 * The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>]. 21821 * If clamped value matches either range endpoint, timeouts will be disabled. 21822 * 21823 * @private 21824 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value} 21825 * @param {number|string} ms - Timeout threshold value. 21826 * @returns {Runnable} this 21827 * @chainable 21828 */ 21829 21830 21831 Runnable.prototype.timeout = function (ms$1) { 21832 if (!arguments.length) { 21833 return this._timeout; 21834 } 21835 21836 if (typeof ms$1 === 'string') { 21837 ms$1 = ms(ms$1); 21838 } // Clamp to range 21839 21840 21841 var INT_MAX = Math.pow(2, 31) - 1; 21842 var range = [0, INT_MAX]; 21843 ms$1 = utils.clamp(ms$1, range); // see #1652 for reasoning 21844 21845 if (ms$1 === range[0] || ms$1 === range[1]) { 21846 this._timeout = 0; 21847 } else { 21848 this._timeout = ms$1; 21849 } 21850 21851 debug$1('timeout %d', this._timeout); 21852 21853 if (this.timer) { 21854 this.resetTimeout(); 21855 } 21856 21857 return this; 21858 }; 21859 /** 21860 * Set or get slow `ms`. 21861 * 21862 * @private 21863 * @param {number|string} ms 21864 * @return {Runnable|number} ms or Runnable instance. 21865 */ 21866 21867 21868 Runnable.prototype.slow = function (ms$1) { 21869 if (!arguments.length || typeof ms$1 === 'undefined') { 21870 return this._slow; 21871 } 21872 21873 if (typeof ms$1 === 'string') { 21874 ms$1 = ms(ms$1); 21875 } 21876 21877 debug$1('slow %d', ms$1); 21878 this._slow = ms$1; 21879 return this; 21880 }; 21881 /** 21882 * Halt and mark as pending. 21883 * 21884 * @memberof Mocha.Runnable 21885 * @public 21886 */ 21887 21888 21889 Runnable.prototype.skip = function () { 21890 this.pending = true; 21891 throw new pending('sync skip; aborting execution'); 21892 }; 21893 /** 21894 * Check if this runnable or its parent suite is marked as pending. 21895 * 21896 * @private 21897 */ 21898 21899 21900 Runnable.prototype.isPending = function () { 21901 return this.pending || this.parent && this.parent.isPending(); 21902 }; 21903 /** 21904 * Return `true` if this Runnable has failed. 21905 * @return {boolean} 21906 * @private 21907 */ 21908 21909 21910 Runnable.prototype.isFailed = function () { 21911 return !this.isPending() && this.state === constants$1.STATE_FAILED; 21912 }; 21913 /** 21914 * Return `true` if this Runnable has passed. 21915 * @return {boolean} 21916 * @private 21917 */ 21918 21919 21920 Runnable.prototype.isPassed = function () { 21921 return !this.isPending() && this.state === constants$1.STATE_PASSED; 21922 }; 21923 /** 21924 * Set or get number of retries. 21925 * 21926 * @private 21927 */ 21928 21929 21930 Runnable.prototype.retries = function (n) { 21931 if (!arguments.length) { 21932 return this._retries; 21933 } 21934 21935 this._retries = n; 21936 }; 21937 /** 21938 * Set or get current retry 21939 * 21940 * @private 21941 */ 21942 21943 21944 Runnable.prototype.currentRetry = function (n) { 21945 if (!arguments.length) { 21946 return this._currentRetry; 21947 } 21948 21949 this._currentRetry = n; 21950 }; 21951 /** 21952 * Return the full title generated by recursively concatenating the parent's 21953 * full title. 21954 * 21955 * @memberof Mocha.Runnable 21956 * @public 21957 * @return {string} 21958 */ 21959 21960 21961 Runnable.prototype.fullTitle = function () { 21962 return this.titlePath().join(' '); 21963 }; 21964 /** 21965 * Return the title path generated by concatenating the parent's title path with the title. 21966 * 21967 * @memberof Mocha.Runnable 21968 * @public 21969 * @return {string} 21970 */ 21971 21972 21973 Runnable.prototype.titlePath = function () { 21974 return this.parent.titlePath().concat([this.title]); 21975 }; 21976 /** 21977 * Clear the timeout. 21978 * 21979 * @private 21980 */ 21981 21982 21983 Runnable.prototype.clearTimeout = function () { 21984 clearTimeout$1(this.timer); 21985 }; 21986 /** 21987 * Reset the timeout. 21988 * 21989 * @private 21990 */ 21991 21992 21993 Runnable.prototype.resetTimeout = function () { 21994 var self = this; 21995 var ms = this.timeout(); 21996 21997 if (ms === 0) { 21998 return; 21999 } 22000 22001 this.clearTimeout(); 22002 this.timer = setTimeout$1(function () { 22003 if (self.timeout() === 0) { 22004 return; 22005 } 22006 22007 self.callback(self._timeoutError(ms)); 22008 self.timedOut = true; 22009 }, ms); 22010 }; 22011 /** 22012 * Set or get a list of whitelisted globals for this test run. 22013 * 22014 * @private 22015 * @param {string[]} globals 22016 */ 22017 22018 22019 Runnable.prototype.globals = function (globals) { 22020 if (!arguments.length) { 22021 return this._allowedGlobals; 22022 } 22023 22024 this._allowedGlobals = globals; 22025 }; 22026 /** 22027 * Run the test and invoke `fn(err)`. 22028 * 22029 * @param {Function} fn 22030 * @private 22031 */ 22032 22033 22034 Runnable.prototype.run = function (fn) { 22035 var self = this; 22036 var start = new Date$1(); 22037 var ctx = this.ctx; 22038 var finished; 22039 var errorWasHandled = false; 22040 if (this.isPending()) return fn(); // Sometimes the ctx exists, but it is not runnable 22041 22042 if (ctx && ctx.runnable) { 22043 ctx.runnable(this); 22044 } // called multiple times 22045 22046 22047 function multiple(err) { 22048 if (errorWasHandled) { 22049 return; 22050 } 22051 22052 errorWasHandled = true; 22053 self.emit('error', createMultipleDoneError$1(self, err)); 22054 } // finished 22055 22056 22057 function done(err) { 22058 var ms = self.timeout(); 22059 22060 if (self.timedOut) { 22061 return; 22062 } 22063 22064 if (finished) { 22065 return multiple(err); 22066 } 22067 22068 self.clearTimeout(); 22069 self.duration = new Date$1() - start; 22070 finished = true; 22071 22072 if (!err && self.duration > ms && ms > 0) { 22073 err = self._timeoutError(ms); 22074 } 22075 22076 fn(err); 22077 } // for .resetTimeout() and Runner#uncaught() 22078 22079 22080 this.callback = done; 22081 22082 if (this.fn && typeof this.fn.call !== 'function') { 22083 done(new TypeError('A runnable must be passed a function as its second argument.')); 22084 return; 22085 } // explicit async with `done` argument 22086 22087 22088 if (this.async) { 22089 this.resetTimeout(); // allows skip() to be used in an explicit async context 22090 22091 this.skip = function asyncSkip() { 22092 this.pending = true; 22093 done(); // halt execution, the uncaught handler will ignore the failure. 22094 22095 throw new pending('async skip; aborting execution'); 22096 }; 22097 22098 try { 22099 callFnAsync(this.fn); 22100 } catch (err) { 22101 // handles async runnables which actually run synchronously 22102 errorWasHandled = true; 22103 22104 if (err instanceof pending) { 22105 return; // done() is already called in this.skip() 22106 } else if (this.allowUncaught) { 22107 throw err; 22108 } 22109 22110 done(Runnable.toValueOrError(err)); 22111 } 22112 22113 return; 22114 } // sync or promise-returning 22115 22116 22117 try { 22118 callFn(this.fn); 22119 } catch (err) { 22120 errorWasHandled = true; 22121 22122 if (err instanceof pending) { 22123 return done(); 22124 } else if (this.allowUncaught) { 22125 throw err; 22126 } 22127 22128 done(Runnable.toValueOrError(err)); 22129 } 22130 22131 function callFn(fn) { 22132 var result = fn.call(ctx); 22133 22134 if (result && typeof result.then === 'function') { 22135 self.resetTimeout(); 22136 result.then(function () { 22137 done(); // Return null so libraries like bluebird do not warn about 22138 // subsequently constructed Promises. 22139 22140 return null; 22141 }, function (reason) { 22142 done(reason || new Error('Promise rejected with no or falsy reason')); 22143 }); 22144 } else { 22145 if (self.asyncOnly) { 22146 return done(new Error('--async-only option in use without declaring `done()` or returning a promise')); 22147 } 22148 22149 done(); 22150 } 22151 } 22152 22153 function callFnAsync(fn) { 22154 var result = fn.call(ctx, function (err) { 22155 if (err instanceof Error || toString$4.call(err) === '[object Error]') { 22156 return done(err); 22157 } 22158 22159 if (err) { 22160 if (Object.prototype.toString.call(err) === '[object Object]') { 22161 return done(new Error('done() invoked with non-Error: ' + JSON.stringify(err))); 22162 } 22163 22164 return done(new Error('done() invoked with non-Error: ' + err)); 22165 } 22166 22167 if (result && utils.isPromise(result)) { 22168 return done(new Error('Resolution method is overspecified. Specify a callback *or* return a Promise; not both.')); 22169 } 22170 22171 done(); 22172 }); 22173 } 22174 }; 22175 /** 22176 * Instantiates a "timeout" error 22177 * 22178 * @param {number} ms - Timeout (in milliseconds) 22179 * @returns {Error} a "timeout" error 22180 * @private 22181 */ 22182 22183 22184 Runnable.prototype._timeoutError = function (ms) { 22185 var msg = "Timeout of ".concat(ms, "ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves."); 22186 22187 if (this.file) { 22188 msg += ' (' + this.file + ')'; 22189 } 22190 22191 return createTimeoutError$1(msg, ms, this.file); 22192 }; 22193 22194 var constants$1 = utils.defineConstants( 22195 /** 22196 * {@link Runnable}-related constants. 22197 * @public 22198 * @memberof Runnable 22199 * @readonly 22200 * @static 22201 * @alias constants 22202 * @enum {string} 22203 */ 22204 { 22205 /** 22206 * Value of `state` prop when a `Runnable` has failed 22207 */ 22208 STATE_FAILED: 'failed', 22209 22210 /** 22211 * Value of `state` prop when a `Runnable` has passed 22212 */ 22213 STATE_PASSED: 'passed', 22214 22215 /** 22216 * Value of `state` prop when a `Runnable` has been skipped by user 22217 */ 22218 STATE_PENDING: 'pending' 22219 }); 22220 /** 22221 * Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that. 22222 * @param {*} [value] - Value to return, if present 22223 * @returns {*|Error} `value`, otherwise an `Error` 22224 * @private 22225 */ 22226 22227 Runnable.toValueOrError = function (value) { 22228 return value || createInvalidExceptionError$1('Runnable failed with falsy or undefined exception. Please throw an Error instead.', value); 22229 }; 22230 22231 Runnable.constants = constants$1; 22232 22233 var inherits$3 = utils.inherits, 22234 constants$2 = utils.constants; 22235 var MOCHA_ID_PROP_NAME = constants$2.MOCHA_ID_PROP_NAME; 22236 /** 22237 * Expose `Hook`. 22238 */ 22239 22240 var hook = Hook; 22241 /** 22242 * Initialize a new `Hook` with the given `title` and callback `fn` 22243 * 22244 * @class 22245 * @extends Runnable 22246 * @param {String} title 22247 * @param {Function} fn 22248 */ 22249 22250 function Hook(title, fn) { 22251 runnable.call(this, title, fn); 22252 this.type = 'hook'; 22253 } 22254 /** 22255 * Inherit from `Runnable.prototype`. 22256 */ 22257 22258 22259 inherits$3(Hook, runnable); 22260 /** 22261 * Resets the state for a next run. 22262 */ 22263 22264 Hook.prototype.reset = function () { 22265 runnable.prototype.reset.call(this); 22266 delete this._error; 22267 }; 22268 /** 22269 * Get or set the test `err`. 22270 * 22271 * @memberof Hook 22272 * @public 22273 * @param {Error} err 22274 * @return {Error} 22275 */ 22276 22277 22278 Hook.prototype.error = function (err) { 22279 if (!arguments.length) { 22280 err = this._error; 22281 this._error = null; 22282 return err; 22283 } 22284 22285 this._error = err; 22286 }; 22287 /** 22288 * Returns an object suitable for IPC. 22289 * Functions are represented by keys beginning with `$$`. 22290 * @private 22291 * @returns {Object} 22292 */ 22293 22294 22295 Hook.prototype.serialize = function serialize() { 22296 return _defineProperty({ 22297 $$isPending: this.isPending(), 22298 $$titlePath: this.titlePath(), 22299 ctx: this.ctx && this.ctx.currentTest ? { 22300 currentTest: _defineProperty({ 22301 title: this.ctx.currentTest.title 22302 }, MOCHA_ID_PROP_NAME, this.ctx.currentTest.id) 22303 } : {}, 22304 parent: _defineProperty({}, MOCHA_ID_PROP_NAME, this.parent.id), 22305 title: this.title, 22306 type: this.type 22307 }, MOCHA_ID_PROP_NAME, this.id); 22308 }; 22309 22310 var suite = createCommonjsModule(function (module, exports) { 22311 /** 22312 * Module dependencies. 22313 * @private 22314 */ 22315 22316 var EventEmitter$1 = EventEmitter.EventEmitter; 22317 var assignNewMochaID = utils.assignNewMochaID, 22318 clamp = utils.clamp, 22319 utilsConstants = utils.constants, 22320 createMap = utils.createMap, 22321 defineConstants = utils.defineConstants, 22322 getMochaID = utils.getMochaID, 22323 inherits = utils.inherits, 22324 isString = utils.isString; 22325 var debug = browser$2('mocha:suite'); 22326 var MOCHA_ID_PROP_NAME = utilsConstants.MOCHA_ID_PROP_NAME; 22327 /** 22328 * Expose `Suite`. 22329 */ 22330 22331 module.exports = Suite; 22332 /** 22333 * Create a new `Suite` with the given `title` and parent `Suite`. 22334 * 22335 * @public 22336 * @param {Suite} parent - Parent suite (required!) 22337 * @param {string} title - Title 22338 * @return {Suite} 22339 */ 22340 22341 Suite.create = function (parent, title) { 22342 var suite = new Suite(title, parent.ctx); 22343 suite.parent = parent; 22344 title = suite.fullTitle(); 22345 parent.addSuite(suite); 22346 return suite; 22347 }; 22348 /** 22349 * Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`. 22350 * 22351 * @public 22352 * @class 22353 * @extends EventEmitter 22354 * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter} 22355 * @param {string} title - Suite title. 22356 * @param {Context} parentContext - Parent context instance. 22357 * @param {boolean} [isRoot=false] - Whether this is the root suite. 22358 */ 22359 22360 22361 function Suite(title, parentContext, isRoot) { 22362 if (!isString(title)) { 22363 throw errors.createInvalidArgumentTypeError('Suite argument "title" must be a string. Received type "' + _typeof(title) + '"', 'title', 'string'); 22364 } 22365 22366 this.title = title; 22367 22368 function Context() {} 22369 22370 Context.prototype = parentContext; 22371 this.ctx = new Context(); 22372 this.suites = []; 22373 this.tests = []; 22374 this.root = isRoot === true; 22375 this.pending = false; 22376 this._retries = -1; 22377 this._beforeEach = []; 22378 this._beforeAll = []; 22379 this._afterEach = []; 22380 this._afterAll = []; 22381 this._timeout = 2000; 22382 this._slow = 75; 22383 this._bail = false; 22384 this._onlyTests = []; 22385 this._onlySuites = []; 22386 assignNewMochaID(this); 22387 Object.defineProperty(this, 'id', { 22388 get: function get() { 22389 return getMochaID(this); 22390 } 22391 }); 22392 this.reset(); 22393 this.on('newListener', function (event) { 22394 if (deprecatedEvents[event]) { 22395 errors.deprecate('Event "' + event + '" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm'); 22396 } 22397 }); 22398 } 22399 /** 22400 * Inherit from `EventEmitter.prototype`. 22401 */ 22402 22403 22404 inherits(Suite, EventEmitter$1); 22405 /** 22406 * Resets the state initially or for a next run. 22407 */ 22408 22409 Suite.prototype.reset = function () { 22410 this.delayed = false; 22411 22412 function doReset(thingToReset) { 22413 thingToReset.reset(); 22414 } 22415 22416 this.suites.forEach(doReset); 22417 this.tests.forEach(doReset); 22418 22419 this._beforeEach.forEach(doReset); 22420 22421 this._afterEach.forEach(doReset); 22422 22423 this._beforeAll.forEach(doReset); 22424 22425 this._afterAll.forEach(doReset); 22426 }; 22427 /** 22428 * Return a clone of this `Suite`. 22429 * 22430 * @private 22431 * @return {Suite} 22432 */ 22433 22434 22435 Suite.prototype.clone = function () { 22436 var suite = new Suite(this.title); 22437 debug('clone'); 22438 suite.ctx = this.ctx; 22439 suite.root = this.root; 22440 suite.timeout(this.timeout()); 22441 suite.retries(this.retries()); 22442 suite.slow(this.slow()); 22443 suite.bail(this.bail()); 22444 return suite; 22445 }; 22446 /** 22447 * Set or get timeout `ms` or short-hand such as "2s". 22448 * 22449 * @private 22450 * @todo Do not attempt to set value if `ms` is undefined 22451 * @param {number|string} ms 22452 * @return {Suite|number} for chaining 22453 */ 22454 22455 22456 Suite.prototype.timeout = function (ms$1) { 22457 if (!arguments.length) { 22458 return this._timeout; 22459 } 22460 22461 if (typeof ms$1 === 'string') { 22462 ms$1 = ms(ms$1); 22463 } // Clamp to range 22464 22465 22466 var INT_MAX = Math.pow(2, 31) - 1; 22467 var range = [0, INT_MAX]; 22468 ms$1 = clamp(ms$1, range); 22469 debug('timeout %d', ms$1); 22470 this._timeout = parseInt(ms$1, 10); 22471 return this; 22472 }; 22473 /** 22474 * Set or get number of times to retry a failed test. 22475 * 22476 * @private 22477 * @param {number|string} n 22478 * @return {Suite|number} for chaining 22479 */ 22480 22481 22482 Suite.prototype.retries = function (n) { 22483 if (!arguments.length) { 22484 return this._retries; 22485 } 22486 22487 debug('retries %d', n); 22488 this._retries = parseInt(n, 10) || 0; 22489 return this; 22490 }; 22491 /** 22492 * Set or get slow `ms` or short-hand such as "2s". 22493 * 22494 * @private 22495 * @param {number|string} ms 22496 * @return {Suite|number} for chaining 22497 */ 22498 22499 22500 Suite.prototype.slow = function (ms$1) { 22501 if (!arguments.length) { 22502 return this._slow; 22503 } 22504 22505 if (typeof ms$1 === 'string') { 22506 ms$1 = ms(ms$1); 22507 } 22508 22509 debug('slow %d', ms$1); 22510 this._slow = ms$1; 22511 return this; 22512 }; 22513 /** 22514 * Set or get whether to bail after first error. 22515 * 22516 * @private 22517 * @param {boolean} bail 22518 * @return {Suite|number} for chaining 22519 */ 22520 22521 22522 Suite.prototype.bail = function (bail) { 22523 if (!arguments.length) { 22524 return this._bail; 22525 } 22526 22527 debug('bail %s', bail); 22528 this._bail = bail; 22529 return this; 22530 }; 22531 /** 22532 * Check if this suite or its parent suite is marked as pending. 22533 * 22534 * @private 22535 */ 22536 22537 22538 Suite.prototype.isPending = function () { 22539 return this.pending || this.parent && this.parent.isPending(); 22540 }; 22541 /** 22542 * Generic hook-creator. 22543 * @private 22544 * @param {string} title - Title of hook 22545 * @param {Function} fn - Hook callback 22546 * @returns {Hook} A new hook 22547 */ 22548 22549 22550 Suite.prototype._createHook = function (title, fn) { 22551 var hook$1 = new hook(title, fn); 22552 hook$1.parent = this; 22553 hook$1.timeout(this.timeout()); 22554 hook$1.retries(this.retries()); 22555 hook$1.slow(this.slow()); 22556 hook$1.ctx = this.ctx; 22557 hook$1.file = this.file; 22558 return hook$1; 22559 }; 22560 /** 22561 * Run `fn(test[, done])` before running tests. 22562 * 22563 * @private 22564 * @param {string} title 22565 * @param {Function} fn 22566 * @return {Suite} for chaining 22567 */ 22568 22569 22570 Suite.prototype.beforeAll = function (title, fn) { 22571 if (this.isPending()) { 22572 return this; 22573 } 22574 22575 if (typeof title === 'function') { 22576 fn = title; 22577 title = fn.name; 22578 } 22579 22580 title = '"before all" hook' + (title ? ': ' + title : ''); 22581 22582 var hook = this._createHook(title, fn); 22583 22584 this._beforeAll.push(hook); 22585 22586 this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook); 22587 return this; 22588 }; 22589 /** 22590 * Run `fn(test[, done])` after running tests. 22591 * 22592 * @private 22593 * @param {string} title 22594 * @param {Function} fn 22595 * @return {Suite} for chaining 22596 */ 22597 22598 22599 Suite.prototype.afterAll = function (title, fn) { 22600 if (this.isPending()) { 22601 return this; 22602 } 22603 22604 if (typeof title === 'function') { 22605 fn = title; 22606 title = fn.name; 22607 } 22608 22609 title = '"after all" hook' + (title ? ': ' + title : ''); 22610 22611 var hook = this._createHook(title, fn); 22612 22613 this._afterAll.push(hook); 22614 22615 this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook); 22616 return this; 22617 }; 22618 /** 22619 * Run `fn(test[, done])` before each test case. 22620 * 22621 * @private 22622 * @param {string} title 22623 * @param {Function} fn 22624 * @return {Suite} for chaining 22625 */ 22626 22627 22628 Suite.prototype.beforeEach = function (title, fn) { 22629 if (this.isPending()) { 22630 return this; 22631 } 22632 22633 if (typeof title === 'function') { 22634 fn = title; 22635 title = fn.name; 22636 } 22637 22638 title = '"before each" hook' + (title ? ': ' + title : ''); 22639 22640 var hook = this._createHook(title, fn); 22641 22642 this._beforeEach.push(hook); 22643 22644 this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook); 22645 return this; 22646 }; 22647 /** 22648 * Run `fn(test[, done])` after each test case. 22649 * 22650 * @private 22651 * @param {string} title 22652 * @param {Function} fn 22653 * @return {Suite} for chaining 22654 */ 22655 22656 22657 Suite.prototype.afterEach = function (title, fn) { 22658 if (this.isPending()) { 22659 return this; 22660 } 22661 22662 if (typeof title === 'function') { 22663 fn = title; 22664 title = fn.name; 22665 } 22666 22667 title = '"after each" hook' + (title ? ': ' + title : ''); 22668 22669 var hook = this._createHook(title, fn); 22670 22671 this._afterEach.push(hook); 22672 22673 this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook); 22674 return this; 22675 }; 22676 /** 22677 * Add a test `suite`. 22678 * 22679 * @private 22680 * @param {Suite} suite 22681 * @return {Suite} for chaining 22682 */ 22683 22684 22685 Suite.prototype.addSuite = function (suite) { 22686 suite.parent = this; 22687 suite.root = false; 22688 suite.timeout(this.timeout()); 22689 suite.retries(this.retries()); 22690 suite.slow(this.slow()); 22691 suite.bail(this.bail()); 22692 this.suites.push(suite); 22693 this.emit(constants.EVENT_SUITE_ADD_SUITE, suite); 22694 return this; 22695 }; 22696 /** 22697 * Add a `test` to this suite. 22698 * 22699 * @private 22700 * @param {Test} test 22701 * @return {Suite} for chaining 22702 */ 22703 22704 22705 Suite.prototype.addTest = function (test) { 22706 test.parent = this; 22707 test.timeout(this.timeout()); 22708 test.retries(this.retries()); 22709 test.slow(this.slow()); 22710 test.ctx = this.ctx; 22711 this.tests.push(test); 22712 this.emit(constants.EVENT_SUITE_ADD_TEST, test); 22713 return this; 22714 }; 22715 /** 22716 * Return the full title generated by recursively concatenating the parent's 22717 * full title. 22718 * 22719 * @memberof Suite 22720 * @public 22721 * @return {string} 22722 */ 22723 22724 22725 Suite.prototype.fullTitle = function () { 22726 return this.titlePath().join(' '); 22727 }; 22728 /** 22729 * Return the title path generated by recursively concatenating the parent's 22730 * title path. 22731 * 22732 * @memberof Suite 22733 * @public 22734 * @return {string} 22735 */ 22736 22737 22738 Suite.prototype.titlePath = function () { 22739 var result = []; 22740 22741 if (this.parent) { 22742 result = result.concat(this.parent.titlePath()); 22743 } 22744 22745 if (!this.root) { 22746 result.push(this.title); 22747 } 22748 22749 return result; 22750 }; 22751 /** 22752 * Return the total number of tests. 22753 * 22754 * @memberof Suite 22755 * @public 22756 * @return {number} 22757 */ 22758 22759 22760 Suite.prototype.total = function () { 22761 return this.suites.reduce(function (sum, suite) { 22762 return sum + suite.total(); 22763 }, 0) + this.tests.length; 22764 }; 22765 /** 22766 * Iterates through each suite recursively to find all tests. Applies a 22767 * function in the format `fn(test)`. 22768 * 22769 * @private 22770 * @param {Function} fn 22771 * @return {Suite} 22772 */ 22773 22774 22775 Suite.prototype.eachTest = function (fn) { 22776 this.tests.forEach(fn); 22777 this.suites.forEach(function (suite) { 22778 suite.eachTest(fn); 22779 }); 22780 return this; 22781 }; 22782 /** 22783 * This will run the root suite if we happen to be running in delayed mode. 22784 * @private 22785 */ 22786 22787 22788 Suite.prototype.run = function run() { 22789 if (this.root) { 22790 this.emit(constants.EVENT_ROOT_SUITE_RUN); 22791 } 22792 }; 22793 /** 22794 * Determines whether a suite has an `only` test or suite as a descendant. 22795 * 22796 * @private 22797 * @returns {Boolean} 22798 */ 22799 22800 22801 Suite.prototype.hasOnly = function hasOnly() { 22802 return this._onlyTests.length > 0 || this._onlySuites.length > 0 || this.suites.some(function (suite) { 22803 return suite.hasOnly(); 22804 }); 22805 }; 22806 /** 22807 * Filter suites based on `isOnly` logic. 22808 * 22809 * @private 22810 * @returns {Boolean} 22811 */ 22812 22813 22814 Suite.prototype.filterOnly = function filterOnly() { 22815 if (this._onlyTests.length) { 22816 // If the suite contains `only` tests, run those and ignore any nested suites. 22817 this.tests = this._onlyTests; 22818 this.suites = []; 22819 } else { 22820 // Otherwise, do not run any of the tests in this suite. 22821 this.tests = []; 22822 22823 this._onlySuites.forEach(function (onlySuite) { 22824 // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite. 22825 // Otherwise, all of the tests on this `only` suite should be run, so don't filter it. 22826 if (onlySuite.hasOnly()) { 22827 onlySuite.filterOnly(); 22828 } 22829 }); // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants. 22830 22831 22832 var onlySuites = this._onlySuites; 22833 this.suites = this.suites.filter(function (childSuite) { 22834 return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly(); 22835 }); 22836 } // Keep the suite only if there is something to run 22837 22838 22839 return this.tests.length > 0 || this.suites.length > 0; 22840 }; 22841 /** 22842 * Adds a suite to the list of subsuites marked `only`. 22843 * 22844 * @private 22845 * @param {Suite} suite 22846 */ 22847 22848 22849 Suite.prototype.appendOnlySuite = function (suite) { 22850 this._onlySuites.push(suite); 22851 }; 22852 /** 22853 * Marks a suite to be `only`. 22854 * 22855 * @private 22856 */ 22857 22858 22859 Suite.prototype.markOnly = function () { 22860 this.parent && this.parent.appendOnlySuite(this); 22861 }; 22862 /** 22863 * Adds a test to the list of tests marked `only`. 22864 * 22865 * @private 22866 * @param {Test} test 22867 */ 22868 22869 22870 Suite.prototype.appendOnlyTest = function (test) { 22871 this._onlyTests.push(test); 22872 }; 22873 /** 22874 * Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants. 22875 * @private 22876 */ 22877 22878 22879 Suite.prototype.getHooks = function getHooks(name) { 22880 return this['_' + name]; 22881 }; 22882 /** 22883 * cleans all references from this suite and all child suites. 22884 */ 22885 22886 22887 Suite.prototype.dispose = function () { 22888 this.suites.forEach(function (suite) { 22889 suite.dispose(); 22890 }); 22891 this.cleanReferences(); 22892 }; 22893 /** 22894 * Cleans up the references to all the deferred functions 22895 * (before/after/beforeEach/afterEach) and tests of a Suite. 22896 * These must be deleted otherwise a memory leak can happen, 22897 * as those functions may reference variables from closures, 22898 * thus those variables can never be garbage collected as long 22899 * as the deferred functions exist. 22900 * 22901 * @private 22902 */ 22903 22904 22905 Suite.prototype.cleanReferences = function cleanReferences() { 22906 function cleanArrReferences(arr) { 22907 for (var i = 0; i < arr.length; i++) { 22908 delete arr[i].fn; 22909 } 22910 } 22911 22912 if (Array.isArray(this._beforeAll)) { 22913 cleanArrReferences(this._beforeAll); 22914 } 22915 22916 if (Array.isArray(this._beforeEach)) { 22917 cleanArrReferences(this._beforeEach); 22918 } 22919 22920 if (Array.isArray(this._afterAll)) { 22921 cleanArrReferences(this._afterAll); 22922 } 22923 22924 if (Array.isArray(this._afterEach)) { 22925 cleanArrReferences(this._afterEach); 22926 } 22927 22928 for (var i = 0; i < this.tests.length; i++) { 22929 delete this.tests[i].fn; 22930 } 22931 }; 22932 /** 22933 * Returns an object suitable for IPC. 22934 * Functions are represented by keys beginning with `$$`. 22935 * @private 22936 * @returns {Object} 22937 */ 22938 22939 22940 Suite.prototype.serialize = function serialize() { 22941 return { 22942 _bail: this._bail, 22943 $$fullTitle: this.fullTitle(), 22944 $$isPending: this.isPending(), 22945 root: this.root, 22946 title: this.title, 22947 id: this.id, 22948 parent: this.parent ? _defineProperty({}, MOCHA_ID_PROP_NAME, this.parent.id) : null 22949 }; 22950 }; 22951 22952 var constants = defineConstants( 22953 /** 22954 * {@link Suite}-related constants. 22955 * @public 22956 * @memberof Suite 22957 * @alias constants 22958 * @readonly 22959 * @static 22960 * @enum {string} 22961 */ 22962 { 22963 /** 22964 * Event emitted after a test file has been loaded Not emitted in browser. 22965 */ 22966 EVENT_FILE_POST_REQUIRE: 'post-require', 22967 22968 /** 22969 * Event emitted before a test file has been loaded. In browser, this is emitted once an interface has been selected. 22970 */ 22971 EVENT_FILE_PRE_REQUIRE: 'pre-require', 22972 22973 /** 22974 * Event emitted immediately after a test file has been loaded. Not emitted in browser. 22975 */ 22976 EVENT_FILE_REQUIRE: 'require', 22977 22978 /** 22979 * Event emitted when `global.run()` is called (use with `delay` option) 22980 */ 22981 EVENT_ROOT_SUITE_RUN: 'run', 22982 22983 /** 22984 * Namespace for collection of a `Suite`'s "after all" hooks 22985 */ 22986 HOOK_TYPE_AFTER_ALL: 'afterAll', 22987 22988 /** 22989 * Namespace for collection of a `Suite`'s "after each" hooks 22990 */ 22991 HOOK_TYPE_AFTER_EACH: 'afterEach', 22992 22993 /** 22994 * Namespace for collection of a `Suite`'s "before all" hooks 22995 */ 22996 HOOK_TYPE_BEFORE_ALL: 'beforeAll', 22997 22998 /** 22999 * Namespace for collection of a `Suite`'s "before all" hooks 23000 */ 23001 HOOK_TYPE_BEFORE_EACH: 'beforeEach', 23002 // the following events are all deprecated 23003 23004 /** 23005 * Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated 23006 */ 23007 EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll', 23008 23009 /** 23010 * Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated 23011 */ 23012 EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach', 23013 23014 /** 23015 * Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated 23016 */ 23017 EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll', 23018 23019 /** 23020 * Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated 23021 */ 23022 EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach', 23023 23024 /** 23025 * Emitted after a child `Suite` has been added to a `Suite`. Deprecated 23026 */ 23027 EVENT_SUITE_ADD_SUITE: 'suite', 23028 23029 /** 23030 * Emitted after a `Test` has been added to a `Suite`. Deprecated 23031 */ 23032 EVENT_SUITE_ADD_TEST: 'test' 23033 }); 23034 /** 23035 * @summary There are no known use cases for these events. 23036 * @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`. 23037 * @todo Remove eventually 23038 * @type {Object<string,boolean>} 23039 * @ignore 23040 */ 23041 23042 var deprecatedEvents = Object.keys(constants).filter(function (constant) { 23043 return constant.substring(0, 15) === 'EVENT_SUITE_ADD'; 23044 }).reduce(function (acc, constant) { 23045 acc[constants[constant]] = true; 23046 return acc; 23047 }, createMap()); 23048 Suite.constants = constants; 23049 }); 23050 23051 /** 23052 * Module dependencies. 23053 * @private 23054 */ 23055 23056 23057 var EventEmitter$2 = EventEmitter.EventEmitter; 23058 var debug$2 = browser$2('mocha:runner'); 23059 var HOOK_TYPE_BEFORE_EACH = suite.constants.HOOK_TYPE_BEFORE_EACH; 23060 var HOOK_TYPE_AFTER_EACH = suite.constants.HOOK_TYPE_AFTER_EACH; 23061 var HOOK_TYPE_AFTER_ALL = suite.constants.HOOK_TYPE_AFTER_ALL; 23062 var HOOK_TYPE_BEFORE_ALL = suite.constants.HOOK_TYPE_BEFORE_ALL; 23063 var EVENT_ROOT_SUITE_RUN = suite.constants.EVENT_ROOT_SUITE_RUN; 23064 var STATE_FAILED = runnable.constants.STATE_FAILED; 23065 var STATE_PASSED = runnable.constants.STATE_PASSED; 23066 var STATE_PENDING = runnable.constants.STATE_PENDING; 23067 var dQuote = utils.dQuote; 23068 var sQuote = utils.sQuote; 23069 var stackFilter = utils.stackTraceFilter(); 23070 var stringify = utils.stringify; 23071 var createInvalidExceptionError$2 = errors.createInvalidExceptionError, 23072 createUnsupportedError$1 = errors.createUnsupportedError, 23073 createFatalError$1 = errors.createFatalError, 23074 isMochaError$1 = errors.isMochaError, 23075 errorConstants = errors.constants; 23076 /** 23077 * Non-enumerable globals. 23078 * @private 23079 * @readonly 23080 */ 23081 23082 var globals = ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'XMLHttpRequest', 'Date', 'setImmediate', 'clearImmediate']; 23083 var constants$3 = utils.defineConstants( 23084 /** 23085 * {@link Runner}-related constants. 23086 * @public 23087 * @memberof Runner 23088 * @readonly 23089 * @alias constants 23090 * @static 23091 * @enum {string} 23092 */ 23093 { 23094 /** 23095 * Emitted when {@link Hook} execution begins 23096 */ 23097 EVENT_HOOK_BEGIN: 'hook', 23098 23099 /** 23100 * Emitted when {@link Hook} execution ends 23101 */ 23102 EVENT_HOOK_END: 'hook end', 23103 23104 /** 23105 * Emitted when Root {@link Suite} execution begins (all files have been parsed and hooks/tests are ready for execution) 23106 */ 23107 EVENT_RUN_BEGIN: 'start', 23108 23109 /** 23110 * Emitted when Root {@link Suite} execution has been delayed via `delay` option 23111 */ 23112 EVENT_DELAY_BEGIN: 'waiting', 23113 23114 /** 23115 * Emitted when delayed Root {@link Suite} execution is triggered by user via `global.run()` 23116 */ 23117 EVENT_DELAY_END: 'ready', 23118 23119 /** 23120 * Emitted when Root {@link Suite} execution ends 23121 */ 23122 EVENT_RUN_END: 'end', 23123 23124 /** 23125 * Emitted when {@link Suite} execution begins 23126 */ 23127 EVENT_SUITE_BEGIN: 'suite', 23128 23129 /** 23130 * Emitted when {@link Suite} execution ends 23131 */ 23132 EVENT_SUITE_END: 'suite end', 23133 23134 /** 23135 * Emitted when {@link Test} execution begins 23136 */ 23137 EVENT_TEST_BEGIN: 'test', 23138 23139 /** 23140 * Emitted when {@link Test} execution ends 23141 */ 23142 EVENT_TEST_END: 'test end', 23143 23144 /** 23145 * Emitted when {@link Test} execution fails 23146 */ 23147 EVENT_TEST_FAIL: 'fail', 23148 23149 /** 23150 * Emitted when {@link Test} execution succeeds 23151 */ 23152 EVENT_TEST_PASS: 'pass', 23153 23154 /** 23155 * Emitted when {@link Test} becomes pending 23156 */ 23157 EVENT_TEST_PENDING: 'pending', 23158 23159 /** 23160 * Emitted when {@link Test} execution has failed, but will retry 23161 */ 23162 EVENT_TEST_RETRY: 'retry', 23163 23164 /** 23165 * Initial state of Runner 23166 */ 23167 STATE_IDLE: 'idle', 23168 23169 /** 23170 * State set to this value when the Runner has started running 23171 */ 23172 STATE_RUNNING: 'running', 23173 23174 /** 23175 * State set to this value when the Runner has stopped 23176 */ 23177 STATE_STOPPED: 'stopped' 23178 }); 23179 23180 var Runner = /*#__PURE__*/function (_EventEmitter) { 23181 _inherits(Runner, _EventEmitter); 23182 23183 var _super = _createSuper(Runner); 23184 23185 /** 23186 * Initialize a `Runner` at the Root {@link Suite}, which represents a hierarchy of {@link Suite|Suites} and {@link Test|Tests}. 23187 * 23188 * @extends external:EventEmitter 23189 * @public 23190 * @class 23191 * @param {Suite} suite - Root suite 23192 * @param {Object|boolean} [opts] - Options. If `boolean`, whether or not to delay execution of root suite until ready (for backwards compatibility). 23193 * @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready. 23194 * @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done. 23195 */ 23196 function Runner(suite, opts) { 23197 var _this; 23198 23199 _classCallCheck(this, Runner); 23200 23201 _this = _super.call(this); 23202 23203 if (opts === undefined) { 23204 opts = {}; 23205 } 23206 23207 if (typeof opts === 'boolean') { 23208 // TODO: deprecate this 23209 _this._delay = opts; 23210 opts = {}; 23211 } else { 23212 _this._delay = opts.delay; 23213 } 23214 23215 var self = _assertThisInitialized(_this); 23216 23217 _this._globals = []; 23218 _this._abort = false; 23219 _this.suite = suite; 23220 _this._opts = opts; 23221 _this.state = constants$3.STATE_IDLE; 23222 _this.total = suite.total(); 23223 _this.failures = 0; 23224 /** 23225 * @type {Map<EventEmitter,Map<string,Set<EventListener>>>} 23226 */ 23227 23228 _this._eventListeners = new Map(); 23229 23230 _this.on(constants$3.EVENT_TEST_END, function (test) { 23231 if (test.type === 'test' && test.retriedTest() && test.parent) { 23232 var idx = test.parent.tests && test.parent.tests.indexOf(test.retriedTest()); 23233 if (idx > -1) test.parent.tests[idx] = test; 23234 } 23235 23236 self.checkGlobals(test); 23237 }); 23238 23239 _this.on(constants$3.EVENT_HOOK_END, function (hook) { 23240 self.checkGlobals(hook); 23241 }); 23242 23243 _this._defaultGrep = /.*/; 23244 23245 _this.grep(_this._defaultGrep); 23246 23247 _this.globals(_this.globalProps()); 23248 23249 _this.uncaught = _this._uncaught.bind(_assertThisInitialized(_this)); 23250 23251 _this.unhandled = function (reason, promise) { 23252 if (isMochaError$1(reason)) { 23253 debug$2('trapped unhandled rejection coming out of Mocha; forwarding to uncaught handler:', reason); 23254 23255 _this.uncaught(reason); 23256 } else { 23257 debug$2('trapped unhandled rejection from (probably) user code; re-emitting on process'); 23258 23259 _this._removeEventListener(process$1, 'unhandledRejection', _this.unhandled); 23260 23261 try { 23262 process$1.emit('unhandledRejection', reason, promise); 23263 } finally { 23264 _this._addEventListener(process$1, 'unhandledRejection', _this.unhandled); 23265 } 23266 } 23267 }; 23268 23269 return _this; 23270 } 23271 23272 return Runner; 23273 }(EventEmitter$2); 23274 /** 23275 * Wrapper for setImmediate, process.nextTick, or browser polyfill. 23276 * 23277 * @param {Function} fn 23278 * @private 23279 */ 23280 23281 23282 Runner.immediately = commonjsGlobal.setImmediate || nextTick; 23283 /** 23284 * Replacement for `target.on(eventName, listener)` that does bookkeeping to remove them when this runner instance is disposed. 23285 * @param {EventEmitter} target - The `EventEmitter` 23286 * @param {string} eventName - The event name 23287 * @param {string} fn - Listener function 23288 * @private 23289 */ 23290 23291 Runner.prototype._addEventListener = function (target, eventName, listener) { 23292 debug$2('_addEventListener(): adding for event %s; %d current listeners', eventName, target.listenerCount(eventName)); 23293 /* istanbul ignore next */ 23294 23295 if (this._eventListeners.has(target) && this._eventListeners.get(target).has(eventName) && this._eventListeners.get(target).get(eventName).has(listener)) { 23296 debug$2('warning: tried to attach duplicate event listener for %s', eventName); 23297 return; 23298 } 23299 23300 target.on(eventName, listener); 23301 var targetListeners = this._eventListeners.has(target) ? this._eventListeners.get(target) : new Map(); 23302 var targetEventListeners = targetListeners.has(eventName) ? targetListeners.get(eventName) : new Set(); 23303 targetEventListeners.add(listener); 23304 targetListeners.set(eventName, targetEventListeners); 23305 23306 this._eventListeners.set(target, targetListeners); 23307 }; 23308 /** 23309 * Replacement for `target.removeListener(eventName, listener)` that also updates the bookkeeping. 23310 * @param {EventEmitter} target - The `EventEmitter` 23311 * @param {string} eventName - The event name 23312 * @param {function} listener - Listener function 23313 * @private 23314 */ 23315 23316 23317 Runner.prototype._removeEventListener = function (target, eventName, listener) { 23318 target.removeListener(eventName, listener); 23319 23320 if (this._eventListeners.has(target)) { 23321 var targetListeners = this._eventListeners.get(target); 23322 23323 if (targetListeners.has(eventName)) { 23324 var targetEventListeners = targetListeners.get(eventName); 23325 targetEventListeners["delete"](listener); 23326 23327 if (!targetEventListeners.size) { 23328 targetListeners["delete"](eventName); 23329 } 23330 } 23331 23332 if (!targetListeners.size) { 23333 this._eventListeners["delete"](target); 23334 } 23335 } else { 23336 debug$2('trying to remove listener for untracked object %s', target); 23337 } 23338 }; 23339 /** 23340 * Removes all event handlers set during a run on this instance. 23341 * Remark: this does _not_ clean/dispose the tests or suites themselves. 23342 */ 23343 23344 23345 Runner.prototype.dispose = function () { 23346 this.removeAllListeners(); 23347 23348 this._eventListeners.forEach(function (targetListeners, target) { 23349 targetListeners.forEach(function (targetEventListeners, eventName) { 23350 targetEventListeners.forEach(function (listener) { 23351 target.removeListener(eventName, listener); 23352 }); 23353 }); 23354 }); 23355 23356 this._eventListeners.clear(); 23357 }; 23358 /** 23359 * Run tests with full titles matching `re`. Updates runner.total 23360 * with number of tests matched. 23361 * 23362 * @public 23363 * @memberof Runner 23364 * @param {RegExp} re 23365 * @param {boolean} invert 23366 * @return {Runner} Runner instance. 23367 */ 23368 23369 23370 Runner.prototype.grep = function (re, invert) { 23371 debug$2('grep(): setting to %s', re); 23372 this._grep = re; 23373 this._invert = invert; 23374 this.total = this.grepTotal(this.suite); 23375 return this; 23376 }; 23377 /** 23378 * Returns the number of tests matching the grep search for the 23379 * given suite. 23380 * 23381 * @memberof Runner 23382 * @public 23383 * @param {Suite} suite 23384 * @return {number} 23385 */ 23386 23387 23388 Runner.prototype.grepTotal = function (suite) { 23389 var self = this; 23390 var total = 0; 23391 suite.eachTest(function (test) { 23392 var match = self._grep.test(test.fullTitle()); 23393 23394 if (self._invert) { 23395 match = !match; 23396 } 23397 23398 if (match) { 23399 total++; 23400 } 23401 }); 23402 return total; 23403 }; 23404 /** 23405 * Return a list of global properties. 23406 * 23407 * @return {Array} 23408 * @private 23409 */ 23410 23411 23412 Runner.prototype.globalProps = function () { 23413 var props = Object.keys(commonjsGlobal); // non-enumerables 23414 23415 for (var i = 0; i < globals.length; ++i) { 23416 if (~props.indexOf(globals[i])) { 23417 continue; 23418 } 23419 23420 props.push(globals[i]); 23421 } 23422 23423 return props; 23424 }; 23425 /** 23426 * Allow the given `arr` of globals. 23427 * 23428 * @public 23429 * @memberof Runner 23430 * @param {Array} arr 23431 * @return {Runner} Runner instance. 23432 */ 23433 23434 23435 Runner.prototype.globals = function (arr) { 23436 if (!arguments.length) { 23437 return this._globals; 23438 } 23439 23440 debug$2('globals(): setting to %O', arr); 23441 this._globals = this._globals.concat(arr); 23442 return this; 23443 }; 23444 /** 23445 * Check for global variable leaks. 23446 * 23447 * @private 23448 */ 23449 23450 23451 Runner.prototype.checkGlobals = function (test) { 23452 if (!this.checkLeaks) { 23453 return; 23454 } 23455 23456 var ok = this._globals; 23457 var globals = this.globalProps(); 23458 var leaks; 23459 23460 if (test) { 23461 ok = ok.concat(test._allowedGlobals || []); 23462 } 23463 23464 if (this.prevGlobalsLength === globals.length) { 23465 return; 23466 } 23467 23468 this.prevGlobalsLength = globals.length; 23469 leaks = filterLeaks(ok, globals); 23470 this._globals = this._globals.concat(leaks); 23471 23472 if (leaks.length) { 23473 var msg = 'global leak(s) detected: %s'; 23474 var error = new Error(util.format(msg, leaks.map(sQuote).join(', '))); 23475 this.fail(test, error); 23476 } 23477 }; 23478 /** 23479 * Fail the given `test`. 23480 * 23481 * If `test` is a hook, failures work in the following pattern: 23482 * - If bail, run corresponding `after each` and `after` hooks, 23483 * then exit 23484 * - Failed `before` hook skips all tests in a suite and subsuites, 23485 * but jumps to corresponding `after` hook 23486 * - Failed `before each` hook skips remaining tests in a 23487 * suite and jumps to corresponding `after each` hook, 23488 * which is run only once 23489 * - Failed `after` hook does not alter execution order 23490 * - Failed `after each` hook skips remaining tests in a 23491 * suite and subsuites, but executes other `after each` 23492 * hooks 23493 * 23494 * @private 23495 * @param {Runnable} test 23496 * @param {Error} err 23497 * @param {boolean} [force=false] - Whether to fail a pending test. 23498 */ 23499 23500 23501 Runner.prototype.fail = function (test, err, force) { 23502 force = force === true; 23503 23504 if (test.isPending() && !force) { 23505 return; 23506 } 23507 23508 if (this.state === constants$3.STATE_STOPPED) { 23509 if (err.code === errorConstants.MULTIPLE_DONE) { 23510 throw err; 23511 } 23512 23513 throw createFatalError$1('Test failed after root suite execution completed!', err); 23514 } 23515 23516 ++this.failures; 23517 debug$2('total number of failures: %d', this.failures); 23518 test.state = STATE_FAILED; 23519 23520 if (!isError$1(err)) { 23521 err = thrown2Error(err); 23522 } 23523 23524 try { 23525 err.stack = this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack); 23526 } catch (ignore) {// some environments do not take kindly to monkeying with the stack 23527 } 23528 23529 this.emit(constants$3.EVENT_TEST_FAIL, test, err); 23530 }; 23531 /** 23532 * Run hook `name` callbacks and then invoke `fn()`. 23533 * 23534 * @private 23535 * @param {string} name 23536 * @param {Function} fn 23537 */ 23538 23539 23540 Runner.prototype.hook = function (name, fn) { 23541 var suite = this.suite; 23542 var hooks = suite.getHooks(name); 23543 var self = this; 23544 23545 function next(i) { 23546 var hook = hooks[i]; 23547 23548 if (!hook) { 23549 return fn(); 23550 } 23551 23552 self.currentRunnable = hook; 23553 23554 if (name === HOOK_TYPE_BEFORE_ALL) { 23555 hook.ctx.currentTest = hook.parent.tests[0]; 23556 } else if (name === HOOK_TYPE_AFTER_ALL) { 23557 hook.ctx.currentTest = hook.parent.tests[hook.parent.tests.length - 1]; 23558 } else { 23559 hook.ctx.currentTest = self.test; 23560 } 23561 23562 setHookTitle(hook); 23563 hook.allowUncaught = self.allowUncaught; 23564 self.emit(constants$3.EVENT_HOOK_BEGIN, hook); 23565 23566 if (!hook.listeners('error').length) { 23567 self._addEventListener(hook, 'error', function (err) { 23568 self.fail(hook, err); 23569 }); 23570 } 23571 23572 hook.run(function cbHookRun(err) { 23573 var testError = hook.error(); 23574 23575 if (testError) { 23576 self.fail(self.test, testError); 23577 } // conditional skip 23578 23579 23580 if (hook.pending) { 23581 if (name === HOOK_TYPE_AFTER_EACH) { 23582 // TODO define and implement use case 23583 if (self.test) { 23584 self.test.pending = true; 23585 } 23586 } else if (name === HOOK_TYPE_BEFORE_EACH) { 23587 if (self.test) { 23588 self.test.pending = true; 23589 } 23590 23591 self.emit(constants$3.EVENT_HOOK_END, hook); 23592 hook.pending = false; // activates hook for next test 23593 23594 return fn(new Error('abort hookDown')); 23595 } else if (name === HOOK_TYPE_BEFORE_ALL) { 23596 suite.tests.forEach(function (test) { 23597 test.pending = true; 23598 }); 23599 suite.suites.forEach(function (suite) { 23600 suite.pending = true; 23601 }); 23602 hooks = []; 23603 } else { 23604 hook.pending = false; 23605 var errForbid = createUnsupportedError$1('`this.skip` forbidden'); 23606 self.fail(hook, errForbid); 23607 return fn(errForbid); 23608 } 23609 } else if (err) { 23610 self.fail(hook, err); // stop executing hooks, notify callee of hook err 23611 23612 return fn(err); 23613 } 23614 23615 self.emit(constants$3.EVENT_HOOK_END, hook); 23616 delete hook.ctx.currentTest; 23617 setHookTitle(hook); 23618 next(++i); 23619 }); 23620 23621 function setHookTitle(hook) { 23622 hook.originalTitle = hook.originalTitle || hook.title; 23623 23624 if (hook.ctx && hook.ctx.currentTest) { 23625 hook.title = hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title); 23626 } else { 23627 var parentTitle; 23628 23629 if (hook.parent.title) { 23630 parentTitle = hook.parent.title; 23631 } else { 23632 parentTitle = hook.parent.root ? '{root}' : ''; 23633 } 23634 23635 hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle); 23636 } 23637 } 23638 } 23639 23640 Runner.immediately(function () { 23641 next(0); 23642 }); 23643 }; 23644 /** 23645 * Run hook `name` for the given array of `suites` 23646 * in order, and callback `fn(err, errSuite)`. 23647 * 23648 * @private 23649 * @param {string} name 23650 * @param {Array} suites 23651 * @param {Function} fn 23652 */ 23653 23654 23655 Runner.prototype.hooks = function (name, suites, fn) { 23656 var self = this; 23657 var orig = this.suite; 23658 23659 function next(suite) { 23660 self.suite = suite; 23661 23662 if (!suite) { 23663 self.suite = orig; 23664 return fn(); 23665 } 23666 23667 self.hook(name, function (err) { 23668 if (err) { 23669 var errSuite = self.suite; 23670 self.suite = orig; 23671 return fn(err, errSuite); 23672 } 23673 23674 next(suites.pop()); 23675 }); 23676 } 23677 23678 next(suites.pop()); 23679 }; 23680 /** 23681 * Run hooks from the top level down. 23682 * 23683 * @param {String} name 23684 * @param {Function} fn 23685 * @private 23686 */ 23687 23688 23689 Runner.prototype.hookUp = function (name, fn) { 23690 var suites = [this.suite].concat(this.parents()).reverse(); 23691 this.hooks(name, suites, fn); 23692 }; 23693 /** 23694 * Run hooks from the bottom up. 23695 * 23696 * @param {String} name 23697 * @param {Function} fn 23698 * @private 23699 */ 23700 23701 23702 Runner.prototype.hookDown = function (name, fn) { 23703 var suites = [this.suite].concat(this.parents()); 23704 this.hooks(name, suites, fn); 23705 }; 23706 /** 23707 * Return an array of parent Suites from 23708 * closest to furthest. 23709 * 23710 * @return {Array} 23711 * @private 23712 */ 23713 23714 23715 Runner.prototype.parents = function () { 23716 var suite = this.suite; 23717 var suites = []; 23718 23719 while (suite.parent) { 23720 suite = suite.parent; 23721 suites.push(suite); 23722 } 23723 23724 return suites; 23725 }; 23726 /** 23727 * Run the current test and callback `fn(err)`. 23728 * 23729 * @param {Function} fn 23730 * @private 23731 */ 23732 23733 23734 Runner.prototype.runTest = function (fn) { 23735 var self = this; 23736 var test = this.test; 23737 23738 if (!test) { 23739 return; 23740 } 23741 23742 if (this.asyncOnly) { 23743 test.asyncOnly = true; 23744 } 23745 23746 this._addEventListener(test, 'error', function (err) { 23747 self.fail(test, err); 23748 }); 23749 23750 if (this.allowUncaught) { 23751 test.allowUncaught = true; 23752 return test.run(fn); 23753 } 23754 23755 try { 23756 test.run(fn); 23757 } catch (err) { 23758 fn(err); 23759 } 23760 }; 23761 /** 23762 * Run tests in the given `suite` and invoke the callback `fn()` when complete. 23763 * 23764 * @private 23765 * @param {Suite} suite 23766 * @param {Function} fn 23767 */ 23768 23769 23770 Runner.prototype.runTests = function (suite, fn) { 23771 var self = this; 23772 var tests = suite.tests.slice(); 23773 var test; 23774 23775 function hookErr(_, errSuite, after) { 23776 // before/after Each hook for errSuite failed: 23777 var orig = self.suite; // for failed 'after each' hook start from errSuite parent, 23778 // otherwise start from errSuite itself 23779 23780 self.suite = after ? errSuite.parent : errSuite; 23781 23782 if (self.suite) { 23783 // call hookUp afterEach 23784 self.hookUp(HOOK_TYPE_AFTER_EACH, function (err2, errSuite2) { 23785 self.suite = orig; // some hooks may fail even now 23786 23787 if (err2) { 23788 return hookErr(err2, errSuite2, true); 23789 } // report error suite 23790 23791 23792 fn(errSuite); 23793 }); 23794 } else { 23795 // there is no need calling other 'after each' hooks 23796 self.suite = orig; 23797 fn(errSuite); 23798 } 23799 } 23800 23801 function next(err, errSuite) { 23802 // if we bail after first err 23803 if (self.failures && suite._bail) { 23804 tests = []; 23805 } 23806 23807 if (self._abort) { 23808 return fn(); 23809 } 23810 23811 if (err) { 23812 return hookErr(err, errSuite, true); 23813 } // next test 23814 23815 23816 test = tests.shift(); // all done 23817 23818 if (!test) { 23819 return fn(); 23820 } // grep 23821 23822 23823 var match = self._grep.test(test.fullTitle()); 23824 23825 if (self._invert) { 23826 match = !match; 23827 } 23828 23829 if (!match) { 23830 // Run immediately only if we have defined a grep. When we 23831 // define a grep — It can cause maximum callstack error if 23832 // the grep is doing a large recursive loop by neglecting 23833 // all tests. The run immediately function also comes with 23834 // a performance cost. So we don't want to run immediately 23835 // if we run the whole test suite, because running the whole 23836 // test suite don't do any immediate recursive loops. Thus, 23837 // allowing a JS runtime to breathe. 23838 if (self._grep !== self._defaultGrep) { 23839 Runner.immediately(next); 23840 } else { 23841 next(); 23842 } 23843 23844 return; 23845 } // static skip, no hooks are executed 23846 23847 23848 if (test.isPending()) { 23849 if (self.forbidPending) { 23850 self.fail(test, new Error('Pending test forbidden'), true); 23851 } else { 23852 test.state = STATE_PENDING; 23853 self.emit(constants$3.EVENT_TEST_PENDING, test); 23854 } 23855 23856 self.emit(constants$3.EVENT_TEST_END, test); 23857 return next(); 23858 } // execute test and hook(s) 23859 23860 23861 self.emit(constants$3.EVENT_TEST_BEGIN, self.test = test); 23862 self.hookDown(HOOK_TYPE_BEFORE_EACH, function (err, errSuite) { 23863 // conditional skip within beforeEach 23864 if (test.isPending()) { 23865 if (self.forbidPending) { 23866 self.fail(test, new Error('Pending test forbidden'), true); 23867 } else { 23868 test.state = STATE_PENDING; 23869 self.emit(constants$3.EVENT_TEST_PENDING, test); 23870 } 23871 23872 self.emit(constants$3.EVENT_TEST_END, test); // skip inner afterEach hooks below errSuite level 23873 23874 var origSuite = self.suite; 23875 self.suite = errSuite || self.suite; 23876 return self.hookUp(HOOK_TYPE_AFTER_EACH, function (e, eSuite) { 23877 self.suite = origSuite; 23878 next(e, eSuite); 23879 }); 23880 } 23881 23882 if (err) { 23883 return hookErr(err, errSuite, false); 23884 } 23885 23886 self.currentRunnable = self.test; 23887 self.runTest(function (err) { 23888 test = self.test; // conditional skip within it 23889 23890 if (test.pending) { 23891 if (self.forbidPending) { 23892 self.fail(test, new Error('Pending test forbidden'), true); 23893 } else { 23894 test.state = STATE_PENDING; 23895 self.emit(constants$3.EVENT_TEST_PENDING, test); 23896 } 23897 23898 self.emit(constants$3.EVENT_TEST_END, test); 23899 return self.hookUp(HOOK_TYPE_AFTER_EACH, next); 23900 } else if (err) { 23901 var retry = test.currentRetry(); 23902 23903 if (retry < test.retries()) { 23904 var clonedTest = test.clone(); 23905 clonedTest.currentRetry(retry + 1); 23906 tests.unshift(clonedTest); 23907 self.emit(constants$3.EVENT_TEST_RETRY, test, err); // Early return + hook trigger so that it doesn't 23908 // increment the count wrong 23909 23910 return self.hookUp(HOOK_TYPE_AFTER_EACH, next); 23911 } else { 23912 self.fail(test, err); 23913 } 23914 23915 self.emit(constants$3.EVENT_TEST_END, test); 23916 return self.hookUp(HOOK_TYPE_AFTER_EACH, next); 23917 } 23918 23919 test.state = STATE_PASSED; 23920 self.emit(constants$3.EVENT_TEST_PASS, test); 23921 self.emit(constants$3.EVENT_TEST_END, test); 23922 self.hookUp(HOOK_TYPE_AFTER_EACH, next); 23923 }); 23924 }); 23925 } 23926 23927 this.next = next; 23928 this.hookErr = hookErr; 23929 next(); 23930 }; 23931 /** 23932 * Run the given `suite` and invoke the callback `fn()` when complete. 23933 * 23934 * @private 23935 * @param {Suite} suite 23936 * @param {Function} fn 23937 */ 23938 23939 23940 Runner.prototype.runSuite = function (suite, fn) { 23941 var i = 0; 23942 var self = this; 23943 var total = this.grepTotal(suite); 23944 debug$2('runSuite(): running %s', suite.fullTitle()); 23945 23946 if (!total || self.failures && suite._bail) { 23947 debug$2('runSuite(): bailing'); 23948 return fn(); 23949 } 23950 23951 this.emit(constants$3.EVENT_SUITE_BEGIN, this.suite = suite); 23952 23953 function next(errSuite) { 23954 if (errSuite) { 23955 // current suite failed on a hook from errSuite 23956 if (errSuite === suite) { 23957 // if errSuite is current suite 23958 // continue to the next sibling suite 23959 return done(); 23960 } // errSuite is among the parents of current suite 23961 // stop execution of errSuite and all sub-suites 23962 23963 23964 return done(errSuite); 23965 } 23966 23967 if (self._abort) { 23968 return done(); 23969 } 23970 23971 var curr = suite.suites[i++]; 23972 23973 if (!curr) { 23974 return done(); 23975 } // Avoid grep neglecting large number of tests causing a 23976 // huge recursive loop and thus a maximum call stack error. 23977 // See comment in `this.runTests()` for more information. 23978 23979 23980 if (self._grep !== self._defaultGrep) { 23981 Runner.immediately(function () { 23982 self.runSuite(curr, next); 23983 }); 23984 } else { 23985 self.runSuite(curr, next); 23986 } 23987 } 23988 23989 function done(errSuite) { 23990 self.suite = suite; 23991 self.nextSuite = next; // remove reference to test 23992 23993 delete self.test; 23994 self.hook(HOOK_TYPE_AFTER_ALL, function () { 23995 self.emit(constants$3.EVENT_SUITE_END, suite); 23996 fn(errSuite); 23997 }); 23998 } 23999 24000 this.nextSuite = next; 24001 this.hook(HOOK_TYPE_BEFORE_ALL, function (err) { 24002 if (err) { 24003 return done(); 24004 } 24005 24006 self.runTests(suite, next); 24007 }); 24008 }; 24009 /** 24010 * Handle uncaught exceptions within runner. 24011 * 24012 * This function is bound to the instance as `Runner#uncaught` at instantiation 24013 * time. It's intended to be listening on the `Process.uncaughtException` event. 24014 * In order to not leak EE listeners, we need to ensure no more than a single 24015 * `uncaughtException` listener exists per `Runner`. The only way to do 24016 * this--because this function needs the context (and we don't have lambdas)--is 24017 * to use `Function.prototype.bind`. We need strict equality to unregister and 24018 * _only_ unregister the _one_ listener we set from the 24019 * `Process.uncaughtException` event; would be poor form to just remove 24020 * everything. See {@link Runner#run} for where the event listener is registered 24021 * and unregistered. 24022 * @param {Error} err - Some uncaught error 24023 * @private 24024 */ 24025 24026 24027 Runner.prototype._uncaught = function (err) { 24028 // this is defensive to prevent future developers from mis-calling this function. 24029 // it's more likely that it'd be called with the incorrect context--say, the global 24030 // `process` object--than it would to be called with a context that is not a "subclass" 24031 // of `Runner`. 24032 if (!(this instanceof Runner)) { 24033 throw createFatalError$1('Runner#uncaught() called with invalid context', this); 24034 } 24035 24036 if (err instanceof pending) { 24037 debug$2('uncaught(): caught a Pending'); 24038 return; 24039 } // browser does not exit script when throwing in global.onerror() 24040 24041 24042 if (this.allowUncaught && !utils.isBrowser()) { 24043 debug$2('uncaught(): bubbling exception due to --allow-uncaught'); 24044 throw err; 24045 } 24046 24047 if (this.state === constants$3.STATE_STOPPED) { 24048 debug$2('uncaught(): throwing after run has completed!'); 24049 throw err; 24050 } 24051 24052 if (err) { 24053 debug$2('uncaught(): got truthy exception %O', err); 24054 } else { 24055 debug$2('uncaught(): undefined/falsy exception'); 24056 err = createInvalidExceptionError$2('Caught falsy/undefined exception which would otherwise be uncaught. No stack trace found; try a debugger', err); 24057 } 24058 24059 if (!isError$1(err)) { 24060 err = thrown2Error(err); 24061 debug$2('uncaught(): converted "error" %o to Error', err); 24062 } 24063 24064 err.uncaught = true; 24065 var runnable$1 = this.currentRunnable; 24066 24067 if (!runnable$1) { 24068 runnable$1 = new runnable('Uncaught error outside test suite'); 24069 debug$2('uncaught(): no current Runnable; created a phony one'); 24070 runnable$1.parent = this.suite; 24071 24072 if (this.state === constants$3.STATE_RUNNING) { 24073 debug$2('uncaught(): failing gracefully'); 24074 this.fail(runnable$1, err); 24075 } else { 24076 // Can't recover from this failure 24077 debug$2('uncaught(): test run has not yet started; unrecoverable'); 24078 this.emit(constants$3.EVENT_RUN_BEGIN); 24079 this.fail(runnable$1, err); 24080 this.emit(constants$3.EVENT_RUN_END); 24081 } 24082 24083 return; 24084 } 24085 24086 runnable$1.clearTimeout(); 24087 24088 if (runnable$1.isFailed()) { 24089 debug$2('uncaught(): Runnable has already failed'); // Ignore error if already failed 24090 24091 return; 24092 } else if (runnable$1.isPending()) { 24093 debug$2('uncaught(): pending Runnable wound up failing!'); // report 'pending test' retrospectively as failed 24094 24095 this.fail(runnable$1, err, true); 24096 return; 24097 } // we cannot recover gracefully if a Runnable has already passed 24098 // then fails asynchronously 24099 24100 24101 if (runnable$1.isPassed()) { 24102 debug$2('uncaught(): Runnable has already passed; bailing gracefully'); 24103 this.fail(runnable$1, err); 24104 this.abort(); 24105 } else { 24106 debug$2('uncaught(): forcing Runnable to complete with Error'); 24107 return runnable$1.callback(err); 24108 } 24109 }; 24110 /** 24111 * Run the root suite and invoke `fn(failures)` 24112 * on completion. 24113 * 24114 * @public 24115 * @memberof Runner 24116 * @param {Function} fn - Callback when finished 24117 * @param {{files: string[], options: Options}} [opts] - For subclasses 24118 * @returns {Runner} Runner instance. 24119 */ 24120 24121 24122 Runner.prototype.run = function (fn) { 24123 var _this2 = this; 24124 24125 var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 24126 var rootSuite = this.suite; 24127 var options = opts.options || {}; 24128 debug$2('run(): got options: %O', options); 24129 24130 fn = fn || function () {}; 24131 24132 var end = function end() { 24133 debug$2('run(): root suite completed; emitting %s', constants$3.EVENT_RUN_END); 24134 24135 _this2.emit(constants$3.EVENT_RUN_END); 24136 }; 24137 24138 var begin = function begin() { 24139 debug$2('run(): emitting %s', constants$3.EVENT_RUN_BEGIN); 24140 24141 _this2.emit(constants$3.EVENT_RUN_BEGIN); 24142 24143 debug$2('run(): emitted %s', constants$3.EVENT_RUN_BEGIN); 24144 24145 _this2.runSuite(rootSuite, end); 24146 }; 24147 24148 var prepare = function prepare() { 24149 debug$2('run(): starting'); // If there is an `only` filter 24150 24151 if (rootSuite.hasOnly()) { 24152 rootSuite.filterOnly(); 24153 debug$2('run(): filtered exclusive Runnables'); 24154 } 24155 24156 _this2.state = constants$3.STATE_RUNNING; 24157 24158 if (_this2._delay) { 24159 _this2.emit(constants$3.EVENT_DELAY_END); 24160 24161 debug$2('run(): "delay" ended'); 24162 } 24163 24164 return begin(); 24165 }; // references cleanup to avoid memory leaks 24166 24167 24168 if (this._opts.cleanReferencesAfterRun) { 24169 this.on(constants$3.EVENT_SUITE_END, function (suite) { 24170 suite.cleanReferences(); 24171 }); 24172 } // callback 24173 24174 24175 this.on(constants$3.EVENT_RUN_END, function () { 24176 this.state = constants$3.STATE_STOPPED; 24177 debug$2('run(): emitted %s', constants$3.EVENT_RUN_END); 24178 fn(this.failures); 24179 }); 24180 24181 this._removeEventListener(process$1, 'uncaughtException', this.uncaught); 24182 24183 this._removeEventListener(process$1, 'unhandledRejection', this.unhandled); 24184 24185 this._addEventListener(process$1, 'uncaughtException', this.uncaught); 24186 24187 this._addEventListener(process$1, 'unhandledRejection', this.unhandled); 24188 24189 if (this._delay) { 24190 // for reporters, I guess. 24191 // might be nice to debounce some dots while we wait. 24192 this.emit(constants$3.EVENT_DELAY_BEGIN, rootSuite); 24193 rootSuite.once(EVENT_ROOT_SUITE_RUN, prepare); 24194 debug$2('run(): waiting for green light due to --delay'); 24195 } else { 24196 Runner.immediately(prepare); 24197 } 24198 24199 return this; 24200 }; 24201 /** 24202 * Toggle partial object linking behavior; used for building object references from 24203 * unique ID's. Does nothing in serial mode, because the object references already exist. 24204 * Subclasses can implement this (e.g., `ParallelBufferedRunner`) 24205 * @abstract 24206 * @param {boolean} [value] - If `true`, enable partial object linking, otherwise disable 24207 * @returns {Runner} 24208 * @chainable 24209 * @public 24210 * @example 24211 * // this reporter needs proper object references when run in parallel mode 24212 * class MyReporter() { 24213 * constructor(runner) { 24214 * this.runner.linkPartialObjects(true) 24215 * .on(EVENT_SUITE_BEGIN, suite => { 24216 // this Suite may be the same object... 24217 * }) 24218 * .on(EVENT_TEST_BEGIN, test => { 24219 * // ...as the `test.parent` property 24220 * }); 24221 * } 24222 * } 24223 */ 24224 24225 24226 Runner.prototype.linkPartialObjects = function (value) { 24227 return this; 24228 }; 24229 /* 24230 * Like {@link Runner#run}, but does not accept a callback and returns a `Promise` instead of a `Runner`. 24231 * This function cannot reject; an `unhandledRejection` event will bubble up to the `process` object instead. 24232 * @public 24233 * @memberof Runner 24234 * @param {Object} [opts] - Options for {@link Runner#run} 24235 * @returns {Promise<number>} Failure count 24236 */ 24237 24238 24239 Runner.prototype.runAsync = /*#__PURE__*/function () { 24240 var _runAsync = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { 24241 var _this3 = this; 24242 24243 var opts, 24244 _args = arguments; 24245 return regeneratorRuntime.wrap(function _callee$(_context) { 24246 while (1) { 24247 switch (_context.prev = _context.next) { 24248 case 0: 24249 opts = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; 24250 return _context.abrupt("return", new Promise(function (resolve) { 24251 _this3.run(resolve, opts); 24252 })); 24253 24254 case 2: 24255 case "end": 24256 return _context.stop(); 24257 } 24258 } 24259 }, _callee); 24260 })); 24261 24262 function runAsync() { 24263 return _runAsync.apply(this, arguments); 24264 } 24265 24266 return runAsync; 24267 }(); 24268 /** 24269 * Cleanly abort execution. 24270 * 24271 * @memberof Runner 24272 * @public 24273 * @return {Runner} Runner instance. 24274 */ 24275 24276 24277 Runner.prototype.abort = function () { 24278 debug$2('abort(): aborting'); 24279 this._abort = true; 24280 return this; 24281 }; 24282 /** 24283 * Returns `true` if Mocha is running in parallel mode. For reporters. 24284 * 24285 * Subclasses should return an appropriate value. 24286 * @public 24287 * @returns {false} 24288 */ 24289 24290 24291 Runner.prototype.isParallelMode = function isParallelMode() { 24292 return false; 24293 }; 24294 /** 24295 * Configures an alternate reporter for worker processes to use. Subclasses 24296 * using worker processes should implement this. 24297 * @public 24298 * @param {string} path - Absolute path to alternate reporter for worker processes to use 24299 * @returns {Runner} 24300 * @throws When in serial mode 24301 * @chainable 24302 * @abstract 24303 */ 24304 24305 24306 Runner.prototype.workerReporter = function () { 24307 throw createUnsupportedError$1('workerReporter() not supported in serial mode'); 24308 }; 24309 /** 24310 * Filter leaks with the given globals flagged as `ok`. 24311 * 24312 * @private 24313 * @param {Array} ok 24314 * @param {Array} globals 24315 * @return {Array} 24316 */ 24317 24318 24319 function filterLeaks(ok, globals) { 24320 return globals.filter(function (key) { 24321 // Firefox and Chrome exposes iframes as index inside the window object 24322 if (/^\d+/.test(key)) { 24323 return false; 24324 } // in firefox 24325 // if runner runs in an iframe, this iframe's window.getInterface method 24326 // not init at first it is assigned in some seconds 24327 24328 24329 if (commonjsGlobal.navigator && /^getInterface/.test(key)) { 24330 return false; 24331 } // an iframe could be approached by window[iframeIndex] 24332 // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak 24333 24334 24335 if (commonjsGlobal.navigator && /^\d+/.test(key)) { 24336 return false; 24337 } // Opera and IE expose global variables for HTML element IDs (issue #243) 24338 24339 24340 if (/^mocha-/.test(key)) { 24341 return false; 24342 } 24343 24344 var matched = ok.filter(function (ok) { 24345 if (~ok.indexOf('*')) { 24346 return key.indexOf(ok.split('*')[0]) === 0; 24347 } 24348 24349 return key === ok; 24350 }); 24351 return !matched.length && (!commonjsGlobal.navigator || key !== 'onerror'); 24352 }); 24353 } 24354 /** 24355 * Check if argument is an instance of Error object or a duck-typed equivalent. 24356 * 24357 * @private 24358 * @param {Object} err - object to check 24359 * @param {string} err.message - error message 24360 * @returns {boolean} 24361 */ 24362 24363 24364 function isError$1(err) { 24365 return err instanceof Error || err && typeof err.message === 'string'; 24366 } 24367 /** 24368 * 24369 * Converts thrown non-extensible type into proper Error. 24370 * 24371 * @private 24372 * @param {*} thrown - Non-extensible type thrown by code 24373 * @return {Error} 24374 */ 24375 24376 24377 function thrown2Error(err) { 24378 return new Error("the ".concat(utils.canonicalType(err), " ").concat(stringify(err), " was thrown, throw an Error :)")); 24379 } 24380 24381 Runner.constants = constants$3; 24382 /** 24383 * Node.js' `EventEmitter` 24384 * @external EventEmitter 24385 * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter} 24386 */ 24387 24388 var runner$1 = Runner; 24389 24390 var base = createCommonjsModule(function (module, exports) { 24391 /** 24392 * @module Base 24393 */ 24394 24395 /** 24396 * Module dependencies. 24397 */ 24398 24399 var constants = runner$1.constants; 24400 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 24401 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 24402 var isBrowser = utils.isBrowser(); 24403 24404 function getBrowserWindowSize() { 24405 if ('innerHeight' in commonjsGlobal) { 24406 return [commonjsGlobal.innerHeight, commonjsGlobal.innerWidth]; 24407 } // In a Web Worker, the DOM Window is not available. 24408 24409 24410 return [640, 480]; 24411 } 24412 /** 24413 * Expose `Base`. 24414 */ 24415 24416 24417 exports = module.exports = Base; 24418 /** 24419 * Check if both stdio streams are associated with a tty. 24420 */ 24421 24422 var isatty = isBrowser || process$1.stdout.isTTY && process$1.stderr.isTTY; 24423 /** 24424 * Save log references to avoid tests interfering (see GH-3604). 24425 */ 24426 24427 var consoleLog = console.log; 24428 /** 24429 * Enable coloring by default, except in the browser interface. 24430 */ 24431 24432 exports.useColors = !isBrowser && (require$$11.stdout || process$1.env.MOCHA_COLORS !== undefined); 24433 /** 24434 * Inline diffs instead of +/- 24435 */ 24436 24437 exports.inlineDiffs = false; 24438 /** 24439 * Default color map. 24440 */ 24441 24442 exports.colors = { 24443 pass: 90, 24444 fail: 31, 24445 'bright pass': 92, 24446 'bright fail': 91, 24447 'bright yellow': 93, 24448 pending: 36, 24449 suite: 0, 24450 'error title': 0, 24451 'error message': 31, 24452 'error stack': 90, 24453 checkmark: 32, 24454 fast: 90, 24455 medium: 33, 24456 slow: 31, 24457 green: 32, 24458 light: 90, 24459 'diff gutter': 90, 24460 'diff added': 32, 24461 'diff removed': 31, 24462 'diff added inline': '30;42', 24463 'diff removed inline': '30;41' 24464 }; 24465 /** 24466 * Default symbol map. 24467 */ 24468 24469 exports.symbols = { 24470 ok: '✓', 24471 err: '✖', 24472 dot: '․', 24473 comma: ',', 24474 bang: '!' 24475 }; // With node.js on Windows: use symbols available in terminal default fonts 24476 24477 if (process$1.platform === 'win32') { 24478 exports.symbols.ok = "\u221A"; 24479 exports.symbols.err = "\xD7"; 24480 exports.symbols.dot = '.'; 24481 } 24482 /** 24483 * Color `str` with the given `type`, 24484 * allowing colors to be disabled, 24485 * as well as user-defined color 24486 * schemes. 24487 * 24488 * @private 24489 * @param {string} type 24490 * @param {string} str 24491 * @return {string} 24492 */ 24493 24494 24495 var color = exports.color = function (type, str) { 24496 if (!exports.useColors) { 24497 return String(str); 24498 } 24499 24500 return "\x1B[" + exports.colors[type] + 'm' + str + "\x1B[0m"; 24501 }; 24502 /** 24503 * Expose term window size, with some defaults for when stderr is not a tty. 24504 */ 24505 24506 24507 exports.window = { 24508 width: 75 24509 }; 24510 24511 if (isatty) { 24512 if (isBrowser) { 24513 exports.window.width = getBrowserWindowSize()[1]; 24514 } else { 24515 exports.window.width = process$1.stdout.getWindowSize(1)[0]; 24516 } 24517 } 24518 /** 24519 * Expose some basic cursor interactions that are common among reporters. 24520 */ 24521 24522 24523 exports.cursor = { 24524 hide: function hide() { 24525 isatty && process$1.stdout.write("\x1B[?25l"); 24526 }, 24527 show: function show() { 24528 isatty && process$1.stdout.write("\x1B[?25h"); 24529 }, 24530 deleteLine: function deleteLine() { 24531 isatty && process$1.stdout.write("\x1B[2K"); 24532 }, 24533 beginningOfLine: function beginningOfLine() { 24534 isatty && process$1.stdout.write("\x1B[0G"); 24535 }, 24536 CR: function CR() { 24537 if (isatty) { 24538 exports.cursor.deleteLine(); 24539 exports.cursor.beginningOfLine(); 24540 } else { 24541 process$1.stdout.write('\r'); 24542 } 24543 } 24544 }; 24545 24546 var showDiff = exports.showDiff = function (err) { 24547 return err && err.showDiff !== false && sameType(err.actual, err.expected) && err.expected !== undefined; 24548 }; 24549 24550 function stringifyDiffObjs(err) { 24551 if (!utils.isString(err.actual) || !utils.isString(err.expected)) { 24552 err.actual = utils.stringify(err.actual); 24553 err.expected = utils.stringify(err.expected); 24554 } 24555 } 24556 /** 24557 * Returns a diff between 2 strings with coloured ANSI output. 24558 * 24559 * @description 24560 * The diff will be either inline or unified dependent on the value 24561 * of `Base.inlineDiff`. 24562 * 24563 * @param {string} actual 24564 * @param {string} expected 24565 * @return {string} Diff 24566 */ 24567 24568 24569 var generateDiff = exports.generateDiff = function (actual, expected) { 24570 try { 24571 return exports.inlineDiffs ? inlineDiff(actual, expected) : unifiedDiff(actual, expected); 24572 } catch (err) { 24573 var msg = '\n ' + color('diff added', '+ expected') + ' ' + color('diff removed', '- actual: failed to generate Mocha diff') + '\n'; 24574 return msg; 24575 } 24576 }; 24577 /** 24578 * Outputs the given `failures` as a list. 24579 * 24580 * @public 24581 * @memberof Mocha.reporters.Base 24582 * @variation 1 24583 * @param {Object[]} failures - Each is Test instance with corresponding 24584 * Error property 24585 */ 24586 24587 24588 exports.list = function (failures) { 24589 var multipleErr, multipleTest; 24590 Base.consoleLog(); 24591 failures.forEach(function (test, i) { 24592 // format 24593 var fmt = color('error title', ' %s) %s:\n') + color('error message', ' %s') + color('error stack', '\n%s\n'); // msg 24594 24595 var msg; 24596 var err; 24597 24598 if (test.err && test.err.multiple) { 24599 if (multipleTest !== test) { 24600 multipleTest = test; 24601 multipleErr = [test.err].concat(test.err.multiple); 24602 } 24603 24604 err = multipleErr.shift(); 24605 } else { 24606 err = test.err; 24607 } 24608 24609 var message; 24610 24611 if (err.message && typeof err.message.toString === 'function') { 24612 message = err.message + ''; 24613 } else if (typeof err.inspect === 'function') { 24614 message = err.inspect() + ''; 24615 } else { 24616 message = ''; 24617 } 24618 24619 var stack = err.stack || message; 24620 var index = message ? stack.indexOf(message) : -1; 24621 24622 if (index === -1) { 24623 msg = message; 24624 } else { 24625 index += message.length; 24626 msg = stack.slice(0, index); // remove msg from stack 24627 24628 stack = stack.slice(index + 1); 24629 } // uncaught 24630 24631 24632 if (err.uncaught) { 24633 msg = 'Uncaught ' + msg; 24634 } // explicitly show diff 24635 24636 24637 if (!exports.hideDiff && showDiff(err)) { 24638 stringifyDiffObjs(err); 24639 fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n'); 24640 var match = message.match(/^([^:]+): expected/); 24641 msg = '\n ' + color('error message', match ? match[1] : msg); 24642 msg += generateDiff(err.actual, err.expected); 24643 } // indent stack trace 24644 24645 24646 stack = stack.replace(/^/gm, ' '); // indented test title 24647 24648 var testTitle = ''; 24649 test.titlePath().forEach(function (str, index) { 24650 if (index !== 0) { 24651 testTitle += '\n '; 24652 } 24653 24654 for (var i = 0; i < index; i++) { 24655 testTitle += ' '; 24656 } 24657 24658 testTitle += str; 24659 }); 24660 Base.consoleLog(fmt, i + 1, testTitle, msg, stack); 24661 }); 24662 }; 24663 /** 24664 * Constructs a new `Base` reporter instance. 24665 * 24666 * @description 24667 * All other reporters generally inherit from this reporter. 24668 * 24669 * @public 24670 * @class 24671 * @memberof Mocha.reporters 24672 * @param {Runner} runner - Instance triggers reporter actions. 24673 * @param {Object} [options] - runner options 24674 */ 24675 24676 24677 function Base(runner, options) { 24678 var failures = this.failures = []; 24679 24680 if (!runner) { 24681 throw new TypeError('Missing runner argument'); 24682 } 24683 24684 this.options = options || {}; 24685 this.runner = runner; 24686 this.stats = runner.stats; // assigned so Reporters keep a closer reference 24687 24688 runner.on(EVENT_TEST_PASS, function (test) { 24689 if (test.duration > test.slow()) { 24690 test.speed = 'slow'; 24691 } else if (test.duration > test.slow() / 2) { 24692 test.speed = 'medium'; 24693 } else { 24694 test.speed = 'fast'; 24695 } 24696 }); 24697 runner.on(EVENT_TEST_FAIL, function (test, err) { 24698 if (showDiff(err)) { 24699 stringifyDiffObjs(err); 24700 } // more than one error per test 24701 24702 24703 if (test.err && err instanceof Error) { 24704 test.err.multiple = (test.err.multiple || []).concat(err); 24705 } else { 24706 test.err = err; 24707 } 24708 24709 failures.push(test); 24710 }); 24711 } 24712 /** 24713 * Outputs common epilogue used by many of the bundled reporters. 24714 * 24715 * @public 24716 * @memberof Mocha.reporters 24717 */ 24718 24719 24720 Base.prototype.epilogue = function () { 24721 var stats = this.stats; 24722 var fmt; 24723 Base.consoleLog(); // passes 24724 24725 fmt = color('bright pass', ' ') + color('green', ' %d passing') + color('light', ' (%s)'); 24726 Base.consoleLog(fmt, stats.passes || 0, ms(stats.duration)); // pending 24727 24728 if (stats.pending) { 24729 fmt = color('pending', ' ') + color('pending', ' %d pending'); 24730 Base.consoleLog(fmt, stats.pending); 24731 } // failures 24732 24733 24734 if (stats.failures) { 24735 fmt = color('fail', ' %d failing'); 24736 Base.consoleLog(fmt, stats.failures); 24737 Base.list(this.failures); 24738 Base.consoleLog(); 24739 } 24740 24741 Base.consoleLog(); 24742 }; 24743 /** 24744 * Pads the given `str` to `len`. 24745 * 24746 * @private 24747 * @param {string} str 24748 * @param {string} len 24749 * @return {string} 24750 */ 24751 24752 24753 function pad(str, len) { 24754 str = String(str); 24755 return Array(len - str.length + 1).join(' ') + str; 24756 } 24757 /** 24758 * Returns inline diff between 2 strings with coloured ANSI output. 24759 * 24760 * @private 24761 * @param {String} actual 24762 * @param {String} expected 24763 * @return {string} Diff 24764 */ 24765 24766 24767 function inlineDiff(actual, expected) { 24768 var msg = errorDiff(actual, expected); // linenos 24769 24770 var lines = msg.split('\n'); 24771 24772 if (lines.length > 4) { 24773 var width = String(lines.length).length; 24774 msg = lines.map(function (str, i) { 24775 return pad(++i, width) + ' |' + ' ' + str; 24776 }).join('\n'); 24777 } // legend 24778 24779 24780 msg = '\n' + color('diff removed inline', 'actual') + ' ' + color('diff added inline', 'expected') + '\n\n' + msg + '\n'; // indent 24781 24782 msg = msg.replace(/^/gm, ' '); 24783 return msg; 24784 } 24785 /** 24786 * Returns unified diff between two strings with coloured ANSI output. 24787 * 24788 * @private 24789 * @param {String} actual 24790 * @param {String} expected 24791 * @return {string} The diff. 24792 */ 24793 24794 24795 function unifiedDiff(actual, expected) { 24796 var indent = ' '; 24797 24798 function cleanUp(line) { 24799 if (line[0] === '+') { 24800 return indent + colorLines('diff added', line); 24801 } 24802 24803 if (line[0] === '-') { 24804 return indent + colorLines('diff removed', line); 24805 } 24806 24807 if (line.match(/@@/)) { 24808 return '--'; 24809 } 24810 24811 if (line.match(/\\ No newline/)) { 24812 return null; 24813 } 24814 24815 return indent + line; 24816 } 24817 24818 function notBlank(line) { 24819 return typeof line !== 'undefined' && line !== null; 24820 } 24821 24822 var msg = diff.createPatch('string', actual, expected); 24823 var lines = msg.split('\n').splice(5); 24824 return '\n ' + colorLines('diff added', '+ expected') + ' ' + colorLines('diff removed', '- actual') + '\n\n' + lines.map(cleanUp).filter(notBlank).join('\n'); 24825 } 24826 /** 24827 * Returns character diff for `err`. 24828 * 24829 * @private 24830 * @param {String} actual 24831 * @param {String} expected 24832 * @return {string} the diff 24833 */ 24834 24835 24836 function errorDiff(actual, expected) { 24837 return diff.diffWordsWithSpace(actual, expected).map(function (str) { 24838 if (str.added) { 24839 return colorLines('diff added inline', str.value); 24840 } 24841 24842 if (str.removed) { 24843 return colorLines('diff removed inline', str.value); 24844 } 24845 24846 return str.value; 24847 }).join(''); 24848 } 24849 /** 24850 * Colors lines for `str`, using the color `name`. 24851 * 24852 * @private 24853 * @param {string} name 24854 * @param {string} str 24855 * @return {string} 24856 */ 24857 24858 24859 function colorLines(name, str) { 24860 return str.split('\n').map(function (str) { 24861 return color(name, str); 24862 }).join('\n'); 24863 } 24864 /** 24865 * Object#toString reference. 24866 */ 24867 24868 24869 var objToString = Object.prototype.toString; 24870 /** 24871 * Checks that a / b have the same type. 24872 * 24873 * @private 24874 * @param {Object} a 24875 * @param {Object} b 24876 * @return {boolean} 24877 */ 24878 24879 function sameType(a, b) { 24880 return objToString.call(a) === objToString.call(b); 24881 } 24882 24883 Base.consoleLog = consoleLog; 24884 Base["abstract"] = true; 24885 }); 24886 24887 var dot = createCommonjsModule(function (module, exports) { 24888 /** 24889 * @module Dot 24890 */ 24891 24892 /** 24893 * Module dependencies. 24894 */ 24895 24896 var inherits = utils.inherits; 24897 var constants = runner$1.constants; 24898 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 24899 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 24900 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 24901 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 24902 var EVENT_RUN_END = constants.EVENT_RUN_END; 24903 /** 24904 * Expose `Dot`. 24905 */ 24906 24907 module.exports = Dot; 24908 /** 24909 * Constructs a new `Dot` reporter instance. 24910 * 24911 * @public 24912 * @class 24913 * @memberof Mocha.reporters 24914 * @extends Mocha.reporters.Base 24915 * @param {Runner} runner - Instance triggers reporter actions. 24916 * @param {Object} [options] - runner options 24917 */ 24918 24919 function Dot(runner, options) { 24920 base.call(this, runner, options); 24921 var self = this; 24922 var width = base.window.width * 0.75 | 0; 24923 var n = -1; 24924 runner.on(EVENT_RUN_BEGIN, function () { 24925 process$1.stdout.write('\n'); 24926 }); 24927 runner.on(EVENT_TEST_PENDING, function () { 24928 if (++n % width === 0) { 24929 process$1.stdout.write('\n '); 24930 } 24931 24932 process$1.stdout.write(base.color('pending', base.symbols.comma)); 24933 }); 24934 runner.on(EVENT_TEST_PASS, function (test) { 24935 if (++n % width === 0) { 24936 process$1.stdout.write('\n '); 24937 } 24938 24939 if (test.speed === 'slow') { 24940 process$1.stdout.write(base.color('bright yellow', base.symbols.dot)); 24941 } else { 24942 process$1.stdout.write(base.color(test.speed, base.symbols.dot)); 24943 } 24944 }); 24945 runner.on(EVENT_TEST_FAIL, function () { 24946 if (++n % width === 0) { 24947 process$1.stdout.write('\n '); 24948 } 24949 24950 process$1.stdout.write(base.color('fail', base.symbols.bang)); 24951 }); 24952 runner.once(EVENT_RUN_END, function () { 24953 process$1.stdout.write('\n'); 24954 self.epilogue(); 24955 }); 24956 } 24957 /** 24958 * Inherit from `Base.prototype`. 24959 */ 24960 24961 24962 inherits(Dot, base); 24963 Dot.description = 'dot matrix representation'; 24964 }); 24965 24966 var doc = createCommonjsModule(function (module, exports) { 24967 /** 24968 * @module Doc 24969 */ 24970 24971 /** 24972 * Module dependencies. 24973 */ 24974 24975 var constants = runner$1.constants; 24976 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 24977 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 24978 var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; 24979 var EVENT_SUITE_END = constants.EVENT_SUITE_END; 24980 /** 24981 * Expose `Doc`. 24982 */ 24983 24984 module.exports = Doc; 24985 /** 24986 * Constructs a new `Doc` reporter instance. 24987 * 24988 * @public 24989 * @class 24990 * @memberof Mocha.reporters 24991 * @extends Mocha.reporters.Base 24992 * @param {Runner} runner - Instance triggers reporter actions. 24993 * @param {Object} [options] - runner options 24994 */ 24995 24996 function Doc(runner, options) { 24997 base.call(this, runner, options); 24998 var indents = 2; 24999 25000 function indent() { 25001 return Array(indents).join(' '); 25002 } 25003 25004 runner.on(EVENT_SUITE_BEGIN, function (suite) { 25005 if (suite.root) { 25006 return; 25007 } 25008 25009 ++indents; 25010 base.consoleLog('%s<section class="suite">', indent()); 25011 ++indents; 25012 base.consoleLog('%s<h1>%s</h1>', indent(), utils.escape(suite.title)); 25013 base.consoleLog('%s<dl>', indent()); 25014 }); 25015 runner.on(EVENT_SUITE_END, function (suite) { 25016 if (suite.root) { 25017 return; 25018 } 25019 25020 base.consoleLog('%s</dl>', indent()); 25021 --indents; 25022 base.consoleLog('%s</section>', indent()); 25023 --indents; 25024 }); 25025 runner.on(EVENT_TEST_PASS, function (test) { 25026 base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.title)); 25027 base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.file)); 25028 var code = utils.escape(utils.clean(test.body)); 25029 base.consoleLog('%s <dd><pre><code>%s</code></pre></dd>', indent(), code); 25030 }); 25031 runner.on(EVENT_TEST_FAIL, function (test, err) { 25032 base.consoleLog('%s <dt class="error">%s</dt>', indent(), utils.escape(test.title)); 25033 base.consoleLog('%s <dt class="error">%s</dt>', indent(), utils.escape(test.file)); 25034 var code = utils.escape(utils.clean(test.body)); 25035 base.consoleLog('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(), code); 25036 base.consoleLog('%s <dd class="error">%s</dd>', indent(), utils.escape(err)); 25037 }); 25038 } 25039 25040 Doc.description = 'HTML documentation'; 25041 }); 25042 25043 var tap = createCommonjsModule(function (module, exports) { 25044 /** 25045 * @module TAP 25046 */ 25047 25048 /** 25049 * Module dependencies. 25050 */ 25051 25052 var constants = runner$1.constants; 25053 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 25054 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 25055 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 25056 var EVENT_RUN_END = constants.EVENT_RUN_END; 25057 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 25058 var EVENT_TEST_END = constants.EVENT_TEST_END; 25059 var inherits = utils.inherits; 25060 var sprintf = util.format; 25061 /** 25062 * Expose `TAP`. 25063 */ 25064 25065 module.exports = TAP; 25066 /** 25067 * Constructs a new `TAP` reporter instance. 25068 * 25069 * @public 25070 * @class 25071 * @memberof Mocha.reporters 25072 * @extends Mocha.reporters.Base 25073 * @param {Runner} runner - Instance triggers reporter actions. 25074 * @param {Object} [options] - runner options 25075 */ 25076 25077 function TAP(runner, options) { 25078 base.call(this, runner, options); 25079 var self = this; 25080 var n = 1; 25081 var tapVersion = '12'; 25082 25083 if (options && options.reporterOptions) { 25084 if (options.reporterOptions.tapVersion) { 25085 tapVersion = options.reporterOptions.tapVersion.toString(); 25086 } 25087 } 25088 25089 this._producer = createProducer(tapVersion); 25090 runner.once(EVENT_RUN_BEGIN, function () { 25091 self._producer.writeVersion(); 25092 }); 25093 runner.on(EVENT_TEST_END, function () { 25094 ++n; 25095 }); 25096 runner.on(EVENT_TEST_PENDING, function (test) { 25097 self._producer.writePending(n, test); 25098 }); 25099 runner.on(EVENT_TEST_PASS, function (test) { 25100 self._producer.writePass(n, test); 25101 }); 25102 runner.on(EVENT_TEST_FAIL, function (test, err) { 25103 self._producer.writeFail(n, test, err); 25104 }); 25105 runner.once(EVENT_RUN_END, function () { 25106 self._producer.writeEpilogue(runner.stats); 25107 }); 25108 } 25109 /** 25110 * Inherit from `Base.prototype`. 25111 */ 25112 25113 25114 inherits(TAP, base); 25115 /** 25116 * Returns a TAP-safe title of `test`. 25117 * 25118 * @private 25119 * @param {Test} test - Test instance. 25120 * @return {String} title with any hash character removed 25121 */ 25122 25123 function title(test) { 25124 return test.fullTitle().replace(/#/g, ''); 25125 } 25126 /** 25127 * Writes newline-terminated formatted string to reporter output stream. 25128 * 25129 * @private 25130 * @param {string} format - `printf`-like format string 25131 * @param {...*} [varArgs] - Format string arguments 25132 */ 25133 25134 25135 function println(format, varArgs) { 25136 var vargs = Array.from(arguments); 25137 vargs[0] += '\n'; 25138 process$1.stdout.write(sprintf.apply(null, vargs)); 25139 } 25140 /** 25141 * Returns a `tapVersion`-appropriate TAP producer instance, if possible. 25142 * 25143 * @private 25144 * @param {string} tapVersion - Version of TAP specification to produce. 25145 * @returns {TAPProducer} specification-appropriate instance 25146 * @throws {Error} if specification version has no associated producer. 25147 */ 25148 25149 25150 function createProducer(tapVersion) { 25151 var producers = { 25152 '12': new TAP12Producer(), 25153 '13': new TAP13Producer() 25154 }; 25155 var producer = producers[tapVersion]; 25156 25157 if (!producer) { 25158 throw new Error('invalid or unsupported TAP version: ' + JSON.stringify(tapVersion)); 25159 } 25160 25161 return producer; 25162 } 25163 /** 25164 * @summary 25165 * Constructs a new TAPProducer. 25166 * 25167 * @description 25168 * <em>Only</em> to be used as an abstract base class. 25169 * 25170 * @private 25171 * @constructor 25172 */ 25173 25174 25175 function TAPProducer() {} 25176 /** 25177 * Writes the TAP version to reporter output stream. 25178 * 25179 * @abstract 25180 */ 25181 25182 25183 TAPProducer.prototype.writeVersion = function () {}; 25184 /** 25185 * Writes the plan to reporter output stream. 25186 * 25187 * @abstract 25188 * @param {number} ntests - Number of tests that are planned to run. 25189 */ 25190 25191 25192 TAPProducer.prototype.writePlan = function (ntests) { 25193 println('%d..%d', 1, ntests); 25194 }; 25195 /** 25196 * Writes that test passed to reporter output stream. 25197 * 25198 * @abstract 25199 * @param {number} n - Index of test that passed. 25200 * @param {Test} test - Instance containing test information. 25201 */ 25202 25203 25204 TAPProducer.prototype.writePass = function (n, test) { 25205 println('ok %d %s', n, title(test)); 25206 }; 25207 /** 25208 * Writes that test was skipped to reporter output stream. 25209 * 25210 * @abstract 25211 * @param {number} n - Index of test that was skipped. 25212 * @param {Test} test - Instance containing test information. 25213 */ 25214 25215 25216 TAPProducer.prototype.writePending = function (n, test) { 25217 println('ok %d %s # SKIP -', n, title(test)); 25218 }; 25219 /** 25220 * Writes that test failed to reporter output stream. 25221 * 25222 * @abstract 25223 * @param {number} n - Index of test that failed. 25224 * @param {Test} test - Instance containing test information. 25225 * @param {Error} err - Reason the test failed. 25226 */ 25227 25228 25229 TAPProducer.prototype.writeFail = function (n, test, err) { 25230 println('not ok %d %s', n, title(test)); 25231 }; 25232 /** 25233 * Writes the summary epilogue to reporter output stream. 25234 * 25235 * @abstract 25236 * @param {Object} stats - Object containing run statistics. 25237 */ 25238 25239 25240 TAPProducer.prototype.writeEpilogue = function (stats) { 25241 // :TBD: Why is this not counting pending tests? 25242 println('# tests ' + (stats.passes + stats.failures)); 25243 println('# pass ' + stats.passes); // :TBD: Why are we not showing pending results? 25244 25245 println('# fail ' + stats.failures); 25246 this.writePlan(stats.passes + stats.failures + stats.pending); 25247 }; 25248 /** 25249 * @summary 25250 * Constructs a new TAP12Producer. 25251 * 25252 * @description 25253 * Produces output conforming to the TAP12 specification. 25254 * 25255 * @private 25256 * @constructor 25257 * @extends TAPProducer 25258 * @see {@link https://testanything.org/tap-specification.html|Specification} 25259 */ 25260 25261 25262 function TAP12Producer() { 25263 /** 25264 * Writes that test failed to reporter output stream, with error formatting. 25265 * @override 25266 */ 25267 this.writeFail = function (n, test, err) { 25268 TAPProducer.prototype.writeFail.call(this, n, test, err); 25269 25270 if (err.message) { 25271 println(err.message.replace(/^/gm, ' ')); 25272 } 25273 25274 if (err.stack) { 25275 println(err.stack.replace(/^/gm, ' ')); 25276 } 25277 }; 25278 } 25279 /** 25280 * Inherit from `TAPProducer.prototype`. 25281 */ 25282 25283 25284 inherits(TAP12Producer, TAPProducer); 25285 /** 25286 * @summary 25287 * Constructs a new TAP13Producer. 25288 * 25289 * @description 25290 * Produces output conforming to the TAP13 specification. 25291 * 25292 * @private 25293 * @constructor 25294 * @extends TAPProducer 25295 * @see {@link https://testanything.org/tap-version-13-specification.html|Specification} 25296 */ 25297 25298 function TAP13Producer() { 25299 /** 25300 * Writes the TAP version to reporter output stream. 25301 * @override 25302 */ 25303 this.writeVersion = function () { 25304 println('TAP version 13'); 25305 }; 25306 /** 25307 * Writes that test failed to reporter output stream, with error formatting. 25308 * @override 25309 */ 25310 25311 25312 this.writeFail = function (n, test, err) { 25313 TAPProducer.prototype.writeFail.call(this, n, test, err); 25314 var emitYamlBlock = err.message != null || err.stack != null; 25315 25316 if (emitYamlBlock) { 25317 println(indent(1) + '---'); 25318 25319 if (err.message) { 25320 println(indent(2) + 'message: |-'); 25321 println(err.message.replace(/^/gm, indent(3))); 25322 } 25323 25324 if (err.stack) { 25325 println(indent(2) + 'stack: |-'); 25326 println(err.stack.replace(/^/gm, indent(3))); 25327 } 25328 25329 println(indent(1) + '...'); 25330 } 25331 }; 25332 25333 function indent(level) { 25334 return Array(level + 1).join(' '); 25335 } 25336 } 25337 /** 25338 * Inherit from `TAPProducer.prototype`. 25339 */ 25340 25341 25342 inherits(TAP13Producer, TAPProducer); 25343 TAP.description = 'TAP-compatible output'; 25344 }); 25345 25346 var json = createCommonjsModule(function (module, exports) { 25347 /** 25348 * @module JSON 25349 */ 25350 25351 /** 25352 * Module dependencies. 25353 */ 25354 25355 var constants = runner$1.constants; 25356 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 25357 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 25358 var EVENT_TEST_END = constants.EVENT_TEST_END; 25359 var EVENT_RUN_END = constants.EVENT_RUN_END; 25360 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 25361 /** 25362 * Expose `JSON`. 25363 */ 25364 25365 module.exports = JSONReporter; 25366 /** 25367 * Constructs a new `JSON` reporter instance. 25368 * 25369 * @public 25370 * @class JSON 25371 * @memberof Mocha.reporters 25372 * @extends Mocha.reporters.Base 25373 * @param {Runner} runner - Instance triggers reporter actions. 25374 * @param {Object} [options] - runner options 25375 */ 25376 25377 function JSONReporter(runner, options) { 25378 base.call(this, runner, options); 25379 var self = this; 25380 var tests = []; 25381 var pending = []; 25382 var failures = []; 25383 var passes = []; 25384 runner.on(EVENT_TEST_END, function (test) { 25385 tests.push(test); 25386 }); 25387 runner.on(EVENT_TEST_PASS, function (test) { 25388 passes.push(test); 25389 }); 25390 runner.on(EVENT_TEST_FAIL, function (test) { 25391 failures.push(test); 25392 }); 25393 runner.on(EVENT_TEST_PENDING, function (test) { 25394 pending.push(test); 25395 }); 25396 runner.once(EVENT_RUN_END, function () { 25397 var obj = { 25398 stats: self.stats, 25399 tests: tests.map(clean), 25400 pending: pending.map(clean), 25401 failures: failures.map(clean), 25402 passes: passes.map(clean) 25403 }; 25404 runner.testResults = obj; 25405 process$1.stdout.write(JSON.stringify(obj, null, 2)); 25406 }); 25407 } 25408 /** 25409 * Return a plain-object representation of `test` 25410 * free of cyclic properties etc. 25411 * 25412 * @private 25413 * @param {Object} test 25414 * @return {Object} 25415 */ 25416 25417 25418 function clean(test) { 25419 var err = test.err || {}; 25420 25421 if (err instanceof Error) { 25422 err = errorJSON(err); 25423 } 25424 25425 return { 25426 title: test.title, 25427 fullTitle: test.fullTitle(), 25428 file: test.file, 25429 duration: test.duration, 25430 currentRetry: test.currentRetry(), 25431 speed: test.speed, 25432 err: cleanCycles(err) 25433 }; 25434 } 25435 /** 25436 * Replaces any circular references inside `obj` with '[object Object]' 25437 * 25438 * @private 25439 * @param {Object} obj 25440 * @return {Object} 25441 */ 25442 25443 25444 function cleanCycles(obj) { 25445 var cache = []; 25446 return JSON.parse(JSON.stringify(obj, function (key, value) { 25447 if (_typeof(value) === 'object' && value !== null) { 25448 if (cache.indexOf(value) !== -1) { 25449 // Instead of going in a circle, we'll print [object Object] 25450 return '' + value; 25451 } 25452 25453 cache.push(value); 25454 } 25455 25456 return value; 25457 })); 25458 } 25459 /** 25460 * Transform an Error object into a JSON object. 25461 * 25462 * @private 25463 * @param {Error} err 25464 * @return {Object} 25465 */ 25466 25467 25468 function errorJSON(err) { 25469 var res = {}; 25470 Object.getOwnPropertyNames(err).forEach(function (key) { 25471 res[key] = err[key]; 25472 }, err); 25473 return res; 25474 } 25475 25476 JSONReporter.description = 'single JSON object'; 25477 }); 25478 25479 // `thisNumberValue` abstract operation 25480 // https://tc39.es/ecma262/#sec-thisnumbervalue 25481 var thisNumberValue = function (value) { 25482 if (typeof value != 'number' && classofRaw(value) != 'Number') { 25483 throw TypeError('Incorrect invocation'); 25484 } 25485 return +value; 25486 }; 25487 25488 // `String.prototype.repeat` method implementation 25489 // https://tc39.es/ecma262/#sec-string.prototype.repeat 25490 var stringRepeat = ''.repeat || function repeat(count) { 25491 var str = String(requireObjectCoercible(this)); 25492 var result = ''; 25493 var n = toInteger(count); 25494 if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions'); 25495 for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str; 25496 return result; 25497 }; 25498 25499 var nativeToFixed = 1.0.toFixed; 25500 var floor$4 = Math.floor; 25501 25502 var pow$1 = function (x, n, acc) { 25503 return n === 0 ? acc : n % 2 === 1 ? pow$1(x, n - 1, acc * x) : pow$1(x * x, n / 2, acc); 25504 }; 25505 25506 var log$2 = function (x) { 25507 var n = 0; 25508 var x2 = x; 25509 while (x2 >= 4096) { 25510 n += 12; 25511 x2 /= 4096; 25512 } 25513 while (x2 >= 2) { 25514 n += 1; 25515 x2 /= 2; 25516 } return n; 25517 }; 25518 25519 var FORCED$8 = nativeToFixed && ( 25520 0.00008.toFixed(3) !== '0.000' || 25521 0.9.toFixed(0) !== '1' || 25522 1.255.toFixed(2) !== '1.25' || 25523 1000000000000000128.0.toFixed(0) !== '1000000000000000128' 25524 ) || !fails(function () { 25525 // V8 ~ Android 4.3- 25526 nativeToFixed.call({}); 25527 }); 25528 25529 // `Number.prototype.toFixed` method 25530 // https://tc39.es/ecma262/#sec-number.prototype.tofixed 25531 _export({ target: 'Number', proto: true, forced: FORCED$8 }, { 25532 // eslint-disable-next-line max-statements 25533 toFixed: function toFixed(fractionDigits) { 25534 var number = thisNumberValue(this); 25535 var fractDigits = toInteger(fractionDigits); 25536 var data = [0, 0, 0, 0, 0, 0]; 25537 var sign = ''; 25538 var result = '0'; 25539 var e, z, j, k; 25540 25541 var multiply = function (n, c) { 25542 var index = -1; 25543 var c2 = c; 25544 while (++index < 6) { 25545 c2 += n * data[index]; 25546 data[index] = c2 % 1e7; 25547 c2 = floor$4(c2 / 1e7); 25548 } 25549 }; 25550 25551 var divide = function (n) { 25552 var index = 6; 25553 var c = 0; 25554 while (--index >= 0) { 25555 c += data[index]; 25556 data[index] = floor$4(c / n); 25557 c = (c % n) * 1e7; 25558 } 25559 }; 25560 25561 var dataToString = function () { 25562 var index = 6; 25563 var s = ''; 25564 while (--index >= 0) { 25565 if (s !== '' || index === 0 || data[index] !== 0) { 25566 var t = String(data[index]); 25567 s = s === '' ? t : s + stringRepeat.call('0', 7 - t.length) + t; 25568 } 25569 } return s; 25570 }; 25571 25572 if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits'); 25573 // eslint-disable-next-line no-self-compare 25574 if (number != number) return 'NaN'; 25575 if (number <= -1e21 || number >= 1e21) return String(number); 25576 if (number < 0) { 25577 sign = '-'; 25578 number = -number; 25579 } 25580 if (number > 1e-21) { 25581 e = log$2(number * pow$1(2, 69, 1)) - 69; 25582 z = e < 0 ? number * pow$1(2, -e, 1) : number / pow$1(2, e, 1); 25583 z *= 0x10000000000000; 25584 e = 52 - e; 25585 if (e > 0) { 25586 multiply(0, z); 25587 j = fractDigits; 25588 while (j >= 7) { 25589 multiply(1e7, 0); 25590 j -= 7; 25591 } 25592 multiply(pow$1(10, j, 1), 0); 25593 j = e - 1; 25594 while (j >= 23) { 25595 divide(1 << 23); 25596 j -= 23; 25597 } 25598 divide(1 << j); 25599 multiply(1, 1); 25600 divide(2); 25601 result = dataToString(); 25602 } else { 25603 multiply(0, z); 25604 multiply(1 << -e, 0); 25605 result = dataToString() + stringRepeat.call('0', fractDigits); 25606 } 25607 } 25608 if (fractDigits > 0) { 25609 k = result.length; 25610 result = sign + (k <= fractDigits 25611 ? '0.' + stringRepeat.call('0', fractDigits - k) + result 25612 : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits)); 25613 } else { 25614 result = sign + result; 25615 } return result; 25616 } 25617 }); 25618 25619 /** 25620 @module browser/Progress 25621 */ 25622 25623 /** 25624 * Expose `Progress`. 25625 */ 25626 25627 var progress = Progress; 25628 /** 25629 * Initialize a new `Progress` indicator. 25630 */ 25631 25632 function Progress() { 25633 this.percent = 0; 25634 this.size(0); 25635 this.fontSize(11); 25636 this.font('helvetica, arial, sans-serif'); 25637 } 25638 /** 25639 * Set progress size to `size`. 25640 * 25641 * @public 25642 * @param {number} size 25643 * @return {Progress} Progress instance. 25644 */ 25645 25646 25647 Progress.prototype.size = function (size) { 25648 this._size = size; 25649 return this; 25650 }; 25651 /** 25652 * Set text to `text`. 25653 * 25654 * @public 25655 * @param {string} text 25656 * @return {Progress} Progress instance. 25657 */ 25658 25659 25660 Progress.prototype.text = function (text) { 25661 this._text = text; 25662 return this; 25663 }; 25664 /** 25665 * Set font size to `size`. 25666 * 25667 * @public 25668 * @param {number} size 25669 * @return {Progress} Progress instance. 25670 */ 25671 25672 25673 Progress.prototype.fontSize = function (size) { 25674 this._fontSize = size; 25675 return this; 25676 }; 25677 /** 25678 * Set font to `family`. 25679 * 25680 * @param {string} family 25681 * @return {Progress} Progress instance. 25682 */ 25683 25684 25685 Progress.prototype.font = function (family) { 25686 this._font = family; 25687 return this; 25688 }; 25689 /** 25690 * Update percentage to `n`. 25691 * 25692 * @param {number} n 25693 * @return {Progress} Progress instance. 25694 */ 25695 25696 25697 Progress.prototype.update = function (n) { 25698 this.percent = n; 25699 return this; 25700 }; 25701 /** 25702 * Draw on `ctx`. 25703 * 25704 * @param {CanvasRenderingContext2d} ctx 25705 * @return {Progress} Progress instance. 25706 */ 25707 25708 25709 Progress.prototype.draw = function (ctx) { 25710 try { 25711 var percent = Math.min(this.percent, 100); 25712 var size = this._size; 25713 var half = size / 2; 25714 var x = half; 25715 var y = half; 25716 var rad = half - 1; 25717 var fontSize = this._fontSize; 25718 ctx.font = fontSize + 'px ' + this._font; 25719 var angle = Math.PI * 2 * (percent / 100); 25720 ctx.clearRect(0, 0, size, size); // outer circle 25721 25722 ctx.strokeStyle = '#9f9f9f'; 25723 ctx.beginPath(); 25724 ctx.arc(x, y, rad, 0, angle, false); 25725 ctx.stroke(); // inner circle 25726 25727 ctx.strokeStyle = '#eee'; 25728 ctx.beginPath(); 25729 ctx.arc(x, y, rad - 1, 0, angle, true); 25730 ctx.stroke(); // text 25731 25732 var text = this._text || (percent | 0) + '%'; 25733 var w = ctx.measureText(text).width; 25734 ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1); 25735 } catch (ignore) {// don't fail if we can't render progress 25736 } 25737 25738 return this; 25739 }; 25740 25741 var html$1 = createCommonjsModule(function (module, exports) { 25742 /* eslint-env browser */ 25743 25744 /** 25745 * @module HTML 25746 */ 25747 25748 /** 25749 * Module dependencies. 25750 */ 25751 25752 var constants = runner$1.constants; 25753 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 25754 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 25755 var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; 25756 var EVENT_SUITE_END = constants.EVENT_SUITE_END; 25757 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 25758 var escape = utils.escape; 25759 /** 25760 * Save timer references to avoid Sinon interfering (see GH-237). 25761 */ 25762 25763 var Date = commonjsGlobal.Date; 25764 /** 25765 * Expose `HTML`. 25766 */ 25767 25768 module.exports = HTML; 25769 /** 25770 * Stats template. 25771 */ 25772 25773 var statsTemplate = '<ul id="mocha-stats">' + '<li class="progress"><canvas width="40" height="40"></canvas></li>' + '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' + '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' + '<li class="duration">duration: <em>0</em>s</li>' + '</ul>'; 25774 var playIcon = '‣'; 25775 /** 25776 * Constructs a new `HTML` reporter instance. 25777 * 25778 * @public 25779 * @class 25780 * @memberof Mocha.reporters 25781 * @extends Mocha.reporters.Base 25782 * @param {Runner} runner - Instance triggers reporter actions. 25783 * @param {Object} [options] - runner options 25784 */ 25785 25786 function HTML(runner, options) { 25787 base.call(this, runner, options); 25788 var self = this; 25789 var stats = this.stats; 25790 var stat = fragment(statsTemplate); 25791 var items = stat.getElementsByTagName('li'); 25792 var passes = items[1].getElementsByTagName('em')[0]; 25793 var passesLink = items[1].getElementsByTagName('a')[0]; 25794 var failures = items[2].getElementsByTagName('em')[0]; 25795 var failuresLink = items[2].getElementsByTagName('a')[0]; 25796 var duration = items[3].getElementsByTagName('em')[0]; 25797 var canvas = stat.getElementsByTagName('canvas')[0]; 25798 var report = fragment('<ul id="mocha-report"></ul>'); 25799 var stack = [report]; 25800 var progress$1; 25801 var ctx; 25802 var root = document.getElementById('mocha'); 25803 25804 if (canvas.getContext) { 25805 var ratio = window.devicePixelRatio || 1; 25806 canvas.style.width = canvas.width; 25807 canvas.style.height = canvas.height; 25808 canvas.width *= ratio; 25809 canvas.height *= ratio; 25810 ctx = canvas.getContext('2d'); 25811 ctx.scale(ratio, ratio); 25812 progress$1 = new progress(); 25813 } 25814 25815 if (!root) { 25816 return error('#mocha div missing, add it to your document'); 25817 } // pass toggle 25818 25819 25820 on(passesLink, 'click', function (evt) { 25821 evt.preventDefault(); 25822 unhide(); 25823 var name = /pass/.test(report.className) ? '' : ' pass'; 25824 report.className = report.className.replace(/fail|pass/g, '') + name; 25825 25826 if (report.className.trim()) { 25827 hideSuitesWithout('test pass'); 25828 } 25829 }); // failure toggle 25830 25831 on(failuresLink, 'click', function (evt) { 25832 evt.preventDefault(); 25833 unhide(); 25834 var name = /fail/.test(report.className) ? '' : ' fail'; 25835 report.className = report.className.replace(/fail|pass/g, '') + name; 25836 25837 if (report.className.trim()) { 25838 hideSuitesWithout('test fail'); 25839 } 25840 }); 25841 root.appendChild(stat); 25842 root.appendChild(report); 25843 25844 if (progress$1) { 25845 progress$1.size(40); 25846 } 25847 25848 runner.on(EVENT_SUITE_BEGIN, function (suite) { 25849 if (suite.root) { 25850 return; 25851 } // suite 25852 25853 25854 var url = self.suiteURL(suite); 25855 var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title)); // container 25856 25857 stack[0].appendChild(el); 25858 stack.unshift(document.createElement('ul')); 25859 el.appendChild(stack[0]); 25860 }); 25861 runner.on(EVENT_SUITE_END, function (suite) { 25862 if (suite.root) { 25863 updateStats(); 25864 return; 25865 } 25866 25867 stack.shift(); 25868 }); 25869 runner.on(EVENT_TEST_PASS, function (test) { 25870 var url = self.testURL(test); 25871 var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' + '<a href="%s" class="replay">' + playIcon + '</a></h2></li>'; 25872 var el = fragment(markup, test.speed, test.title, test.duration, url); 25873 self.addCodeToggle(el, test.body); 25874 appendToStack(el); 25875 updateStats(); 25876 }); 25877 runner.on(EVENT_TEST_FAIL, function (test) { 25878 var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>', test.title, self.testURL(test)); 25879 var stackString; // Note: Includes leading newline 25880 25881 var message = test.err.toString(); // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we 25882 // check for the result of the stringifying. 25883 25884 if (message === '[object Error]') { 25885 message = test.err.message; 25886 } 25887 25888 if (test.err.stack) { 25889 var indexOfMessage = test.err.stack.indexOf(test.err.message); 25890 25891 if (indexOfMessage === -1) { 25892 stackString = test.err.stack; 25893 } else { 25894 stackString = test.err.stack.substr(test.err.message.length + indexOfMessage); 25895 } 25896 } else if (test.err.sourceURL && test.err.line !== undefined) { 25897 // Safari doesn't give you a stack. Let's at least provide a source line. 25898 stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')'; 25899 } 25900 25901 stackString = stackString || ''; 25902 25903 if (test.err.htmlMessage && stackString) { 25904 el.appendChild(fragment('<div class="html-error">%s\n<pre class="error">%e</pre></div>', test.err.htmlMessage, stackString)); 25905 } else if (test.err.htmlMessage) { 25906 el.appendChild(fragment('<div class="html-error">%s</div>', test.err.htmlMessage)); 25907 } else { 25908 el.appendChild(fragment('<pre class="error">%e%e</pre>', message, stackString)); 25909 } 25910 25911 self.addCodeToggle(el, test.body); 25912 appendToStack(el); 25913 updateStats(); 25914 }); 25915 runner.on(EVENT_TEST_PENDING, function (test) { 25916 var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title); 25917 appendToStack(el); 25918 updateStats(); 25919 }); 25920 25921 function appendToStack(el) { 25922 // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack. 25923 if (stack[0]) { 25924 stack[0].appendChild(el); 25925 } 25926 } 25927 25928 function updateStats() { 25929 // TODO: add to stats 25930 var percent = stats.tests / runner.total * 100 | 0; 25931 25932 if (progress$1) { 25933 progress$1.update(percent).draw(ctx); 25934 } // update stats 25935 25936 25937 var ms = new Date() - stats.start; 25938 text(passes, stats.passes); 25939 text(failures, stats.failures); 25940 text(duration, (ms / 1000).toFixed(2)); 25941 } 25942 } 25943 /** 25944 * Makes a URL, preserving querystring ("search") parameters. 25945 * 25946 * @param {string} s 25947 * @return {string} A new URL. 25948 */ 25949 25950 25951 function makeUrl(s) { 25952 var search = window.location.search; // Remove previous grep query parameter if present 25953 25954 if (search) { 25955 search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?'); 25956 } 25957 25958 return window.location.pathname + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeStringRegexp(s)); 25959 } 25960 /** 25961 * Provide suite URL. 25962 * 25963 * @param {Object} [suite] 25964 */ 25965 25966 25967 HTML.prototype.suiteURL = function (suite) { 25968 return makeUrl(suite.fullTitle()); 25969 }; 25970 /** 25971 * Provide test URL. 25972 * 25973 * @param {Object} [test] 25974 */ 25975 25976 25977 HTML.prototype.testURL = function (test) { 25978 return makeUrl(test.fullTitle()); 25979 }; 25980 /** 25981 * Adds code toggle functionality for the provided test's list element. 25982 * 25983 * @param {HTMLLIElement} el 25984 * @param {string} contents 25985 */ 25986 25987 25988 HTML.prototype.addCodeToggle = function (el, contents) { 25989 var h2 = el.getElementsByTagName('h2')[0]; 25990 on(h2, 'click', function () { 25991 pre.style.display = pre.style.display === 'none' ? 'block' : 'none'; 25992 }); 25993 var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents)); 25994 el.appendChild(pre); 25995 pre.style.display = 'none'; 25996 }; 25997 /** 25998 * Display error `msg`. 25999 * 26000 * @param {string} msg 26001 */ 26002 26003 26004 function error(msg) { 26005 document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg)); 26006 } 26007 /** 26008 * Return a DOM fragment from `html`. 26009 * 26010 * @param {string} html 26011 */ 26012 26013 26014 function fragment(html) { 26015 var args = arguments; 26016 var div = document.createElement('div'); 26017 var i = 1; 26018 div.innerHTML = html.replace(/%([se])/g, function (_, type) { 26019 switch (type) { 26020 case 's': 26021 return String(args[i++]); 26022 26023 case 'e': 26024 return escape(args[i++]); 26025 // no default 26026 } 26027 }); 26028 return div.firstChild; 26029 } 26030 /** 26031 * Check for suites that do not have elements 26032 * with `classname`, and hide them. 26033 * 26034 * @param {text} classname 26035 */ 26036 26037 26038 function hideSuitesWithout(classname) { 26039 var suites = document.getElementsByClassName('suite'); 26040 26041 for (var i = 0; i < suites.length; i++) { 26042 var els = suites[i].getElementsByClassName(classname); 26043 26044 if (!els.length) { 26045 suites[i].className += ' hidden'; 26046 } 26047 } 26048 } 26049 /** 26050 * Unhide .hidden suites. 26051 */ 26052 26053 26054 function unhide() { 26055 var els = document.getElementsByClassName('suite hidden'); 26056 26057 while (els.length > 0) { 26058 els[0].className = els[0].className.replace('suite hidden', 'suite'); 26059 } 26060 } 26061 /** 26062 * Set an element's text contents. 26063 * 26064 * @param {HTMLElement} el 26065 * @param {string} contents 26066 */ 26067 26068 26069 function text(el, contents) { 26070 if (el.textContent) { 26071 el.textContent = contents; 26072 } else { 26073 el.innerText = contents; 26074 } 26075 } 26076 /** 26077 * Listen on `event` with callback `fn`. 26078 */ 26079 26080 26081 function on(el, event, fn) { 26082 if (el.addEventListener) { 26083 el.addEventListener(event, fn, false); 26084 } else { 26085 el.attachEvent('on' + event, fn); 26086 } 26087 } 26088 26089 HTML.browserOnly = true; 26090 }); 26091 26092 var list = createCommonjsModule(function (module, exports) { 26093 /** 26094 * @module List 26095 */ 26096 26097 /** 26098 * Module dependencies. 26099 */ 26100 26101 var inherits = utils.inherits; 26102 var constants = runner$1.constants; 26103 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 26104 var EVENT_RUN_END = constants.EVENT_RUN_END; 26105 var EVENT_TEST_BEGIN = constants.EVENT_TEST_BEGIN; 26106 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 26107 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 26108 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 26109 var color = base.color; 26110 var cursor = base.cursor; 26111 /** 26112 * Expose `List`. 26113 */ 26114 26115 module.exports = List; 26116 /** 26117 * Constructs a new `List` reporter instance. 26118 * 26119 * @public 26120 * @class 26121 * @memberof Mocha.reporters 26122 * @extends Mocha.reporters.Base 26123 * @param {Runner} runner - Instance triggers reporter actions. 26124 * @param {Object} [options] - runner options 26125 */ 26126 26127 function List(runner, options) { 26128 base.call(this, runner, options); 26129 var self = this; 26130 var n = 0; 26131 runner.on(EVENT_RUN_BEGIN, function () { 26132 base.consoleLog(); 26133 }); 26134 runner.on(EVENT_TEST_BEGIN, function (test) { 26135 process$1.stdout.write(color('pass', ' ' + test.fullTitle() + ': ')); 26136 }); 26137 runner.on(EVENT_TEST_PENDING, function (test) { 26138 var fmt = color('checkmark', ' -') + color('pending', ' %s'); 26139 base.consoleLog(fmt, test.fullTitle()); 26140 }); 26141 runner.on(EVENT_TEST_PASS, function (test) { 26142 var fmt = color('checkmark', ' ' + base.symbols.ok) + color('pass', ' %s: ') + color(test.speed, '%dms'); 26143 cursor.CR(); 26144 base.consoleLog(fmt, test.fullTitle(), test.duration); 26145 }); 26146 runner.on(EVENT_TEST_FAIL, function (test) { 26147 cursor.CR(); 26148 base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle()); 26149 }); 26150 runner.once(EVENT_RUN_END, self.epilogue.bind(self)); 26151 } 26152 /** 26153 * Inherit from `Base.prototype`. 26154 */ 26155 26156 26157 inherits(List, base); 26158 List.description = 'like "spec" reporter but flat'; 26159 }); 26160 26161 var min$7 = createCommonjsModule(function (module, exports) { 26162 /** 26163 * @module Min 26164 */ 26165 26166 /** 26167 * Module dependencies. 26168 */ 26169 26170 var inherits = utils.inherits; 26171 var constants = runner$1.constants; 26172 var EVENT_RUN_END = constants.EVENT_RUN_END; 26173 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 26174 /** 26175 * Expose `Min`. 26176 */ 26177 26178 module.exports = Min; 26179 /** 26180 * Constructs a new `Min` reporter instance. 26181 * 26182 * @description 26183 * This minimal test reporter is best used with '--watch'. 26184 * 26185 * @public 26186 * @class 26187 * @memberof Mocha.reporters 26188 * @extends Mocha.reporters.Base 26189 * @param {Runner} runner - Instance triggers reporter actions. 26190 * @param {Object} [options] - runner options 26191 */ 26192 26193 function Min(runner, options) { 26194 base.call(this, runner, options); 26195 runner.on(EVENT_RUN_BEGIN, function () { 26196 // clear screen 26197 process$1.stdout.write("\x1B[2J"); // set cursor position 26198 26199 process$1.stdout.write("\x1B[1;3H"); 26200 }); 26201 runner.once(EVENT_RUN_END, this.epilogue.bind(this)); 26202 } 26203 /** 26204 * Inherit from `Base.prototype`. 26205 */ 26206 26207 26208 inherits(Min, base); 26209 Min.description = 'essentially just a summary'; 26210 }); 26211 26212 var spec = createCommonjsModule(function (module, exports) { 26213 /** 26214 * @module Spec 26215 */ 26216 26217 /** 26218 * Module dependencies. 26219 */ 26220 26221 var constants = runner$1.constants; 26222 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 26223 var EVENT_RUN_END = constants.EVENT_RUN_END; 26224 var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; 26225 var EVENT_SUITE_END = constants.EVENT_SUITE_END; 26226 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 26227 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 26228 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 26229 var inherits = utils.inherits; 26230 var color = base.color; 26231 /** 26232 * Expose `Spec`. 26233 */ 26234 26235 module.exports = Spec; 26236 /** 26237 * Constructs a new `Spec` reporter instance. 26238 * 26239 * @public 26240 * @class 26241 * @memberof Mocha.reporters 26242 * @extends Mocha.reporters.Base 26243 * @param {Runner} runner - Instance triggers reporter actions. 26244 * @param {Object} [options] - runner options 26245 */ 26246 26247 function Spec(runner, options) { 26248 base.call(this, runner, options); 26249 var self = this; 26250 var indents = 0; 26251 var n = 0; 26252 26253 function indent() { 26254 return Array(indents).join(' '); 26255 } 26256 26257 runner.on(EVENT_RUN_BEGIN, function () { 26258 base.consoleLog(); 26259 }); 26260 runner.on(EVENT_SUITE_BEGIN, function (suite) { 26261 ++indents; 26262 base.consoleLog(color('suite', '%s%s'), indent(), suite.title); 26263 }); 26264 runner.on(EVENT_SUITE_END, function () { 26265 --indents; 26266 26267 if (indents === 1) { 26268 base.consoleLog(); 26269 } 26270 }); 26271 runner.on(EVENT_TEST_PENDING, function (test) { 26272 var fmt = indent() + color('pending', ' - %s'); 26273 base.consoleLog(fmt, test.title); 26274 }); 26275 runner.on(EVENT_TEST_PASS, function (test) { 26276 var fmt; 26277 26278 if (test.speed === 'fast') { 26279 fmt = indent() + color('checkmark', ' ' + base.symbols.ok) + color('pass', ' %s'); 26280 base.consoleLog(fmt, test.title); 26281 } else { 26282 fmt = indent() + color('checkmark', ' ' + base.symbols.ok) + color('pass', ' %s') + color(test.speed, ' (%dms)'); 26283 base.consoleLog(fmt, test.title, test.duration); 26284 } 26285 }); 26286 runner.on(EVENT_TEST_FAIL, function (test) { 26287 base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title); 26288 }); 26289 runner.once(EVENT_RUN_END, self.epilogue.bind(self)); 26290 } 26291 /** 26292 * Inherit from `Base.prototype`. 26293 */ 26294 26295 26296 inherits(Spec, base); 26297 Spec.description = 'hierarchical & verbose [default]'; 26298 }); 26299 26300 var nyan = createCommonjsModule(function (module, exports) { 26301 /** 26302 * @module Nyan 26303 */ 26304 26305 /** 26306 * Module dependencies. 26307 */ 26308 26309 var constants = runner$1.constants; 26310 var inherits = utils.inherits; 26311 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 26312 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 26313 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 26314 var EVENT_RUN_END = constants.EVENT_RUN_END; 26315 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 26316 /** 26317 * Expose `Dot`. 26318 */ 26319 26320 module.exports = NyanCat; 26321 /** 26322 * Constructs a new `Nyan` reporter instance. 26323 * 26324 * @public 26325 * @class Nyan 26326 * @memberof Mocha.reporters 26327 * @extends Mocha.reporters.Base 26328 * @param {Runner} runner - Instance triggers reporter actions. 26329 * @param {Object} [options] - runner options 26330 */ 26331 26332 function NyanCat(runner, options) { 26333 base.call(this, runner, options); 26334 var self = this; 26335 var width = base.window.width * 0.75 | 0; 26336 var nyanCatWidth = this.nyanCatWidth = 11; 26337 this.colorIndex = 0; 26338 this.numberOfLines = 4; 26339 this.rainbowColors = self.generateColors(); 26340 this.scoreboardWidth = 5; 26341 this.tick = 0; 26342 this.trajectories = [[], [], [], []]; 26343 this.trajectoryWidthMax = width - nyanCatWidth; 26344 runner.on(EVENT_RUN_BEGIN, function () { 26345 base.cursor.hide(); 26346 self.draw(); 26347 }); 26348 runner.on(EVENT_TEST_PENDING, function () { 26349 self.draw(); 26350 }); 26351 runner.on(EVENT_TEST_PASS, function () { 26352 self.draw(); 26353 }); 26354 runner.on(EVENT_TEST_FAIL, function () { 26355 self.draw(); 26356 }); 26357 runner.once(EVENT_RUN_END, function () { 26358 base.cursor.show(); 26359 26360 for (var i = 0; i < self.numberOfLines; i++) { 26361 write('\n'); 26362 } 26363 26364 self.epilogue(); 26365 }); 26366 } 26367 /** 26368 * Inherit from `Base.prototype`. 26369 */ 26370 26371 26372 inherits(NyanCat, base); 26373 /** 26374 * Draw the nyan cat 26375 * 26376 * @private 26377 */ 26378 26379 NyanCat.prototype.draw = function () { 26380 this.appendRainbow(); 26381 this.drawScoreboard(); 26382 this.drawRainbow(); 26383 this.drawNyanCat(); 26384 this.tick = !this.tick; 26385 }; 26386 /** 26387 * Draw the "scoreboard" showing the number 26388 * of passes, failures and pending tests. 26389 * 26390 * @private 26391 */ 26392 26393 26394 NyanCat.prototype.drawScoreboard = function () { 26395 var stats = this.stats; 26396 26397 function draw(type, n) { 26398 write(' '); 26399 write(base.color(type, n)); 26400 write('\n'); 26401 } 26402 26403 draw('green', stats.passes); 26404 draw('fail', stats.failures); 26405 draw('pending', stats.pending); 26406 write('\n'); 26407 this.cursorUp(this.numberOfLines); 26408 }; 26409 /** 26410 * Append the rainbow. 26411 * 26412 * @private 26413 */ 26414 26415 26416 NyanCat.prototype.appendRainbow = function () { 26417 var segment = this.tick ? '_' : '-'; 26418 var rainbowified = this.rainbowify(segment); 26419 26420 for (var index = 0; index < this.numberOfLines; index++) { 26421 var trajectory = this.trajectories[index]; 26422 26423 if (trajectory.length >= this.trajectoryWidthMax) { 26424 trajectory.shift(); 26425 } 26426 26427 trajectory.push(rainbowified); 26428 } 26429 }; 26430 /** 26431 * Draw the rainbow. 26432 * 26433 * @private 26434 */ 26435 26436 26437 NyanCat.prototype.drawRainbow = function () { 26438 var self = this; 26439 this.trajectories.forEach(function (line) { 26440 write("\x1B[" + self.scoreboardWidth + 'C'); 26441 write(line.join('')); 26442 write('\n'); 26443 }); 26444 this.cursorUp(this.numberOfLines); 26445 }; 26446 /** 26447 * Draw the nyan cat 26448 * 26449 * @private 26450 */ 26451 26452 26453 NyanCat.prototype.drawNyanCat = function () { 26454 var self = this; 26455 var startWidth = this.scoreboardWidth + this.trajectories[0].length; 26456 var dist = "\x1B[" + startWidth + 'C'; 26457 var padding = ''; 26458 write(dist); 26459 write('_,------,'); 26460 write('\n'); 26461 write(dist); 26462 padding = self.tick ? ' ' : ' '; 26463 write('_|' + padding + '/\\_/\\ '); 26464 write('\n'); 26465 write(dist); 26466 padding = self.tick ? '_' : '__'; 26467 var tail = self.tick ? '~' : '^'; 26468 write(tail + '|' + padding + this.face() + ' '); 26469 write('\n'); 26470 write(dist); 26471 padding = self.tick ? ' ' : ' '; 26472 write(padding + '"" "" '); 26473 write('\n'); 26474 this.cursorUp(this.numberOfLines); 26475 }; 26476 /** 26477 * Draw nyan cat face. 26478 * 26479 * @private 26480 * @return {string} 26481 */ 26482 26483 26484 NyanCat.prototype.face = function () { 26485 var stats = this.stats; 26486 26487 if (stats.failures) { 26488 return '( x .x)'; 26489 } else if (stats.pending) { 26490 return '( o .o)'; 26491 } else if (stats.passes) { 26492 return '( ^ .^)'; 26493 } 26494 26495 return '( - .-)'; 26496 }; 26497 /** 26498 * Move cursor up `n`. 26499 * 26500 * @private 26501 * @param {number} n 26502 */ 26503 26504 26505 NyanCat.prototype.cursorUp = function (n) { 26506 write("\x1B[" + n + 'A'); 26507 }; 26508 /** 26509 * Move cursor down `n`. 26510 * 26511 * @private 26512 * @param {number} n 26513 */ 26514 26515 26516 NyanCat.prototype.cursorDown = function (n) { 26517 write("\x1B[" + n + 'B'); 26518 }; 26519 /** 26520 * Generate rainbow colors. 26521 * 26522 * @private 26523 * @return {Array} 26524 */ 26525 26526 26527 NyanCat.prototype.generateColors = function () { 26528 var colors = []; 26529 26530 for (var i = 0; i < 6 * 7; i++) { 26531 var pi3 = Math.floor(Math.PI / 3); 26532 var n = i * (1.0 / 6); 26533 var r = Math.floor(3 * Math.sin(n) + 3); 26534 var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3); 26535 var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3); 26536 colors.push(36 * r + 6 * g + b + 16); 26537 } 26538 26539 return colors; 26540 }; 26541 /** 26542 * Apply rainbow to the given `str`. 26543 * 26544 * @private 26545 * @param {string} str 26546 * @return {string} 26547 */ 26548 26549 26550 NyanCat.prototype.rainbowify = function (str) { 26551 if (!base.useColors) { 26552 return str; 26553 } 26554 26555 var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length]; 26556 this.colorIndex += 1; 26557 return "\x1B[38;5;" + color + 'm' + str + "\x1B[0m"; 26558 }; 26559 /** 26560 * Stdout helper. 26561 * 26562 * @param {string} string A message to write to stdout. 26563 */ 26564 26565 26566 function write(string) { 26567 process$1.stdout.write(string); 26568 } 26569 26570 NyanCat.description = '"nyan cat"'; 26571 }); 26572 26573 var fs = {}; 26574 26575 var xunit = createCommonjsModule(function (module, exports) { 26576 /** 26577 * @module XUnit 26578 */ 26579 26580 /** 26581 * Module dependencies. 26582 */ 26583 26584 var createUnsupportedError = errors.createUnsupportedError; 26585 var constants = runner$1.constants; 26586 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 26587 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 26588 var EVENT_RUN_END = constants.EVENT_RUN_END; 26589 var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; 26590 var STATE_FAILED = runnable.constants.STATE_FAILED; 26591 var inherits = utils.inherits; 26592 var escape = utils.escape; 26593 /** 26594 * Save timer references to avoid Sinon interfering (see GH-237). 26595 */ 26596 26597 var Date = commonjsGlobal.Date; 26598 /** 26599 * Expose `XUnit`. 26600 */ 26601 26602 module.exports = XUnit; 26603 /** 26604 * Constructs a new `XUnit` reporter instance. 26605 * 26606 * @public 26607 * @class 26608 * @memberof Mocha.reporters 26609 * @extends Mocha.reporters.Base 26610 * @param {Runner} runner - Instance triggers reporter actions. 26611 * @param {Object} [options] - runner options 26612 */ 26613 26614 function XUnit(runner, options) { 26615 base.call(this, runner, options); 26616 var stats = this.stats; 26617 var tests = []; 26618 var self = this; // the name of the test suite, as it will appear in the resulting XML file 26619 26620 var suiteName; // the default name of the test suite if none is provided 26621 26622 var DEFAULT_SUITE_NAME = 'Mocha Tests'; 26623 26624 if (options && options.reporterOptions) { 26625 if (options.reporterOptions.output) { 26626 if (!fs.createWriteStream) { 26627 throw createUnsupportedError('file output not supported in browser'); 26628 } 26629 26630 fs.mkdirSync(path$1.dirname(options.reporterOptions.output), { 26631 recursive: true 26632 }); 26633 self.fileStream = fs.createWriteStream(options.reporterOptions.output); 26634 } // get the suite name from the reporter options (if provided) 26635 26636 26637 suiteName = options.reporterOptions.suiteName; 26638 } // fall back to the default suite name 26639 26640 26641 suiteName = suiteName || DEFAULT_SUITE_NAME; 26642 runner.on(EVENT_TEST_PENDING, function (test) { 26643 tests.push(test); 26644 }); 26645 runner.on(EVENT_TEST_PASS, function (test) { 26646 tests.push(test); 26647 }); 26648 runner.on(EVENT_TEST_FAIL, function (test) { 26649 tests.push(test); 26650 }); 26651 runner.once(EVENT_RUN_END, function () { 26652 self.write(tag('testsuite', { 26653 name: suiteName, 26654 tests: stats.tests, 26655 failures: 0, 26656 errors: stats.failures, 26657 skipped: stats.tests - stats.failures - stats.passes, 26658 timestamp: new Date().toUTCString(), 26659 time: stats.duration / 1000 || 0 26660 }, false)); 26661 tests.forEach(function (t) { 26662 self.test(t); 26663 }); 26664 self.write('</testsuite>'); 26665 }); 26666 } 26667 /** 26668 * Inherit from `Base.prototype`. 26669 */ 26670 26671 26672 inherits(XUnit, base); 26673 /** 26674 * Override done to close the stream (if it's a file). 26675 * 26676 * @param failures 26677 * @param {Function} fn 26678 */ 26679 26680 XUnit.prototype.done = function (failures, fn) { 26681 if (this.fileStream) { 26682 this.fileStream.end(function () { 26683 fn(failures); 26684 }); 26685 } else { 26686 fn(failures); 26687 } 26688 }; 26689 /** 26690 * Write out the given line. 26691 * 26692 * @param {string} line 26693 */ 26694 26695 26696 XUnit.prototype.write = function (line) { 26697 if (this.fileStream) { 26698 this.fileStream.write(line + '\n'); 26699 } else if (_typeof(process$1) === 'object' && process$1.stdout) { 26700 process$1.stdout.write(line + '\n'); 26701 } else { 26702 base.consoleLog(line); 26703 } 26704 }; 26705 /** 26706 * Output tag for the given `test.` 26707 * 26708 * @param {Test} test 26709 */ 26710 26711 26712 XUnit.prototype.test = function (test) { 26713 base.useColors = false; 26714 var attrs = { 26715 classname: test.parent.fullTitle(), 26716 name: test.title, 26717 time: test.duration / 1000 || 0 26718 }; 26719 26720 if (test.state === STATE_FAILED) { 26721 var err = test.err; 26722 var diff = !base.hideDiff && base.showDiff(err) ? '\n' + base.generateDiff(err.actual, err.expected) : ''; 26723 this.write(tag('testcase', attrs, false, tag('failure', {}, false, escape(err.message) + escape(diff) + '\n' + escape(err.stack)))); 26724 } else if (test.isPending()) { 26725 this.write(tag('testcase', attrs, false, tag('skipped', {}, true))); 26726 } else { 26727 this.write(tag('testcase', attrs, true)); 26728 } 26729 }; 26730 /** 26731 * HTML tag helper. 26732 * 26733 * @param name 26734 * @param attrs 26735 * @param close 26736 * @param content 26737 * @return {string} 26738 */ 26739 26740 26741 function tag(name, attrs, close, content) { 26742 var end = close ? '/>' : '>'; 26743 var pairs = []; 26744 var tag; 26745 26746 for (var key in attrs) { 26747 if (Object.prototype.hasOwnProperty.call(attrs, key)) { 26748 pairs.push(key + '="' + escape(attrs[key]) + '"'); 26749 } 26750 } 26751 26752 tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end; 26753 26754 if (content) { 26755 tag += content + '</' + name + end; 26756 } 26757 26758 return tag; 26759 } 26760 26761 XUnit.description = 'XUnit-compatible XML output'; 26762 }); 26763 26764 var markdown = createCommonjsModule(function (module, exports) { 26765 /** 26766 * @module Markdown 26767 */ 26768 26769 /** 26770 * Module dependencies. 26771 */ 26772 26773 var constants = runner$1.constants; 26774 var EVENT_RUN_END = constants.EVENT_RUN_END; 26775 var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; 26776 var EVENT_SUITE_END = constants.EVENT_SUITE_END; 26777 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 26778 /** 26779 * Constants 26780 */ 26781 26782 var SUITE_PREFIX = '$'; 26783 /** 26784 * Expose `Markdown`. 26785 */ 26786 26787 module.exports = Markdown; 26788 /** 26789 * Constructs a new `Markdown` reporter instance. 26790 * 26791 * @public 26792 * @class 26793 * @memberof Mocha.reporters 26794 * @extends Mocha.reporters.Base 26795 * @param {Runner} runner - Instance triggers reporter actions. 26796 * @param {Object} [options] - runner options 26797 */ 26798 26799 function Markdown(runner, options) { 26800 base.call(this, runner, options); 26801 var level = 0; 26802 var buf = ''; 26803 26804 function title(str) { 26805 return Array(level).join('#') + ' ' + str; 26806 } 26807 26808 function mapTOC(suite, obj) { 26809 var ret = obj; 26810 var key = SUITE_PREFIX + suite.title; 26811 obj = obj[key] = obj[key] || { 26812 suite: suite 26813 }; 26814 suite.suites.forEach(function (suite) { 26815 mapTOC(suite, obj); 26816 }); 26817 return ret; 26818 } 26819 26820 function stringifyTOC(obj, level) { 26821 ++level; 26822 var buf = ''; 26823 var link; 26824 26825 for (var key in obj) { 26826 if (key === 'suite') { 26827 continue; 26828 } 26829 26830 if (key !== SUITE_PREFIX) { 26831 link = ' - [' + key.substring(1) + ']'; 26832 link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n'; 26833 buf += Array(level).join(' ') + link; 26834 } 26835 26836 buf += stringifyTOC(obj[key], level); 26837 } 26838 26839 return buf; 26840 } 26841 26842 function generateTOC(suite) { 26843 var obj = mapTOC(suite, {}); 26844 return stringifyTOC(obj, 0); 26845 } 26846 26847 generateTOC(runner.suite); 26848 runner.on(EVENT_SUITE_BEGIN, function (suite) { 26849 ++level; 26850 var slug = utils.slug(suite.fullTitle()); 26851 buf += '<a name="' + slug + '"></a>' + '\n'; 26852 buf += title(suite.title) + '\n'; 26853 }); 26854 runner.on(EVENT_SUITE_END, function () { 26855 --level; 26856 }); 26857 runner.on(EVENT_TEST_PASS, function (test) { 26858 var code = utils.clean(test.body); 26859 buf += test.title + '.\n'; 26860 buf += '\n```js\n'; 26861 buf += code + '\n'; 26862 buf += '```\n\n'; 26863 }); 26864 runner.once(EVENT_RUN_END, function () { 26865 process$1.stdout.write('# TOC\n'); 26866 process$1.stdout.write(generateTOC(runner.suite)); 26867 process$1.stdout.write(buf); 26868 }); 26869 } 26870 26871 Markdown.description = 'GitHub Flavored Markdown'; 26872 }); 26873 26874 var progress$1 = createCommonjsModule(function (module, exports) { 26875 /** 26876 * @module Progress 26877 */ 26878 26879 /** 26880 * Module dependencies. 26881 */ 26882 26883 var constants = runner$1.constants; 26884 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 26885 var EVENT_TEST_END = constants.EVENT_TEST_END; 26886 var EVENT_RUN_END = constants.EVENT_RUN_END; 26887 var inherits = utils.inherits; 26888 var color = base.color; 26889 var cursor = base.cursor; 26890 /** 26891 * Expose `Progress`. 26892 */ 26893 26894 module.exports = Progress; 26895 /** 26896 * General progress bar color. 26897 */ 26898 26899 base.colors.progress = 90; 26900 /** 26901 * Constructs a new `Progress` reporter instance. 26902 * 26903 * @public 26904 * @class 26905 * @memberof Mocha.reporters 26906 * @extends Mocha.reporters.Base 26907 * @param {Runner} runner - Instance triggers reporter actions. 26908 * @param {Object} [options] - runner options 26909 */ 26910 26911 function Progress(runner, options) { 26912 base.call(this, runner, options); 26913 var self = this; 26914 var width = base.window.width * 0.5 | 0; 26915 var total = runner.total; 26916 var complete = 0; 26917 var lastN = -1; // default chars 26918 26919 options = options || {}; 26920 var reporterOptions = options.reporterOptions || {}; 26921 options.open = reporterOptions.open || '['; 26922 options.complete = reporterOptions.complete || '▬'; 26923 options.incomplete = reporterOptions.incomplete || base.symbols.dot; 26924 options.close = reporterOptions.close || ']'; 26925 options.verbose = reporterOptions.verbose || false; // tests started 26926 26927 runner.on(EVENT_RUN_BEGIN, function () { 26928 process$1.stdout.write('\n'); 26929 cursor.hide(); 26930 }); // tests complete 26931 26932 runner.on(EVENT_TEST_END, function () { 26933 complete++; 26934 var percent = complete / total; 26935 var n = width * percent | 0; 26936 var i = width - n; 26937 26938 if (n === lastN && !options.verbose) { 26939 // Don't re-render the line if it hasn't changed 26940 return; 26941 } 26942 26943 lastN = n; 26944 cursor.CR(); 26945 process$1.stdout.write("\x1B[J"); 26946 process$1.stdout.write(color('progress', ' ' + options.open)); 26947 process$1.stdout.write(Array(n).join(options.complete)); 26948 process$1.stdout.write(Array(i).join(options.incomplete)); 26949 process$1.stdout.write(color('progress', options.close)); 26950 26951 if (options.verbose) { 26952 process$1.stdout.write(color('progress', ' ' + complete + ' of ' + total)); 26953 } 26954 }); // tests are complete, output some stats 26955 // and the failures if any 26956 26957 runner.once(EVENT_RUN_END, function () { 26958 cursor.show(); 26959 process$1.stdout.write('\n'); 26960 self.epilogue(); 26961 }); 26962 } 26963 /** 26964 * Inherit from `Base.prototype`. 26965 */ 26966 26967 26968 inherits(Progress, base); 26969 Progress.description = 'a progress bar'; 26970 }); 26971 26972 var landing = createCommonjsModule(function (module, exports) { 26973 /** 26974 * @module Landing 26975 */ 26976 26977 /** 26978 * Module dependencies. 26979 */ 26980 26981 var inherits = utils.inherits; 26982 var constants = runner$1.constants; 26983 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 26984 var EVENT_RUN_END = constants.EVENT_RUN_END; 26985 var EVENT_TEST_END = constants.EVENT_TEST_END; 26986 var STATE_FAILED = runnable.constants.STATE_FAILED; 26987 var cursor = base.cursor; 26988 var color = base.color; 26989 /** 26990 * Expose `Landing`. 26991 */ 26992 26993 module.exports = Landing; 26994 /** 26995 * Airplane color. 26996 */ 26997 26998 base.colors.plane = 0; 26999 /** 27000 * Airplane crash color. 27001 */ 27002 27003 base.colors['plane crash'] = 31; 27004 /** 27005 * Runway color. 27006 */ 27007 27008 base.colors.runway = 90; 27009 /** 27010 * Constructs a new `Landing` reporter instance. 27011 * 27012 * @public 27013 * @class 27014 * @memberof Mocha.reporters 27015 * @extends Mocha.reporters.Base 27016 * @param {Runner} runner - Instance triggers reporter actions. 27017 * @param {Object} [options] - runner options 27018 */ 27019 27020 function Landing(runner, options) { 27021 base.call(this, runner, options); 27022 var self = this; 27023 var width = base.window.width * 0.75 | 0; 27024 var stream = process$1.stdout; 27025 var plane = color('plane', '✈'); 27026 var crashed = -1; 27027 var n = 0; 27028 var total = 0; 27029 27030 function runway() { 27031 var buf = Array(width).join('-'); 27032 return ' ' + color('runway', buf); 27033 } 27034 27035 runner.on(EVENT_RUN_BEGIN, function () { 27036 stream.write('\n\n\n '); 27037 cursor.hide(); 27038 }); 27039 runner.on(EVENT_TEST_END, function (test) { 27040 // check if the plane crashed 27041 var col = crashed === -1 ? width * ++n / ++total | 0 : crashed; // show the crash 27042 27043 if (test.state === STATE_FAILED) { 27044 plane = color('plane crash', '✈'); 27045 crashed = col; 27046 } // render landing strip 27047 27048 27049 stream.write("\x1B[" + (width + 1) + "D\x1B[2A"); 27050 stream.write(runway()); 27051 stream.write('\n '); 27052 stream.write(color('runway', Array(col).join('⋅'))); 27053 stream.write(plane); 27054 stream.write(color('runway', Array(width - col).join('⋅') + '\n')); 27055 stream.write(runway()); 27056 stream.write("\x1B[0m"); 27057 }); 27058 runner.once(EVENT_RUN_END, function () { 27059 cursor.show(); 27060 process$1.stdout.write('\n'); 27061 self.epilogue(); 27062 }); // if cursor is hidden when we ctrl-C, then it will remain hidden unless... 27063 27064 process$1.once('SIGINT', function () { 27065 cursor.show(); 27066 nextTick(function () { 27067 process$1.kill(process$1.pid, 'SIGINT'); 27068 }); 27069 }); 27070 } 27071 /** 27072 * Inherit from `Base.prototype`. 27073 */ 27074 27075 27076 inherits(Landing, base); 27077 Landing.description = 'Unicode landing strip'; 27078 }); 27079 27080 var jsonStream = createCommonjsModule(function (module, exports) { 27081 /** 27082 * @module JSONStream 27083 */ 27084 27085 /** 27086 * Module dependencies. 27087 */ 27088 27089 var constants = runner$1.constants; 27090 var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; 27091 var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; 27092 var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; 27093 var EVENT_RUN_END = constants.EVENT_RUN_END; 27094 /** 27095 * Expose `JSONStream`. 27096 */ 27097 27098 module.exports = JSONStream; 27099 /** 27100 * Constructs a new `JSONStream` reporter instance. 27101 * 27102 * @public 27103 * @class 27104 * @memberof Mocha.reporters 27105 * @extends Mocha.reporters.Base 27106 * @param {Runner} runner - Instance triggers reporter actions. 27107 * @param {Object} [options] - runner options 27108 */ 27109 27110 function JSONStream(runner, options) { 27111 base.call(this, runner, options); 27112 var self = this; 27113 var total = runner.total; 27114 runner.once(EVENT_RUN_BEGIN, function () { 27115 writeEvent(['start', { 27116 total: total 27117 }]); 27118 }); 27119 runner.on(EVENT_TEST_PASS, function (test) { 27120 writeEvent(['pass', clean(test)]); 27121 }); 27122 runner.on(EVENT_TEST_FAIL, function (test, err) { 27123 test = clean(test); 27124 test.err = err.message; 27125 test.stack = err.stack || null; 27126 writeEvent(['fail', test]); 27127 }); 27128 runner.once(EVENT_RUN_END, function () { 27129 writeEvent(['end', self.stats]); 27130 }); 27131 } 27132 /** 27133 * Mocha event to be written to the output stream. 27134 * @typedef {Array} JSONStream~MochaEvent 27135 */ 27136 27137 /** 27138 * Writes Mocha event to reporter output stream. 27139 * 27140 * @private 27141 * @param {JSONStream~MochaEvent} event - Mocha event to be output. 27142 */ 27143 27144 27145 function writeEvent(event) { 27146 process$1.stdout.write(JSON.stringify(event) + '\n'); 27147 } 27148 /** 27149 * Returns an object literal representation of `test` 27150 * free of cyclic properties, etc. 27151 * 27152 * @private 27153 * @param {Test} test - Instance used as data source. 27154 * @return {Object} object containing pared-down test instance data 27155 */ 27156 27157 27158 function clean(test) { 27159 return { 27160 title: test.title, 27161 fullTitle: test.fullTitle(), 27162 file: test.file, 27163 duration: test.duration, 27164 currentRetry: test.currentRetry(), 27165 speed: test.speed 27166 }; 27167 } 27168 27169 JSONStream.description = 'newline delimited JSON events'; 27170 }); 27171 27172 var reporters = createCommonjsModule(function (module, exports) { 27173 // for dynamic (try/catch) requires, which Browserify doesn't handle. 27174 27175 exports.Base = exports.base = base; 27176 exports.Dot = exports.dot = dot; 27177 exports.Doc = exports.doc = doc; 27178 exports.TAP = exports.tap = tap; 27179 exports.JSON = exports.json = json; 27180 exports.HTML = exports.html = html$1; 27181 exports.List = exports.list = list; 27182 exports.Min = exports.min = min$7; 27183 exports.Spec = exports.spec = spec; 27184 exports.Nyan = exports.nyan = nyan; 27185 exports.XUnit = exports.xunit = xunit; 27186 exports.Markdown = exports.markdown = markdown; 27187 exports.Progress = exports.progress = progress$1; 27188 exports.Landing = exports.landing = landing; 27189 exports.JSONStream = exports['json-stream'] = jsonStream; 27190 }); 27191 27192 var name = "mocha"; 27193 var version$2 = "8.3.2"; 27194 var homepage = "https://mochajs.org/"; 27195 var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png"; 27196 var _package = { 27197 name: name, 27198 version: version$2, 27199 homepage: homepage, 27200 notifyLogo: notifyLogo 27201 }; 27202 27203 var _package$1 = /*#__PURE__*/Object.freeze({ 27204 __proto__: null, 27205 name: name, 27206 version: version$2, 27207 homepage: homepage, 27208 notifyLogo: notifyLogo, 27209 'default': _package 27210 }); 27211 27212 var require$$10 = getCjsExportFromNamespace(_package$1); 27213 27214 /** 27215 * Web Notifications module. 27216 * @module Growl 27217 */ 27218 27219 /** 27220 * Save timer references to avoid Sinon interfering (see GH-237). 27221 */ 27222 27223 27224 var Date$2 = commonjsGlobal.Date; 27225 var setTimeout$2 = commonjsGlobal.setTimeout; 27226 var EVENT_RUN_END = runner$1.constants.EVENT_RUN_END; 27227 var isBrowser = utils.isBrowser; 27228 /** 27229 * Checks if browser notification support exists. 27230 * 27231 * @public 27232 * @see {@link https://caniuse.com/#feat=notifications|Browser support (notifications)} 27233 * @see {@link https://caniuse.com/#feat=promises|Browser support (promises)} 27234 * @see {@link Mocha#growl} 27235 * @see {@link Mocha#isGrowlCapable} 27236 * @return {boolean} whether browser notification support exists 27237 */ 27238 27239 var isCapable = function isCapable() { 27240 var hasNotificationSupport = ('Notification' in window); 27241 var hasPromiseSupport = typeof Promise === 'function'; 27242 return isBrowser() && hasNotificationSupport && hasPromiseSupport; 27243 }; 27244 /** 27245 * Implements browser notifications as a pseudo-reporter. 27246 * 27247 * @public 27248 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/notification|Notification API} 27249 * @see {@link https://developers.google.com/web/fundamentals/push-notifications/display-a-notification|Displaying a Notification} 27250 * @see {@link Growl#isPermitted} 27251 * @see {@link Mocha#_growl} 27252 * @param {Runner} runner - Runner instance. 27253 */ 27254 27255 27256 var notify$2 = function notify(runner) { 27257 var promise = isPermitted(); 27258 /** 27259 * Attempt notification. 27260 */ 27261 27262 var sendNotification = function sendNotification() { 27263 // If user hasn't responded yet... "No notification for you!" (Seinfeld) 27264 Promise.race([promise, Promise.resolve(undefined)]).then(canNotify).then(function () { 27265 display(runner); 27266 })["catch"](notPermitted); 27267 }; 27268 27269 runner.once(EVENT_RUN_END, sendNotification); 27270 }; 27271 /** 27272 * Checks if browser notification is permitted by user. 27273 * 27274 * @private 27275 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission|Notification.permission} 27276 * @see {@link Mocha#growl} 27277 * @see {@link Mocha#isGrowlPermitted} 27278 * @returns {Promise<boolean>} promise determining if browser notification 27279 * permissible when fulfilled. 27280 */ 27281 27282 27283 function isPermitted() { 27284 var permitted = { 27285 granted: function allow() { 27286 return Promise.resolve(true); 27287 }, 27288 denied: function deny() { 27289 return Promise.resolve(false); 27290 }, 27291 "default": function ask() { 27292 return Notification.requestPermission().then(function (permission) { 27293 return permission === 'granted'; 27294 }); 27295 } 27296 }; 27297 return permitted[Notification.permission](); 27298 } 27299 /** 27300 * @summary 27301 * Determines if notification should proceed. 27302 * 27303 * @description 27304 * Notification shall <strong>not</strong> proceed unless `value` is true. 27305 * 27306 * `value` will equal one of: 27307 * <ul> 27308 * <li><code>true</code> (from `isPermitted`)</li> 27309 * <li><code>false</code> (from `isPermitted`)</li> 27310 * <li><code>undefined</code> (from `Promise.race`)</li> 27311 * </ul> 27312 * 27313 * @private 27314 * @param {boolean|undefined} value - Determines if notification permissible. 27315 * @returns {Promise<undefined>} Notification can proceed 27316 */ 27317 27318 27319 function canNotify(value) { 27320 if (!value) { 27321 var why = value === false ? 'blocked' : 'unacknowledged'; 27322 var reason = 'not permitted by user (' + why + ')'; 27323 return Promise.reject(new Error(reason)); 27324 } 27325 27326 return Promise.resolve(); 27327 } 27328 /** 27329 * Displays the notification. 27330 * 27331 * @private 27332 * @param {Runner} runner - Runner instance. 27333 */ 27334 27335 27336 function display(runner) { 27337 var stats = runner.stats; 27338 var symbol = { 27339 cross: "\u274C", 27340 tick: "\u2705" 27341 }; 27342 var logo = require$$10.notifyLogo; 27343 27344 var _message; 27345 27346 var message; 27347 var title; 27348 27349 if (stats.failures) { 27350 _message = stats.failures + ' of ' + stats.tests + ' tests failed'; 27351 message = symbol.cross + ' ' + _message; 27352 title = 'Failed'; 27353 } else { 27354 _message = stats.passes + ' tests passed in ' + stats.duration + 'ms'; 27355 message = symbol.tick + ' ' + _message; 27356 title = 'Passed'; 27357 } // Send notification 27358 27359 27360 var options = { 27361 badge: logo, 27362 body: message, 27363 dir: 'ltr', 27364 icon: logo, 27365 lang: 'en-US', 27366 name: 'mocha', 27367 requireInteraction: false, 27368 timestamp: Date$2.now() 27369 }; 27370 var notification = new Notification(title, options); // Autoclose after brief delay (makes various browsers act same) 27371 27372 var FORCE_DURATION = 4000; 27373 setTimeout$2(notification.close.bind(notification), FORCE_DURATION); 27374 } 27375 /** 27376 * As notifications are tangential to our purpose, just log the error. 27377 * 27378 * @private 27379 * @param {Error} err - Why notification didn't happen. 27380 */ 27381 27382 27383 function notPermitted(err) { 27384 console.error('notification error:', err.message); 27385 } 27386 27387 var growl = { 27388 isCapable: isCapable, 27389 notify: notify$2 27390 }; 27391 27392 var diff$1 = true; 27393 var extension = [ 27394 "js", 27395 "cjs", 27396 "mjs" 27397 ]; 27398 var reporter = "spec"; 27399 var slow = 75; 27400 var timeout = 2000; 27401 var ui = "bdd"; 27402 var mocharc = { 27403 diff: diff$1, 27404 extension: extension, 27405 "package": "./package.json", 27406 reporter: reporter, 27407 slow: slow, 27408 timeout: timeout, 27409 ui: ui, 27410 "watch-ignore": [ 27411 "node_modules", 27412 ".git" 27413 ] 27414 }; 27415 27416 var mocharc$1 = /*#__PURE__*/Object.freeze({ 27417 __proto__: null, 27418 diff: diff$1, 27419 extension: extension, 27420 reporter: reporter, 27421 slow: slow, 27422 timeout: timeout, 27423 ui: ui, 27424 'default': mocharc 27425 }); 27426 27427 /** 27428 * Provides a factory function for a {@link StatsCollector} object. 27429 * @module 27430 */ 27431 27432 27433 var constants$4 = runner$1.constants; 27434 var EVENT_TEST_PASS = constants$4.EVENT_TEST_PASS; 27435 var EVENT_TEST_FAIL = constants$4.EVENT_TEST_FAIL; 27436 var EVENT_SUITE_BEGIN = constants$4.EVENT_SUITE_BEGIN; 27437 var EVENT_RUN_BEGIN = constants$4.EVENT_RUN_BEGIN; 27438 var EVENT_TEST_PENDING = constants$4.EVENT_TEST_PENDING; 27439 var EVENT_RUN_END$1 = constants$4.EVENT_RUN_END; 27440 var EVENT_TEST_END = constants$4.EVENT_TEST_END; 27441 /** 27442 * Test statistics collector. 27443 * 27444 * @public 27445 * @typedef {Object} StatsCollector 27446 * @property {number} suites - integer count of suites run. 27447 * @property {number} tests - integer count of tests run. 27448 * @property {number} passes - integer count of passing tests. 27449 * @property {number} pending - integer count of pending tests. 27450 * @property {number} failures - integer count of failed tests. 27451 * @property {Date} start - time when testing began. 27452 * @property {Date} end - time when testing concluded. 27453 * @property {number} duration - number of msecs that testing took. 27454 */ 27455 27456 var Date$3 = commonjsGlobal.Date; 27457 /** 27458 * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`. 27459 * 27460 * @private 27461 * @param {Runner} runner - Runner instance 27462 * @throws {TypeError} If falsy `runner` 27463 */ 27464 27465 function createStatsCollector(runner) { 27466 /** 27467 * @type StatsCollector 27468 */ 27469 var stats = { 27470 suites: 0, 27471 tests: 0, 27472 passes: 0, 27473 pending: 0, 27474 failures: 0 27475 }; 27476 27477 if (!runner) { 27478 throw new TypeError('Missing runner argument'); 27479 } 27480 27481 runner.stats = stats; 27482 runner.once(EVENT_RUN_BEGIN, function () { 27483 stats.start = new Date$3(); 27484 }); 27485 runner.on(EVENT_SUITE_BEGIN, function (suite) { 27486 suite.root || stats.suites++; 27487 }); 27488 runner.on(EVENT_TEST_PASS, function () { 27489 stats.passes++; 27490 }); 27491 runner.on(EVENT_TEST_FAIL, function () { 27492 stats.failures++; 27493 }); 27494 runner.on(EVENT_TEST_PENDING, function () { 27495 stats.pending++; 27496 }); 27497 runner.on(EVENT_TEST_END, function () { 27498 stats.tests++; 27499 }); 27500 runner.once(EVENT_RUN_END$1, function () { 27501 stats.end = new Date$3(); 27502 stats.duration = stats.end - stats.start; 27503 }); 27504 } 27505 27506 var statsCollector = createStatsCollector; 27507 27508 var createInvalidArgumentTypeError$1 = errors.createInvalidArgumentTypeError; 27509 var isString$1 = utils.isString; 27510 var MOCHA_ID_PROP_NAME$1 = utils.constants.MOCHA_ID_PROP_NAME; 27511 var test$1 = Test; 27512 /** 27513 * Initialize a new `Test` with the given `title` and callback `fn`. 27514 * 27515 * @public 27516 * @class 27517 * @extends Runnable 27518 * @param {String} title - Test title (required) 27519 * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending" 27520 */ 27521 27522 function Test(title, fn) { 27523 if (!isString$1(title)) { 27524 throw createInvalidArgumentTypeError$1('Test argument "title" should be a string. Received type "' + _typeof(title) + '"', 'title', 'string'); 27525 } 27526 27527 this.type = 'test'; 27528 runnable.call(this, title, fn); 27529 this.reset(); 27530 } 27531 /** 27532 * Inherit from `Runnable.prototype`. 27533 */ 27534 27535 27536 utils.inherits(Test, runnable); 27537 /** 27538 * Resets the state initially or for a next run. 27539 */ 27540 27541 Test.prototype.reset = function () { 27542 runnable.prototype.reset.call(this); 27543 this.pending = !this.fn; 27544 delete this.state; 27545 }; 27546 /** 27547 * Set or get retried test 27548 * 27549 * @private 27550 */ 27551 27552 27553 Test.prototype.retriedTest = function (n) { 27554 if (!arguments.length) { 27555 return this._retriedTest; 27556 } 27557 27558 this._retriedTest = n; 27559 }; 27560 /** 27561 * Add test to the list of tests marked `only`. 27562 * 27563 * @private 27564 */ 27565 27566 27567 Test.prototype.markOnly = function () { 27568 this.parent.appendOnlyTest(this); 27569 }; 27570 27571 Test.prototype.clone = function () { 27572 var test = new Test(this.title, this.fn); 27573 test.timeout(this.timeout()); 27574 test.slow(this.slow()); 27575 test.retries(this.retries()); 27576 test.currentRetry(this.currentRetry()); 27577 test.retriedTest(this.retriedTest() || this); 27578 test.globals(this.globals()); 27579 test.parent = this.parent; 27580 test.file = this.file; 27581 test.ctx = this.ctx; 27582 return test; 27583 }; 27584 /** 27585 * Returns an minimal object suitable for transmission over IPC. 27586 * Functions are represented by keys beginning with `$$`. 27587 * @private 27588 * @returns {Object} 27589 */ 27590 27591 27592 Test.prototype.serialize = function serialize() { 27593 return _defineProperty({ 27594 $$currentRetry: this._currentRetry, 27595 $$fullTitle: this.fullTitle(), 27596 $$isPending: this.pending, 27597 $$retriedTest: this._retriedTest || null, 27598 $$slow: this._slow, 27599 $$titlePath: this.titlePath(), 27600 body: this.body, 27601 duration: this.duration, 27602 err: this.err, 27603 parent: _defineProperty({ 27604 $$fullTitle: this.parent.fullTitle() 27605 }, MOCHA_ID_PROP_NAME$1, this.parent.id), 27606 speed: this.speed, 27607 state: this.state, 27608 title: this.title, 27609 type: this.type, 27610 file: this.file 27611 }, MOCHA_ID_PROP_NAME$1, this.id); 27612 }; 27613 27614 /** 27615 @module interfaces/common 27616 */ 27617 27618 27619 var createMissingArgumentError$1 = errors.createMissingArgumentError; 27620 var createUnsupportedError$2 = errors.createUnsupportedError; 27621 var createForbiddenExclusivityError$1 = errors.createForbiddenExclusivityError; 27622 /** 27623 * Functions common to more than one interface. 27624 * 27625 * @private 27626 * @param {Suite[]} suites 27627 * @param {Context} context 27628 * @param {Mocha} mocha 27629 * @return {Object} An object containing common functions. 27630 */ 27631 27632 var common$1 = function common(suites, context, mocha) { 27633 /** 27634 * Check if the suite should be tested. 27635 * 27636 * @private 27637 * @param {Suite} suite - suite to check 27638 * @returns {boolean} 27639 */ 27640 function shouldBeTested(suite) { 27641 return !mocha.options.grep || mocha.options.grep && mocha.options.grep.test(suite.fullTitle()) && !mocha.options.invert; 27642 } 27643 27644 return { 27645 /** 27646 * This is only present if flag --delay is passed into Mocha. It triggers 27647 * root suite execution. 27648 * 27649 * @param {Suite} suite The root suite. 27650 * @return {Function} A function which runs the root suite 27651 */ 27652 runWithSuite: function runWithSuite(suite) { 27653 return function run() { 27654 suite.run(); 27655 }; 27656 }, 27657 27658 /** 27659 * Execute before running tests. 27660 * 27661 * @param {string} name 27662 * @param {Function} fn 27663 */ 27664 before: function before(name, fn) { 27665 suites[0].beforeAll(name, fn); 27666 }, 27667 27668 /** 27669 * Execute after running tests. 27670 * 27671 * @param {string} name 27672 * @param {Function} fn 27673 */ 27674 after: function after(name, fn) { 27675 suites[0].afterAll(name, fn); 27676 }, 27677 27678 /** 27679 * Execute before each test case. 27680 * 27681 * @param {string} name 27682 * @param {Function} fn 27683 */ 27684 beforeEach: function beforeEach(name, fn) { 27685 suites[0].beforeEach(name, fn); 27686 }, 27687 27688 /** 27689 * Execute after each test case. 27690 * 27691 * @param {string} name 27692 * @param {Function} fn 27693 */ 27694 afterEach: function afterEach(name, fn) { 27695 suites[0].afterEach(name, fn); 27696 }, 27697 suite: { 27698 /** 27699 * Create an exclusive Suite; convenience function 27700 * See docstring for create() below. 27701 * 27702 * @param {Object} opts 27703 * @returns {Suite} 27704 */ 27705 only: function only(opts) { 27706 if (mocha.options.forbidOnly) { 27707 throw createForbiddenExclusivityError$1(mocha); 27708 } 27709 27710 opts.isOnly = true; 27711 return this.create(opts); 27712 }, 27713 27714 /** 27715 * Create a Suite, but skip it; convenience function 27716 * See docstring for create() below. 27717 * 27718 * @param {Object} opts 27719 * @returns {Suite} 27720 */ 27721 skip: function skip(opts) { 27722 opts.pending = true; 27723 return this.create(opts); 27724 }, 27725 27726 /** 27727 * Creates a suite. 27728 * 27729 * @param {Object} opts Options 27730 * @param {string} opts.title Title of Suite 27731 * @param {Function} [opts.fn] Suite Function (not always applicable) 27732 * @param {boolean} [opts.pending] Is Suite pending? 27733 * @param {string} [opts.file] Filepath where this Suite resides 27734 * @param {boolean} [opts.isOnly] Is Suite exclusive? 27735 * @returns {Suite} 27736 */ 27737 create: function create(opts) { 27738 var suite$1 = suite.create(suites[0], opts.title); 27739 suite$1.pending = Boolean(opts.pending); 27740 suite$1.file = opts.file; 27741 suites.unshift(suite$1); 27742 27743 if (opts.isOnly) { 27744 suite$1.markOnly(); 27745 } 27746 27747 if (suite$1.pending && mocha.options.forbidPending && shouldBeTested(suite$1)) { 27748 throw createUnsupportedError$2('Pending test forbidden'); 27749 } 27750 27751 if (typeof opts.fn === 'function') { 27752 opts.fn.call(suite$1); 27753 suites.shift(); 27754 } else if (typeof opts.fn === 'undefined' && !suite$1.pending) { 27755 throw createMissingArgumentError$1('Suite "' + suite$1.fullTitle() + '" was defined but no callback was supplied. ' + 'Supply a callback or explicitly skip the suite.', 'callback', 'function'); 27756 } else if (!opts.fn && suite$1.pending) { 27757 suites.shift(); 27758 } 27759 27760 return suite$1; 27761 } 27762 }, 27763 test: { 27764 /** 27765 * Exclusive test-case. 27766 * 27767 * @param {Object} mocha 27768 * @param {Function} test 27769 * @returns {*} 27770 */ 27771 only: function only(mocha, test) { 27772 if (mocha.options.forbidOnly) { 27773 throw createForbiddenExclusivityError$1(mocha); 27774 } 27775 27776 test.markOnly(); 27777 return test; 27778 }, 27779 27780 /** 27781 * Pending test case. 27782 * 27783 * @param {string} title 27784 */ 27785 skip: function skip(title) { 27786 context.test(title); 27787 }, 27788 27789 /** 27790 * Number of retry attempts 27791 * 27792 * @param {number} n 27793 */ 27794 retries: function retries(n) { 27795 context.retries(n); 27796 } 27797 } 27798 }; 27799 }; 27800 27801 var EVENT_FILE_PRE_REQUIRE = suite.constants.EVENT_FILE_PRE_REQUIRE; 27802 /** 27803 * BDD-style interface: 27804 * 27805 * describe('Array', function() { 27806 * describe('#indexOf()', function() { 27807 * it('should return -1 when not present', function() { 27808 * // ... 27809 * }); 27810 * 27811 * it('should return the index when present', function() { 27812 * // ... 27813 * }); 27814 * }); 27815 * }); 27816 * 27817 * @param {Suite} suite Root suite. 27818 */ 27819 27820 var bdd = function bddInterface(suite) { 27821 var suites = [suite]; 27822 suite.on(EVENT_FILE_PRE_REQUIRE, function (context, file, mocha) { 27823 var common = common$1(suites, context, mocha); 27824 context.before = common.before; 27825 context.after = common.after; 27826 context.beforeEach = common.beforeEach; 27827 context.afterEach = common.afterEach; 27828 context.run = mocha.options.delay && common.runWithSuite(suite); 27829 /** 27830 * Describe a "suite" with the given `title` 27831 * and callback `fn` containing nested suites 27832 * and/or tests. 27833 */ 27834 27835 context.describe = context.context = function (title, fn) { 27836 return common.suite.create({ 27837 title: title, 27838 file: file, 27839 fn: fn 27840 }); 27841 }; 27842 /** 27843 * Pending describe. 27844 */ 27845 27846 27847 context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) { 27848 return common.suite.skip({ 27849 title: title, 27850 file: file, 27851 fn: fn 27852 }); 27853 }; 27854 /** 27855 * Exclusive suite. 27856 */ 27857 27858 27859 context.describe.only = function (title, fn) { 27860 return common.suite.only({ 27861 title: title, 27862 file: file, 27863 fn: fn 27864 }); 27865 }; 27866 /** 27867 * Describe a specification or test-case 27868 * with the given `title` and callback `fn` 27869 * acting as a thunk. 27870 */ 27871 27872 27873 context.it = context.specify = function (title, fn) { 27874 var suite = suites[0]; 27875 27876 if (suite.isPending()) { 27877 fn = null; 27878 } 27879 27880 var test = new test$1(title, fn); 27881 test.file = file; 27882 suite.addTest(test); 27883 return test; 27884 }; 27885 /** 27886 * Exclusive test-case. 27887 */ 27888 27889 27890 context.it.only = function (title, fn) { 27891 return common.test.only(mocha, context.it(title, fn)); 27892 }; 27893 /** 27894 * Pending test case. 27895 */ 27896 27897 27898 context.xit = context.xspecify = context.it.skip = function (title) { 27899 return context.it(title); 27900 }; 27901 /** 27902 * Number of attempts to retry. 27903 */ 27904 27905 27906 context.it.retries = function (n) { 27907 context.retries(n); 27908 }; 27909 }); 27910 }; 27911 27912 var description = 'BDD or RSpec style [default]'; 27913 bdd.description = description; 27914 27915 var EVENT_FILE_PRE_REQUIRE$1 = suite.constants.EVENT_FILE_PRE_REQUIRE; 27916 /** 27917 * TDD-style interface: 27918 * 27919 * suite('Array', function() { 27920 * suite('#indexOf()', function() { 27921 * suiteSetup(function() { 27922 * 27923 * }); 27924 * 27925 * test('should return -1 when not present', function() { 27926 * 27927 * }); 27928 * 27929 * test('should return the index when present', function() { 27930 * 27931 * }); 27932 * 27933 * suiteTeardown(function() { 27934 * 27935 * }); 27936 * }); 27937 * }); 27938 * 27939 * @param {Suite} suite Root suite. 27940 */ 27941 27942 var tdd = function tdd(suite) { 27943 var suites = [suite]; 27944 suite.on(EVENT_FILE_PRE_REQUIRE$1, function (context, file, mocha) { 27945 var common = common$1(suites, context, mocha); 27946 context.setup = common.beforeEach; 27947 context.teardown = common.afterEach; 27948 context.suiteSetup = common.before; 27949 context.suiteTeardown = common.after; 27950 context.run = mocha.options.delay && common.runWithSuite(suite); 27951 /** 27952 * Describe a "suite" with the given `title` and callback `fn` containing 27953 * nested suites and/or tests. 27954 */ 27955 27956 context.suite = function (title, fn) { 27957 return common.suite.create({ 27958 title: title, 27959 file: file, 27960 fn: fn 27961 }); 27962 }; 27963 /** 27964 * Pending suite. 27965 */ 27966 27967 27968 context.suite.skip = function (title, fn) { 27969 return common.suite.skip({ 27970 title: title, 27971 file: file, 27972 fn: fn 27973 }); 27974 }; 27975 /** 27976 * Exclusive test-case. 27977 */ 27978 27979 27980 context.suite.only = function (title, fn) { 27981 return common.suite.only({ 27982 title: title, 27983 file: file, 27984 fn: fn 27985 }); 27986 }; 27987 /** 27988 * Describe a specification or test-case with the given `title` and 27989 * callback `fn` acting as a thunk. 27990 */ 27991 27992 27993 context.test = function (title, fn) { 27994 var suite = suites[0]; 27995 27996 if (suite.isPending()) { 27997 fn = null; 27998 } 27999 28000 var test = new test$1(title, fn); 28001 test.file = file; 28002 suite.addTest(test); 28003 return test; 28004 }; 28005 /** 28006 * Exclusive test-case. 28007 */ 28008 28009 28010 context.test.only = function (title, fn) { 28011 return common.test.only(mocha, context.test(title, fn)); 28012 }; 28013 28014 context.test.skip = common.test.skip; 28015 context.test.retries = common.test.retries; 28016 }); 28017 }; 28018 28019 var description$1 = 'traditional "suite"/"test" instead of BDD\'s "describe"/"it"'; 28020 tdd.description = description$1; 28021 28022 var EVENT_FILE_PRE_REQUIRE$2 = suite.constants.EVENT_FILE_PRE_REQUIRE; 28023 /** 28024 * QUnit-style interface: 28025 * 28026 * suite('Array'); 28027 * 28028 * test('#length', function() { 28029 * var arr = [1,2,3]; 28030 * ok(arr.length == 3); 28031 * }); 28032 * 28033 * test('#indexOf()', function() { 28034 * var arr = [1,2,3]; 28035 * ok(arr.indexOf(1) == 0); 28036 * ok(arr.indexOf(2) == 1); 28037 * ok(arr.indexOf(3) == 2); 28038 * }); 28039 * 28040 * suite('String'); 28041 * 28042 * test('#length', function() { 28043 * ok('foo'.length == 3); 28044 * }); 28045 * 28046 * @param {Suite} suite Root suite. 28047 */ 28048 28049 var qunit = function qUnitInterface(suite) { 28050 var suites = [suite]; 28051 suite.on(EVENT_FILE_PRE_REQUIRE$2, function (context, file, mocha) { 28052 var common = common$1(suites, context, mocha); 28053 context.before = common.before; 28054 context.after = common.after; 28055 context.beforeEach = common.beforeEach; 28056 context.afterEach = common.afterEach; 28057 context.run = mocha.options.delay && common.runWithSuite(suite); 28058 /** 28059 * Describe a "suite" with the given `title`. 28060 */ 28061 28062 context.suite = function (title) { 28063 if (suites.length > 1) { 28064 suites.shift(); 28065 } 28066 28067 return common.suite.create({ 28068 title: title, 28069 file: file, 28070 fn: false 28071 }); 28072 }; 28073 /** 28074 * Exclusive Suite. 28075 */ 28076 28077 28078 context.suite.only = function (title) { 28079 if (suites.length > 1) { 28080 suites.shift(); 28081 } 28082 28083 return common.suite.only({ 28084 title: title, 28085 file: file, 28086 fn: false 28087 }); 28088 }; 28089 /** 28090 * Describe a specification or test-case 28091 * with the given `title` and callback `fn` 28092 * acting as a thunk. 28093 */ 28094 28095 28096 context.test = function (title, fn) { 28097 var test = new test$1(title, fn); 28098 test.file = file; 28099 suites[0].addTest(test); 28100 return test; 28101 }; 28102 /** 28103 * Exclusive test-case. 28104 */ 28105 28106 28107 context.test.only = function (title, fn) { 28108 return common.test.only(mocha, context.test(title, fn)); 28109 }; 28110 28111 context.test.skip = common.test.skip; 28112 context.test.retries = common.test.retries; 28113 }); 28114 }; 28115 28116 var description$2 = 'QUnit style'; 28117 qunit.description = description$2; 28118 28119 /** 28120 * Exports-style (as Node.js module) interface: 28121 * 28122 * exports.Array = { 28123 * '#indexOf()': { 28124 * 'should return -1 when the value is not present': function() { 28125 * 28126 * }, 28127 * 28128 * 'should return the correct index when the value is present': function() { 28129 * 28130 * } 28131 * } 28132 * }; 28133 * 28134 * @param {Suite} suite Root suite. 28135 */ 28136 28137 28138 var exports$1 = function exports(suite$1) { 28139 var suites = [suite$1]; 28140 suite$1.on(suite.constants.EVENT_FILE_REQUIRE, visit); 28141 28142 function visit(obj, file) { 28143 var suite$1; 28144 28145 for (var key in obj) { 28146 if (typeof obj[key] === 'function') { 28147 var fn = obj[key]; 28148 28149 switch (key) { 28150 case 'before': 28151 suites[0].beforeAll(fn); 28152 break; 28153 28154 case 'after': 28155 suites[0].afterAll(fn); 28156 break; 28157 28158 case 'beforeEach': 28159 suites[0].beforeEach(fn); 28160 break; 28161 28162 case 'afterEach': 28163 suites[0].afterEach(fn); 28164 break; 28165 28166 default: 28167 var test = new test$1(key, fn); 28168 test.file = file; 28169 suites[0].addTest(test); 28170 } 28171 } else { 28172 suite$1 = suite.create(suites[0], key); 28173 suites.unshift(suite$1); 28174 visit(obj[key], file); 28175 suites.shift(); 28176 } 28177 } 28178 } 28179 }; 28180 28181 var description$3 = 'Node.js module ("exports") style'; 28182 exports$1.description = description$3; 28183 28184 var bdd$1 = bdd; 28185 var tdd$1 = tdd; 28186 var qunit$1 = qunit; 28187 var exports$2 = exports$1; 28188 var interfaces = { 28189 bdd: bdd$1, 28190 tdd: tdd$1, 28191 qunit: qunit$1, 28192 exports: exports$2 28193 }; 28194 28195 /** 28196 * @module Context 28197 */ 28198 28199 /** 28200 * Expose `Context`. 28201 */ 28202 28203 var context = Context; 28204 /** 28205 * Initialize a new `Context`. 28206 * 28207 * @private 28208 */ 28209 28210 function Context() {} 28211 /** 28212 * Set or get the context `Runnable` to `runnable`. 28213 * 28214 * @private 28215 * @param {Runnable} runnable 28216 * @return {Context} context 28217 */ 28218 28219 28220 Context.prototype.runnable = function (runnable) { 28221 if (!arguments.length) { 28222 return this._runnable; 28223 } 28224 28225 this.test = this._runnable = runnable; 28226 return this; 28227 }; 28228 /** 28229 * Set or get test timeout `ms`. 28230 * 28231 * @private 28232 * @param {number} ms 28233 * @return {Context} self 28234 */ 28235 28236 28237 Context.prototype.timeout = function (ms) { 28238 if (!arguments.length) { 28239 return this.runnable().timeout(); 28240 } 28241 28242 this.runnable().timeout(ms); 28243 return this; 28244 }; 28245 /** 28246 * Set or get test slowness threshold `ms`. 28247 * 28248 * @private 28249 * @param {number} ms 28250 * @return {Context} self 28251 */ 28252 28253 28254 Context.prototype.slow = function (ms) { 28255 if (!arguments.length) { 28256 return this.runnable().slow(); 28257 } 28258 28259 this.runnable().slow(ms); 28260 return this; 28261 }; 28262 /** 28263 * Mark a test as skipped. 28264 * 28265 * @private 28266 * @throws Pending 28267 */ 28268 28269 28270 Context.prototype.skip = function () { 28271 this.runnable().skip(); 28272 }; 28273 /** 28274 * Set or get a number of allowed retries on failed tests 28275 * 28276 * @private 28277 * @param {number} n 28278 * @return {Context} self 28279 */ 28280 28281 28282 Context.prototype.retries = function (n) { 28283 if (!arguments.length) { 28284 return this.runnable().retries(); 28285 } 28286 28287 this.runnable().retries(n); 28288 return this; 28289 }; 28290 28291 var mocharc$2 = getCjsExportFromNamespace(mocharc$1); 28292 28293 var mocha = createCommonjsModule(function (module, exports) { 28294 /*! 28295 * mocha 28296 * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca> 28297 * MIT Licensed 28298 */ 28299 28300 var esmUtils = utils.supportsEsModules(true) ? require$$11 : undefined; 28301 var warn = errors.warn, 28302 createInvalidReporterError = errors.createInvalidReporterError, 28303 createInvalidInterfaceError = errors.createInvalidInterfaceError, 28304 createMochaInstanceAlreadyDisposedError = errors.createMochaInstanceAlreadyDisposedError, 28305 createMochaInstanceAlreadyRunningError = errors.createMochaInstanceAlreadyRunningError, 28306 createUnsupportedError = errors.createUnsupportedError; 28307 var _Suite$constants = suite.constants, 28308 EVENT_FILE_PRE_REQUIRE = _Suite$constants.EVENT_FILE_PRE_REQUIRE, 28309 EVENT_FILE_POST_REQUIRE = _Suite$constants.EVENT_FILE_POST_REQUIRE, 28310 EVENT_FILE_REQUIRE = _Suite$constants.EVENT_FILE_REQUIRE; 28311 var sQuote = utils.sQuote; 28312 var debug = browser$2('mocha:mocha'); 28313 exports = module.exports = Mocha; 28314 /** 28315 * A Mocha instance is a finite state machine. 28316 * These are the states it can be in. 28317 * @private 28318 */ 28319 28320 var mochaStates = utils.defineConstants({ 28321 /** 28322 * Initial state of the mocha instance 28323 * @private 28324 */ 28325 INIT: 'init', 28326 28327 /** 28328 * Mocha instance is running tests 28329 * @private 28330 */ 28331 RUNNING: 'running', 28332 28333 /** 28334 * Mocha instance is done running tests and references to test functions and hooks are cleaned. 28335 * You can reset this state by unloading the test files. 28336 * @private 28337 */ 28338 REFERENCES_CLEANED: 'referencesCleaned', 28339 28340 /** 28341 * Mocha instance is disposed and can no longer be used. 28342 * @private 28343 */ 28344 DISPOSED: 'disposed' 28345 }); 28346 /** 28347 * To require local UIs and reporters when running in node. 28348 */ 28349 28350 if (!utils.isBrowser() && typeof module.paths !== 'undefined') { 28351 var cwd = utils.cwd(); 28352 module.paths.push(cwd, path$1.join(cwd, 'node_modules')); 28353 } 28354 /** 28355 * Expose internals. 28356 * @private 28357 */ 28358 28359 28360 exports.utils = utils; 28361 exports.interfaces = interfaces; 28362 /** 28363 * @public 28364 * @memberof Mocha 28365 */ 28366 28367 exports.reporters = reporters; 28368 exports.Runnable = runnable; 28369 exports.Context = context; 28370 /** 28371 * 28372 * @memberof Mocha 28373 */ 28374 28375 exports.Runner = runner$1; 28376 exports.Suite = suite; 28377 exports.Hook = hook; 28378 exports.Test = test$1; 28379 var currentContext; 28380 28381 exports.afterEach = function () { 28382 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 28383 args[_key] = arguments[_key]; 28384 } 28385 28386 return (currentContext.afterEach || currentContext.teardown).apply(this, args); 28387 }; 28388 28389 exports.after = function () { 28390 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 28391 args[_key2] = arguments[_key2]; 28392 } 28393 28394 return (currentContext.after || currentContext.suiteTeardown).apply(this, args); 28395 }; 28396 28397 exports.beforeEach = function () { 28398 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 28399 args[_key3] = arguments[_key3]; 28400 } 28401 28402 return (currentContext.beforeEach || currentContext.setup).apply(this, args); 28403 }; 28404 28405 exports.before = function () { 28406 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 28407 args[_key4] = arguments[_key4]; 28408 } 28409 28410 return (currentContext.before || currentContext.suiteSetup).apply(this, args); 28411 }; 28412 28413 exports.describe = function () { 28414 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { 28415 args[_key5] = arguments[_key5]; 28416 } 28417 28418 return (currentContext.describe || currentContext.suite).apply(this, args); 28419 }; 28420 28421 exports.describe.only = function () { 28422 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { 28423 args[_key6] = arguments[_key6]; 28424 } 28425 28426 return (currentContext.describe || currentContext.suite).only.apply(this, args); 28427 }; 28428 28429 exports.describe.skip = function () { 28430 for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { 28431 args[_key7] = arguments[_key7]; 28432 } 28433 28434 return (currentContext.describe || currentContext.suite).skip.apply(this, args); 28435 }; 28436 28437 exports.it = function () { 28438 for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { 28439 args[_key8] = arguments[_key8]; 28440 } 28441 28442 return (currentContext.it || currentContext.test).apply(this, args); 28443 }; 28444 28445 exports.it.only = function () { 28446 for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { 28447 args[_key9] = arguments[_key9]; 28448 } 28449 28450 return (currentContext.it || currentContext.test).only.apply(this, args); 28451 }; 28452 28453 exports.it.skip = function () { 28454 for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { 28455 args[_key10] = arguments[_key10]; 28456 } 28457 28458 return (currentContext.it || currentContext.test).skip.apply(this, args); 28459 }; 28460 28461 exports.xdescribe = exports.describe.skip; 28462 exports.xit = exports.it.skip; 28463 exports.setup = exports.beforeEach; 28464 exports.suiteSetup = exports.before; 28465 exports.suiteTeardown = exports.after; 28466 exports.suite = exports.describe; 28467 exports.teardown = exports.afterEach; 28468 exports.test = exports.it; 28469 28470 exports.run = function () { 28471 for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { 28472 args[_key11] = arguments[_key11]; 28473 } 28474 28475 return currentContext.run.apply(this, args); 28476 }; 28477 /** 28478 * Constructs a new Mocha instance with `options`. 28479 * 28480 * @public 28481 * @class Mocha 28482 * @param {Object} [options] - Settings object. 28483 * @param {boolean} [options.allowUncaught] - Propagate uncaught errors? 28484 * @param {boolean} [options.asyncOnly] - Force `done` callback or promise? 28485 * @param {boolean} [options.bail] - Bail after first test failure? 28486 * @param {boolean} [options.checkLeaks] - Check for global variable leaks? 28487 * @param {boolean} [options.color] - Color TTY output from reporter? 28488 * @param {boolean} [options.delay] - Delay root suite execution? 28489 * @param {boolean} [options.diff] - Show diff on failure? 28490 * @param {string} [options.fgrep] - Test filter given string. 28491 * @param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite? 28492 * @param {boolean} [options.forbidPending] - Pending tests fail the suite? 28493 * @param {boolean} [options.fullTrace] - Full stacktrace upon failure? 28494 * @param {string[]} [options.global] - Variables expected in global scope. 28495 * @param {RegExp|string} [options.grep] - Test filter given regular expression. 28496 * @param {boolean} [options.growl] - Enable desktop notifications? 28497 * @param {boolean} [options.inlineDiffs] - Display inline diffs? 28498 * @param {boolean} [options.invert] - Invert test filter matches? 28499 * @param {boolean} [options.noHighlighting] - Disable syntax highlighting? 28500 * @param {string|constructor} [options.reporter] - Reporter name or constructor. 28501 * @param {Object} [options.reporterOption] - Reporter settings object. 28502 * @param {number} [options.retries] - Number of times to retry failed tests. 28503 * @param {number} [options.slow] - Slow threshold value. 28504 * @param {number|string} [options.timeout] - Timeout threshold value. 28505 * @param {string} [options.ui] - Interface name. 28506 * @param {boolean} [options.parallel] - Run jobs in parallel 28507 * @param {number} [options.jobs] - Max number of worker processes for parallel runs 28508 * @param {MochaRootHookObject} [options.rootHooks] - Hooks to bootstrap the root 28509 * suite with 28510 * @param {boolean} [options.isWorker] - Should be `true` if `Mocha` process is running in a worker process. 28511 */ 28512 28513 28514 function Mocha() { 28515 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 28516 options = _objectSpread2(_objectSpread2({}, mocharc$2), options); 28517 this.files = []; 28518 this.options = options; // root suite 28519 28520 this.suite = new exports.Suite('', new exports.Context(), true); 28521 this._cleanReferencesAfterRun = true; 28522 this._state = mochaStates.INIT; 28523 this.grep(options.grep).fgrep(options.fgrep).ui(options.ui).reporter(options.reporter, options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter 28524 ).slow(options.slow).global(options.global); // this guard exists because Suite#timeout does not consider `undefined` to be valid input 28525 28526 if (typeof options.timeout !== 'undefined') { 28527 this.timeout(options.timeout === false ? 0 : options.timeout); 28528 } 28529 28530 if ('retries' in options) { 28531 this.retries(options.retries); 28532 } 28533 28534 ['allowUncaught', 'asyncOnly', 'bail', 'checkLeaks', 'color', 'delay', 'diff', 'forbidOnly', 'forbidPending', 'fullTrace', 'growl', 'inlineDiffs', 'invert'].forEach(function (opt) { 28535 if (options[opt]) { 28536 this[opt](); 28537 } 28538 }, this); 28539 28540 if (options.rootHooks) { 28541 this.rootHooks(options.rootHooks); 28542 } 28543 /** 28544 * The class which we'll instantiate in {@link Mocha#run}. Defaults to 28545 * {@link Runner} in serial mode; changes in parallel mode. 28546 * @memberof Mocha 28547 * @private 28548 */ 28549 28550 28551 this._runnerClass = exports.Runner; 28552 /** 28553 * Whether or not to call {@link Mocha#loadFiles} implicitly when calling 28554 * {@link Mocha#run}. If this is `true`, then it's up to the consumer to call 28555 * {@link Mocha#loadFiles} _or_ {@link Mocha#loadFilesAsync}. 28556 * @private 28557 * @memberof Mocha 28558 */ 28559 28560 this._lazyLoadFiles = false; 28561 /** 28562 * It's useful for a Mocha instance to know if it's running in a worker process. 28563 * We could derive this via other means, but it's helpful to have a flag to refer to. 28564 * @memberof Mocha 28565 * @private 28566 */ 28567 28568 this.isWorker = Boolean(options.isWorker); 28569 this.globalSetup(options.globalSetup).globalTeardown(options.globalTeardown).enableGlobalSetup(options.enableGlobalSetup).enableGlobalTeardown(options.enableGlobalTeardown); 28570 28571 if (options.parallel && (typeof options.jobs === 'undefined' || options.jobs > 1)) { 28572 debug('attempting to enable parallel mode'); 28573 this.parallelMode(true); 28574 } 28575 } 28576 /** 28577 * Enables or disables bailing on the first failure. 28578 * 28579 * @public 28580 * @see [CLI option](../#-bail-b) 28581 * @param {boolean} [bail=true] - Whether to bail on first error. 28582 * @returns {Mocha} this 28583 * @chainable 28584 */ 28585 28586 28587 Mocha.prototype.bail = function (bail) { 28588 this.suite.bail(bail !== false); 28589 return this; 28590 }; 28591 /** 28592 * @summary 28593 * Adds `file` to be loaded for execution. 28594 * 28595 * @description 28596 * Useful for generic setup code that must be included within test suite. 28597 * 28598 * @public 28599 * @see [CLI option](../#-file-filedirectoryglob) 28600 * @param {string} file - Pathname of file to be loaded. 28601 * @returns {Mocha} this 28602 * @chainable 28603 */ 28604 28605 28606 Mocha.prototype.addFile = function (file) { 28607 this.files.push(file); 28608 return this; 28609 }; 28610 /** 28611 * Sets reporter to `reporter`, defaults to "spec". 28612 * 28613 * @public 28614 * @see [CLI option](../#-reporter-name-r-name) 28615 * @see [Reporters](../#reporters) 28616 * @param {String|Function} reporterName - Reporter name or constructor. 28617 * @param {Object} [reporterOptions] - Options used to configure the reporter. 28618 * @returns {Mocha} this 28619 * @chainable 28620 * @throws {Error} if requested reporter cannot be loaded 28621 * @example 28622 * 28623 * // Use XUnit reporter and direct its output to file 28624 * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' }); 28625 */ 28626 28627 28628 Mocha.prototype.reporter = function (reporterName, reporterOptions) { 28629 if (typeof reporterName === 'function') { 28630 this._reporter = reporterName; 28631 } else { 28632 reporterName = reporterName || 'spec'; 28633 var reporter; // Try to load a built-in reporter. 28634 28635 if (reporters[reporterName]) { 28636 reporter = reporters[reporterName]; 28637 } // Try to load reporters from process.cwd() and node_modules 28638 28639 28640 if (!reporter) { 28641 try { 28642 reporter = commonjsRequire(reporterName); 28643 } catch (err) { 28644 if (err.code === 'MODULE_NOT_FOUND') { 28645 // Try to load reporters from a path (absolute or relative) 28646 try { 28647 reporter = commonjsRequire(path$1.resolve(utils.cwd(), reporterName)); 28648 } catch (_err) { 28649 _err.code === 'MODULE_NOT_FOUND' ? warn(sQuote(reporterName) + ' reporter not found') : warn(sQuote(reporterName) + ' reporter blew up with error:\n' + err.stack); 28650 } 28651 } else { 28652 warn(sQuote(reporterName) + ' reporter blew up with error:\n' + err.stack); 28653 } 28654 } 28655 } 28656 28657 if (!reporter) { 28658 throw createInvalidReporterError('invalid reporter ' + sQuote(reporterName), reporterName); 28659 } 28660 28661 this._reporter = reporter; 28662 } 28663 28664 this.options.reporterOption = reporterOptions; // alias option name is used in public reporters xunit/tap/progress 28665 28666 this.options.reporterOptions = reporterOptions; 28667 return this; 28668 }; 28669 /** 28670 * Sets test UI `name`, defaults to "bdd". 28671 * 28672 * @public 28673 * @see [CLI option](../#-ui-name-u-name) 28674 * @see [Interface DSLs](../#interfaces) 28675 * @param {string|Function} [ui=bdd] - Interface name or class. 28676 * @returns {Mocha} this 28677 * @chainable 28678 * @throws {Error} if requested interface cannot be loaded 28679 */ 28680 28681 28682 Mocha.prototype.ui = function (ui) { 28683 var bindInterface; 28684 28685 if (typeof ui === 'function') { 28686 bindInterface = ui; 28687 } else { 28688 ui = ui || 'bdd'; 28689 bindInterface = exports.interfaces[ui]; 28690 28691 if (!bindInterface) { 28692 try { 28693 bindInterface = commonjsRequire(ui); 28694 } catch (err) { 28695 throw createInvalidInterfaceError('invalid interface ' + sQuote(ui), ui); 28696 } 28697 } 28698 } 28699 28700 bindInterface(this.suite); 28701 this.suite.on(EVENT_FILE_PRE_REQUIRE, function (context) { 28702 currentContext = context; 28703 }); 28704 return this; 28705 }; 28706 /** 28707 * Loads `files` prior to execution. Does not support ES Modules. 28708 * 28709 * @description 28710 * The implementation relies on Node's `require` to execute 28711 * the test interface functions and will be subject to its cache. 28712 * Supports only CommonJS modules. To load ES modules, use Mocha#loadFilesAsync. 28713 * 28714 * @private 28715 * @see {@link Mocha#addFile} 28716 * @see {@link Mocha#run} 28717 * @see {@link Mocha#unloadFiles} 28718 * @see {@link Mocha#loadFilesAsync} 28719 * @param {Function} [fn] - Callback invoked upon completion. 28720 */ 28721 28722 28723 Mocha.prototype.loadFiles = function (fn) { 28724 var self = this; 28725 var suite = this.suite; 28726 this.files.forEach(function (file) { 28727 file = path$1.resolve(file); 28728 suite.emit(EVENT_FILE_PRE_REQUIRE, commonjsGlobal, file, self); 28729 suite.emit(EVENT_FILE_REQUIRE, commonjsRequire(), file, self); 28730 suite.emit(EVENT_FILE_POST_REQUIRE, commonjsGlobal, file, self); 28731 }); 28732 fn && fn(); 28733 }; 28734 /** 28735 * Loads `files` prior to execution. Supports Node ES Modules. 28736 * 28737 * @description 28738 * The implementation relies on Node's `require` and `import` to execute 28739 * the test interface functions and will be subject to its cache. 28740 * Supports both CJS and ESM modules. 28741 * 28742 * @public 28743 * @see {@link Mocha#addFile} 28744 * @see {@link Mocha#run} 28745 * @see {@link Mocha#unloadFiles} 28746 * @returns {Promise} 28747 * @example 28748 * 28749 * // loads ESM (and CJS) test files asynchronously, then runs root suite 28750 * mocha.loadFilesAsync() 28751 * .then(() => mocha.run(failures => process.exitCode = failures ? 1 : 0)) 28752 * .catch(() => process.exitCode = 1); 28753 */ 28754 28755 28756 Mocha.prototype.loadFilesAsync = function () { 28757 var self = this; 28758 var suite = this.suite; 28759 this.lazyLoadFiles(true); 28760 28761 if (!esmUtils) { 28762 return new Promise(function (resolve) { 28763 self.loadFiles(resolve); 28764 }); 28765 } 28766 28767 return esmUtils.loadFilesAsync(this.files, function (file) { 28768 suite.emit(EVENT_FILE_PRE_REQUIRE, commonjsGlobal, file, self); 28769 }, function (file, resultModule) { 28770 suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self); 28771 suite.emit(EVENT_FILE_POST_REQUIRE, commonjsGlobal, file, self); 28772 }); 28773 }; 28774 /** 28775 * Removes a previously loaded file from Node's `require` cache. 28776 * 28777 * @private 28778 * @static 28779 * @see {@link Mocha#unloadFiles} 28780 * @param {string} file - Pathname of file to be unloaded. 28781 */ 28782 28783 28784 Mocha.unloadFile = function (file) { 28785 if (utils.isBrowser()) { 28786 throw createUnsupportedError('unloadFile() is only suported in a Node.js environment'); 28787 } 28788 28789 return require$$11.unloadFile(file); 28790 }; 28791 /** 28792 * Unloads `files` from Node's `require` cache. 28793 * 28794 * @description 28795 * This allows required files to be "freshly" reloaded, providing the ability 28796 * to reuse a Mocha instance programmatically. 28797 * Note: does not clear ESM module files from the cache 28798 * 28799 * <strong>Intended for consumers — not used internally</strong> 28800 * 28801 * @public 28802 * @see {@link Mocha#run} 28803 * @returns {Mocha} this 28804 * @chainable 28805 */ 28806 28807 28808 Mocha.prototype.unloadFiles = function () { 28809 if (this._state === mochaStates.DISPOSED) { 28810 throw createMochaInstanceAlreadyDisposedError('Mocha instance is already disposed, it cannot be used again.', this._cleanReferencesAfterRun, this); 28811 } 28812 28813 this.files.forEach(function (file) { 28814 Mocha.unloadFile(file); 28815 }); 28816 this._state = mochaStates.INIT; 28817 return this; 28818 }; 28819 /** 28820 * Sets `grep` filter after escaping RegExp special characters. 28821 * 28822 * @public 28823 * @see {@link Mocha#grep} 28824 * @param {string} str - Value to be converted to a regexp. 28825 * @returns {Mocha} this 28826 * @chainable 28827 * @example 28828 * 28829 * // Select tests whose full title begins with `"foo"` followed by a period 28830 * mocha.fgrep('foo.'); 28831 */ 28832 28833 28834 Mocha.prototype.fgrep = function (str) { 28835 if (!str) { 28836 return this; 28837 } 28838 28839 return this.grep(new RegExp(escapeStringRegexp(str))); 28840 }; 28841 /** 28842 * @summary 28843 * Sets `grep` filter used to select specific tests for execution. 28844 * 28845 * @description 28846 * If `re` is a regexp-like string, it will be converted to regexp. 28847 * The regexp is tested against the full title of each test (i.e., the 28848 * name of the test preceded by titles of each its ancestral suites). 28849 * As such, using an <em>exact-match</em> fixed pattern against the 28850 * test name itself will not yield any matches. 28851 * <br> 28852 * <strong>Previous filter value will be overwritten on each call!</strong> 28853 * 28854 * @public 28855 * @see [CLI option](../#-grep-regexp-g-regexp) 28856 * @see {@link Mocha#fgrep} 28857 * @see {@link Mocha#invert} 28858 * @param {RegExp|String} re - Regular expression used to select tests. 28859 * @return {Mocha} this 28860 * @chainable 28861 * @example 28862 * 28863 * // Select tests whose full title contains `"match"`, ignoring case 28864 * mocha.grep(/match/i); 28865 * @example 28866 * 28867 * // Same as above but with regexp-like string argument 28868 * mocha.grep('/match/i'); 28869 * @example 28870 * 28871 * // ## Anti-example 28872 * // Given embedded test `it('only-this-test')`... 28873 * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this! 28874 */ 28875 28876 28877 Mocha.prototype.grep = function (re) { 28878 if (utils.isString(re)) { 28879 // extract args if it's regex-like, i.e: [string, pattern, flag] 28880 var arg = re.match(/^\/(.*)\/(g|i|)$|.*/); 28881 this.options.grep = new RegExp(arg[1] || arg[0], arg[2]); 28882 } else { 28883 this.options.grep = re; 28884 } 28885 28886 return this; 28887 }; 28888 /** 28889 * Inverts `grep` matches. 28890 * 28891 * @public 28892 * @see {@link Mocha#grep} 28893 * @return {Mocha} this 28894 * @chainable 28895 * @example 28896 * 28897 * // Select tests whose full title does *not* contain `"match"`, ignoring case 28898 * mocha.grep(/match/i).invert(); 28899 */ 28900 28901 28902 Mocha.prototype.invert = function () { 28903 this.options.invert = true; 28904 return this; 28905 }; 28906 /** 28907 * Enables or disables checking for global variables leaked while running tests. 28908 * 28909 * @public 28910 * @see [CLI option](../#-check-leaks) 28911 * @param {boolean} [checkLeaks=true] - Whether to check for global variable leaks. 28912 * @return {Mocha} this 28913 * @chainable 28914 */ 28915 28916 28917 Mocha.prototype.checkLeaks = function (checkLeaks) { 28918 this.options.checkLeaks = checkLeaks !== false; 28919 return this; 28920 }; 28921 /** 28922 * Enables or disables whether or not to dispose after each test run. 28923 * Disable this to ensure you can run the test suite multiple times. 28924 * If disabled, be sure to dispose mocha when you're done to prevent memory leaks. 28925 * @public 28926 * @see {@link Mocha#dispose} 28927 * @param {boolean} cleanReferencesAfterRun 28928 * @return {Mocha} this 28929 * @chainable 28930 */ 28931 28932 28933 Mocha.prototype.cleanReferencesAfterRun = function (cleanReferencesAfterRun) { 28934 this._cleanReferencesAfterRun = cleanReferencesAfterRun !== false; 28935 return this; 28936 }; 28937 /** 28938 * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests. 28939 * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector. 28940 * @public 28941 */ 28942 28943 28944 Mocha.prototype.dispose = function () { 28945 if (this._state === mochaStates.RUNNING) { 28946 throw createMochaInstanceAlreadyRunningError('Cannot dispose while the mocha instance is still running tests.'); 28947 } 28948 28949 this.unloadFiles(); 28950 this._previousRunner && this._previousRunner.dispose(); 28951 this.suite.dispose(); 28952 this._state = mochaStates.DISPOSED; 28953 }; 28954 /** 28955 * Displays full stack trace upon test failure. 28956 * 28957 * @public 28958 * @see [CLI option](../#-full-trace) 28959 * @param {boolean} [fullTrace=true] - Whether to print full stacktrace upon failure. 28960 * @return {Mocha} this 28961 * @chainable 28962 */ 28963 28964 28965 Mocha.prototype.fullTrace = function (fullTrace) { 28966 this.options.fullTrace = fullTrace !== false; 28967 return this; 28968 }; 28969 /** 28970 * Enables desktop notification support if prerequisite software installed. 28971 * 28972 * @public 28973 * @see [CLI option](../#-growl-g) 28974 * @return {Mocha} this 28975 * @chainable 28976 */ 28977 28978 28979 Mocha.prototype.growl = function () { 28980 this.options.growl = this.isGrowlCapable(); 28981 28982 if (!this.options.growl) { 28983 var detail = utils.isBrowser() ? 'notification support not available in this browser...' : 'notification support prerequisites not installed...'; 28984 console.error(detail + ' cannot enable!'); 28985 } 28986 28987 return this; 28988 }; 28989 /** 28990 * @summary 28991 * Determines if Growl support seems likely. 28992 * 28993 * @description 28994 * <strong>Not available when run in browser.</strong> 28995 * 28996 * @private 28997 * @see {@link Growl#isCapable} 28998 * @see {@link Mocha#growl} 28999 * @return {boolean} whether Growl support can be expected 29000 */ 29001 29002 29003 Mocha.prototype.isGrowlCapable = growl.isCapable; 29004 /** 29005 * Implements desktop notifications using a pseudo-reporter. 29006 * 29007 * @private 29008 * @see {@link Mocha#growl} 29009 * @see {@link Growl#notify} 29010 * @param {Runner} runner - Runner instance. 29011 */ 29012 29013 Mocha.prototype._growl = growl.notify; 29014 /** 29015 * Specifies whitelist of variable names to be expected in global scope. 29016 * 29017 * @public 29018 * @see [CLI option](../#-global-variable-name) 29019 * @see {@link Mocha#checkLeaks} 29020 * @param {String[]|String} global - Accepted global variable name(s). 29021 * @return {Mocha} this 29022 * @chainable 29023 * @example 29024 * 29025 * // Specify variables to be expected in global scope 29026 * mocha.global(['jQuery', 'MyLib']); 29027 */ 29028 29029 Mocha.prototype.global = function (global) { 29030 this.options.global = (this.options.global || []).concat(global).filter(Boolean).filter(function (elt, idx, arr) { 29031 return arr.indexOf(elt) === idx; 29032 }); 29033 return this; 29034 }; // for backwards compability, 'globals' is an alias of 'global' 29035 29036 29037 Mocha.prototype.globals = Mocha.prototype.global; 29038 /** 29039 * Enables or disables TTY color output by screen-oriented reporters. 29040 * 29041 * @public 29042 * @see [CLI option](../#-color-c-colors) 29043 * @param {boolean} [color=true] - Whether to enable color output. 29044 * @return {Mocha} this 29045 * @chainable 29046 */ 29047 29048 Mocha.prototype.color = function (color) { 29049 this.options.color = color !== false; 29050 return this; 29051 }; 29052 /** 29053 * Enables or disables reporter to use inline diffs (rather than +/-) 29054 * in test failure output. 29055 * 29056 * @public 29057 * @see [CLI option](../#-inline-diffs) 29058 * @param {boolean} [inlineDiffs=true] - Whether to use inline diffs. 29059 * @return {Mocha} this 29060 * @chainable 29061 */ 29062 29063 29064 Mocha.prototype.inlineDiffs = function (inlineDiffs) { 29065 this.options.inlineDiffs = inlineDiffs !== false; 29066 return this; 29067 }; 29068 /** 29069 * Enables or disables reporter to include diff in test failure output. 29070 * 29071 * @public 29072 * @see [CLI option](../#-diff) 29073 * @param {boolean} [diff=true] - Whether to show diff on failure. 29074 * @return {Mocha} this 29075 * @chainable 29076 */ 29077 29078 29079 Mocha.prototype.diff = function (diff) { 29080 this.options.diff = diff !== false; 29081 return this; 29082 }; 29083 /** 29084 * @summary 29085 * Sets timeout threshold value. 29086 * 29087 * @description 29088 * A string argument can use shorthand (such as "2s") and will be converted. 29089 * If the value is `0`, timeouts will be disabled. 29090 * 29091 * @public 29092 * @see [CLI option](../#-timeout-ms-t-ms) 29093 * @see [Timeouts](../#timeouts) 29094 * @param {number|string} msecs - Timeout threshold value. 29095 * @return {Mocha} this 29096 * @chainable 29097 * @example 29098 * 29099 * // Sets timeout to one second 29100 * mocha.timeout(1000); 29101 * @example 29102 * 29103 * // Same as above but using string argument 29104 * mocha.timeout('1s'); 29105 */ 29106 29107 29108 Mocha.prototype.timeout = function (msecs) { 29109 this.suite.timeout(msecs); 29110 return this; 29111 }; 29112 /** 29113 * Sets the number of times to retry failed tests. 29114 * 29115 * @public 29116 * @see [CLI option](../#-retries-n) 29117 * @see [Retry Tests](../#retry-tests) 29118 * @param {number} retry - Number of times to retry failed tests. 29119 * @return {Mocha} this 29120 * @chainable 29121 * @example 29122 * 29123 * // Allow any failed test to retry one more time 29124 * mocha.retries(1); 29125 */ 29126 29127 29128 Mocha.prototype.retries = function (retry) { 29129 this.suite.retries(retry); 29130 return this; 29131 }; 29132 /** 29133 * Sets slowness threshold value. 29134 * 29135 * @public 29136 * @see [CLI option](../#-slow-ms-s-ms) 29137 * @param {number} msecs - Slowness threshold value. 29138 * @return {Mocha} this 29139 * @chainable 29140 * @example 29141 * 29142 * // Sets "slow" threshold to half a second 29143 * mocha.slow(500); 29144 * @example 29145 * 29146 * // Same as above but using string argument 29147 * mocha.slow('0.5s'); 29148 */ 29149 29150 29151 Mocha.prototype.slow = function (msecs) { 29152 this.suite.slow(msecs); 29153 return this; 29154 }; 29155 /** 29156 * Forces all tests to either accept a `done` callback or return a promise. 29157 * 29158 * @public 29159 * @see [CLI option](../#-async-only-a) 29160 * @param {boolean} [asyncOnly=true] - Whether to force `done` callback or promise. 29161 * @return {Mocha} this 29162 * @chainable 29163 */ 29164 29165 29166 Mocha.prototype.asyncOnly = function (asyncOnly) { 29167 this.options.asyncOnly = asyncOnly !== false; 29168 return this; 29169 }; 29170 /** 29171 * Disables syntax highlighting (in browser). 29172 * 29173 * @public 29174 * @return {Mocha} this 29175 * @chainable 29176 */ 29177 29178 29179 Mocha.prototype.noHighlighting = function () { 29180 this.options.noHighlighting = true; 29181 return this; 29182 }; 29183 /** 29184 * Enables or disables uncaught errors to propagate. 29185 * 29186 * @public 29187 * @see [CLI option](../#-allow-uncaught) 29188 * @param {boolean} [allowUncaught=true] - Whether to propagate uncaught errors. 29189 * @return {Mocha} this 29190 * @chainable 29191 */ 29192 29193 29194 Mocha.prototype.allowUncaught = function (allowUncaught) { 29195 this.options.allowUncaught = allowUncaught !== false; 29196 return this; 29197 }; 29198 /** 29199 * @summary 29200 * Delays root suite execution. 29201 * 29202 * @description 29203 * Used to perform async operations before any suites are run. 29204 * 29205 * @public 29206 * @see [delayed root suite](../#delayed-root-suite) 29207 * @returns {Mocha} this 29208 * @chainable 29209 */ 29210 29211 29212 Mocha.prototype.delay = function delay() { 29213 this.options.delay = true; 29214 return this; 29215 }; 29216 /** 29217 * Causes tests marked `only` to fail the suite. 29218 * 29219 * @public 29220 * @see [CLI option](../#-forbid-only) 29221 * @param {boolean} [forbidOnly=true] - Whether tests marked `only` fail the suite. 29222 * @returns {Mocha} this 29223 * @chainable 29224 */ 29225 29226 29227 Mocha.prototype.forbidOnly = function (forbidOnly) { 29228 this.options.forbidOnly = forbidOnly !== false; 29229 return this; 29230 }; 29231 /** 29232 * Causes pending tests and tests marked `skip` to fail the suite. 29233 * 29234 * @public 29235 * @see [CLI option](../#-forbid-pending) 29236 * @param {boolean} [forbidPending=true] - Whether pending tests fail the suite. 29237 * @returns {Mocha} this 29238 * @chainable 29239 */ 29240 29241 29242 Mocha.prototype.forbidPending = function (forbidPending) { 29243 this.options.forbidPending = forbidPending !== false; 29244 return this; 29245 }; 29246 /** 29247 * Throws an error if mocha is in the wrong state to be able to transition to a "running" state. 29248 * @private 29249 */ 29250 29251 29252 Mocha.prototype._guardRunningStateTransition = function () { 29253 if (this._state === mochaStates.RUNNING) { 29254 throw createMochaInstanceAlreadyRunningError('Mocha instance is currently running tests, cannot start a next test run until this one is done', this); 29255 } 29256 29257 if (this._state === mochaStates.DISPOSED || this._state === mochaStates.REFERENCES_CLEANED) { 29258 throw createMochaInstanceAlreadyDisposedError('Mocha instance is already disposed, cannot start a new test run. Please create a new mocha instance. Be sure to set disable `cleanReferencesAfterRun` when you want to reuse the same mocha instance for multiple test runs.', this._cleanReferencesAfterRun, this); 29259 } 29260 }; 29261 /** 29262 * Mocha version as specified by "package.json". 29263 * 29264 * @name Mocha#version 29265 * @type string 29266 * @readonly 29267 */ 29268 29269 29270 Object.defineProperty(Mocha.prototype, 'version', { 29271 value: require$$10.version, 29272 configurable: false, 29273 enumerable: true, 29274 writable: false 29275 }); 29276 /** 29277 * Callback to be invoked when test execution is complete. 29278 * 29279 * @private 29280 * @callback DoneCB 29281 * @param {number} failures - Number of failures that occurred. 29282 */ 29283 29284 /** 29285 * Runs root suite and invokes `fn()` when complete. 29286 * 29287 * @description 29288 * To run tests multiple times (or to run tests in files that are 29289 * already in the `require` cache), make sure to clear them from 29290 * the cache first! 29291 * 29292 * @public 29293 * @see {@link Mocha#unloadFiles} 29294 * @see {@link Runner#run} 29295 * @param {DoneCB} [fn] - Callback invoked when test execution completed. 29296 * @returns {Runner} runner instance 29297 * @example 29298 * 29299 * // exit with non-zero status if there were test failures 29300 * mocha.run(failures => process.exitCode = failures ? 1 : 0); 29301 */ 29302 29303 Mocha.prototype.run = function (fn) { 29304 var _this = this; 29305 29306 this._guardRunningStateTransition(); 29307 29308 this._state = mochaStates.RUNNING; 29309 29310 if (this._previousRunner) { 29311 this._previousRunner.dispose(); 29312 29313 this.suite.reset(); 29314 } 29315 29316 if (this.files.length && !this._lazyLoadFiles) { 29317 this.loadFiles(); 29318 } 29319 29320 var suite = this.suite; 29321 var options = this.options; 29322 options.files = this.files; 29323 var runner = new this._runnerClass(suite, { 29324 delay: options.delay, 29325 cleanReferencesAfterRun: this._cleanReferencesAfterRun 29326 }); 29327 statsCollector(runner); 29328 var reporter = new this._reporter(runner, options); 29329 runner.checkLeaks = options.checkLeaks === true; 29330 runner.fullStackTrace = options.fullTrace; 29331 runner.asyncOnly = options.asyncOnly; 29332 runner.allowUncaught = options.allowUncaught; 29333 runner.forbidOnly = options.forbidOnly; 29334 runner.forbidPending = options.forbidPending; 29335 29336 if (options.grep) { 29337 runner.grep(options.grep, options.invert); 29338 } 29339 29340 if (options.global) { 29341 runner.globals(options.global); 29342 } 29343 29344 if (options.growl) { 29345 this._growl(runner); 29346 } 29347 29348 if (options.color !== undefined) { 29349 exports.reporters.Base.useColors = options.color; 29350 } 29351 29352 exports.reporters.Base.inlineDiffs = options.inlineDiffs; 29353 exports.reporters.Base.hideDiff = !options.diff; 29354 29355 var done = function done(failures) { 29356 _this._previousRunner = runner; 29357 _this._state = _this._cleanReferencesAfterRun ? mochaStates.REFERENCES_CLEANED : mochaStates.INIT; 29358 fn = fn || utils.noop; 29359 29360 if (typeof reporter.done === 'function') { 29361 reporter.done(failures, fn); 29362 } else { 29363 fn(failures); 29364 } 29365 }; 29366 29367 var runAsync = /*#__PURE__*/function () { 29368 var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(runner) { 29369 var context, failureCount; 29370 return regeneratorRuntime.wrap(function _callee$(_context) { 29371 while (1) { 29372 switch (_context.prev = _context.next) { 29373 case 0: 29374 if (!(_this.options.enableGlobalSetup && _this.hasGlobalSetupFixtures())) { 29375 _context.next = 6; 29376 break; 29377 } 29378 29379 _context.next = 3; 29380 return _this.runGlobalSetup(runner); 29381 29382 case 3: 29383 _context.t0 = _context.sent; 29384 _context.next = 7; 29385 break; 29386 29387 case 6: 29388 _context.t0 = {}; 29389 29390 case 7: 29391 context = _context.t0; 29392 _context.next = 10; 29393 return runner.runAsync({ 29394 files: _this.files, 29395 options: options 29396 }); 29397 29398 case 10: 29399 failureCount = _context.sent; 29400 29401 if (!(_this.options.enableGlobalTeardown && _this.hasGlobalTeardownFixtures())) { 29402 _context.next = 14; 29403 break; 29404 } 29405 29406 _context.next = 14; 29407 return _this.runGlobalTeardown(runner, { 29408 context: context 29409 }); 29410 29411 case 14: 29412 return _context.abrupt("return", failureCount); 29413 29414 case 15: 29415 case "end": 29416 return _context.stop(); 29417 } 29418 } 29419 }, _callee); 29420 })); 29421 29422 return function runAsync(_x) { 29423 return _ref.apply(this, arguments); 29424 }; 29425 }(); // no "catch" here is intentional. errors coming out of 29426 // Runner#run are considered uncaught/unhandled and caught 29427 // by the `process` event listeners. 29428 // also: returning anything other than `runner` would be a breaking 29429 // change 29430 29431 29432 runAsync(runner).then(done); 29433 return runner; 29434 }; 29435 /** 29436 * Assigns hooks to the root suite 29437 * @param {MochaRootHookObject} [hooks] - Hooks to assign to root suite 29438 * @chainable 29439 */ 29440 29441 29442 Mocha.prototype.rootHooks = function rootHooks() { 29443 var _this2 = this; 29444 29445 var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, 29446 _ref2$beforeAll = _ref2.beforeAll, 29447 beforeAll = _ref2$beforeAll === void 0 ? [] : _ref2$beforeAll, 29448 _ref2$beforeEach = _ref2.beforeEach, 29449 beforeEach = _ref2$beforeEach === void 0 ? [] : _ref2$beforeEach, 29450 _ref2$afterAll = _ref2.afterAll, 29451 afterAll = _ref2$afterAll === void 0 ? [] : _ref2$afterAll, 29452 _ref2$afterEach = _ref2.afterEach, 29453 afterEach = _ref2$afterEach === void 0 ? [] : _ref2$afterEach; 29454 29455 beforeAll = utils.castArray(beforeAll); 29456 beforeEach = utils.castArray(beforeEach); 29457 afterAll = utils.castArray(afterAll); 29458 afterEach = utils.castArray(afterEach); 29459 beforeAll.forEach(function (hook) { 29460 _this2.suite.beforeAll(hook); 29461 }); 29462 beforeEach.forEach(function (hook) { 29463 _this2.suite.beforeEach(hook); 29464 }); 29465 afterAll.forEach(function (hook) { 29466 _this2.suite.afterAll(hook); 29467 }); 29468 afterEach.forEach(function (hook) { 29469 _this2.suite.afterEach(hook); 29470 }); 29471 return this; 29472 }; 29473 /** 29474 * Toggles parallel mode. 29475 * 29476 * Must be run before calling {@link Mocha#run}. Changes the `Runner` class to 29477 * use; also enables lazy file loading if not already done so. 29478 * 29479 * Warning: when passed `false` and lazy loading has been enabled _via any means_ (including calling `parallelMode(true)`), this method will _not_ disable lazy loading. Lazy loading is a prerequisite for parallel 29480 * mode, but parallel mode is _not_ a prerequisite for lazy loading! 29481 * @param {boolean} [enable] - If `true`, enable; otherwise disable. 29482 * @throws If run in browser 29483 * @throws If Mocha not in `INIT` state 29484 * @returns {Mocha} 29485 * @chainable 29486 * @public 29487 */ 29488 29489 29490 Mocha.prototype.parallelMode = function parallelMode() { 29491 var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 29492 29493 if (utils.isBrowser()) { 29494 throw createUnsupportedError('parallel mode is only supported in Node.js'); 29495 } 29496 29497 var parallel = Boolean(enable); 29498 29499 if (parallel === this.options.parallel && this._lazyLoadFiles && this._runnerClass !== exports.Runner) { 29500 return this; 29501 } 29502 29503 if (this._state !== mochaStates.INIT) { 29504 throw createUnsupportedError('cannot change parallel mode after having called run()'); 29505 } 29506 29507 this.options.parallel = parallel; // swap Runner class 29508 29509 this._runnerClass = parallel ? require$$11 : exports.Runner; // lazyLoadFiles may have been set `true` otherwise (for ESM loading), 29510 // so keep `true` if so. 29511 29512 return this.lazyLoadFiles(this._lazyLoadFiles || parallel); 29513 }; 29514 /** 29515 * Disables implicit call to {@link Mocha#loadFiles} in {@link Mocha#run}. This 29516 * setting is used by watch mode, parallel mode, and for loading ESM files. 29517 * @todo This should throw if we've already loaded files; such behavior 29518 * necessitates adding a new state. 29519 * @param {boolean} [enable] - If `true`, disable eager loading of files in 29520 * {@link Mocha#run} 29521 * @chainable 29522 * @public 29523 */ 29524 29525 29526 Mocha.prototype.lazyLoadFiles = function lazyLoadFiles(enable) { 29527 this._lazyLoadFiles = enable === true; 29528 debug('set lazy load to %s', enable); 29529 return this; 29530 }; 29531 /** 29532 * Configures one or more global setup fixtures. 29533 * 29534 * If given no parameters, _unsets_ any previously-set fixtures. 29535 * @chainable 29536 * @public 29537 * @param {MochaGlobalFixture|MochaGlobalFixture[]} [setupFns] - Global setup fixture(s) 29538 * @returns {Mocha} 29539 */ 29540 29541 29542 Mocha.prototype.globalSetup = function globalSetup() { 29543 var setupFns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 29544 setupFns = utils.castArray(setupFns); 29545 this.options.globalSetup = setupFns; 29546 debug('configured %d global setup functions', setupFns.length); 29547 return this; 29548 }; 29549 /** 29550 * Configures one or more global teardown fixtures. 29551 * 29552 * If given no parameters, _unsets_ any previously-set fixtures. 29553 * @chainable 29554 * @public 29555 * @param {MochaGlobalFixture|MochaGlobalFixture[]} [teardownFns] - Global teardown fixture(s) 29556 * @returns {Mocha} 29557 */ 29558 29559 29560 Mocha.prototype.globalTeardown = function globalTeardown() { 29561 var teardownFns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 29562 teardownFns = utils.castArray(teardownFns); 29563 this.options.globalTeardown = teardownFns; 29564 debug('configured %d global teardown functions', teardownFns.length); 29565 return this; 29566 }; 29567 /** 29568 * Run any global setup fixtures sequentially, if any. 29569 * 29570 * This is _automatically called_ by {@link Mocha#run} _unless_ the `runGlobalSetup` option is `false`; see {@link Mocha#enableGlobalSetup}. 29571 * 29572 * The context object this function resolves with should be consumed by {@link Mocha#runGlobalTeardown}. 29573 * @param {object} [context] - Context object if already have one 29574 * @public 29575 * @returns {Promise<object>} Context object 29576 */ 29577 29578 29579 Mocha.prototype.runGlobalSetup = /*#__PURE__*/function () { 29580 var _runGlobalSetup = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { 29581 var context, 29582 globalSetup, 29583 _args2 = arguments; 29584 return regeneratorRuntime.wrap(function _callee2$(_context2) { 29585 while (1) { 29586 switch (_context2.prev = _context2.next) { 29587 case 0: 29588 context = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}; 29589 globalSetup = this.options.globalSetup; 29590 29591 if (!(globalSetup && globalSetup.length)) { 29592 _context2.next = 7; 29593 break; 29594 } 29595 29596 debug('run(): global setup starting'); 29597 _context2.next = 6; 29598 return this._runGlobalFixtures(globalSetup, context); 29599 29600 case 6: 29601 debug('run(): global setup complete'); 29602 29603 case 7: 29604 return _context2.abrupt("return", context); 29605 29606 case 8: 29607 case "end": 29608 return _context2.stop(); 29609 } 29610 } 29611 }, _callee2, this); 29612 })); 29613 29614 function runGlobalSetup() { 29615 return _runGlobalSetup.apply(this, arguments); 29616 } 29617 29618 return runGlobalSetup; 29619 }(); 29620 /** 29621 * Run any global teardown fixtures sequentially, if any. 29622 * 29623 * This is _automatically called_ by {@link Mocha#run} _unless_ the `runGlobalTeardown` option is `false`; see {@link Mocha#enableGlobalTeardown}. 29624 * 29625 * Should be called with context object returned by {@link Mocha#runGlobalSetup}, if applicable. 29626 * @param {object} [context] - Context object if already have one 29627 * @public 29628 * @returns {Promise<object>} Context object 29629 */ 29630 29631 29632 Mocha.prototype.runGlobalTeardown = /*#__PURE__*/function () { 29633 var _runGlobalTeardown = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { 29634 var context, 29635 globalTeardown, 29636 _args3 = arguments; 29637 return regeneratorRuntime.wrap(function _callee3$(_context3) { 29638 while (1) { 29639 switch (_context3.prev = _context3.next) { 29640 case 0: 29641 context = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}; 29642 globalTeardown = this.options.globalTeardown; 29643 29644 if (!(globalTeardown && globalTeardown.length)) { 29645 _context3.next = 6; 29646 break; 29647 } 29648 29649 debug('run(): global teardown starting'); 29650 _context3.next = 6; 29651 return this._runGlobalFixtures(globalTeardown, context); 29652 29653 case 6: 29654 debug('run(): global teardown complete'); 29655 return _context3.abrupt("return", context); 29656 29657 case 8: 29658 case "end": 29659 return _context3.stop(); 29660 } 29661 } 29662 }, _callee3, this); 29663 })); 29664 29665 function runGlobalTeardown() { 29666 return _runGlobalTeardown.apply(this, arguments); 29667 } 29668 29669 return runGlobalTeardown; 29670 }(); 29671 /** 29672 * Run global fixtures sequentially with context `context` 29673 * @private 29674 * @param {MochaGlobalFixture[]} [fixtureFns] - Fixtures to run 29675 * @param {object} [context] - context object 29676 * @returns {Promise<object>} context object 29677 */ 29678 29679 29680 Mocha.prototype._runGlobalFixtures = /*#__PURE__*/function () { 29681 var _runGlobalFixtures2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { 29682 var fixtureFns, 29683 context, 29684 _iteratorNormalCompletion, 29685 _didIteratorError, 29686 _iteratorError, 29687 _iterator, 29688 _step, 29689 _value, 29690 fixtureFn, 29691 _args4 = arguments; 29692 29693 return regeneratorRuntime.wrap(function _callee4$(_context4) { 29694 while (1) { 29695 switch (_context4.prev = _context4.next) { 29696 case 0: 29697 fixtureFns = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : []; 29698 context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}; 29699 _iteratorNormalCompletion = true; 29700 _didIteratorError = false; 29701 _context4.prev = 4; 29702 _iterator = _asyncIterator(fixtureFns); 29703 29704 case 6: 29705 _context4.next = 8; 29706 return _iterator.next(); 29707 29708 case 8: 29709 _step = _context4.sent; 29710 _iteratorNormalCompletion = _step.done; 29711 _context4.next = 12; 29712 return _step.value; 29713 29714 case 12: 29715 _value = _context4.sent; 29716 29717 if (_iteratorNormalCompletion) { 29718 _context4.next = 20; 29719 break; 29720 } 29721 29722 fixtureFn = _value; 29723 _context4.next = 17; 29724 return fixtureFn.call(context); 29725 29726 case 17: 29727 _iteratorNormalCompletion = true; 29728 _context4.next = 6; 29729 break; 29730 29731 case 20: 29732 _context4.next = 26; 29733 break; 29734 29735 case 22: 29736 _context4.prev = 22; 29737 _context4.t0 = _context4["catch"](4); 29738 _didIteratorError = true; 29739 _iteratorError = _context4.t0; 29740 29741 case 26: 29742 _context4.prev = 26; 29743 _context4.prev = 27; 29744 29745 if (!(!_iteratorNormalCompletion && _iterator["return"] != null)) { 29746 _context4.next = 31; 29747 break; 29748 } 29749 29750 _context4.next = 31; 29751 return _iterator["return"](); 29752 29753 case 31: 29754 _context4.prev = 31; 29755 29756 if (!_didIteratorError) { 29757 _context4.next = 34; 29758 break; 29759 } 29760 29761 throw _iteratorError; 29762 29763 case 34: 29764 return _context4.finish(31); 29765 29766 case 35: 29767 return _context4.finish(26); 29768 29769 case 36: 29770 return _context4.abrupt("return", context); 29771 29772 case 37: 29773 case "end": 29774 return _context4.stop(); 29775 } 29776 } 29777 }, _callee4, null, [[4, 22, 26, 36], [27,, 31, 35]]); 29778 })); 29779 29780 function _runGlobalFixtures() { 29781 return _runGlobalFixtures2.apply(this, arguments); 29782 } 29783 29784 return _runGlobalFixtures; 29785 }(); 29786 /** 29787 * Toggle execution of any global setup fixture(s) 29788 * 29789 * @chainable 29790 * @public 29791 * @param {boolean } [enabled=true] - If `false`, do not run global setup fixture 29792 * @returns {Mocha} 29793 */ 29794 29795 29796 Mocha.prototype.enableGlobalSetup = function enableGlobalSetup() { 29797 var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 29798 this.options.enableGlobalSetup = Boolean(enabled); 29799 return this; 29800 }; 29801 /** 29802 * Toggle execution of any global teardown fixture(s) 29803 * 29804 * @chainable 29805 * @public 29806 * @param {boolean } [enabled=true] - If `false`, do not run global teardown fixture 29807 * @returns {Mocha} 29808 */ 29809 29810 29811 Mocha.prototype.enableGlobalTeardown = function enableGlobalTeardown() { 29812 var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 29813 this.options.enableGlobalTeardown = Boolean(enabled); 29814 return this; 29815 }; 29816 /** 29817 * Returns `true` if one or more global setup fixtures have been supplied. 29818 * @public 29819 * @returns {boolean} 29820 */ 29821 29822 29823 Mocha.prototype.hasGlobalSetupFixtures = function hasGlobalSetupFixtures() { 29824 return Boolean(this.options.globalSetup.length); 29825 }; 29826 /** 29827 * Returns `true` if one or more global teardown fixtures have been supplied. 29828 * @public 29829 * @returns {boolean} 29830 */ 29831 29832 29833 Mocha.prototype.hasGlobalTeardownFixtures = function hasGlobalTeardownFixtures() { 29834 return Boolean(this.options.globalTeardown.length); 29835 }; 29836 /** 29837 * An alternative way to define root hooks that works with parallel runs. 29838 * @typedef {Object} MochaRootHookObject 29839 * @property {Function|Function[]} [beforeAll] - "Before all" hook(s) 29840 * @property {Function|Function[]} [beforeEach] - "Before each" hook(s) 29841 * @property {Function|Function[]} [afterAll] - "After all" hook(s) 29842 * @property {Function|Function[]} [afterEach] - "After each" hook(s) 29843 */ 29844 29845 /** 29846 * An function that returns a {@link MochaRootHookObject}, either sync or async. 29847 @callback MochaRootHookFunction 29848 * @returns {MochaRootHookObject|Promise<MochaRootHookObject>} 29849 */ 29850 29851 /** 29852 * A function that's invoked _once_ which is either sync or async. 29853 * Can be a "teardown" or "setup". These will all share the same context. 29854 * @callback MochaGlobalFixture 29855 * @returns {void|Promise<void>} 29856 */ 29857 29858 /** 29859 * An object making up all necessary parts of a plugin loader and aggregator 29860 * @typedef {Object} PluginDefinition 29861 * @property {string} exportName - Named export to use 29862 * @property {string} [optionName] - Option name for Mocha constructor (use `exportName` if omitted) 29863 * @property {PluginValidator} [validate] - Validator function 29864 * @property {PluginFinalizer} [finalize] - Finalizer/aggregator function 29865 */ 29866 29867 /** 29868 * A (sync) function to assert a user-supplied plugin implementation is valid. 29869 * 29870 * Defined in a {@link PluginDefinition}. 29871 29872 * @callback PluginValidator 29873 * @param {*} value - Value to check 29874 * @this {PluginDefinition} 29875 * @returns {void} 29876 */ 29877 29878 /** 29879 * A function to finalize plugins impls of a particular ilk 29880 * @callback PluginFinalizer 29881 * @param {Array<*>} impls - User-supplied implementations 29882 * @returns {Promise<*>|*} 29883 */ 29884 29885 }); 29886 29887 /* eslint no-unused-vars: off */ 29888 29889 /* eslint-env commonjs */ 29890 29891 /** 29892 * Shim process.stdout. 29893 */ 29894 29895 29896 process$1.stdout = browserStdout({ 29897 label: false 29898 }); 29899 /** 29900 * Create a Mocha instance. 29901 * 29902 * @return {undefined} 29903 */ 29904 29905 var mocha$1 = new mocha({ 29906 reporter: 'html' 29907 }); 29908 /** 29909 * Save timer references to avoid Sinon interfering (see GH-237). 29910 */ 29911 29912 var Date$4 = commonjsGlobal.Date; 29913 var setTimeout$3 = commonjsGlobal.setTimeout; 29914 var uncaughtExceptionHandlers = []; 29915 var originalOnerrorHandler = commonjsGlobal.onerror; 29916 /** 29917 * Remove uncaughtException listener. 29918 * Revert to original onerror handler if previously defined. 29919 */ 29920 29921 process$1.removeListener = function (e, fn) { 29922 if (e === 'uncaughtException') { 29923 if (originalOnerrorHandler) { 29924 commonjsGlobal.onerror = originalOnerrorHandler; 29925 } else { 29926 commonjsGlobal.onerror = function () {}; 29927 } 29928 29929 var i = uncaughtExceptionHandlers.indexOf(fn); 29930 29931 if (i !== -1) { 29932 uncaughtExceptionHandlers.splice(i, 1); 29933 } 29934 } 29935 }; 29936 /** 29937 * Implements listenerCount for 'uncaughtException'. 29938 */ 29939 29940 29941 process$1.listenerCount = function (name) { 29942 if (name === 'uncaughtException') { 29943 return uncaughtExceptionHandlers.length; 29944 } 29945 29946 return 0; 29947 }; 29948 /** 29949 * Implements uncaughtException listener. 29950 */ 29951 29952 29953 process$1.on = function (e, fn) { 29954 if (e === 'uncaughtException') { 29955 commonjsGlobal.onerror = function (err, url, line) { 29956 fn(new Error(err + ' (' + url + ':' + line + ')')); 29957 return !mocha$1.options.allowUncaught; 29958 }; 29959 29960 uncaughtExceptionHandlers.push(fn); 29961 } 29962 }; 29963 29964 process$1.listeners = function (e) { 29965 if (e === 'uncaughtException') { 29966 return uncaughtExceptionHandlers; 29967 } 29968 29969 return []; 29970 }; // The BDD UI is registered by default, but no UI will be functional in the 29971 // browser without an explicit call to the overridden `mocha.ui` (see below). 29972 // Ensure that this default UI does not expose its methods to the global scope. 29973 29974 29975 mocha$1.suite.removeAllListeners('pre-require'); 29976 var immediateQueue = []; 29977 var immediateTimeout; 29978 29979 function timeslice() { 29980 var immediateStart = new Date$4().getTime(); 29981 29982 while (immediateQueue.length && new Date$4().getTime() - immediateStart < 100) { 29983 immediateQueue.shift()(); 29984 } 29985 29986 if (immediateQueue.length) { 29987 immediateTimeout = setTimeout$3(timeslice, 0); 29988 } else { 29989 immediateTimeout = null; 29990 } 29991 } 29992 /** 29993 * High-performance override of Runner.immediately. 29994 */ 29995 29996 29997 mocha.Runner.immediately = function (callback) { 29998 immediateQueue.push(callback); 29999 30000 if (!immediateTimeout) { 30001 immediateTimeout = setTimeout$3(timeslice, 0); 30002 } 30003 }; 30004 /** 30005 * Function to allow assertion libraries to throw errors directly into mocha. 30006 * This is useful when running tests in a browser because window.onerror will 30007 * only receive the 'message' attribute of the Error. 30008 */ 30009 30010 30011 mocha$1.throwError = function (err) { 30012 uncaughtExceptionHandlers.forEach(function (fn) { 30013 fn(err); 30014 }); 30015 throw err; 30016 }; 30017 /** 30018 * Override ui to ensure that the ui functions are initialized. 30019 * Normally this would happen in Mocha.prototype.loadFiles. 30020 */ 30021 30022 30023 mocha$1.ui = function (ui) { 30024 mocha.prototype.ui.call(this, ui); 30025 this.suite.emit('pre-require', commonjsGlobal, null, this); 30026 return this; 30027 }; 30028 /** 30029 * Setup mocha with the given setting options. 30030 */ 30031 30032 30033 mocha$1.setup = function (opts) { 30034 if (typeof opts === 'string') { 30035 opts = { 30036 ui: opts 30037 }; 30038 } 30039 30040 if (opts.delay === true) { 30041 this.delay(); 30042 } 30043 30044 var self = this; 30045 Object.keys(opts).filter(function (opt) { 30046 return opt !== 'delay'; 30047 }).forEach(function (opt) { 30048 if (Object.prototype.hasOwnProperty.call(opts, opt)) { 30049 self[opt](opts[opt]); 30050 } 30051 }); 30052 return this; 30053 }; 30054 /** 30055 * Run mocha, returning the Runner. 30056 */ 30057 30058 30059 mocha$1.run = function (fn) { 30060 var options = mocha$1.options; 30061 mocha$1.globals('location'); 30062 var query = parseQuery(commonjsGlobal.location.search || ''); 30063 30064 if (query.grep) { 30065 mocha$1.grep(query.grep); 30066 } 30067 30068 if (query.fgrep) { 30069 mocha$1.fgrep(query.fgrep); 30070 } 30071 30072 if (query.invert) { 30073 mocha$1.invert(); 30074 } 30075 30076 return mocha.prototype.run.call(mocha$1, function (err) { 30077 // The DOM Document is not available in Web Workers. 30078 var document = commonjsGlobal.document; 30079 30080 if (document && document.getElementById('mocha') && options.noHighlighting !== true) { 30081 highlightTags('code'); 30082 } 30083 30084 if (fn) { 30085 fn(err); 30086 } 30087 }); 30088 }; 30089 /** 30090 * Expose the process shim. 30091 * https://github.com/mochajs/mocha/pull/916 30092 */ 30093 30094 30095 mocha.process = process$1; 30096 /** 30097 * Expose mocha. 30098 */ 30099 30100 commonjsGlobal.Mocha = mocha; 30101 commonjsGlobal.mocha = mocha$1; // this allows test/acceptance/required-tokens.js to pass; thus, 30102 // you can now do `const describe = require('mocha').describe` in a 30103 // browser context (assuming browserification). should fix #880 30104 30105 var browserEntry = Object.assign(mocha$1, commonjsGlobal); 30106 30107 return browserEntry; 30108 30109 }))); 30110 //# sourceMappingURL=mocha.js.map