Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1 | (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ |
| 2 | (function (process,global){ |
| 3 | 'use strict'; |
| 4 | |
| 5 | /* eslint no-unused-vars: off */ |
| 6 | /* eslint-env commonjs */ |
| 7 | |
| 8 | /** |
| 9 | * Shim process.stdout. |
| 10 | */ |
| 11 | |
| 12 | process.stdout = require('browser-stdout')({label: false}); |
| 13 | |
| 14 | var Mocha = require('./lib/mocha'); |
| 15 | |
| 16 | /** |
| 17 | * Create a Mocha instance. |
| 18 | * |
| 19 | * @return {undefined} |
| 20 | */ |
| 21 | |
| 22 | var mocha = new Mocha({reporter: 'html'}); |
| 23 | |
| 24 | /** |
| 25 | * Save timer references to avoid Sinon interfering (see GH-237). |
| 26 | */ |
| 27 | |
| 28 | var Date = global.Date; |
| 29 | var setTimeout = global.setTimeout; |
| 30 | var setInterval = global.setInterval; |
| 31 | var clearTimeout = global.clearTimeout; |
| 32 | var clearInterval = global.clearInterval; |
| 33 | |
| 34 | var uncaughtExceptionHandlers = []; |
| 35 | |
| 36 | var originalOnerrorHandler = global.onerror; |
| 37 | |
| 38 | /** |
| 39 | * Remove uncaughtException listener. |
| 40 | * Revert to original onerror handler if previously defined. |
| 41 | */ |
| 42 | |
| 43 | process.removeListener = function(e, fn) { |
| 44 | if (e === 'uncaughtException') { |
| 45 | if (originalOnerrorHandler) { |
| 46 | global.onerror = originalOnerrorHandler; |
| 47 | } else { |
| 48 | global.onerror = function() {}; |
| 49 | } |
| 50 | var i = uncaughtExceptionHandlers.indexOf(fn); |
| 51 | if (i !== -1) { |
| 52 | uncaughtExceptionHandlers.splice(i, 1); |
| 53 | } |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * Implements uncaughtException listener. |
| 59 | */ |
| 60 | |
| 61 | process.on = function(e, fn) { |
| 62 | if (e === 'uncaughtException') { |
| 63 | global.onerror = function(err, url, line) { |
| 64 | fn(new Error(err + ' (' + url + ':' + line + ')')); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 65 | return !mocha.options.allowUncaught; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 66 | }; |
| 67 | uncaughtExceptionHandlers.push(fn); |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | // The BDD UI is registered by default, but no UI will be functional in the |
| 72 | // browser without an explicit call to the overridden `mocha.ui` (see below). |
| 73 | // Ensure that this default UI does not expose its methods to the global scope. |
| 74 | mocha.suite.removeAllListeners('pre-require'); |
| 75 | |
| 76 | var immediateQueue = []; |
| 77 | var immediateTimeout; |
| 78 | |
| 79 | function timeslice() { |
| 80 | var immediateStart = new Date().getTime(); |
| 81 | while (immediateQueue.length && new Date().getTime() - immediateStart < 100) { |
| 82 | immediateQueue.shift()(); |
| 83 | } |
| 84 | if (immediateQueue.length) { |
| 85 | immediateTimeout = setTimeout(timeslice, 0); |
| 86 | } else { |
| 87 | immediateTimeout = null; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * High-performance override of Runner.immediately. |
| 93 | */ |
| 94 | |
| 95 | Mocha.Runner.immediately = function(callback) { |
| 96 | immediateQueue.push(callback); |
| 97 | if (!immediateTimeout) { |
| 98 | immediateTimeout = setTimeout(timeslice, 0); |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | /** |
| 103 | * Function to allow assertion libraries to throw errors directly into mocha. |
| 104 | * This is useful when running tests in a browser because window.onerror will |
| 105 | * only receive the 'message' attribute of the Error. |
| 106 | */ |
| 107 | mocha.throwError = function(err) { |
| 108 | uncaughtExceptionHandlers.forEach(function(fn) { |
| 109 | fn(err); |
| 110 | }); |
| 111 | throw err; |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * Override ui to ensure that the ui functions are initialized. |
| 116 | * Normally this would happen in Mocha.prototype.loadFiles. |
| 117 | */ |
| 118 | |
| 119 | mocha.ui = function(ui) { |
| 120 | Mocha.prototype.ui.call(this, ui); |
| 121 | this.suite.emit('pre-require', global, null, this); |
| 122 | return this; |
| 123 | }; |
| 124 | |
| 125 | /** |
| 126 | * Setup mocha with the given setting options. |
| 127 | */ |
| 128 | |
| 129 | mocha.setup = function(opts) { |
| 130 | if (typeof opts === 'string') { |
| 131 | opts = {ui: opts}; |
| 132 | } |
| 133 | for (var opt in opts) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 134 | if (Object.prototype.hasOwnProperty.call(opts, opt)) { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 135 | this[opt](opts[opt]); |
| 136 | } |
| 137 | } |
| 138 | return this; |
| 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * Run mocha, returning the Runner. |
| 143 | */ |
| 144 | |
| 145 | mocha.run = function(fn) { |
| 146 | var options = mocha.options; |
| 147 | mocha.globals('location'); |
| 148 | |
| 149 | var query = Mocha.utils.parseQuery(global.location.search || ''); |
| 150 | if (query.grep) { |
| 151 | mocha.grep(query.grep); |
| 152 | } |
| 153 | if (query.fgrep) { |
| 154 | mocha.fgrep(query.fgrep); |
| 155 | } |
| 156 | if (query.invert) { |
| 157 | mocha.invert(); |
| 158 | } |
| 159 | |
| 160 | return Mocha.prototype.run.call(mocha, function(err) { |
| 161 | // The DOM Document is not available in Web Workers. |
| 162 | var document = global.document; |
| 163 | if ( |
| 164 | document && |
| 165 | document.getElementById('mocha') && |
| 166 | options.noHighlighting !== true |
| 167 | ) { |
| 168 | Mocha.utils.highlightTags('code'); |
| 169 | } |
| 170 | if (fn) { |
| 171 | fn(err); |
| 172 | } |
| 173 | }); |
| 174 | }; |
| 175 | |
| 176 | /** |
| 177 | * Expose the process shim. |
| 178 | * https://github.com/mochajs/mocha/pull/916 |
| 179 | */ |
| 180 | |
| 181 | Mocha.process = process; |
| 182 | |
| 183 | /** |
| 184 | * Expose mocha. |
| 185 | */ |
| 186 | |
| 187 | global.Mocha = Mocha; |
| 188 | global.mocha = mocha; |
| 189 | |
| 190 | // this allows test/acceptance/required-tokens.js to pass; thus, |
| 191 | // you can now do `const describe = require('mocha').describe` in a |
| 192 | // browser context (assuming browserification). should fix #880 |
| 193 | module.exports = global; |
| 194 | |
| 195 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 196 | },{"./lib/mocha":14,"_process":69,"browser-stdout":41}],2:[function(require,module,exports){ |
| 197 | (function (process,global){ |
| 198 | 'use strict'; |
| 199 | |
| 200 | /** |
| 201 | * Web Notifications module. |
| 202 | * @module Growl |
| 203 | */ |
| 204 | |
| 205 | /** |
| 206 | * Save timer references to avoid Sinon interfering (see GH-237). |
| 207 | */ |
| 208 | var Date = global.Date; |
| 209 | var setTimeout = global.setTimeout; |
| 210 | var EVENT_RUN_END = require('../runner').constants.EVENT_RUN_END; |
| 211 | |
| 212 | /** |
| 213 | * Checks if browser notification support exists. |
| 214 | * |
| 215 | * @public |
| 216 | * @see {@link https://caniuse.com/#feat=notifications|Browser support (notifications)} |
| 217 | * @see {@link https://caniuse.com/#feat=promises|Browser support (promises)} |
| 218 | * @see {@link Mocha#growl} |
| 219 | * @see {@link Mocha#isGrowlCapable} |
| 220 | * @return {boolean} whether browser notification support exists |
| 221 | */ |
| 222 | exports.isCapable = function() { |
| 223 | var hasNotificationSupport = 'Notification' in window; |
| 224 | var hasPromiseSupport = typeof Promise === 'function'; |
| 225 | return process.browser && hasNotificationSupport && hasPromiseSupport; |
| 226 | }; |
| 227 | |
| 228 | /** |
| 229 | * Implements browser notifications as a pseudo-reporter. |
| 230 | * |
| 231 | * @public |
| 232 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/notification|Notification API} |
| 233 | * @see {@link https://developers.google.com/web/fundamentals/push-notifications/display-a-notification|Displaying a Notification} |
| 234 | * @see {@link Growl#isPermitted} |
| 235 | * @see {@link Mocha#_growl} |
| 236 | * @param {Runner} runner - Runner instance. |
| 237 | */ |
| 238 | exports.notify = function(runner) { |
| 239 | var promise = isPermitted(); |
| 240 | |
| 241 | /** |
| 242 | * Attempt notification. |
| 243 | */ |
| 244 | var sendNotification = function() { |
| 245 | // If user hasn't responded yet... "No notification for you!" (Seinfeld) |
| 246 | Promise.race([promise, Promise.resolve(undefined)]) |
| 247 | .then(canNotify) |
| 248 | .then(function() { |
| 249 | display(runner); |
| 250 | }) |
| 251 | .catch(notPermitted); |
| 252 | }; |
| 253 | |
| 254 | runner.once(EVENT_RUN_END, sendNotification); |
| 255 | }; |
| 256 | |
| 257 | /** |
| 258 | * Checks if browser notification is permitted by user. |
| 259 | * |
| 260 | * @private |
| 261 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission|Notification.permission} |
| 262 | * @see {@link Mocha#growl} |
| 263 | * @see {@link Mocha#isGrowlPermitted} |
| 264 | * @returns {Promise<boolean>} promise determining if browser notification |
| 265 | * permissible when fulfilled. |
| 266 | */ |
| 267 | function isPermitted() { |
| 268 | var permitted = { |
| 269 | granted: function allow() { |
| 270 | return Promise.resolve(true); |
| 271 | }, |
| 272 | denied: function deny() { |
| 273 | return Promise.resolve(false); |
| 274 | }, |
| 275 | default: function ask() { |
| 276 | return Notification.requestPermission().then(function(permission) { |
| 277 | return permission === 'granted'; |
| 278 | }); |
| 279 | } |
| 280 | }; |
| 281 | |
| 282 | return permitted[Notification.permission](); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * @summary |
| 287 | * Determines if notification should proceed. |
| 288 | * |
| 289 | * @description |
| 290 | * Notification shall <strong>not</strong> proceed unless `value` is true. |
| 291 | * |
| 292 | * `value` will equal one of: |
| 293 | * <ul> |
| 294 | * <li><code>true</code> (from `isPermitted`)</li> |
| 295 | * <li><code>false</code> (from `isPermitted`)</li> |
| 296 | * <li><code>undefined</code> (from `Promise.race`)</li> |
| 297 | * </ul> |
| 298 | * |
| 299 | * @private |
| 300 | * @param {boolean|undefined} value - Determines if notification permissible. |
| 301 | * @returns {Promise<undefined>} Notification can proceed |
| 302 | */ |
| 303 | function canNotify(value) { |
| 304 | if (!value) { |
| 305 | var why = value === false ? 'blocked' : 'unacknowledged'; |
| 306 | var reason = 'not permitted by user (' + why + ')'; |
| 307 | return Promise.reject(new Error(reason)); |
| 308 | } |
| 309 | return Promise.resolve(); |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Displays the notification. |
| 314 | * |
| 315 | * @private |
| 316 | * @param {Runner} runner - Runner instance. |
| 317 | */ |
| 318 | function display(runner) { |
| 319 | var stats = runner.stats; |
| 320 | var symbol = { |
| 321 | cross: '\u274C', |
| 322 | tick: '\u2705' |
| 323 | }; |
| 324 | var logo = require('../../package').notifyLogo; |
| 325 | var _message; |
| 326 | var message; |
| 327 | var title; |
| 328 | |
| 329 | if (stats.failures) { |
| 330 | _message = stats.failures + ' of ' + stats.tests + ' tests failed'; |
| 331 | message = symbol.cross + ' ' + _message; |
| 332 | title = 'Failed'; |
| 333 | } else { |
| 334 | _message = stats.passes + ' tests passed in ' + stats.duration + 'ms'; |
| 335 | message = symbol.tick + ' ' + _message; |
| 336 | title = 'Passed'; |
| 337 | } |
| 338 | |
| 339 | // Send notification |
| 340 | var options = { |
| 341 | badge: logo, |
| 342 | body: message, |
| 343 | dir: 'ltr', |
| 344 | icon: logo, |
| 345 | lang: 'en-US', |
| 346 | name: 'mocha', |
| 347 | requireInteraction: false, |
| 348 | timestamp: Date.now() |
| 349 | }; |
| 350 | var notification = new Notification(title, options); |
| 351 | |
| 352 | // Autoclose after brief delay (makes various browsers act same) |
| 353 | var FORCE_DURATION = 4000; |
| 354 | setTimeout(notification.close.bind(notification), FORCE_DURATION); |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * As notifications are tangential to our purpose, just log the error. |
| 359 | * |
| 360 | * @private |
| 361 | * @param {Error} err - Why notification didn't happen. |
| 362 | */ |
| 363 | function notPermitted(err) { |
| 364 | console.error('notification error:', err.message); |
| 365 | } |
| 366 | |
| 367 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 368 | },{"../../package":90,"../runner":34,"_process":69}],3:[function(require,module,exports){ |
| 369 | 'use strict'; |
| 370 | |
| 371 | /** |
| 372 | * Expose `Progress`. |
| 373 | */ |
| 374 | |
| 375 | module.exports = Progress; |
| 376 | |
| 377 | /** |
| 378 | * Initialize a new `Progress` indicator. |
| 379 | */ |
| 380 | function Progress() { |
| 381 | this.percent = 0; |
| 382 | this.size(0); |
| 383 | this.fontSize(11); |
| 384 | this.font('helvetica, arial, sans-serif'); |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * Set progress size to `size`. |
| 389 | * |
| 390 | * @public |
| 391 | * @param {number} size |
| 392 | * @return {Progress} Progress instance. |
| 393 | */ |
| 394 | Progress.prototype.size = function(size) { |
| 395 | this._size = size; |
| 396 | return this; |
| 397 | }; |
| 398 | |
| 399 | /** |
| 400 | * Set text to `text`. |
| 401 | * |
| 402 | * @public |
| 403 | * @param {string} text |
| 404 | * @return {Progress} Progress instance. |
| 405 | */ |
| 406 | Progress.prototype.text = function(text) { |
| 407 | this._text = text; |
| 408 | return this; |
| 409 | }; |
| 410 | |
| 411 | /** |
| 412 | * Set font size to `size`. |
| 413 | * |
| 414 | * @public |
| 415 | * @param {number} size |
| 416 | * @return {Progress} Progress instance. |
| 417 | */ |
| 418 | Progress.prototype.fontSize = function(size) { |
| 419 | this._fontSize = size; |
| 420 | return this; |
| 421 | }; |
| 422 | |
| 423 | /** |
| 424 | * Set font to `family`. |
| 425 | * |
| 426 | * @param {string} family |
| 427 | * @return {Progress} Progress instance. |
| 428 | */ |
| 429 | Progress.prototype.font = function(family) { |
| 430 | this._font = family; |
| 431 | return this; |
| 432 | }; |
| 433 | |
| 434 | /** |
| 435 | * Update percentage to `n`. |
| 436 | * |
| 437 | * @param {number} n |
| 438 | * @return {Progress} Progress instance. |
| 439 | */ |
| 440 | Progress.prototype.update = function(n) { |
| 441 | this.percent = n; |
| 442 | return this; |
| 443 | }; |
| 444 | |
| 445 | /** |
| 446 | * Draw on `ctx`. |
| 447 | * |
| 448 | * @param {CanvasRenderingContext2d} ctx |
| 449 | * @return {Progress} Progress instance. |
| 450 | */ |
| 451 | Progress.prototype.draw = function(ctx) { |
| 452 | try { |
| 453 | var percent = Math.min(this.percent, 100); |
| 454 | var size = this._size; |
| 455 | var half = size / 2; |
| 456 | var x = half; |
| 457 | var y = half; |
| 458 | var rad = half - 1; |
| 459 | var fontSize = this._fontSize; |
| 460 | |
| 461 | ctx.font = fontSize + 'px ' + this._font; |
| 462 | |
| 463 | var angle = Math.PI * 2 * (percent / 100); |
| 464 | ctx.clearRect(0, 0, size, size); |
| 465 | |
| 466 | // outer circle |
| 467 | ctx.strokeStyle = '#9f9f9f'; |
| 468 | ctx.beginPath(); |
| 469 | ctx.arc(x, y, rad, 0, angle, false); |
| 470 | ctx.stroke(); |
| 471 | |
| 472 | // inner circle |
| 473 | ctx.strokeStyle = '#eee'; |
| 474 | ctx.beginPath(); |
| 475 | ctx.arc(x, y, rad - 1, 0, angle, true); |
| 476 | ctx.stroke(); |
| 477 | |
| 478 | // text |
| 479 | var text = this._text || (percent | 0) + '%'; |
| 480 | var w = ctx.measureText(text).width; |
| 481 | |
| 482 | ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1); |
| 483 | } catch (ignore) { |
| 484 | // don't fail if we can't render progress |
| 485 | } |
| 486 | return this; |
| 487 | }; |
| 488 | |
| 489 | },{}],4:[function(require,module,exports){ |
| 490 | (function (global){ |
| 491 | 'use strict'; |
| 492 | |
| 493 | exports.isatty = function isatty() { |
| 494 | return true; |
| 495 | }; |
| 496 | |
| 497 | exports.getWindowSize = function getWindowSize() { |
| 498 | if ('innerHeight' in global) { |
| 499 | return [global.innerHeight, global.innerWidth]; |
| 500 | } |
| 501 | // In a Web Worker, the DOM Window is not available. |
| 502 | return [640, 480]; |
| 503 | }; |
| 504 | |
| 505 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 506 | },{}],5:[function(require,module,exports){ |
| 507 | 'use strict'; |
| 508 | /** |
| 509 | * @module Context |
| 510 | */ |
| 511 | /** |
| 512 | * Expose `Context`. |
| 513 | */ |
| 514 | |
| 515 | module.exports = Context; |
| 516 | |
| 517 | /** |
| 518 | * Initialize a new `Context`. |
| 519 | * |
| 520 | * @private |
| 521 | */ |
| 522 | function Context() {} |
| 523 | |
| 524 | /** |
| 525 | * Set or get the context `Runnable` to `runnable`. |
| 526 | * |
| 527 | * @private |
| 528 | * @param {Runnable} runnable |
| 529 | * @return {Context} context |
| 530 | */ |
| 531 | Context.prototype.runnable = function(runnable) { |
| 532 | if (!arguments.length) { |
| 533 | return this._runnable; |
| 534 | } |
| 535 | this.test = this._runnable = runnable; |
| 536 | return this; |
| 537 | }; |
| 538 | |
| 539 | /** |
| 540 | * Set or get test timeout `ms`. |
| 541 | * |
| 542 | * @private |
| 543 | * @param {number} ms |
| 544 | * @return {Context} self |
| 545 | */ |
| 546 | Context.prototype.timeout = function(ms) { |
| 547 | if (!arguments.length) { |
| 548 | return this.runnable().timeout(); |
| 549 | } |
| 550 | this.runnable().timeout(ms); |
| 551 | return this; |
| 552 | }; |
| 553 | |
| 554 | /** |
| 555 | * Set test timeout `enabled`. |
| 556 | * |
| 557 | * @private |
| 558 | * @param {boolean} enabled |
| 559 | * @return {Context} self |
| 560 | */ |
| 561 | Context.prototype.enableTimeouts = function(enabled) { |
| 562 | if (!arguments.length) { |
| 563 | return this.runnable().enableTimeouts(); |
| 564 | } |
| 565 | this.runnable().enableTimeouts(enabled); |
| 566 | return this; |
| 567 | }; |
| 568 | |
| 569 | /** |
| 570 | * Set or get test slowness threshold `ms`. |
| 571 | * |
| 572 | * @private |
| 573 | * @param {number} ms |
| 574 | * @return {Context} self |
| 575 | */ |
| 576 | Context.prototype.slow = function(ms) { |
| 577 | if (!arguments.length) { |
| 578 | return this.runnable().slow(); |
| 579 | } |
| 580 | this.runnable().slow(ms); |
| 581 | return this; |
| 582 | }; |
| 583 | |
| 584 | /** |
| 585 | * Mark a test as skipped. |
| 586 | * |
| 587 | * @private |
| 588 | * @throws Pending |
| 589 | */ |
| 590 | Context.prototype.skip = function() { |
| 591 | this.runnable().skip(); |
| 592 | }; |
| 593 | |
| 594 | /** |
| 595 | * Set or get a number of allowed retries on failed tests |
| 596 | * |
| 597 | * @private |
| 598 | * @param {number} n |
| 599 | * @return {Context} self |
| 600 | */ |
| 601 | Context.prototype.retries = function(n) { |
| 602 | if (!arguments.length) { |
| 603 | return this.runnable().retries(); |
| 604 | } |
| 605 | this.runnable().retries(n); |
| 606 | return this; |
| 607 | }; |
| 608 | |
| 609 | },{}],6:[function(require,module,exports){ |
| 610 | 'use strict'; |
| 611 | /** |
| 612 | * @module Errors |
| 613 | */ |
| 614 | /** |
| 615 | * Factory functions to create throwable error objects |
| 616 | */ |
| 617 | |
| 618 | /** |
| 619 | * Creates an error object to be thrown when no files to be tested could be found using specified pattern. |
| 620 | * |
| 621 | * @public |
| 622 | * @param {string} message - Error message to be displayed. |
| 623 | * @param {string} pattern - User-specified argument value. |
| 624 | * @returns {Error} instance detailing the error condition |
| 625 | */ |
| 626 | function createNoFilesMatchPatternError(message, pattern) { |
| 627 | var err = new Error(message); |
| 628 | err.code = 'ERR_MOCHA_NO_FILES_MATCH_PATTERN'; |
| 629 | err.pattern = pattern; |
| 630 | return err; |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * Creates an error object to be thrown when the reporter specified in the options was not found. |
| 635 | * |
| 636 | * @public |
| 637 | * @param {string} message - Error message to be displayed. |
| 638 | * @param {string} reporter - User-specified reporter value. |
| 639 | * @returns {Error} instance detailing the error condition |
| 640 | */ |
| 641 | function createInvalidReporterError(message, reporter) { |
| 642 | var err = new TypeError(message); |
| 643 | err.code = 'ERR_MOCHA_INVALID_REPORTER'; |
| 644 | err.reporter = reporter; |
| 645 | return err; |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * Creates an error object to be thrown when the interface specified in the options was not found. |
| 650 | * |
| 651 | * @public |
| 652 | * @param {string} message - Error message to be displayed. |
| 653 | * @param {string} ui - User-specified interface value. |
| 654 | * @returns {Error} instance detailing the error condition |
| 655 | */ |
| 656 | function createInvalidInterfaceError(message, ui) { |
| 657 | var err = new Error(message); |
| 658 | err.code = 'ERR_MOCHA_INVALID_INTERFACE'; |
| 659 | err.interface = ui; |
| 660 | return err; |
| 661 | } |
| 662 | |
| 663 | /** |
| 664 | * Creates an error object to be thrown when a behavior, option, or parameter is unsupported. |
| 665 | * |
| 666 | * @public |
| 667 | * @param {string} message - Error message to be displayed. |
| 668 | * @returns {Error} instance detailing the error condition |
| 669 | */ |
| 670 | function createUnsupportedError(message) { |
| 671 | var err = new Error(message); |
| 672 | err.code = 'ERR_MOCHA_UNSUPPORTED'; |
| 673 | return err; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * Creates an error object to be thrown when an argument is missing. |
| 678 | * |
| 679 | * @public |
| 680 | * @param {string} message - Error message to be displayed. |
| 681 | * @param {string} argument - Argument name. |
| 682 | * @param {string} expected - Expected argument datatype. |
| 683 | * @returns {Error} instance detailing the error condition |
| 684 | */ |
| 685 | function createMissingArgumentError(message, argument, expected) { |
| 686 | return createInvalidArgumentTypeError(message, argument, expected); |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Creates an error object to be thrown when an argument did not use the supported type |
| 691 | * |
| 692 | * @public |
| 693 | * @param {string} message - Error message to be displayed. |
| 694 | * @param {string} argument - Argument name. |
| 695 | * @param {string} expected - Expected argument datatype. |
| 696 | * @returns {Error} instance detailing the error condition |
| 697 | */ |
| 698 | function createInvalidArgumentTypeError(message, argument, expected) { |
| 699 | var err = new TypeError(message); |
| 700 | err.code = 'ERR_MOCHA_INVALID_ARG_TYPE'; |
| 701 | err.argument = argument; |
| 702 | err.expected = expected; |
| 703 | err.actual = typeof argument; |
| 704 | return err; |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * Creates an error object to be thrown when an argument did not use the supported value |
| 709 | * |
| 710 | * @public |
| 711 | * @param {string} message - Error message to be displayed. |
| 712 | * @param {string} argument - Argument name. |
| 713 | * @param {string} value - Argument value. |
| 714 | * @param {string} [reason] - Why value is invalid. |
| 715 | * @returns {Error} instance detailing the error condition |
| 716 | */ |
| 717 | function createInvalidArgumentValueError(message, argument, value, reason) { |
| 718 | var err = new TypeError(message); |
| 719 | err.code = 'ERR_MOCHA_INVALID_ARG_VALUE'; |
| 720 | err.argument = argument; |
| 721 | err.value = value; |
| 722 | err.reason = typeof reason !== 'undefined' ? reason : 'is invalid'; |
| 723 | return err; |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined. |
| 728 | * |
| 729 | * @public |
| 730 | * @param {string} message - Error message to be displayed. |
| 731 | * @returns {Error} instance detailing the error condition |
| 732 | */ |
| 733 | function createInvalidExceptionError(message, value) { |
| 734 | var err = new Error(message); |
| 735 | err.code = 'ERR_MOCHA_INVALID_EXCEPTION'; |
| 736 | err.valueType = typeof value; |
| 737 | err.value = value; |
| 738 | return err; |
| 739 | } |
| 740 | |
| 741 | module.exports = { |
| 742 | createInvalidArgumentTypeError: createInvalidArgumentTypeError, |
| 743 | createInvalidArgumentValueError: createInvalidArgumentValueError, |
| 744 | createInvalidExceptionError: createInvalidExceptionError, |
| 745 | createInvalidInterfaceError: createInvalidInterfaceError, |
| 746 | createInvalidReporterError: createInvalidReporterError, |
| 747 | createMissingArgumentError: createMissingArgumentError, |
| 748 | createNoFilesMatchPatternError: createNoFilesMatchPatternError, |
| 749 | createUnsupportedError: createUnsupportedError |
| 750 | }; |
| 751 | |
| 752 | },{}],7:[function(require,module,exports){ |
| 753 | 'use strict'; |
| 754 | |
| 755 | var Runnable = require('./runnable'); |
| 756 | var inherits = require('./utils').inherits; |
| 757 | |
| 758 | /** |
| 759 | * Expose `Hook`. |
| 760 | */ |
| 761 | |
| 762 | module.exports = Hook; |
| 763 | |
| 764 | /** |
| 765 | * Initialize a new `Hook` with the given `title` and callback `fn` |
| 766 | * |
| 767 | * @class |
| 768 | * @extends Runnable |
| 769 | * @param {String} title |
| 770 | * @param {Function} fn |
| 771 | */ |
| 772 | function Hook(title, fn) { |
| 773 | Runnable.call(this, title, fn); |
| 774 | this.type = 'hook'; |
| 775 | } |
| 776 | |
| 777 | /** |
| 778 | * Inherit from `Runnable.prototype`. |
| 779 | */ |
| 780 | inherits(Hook, Runnable); |
| 781 | |
| 782 | /** |
| 783 | * Get or set the test `err`. |
| 784 | * |
| 785 | * @memberof Hook |
| 786 | * @public |
| 787 | * @param {Error} err |
| 788 | * @return {Error} |
| 789 | */ |
| 790 | Hook.prototype.error = function(err) { |
| 791 | if (!arguments.length) { |
| 792 | err = this._error; |
| 793 | this._error = null; |
| 794 | return err; |
| 795 | } |
| 796 | |
| 797 | this._error = err; |
| 798 | }; |
| 799 | |
| 800 | },{"./runnable":33,"./utils":38}],8:[function(require,module,exports){ |
| 801 | 'use strict'; |
| 802 | |
| 803 | var Test = require('../test'); |
| 804 | var EVENT_FILE_PRE_REQUIRE = require('../suite').constants |
| 805 | .EVENT_FILE_PRE_REQUIRE; |
| 806 | |
| 807 | /** |
| 808 | * BDD-style interface: |
| 809 | * |
| 810 | * describe('Array', function() { |
| 811 | * describe('#indexOf()', function() { |
| 812 | * it('should return -1 when not present', function() { |
| 813 | * // ... |
| 814 | * }); |
| 815 | * |
| 816 | * it('should return the index when present', function() { |
| 817 | * // ... |
| 818 | * }); |
| 819 | * }); |
| 820 | * }); |
| 821 | * |
| 822 | * @param {Suite} suite Root suite. |
| 823 | */ |
| 824 | module.exports = function bddInterface(suite) { |
| 825 | var suites = [suite]; |
| 826 | |
| 827 | suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { |
| 828 | var common = require('./common')(suites, context, mocha); |
| 829 | |
| 830 | context.before = common.before; |
| 831 | context.after = common.after; |
| 832 | context.beforeEach = common.beforeEach; |
| 833 | context.afterEach = common.afterEach; |
| 834 | context.run = mocha.options.delay && common.runWithSuite(suite); |
| 835 | /** |
| 836 | * Describe a "suite" with the given `title` |
| 837 | * and callback `fn` containing nested suites |
| 838 | * and/or tests. |
| 839 | */ |
| 840 | |
| 841 | context.describe = context.context = function(title, fn) { |
| 842 | return common.suite.create({ |
| 843 | title: title, |
| 844 | file: file, |
| 845 | fn: fn |
| 846 | }); |
| 847 | }; |
| 848 | |
| 849 | /** |
| 850 | * Pending describe. |
| 851 | */ |
| 852 | |
| 853 | context.xdescribe = context.xcontext = context.describe.skip = function( |
| 854 | title, |
| 855 | fn |
| 856 | ) { |
| 857 | return common.suite.skip({ |
| 858 | title: title, |
| 859 | file: file, |
| 860 | fn: fn |
| 861 | }); |
| 862 | }; |
| 863 | |
| 864 | /** |
| 865 | * Exclusive suite. |
| 866 | */ |
| 867 | |
| 868 | context.describe.only = function(title, fn) { |
| 869 | return common.suite.only({ |
| 870 | title: title, |
| 871 | file: file, |
| 872 | fn: fn |
| 873 | }); |
| 874 | }; |
| 875 | |
| 876 | /** |
| 877 | * Describe a specification or test-case |
| 878 | * with the given `title` and callback `fn` |
| 879 | * acting as a thunk. |
| 880 | */ |
| 881 | |
| 882 | context.it = context.specify = function(title, fn) { |
| 883 | var suite = suites[0]; |
| 884 | if (suite.isPending()) { |
| 885 | fn = null; |
| 886 | } |
| 887 | var test = new Test(title, fn); |
| 888 | test.file = file; |
| 889 | suite.addTest(test); |
| 890 | return test; |
| 891 | }; |
| 892 | |
| 893 | /** |
| 894 | * Exclusive test-case. |
| 895 | */ |
| 896 | |
| 897 | context.it.only = function(title, fn) { |
| 898 | return common.test.only(mocha, context.it(title, fn)); |
| 899 | }; |
| 900 | |
| 901 | /** |
| 902 | * Pending test case. |
| 903 | */ |
| 904 | |
| 905 | context.xit = context.xspecify = context.it.skip = function(title) { |
| 906 | return context.it(title); |
| 907 | }; |
| 908 | |
| 909 | /** |
| 910 | * Number of attempts to retry. |
| 911 | */ |
| 912 | context.it.retries = function(n) { |
| 913 | context.retries(n); |
| 914 | }; |
| 915 | }); |
| 916 | }; |
| 917 | |
| 918 | module.exports.description = 'BDD or RSpec style [default]'; |
| 919 | |
| 920 | },{"../suite":36,"../test":37,"./common":9}],9:[function(require,module,exports){ |
| 921 | 'use strict'; |
| 922 | |
| 923 | var Suite = require('../suite'); |
| 924 | var errors = require('../errors'); |
| 925 | var createMissingArgumentError = errors.createMissingArgumentError; |
| 926 | |
| 927 | /** |
| 928 | * Functions common to more than one interface. |
| 929 | * |
| 930 | * @param {Suite[]} suites |
| 931 | * @param {Context} context |
| 932 | * @param {Mocha} mocha |
| 933 | * @return {Object} An object containing common functions. |
| 934 | */ |
| 935 | module.exports = function(suites, context, mocha) { |
| 936 | /** |
| 937 | * Check if the suite should be tested. |
| 938 | * |
| 939 | * @private |
| 940 | * @param {Suite} suite - suite to check |
| 941 | * @returns {boolean} |
| 942 | */ |
| 943 | function shouldBeTested(suite) { |
| 944 | return ( |
| 945 | !mocha.options.grep || |
| 946 | (mocha.options.grep && |
| 947 | mocha.options.grep.test(suite.fullTitle()) && |
| 948 | !mocha.options.invert) |
| 949 | ); |
| 950 | } |
| 951 | |
| 952 | return { |
| 953 | /** |
| 954 | * This is only present if flag --delay is passed into Mocha. It triggers |
| 955 | * root suite execution. |
| 956 | * |
| 957 | * @param {Suite} suite The root suite. |
| 958 | * @return {Function} A function which runs the root suite |
| 959 | */ |
| 960 | runWithSuite: function runWithSuite(suite) { |
| 961 | return function run() { |
| 962 | suite.run(); |
| 963 | }; |
| 964 | }, |
| 965 | |
| 966 | /** |
| 967 | * Execute before running tests. |
| 968 | * |
| 969 | * @param {string} name |
| 970 | * @param {Function} fn |
| 971 | */ |
| 972 | before: function(name, fn) { |
| 973 | suites[0].beforeAll(name, fn); |
| 974 | }, |
| 975 | |
| 976 | /** |
| 977 | * Execute after running tests. |
| 978 | * |
| 979 | * @param {string} name |
| 980 | * @param {Function} fn |
| 981 | */ |
| 982 | after: function(name, fn) { |
| 983 | suites[0].afterAll(name, fn); |
| 984 | }, |
| 985 | |
| 986 | /** |
| 987 | * Execute before each test case. |
| 988 | * |
| 989 | * @param {string} name |
| 990 | * @param {Function} fn |
| 991 | */ |
| 992 | beforeEach: function(name, fn) { |
| 993 | suites[0].beforeEach(name, fn); |
| 994 | }, |
| 995 | |
| 996 | /** |
| 997 | * Execute after each test case. |
| 998 | * |
| 999 | * @param {string} name |
| 1000 | * @param {Function} fn |
| 1001 | */ |
| 1002 | afterEach: function(name, fn) { |
| 1003 | suites[0].afterEach(name, fn); |
| 1004 | }, |
| 1005 | |
| 1006 | suite: { |
| 1007 | /** |
| 1008 | * Create an exclusive Suite; convenience function |
| 1009 | * See docstring for create() below. |
| 1010 | * |
| 1011 | * @param {Object} opts |
| 1012 | * @returns {Suite} |
| 1013 | */ |
| 1014 | only: function only(opts) { |
| 1015 | opts.isOnly = true; |
| 1016 | return this.create(opts); |
| 1017 | }, |
| 1018 | |
| 1019 | /** |
| 1020 | * Create a Suite, but skip it; convenience function |
| 1021 | * See docstring for create() below. |
| 1022 | * |
| 1023 | * @param {Object} opts |
| 1024 | * @returns {Suite} |
| 1025 | */ |
| 1026 | skip: function skip(opts) { |
| 1027 | opts.pending = true; |
| 1028 | return this.create(opts); |
| 1029 | }, |
| 1030 | |
| 1031 | /** |
| 1032 | * Creates a suite. |
| 1033 | * |
| 1034 | * @param {Object} opts Options |
| 1035 | * @param {string} opts.title Title of Suite |
| 1036 | * @param {Function} [opts.fn] Suite Function (not always applicable) |
| 1037 | * @param {boolean} [opts.pending] Is Suite pending? |
| 1038 | * @param {string} [opts.file] Filepath where this Suite resides |
| 1039 | * @param {boolean} [opts.isOnly] Is Suite exclusive? |
| 1040 | * @returns {Suite} |
| 1041 | */ |
| 1042 | create: function create(opts) { |
| 1043 | var suite = Suite.create(suites[0], opts.title); |
| 1044 | suite.pending = Boolean(opts.pending); |
| 1045 | suite.file = opts.file; |
| 1046 | suites.unshift(suite); |
| 1047 | if (opts.isOnly) { |
| 1048 | if (mocha.options.forbidOnly && shouldBeTested(suite)) { |
| 1049 | throw new Error('`.only` forbidden'); |
| 1050 | } |
| 1051 | |
| 1052 | suite.parent.appendOnlySuite(suite); |
| 1053 | } |
| 1054 | if (suite.pending) { |
| 1055 | if (mocha.options.forbidPending && shouldBeTested(suite)) { |
| 1056 | throw new Error('Pending test forbidden'); |
| 1057 | } |
| 1058 | } |
| 1059 | if (typeof opts.fn === 'function') { |
| 1060 | opts.fn.call(suite); |
| 1061 | suites.shift(); |
| 1062 | } else if (typeof opts.fn === 'undefined' && !suite.pending) { |
| 1063 | throw createMissingArgumentError( |
| 1064 | 'Suite "' + |
| 1065 | suite.fullTitle() + |
| 1066 | '" was defined but no callback was supplied. ' + |
| 1067 | 'Supply a callback or explicitly skip the suite.', |
| 1068 | 'callback', |
| 1069 | 'function' |
| 1070 | ); |
| 1071 | } else if (!opts.fn && suite.pending) { |
| 1072 | suites.shift(); |
| 1073 | } |
| 1074 | |
| 1075 | return suite; |
| 1076 | } |
| 1077 | }, |
| 1078 | |
| 1079 | test: { |
| 1080 | /** |
| 1081 | * Exclusive test-case. |
| 1082 | * |
| 1083 | * @param {Object} mocha |
| 1084 | * @param {Function} test |
| 1085 | * @returns {*} |
| 1086 | */ |
| 1087 | only: function(mocha, test) { |
| 1088 | test.parent.appendOnlyTest(test); |
| 1089 | return test; |
| 1090 | }, |
| 1091 | |
| 1092 | /** |
| 1093 | * Pending test case. |
| 1094 | * |
| 1095 | * @param {string} title |
| 1096 | */ |
| 1097 | skip: function(title) { |
| 1098 | context.test(title); |
| 1099 | }, |
| 1100 | |
| 1101 | /** |
| 1102 | * Number of retry attempts |
| 1103 | * |
| 1104 | * @param {number} n |
| 1105 | */ |
| 1106 | retries: function(n) { |
| 1107 | context.retries(n); |
| 1108 | } |
| 1109 | } |
| 1110 | }; |
| 1111 | }; |
| 1112 | |
| 1113 | },{"../errors":6,"../suite":36}],10:[function(require,module,exports){ |
| 1114 | 'use strict'; |
| 1115 | var Suite = require('../suite'); |
| 1116 | var Test = require('../test'); |
| 1117 | |
| 1118 | /** |
| 1119 | * Exports-style (as Node.js module) interface: |
| 1120 | * |
| 1121 | * exports.Array = { |
| 1122 | * '#indexOf()': { |
| 1123 | * 'should return -1 when the value is not present': function() { |
| 1124 | * |
| 1125 | * }, |
| 1126 | * |
| 1127 | * 'should return the correct index when the value is present': function() { |
| 1128 | * |
| 1129 | * } |
| 1130 | * } |
| 1131 | * }; |
| 1132 | * |
| 1133 | * @param {Suite} suite Root suite. |
| 1134 | */ |
| 1135 | module.exports = function(suite) { |
| 1136 | var suites = [suite]; |
| 1137 | |
| 1138 | suite.on(Suite.constants.EVENT_FILE_REQUIRE, visit); |
| 1139 | |
| 1140 | function visit(obj, file) { |
| 1141 | var suite; |
| 1142 | for (var key in obj) { |
| 1143 | if (typeof obj[key] === 'function') { |
| 1144 | var fn = obj[key]; |
| 1145 | switch (key) { |
| 1146 | case 'before': |
| 1147 | suites[0].beforeAll(fn); |
| 1148 | break; |
| 1149 | case 'after': |
| 1150 | suites[0].afterAll(fn); |
| 1151 | break; |
| 1152 | case 'beforeEach': |
| 1153 | suites[0].beforeEach(fn); |
| 1154 | break; |
| 1155 | case 'afterEach': |
| 1156 | suites[0].afterEach(fn); |
| 1157 | break; |
| 1158 | default: |
| 1159 | var test = new Test(key, fn); |
| 1160 | test.file = file; |
| 1161 | suites[0].addTest(test); |
| 1162 | } |
| 1163 | } else { |
| 1164 | suite = Suite.create(suites[0], key); |
| 1165 | suites.unshift(suite); |
| 1166 | visit(obj[key], file); |
| 1167 | suites.shift(); |
| 1168 | } |
| 1169 | } |
| 1170 | } |
| 1171 | }; |
| 1172 | |
| 1173 | module.exports.description = 'Node.js module ("exports") style'; |
| 1174 | |
| 1175 | },{"../suite":36,"../test":37}],11:[function(require,module,exports){ |
| 1176 | 'use strict'; |
| 1177 | |
| 1178 | exports.bdd = require('./bdd'); |
| 1179 | exports.tdd = require('./tdd'); |
| 1180 | exports.qunit = require('./qunit'); |
| 1181 | exports.exports = require('./exports'); |
| 1182 | |
| 1183 | },{"./bdd":8,"./exports":10,"./qunit":12,"./tdd":13}],12:[function(require,module,exports){ |
| 1184 | 'use strict'; |
| 1185 | |
| 1186 | var Test = require('../test'); |
| 1187 | var EVENT_FILE_PRE_REQUIRE = require('../suite').constants |
| 1188 | .EVENT_FILE_PRE_REQUIRE; |
| 1189 | |
| 1190 | /** |
| 1191 | * QUnit-style interface: |
| 1192 | * |
| 1193 | * suite('Array'); |
| 1194 | * |
| 1195 | * test('#length', function() { |
| 1196 | * var arr = [1,2,3]; |
| 1197 | * ok(arr.length == 3); |
| 1198 | * }); |
| 1199 | * |
| 1200 | * test('#indexOf()', function() { |
| 1201 | * var arr = [1,2,3]; |
| 1202 | * ok(arr.indexOf(1) == 0); |
| 1203 | * ok(arr.indexOf(2) == 1); |
| 1204 | * ok(arr.indexOf(3) == 2); |
| 1205 | * }); |
| 1206 | * |
| 1207 | * suite('String'); |
| 1208 | * |
| 1209 | * test('#length', function() { |
| 1210 | * ok('foo'.length == 3); |
| 1211 | * }); |
| 1212 | * |
| 1213 | * @param {Suite} suite Root suite. |
| 1214 | */ |
| 1215 | module.exports = function qUnitInterface(suite) { |
| 1216 | var suites = [suite]; |
| 1217 | |
| 1218 | suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { |
| 1219 | var common = require('./common')(suites, context, mocha); |
| 1220 | |
| 1221 | context.before = common.before; |
| 1222 | context.after = common.after; |
| 1223 | context.beforeEach = common.beforeEach; |
| 1224 | context.afterEach = common.afterEach; |
| 1225 | context.run = mocha.options.delay && common.runWithSuite(suite); |
| 1226 | /** |
| 1227 | * Describe a "suite" with the given `title`. |
| 1228 | */ |
| 1229 | |
| 1230 | context.suite = function(title) { |
| 1231 | if (suites.length > 1) { |
| 1232 | suites.shift(); |
| 1233 | } |
| 1234 | return common.suite.create({ |
| 1235 | title: title, |
| 1236 | file: file, |
| 1237 | fn: false |
| 1238 | }); |
| 1239 | }; |
| 1240 | |
| 1241 | /** |
| 1242 | * Exclusive Suite. |
| 1243 | */ |
| 1244 | |
| 1245 | context.suite.only = function(title) { |
| 1246 | if (suites.length > 1) { |
| 1247 | suites.shift(); |
| 1248 | } |
| 1249 | return common.suite.only({ |
| 1250 | title: title, |
| 1251 | file: file, |
| 1252 | fn: false |
| 1253 | }); |
| 1254 | }; |
| 1255 | |
| 1256 | /** |
| 1257 | * Describe a specification or test-case |
| 1258 | * with the given `title` and callback `fn` |
| 1259 | * acting as a thunk. |
| 1260 | */ |
| 1261 | |
| 1262 | context.test = function(title, fn) { |
| 1263 | var test = new Test(title, fn); |
| 1264 | test.file = file; |
| 1265 | suites[0].addTest(test); |
| 1266 | return test; |
| 1267 | }; |
| 1268 | |
| 1269 | /** |
| 1270 | * Exclusive test-case. |
| 1271 | */ |
| 1272 | |
| 1273 | context.test.only = function(title, fn) { |
| 1274 | return common.test.only(mocha, context.test(title, fn)); |
| 1275 | }; |
| 1276 | |
| 1277 | context.test.skip = common.test.skip; |
| 1278 | context.test.retries = common.test.retries; |
| 1279 | }); |
| 1280 | }; |
| 1281 | |
| 1282 | module.exports.description = 'QUnit style'; |
| 1283 | |
| 1284 | },{"../suite":36,"../test":37,"./common":9}],13:[function(require,module,exports){ |
| 1285 | 'use strict'; |
| 1286 | |
| 1287 | var Test = require('../test'); |
| 1288 | var EVENT_FILE_PRE_REQUIRE = require('../suite').constants |
| 1289 | .EVENT_FILE_PRE_REQUIRE; |
| 1290 | |
| 1291 | /** |
| 1292 | * TDD-style interface: |
| 1293 | * |
| 1294 | * suite('Array', function() { |
| 1295 | * suite('#indexOf()', function() { |
| 1296 | * suiteSetup(function() { |
| 1297 | * |
| 1298 | * }); |
| 1299 | * |
| 1300 | * test('should return -1 when not present', function() { |
| 1301 | * |
| 1302 | * }); |
| 1303 | * |
| 1304 | * test('should return the index when present', function() { |
| 1305 | * |
| 1306 | * }); |
| 1307 | * |
| 1308 | * suiteTeardown(function() { |
| 1309 | * |
| 1310 | * }); |
| 1311 | * }); |
| 1312 | * }); |
| 1313 | * |
| 1314 | * @param {Suite} suite Root suite. |
| 1315 | */ |
| 1316 | module.exports = function(suite) { |
| 1317 | var suites = [suite]; |
| 1318 | |
| 1319 | suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { |
| 1320 | var common = require('./common')(suites, context, mocha); |
| 1321 | |
| 1322 | context.setup = common.beforeEach; |
| 1323 | context.teardown = common.afterEach; |
| 1324 | context.suiteSetup = common.before; |
| 1325 | context.suiteTeardown = common.after; |
| 1326 | context.run = mocha.options.delay && common.runWithSuite(suite); |
| 1327 | |
| 1328 | /** |
| 1329 | * Describe a "suite" with the given `title` and callback `fn` containing |
| 1330 | * nested suites and/or tests. |
| 1331 | */ |
| 1332 | context.suite = function(title, fn) { |
| 1333 | return common.suite.create({ |
| 1334 | title: title, |
| 1335 | file: file, |
| 1336 | fn: fn |
| 1337 | }); |
| 1338 | }; |
| 1339 | |
| 1340 | /** |
| 1341 | * Pending suite. |
| 1342 | */ |
| 1343 | context.suite.skip = function(title, fn) { |
| 1344 | return common.suite.skip({ |
| 1345 | title: title, |
| 1346 | file: file, |
| 1347 | fn: fn |
| 1348 | }); |
| 1349 | }; |
| 1350 | |
| 1351 | /** |
| 1352 | * Exclusive test-case. |
| 1353 | */ |
| 1354 | context.suite.only = function(title, fn) { |
| 1355 | return common.suite.only({ |
| 1356 | title: title, |
| 1357 | file: file, |
| 1358 | fn: fn |
| 1359 | }); |
| 1360 | }; |
| 1361 | |
| 1362 | /** |
| 1363 | * Describe a specification or test-case with the given `title` and |
| 1364 | * callback `fn` acting as a thunk. |
| 1365 | */ |
| 1366 | context.test = function(title, fn) { |
| 1367 | var suite = suites[0]; |
| 1368 | if (suite.isPending()) { |
| 1369 | fn = null; |
| 1370 | } |
| 1371 | var test = new Test(title, fn); |
| 1372 | test.file = file; |
| 1373 | suite.addTest(test); |
| 1374 | return test; |
| 1375 | }; |
| 1376 | |
| 1377 | /** |
| 1378 | * Exclusive test-case. |
| 1379 | */ |
| 1380 | |
| 1381 | context.test.only = function(title, fn) { |
| 1382 | return common.test.only(mocha, context.test(title, fn)); |
| 1383 | }; |
| 1384 | |
| 1385 | context.test.skip = common.test.skip; |
| 1386 | context.test.retries = common.test.retries; |
| 1387 | }); |
| 1388 | }; |
| 1389 | |
| 1390 | module.exports.description = |
| 1391 | 'traditional "suite"/"test" instead of BDD\'s "describe"/"it"'; |
| 1392 | |
| 1393 | },{"../suite":36,"../test":37,"./common":9}],14:[function(require,module,exports){ |
| 1394 | (function (process,global){ |
| 1395 | 'use strict'; |
| 1396 | |
| 1397 | /*! |
| 1398 | * mocha |
| 1399 | * Copyright(c) 2011 TJ Holowaychuk <[email protected]> |
| 1400 | * MIT Licensed |
| 1401 | */ |
| 1402 | |
| 1403 | var escapeRe = require('escape-string-regexp'); |
| 1404 | var path = require('path'); |
| 1405 | var builtinReporters = require('./reporters'); |
| 1406 | var growl = require('./growl'); |
| 1407 | var utils = require('./utils'); |
| 1408 | var mocharc = require('./mocharc.json'); |
| 1409 | var errors = require('./errors'); |
| 1410 | var Suite = require('./suite'); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1411 | var esmUtils = utils.supportsEsModules() ? require('./esm-utils') : undefined; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1412 | var createStatsCollector = require('./stats-collector'); |
| 1413 | var createInvalidReporterError = errors.createInvalidReporterError; |
| 1414 | var createInvalidInterfaceError = errors.createInvalidInterfaceError; |
| 1415 | var EVENT_FILE_PRE_REQUIRE = Suite.constants.EVENT_FILE_PRE_REQUIRE; |
| 1416 | var EVENT_FILE_POST_REQUIRE = Suite.constants.EVENT_FILE_POST_REQUIRE; |
| 1417 | var EVENT_FILE_REQUIRE = Suite.constants.EVENT_FILE_REQUIRE; |
| 1418 | var sQuote = utils.sQuote; |
| 1419 | |
| 1420 | exports = module.exports = Mocha; |
| 1421 | |
| 1422 | /** |
| 1423 | * To require local UIs and reporters when running in node. |
| 1424 | */ |
| 1425 | |
| 1426 | if (!process.browser) { |
| 1427 | var cwd = process.cwd(); |
| 1428 | module.paths.push(cwd, path.join(cwd, 'node_modules')); |
| 1429 | } |
| 1430 | |
| 1431 | /** |
| 1432 | * Expose internals. |
| 1433 | */ |
| 1434 | |
| 1435 | /** |
| 1436 | * @public |
| 1437 | * @class utils |
| 1438 | * @memberof Mocha |
| 1439 | */ |
| 1440 | exports.utils = utils; |
| 1441 | exports.interfaces = require('./interfaces'); |
| 1442 | /** |
| 1443 | * @public |
| 1444 | * @memberof Mocha |
| 1445 | */ |
| 1446 | exports.reporters = builtinReporters; |
| 1447 | exports.Runnable = require('./runnable'); |
| 1448 | exports.Context = require('./context'); |
| 1449 | /** |
| 1450 | * |
| 1451 | * @memberof Mocha |
| 1452 | */ |
| 1453 | exports.Runner = require('./runner'); |
| 1454 | exports.Suite = Suite; |
| 1455 | exports.Hook = require('./hook'); |
| 1456 | exports.Test = require('./test'); |
| 1457 | |
| 1458 | /** |
| 1459 | * Constructs a new Mocha instance with `options`. |
| 1460 | * |
| 1461 | * @public |
| 1462 | * @class Mocha |
| 1463 | * @param {Object} [options] - Settings object. |
| 1464 | * @param {boolean} [options.allowUncaught] - Propagate uncaught errors? |
| 1465 | * @param {boolean} [options.asyncOnly] - Force `done` callback or promise? |
| 1466 | * @param {boolean} [options.bail] - Bail after first test failure? |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1467 | * @param {boolean} [options.checkLeaks] - Check for global variable leaks? |
| 1468 | * @param {boolean} [options.color] - Color TTY output from reporter? |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1469 | * @param {boolean} [options.delay] - Delay root suite execution? |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1470 | * @param {boolean} [options.diff] - Show diff on failure? |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1471 | * @param {string} [options.fgrep] - Test filter given string. |
| 1472 | * @param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite? |
| 1473 | * @param {boolean} [options.forbidPending] - Pending tests fail the suite? |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1474 | * @param {boolean} [options.fullTrace] - Full stacktrace upon failure? |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1475 | * @param {string[]} [options.global] - Variables expected in global scope. |
| 1476 | * @param {RegExp|string} [options.grep] - Test filter given regular expression. |
| 1477 | * @param {boolean} [options.growl] - Enable desktop notifications? |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1478 | * @param {boolean} [options.inlineDiffs] - Display inline diffs? |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1479 | * @param {boolean} [options.invert] - Invert test filter matches? |
| 1480 | * @param {boolean} [options.noHighlighting] - Disable syntax highlighting? |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1481 | * @param {string|constructor} [options.reporter] - Reporter name or constructor. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1482 | * @param {Object} [options.reporterOption] - Reporter settings object. |
| 1483 | * @param {number} [options.retries] - Number of times to retry failed tests. |
| 1484 | * @param {number} [options.slow] - Slow threshold value. |
| 1485 | * @param {number|string} [options.timeout] - Timeout threshold value. |
| 1486 | * @param {string} [options.ui] - Interface name. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1487 | */ |
| 1488 | function Mocha(options) { |
| 1489 | options = utils.assign({}, mocharc, options || {}); |
| 1490 | this.files = []; |
| 1491 | this.options = options; |
| 1492 | // root suite |
| 1493 | this.suite = new exports.Suite('', new exports.Context(), true); |
| 1494 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1495 | this.grep(options.grep) |
| 1496 | .fgrep(options.fgrep) |
| 1497 | .ui(options.ui) |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1498 | .reporter( |
| 1499 | options.reporter, |
| 1500 | options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter |
| 1501 | ) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1502 | .slow(options.slow) |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1503 | .global(options.global); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1504 | |
| 1505 | // this guard exists because Suite#timeout does not consider `undefined` to be valid input |
| 1506 | if (typeof options.timeout !== 'undefined') { |
| 1507 | this.timeout(options.timeout === false ? 0 : options.timeout); |
| 1508 | } |
| 1509 | |
| 1510 | if ('retries' in options) { |
| 1511 | this.retries(options.retries); |
| 1512 | } |
| 1513 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1514 | [ |
| 1515 | 'allowUncaught', |
| 1516 | 'asyncOnly', |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1517 | 'bail', |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1518 | 'checkLeaks', |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1519 | 'color', |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1520 | 'delay', |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1521 | 'diff', |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1522 | 'forbidOnly', |
| 1523 | 'forbidPending', |
| 1524 | 'fullTrace', |
| 1525 | 'growl', |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1526 | 'inlineDiffs', |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1527 | 'invert' |
| 1528 | ].forEach(function(opt) { |
| 1529 | if (options[opt]) { |
| 1530 | this[opt](); |
| 1531 | } |
| 1532 | }, this); |
| 1533 | } |
| 1534 | |
| 1535 | /** |
| 1536 | * Enables or disables bailing on the first failure. |
| 1537 | * |
| 1538 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1539 | * @see [CLI option](../#-bail-b) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1540 | * @param {boolean} [bail=true] - Whether to bail on first error. |
| 1541 | * @returns {Mocha} this |
| 1542 | * @chainable |
| 1543 | */ |
| 1544 | Mocha.prototype.bail = function(bail) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1545 | this.suite.bail(bail !== false); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1546 | return this; |
| 1547 | }; |
| 1548 | |
| 1549 | /** |
| 1550 | * @summary |
| 1551 | * Adds `file` to be loaded for execution. |
| 1552 | * |
| 1553 | * @description |
| 1554 | * Useful for generic setup code that must be included within test suite. |
| 1555 | * |
| 1556 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1557 | * @see [CLI option](../#-file-filedirectoryglob) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1558 | * @param {string} file - Pathname of file to be loaded. |
| 1559 | * @returns {Mocha} this |
| 1560 | * @chainable |
| 1561 | */ |
| 1562 | Mocha.prototype.addFile = function(file) { |
| 1563 | this.files.push(file); |
| 1564 | return this; |
| 1565 | }; |
| 1566 | |
| 1567 | /** |
| 1568 | * Sets reporter to `reporter`, defaults to "spec". |
| 1569 | * |
| 1570 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1571 | * @see [CLI option](../#-reporter-name-r-name) |
| 1572 | * @see [Reporters](../#reporters) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1573 | * @param {String|Function} reporter - Reporter name or constructor. |
| 1574 | * @param {Object} [reporterOptions] - Options used to configure the reporter. |
| 1575 | * @returns {Mocha} this |
| 1576 | * @chainable |
| 1577 | * @throws {Error} if requested reporter cannot be loaded |
| 1578 | * @example |
| 1579 | * |
| 1580 | * // Use XUnit reporter and direct its output to file |
| 1581 | * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' }); |
| 1582 | */ |
| 1583 | Mocha.prototype.reporter = function(reporter, reporterOptions) { |
| 1584 | if (typeof reporter === 'function') { |
| 1585 | this._reporter = reporter; |
| 1586 | } else { |
| 1587 | reporter = reporter || 'spec'; |
| 1588 | var _reporter; |
| 1589 | // Try to load a built-in reporter. |
| 1590 | if (builtinReporters[reporter]) { |
| 1591 | _reporter = builtinReporters[reporter]; |
| 1592 | } |
| 1593 | // Try to load reporters from process.cwd() and node_modules |
| 1594 | if (!_reporter) { |
| 1595 | try { |
| 1596 | _reporter = require(reporter); |
| 1597 | } catch (err) { |
| 1598 | if ( |
| 1599 | err.code !== 'MODULE_NOT_FOUND' || |
| 1600 | err.message.indexOf('Cannot find module') !== -1 |
| 1601 | ) { |
| 1602 | // Try to load reporters from a path (absolute or relative) |
| 1603 | try { |
| 1604 | _reporter = require(path.resolve(process.cwd(), reporter)); |
| 1605 | } catch (_err) { |
| 1606 | _err.code !== 'MODULE_NOT_FOUND' || |
| 1607 | _err.message.indexOf('Cannot find module') !== -1 |
| 1608 | ? console.warn(sQuote(reporter) + ' reporter not found') |
| 1609 | : console.warn( |
| 1610 | sQuote(reporter) + |
| 1611 | ' reporter blew up with error:\n' + |
| 1612 | err.stack |
| 1613 | ); |
| 1614 | } |
| 1615 | } else { |
| 1616 | console.warn( |
| 1617 | sQuote(reporter) + ' reporter blew up with error:\n' + err.stack |
| 1618 | ); |
| 1619 | } |
| 1620 | } |
| 1621 | } |
| 1622 | if (!_reporter) { |
| 1623 | throw createInvalidReporterError( |
| 1624 | 'invalid reporter ' + sQuote(reporter), |
| 1625 | reporter |
| 1626 | ); |
| 1627 | } |
| 1628 | this._reporter = _reporter; |
| 1629 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1630 | this.options.reporterOption = reporterOptions; |
| 1631 | // alias option name is used in public reporters xunit/tap/progress |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1632 | this.options.reporterOptions = reporterOptions; |
| 1633 | return this; |
| 1634 | }; |
| 1635 | |
| 1636 | /** |
| 1637 | * Sets test UI `name`, defaults to "bdd". |
| 1638 | * |
| 1639 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1640 | * @see [CLI option](../#-ui-name-u-name) |
| 1641 | * @see [Interface DSLs](../#interfaces) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1642 | * @param {string|Function} [ui=bdd] - Interface name or class. |
| 1643 | * @returns {Mocha} this |
| 1644 | * @chainable |
| 1645 | * @throws {Error} if requested interface cannot be loaded |
| 1646 | */ |
| 1647 | Mocha.prototype.ui = function(ui) { |
| 1648 | var bindInterface; |
| 1649 | if (typeof ui === 'function') { |
| 1650 | bindInterface = ui; |
| 1651 | } else { |
| 1652 | ui = ui || 'bdd'; |
| 1653 | bindInterface = exports.interfaces[ui]; |
| 1654 | if (!bindInterface) { |
| 1655 | try { |
| 1656 | bindInterface = require(ui); |
| 1657 | } catch (err) { |
| 1658 | throw createInvalidInterfaceError( |
| 1659 | 'invalid interface ' + sQuote(ui), |
| 1660 | ui |
| 1661 | ); |
| 1662 | } |
| 1663 | } |
| 1664 | } |
| 1665 | bindInterface(this.suite); |
| 1666 | |
| 1667 | this.suite.on(EVENT_FILE_PRE_REQUIRE, function(context) { |
| 1668 | exports.afterEach = context.afterEach || context.teardown; |
| 1669 | exports.after = context.after || context.suiteTeardown; |
| 1670 | exports.beforeEach = context.beforeEach || context.setup; |
| 1671 | exports.before = context.before || context.suiteSetup; |
| 1672 | exports.describe = context.describe || context.suite; |
| 1673 | exports.it = context.it || context.test; |
| 1674 | exports.xit = context.xit || (context.test && context.test.skip); |
| 1675 | exports.setup = context.setup || context.beforeEach; |
| 1676 | exports.suiteSetup = context.suiteSetup || context.before; |
| 1677 | exports.suiteTeardown = context.suiteTeardown || context.after; |
| 1678 | exports.suite = context.suite || context.describe; |
| 1679 | exports.teardown = context.teardown || context.afterEach; |
| 1680 | exports.test = context.test || context.it; |
| 1681 | exports.run = context.run; |
| 1682 | }); |
| 1683 | |
| 1684 | return this; |
| 1685 | }; |
| 1686 | |
| 1687 | /** |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1688 | * Loads `files` prior to execution. Does not support ES Modules. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1689 | * |
| 1690 | * @description |
| 1691 | * The implementation relies on Node's `require` to execute |
| 1692 | * the test interface functions and will be subject to its cache. |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1693 | * Supports only CommonJS modules. To load ES modules, use Mocha#loadFilesAsync. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1694 | * |
| 1695 | * @private |
| 1696 | * @see {@link Mocha#addFile} |
| 1697 | * @see {@link Mocha#run} |
| 1698 | * @see {@link Mocha#unloadFiles} |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1699 | * @see {@link Mocha#loadFilesAsync} |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1700 | * @param {Function} [fn] - Callback invoked upon completion. |
| 1701 | */ |
| 1702 | Mocha.prototype.loadFiles = function(fn) { |
| 1703 | var self = this; |
| 1704 | var suite = this.suite; |
| 1705 | this.files.forEach(function(file) { |
| 1706 | file = path.resolve(file); |
| 1707 | suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self); |
| 1708 | suite.emit(EVENT_FILE_REQUIRE, require(file), file, self); |
| 1709 | suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self); |
| 1710 | }); |
| 1711 | fn && fn(); |
| 1712 | }; |
| 1713 | |
| 1714 | /** |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1715 | * Loads `files` prior to execution. Supports Node ES Modules. |
| 1716 | * |
| 1717 | * @description |
| 1718 | * The implementation relies on Node's `require` and `import` to execute |
| 1719 | * the test interface functions and will be subject to its cache. |
| 1720 | * Supports both CJS and ESM modules. |
| 1721 | * |
| 1722 | * @public |
| 1723 | * @see {@link Mocha#addFile} |
| 1724 | * @see {@link Mocha#run} |
| 1725 | * @see {@link Mocha#unloadFiles} |
| 1726 | * @returns {Promise} |
| 1727 | * @example |
| 1728 | * |
| 1729 | * // loads ESM (and CJS) test files asynchronously, then runs root suite |
| 1730 | * mocha.loadFilesAsync() |
| 1731 | * .then(() => mocha.run(failures => process.exitCode = failures ? 1 : 0)) |
| 1732 | * .catch(() => process.exitCode = 1); |
| 1733 | */ |
| 1734 | Mocha.prototype.loadFilesAsync = function() { |
| 1735 | var self = this; |
| 1736 | var suite = this.suite; |
| 1737 | this.loadAsync = true; |
| 1738 | |
| 1739 | if (!esmUtils) { |
| 1740 | return new Promise(function(resolve) { |
| 1741 | self.loadFiles(resolve); |
| 1742 | }); |
| 1743 | } |
| 1744 | |
| 1745 | return esmUtils.loadFilesAsync( |
| 1746 | this.files, |
| 1747 | function(file) { |
| 1748 | suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self); |
| 1749 | }, |
| 1750 | function(file, resultModule) { |
| 1751 | suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self); |
| 1752 | suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self); |
| 1753 | } |
| 1754 | ); |
| 1755 | }; |
| 1756 | |
| 1757 | /** |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1758 | * Removes a previously loaded file from Node's `require` cache. |
| 1759 | * |
| 1760 | * @private |
| 1761 | * @static |
| 1762 | * @see {@link Mocha#unloadFiles} |
| 1763 | * @param {string} file - Pathname of file to be unloaded. |
| 1764 | */ |
| 1765 | Mocha.unloadFile = function(file) { |
| 1766 | delete require.cache[require.resolve(file)]; |
| 1767 | }; |
| 1768 | |
| 1769 | /** |
| 1770 | * Unloads `files` from Node's `require` cache. |
| 1771 | * |
| 1772 | * @description |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1773 | * This allows required files to be "freshly" reloaded, providing the ability |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1774 | * to reuse a Mocha instance programmatically. |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1775 | * Note: does not clear ESM module files from the cache |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1776 | * |
| 1777 | * <strong>Intended for consumers — not used internally</strong> |
| 1778 | * |
| 1779 | * @public |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1780 | * @see {@link Mocha#run} |
| 1781 | * @returns {Mocha} this |
| 1782 | * @chainable |
| 1783 | */ |
| 1784 | Mocha.prototype.unloadFiles = function() { |
| 1785 | this.files.forEach(Mocha.unloadFile); |
| 1786 | return this; |
| 1787 | }; |
| 1788 | |
| 1789 | /** |
| 1790 | * Sets `grep` filter after escaping RegExp special characters. |
| 1791 | * |
| 1792 | * @public |
| 1793 | * @see {@link Mocha#grep} |
| 1794 | * @param {string} str - Value to be converted to a regexp. |
| 1795 | * @returns {Mocha} this |
| 1796 | * @chainable |
| 1797 | * @example |
| 1798 | * |
| 1799 | * // Select tests whose full title begins with `"foo"` followed by a period |
| 1800 | * mocha.fgrep('foo.'); |
| 1801 | */ |
| 1802 | Mocha.prototype.fgrep = function(str) { |
| 1803 | if (!str) { |
| 1804 | return this; |
| 1805 | } |
| 1806 | return this.grep(new RegExp(escapeRe(str))); |
| 1807 | }; |
| 1808 | |
| 1809 | /** |
| 1810 | * @summary |
| 1811 | * Sets `grep` filter used to select specific tests for execution. |
| 1812 | * |
| 1813 | * @description |
| 1814 | * If `re` is a regexp-like string, it will be converted to regexp. |
| 1815 | * The regexp is tested against the full title of each test (i.e., the |
| 1816 | * name of the test preceded by titles of each its ancestral suites). |
| 1817 | * As such, using an <em>exact-match</em> fixed pattern against the |
| 1818 | * test name itself will not yield any matches. |
| 1819 | * <br> |
| 1820 | * <strong>Previous filter value will be overwritten on each call!</strong> |
| 1821 | * |
| 1822 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1823 | * @see [CLI option](../#-grep-regexp-g-regexp) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1824 | * @see {@link Mocha#fgrep} |
| 1825 | * @see {@link Mocha#invert} |
| 1826 | * @param {RegExp|String} re - Regular expression used to select tests. |
| 1827 | * @return {Mocha} this |
| 1828 | * @chainable |
| 1829 | * @example |
| 1830 | * |
| 1831 | * // Select tests whose full title contains `"match"`, ignoring case |
| 1832 | * mocha.grep(/match/i); |
| 1833 | * @example |
| 1834 | * |
| 1835 | * // Same as above but with regexp-like string argument |
| 1836 | * mocha.grep('/match/i'); |
| 1837 | * @example |
| 1838 | * |
| 1839 | * // ## Anti-example |
| 1840 | * // Given embedded test `it('only-this-test')`... |
| 1841 | * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this! |
| 1842 | */ |
| 1843 | Mocha.prototype.grep = function(re) { |
| 1844 | if (utils.isString(re)) { |
| 1845 | // extract args if it's regex-like, i.e: [string, pattern, flag] |
| 1846 | var arg = re.match(/^\/(.*)\/(g|i|)$|.*/); |
| 1847 | this.options.grep = new RegExp(arg[1] || arg[0], arg[2]); |
| 1848 | } else { |
| 1849 | this.options.grep = re; |
| 1850 | } |
| 1851 | return this; |
| 1852 | }; |
| 1853 | |
| 1854 | /** |
| 1855 | * Inverts `grep` matches. |
| 1856 | * |
| 1857 | * @public |
| 1858 | * @see {@link Mocha#grep} |
| 1859 | * @return {Mocha} this |
| 1860 | * @chainable |
| 1861 | * @example |
| 1862 | * |
| 1863 | * // Select tests whose full title does *not* contain `"match"`, ignoring case |
| 1864 | * mocha.grep(/match/i).invert(); |
| 1865 | */ |
| 1866 | Mocha.prototype.invert = function() { |
| 1867 | this.options.invert = true; |
| 1868 | return this; |
| 1869 | }; |
| 1870 | |
| 1871 | /** |
| 1872 | * Enables or disables ignoring global leaks. |
| 1873 | * |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1874 | * @deprecated since v7.0.0 |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1875 | * @public |
| 1876 | * @see {@link Mocha#checkLeaks} |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1877 | * @param {boolean} [ignoreLeaks=false] - Whether to ignore global leaks. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1878 | * @return {Mocha} this |
| 1879 | * @chainable |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1880 | */ |
| 1881 | Mocha.prototype.ignoreLeaks = function(ignoreLeaks) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1882 | utils.deprecate( |
| 1883 | '"ignoreLeaks()" is DEPRECATED, please use "checkLeaks()" instead.' |
| 1884 | ); |
| 1885 | this.options.checkLeaks = !ignoreLeaks; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1886 | return this; |
| 1887 | }; |
| 1888 | |
| 1889 | /** |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1890 | * Enables or disables checking for global variables leaked while running tests. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1891 | * |
| 1892 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1893 | * @see [CLI option](../#-check-leaks) |
| 1894 | * @param {boolean} [checkLeaks=true] - Whether to check for global variable leaks. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1895 | * @return {Mocha} this |
| 1896 | * @chainable |
| 1897 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1898 | Mocha.prototype.checkLeaks = function(checkLeaks) { |
| 1899 | this.options.checkLeaks = checkLeaks !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1900 | return this; |
| 1901 | }; |
| 1902 | |
| 1903 | /** |
| 1904 | * Displays full stack trace upon test failure. |
| 1905 | * |
| 1906 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1907 | * @see [CLI option](../#-full-trace) |
| 1908 | * @param {boolean} [fullTrace=true] - Whether to print full stacktrace upon failure. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1909 | * @return {Mocha} this |
| 1910 | * @chainable |
| 1911 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1912 | Mocha.prototype.fullTrace = function(fullTrace) { |
| 1913 | this.options.fullTrace = fullTrace !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1914 | return this; |
| 1915 | }; |
| 1916 | |
| 1917 | /** |
| 1918 | * Enables desktop notification support if prerequisite software installed. |
| 1919 | * |
| 1920 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1921 | * @see [CLI option](../#-growl-g) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1922 | * @return {Mocha} this |
| 1923 | * @chainable |
| 1924 | */ |
| 1925 | Mocha.prototype.growl = function() { |
| 1926 | this.options.growl = this.isGrowlCapable(); |
| 1927 | if (!this.options.growl) { |
| 1928 | var detail = process.browser |
| 1929 | ? 'notification support not available in this browser...' |
| 1930 | : 'notification support prerequisites not installed...'; |
| 1931 | console.error(detail + ' cannot enable!'); |
| 1932 | } |
| 1933 | return this; |
| 1934 | }; |
| 1935 | |
| 1936 | /** |
| 1937 | * @summary |
| 1938 | * Determines if Growl support seems likely. |
| 1939 | * |
| 1940 | * @description |
| 1941 | * <strong>Not available when run in browser.</strong> |
| 1942 | * |
| 1943 | * @private |
| 1944 | * @see {@link Growl#isCapable} |
| 1945 | * @see {@link Mocha#growl} |
| 1946 | * @return {boolean} whether Growl support can be expected |
| 1947 | */ |
| 1948 | Mocha.prototype.isGrowlCapable = growl.isCapable; |
| 1949 | |
| 1950 | /** |
| 1951 | * Implements desktop notifications using a pseudo-reporter. |
| 1952 | * |
| 1953 | * @private |
| 1954 | * @see {@link Mocha#growl} |
| 1955 | * @see {@link Growl#notify} |
| 1956 | * @param {Runner} runner - Runner instance. |
| 1957 | */ |
| 1958 | Mocha.prototype._growl = growl.notify; |
| 1959 | |
| 1960 | /** |
| 1961 | * Specifies whitelist of variable names to be expected in global scope. |
| 1962 | * |
| 1963 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1964 | * @see [CLI option](../#-global-variable-name) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1965 | * @see {@link Mocha#checkLeaks} |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1966 | * @param {String[]|String} global - Accepted global variable name(s). |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1967 | * @return {Mocha} this |
| 1968 | * @chainable |
| 1969 | * @example |
| 1970 | * |
| 1971 | * // Specify variables to be expected in global scope |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1972 | * mocha.global(['jQuery', 'MyLib']); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1973 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1974 | Mocha.prototype.global = function(global) { |
| 1975 | this.options.global = (this.options.global || []) |
| 1976 | .concat(global) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 1977 | .filter(Boolean) |
| 1978 | .filter(function(elt, idx, arr) { |
| 1979 | return arr.indexOf(elt) === idx; |
| 1980 | }); |
| 1981 | return this; |
| 1982 | }; |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 1983 | // for backwards compability, 'globals' is an alias of 'global' |
| 1984 | Mocha.prototype.globals = Mocha.prototype.global; |
| 1985 | |
| 1986 | /** |
| 1987 | * Enables or disables TTY color output by screen-oriented reporters. |
| 1988 | * |
| 1989 | * @deprecated since v7.0.0 |
| 1990 | * @public |
| 1991 | * @see {@link Mocha#color} |
| 1992 | * @param {boolean} colors - Whether to enable color output. |
| 1993 | * @return {Mocha} this |
| 1994 | * @chainable |
| 1995 | */ |
| 1996 | Mocha.prototype.useColors = function(colors) { |
| 1997 | utils.deprecate('"useColors()" is DEPRECATED, please use "color()" instead.'); |
| 1998 | if (colors !== undefined) { |
| 1999 | this.options.color = colors; |
| 2000 | } |
| 2001 | return this; |
| 2002 | }; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2003 | |
| 2004 | /** |
| 2005 | * Enables or disables TTY color output by screen-oriented reporters. |
| 2006 | * |
| 2007 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2008 | * @see [CLI option](../#-color-c-colors) |
| 2009 | * @param {boolean} [color=true] - Whether to enable color output. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2010 | * @return {Mocha} this |
| 2011 | * @chainable |
| 2012 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2013 | Mocha.prototype.color = function(color) { |
| 2014 | this.options.color = color !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2015 | return this; |
| 2016 | }; |
| 2017 | |
| 2018 | /** |
| 2019 | * Determines if reporter should use inline diffs (rather than +/-) |
| 2020 | * in test failure output. |
| 2021 | * |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2022 | * @deprecated since v7.0.0 |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2023 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2024 | * @see {@link Mocha#inlineDiffs} |
| 2025 | * @param {boolean} [inlineDiffs=false] - Whether to use inline diffs. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2026 | * @return {Mocha} this |
| 2027 | * @chainable |
| 2028 | */ |
| 2029 | Mocha.prototype.useInlineDiffs = function(inlineDiffs) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2030 | utils.deprecate( |
| 2031 | '"useInlineDiffs()" is DEPRECATED, please use "inlineDiffs()" instead.' |
| 2032 | ); |
| 2033 | this.options.inlineDiffs = inlineDiffs !== undefined && inlineDiffs; |
| 2034 | return this; |
| 2035 | }; |
| 2036 | |
| 2037 | /** |
| 2038 | * Enables or disables reporter to use inline diffs (rather than +/-) |
| 2039 | * in test failure output. |
| 2040 | * |
| 2041 | * @public |
| 2042 | * @see [CLI option](../#-inline-diffs) |
| 2043 | * @param {boolean} [inlineDiffs=true] - Whether to use inline diffs. |
| 2044 | * @return {Mocha} this |
| 2045 | * @chainable |
| 2046 | */ |
| 2047 | Mocha.prototype.inlineDiffs = function(inlineDiffs) { |
| 2048 | this.options.inlineDiffs = inlineDiffs !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2049 | return this; |
| 2050 | }; |
| 2051 | |
| 2052 | /** |
| 2053 | * Determines if reporter should include diffs in test failure output. |
| 2054 | * |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2055 | * @deprecated since v7.0.0 |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2056 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2057 | * @see {@link Mocha#diff} |
| 2058 | * @param {boolean} [hideDiff=false] - Whether to hide diffs. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2059 | * @return {Mocha} this |
| 2060 | * @chainable |
| 2061 | */ |
| 2062 | Mocha.prototype.hideDiff = function(hideDiff) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2063 | utils.deprecate('"hideDiff()" is DEPRECATED, please use "diff()" instead.'); |
| 2064 | this.options.diff = !(hideDiff === true); |
| 2065 | return this; |
| 2066 | }; |
| 2067 | |
| 2068 | /** |
| 2069 | * Enables or disables reporter to include diff in test failure output. |
| 2070 | * |
| 2071 | * @public |
| 2072 | * @see [CLI option](../#-diff) |
| 2073 | * @param {boolean} [diff=true] - Whether to show diff on failure. |
| 2074 | * @return {Mocha} this |
| 2075 | * @chainable |
| 2076 | */ |
| 2077 | Mocha.prototype.diff = function(diff) { |
| 2078 | this.options.diff = diff !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2079 | return this; |
| 2080 | }; |
| 2081 | |
| 2082 | /** |
| 2083 | * @summary |
| 2084 | * Sets timeout threshold value. |
| 2085 | * |
| 2086 | * @description |
| 2087 | * A string argument can use shorthand (such as "2s") and will be converted. |
| 2088 | * If the value is `0`, timeouts will be disabled. |
| 2089 | * |
| 2090 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2091 | * @see [CLI option](../#-timeout-ms-t-ms) |
| 2092 | * @see [Timeouts](../#timeouts) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2093 | * @see {@link Mocha#enableTimeouts} |
| 2094 | * @param {number|string} msecs - Timeout threshold value. |
| 2095 | * @return {Mocha} this |
| 2096 | * @chainable |
| 2097 | * @example |
| 2098 | * |
| 2099 | * // Sets timeout to one second |
| 2100 | * mocha.timeout(1000); |
| 2101 | * @example |
| 2102 | * |
| 2103 | * // Same as above but using string argument |
| 2104 | * mocha.timeout('1s'); |
| 2105 | */ |
| 2106 | Mocha.prototype.timeout = function(msecs) { |
| 2107 | this.suite.timeout(msecs); |
| 2108 | return this; |
| 2109 | }; |
| 2110 | |
| 2111 | /** |
| 2112 | * Sets the number of times to retry failed tests. |
| 2113 | * |
| 2114 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2115 | * @see [CLI option](../#-retries-n) |
| 2116 | * @see [Retry Tests](../#retry-tests) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2117 | * @param {number} retry - Number of times to retry failed tests. |
| 2118 | * @return {Mocha} this |
| 2119 | * @chainable |
| 2120 | * @example |
| 2121 | * |
| 2122 | * // Allow any failed test to retry one more time |
| 2123 | * mocha.retries(1); |
| 2124 | */ |
| 2125 | Mocha.prototype.retries = function(n) { |
| 2126 | this.suite.retries(n); |
| 2127 | return this; |
| 2128 | }; |
| 2129 | |
| 2130 | /** |
| 2131 | * Sets slowness threshold value. |
| 2132 | * |
| 2133 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2134 | * @see [CLI option](../#-slow-ms-s-ms) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2135 | * @param {number} msecs - Slowness threshold value. |
| 2136 | * @return {Mocha} this |
| 2137 | * @chainable |
| 2138 | * @example |
| 2139 | * |
| 2140 | * // Sets "slow" threshold to half a second |
| 2141 | * mocha.slow(500); |
| 2142 | * @example |
| 2143 | * |
| 2144 | * // Same as above but using string argument |
| 2145 | * mocha.slow('0.5s'); |
| 2146 | */ |
| 2147 | Mocha.prototype.slow = function(msecs) { |
| 2148 | this.suite.slow(msecs); |
| 2149 | return this; |
| 2150 | }; |
| 2151 | |
| 2152 | /** |
| 2153 | * Enables or disables timeouts. |
| 2154 | * |
| 2155 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2156 | * @see [CLI option](../#-timeout-ms-t-ms) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2157 | * @param {boolean} enableTimeouts - Whether to enable timeouts. |
| 2158 | * @return {Mocha} this |
| 2159 | * @chainable |
| 2160 | */ |
| 2161 | Mocha.prototype.enableTimeouts = function(enableTimeouts) { |
| 2162 | this.suite.enableTimeouts( |
| 2163 | arguments.length && enableTimeouts !== undefined ? enableTimeouts : true |
| 2164 | ); |
| 2165 | return this; |
| 2166 | }; |
| 2167 | |
| 2168 | /** |
| 2169 | * Forces all tests to either accept a `done` callback or return a promise. |
| 2170 | * |
| 2171 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2172 | * @see [CLI option](../#-async-only-a) |
| 2173 | * @param {boolean} [asyncOnly=true] - Wether to force `done` callback or promise. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2174 | * @return {Mocha} this |
| 2175 | * @chainable |
| 2176 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2177 | Mocha.prototype.asyncOnly = function(asyncOnly) { |
| 2178 | this.options.asyncOnly = asyncOnly !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2179 | return this; |
| 2180 | }; |
| 2181 | |
| 2182 | /** |
| 2183 | * Disables syntax highlighting (in browser). |
| 2184 | * |
| 2185 | * @public |
| 2186 | * @return {Mocha} this |
| 2187 | * @chainable |
| 2188 | */ |
| 2189 | Mocha.prototype.noHighlighting = function() { |
| 2190 | this.options.noHighlighting = true; |
| 2191 | return this; |
| 2192 | }; |
| 2193 | |
| 2194 | /** |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2195 | * Enables or disables uncaught errors to propagate. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2196 | * |
| 2197 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2198 | * @see [CLI option](../#-allow-uncaught) |
| 2199 | * @param {boolean} [allowUncaught=true] - Whether to propagate uncaught errors. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2200 | * @return {Mocha} this |
| 2201 | * @chainable |
| 2202 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2203 | Mocha.prototype.allowUncaught = function(allowUncaught) { |
| 2204 | this.options.allowUncaught = allowUncaught !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2205 | return this; |
| 2206 | }; |
| 2207 | |
| 2208 | /** |
| 2209 | * @summary |
| 2210 | * Delays root suite execution. |
| 2211 | * |
| 2212 | * @description |
| 2213 | * Used to perform asynch operations before any suites are run. |
| 2214 | * |
| 2215 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2216 | * @see [delayed root suite](../#delayed-root-suite) |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2217 | * @returns {Mocha} this |
| 2218 | * @chainable |
| 2219 | */ |
| 2220 | Mocha.prototype.delay = function delay() { |
| 2221 | this.options.delay = true; |
| 2222 | return this; |
| 2223 | }; |
| 2224 | |
| 2225 | /** |
| 2226 | * Causes tests marked `only` to fail the suite. |
| 2227 | * |
| 2228 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2229 | * @see [CLI option](../#-forbid-only) |
| 2230 | * @param {boolean} [forbidOnly=true] - Whether tests marked `only` fail the suite. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2231 | * @returns {Mocha} this |
| 2232 | * @chainable |
| 2233 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2234 | Mocha.prototype.forbidOnly = function(forbidOnly) { |
| 2235 | this.options.forbidOnly = forbidOnly !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2236 | return this; |
| 2237 | }; |
| 2238 | |
| 2239 | /** |
| 2240 | * Causes pending tests and tests marked `skip` to fail the suite. |
| 2241 | * |
| 2242 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2243 | * @see [CLI option](../#-forbid-pending) |
| 2244 | * @param {boolean} [forbidPending=true] - Whether pending tests fail the suite. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2245 | * @returns {Mocha} this |
| 2246 | * @chainable |
| 2247 | */ |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2248 | Mocha.prototype.forbidPending = function(forbidPending) { |
| 2249 | this.options.forbidPending = forbidPending !== false; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2250 | return this; |
| 2251 | }; |
| 2252 | |
| 2253 | /** |
| 2254 | * Mocha version as specified by "package.json". |
| 2255 | * |
| 2256 | * @name Mocha#version |
| 2257 | * @type string |
| 2258 | * @readonly |
| 2259 | */ |
| 2260 | Object.defineProperty(Mocha.prototype, 'version', { |
| 2261 | value: require('../package.json').version, |
| 2262 | configurable: false, |
| 2263 | enumerable: true, |
| 2264 | writable: false |
| 2265 | }); |
| 2266 | |
| 2267 | /** |
| 2268 | * Callback to be invoked when test execution is complete. |
| 2269 | * |
| 2270 | * @callback DoneCB |
| 2271 | * @param {number} failures - Number of failures that occurred. |
| 2272 | */ |
| 2273 | |
| 2274 | /** |
| 2275 | * Runs root suite and invokes `fn()` when complete. |
| 2276 | * |
| 2277 | * @description |
| 2278 | * To run tests multiple times (or to run tests in files that are |
| 2279 | * already in the `require` cache), make sure to clear them from |
| 2280 | * the cache first! |
| 2281 | * |
| 2282 | * @public |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2283 | * @see {@link Mocha#unloadFiles} |
| 2284 | * @see {@link Runner#run} |
| 2285 | * @param {DoneCB} [fn] - Callback invoked when test execution completed. |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2286 | * @returns {Runner} runner instance |
| 2287 | * @example |
| 2288 | * |
| 2289 | * // exit with non-zero status if there were test failures |
| 2290 | * mocha.run(failures => process.exitCode = failures ? 1 : 0); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2291 | */ |
| 2292 | Mocha.prototype.run = function(fn) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2293 | if (this.files.length && !this.loadAsync) { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2294 | this.loadFiles(); |
| 2295 | } |
| 2296 | var suite = this.suite; |
| 2297 | var options = this.options; |
| 2298 | options.files = this.files; |
| 2299 | var runner = new exports.Runner(suite, options.delay); |
| 2300 | createStatsCollector(runner); |
| 2301 | var reporter = new this._reporter(runner, options); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2302 | runner.checkLeaks = options.checkLeaks === true; |
| 2303 | runner.fullStackTrace = options.fullTrace; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2304 | runner.asyncOnly = options.asyncOnly; |
| 2305 | runner.allowUncaught = options.allowUncaught; |
| 2306 | runner.forbidOnly = options.forbidOnly; |
| 2307 | runner.forbidPending = options.forbidPending; |
| 2308 | if (options.grep) { |
| 2309 | runner.grep(options.grep, options.invert); |
| 2310 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2311 | if (options.global) { |
| 2312 | runner.globals(options.global); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2313 | } |
| 2314 | if (options.growl) { |
| 2315 | this._growl(runner); |
| 2316 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2317 | if (options.color !== undefined) { |
| 2318 | exports.reporters.Base.useColors = options.color; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2319 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2320 | exports.reporters.Base.inlineDiffs = options.inlineDiffs; |
| 2321 | exports.reporters.Base.hideDiff = !options.diff; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2322 | |
| 2323 | function done(failures) { |
| 2324 | fn = fn || utils.noop; |
| 2325 | if (reporter.done) { |
| 2326 | reporter.done(failures, fn); |
| 2327 | } else { |
| 2328 | fn(failures); |
| 2329 | } |
| 2330 | } |
| 2331 | |
| 2332 | return runner.run(done); |
| 2333 | }; |
| 2334 | |
| 2335 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2336 | },{"../package.json":90,"./context":5,"./errors":6,"./esm-utils":42,"./growl":2,"./hook":7,"./interfaces":11,"./mocharc.json":15,"./reporters":21,"./runnable":33,"./runner":34,"./stats-collector":35,"./suite":36,"./test":37,"./utils":38,"_process":69,"escape-string-regexp":49,"path":42}],15:[function(require,module,exports){ |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2337 | module.exports={ |
| 2338 | "diff": true, |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2339 | "extension": ["js", "cjs", "mjs"], |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2340 | "opts": "./test/mocha.opts", |
| 2341 | "package": "./package.json", |
| 2342 | "reporter": "spec", |
| 2343 | "slow": 75, |
| 2344 | "timeout": 2000, |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2345 | "ui": "bdd", |
| 2346 | "watch-ignore": ["node_modules", ".git"] |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2347 | } |
| 2348 | |
| 2349 | },{}],16:[function(require,module,exports){ |
| 2350 | 'use strict'; |
| 2351 | |
| 2352 | module.exports = Pending; |
| 2353 | |
| 2354 | /** |
| 2355 | * Initialize a new `Pending` error with the given message. |
| 2356 | * |
| 2357 | * @param {string} message |
| 2358 | */ |
| 2359 | function Pending(message) { |
| 2360 | this.message = message; |
| 2361 | } |
| 2362 | |
| 2363 | },{}],17:[function(require,module,exports){ |
| 2364 | (function (process){ |
| 2365 | 'use strict'; |
| 2366 | /** |
| 2367 | * @module Base |
| 2368 | */ |
| 2369 | /** |
| 2370 | * Module dependencies. |
| 2371 | */ |
| 2372 | |
| 2373 | var tty = require('tty'); |
| 2374 | var diff = require('diff'); |
| 2375 | var milliseconds = require('ms'); |
| 2376 | var utils = require('../utils'); |
| 2377 | var supportsColor = process.browser ? null : require('supports-color'); |
| 2378 | var constants = require('../runner').constants; |
| 2379 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 2380 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 2381 | |
| 2382 | /** |
| 2383 | * Expose `Base`. |
| 2384 | */ |
| 2385 | |
| 2386 | exports = module.exports = Base; |
| 2387 | |
| 2388 | /** |
| 2389 | * Check if both stdio streams are associated with a tty. |
| 2390 | */ |
| 2391 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2392 | var isatty = process.stdout.isTTY && process.stderr.isTTY; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2393 | |
| 2394 | /** |
| 2395 | * Save log references to avoid tests interfering (see GH-3604). |
| 2396 | */ |
| 2397 | var consoleLog = console.log; |
| 2398 | |
| 2399 | /** |
| 2400 | * Enable coloring by default, except in the browser interface. |
| 2401 | */ |
| 2402 | |
| 2403 | exports.useColors = |
| 2404 | !process.browser && |
| 2405 | (supportsColor.stdout || process.env.MOCHA_COLORS !== undefined); |
| 2406 | |
| 2407 | /** |
| 2408 | * Inline diffs instead of +/- |
| 2409 | */ |
| 2410 | |
| 2411 | exports.inlineDiffs = false; |
| 2412 | |
| 2413 | /** |
| 2414 | * Default color map. |
| 2415 | */ |
| 2416 | |
| 2417 | exports.colors = { |
| 2418 | pass: 90, |
| 2419 | fail: 31, |
| 2420 | 'bright pass': 92, |
| 2421 | 'bright fail': 91, |
| 2422 | 'bright yellow': 93, |
| 2423 | pending: 36, |
| 2424 | suite: 0, |
| 2425 | 'error title': 0, |
| 2426 | 'error message': 31, |
| 2427 | 'error stack': 90, |
| 2428 | checkmark: 32, |
| 2429 | fast: 90, |
| 2430 | medium: 33, |
| 2431 | slow: 31, |
| 2432 | green: 32, |
| 2433 | light: 90, |
| 2434 | 'diff gutter': 90, |
| 2435 | 'diff added': 32, |
| 2436 | 'diff removed': 31 |
| 2437 | }; |
| 2438 | |
| 2439 | /** |
| 2440 | * Default symbol map. |
| 2441 | */ |
| 2442 | |
| 2443 | exports.symbols = { |
| 2444 | ok: '✓', |
| 2445 | err: '✖', |
| 2446 | dot: '․', |
| 2447 | comma: ',', |
| 2448 | bang: '!' |
| 2449 | }; |
| 2450 | |
| 2451 | // With node.js on Windows: use symbols available in terminal default fonts |
| 2452 | if (process.platform === 'win32') { |
| 2453 | exports.symbols.ok = '\u221A'; |
| 2454 | exports.symbols.err = '\u00D7'; |
| 2455 | exports.symbols.dot = '.'; |
| 2456 | } |
| 2457 | |
| 2458 | /** |
| 2459 | * Color `str` with the given `type`, |
| 2460 | * allowing colors to be disabled, |
| 2461 | * as well as user-defined color |
| 2462 | * schemes. |
| 2463 | * |
| 2464 | * @private |
| 2465 | * @param {string} type |
| 2466 | * @param {string} str |
| 2467 | * @return {string} |
| 2468 | */ |
| 2469 | var color = (exports.color = function(type, str) { |
| 2470 | if (!exports.useColors) { |
| 2471 | return String(str); |
| 2472 | } |
| 2473 | return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m'; |
| 2474 | }); |
| 2475 | |
| 2476 | /** |
| 2477 | * Expose term window size, with some defaults for when stderr is not a tty. |
| 2478 | */ |
| 2479 | |
| 2480 | exports.window = { |
| 2481 | width: 75 |
| 2482 | }; |
| 2483 | |
| 2484 | if (isatty) { |
| 2485 | exports.window.width = process.stdout.getWindowSize |
| 2486 | ? process.stdout.getWindowSize(1)[0] |
| 2487 | : tty.getWindowSize()[1]; |
| 2488 | } |
| 2489 | |
| 2490 | /** |
| 2491 | * Expose some basic cursor interactions that are common among reporters. |
| 2492 | */ |
| 2493 | |
| 2494 | exports.cursor = { |
| 2495 | hide: function() { |
| 2496 | isatty && process.stdout.write('\u001b[?25l'); |
| 2497 | }, |
| 2498 | |
| 2499 | show: function() { |
| 2500 | isatty && process.stdout.write('\u001b[?25h'); |
| 2501 | }, |
| 2502 | |
| 2503 | deleteLine: function() { |
| 2504 | isatty && process.stdout.write('\u001b[2K'); |
| 2505 | }, |
| 2506 | |
| 2507 | beginningOfLine: function() { |
| 2508 | isatty && process.stdout.write('\u001b[0G'); |
| 2509 | }, |
| 2510 | |
| 2511 | CR: function() { |
| 2512 | if (isatty) { |
| 2513 | exports.cursor.deleteLine(); |
| 2514 | exports.cursor.beginningOfLine(); |
| 2515 | } else { |
| 2516 | process.stdout.write('\r'); |
| 2517 | } |
| 2518 | } |
| 2519 | }; |
| 2520 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2521 | var showDiff = (exports.showDiff = function(err) { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2522 | return ( |
| 2523 | err && |
| 2524 | err.showDiff !== false && |
| 2525 | sameType(err.actual, err.expected) && |
| 2526 | err.expected !== undefined |
| 2527 | ); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2528 | }); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2529 | |
| 2530 | function stringifyDiffObjs(err) { |
| 2531 | if (!utils.isString(err.actual) || !utils.isString(err.expected)) { |
| 2532 | err.actual = utils.stringify(err.actual); |
| 2533 | err.expected = utils.stringify(err.expected); |
| 2534 | } |
| 2535 | } |
| 2536 | |
| 2537 | /** |
| 2538 | * Returns a diff between 2 strings with coloured ANSI output. |
| 2539 | * |
| 2540 | * @description |
| 2541 | * The diff will be either inline or unified dependent on the value |
| 2542 | * of `Base.inlineDiff`. |
| 2543 | * |
| 2544 | * @param {string} actual |
| 2545 | * @param {string} expected |
| 2546 | * @return {string} Diff |
| 2547 | */ |
| 2548 | var generateDiff = (exports.generateDiff = function(actual, expected) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2549 | try { |
| 2550 | return exports.inlineDiffs |
| 2551 | ? inlineDiff(actual, expected) |
| 2552 | : unifiedDiff(actual, expected); |
| 2553 | } catch (err) { |
| 2554 | var msg = |
| 2555 | '\n ' + |
| 2556 | color('diff added', '+ expected') + |
| 2557 | ' ' + |
| 2558 | color('diff removed', '- actual: failed to generate Mocha diff') + |
| 2559 | '\n'; |
| 2560 | return msg; |
| 2561 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2562 | }); |
| 2563 | |
| 2564 | /** |
| 2565 | * Outputs the given `failures` as a list. |
| 2566 | * |
| 2567 | * @public |
| 2568 | * @memberof Mocha.reporters.Base |
| 2569 | * @variation 1 |
| 2570 | * @param {Object[]} failures - Each is Test instance with corresponding |
| 2571 | * Error property |
| 2572 | */ |
| 2573 | exports.list = function(failures) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2574 | var multipleErr, multipleTest; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2575 | Base.consoleLog(); |
| 2576 | failures.forEach(function(test, i) { |
| 2577 | // format |
| 2578 | var fmt = |
| 2579 | color('error title', ' %s) %s:\n') + |
| 2580 | color('error message', ' %s') + |
| 2581 | color('error stack', '\n%s\n'); |
| 2582 | |
| 2583 | // msg |
| 2584 | var msg; |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2585 | var err; |
| 2586 | if (test.err && test.err.multiple) { |
| 2587 | if (multipleTest !== test) { |
| 2588 | multipleTest = test; |
| 2589 | multipleErr = [test.err].concat(test.err.multiple); |
| 2590 | } |
| 2591 | err = multipleErr.shift(); |
| 2592 | } else { |
| 2593 | err = test.err; |
| 2594 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2595 | var message; |
| 2596 | if (err.message && typeof err.message.toString === 'function') { |
| 2597 | message = err.message + ''; |
| 2598 | } else if (typeof err.inspect === 'function') { |
| 2599 | message = err.inspect() + ''; |
| 2600 | } else { |
| 2601 | message = ''; |
| 2602 | } |
| 2603 | var stack = err.stack || message; |
| 2604 | var index = message ? stack.indexOf(message) : -1; |
| 2605 | |
| 2606 | if (index === -1) { |
| 2607 | msg = message; |
| 2608 | } else { |
| 2609 | index += message.length; |
| 2610 | msg = stack.slice(0, index); |
| 2611 | // remove msg from stack |
| 2612 | stack = stack.slice(index + 1); |
| 2613 | } |
| 2614 | |
| 2615 | // uncaught |
| 2616 | if (err.uncaught) { |
| 2617 | msg = 'Uncaught ' + msg; |
| 2618 | } |
| 2619 | // explicitly show diff |
| 2620 | if (!exports.hideDiff && showDiff(err)) { |
| 2621 | stringifyDiffObjs(err); |
| 2622 | fmt = |
| 2623 | color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n'); |
| 2624 | var match = message.match(/^([^:]+): expected/); |
| 2625 | msg = '\n ' + color('error message', match ? match[1] : msg); |
| 2626 | |
| 2627 | msg += generateDiff(err.actual, err.expected); |
| 2628 | } |
| 2629 | |
| 2630 | // indent stack trace |
| 2631 | stack = stack.replace(/^/gm, ' '); |
| 2632 | |
| 2633 | // indented test title |
| 2634 | var testTitle = ''; |
| 2635 | test.titlePath().forEach(function(str, index) { |
| 2636 | if (index !== 0) { |
| 2637 | testTitle += '\n '; |
| 2638 | } |
| 2639 | for (var i = 0; i < index; i++) { |
| 2640 | testTitle += ' '; |
| 2641 | } |
| 2642 | testTitle += str; |
| 2643 | }); |
| 2644 | |
| 2645 | Base.consoleLog(fmt, i + 1, testTitle, msg, stack); |
| 2646 | }); |
| 2647 | }; |
| 2648 | |
| 2649 | /** |
| 2650 | * Constructs a new `Base` reporter instance. |
| 2651 | * |
| 2652 | * @description |
| 2653 | * All other reporters generally inherit from this reporter. |
| 2654 | * |
| 2655 | * @public |
| 2656 | * @class |
| 2657 | * @memberof Mocha.reporters |
| 2658 | * @param {Runner} runner - Instance triggers reporter actions. |
| 2659 | * @param {Object} [options] - runner options |
| 2660 | */ |
| 2661 | function Base(runner, options) { |
| 2662 | var failures = (this.failures = []); |
| 2663 | |
| 2664 | if (!runner) { |
| 2665 | throw new TypeError('Missing runner argument'); |
| 2666 | } |
| 2667 | this.options = options || {}; |
| 2668 | this.runner = runner; |
| 2669 | this.stats = runner.stats; // assigned so Reporters keep a closer reference |
| 2670 | |
| 2671 | runner.on(EVENT_TEST_PASS, function(test) { |
| 2672 | if (test.duration > test.slow()) { |
| 2673 | test.speed = 'slow'; |
| 2674 | } else if (test.duration > test.slow() / 2) { |
| 2675 | test.speed = 'medium'; |
| 2676 | } else { |
| 2677 | test.speed = 'fast'; |
| 2678 | } |
| 2679 | }); |
| 2680 | |
| 2681 | runner.on(EVENT_TEST_FAIL, function(test, err) { |
| 2682 | if (showDiff(err)) { |
| 2683 | stringifyDiffObjs(err); |
| 2684 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2685 | // more than one error per test |
| 2686 | if (test.err && err instanceof Error) { |
| 2687 | test.err.multiple = (test.err.multiple || []).concat(err); |
| 2688 | } else { |
| 2689 | test.err = err; |
| 2690 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2691 | failures.push(test); |
| 2692 | }); |
| 2693 | } |
| 2694 | |
| 2695 | /** |
| 2696 | * Outputs common epilogue used by many of the bundled reporters. |
| 2697 | * |
| 2698 | * @public |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 2699 | * @memberof Mocha.reporters |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 2700 | */ |
| 2701 | Base.prototype.epilogue = function() { |
| 2702 | var stats = this.stats; |
| 2703 | var fmt; |
| 2704 | |
| 2705 | Base.consoleLog(); |
| 2706 | |
| 2707 | // passes |
| 2708 | fmt = |
| 2709 | color('bright pass', ' ') + |
| 2710 | color('green', ' %d passing') + |
| 2711 | color('light', ' (%s)'); |
| 2712 | |
| 2713 | Base.consoleLog(fmt, stats.passes || 0, milliseconds(stats.duration)); |
| 2714 | |
| 2715 | // pending |
| 2716 | if (stats.pending) { |
| 2717 | fmt = color('pending', ' ') + color('pending', ' %d pending'); |
| 2718 | |
| 2719 | Base.consoleLog(fmt, stats.pending); |
| 2720 | } |
| 2721 | |
| 2722 | // failures |
| 2723 | if (stats.failures) { |
| 2724 | fmt = color('fail', ' %d failing'); |
| 2725 | |
| 2726 | Base.consoleLog(fmt, stats.failures); |
| 2727 | |
| 2728 | Base.list(this.failures); |
| 2729 | Base.consoleLog(); |
| 2730 | } |
| 2731 | |
| 2732 | Base.consoleLog(); |
| 2733 | }; |
| 2734 | |
| 2735 | /** |
| 2736 | * Pads the given `str` to `len`. |
| 2737 | * |
| 2738 | * @private |
| 2739 | * @param {string} str |
| 2740 | * @param {string} len |
| 2741 | * @return {string} |
| 2742 | */ |
| 2743 | function pad(str, len) { |
| 2744 | str = String(str); |
| 2745 | return Array(len - str.length + 1).join(' ') + str; |
| 2746 | } |
| 2747 | |
| 2748 | /** |
| 2749 | * Returns inline diff between 2 strings with coloured ANSI output. |
| 2750 | * |
| 2751 | * @private |
| 2752 | * @param {String} actual |
| 2753 | * @param {String} expected |
| 2754 | * @return {string} Diff |
| 2755 | */ |
| 2756 | function inlineDiff(actual, expected) { |
| 2757 | var msg = errorDiff(actual, expected); |
| 2758 | |
| 2759 | // linenos |
| 2760 | var lines = msg.split('\n'); |
| 2761 | if (lines.length > 4) { |
| 2762 | var width = String(lines.length).length; |
| 2763 | msg = lines |
| 2764 | .map(function(str, i) { |
| 2765 | return pad(++i, width) + ' |' + ' ' + str; |
| 2766 | }) |
| 2767 | .join('\n'); |
| 2768 | } |
| 2769 | |
| 2770 | // legend |
| 2771 | msg = |
| 2772 | '\n' + |
| 2773 | color('diff removed', 'actual') + |
| 2774 | ' ' + |
| 2775 | color('diff added', 'expected') + |
| 2776 | '\n\n' + |
| 2777 | msg + |
| 2778 | '\n'; |
| 2779 | |
| 2780 | // indent |
| 2781 | msg = msg.replace(/^/gm, ' '); |
| 2782 | return msg; |
| 2783 | } |
| 2784 | |
| 2785 | /** |
| 2786 | * Returns unified diff between two strings with coloured ANSI output. |
| 2787 | * |
| 2788 | * @private |
| 2789 | * @param {String} actual |
| 2790 | * @param {String} expected |
| 2791 | * @return {string} The diff. |
| 2792 | */ |
| 2793 | function unifiedDiff(actual, expected) { |
| 2794 | var indent = ' '; |
| 2795 | function cleanUp(line) { |
| 2796 | if (line[0] === '+') { |
| 2797 | return indent + colorLines('diff added', line); |
| 2798 | } |
| 2799 | if (line[0] === '-') { |
| 2800 | return indent + colorLines('diff removed', line); |
| 2801 | } |
| 2802 | if (line.match(/@@/)) { |
| 2803 | return '--'; |
| 2804 | } |
| 2805 | if (line.match(/\\ No newline/)) { |
| 2806 | return null; |
| 2807 | } |
| 2808 | return indent + line; |
| 2809 | } |
| 2810 | function notBlank(line) { |
| 2811 | return typeof line !== 'undefined' && line !== null; |
| 2812 | } |
| 2813 | var msg = diff.createPatch('string', actual, expected); |
| 2814 | var lines = msg.split('\n').splice(5); |
| 2815 | return ( |
| 2816 | '\n ' + |
| 2817 | colorLines('diff added', '+ expected') + |
| 2818 | ' ' + |
| 2819 | colorLines('diff removed', '- actual') + |
| 2820 | '\n\n' + |
| 2821 | lines |
| 2822 | .map(cleanUp) |
| 2823 | .filter(notBlank) |
| 2824 | .join('\n') |
| 2825 | ); |
| 2826 | } |
| 2827 | |
| 2828 | /** |
| 2829 | * Returns character diff for `err`. |
| 2830 | * |
| 2831 | * @private |
| 2832 | * @param {String} actual |
| 2833 | * @param {String} expected |
| 2834 | * @return {string} the diff |
| 2835 | */ |
| 2836 | function errorDiff(actual, expected) { |
| 2837 | return diff |
| 2838 | .diffWordsWithSpace(actual, expected) |
| 2839 | .map(function(str) { |
| 2840 | if (str.added) { |
| 2841 | return colorLines('diff added', str.value); |
| 2842 | } |
| 2843 | if (str.removed) { |
| 2844 | return colorLines('diff removed', str.value); |
| 2845 | } |
| 2846 | return str.value; |
| 2847 | }) |
| 2848 | .join(''); |
| 2849 | } |
| 2850 | |
| 2851 | /** |
| 2852 | * Colors lines for `str`, using the color `name`. |
| 2853 | * |
| 2854 | * @private |
| 2855 | * @param {string} name |
| 2856 | * @param {string} str |
| 2857 | * @return {string} |
| 2858 | */ |
| 2859 | function colorLines(name, str) { |
| 2860 | return str |
| 2861 | .split('\n') |
| 2862 | .map(function(str) { |
| 2863 | return color(name, str); |
| 2864 | }) |
| 2865 | .join('\n'); |
| 2866 | } |
| 2867 | |
| 2868 | /** |
| 2869 | * Object#toString reference. |
| 2870 | */ |
| 2871 | var objToString = Object.prototype.toString; |
| 2872 | |
| 2873 | /** |
| 2874 | * Checks that a / b have the same type. |
| 2875 | * |
| 2876 | * @private |
| 2877 | * @param {Object} a |
| 2878 | * @param {Object} b |
| 2879 | * @return {boolean} |
| 2880 | */ |
| 2881 | function sameType(a, b) { |
| 2882 | return objToString.call(a) === objToString.call(b); |
| 2883 | } |
| 2884 | |
| 2885 | Base.consoleLog = consoleLog; |
| 2886 | |
| 2887 | Base.abstract = true; |
| 2888 | |
| 2889 | }).call(this,require('_process')) |
| 2890 | },{"../runner":34,"../utils":38,"_process":69,"diff":48,"ms":60,"supports-color":42,"tty":4}],18:[function(require,module,exports){ |
| 2891 | 'use strict'; |
| 2892 | /** |
| 2893 | * @module Doc |
| 2894 | */ |
| 2895 | /** |
| 2896 | * Module dependencies. |
| 2897 | */ |
| 2898 | |
| 2899 | var Base = require('./base'); |
| 2900 | var utils = require('../utils'); |
| 2901 | var constants = require('../runner').constants; |
| 2902 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 2903 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 2904 | var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; |
| 2905 | var EVENT_SUITE_END = constants.EVENT_SUITE_END; |
| 2906 | |
| 2907 | /** |
| 2908 | * Expose `Doc`. |
| 2909 | */ |
| 2910 | |
| 2911 | exports = module.exports = Doc; |
| 2912 | |
| 2913 | /** |
| 2914 | * Constructs a new `Doc` reporter instance. |
| 2915 | * |
| 2916 | * @public |
| 2917 | * @class |
| 2918 | * @memberof Mocha.reporters |
| 2919 | * @extends Mocha.reporters.Base |
| 2920 | * @param {Runner} runner - Instance triggers reporter actions. |
| 2921 | * @param {Object} [options] - runner options |
| 2922 | */ |
| 2923 | function Doc(runner, options) { |
| 2924 | Base.call(this, runner, options); |
| 2925 | |
| 2926 | var indents = 2; |
| 2927 | |
| 2928 | function indent() { |
| 2929 | return Array(indents).join(' '); |
| 2930 | } |
| 2931 | |
| 2932 | runner.on(EVENT_SUITE_BEGIN, function(suite) { |
| 2933 | if (suite.root) { |
| 2934 | return; |
| 2935 | } |
| 2936 | ++indents; |
| 2937 | Base.consoleLog('%s<section class="suite">', indent()); |
| 2938 | ++indents; |
| 2939 | Base.consoleLog('%s<h1>%s</h1>', indent(), utils.escape(suite.title)); |
| 2940 | Base.consoleLog('%s<dl>', indent()); |
| 2941 | }); |
| 2942 | |
| 2943 | runner.on(EVENT_SUITE_END, function(suite) { |
| 2944 | if (suite.root) { |
| 2945 | return; |
| 2946 | } |
| 2947 | Base.consoleLog('%s</dl>', indent()); |
| 2948 | --indents; |
| 2949 | Base.consoleLog('%s</section>', indent()); |
| 2950 | --indents; |
| 2951 | }); |
| 2952 | |
| 2953 | runner.on(EVENT_TEST_PASS, function(test) { |
| 2954 | Base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.title)); |
| 2955 | var code = utils.escape(utils.clean(test.body)); |
| 2956 | Base.consoleLog('%s <dd><pre><code>%s</code></pre></dd>', indent(), code); |
| 2957 | }); |
| 2958 | |
| 2959 | runner.on(EVENT_TEST_FAIL, function(test, err) { |
| 2960 | Base.consoleLog( |
| 2961 | '%s <dt class="error">%s</dt>', |
| 2962 | indent(), |
| 2963 | utils.escape(test.title) |
| 2964 | ); |
| 2965 | var code = utils.escape(utils.clean(test.body)); |
| 2966 | Base.consoleLog( |
| 2967 | '%s <dd class="error"><pre><code>%s</code></pre></dd>', |
| 2968 | indent(), |
| 2969 | code |
| 2970 | ); |
| 2971 | Base.consoleLog( |
| 2972 | '%s <dd class="error">%s</dd>', |
| 2973 | indent(), |
| 2974 | utils.escape(err) |
| 2975 | ); |
| 2976 | }); |
| 2977 | } |
| 2978 | |
| 2979 | Doc.description = 'HTML documentation'; |
| 2980 | |
| 2981 | },{"../runner":34,"../utils":38,"./base":17}],19:[function(require,module,exports){ |
| 2982 | (function (process){ |
| 2983 | 'use strict'; |
| 2984 | /** |
| 2985 | * @module Dot |
| 2986 | */ |
| 2987 | /** |
| 2988 | * Module dependencies. |
| 2989 | */ |
| 2990 | |
| 2991 | var Base = require('./base'); |
| 2992 | var inherits = require('../utils').inherits; |
| 2993 | var constants = require('../runner').constants; |
| 2994 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 2995 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 2996 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 2997 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 2998 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 2999 | |
| 3000 | /** |
| 3001 | * Expose `Dot`. |
| 3002 | */ |
| 3003 | |
| 3004 | exports = module.exports = Dot; |
| 3005 | |
| 3006 | /** |
| 3007 | * Constructs a new `Dot` reporter instance. |
| 3008 | * |
| 3009 | * @public |
| 3010 | * @class |
| 3011 | * @memberof Mocha.reporters |
| 3012 | * @extends Mocha.reporters.Base |
| 3013 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3014 | * @param {Object} [options] - runner options |
| 3015 | */ |
| 3016 | function Dot(runner, options) { |
| 3017 | Base.call(this, runner, options); |
| 3018 | |
| 3019 | var self = this; |
| 3020 | var width = (Base.window.width * 0.75) | 0; |
| 3021 | var n = -1; |
| 3022 | |
| 3023 | runner.on(EVENT_RUN_BEGIN, function() { |
| 3024 | process.stdout.write('\n'); |
| 3025 | }); |
| 3026 | |
| 3027 | runner.on(EVENT_TEST_PENDING, function() { |
| 3028 | if (++n % width === 0) { |
| 3029 | process.stdout.write('\n '); |
| 3030 | } |
| 3031 | process.stdout.write(Base.color('pending', Base.symbols.comma)); |
| 3032 | }); |
| 3033 | |
| 3034 | runner.on(EVENT_TEST_PASS, function(test) { |
| 3035 | if (++n % width === 0) { |
| 3036 | process.stdout.write('\n '); |
| 3037 | } |
| 3038 | if (test.speed === 'slow') { |
| 3039 | process.stdout.write(Base.color('bright yellow', Base.symbols.dot)); |
| 3040 | } else { |
| 3041 | process.stdout.write(Base.color(test.speed, Base.symbols.dot)); |
| 3042 | } |
| 3043 | }); |
| 3044 | |
| 3045 | runner.on(EVENT_TEST_FAIL, function() { |
| 3046 | if (++n % width === 0) { |
| 3047 | process.stdout.write('\n '); |
| 3048 | } |
| 3049 | process.stdout.write(Base.color('fail', Base.symbols.bang)); |
| 3050 | }); |
| 3051 | |
| 3052 | runner.once(EVENT_RUN_END, function() { |
| 3053 | process.stdout.write('\n'); |
| 3054 | self.epilogue(); |
| 3055 | }); |
| 3056 | } |
| 3057 | |
| 3058 | /** |
| 3059 | * Inherit from `Base.prototype`. |
| 3060 | */ |
| 3061 | inherits(Dot, Base); |
| 3062 | |
| 3063 | Dot.description = 'dot matrix representation'; |
| 3064 | |
| 3065 | }).call(this,require('_process')) |
| 3066 | },{"../runner":34,"../utils":38,"./base":17,"_process":69}],20:[function(require,module,exports){ |
| 3067 | (function (global){ |
| 3068 | 'use strict'; |
| 3069 | |
| 3070 | /* eslint-env browser */ |
| 3071 | /** |
| 3072 | * @module HTML |
| 3073 | */ |
| 3074 | /** |
| 3075 | * Module dependencies. |
| 3076 | */ |
| 3077 | |
| 3078 | var Base = require('./base'); |
| 3079 | var utils = require('../utils'); |
| 3080 | var Progress = require('../browser/progress'); |
| 3081 | var escapeRe = require('escape-string-regexp'); |
| 3082 | var constants = require('../runner').constants; |
| 3083 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 3084 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 3085 | var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; |
| 3086 | var EVENT_SUITE_END = constants.EVENT_SUITE_END; |
| 3087 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 3088 | var escape = utils.escape; |
| 3089 | |
| 3090 | /** |
| 3091 | * Save timer references to avoid Sinon interfering (see GH-237). |
| 3092 | */ |
| 3093 | |
| 3094 | var Date = global.Date; |
| 3095 | |
| 3096 | /** |
| 3097 | * Expose `HTML`. |
| 3098 | */ |
| 3099 | |
| 3100 | exports = module.exports = HTML; |
| 3101 | |
| 3102 | /** |
| 3103 | * Stats template. |
| 3104 | */ |
| 3105 | |
| 3106 | var statsTemplate = |
| 3107 | '<ul id="mocha-stats">' + |
| 3108 | '<li class="progress"><canvas width="40" height="40"></canvas></li>' + |
| 3109 | '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' + |
| 3110 | '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' + |
| 3111 | '<li class="duration">duration: <em>0</em>s</li>' + |
| 3112 | '</ul>'; |
| 3113 | |
| 3114 | var playIcon = '‣'; |
| 3115 | |
| 3116 | /** |
| 3117 | * Constructs a new `HTML` reporter instance. |
| 3118 | * |
| 3119 | * @public |
| 3120 | * @class |
| 3121 | * @memberof Mocha.reporters |
| 3122 | * @extends Mocha.reporters.Base |
| 3123 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3124 | * @param {Object} [options] - runner options |
| 3125 | */ |
| 3126 | function HTML(runner, options) { |
| 3127 | Base.call(this, runner, options); |
| 3128 | |
| 3129 | var self = this; |
| 3130 | var stats = this.stats; |
| 3131 | var stat = fragment(statsTemplate); |
| 3132 | var items = stat.getElementsByTagName('li'); |
| 3133 | var passes = items[1].getElementsByTagName('em')[0]; |
| 3134 | var passesLink = items[1].getElementsByTagName('a')[0]; |
| 3135 | var failures = items[2].getElementsByTagName('em')[0]; |
| 3136 | var failuresLink = items[2].getElementsByTagName('a')[0]; |
| 3137 | var duration = items[3].getElementsByTagName('em')[0]; |
| 3138 | var canvas = stat.getElementsByTagName('canvas')[0]; |
| 3139 | var report = fragment('<ul id="mocha-report"></ul>'); |
| 3140 | var stack = [report]; |
| 3141 | var progress; |
| 3142 | var ctx; |
| 3143 | var root = document.getElementById('mocha'); |
| 3144 | |
| 3145 | if (canvas.getContext) { |
| 3146 | var ratio = window.devicePixelRatio || 1; |
| 3147 | canvas.style.width = canvas.width; |
| 3148 | canvas.style.height = canvas.height; |
| 3149 | canvas.width *= ratio; |
| 3150 | canvas.height *= ratio; |
| 3151 | ctx = canvas.getContext('2d'); |
| 3152 | ctx.scale(ratio, ratio); |
| 3153 | progress = new Progress(); |
| 3154 | } |
| 3155 | |
| 3156 | if (!root) { |
| 3157 | return error('#mocha div missing, add it to your document'); |
| 3158 | } |
| 3159 | |
| 3160 | // pass toggle |
| 3161 | on(passesLink, 'click', function(evt) { |
| 3162 | evt.preventDefault(); |
| 3163 | unhide(); |
| 3164 | var name = /pass/.test(report.className) ? '' : ' pass'; |
| 3165 | report.className = report.className.replace(/fail|pass/g, '') + name; |
| 3166 | if (report.className.trim()) { |
| 3167 | hideSuitesWithout('test pass'); |
| 3168 | } |
| 3169 | }); |
| 3170 | |
| 3171 | // failure toggle |
| 3172 | on(failuresLink, 'click', function(evt) { |
| 3173 | evt.preventDefault(); |
| 3174 | unhide(); |
| 3175 | var name = /fail/.test(report.className) ? '' : ' fail'; |
| 3176 | report.className = report.className.replace(/fail|pass/g, '') + name; |
| 3177 | if (report.className.trim()) { |
| 3178 | hideSuitesWithout('test fail'); |
| 3179 | } |
| 3180 | }); |
| 3181 | |
| 3182 | root.appendChild(stat); |
| 3183 | root.appendChild(report); |
| 3184 | |
| 3185 | if (progress) { |
| 3186 | progress.size(40); |
| 3187 | } |
| 3188 | |
| 3189 | runner.on(EVENT_SUITE_BEGIN, function(suite) { |
| 3190 | if (suite.root) { |
| 3191 | return; |
| 3192 | } |
| 3193 | |
| 3194 | // suite |
| 3195 | var url = self.suiteURL(suite); |
| 3196 | var el = fragment( |
| 3197 | '<li class="suite"><h1><a href="%s">%s</a></h1></li>', |
| 3198 | url, |
| 3199 | escape(suite.title) |
| 3200 | ); |
| 3201 | |
| 3202 | // container |
| 3203 | stack[0].appendChild(el); |
| 3204 | stack.unshift(document.createElement('ul')); |
| 3205 | el.appendChild(stack[0]); |
| 3206 | }); |
| 3207 | |
| 3208 | runner.on(EVENT_SUITE_END, function(suite) { |
| 3209 | if (suite.root) { |
| 3210 | updateStats(); |
| 3211 | return; |
| 3212 | } |
| 3213 | stack.shift(); |
| 3214 | }); |
| 3215 | |
| 3216 | runner.on(EVENT_TEST_PASS, function(test) { |
| 3217 | var url = self.testURL(test); |
| 3218 | var markup = |
| 3219 | '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' + |
| 3220 | '<a href="%s" class="replay">' + |
| 3221 | playIcon + |
| 3222 | '</a></h2></li>'; |
| 3223 | var el = fragment(markup, test.speed, test.title, test.duration, url); |
| 3224 | self.addCodeToggle(el, test.body); |
| 3225 | appendToStack(el); |
| 3226 | updateStats(); |
| 3227 | }); |
| 3228 | |
| 3229 | runner.on(EVENT_TEST_FAIL, function(test) { |
| 3230 | var el = fragment( |
| 3231 | '<li class="test fail"><h2>%e <a href="%e" class="replay">' + |
| 3232 | playIcon + |
| 3233 | '</a></h2></li>', |
| 3234 | test.title, |
| 3235 | self.testURL(test) |
| 3236 | ); |
| 3237 | var stackString; // Note: Includes leading newline |
| 3238 | var message = test.err.toString(); |
| 3239 | |
| 3240 | // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we |
| 3241 | // check for the result of the stringifying. |
| 3242 | if (message === '[object Error]') { |
| 3243 | message = test.err.message; |
| 3244 | } |
| 3245 | |
| 3246 | if (test.err.stack) { |
| 3247 | var indexOfMessage = test.err.stack.indexOf(test.err.message); |
| 3248 | if (indexOfMessage === -1) { |
| 3249 | stackString = test.err.stack; |
| 3250 | } else { |
| 3251 | stackString = test.err.stack.substr( |
| 3252 | test.err.message.length + indexOfMessage |
| 3253 | ); |
| 3254 | } |
| 3255 | } else if (test.err.sourceURL && test.err.line !== undefined) { |
| 3256 | // Safari doesn't give you a stack. Let's at least provide a source line. |
| 3257 | stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')'; |
| 3258 | } |
| 3259 | |
| 3260 | stackString = stackString || ''; |
| 3261 | |
| 3262 | if (test.err.htmlMessage && stackString) { |
| 3263 | el.appendChild( |
| 3264 | fragment( |
| 3265 | '<div class="html-error">%s\n<pre class="error">%e</pre></div>', |
| 3266 | test.err.htmlMessage, |
| 3267 | stackString |
| 3268 | ) |
| 3269 | ); |
| 3270 | } else if (test.err.htmlMessage) { |
| 3271 | el.appendChild( |
| 3272 | fragment('<div class="html-error">%s</div>', test.err.htmlMessage) |
| 3273 | ); |
| 3274 | } else { |
| 3275 | el.appendChild( |
| 3276 | fragment('<pre class="error">%e%e</pre>', message, stackString) |
| 3277 | ); |
| 3278 | } |
| 3279 | |
| 3280 | self.addCodeToggle(el, test.body); |
| 3281 | appendToStack(el); |
| 3282 | updateStats(); |
| 3283 | }); |
| 3284 | |
| 3285 | runner.on(EVENT_TEST_PENDING, function(test) { |
| 3286 | var el = fragment( |
| 3287 | '<li class="test pass pending"><h2>%e</h2></li>', |
| 3288 | test.title |
| 3289 | ); |
| 3290 | appendToStack(el); |
| 3291 | updateStats(); |
| 3292 | }); |
| 3293 | |
| 3294 | function appendToStack(el) { |
| 3295 | // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack. |
| 3296 | if (stack[0]) { |
| 3297 | stack[0].appendChild(el); |
| 3298 | } |
| 3299 | } |
| 3300 | |
| 3301 | function updateStats() { |
| 3302 | // TODO: add to stats |
| 3303 | var percent = ((stats.tests / runner.total) * 100) | 0; |
| 3304 | if (progress) { |
| 3305 | progress.update(percent).draw(ctx); |
| 3306 | } |
| 3307 | |
| 3308 | // update stats |
| 3309 | var ms = new Date() - stats.start; |
| 3310 | text(passes, stats.passes); |
| 3311 | text(failures, stats.failures); |
| 3312 | text(duration, (ms / 1000).toFixed(2)); |
| 3313 | } |
| 3314 | } |
| 3315 | |
| 3316 | /** |
| 3317 | * Makes a URL, preserving querystring ("search") parameters. |
| 3318 | * |
| 3319 | * @param {string} s |
| 3320 | * @return {string} A new URL. |
| 3321 | */ |
| 3322 | function makeUrl(s) { |
| 3323 | var search = window.location.search; |
| 3324 | |
| 3325 | // Remove previous grep query parameter if present |
| 3326 | if (search) { |
| 3327 | search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?'); |
| 3328 | } |
| 3329 | |
| 3330 | return ( |
| 3331 | window.location.pathname + |
| 3332 | (search ? search + '&' : '?') + |
| 3333 | 'grep=' + |
| 3334 | encodeURIComponent(escapeRe(s)) |
| 3335 | ); |
| 3336 | } |
| 3337 | |
| 3338 | /** |
| 3339 | * Provide suite URL. |
| 3340 | * |
| 3341 | * @param {Object} [suite] |
| 3342 | */ |
| 3343 | HTML.prototype.suiteURL = function(suite) { |
| 3344 | return makeUrl(suite.fullTitle()); |
| 3345 | }; |
| 3346 | |
| 3347 | /** |
| 3348 | * Provide test URL. |
| 3349 | * |
| 3350 | * @param {Object} [test] |
| 3351 | */ |
| 3352 | HTML.prototype.testURL = function(test) { |
| 3353 | return makeUrl(test.fullTitle()); |
| 3354 | }; |
| 3355 | |
| 3356 | /** |
| 3357 | * Adds code toggle functionality for the provided test's list element. |
| 3358 | * |
| 3359 | * @param {HTMLLIElement} el |
| 3360 | * @param {string} contents |
| 3361 | */ |
| 3362 | HTML.prototype.addCodeToggle = function(el, contents) { |
| 3363 | var h2 = el.getElementsByTagName('h2')[0]; |
| 3364 | |
| 3365 | on(h2, 'click', function() { |
| 3366 | pre.style.display = pre.style.display === 'none' ? 'block' : 'none'; |
| 3367 | }); |
| 3368 | |
| 3369 | var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents)); |
| 3370 | el.appendChild(pre); |
| 3371 | pre.style.display = 'none'; |
| 3372 | }; |
| 3373 | |
| 3374 | /** |
| 3375 | * Display error `msg`. |
| 3376 | * |
| 3377 | * @param {string} msg |
| 3378 | */ |
| 3379 | function error(msg) { |
| 3380 | document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg)); |
| 3381 | } |
| 3382 | |
| 3383 | /** |
| 3384 | * Return a DOM fragment from `html`. |
| 3385 | * |
| 3386 | * @param {string} html |
| 3387 | */ |
| 3388 | function fragment(html) { |
| 3389 | var args = arguments; |
| 3390 | var div = document.createElement('div'); |
| 3391 | var i = 1; |
| 3392 | |
| 3393 | div.innerHTML = html.replace(/%([se])/g, function(_, type) { |
| 3394 | switch (type) { |
| 3395 | case 's': |
| 3396 | return String(args[i++]); |
| 3397 | case 'e': |
| 3398 | return escape(args[i++]); |
| 3399 | // no default |
| 3400 | } |
| 3401 | }); |
| 3402 | |
| 3403 | return div.firstChild; |
| 3404 | } |
| 3405 | |
| 3406 | /** |
| 3407 | * Check for suites that do not have elements |
| 3408 | * with `classname`, and hide them. |
| 3409 | * |
| 3410 | * @param {text} classname |
| 3411 | */ |
| 3412 | function hideSuitesWithout(classname) { |
| 3413 | var suites = document.getElementsByClassName('suite'); |
| 3414 | for (var i = 0; i < suites.length; i++) { |
| 3415 | var els = suites[i].getElementsByClassName(classname); |
| 3416 | if (!els.length) { |
| 3417 | suites[i].className += ' hidden'; |
| 3418 | } |
| 3419 | } |
| 3420 | } |
| 3421 | |
| 3422 | /** |
| 3423 | * Unhide .hidden suites. |
| 3424 | */ |
| 3425 | function unhide() { |
| 3426 | var els = document.getElementsByClassName('suite hidden'); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 3427 | while (els.length > 0) { |
| 3428 | els[0].className = els[0].className.replace('suite hidden', 'suite'); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 3429 | } |
| 3430 | } |
| 3431 | |
| 3432 | /** |
| 3433 | * Set an element's text contents. |
| 3434 | * |
| 3435 | * @param {HTMLElement} el |
| 3436 | * @param {string} contents |
| 3437 | */ |
| 3438 | function text(el, contents) { |
| 3439 | if (el.textContent) { |
| 3440 | el.textContent = contents; |
| 3441 | } else { |
| 3442 | el.innerText = contents; |
| 3443 | } |
| 3444 | } |
| 3445 | |
| 3446 | /** |
| 3447 | * Listen on `event` with callback `fn`. |
| 3448 | */ |
| 3449 | function on(el, event, fn) { |
| 3450 | if (el.addEventListener) { |
| 3451 | el.addEventListener(event, fn, false); |
| 3452 | } else { |
| 3453 | el.attachEvent('on' + event, fn); |
| 3454 | } |
| 3455 | } |
| 3456 | |
| 3457 | HTML.browserOnly = true; |
| 3458 | |
| 3459 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 3460 | },{"../browser/progress":3,"../runner":34,"../utils":38,"./base":17,"escape-string-regexp":49}],21:[function(require,module,exports){ |
| 3461 | 'use strict'; |
| 3462 | |
| 3463 | // Alias exports to a their normalized format Mocha#reporter to prevent a need |
| 3464 | // for dynamic (try/catch) requires, which Browserify doesn't handle. |
| 3465 | exports.Base = exports.base = require('./base'); |
| 3466 | exports.Dot = exports.dot = require('./dot'); |
| 3467 | exports.Doc = exports.doc = require('./doc'); |
| 3468 | exports.TAP = exports.tap = require('./tap'); |
| 3469 | exports.JSON = exports.json = require('./json'); |
| 3470 | exports.HTML = exports.html = require('./html'); |
| 3471 | exports.List = exports.list = require('./list'); |
| 3472 | exports.Min = exports.min = require('./min'); |
| 3473 | exports.Spec = exports.spec = require('./spec'); |
| 3474 | exports.Nyan = exports.nyan = require('./nyan'); |
| 3475 | exports.XUnit = exports.xunit = require('./xunit'); |
| 3476 | exports.Markdown = exports.markdown = require('./markdown'); |
| 3477 | exports.Progress = exports.progress = require('./progress'); |
| 3478 | exports.Landing = exports.landing = require('./landing'); |
| 3479 | exports.JSONStream = exports['json-stream'] = require('./json-stream'); |
| 3480 | |
| 3481 | },{"./base":17,"./doc":18,"./dot":19,"./html":20,"./json":23,"./json-stream":22,"./landing":24,"./list":25,"./markdown":26,"./min":27,"./nyan":28,"./progress":29,"./spec":30,"./tap":31,"./xunit":32}],22:[function(require,module,exports){ |
| 3482 | (function (process){ |
| 3483 | 'use strict'; |
| 3484 | /** |
| 3485 | * @module JSONStream |
| 3486 | */ |
| 3487 | /** |
| 3488 | * Module dependencies. |
| 3489 | */ |
| 3490 | |
| 3491 | var Base = require('./base'); |
| 3492 | var constants = require('../runner').constants; |
| 3493 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 3494 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 3495 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 3496 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 3497 | |
| 3498 | /** |
| 3499 | * Expose `JSONStream`. |
| 3500 | */ |
| 3501 | |
| 3502 | exports = module.exports = JSONStream; |
| 3503 | |
| 3504 | /** |
| 3505 | * Constructs a new `JSONStream` reporter instance. |
| 3506 | * |
| 3507 | * @public |
| 3508 | * @class |
| 3509 | * @memberof Mocha.reporters |
| 3510 | * @extends Mocha.reporters.Base |
| 3511 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3512 | * @param {Object} [options] - runner options |
| 3513 | */ |
| 3514 | function JSONStream(runner, options) { |
| 3515 | Base.call(this, runner, options); |
| 3516 | |
| 3517 | var self = this; |
| 3518 | var total = runner.total; |
| 3519 | |
| 3520 | runner.once(EVENT_RUN_BEGIN, function() { |
| 3521 | writeEvent(['start', {total: total}]); |
| 3522 | }); |
| 3523 | |
| 3524 | runner.on(EVENT_TEST_PASS, function(test) { |
| 3525 | writeEvent(['pass', clean(test)]); |
| 3526 | }); |
| 3527 | |
| 3528 | runner.on(EVENT_TEST_FAIL, function(test, err) { |
| 3529 | test = clean(test); |
| 3530 | test.err = err.message; |
| 3531 | test.stack = err.stack || null; |
| 3532 | writeEvent(['fail', test]); |
| 3533 | }); |
| 3534 | |
| 3535 | runner.once(EVENT_RUN_END, function() { |
| 3536 | writeEvent(['end', self.stats]); |
| 3537 | }); |
| 3538 | } |
| 3539 | |
| 3540 | /** |
| 3541 | * Mocha event to be written to the output stream. |
| 3542 | * @typedef {Array} JSONStream~MochaEvent |
| 3543 | */ |
| 3544 | |
| 3545 | /** |
| 3546 | * Writes Mocha event to reporter output stream. |
| 3547 | * |
| 3548 | * @private |
| 3549 | * @param {JSONStream~MochaEvent} event - Mocha event to be output. |
| 3550 | */ |
| 3551 | function writeEvent(event) { |
| 3552 | process.stdout.write(JSON.stringify(event) + '\n'); |
| 3553 | } |
| 3554 | |
| 3555 | /** |
| 3556 | * Returns an object literal representation of `test` |
| 3557 | * free of cyclic properties, etc. |
| 3558 | * |
| 3559 | * @private |
| 3560 | * @param {Test} test - Instance used as data source. |
| 3561 | * @return {Object} object containing pared-down test instance data |
| 3562 | */ |
| 3563 | function clean(test) { |
| 3564 | return { |
| 3565 | title: test.title, |
| 3566 | fullTitle: test.fullTitle(), |
| 3567 | duration: test.duration, |
| 3568 | currentRetry: test.currentRetry() |
| 3569 | }; |
| 3570 | } |
| 3571 | |
| 3572 | JSONStream.description = 'newline delimited JSON events'; |
| 3573 | |
| 3574 | }).call(this,require('_process')) |
| 3575 | },{"../runner":34,"./base":17,"_process":69}],23:[function(require,module,exports){ |
| 3576 | (function (process){ |
| 3577 | 'use strict'; |
| 3578 | /** |
| 3579 | * @module JSON |
| 3580 | */ |
| 3581 | /** |
| 3582 | * Module dependencies. |
| 3583 | */ |
| 3584 | |
| 3585 | var Base = require('./base'); |
| 3586 | var constants = require('../runner').constants; |
| 3587 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 3588 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 3589 | var EVENT_TEST_END = constants.EVENT_TEST_END; |
| 3590 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 3591 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 3592 | |
| 3593 | /** |
| 3594 | * Expose `JSON`. |
| 3595 | */ |
| 3596 | |
| 3597 | exports = module.exports = JSONReporter; |
| 3598 | |
| 3599 | /** |
| 3600 | * Constructs a new `JSON` reporter instance. |
| 3601 | * |
| 3602 | * @public |
| 3603 | * @class JSON |
| 3604 | * @memberof Mocha.reporters |
| 3605 | * @extends Mocha.reporters.Base |
| 3606 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3607 | * @param {Object} [options] - runner options |
| 3608 | */ |
| 3609 | function JSONReporter(runner, options) { |
| 3610 | Base.call(this, runner, options); |
| 3611 | |
| 3612 | var self = this; |
| 3613 | var tests = []; |
| 3614 | var pending = []; |
| 3615 | var failures = []; |
| 3616 | var passes = []; |
| 3617 | |
| 3618 | runner.on(EVENT_TEST_END, function(test) { |
| 3619 | tests.push(test); |
| 3620 | }); |
| 3621 | |
| 3622 | runner.on(EVENT_TEST_PASS, function(test) { |
| 3623 | passes.push(test); |
| 3624 | }); |
| 3625 | |
| 3626 | runner.on(EVENT_TEST_FAIL, function(test) { |
| 3627 | failures.push(test); |
| 3628 | }); |
| 3629 | |
| 3630 | runner.on(EVENT_TEST_PENDING, function(test) { |
| 3631 | pending.push(test); |
| 3632 | }); |
| 3633 | |
| 3634 | runner.once(EVENT_RUN_END, function() { |
| 3635 | var obj = { |
| 3636 | stats: self.stats, |
| 3637 | tests: tests.map(clean), |
| 3638 | pending: pending.map(clean), |
| 3639 | failures: failures.map(clean), |
| 3640 | passes: passes.map(clean) |
| 3641 | }; |
| 3642 | |
| 3643 | runner.testResults = obj; |
| 3644 | |
| 3645 | process.stdout.write(JSON.stringify(obj, null, 2)); |
| 3646 | }); |
| 3647 | } |
| 3648 | |
| 3649 | /** |
| 3650 | * Return a plain-object representation of `test` |
| 3651 | * free of cyclic properties etc. |
| 3652 | * |
| 3653 | * @private |
| 3654 | * @param {Object} test |
| 3655 | * @return {Object} |
| 3656 | */ |
| 3657 | function clean(test) { |
| 3658 | var err = test.err || {}; |
| 3659 | if (err instanceof Error) { |
| 3660 | err = errorJSON(err); |
| 3661 | } |
| 3662 | |
| 3663 | return { |
| 3664 | title: test.title, |
| 3665 | fullTitle: test.fullTitle(), |
| 3666 | duration: test.duration, |
| 3667 | currentRetry: test.currentRetry(), |
| 3668 | err: cleanCycles(err) |
| 3669 | }; |
| 3670 | } |
| 3671 | |
| 3672 | /** |
| 3673 | * Replaces any circular references inside `obj` with '[object Object]' |
| 3674 | * |
| 3675 | * @private |
| 3676 | * @param {Object} obj |
| 3677 | * @return {Object} |
| 3678 | */ |
| 3679 | function cleanCycles(obj) { |
| 3680 | var cache = []; |
| 3681 | return JSON.parse( |
| 3682 | JSON.stringify(obj, function(key, value) { |
| 3683 | if (typeof value === 'object' && value !== null) { |
| 3684 | if (cache.indexOf(value) !== -1) { |
| 3685 | // Instead of going in a circle, we'll print [object Object] |
| 3686 | return '' + value; |
| 3687 | } |
| 3688 | cache.push(value); |
| 3689 | } |
| 3690 | |
| 3691 | return value; |
| 3692 | }) |
| 3693 | ); |
| 3694 | } |
| 3695 | |
| 3696 | /** |
| 3697 | * Transform an Error object into a JSON object. |
| 3698 | * |
| 3699 | * @private |
| 3700 | * @param {Error} err |
| 3701 | * @return {Object} |
| 3702 | */ |
| 3703 | function errorJSON(err) { |
| 3704 | var res = {}; |
| 3705 | Object.getOwnPropertyNames(err).forEach(function(key) { |
| 3706 | res[key] = err[key]; |
| 3707 | }, err); |
| 3708 | return res; |
| 3709 | } |
| 3710 | |
| 3711 | JSONReporter.description = 'single JSON object'; |
| 3712 | |
| 3713 | }).call(this,require('_process')) |
| 3714 | },{"../runner":34,"./base":17,"_process":69}],24:[function(require,module,exports){ |
| 3715 | (function (process){ |
| 3716 | 'use strict'; |
| 3717 | /** |
| 3718 | * @module Landing |
| 3719 | */ |
| 3720 | /** |
| 3721 | * Module dependencies. |
| 3722 | */ |
| 3723 | |
| 3724 | var Base = require('./base'); |
| 3725 | var inherits = require('../utils').inherits; |
| 3726 | var constants = require('../runner').constants; |
| 3727 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 3728 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 3729 | var EVENT_TEST_END = constants.EVENT_TEST_END; |
| 3730 | var STATE_FAILED = require('../runnable').constants.STATE_FAILED; |
| 3731 | |
| 3732 | var cursor = Base.cursor; |
| 3733 | var color = Base.color; |
| 3734 | |
| 3735 | /** |
| 3736 | * Expose `Landing`. |
| 3737 | */ |
| 3738 | |
| 3739 | exports = module.exports = Landing; |
| 3740 | |
| 3741 | /** |
| 3742 | * Airplane color. |
| 3743 | */ |
| 3744 | |
| 3745 | Base.colors.plane = 0; |
| 3746 | |
| 3747 | /** |
| 3748 | * Airplane crash color. |
| 3749 | */ |
| 3750 | |
| 3751 | Base.colors['plane crash'] = 31; |
| 3752 | |
| 3753 | /** |
| 3754 | * Runway color. |
| 3755 | */ |
| 3756 | |
| 3757 | Base.colors.runway = 90; |
| 3758 | |
| 3759 | /** |
| 3760 | * Constructs a new `Landing` reporter instance. |
| 3761 | * |
| 3762 | * @public |
| 3763 | * @class |
| 3764 | * @memberof Mocha.reporters |
| 3765 | * @extends Mocha.reporters.Base |
| 3766 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3767 | * @param {Object} [options] - runner options |
| 3768 | */ |
| 3769 | function Landing(runner, options) { |
| 3770 | Base.call(this, runner, options); |
| 3771 | |
| 3772 | var self = this; |
| 3773 | var width = (Base.window.width * 0.75) | 0; |
| 3774 | var total = runner.total; |
| 3775 | var stream = process.stdout; |
| 3776 | var plane = color('plane', '✈'); |
| 3777 | var crashed = -1; |
| 3778 | var n = 0; |
| 3779 | |
| 3780 | function runway() { |
| 3781 | var buf = Array(width).join('-'); |
| 3782 | return ' ' + color('runway', buf); |
| 3783 | } |
| 3784 | |
| 3785 | runner.on(EVENT_RUN_BEGIN, function() { |
| 3786 | stream.write('\n\n\n '); |
| 3787 | cursor.hide(); |
| 3788 | }); |
| 3789 | |
| 3790 | runner.on(EVENT_TEST_END, function(test) { |
| 3791 | // check if the plane crashed |
| 3792 | var col = crashed === -1 ? ((width * ++n) / total) | 0 : crashed; |
| 3793 | |
| 3794 | // show the crash |
| 3795 | if (test.state === STATE_FAILED) { |
| 3796 | plane = color('plane crash', '✈'); |
| 3797 | crashed = col; |
| 3798 | } |
| 3799 | |
| 3800 | // render landing strip |
| 3801 | stream.write('\u001b[' + (width + 1) + 'D\u001b[2A'); |
| 3802 | stream.write(runway()); |
| 3803 | stream.write('\n '); |
| 3804 | stream.write(color('runway', Array(col).join('⋅'))); |
| 3805 | stream.write(plane); |
| 3806 | stream.write(color('runway', Array(width - col).join('⋅') + '\n')); |
| 3807 | stream.write(runway()); |
| 3808 | stream.write('\u001b[0m'); |
| 3809 | }); |
| 3810 | |
| 3811 | runner.once(EVENT_RUN_END, function() { |
| 3812 | cursor.show(); |
| 3813 | process.stdout.write('\n'); |
| 3814 | self.epilogue(); |
| 3815 | }); |
| 3816 | } |
| 3817 | |
| 3818 | /** |
| 3819 | * Inherit from `Base.prototype`. |
| 3820 | */ |
| 3821 | inherits(Landing, Base); |
| 3822 | |
| 3823 | Landing.description = 'Unicode landing strip'; |
| 3824 | |
| 3825 | }).call(this,require('_process')) |
| 3826 | },{"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":69}],25:[function(require,module,exports){ |
| 3827 | (function (process){ |
| 3828 | 'use strict'; |
| 3829 | /** |
| 3830 | * @module List |
| 3831 | */ |
| 3832 | /** |
| 3833 | * Module dependencies. |
| 3834 | */ |
| 3835 | |
| 3836 | var Base = require('./base'); |
| 3837 | var inherits = require('../utils').inherits; |
| 3838 | var constants = require('../runner').constants; |
| 3839 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 3840 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 3841 | var EVENT_TEST_BEGIN = constants.EVENT_TEST_BEGIN; |
| 3842 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 3843 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 3844 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 3845 | var color = Base.color; |
| 3846 | var cursor = Base.cursor; |
| 3847 | |
| 3848 | /** |
| 3849 | * Expose `List`. |
| 3850 | */ |
| 3851 | |
| 3852 | exports = module.exports = List; |
| 3853 | |
| 3854 | /** |
| 3855 | * Constructs a new `List` reporter instance. |
| 3856 | * |
| 3857 | * @public |
| 3858 | * @class |
| 3859 | * @memberof Mocha.reporters |
| 3860 | * @extends Mocha.reporters.Base |
| 3861 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3862 | * @param {Object} [options] - runner options |
| 3863 | */ |
| 3864 | function List(runner, options) { |
| 3865 | Base.call(this, runner, options); |
| 3866 | |
| 3867 | var self = this; |
| 3868 | var n = 0; |
| 3869 | |
| 3870 | runner.on(EVENT_RUN_BEGIN, function() { |
| 3871 | Base.consoleLog(); |
| 3872 | }); |
| 3873 | |
| 3874 | runner.on(EVENT_TEST_BEGIN, function(test) { |
| 3875 | process.stdout.write(color('pass', ' ' + test.fullTitle() + ': ')); |
| 3876 | }); |
| 3877 | |
| 3878 | runner.on(EVENT_TEST_PENDING, function(test) { |
| 3879 | var fmt = color('checkmark', ' -') + color('pending', ' %s'); |
| 3880 | Base.consoleLog(fmt, test.fullTitle()); |
| 3881 | }); |
| 3882 | |
| 3883 | runner.on(EVENT_TEST_PASS, function(test) { |
| 3884 | var fmt = |
| 3885 | color('checkmark', ' ' + Base.symbols.ok) + |
| 3886 | color('pass', ' %s: ') + |
| 3887 | color(test.speed, '%dms'); |
| 3888 | cursor.CR(); |
| 3889 | Base.consoleLog(fmt, test.fullTitle(), test.duration); |
| 3890 | }); |
| 3891 | |
| 3892 | runner.on(EVENT_TEST_FAIL, function(test) { |
| 3893 | cursor.CR(); |
| 3894 | Base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle()); |
| 3895 | }); |
| 3896 | |
| 3897 | runner.once(EVENT_RUN_END, self.epilogue.bind(self)); |
| 3898 | } |
| 3899 | |
| 3900 | /** |
| 3901 | * Inherit from `Base.prototype`. |
| 3902 | */ |
| 3903 | inherits(List, Base); |
| 3904 | |
| 3905 | List.description = 'like "spec" reporter but flat'; |
| 3906 | |
| 3907 | }).call(this,require('_process')) |
| 3908 | },{"../runner":34,"../utils":38,"./base":17,"_process":69}],26:[function(require,module,exports){ |
| 3909 | (function (process){ |
| 3910 | 'use strict'; |
| 3911 | /** |
| 3912 | * @module Markdown |
| 3913 | */ |
| 3914 | /** |
| 3915 | * Module dependencies. |
| 3916 | */ |
| 3917 | |
| 3918 | var Base = require('./base'); |
| 3919 | var utils = require('../utils'); |
| 3920 | var constants = require('../runner').constants; |
| 3921 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 3922 | var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; |
| 3923 | var EVENT_SUITE_END = constants.EVENT_SUITE_END; |
| 3924 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 3925 | |
| 3926 | /** |
| 3927 | * Constants |
| 3928 | */ |
| 3929 | |
| 3930 | var SUITE_PREFIX = '$'; |
| 3931 | |
| 3932 | /** |
| 3933 | * Expose `Markdown`. |
| 3934 | */ |
| 3935 | |
| 3936 | exports = module.exports = Markdown; |
| 3937 | |
| 3938 | /** |
| 3939 | * Constructs a new `Markdown` reporter instance. |
| 3940 | * |
| 3941 | * @public |
| 3942 | * @class |
| 3943 | * @memberof Mocha.reporters |
| 3944 | * @extends Mocha.reporters.Base |
| 3945 | * @param {Runner} runner - Instance triggers reporter actions. |
| 3946 | * @param {Object} [options] - runner options |
| 3947 | */ |
| 3948 | function Markdown(runner, options) { |
| 3949 | Base.call(this, runner, options); |
| 3950 | |
| 3951 | var level = 0; |
| 3952 | var buf = ''; |
| 3953 | |
| 3954 | function title(str) { |
| 3955 | return Array(level).join('#') + ' ' + str; |
| 3956 | } |
| 3957 | |
| 3958 | function mapTOC(suite, obj) { |
| 3959 | var ret = obj; |
| 3960 | var key = SUITE_PREFIX + suite.title; |
| 3961 | |
| 3962 | obj = obj[key] = obj[key] || {suite: suite}; |
| 3963 | suite.suites.forEach(function(suite) { |
| 3964 | mapTOC(suite, obj); |
| 3965 | }); |
| 3966 | |
| 3967 | return ret; |
| 3968 | } |
| 3969 | |
| 3970 | function stringifyTOC(obj, level) { |
| 3971 | ++level; |
| 3972 | var buf = ''; |
| 3973 | var link; |
| 3974 | for (var key in obj) { |
| 3975 | if (key === 'suite') { |
| 3976 | continue; |
| 3977 | } |
| 3978 | if (key !== SUITE_PREFIX) { |
| 3979 | link = ' - [' + key.substring(1) + ']'; |
| 3980 | link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n'; |
| 3981 | buf += Array(level).join(' ') + link; |
| 3982 | } |
| 3983 | buf += stringifyTOC(obj[key], level); |
| 3984 | } |
| 3985 | return buf; |
| 3986 | } |
| 3987 | |
| 3988 | function generateTOC(suite) { |
| 3989 | var obj = mapTOC(suite, {}); |
| 3990 | return stringifyTOC(obj, 0); |
| 3991 | } |
| 3992 | |
| 3993 | generateTOC(runner.suite); |
| 3994 | |
| 3995 | runner.on(EVENT_SUITE_BEGIN, function(suite) { |
| 3996 | ++level; |
| 3997 | var slug = utils.slug(suite.fullTitle()); |
| 3998 | buf += '<a name="' + slug + '"></a>' + '\n'; |
| 3999 | buf += title(suite.title) + '\n'; |
| 4000 | }); |
| 4001 | |
| 4002 | runner.on(EVENT_SUITE_END, function() { |
| 4003 | --level; |
| 4004 | }); |
| 4005 | |
| 4006 | runner.on(EVENT_TEST_PASS, function(test) { |
| 4007 | var code = utils.clean(test.body); |
| 4008 | buf += test.title + '.\n'; |
| 4009 | buf += '\n```js\n'; |
| 4010 | buf += code + '\n'; |
| 4011 | buf += '```\n\n'; |
| 4012 | }); |
| 4013 | |
| 4014 | runner.once(EVENT_RUN_END, function() { |
| 4015 | process.stdout.write('# TOC\n'); |
| 4016 | process.stdout.write(generateTOC(runner.suite)); |
| 4017 | process.stdout.write(buf); |
| 4018 | }); |
| 4019 | } |
| 4020 | |
| 4021 | Markdown.description = 'GitHub Flavored Markdown'; |
| 4022 | |
| 4023 | }).call(this,require('_process')) |
| 4024 | },{"../runner":34,"../utils":38,"./base":17,"_process":69}],27:[function(require,module,exports){ |
| 4025 | (function (process){ |
| 4026 | 'use strict'; |
| 4027 | /** |
| 4028 | * @module Min |
| 4029 | */ |
| 4030 | /** |
| 4031 | * Module dependencies. |
| 4032 | */ |
| 4033 | |
| 4034 | var Base = require('./base'); |
| 4035 | var inherits = require('../utils').inherits; |
| 4036 | var constants = require('../runner').constants; |
| 4037 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 4038 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 4039 | |
| 4040 | /** |
| 4041 | * Expose `Min`. |
| 4042 | */ |
| 4043 | |
| 4044 | exports = module.exports = Min; |
| 4045 | |
| 4046 | /** |
| 4047 | * Constructs a new `Min` reporter instance. |
| 4048 | * |
| 4049 | * @description |
| 4050 | * This minimal test reporter is best used with '--watch'. |
| 4051 | * |
| 4052 | * @public |
| 4053 | * @class |
| 4054 | * @memberof Mocha.reporters |
| 4055 | * @extends Mocha.reporters.Base |
| 4056 | * @param {Runner} runner - Instance triggers reporter actions. |
| 4057 | * @param {Object} [options] - runner options |
| 4058 | */ |
| 4059 | function Min(runner, options) { |
| 4060 | Base.call(this, runner, options); |
| 4061 | |
| 4062 | runner.on(EVENT_RUN_BEGIN, function() { |
| 4063 | // clear screen |
| 4064 | process.stdout.write('\u001b[2J'); |
| 4065 | // set cursor position |
| 4066 | process.stdout.write('\u001b[1;3H'); |
| 4067 | }); |
| 4068 | |
| 4069 | runner.once(EVENT_RUN_END, this.epilogue.bind(this)); |
| 4070 | } |
| 4071 | |
| 4072 | /** |
| 4073 | * Inherit from `Base.prototype`. |
| 4074 | */ |
| 4075 | inherits(Min, Base); |
| 4076 | |
| 4077 | Min.description = 'essentially just a summary'; |
| 4078 | |
| 4079 | }).call(this,require('_process')) |
| 4080 | },{"../runner":34,"../utils":38,"./base":17,"_process":69}],28:[function(require,module,exports){ |
| 4081 | (function (process){ |
| 4082 | 'use strict'; |
| 4083 | /** |
| 4084 | * @module Nyan |
| 4085 | */ |
| 4086 | /** |
| 4087 | * Module dependencies. |
| 4088 | */ |
| 4089 | |
| 4090 | var Base = require('./base'); |
| 4091 | var constants = require('../runner').constants; |
| 4092 | var inherits = require('../utils').inherits; |
| 4093 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 4094 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 4095 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 4096 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 4097 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 4098 | |
| 4099 | /** |
| 4100 | * Expose `Dot`. |
| 4101 | */ |
| 4102 | |
| 4103 | exports = module.exports = NyanCat; |
| 4104 | |
| 4105 | /** |
| 4106 | * Constructs a new `Nyan` reporter instance. |
| 4107 | * |
| 4108 | * @public |
| 4109 | * @class Nyan |
| 4110 | * @memberof Mocha.reporters |
| 4111 | * @extends Mocha.reporters.Base |
| 4112 | * @param {Runner} runner - Instance triggers reporter actions. |
| 4113 | * @param {Object} [options] - runner options |
| 4114 | */ |
| 4115 | function NyanCat(runner, options) { |
| 4116 | Base.call(this, runner, options); |
| 4117 | |
| 4118 | var self = this; |
| 4119 | var width = (Base.window.width * 0.75) | 0; |
| 4120 | var nyanCatWidth = (this.nyanCatWidth = 11); |
| 4121 | |
| 4122 | this.colorIndex = 0; |
| 4123 | this.numberOfLines = 4; |
| 4124 | this.rainbowColors = self.generateColors(); |
| 4125 | this.scoreboardWidth = 5; |
| 4126 | this.tick = 0; |
| 4127 | this.trajectories = [[], [], [], []]; |
| 4128 | this.trajectoryWidthMax = width - nyanCatWidth; |
| 4129 | |
| 4130 | runner.on(EVENT_RUN_BEGIN, function() { |
| 4131 | Base.cursor.hide(); |
| 4132 | self.draw(); |
| 4133 | }); |
| 4134 | |
| 4135 | runner.on(EVENT_TEST_PENDING, function() { |
| 4136 | self.draw(); |
| 4137 | }); |
| 4138 | |
| 4139 | runner.on(EVENT_TEST_PASS, function() { |
| 4140 | self.draw(); |
| 4141 | }); |
| 4142 | |
| 4143 | runner.on(EVENT_TEST_FAIL, function() { |
| 4144 | self.draw(); |
| 4145 | }); |
| 4146 | |
| 4147 | runner.once(EVENT_RUN_END, function() { |
| 4148 | Base.cursor.show(); |
| 4149 | for (var i = 0; i < self.numberOfLines; i++) { |
| 4150 | write('\n'); |
| 4151 | } |
| 4152 | self.epilogue(); |
| 4153 | }); |
| 4154 | } |
| 4155 | |
| 4156 | /** |
| 4157 | * Inherit from `Base.prototype`. |
| 4158 | */ |
| 4159 | inherits(NyanCat, Base); |
| 4160 | |
| 4161 | /** |
| 4162 | * Draw the nyan cat |
| 4163 | * |
| 4164 | * @private |
| 4165 | */ |
| 4166 | |
| 4167 | NyanCat.prototype.draw = function() { |
| 4168 | this.appendRainbow(); |
| 4169 | this.drawScoreboard(); |
| 4170 | this.drawRainbow(); |
| 4171 | this.drawNyanCat(); |
| 4172 | this.tick = !this.tick; |
| 4173 | }; |
| 4174 | |
| 4175 | /** |
| 4176 | * Draw the "scoreboard" showing the number |
| 4177 | * of passes, failures and pending tests. |
| 4178 | * |
| 4179 | * @private |
| 4180 | */ |
| 4181 | |
| 4182 | NyanCat.prototype.drawScoreboard = function() { |
| 4183 | var stats = this.stats; |
| 4184 | |
| 4185 | function draw(type, n) { |
| 4186 | write(' '); |
| 4187 | write(Base.color(type, n)); |
| 4188 | write('\n'); |
| 4189 | } |
| 4190 | |
| 4191 | draw('green', stats.passes); |
| 4192 | draw('fail', stats.failures); |
| 4193 | draw('pending', stats.pending); |
| 4194 | write('\n'); |
| 4195 | |
| 4196 | this.cursorUp(this.numberOfLines); |
| 4197 | }; |
| 4198 | |
| 4199 | /** |
| 4200 | * Append the rainbow. |
| 4201 | * |
| 4202 | * @private |
| 4203 | */ |
| 4204 | |
| 4205 | NyanCat.prototype.appendRainbow = function() { |
| 4206 | var segment = this.tick ? '_' : '-'; |
| 4207 | var rainbowified = this.rainbowify(segment); |
| 4208 | |
| 4209 | for (var index = 0; index < this.numberOfLines; index++) { |
| 4210 | var trajectory = this.trajectories[index]; |
| 4211 | if (trajectory.length >= this.trajectoryWidthMax) { |
| 4212 | trajectory.shift(); |
| 4213 | } |
| 4214 | trajectory.push(rainbowified); |
| 4215 | } |
| 4216 | }; |
| 4217 | |
| 4218 | /** |
| 4219 | * Draw the rainbow. |
| 4220 | * |
| 4221 | * @private |
| 4222 | */ |
| 4223 | |
| 4224 | NyanCat.prototype.drawRainbow = function() { |
| 4225 | var self = this; |
| 4226 | |
| 4227 | this.trajectories.forEach(function(line) { |
| 4228 | write('\u001b[' + self.scoreboardWidth + 'C'); |
| 4229 | write(line.join('')); |
| 4230 | write('\n'); |
| 4231 | }); |
| 4232 | |
| 4233 | this.cursorUp(this.numberOfLines); |
| 4234 | }; |
| 4235 | |
| 4236 | /** |
| 4237 | * Draw the nyan cat |
| 4238 | * |
| 4239 | * @private |
| 4240 | */ |
| 4241 | NyanCat.prototype.drawNyanCat = function() { |
| 4242 | var self = this; |
| 4243 | var startWidth = this.scoreboardWidth + this.trajectories[0].length; |
| 4244 | var dist = '\u001b[' + startWidth + 'C'; |
| 4245 | var padding = ''; |
| 4246 | |
| 4247 | write(dist); |
| 4248 | write('_,------,'); |
| 4249 | write('\n'); |
| 4250 | |
| 4251 | write(dist); |
| 4252 | padding = self.tick ? ' ' : ' '; |
| 4253 | write('_|' + padding + '/\\_/\\ '); |
| 4254 | write('\n'); |
| 4255 | |
| 4256 | write(dist); |
| 4257 | padding = self.tick ? '_' : '__'; |
| 4258 | var tail = self.tick ? '~' : '^'; |
| 4259 | write(tail + '|' + padding + this.face() + ' '); |
| 4260 | write('\n'); |
| 4261 | |
| 4262 | write(dist); |
| 4263 | padding = self.tick ? ' ' : ' '; |
| 4264 | write(padding + '"" "" '); |
| 4265 | write('\n'); |
| 4266 | |
| 4267 | this.cursorUp(this.numberOfLines); |
| 4268 | }; |
| 4269 | |
| 4270 | /** |
| 4271 | * Draw nyan cat face. |
| 4272 | * |
| 4273 | * @private |
| 4274 | * @return {string} |
| 4275 | */ |
| 4276 | |
| 4277 | NyanCat.prototype.face = function() { |
| 4278 | var stats = this.stats; |
| 4279 | if (stats.failures) { |
| 4280 | return '( x .x)'; |
| 4281 | } else if (stats.pending) { |
| 4282 | return '( o .o)'; |
| 4283 | } else if (stats.passes) { |
| 4284 | return '( ^ .^)'; |
| 4285 | } |
| 4286 | return '( - .-)'; |
| 4287 | }; |
| 4288 | |
| 4289 | /** |
| 4290 | * Move cursor up `n`. |
| 4291 | * |
| 4292 | * @private |
| 4293 | * @param {number} n |
| 4294 | */ |
| 4295 | |
| 4296 | NyanCat.prototype.cursorUp = function(n) { |
| 4297 | write('\u001b[' + n + 'A'); |
| 4298 | }; |
| 4299 | |
| 4300 | /** |
| 4301 | * Move cursor down `n`. |
| 4302 | * |
| 4303 | * @private |
| 4304 | * @param {number} n |
| 4305 | */ |
| 4306 | |
| 4307 | NyanCat.prototype.cursorDown = function(n) { |
| 4308 | write('\u001b[' + n + 'B'); |
| 4309 | }; |
| 4310 | |
| 4311 | /** |
| 4312 | * Generate rainbow colors. |
| 4313 | * |
| 4314 | * @private |
| 4315 | * @return {Array} |
| 4316 | */ |
| 4317 | NyanCat.prototype.generateColors = function() { |
| 4318 | var colors = []; |
| 4319 | |
| 4320 | for (var i = 0; i < 6 * 7; i++) { |
| 4321 | var pi3 = Math.floor(Math.PI / 3); |
| 4322 | var n = i * (1.0 / 6); |
| 4323 | var r = Math.floor(3 * Math.sin(n) + 3); |
| 4324 | var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3); |
| 4325 | var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3); |
| 4326 | colors.push(36 * r + 6 * g + b + 16); |
| 4327 | } |
| 4328 | |
| 4329 | return colors; |
| 4330 | }; |
| 4331 | |
| 4332 | /** |
| 4333 | * Apply rainbow to the given `str`. |
| 4334 | * |
| 4335 | * @private |
| 4336 | * @param {string} str |
| 4337 | * @return {string} |
| 4338 | */ |
| 4339 | NyanCat.prototype.rainbowify = function(str) { |
| 4340 | if (!Base.useColors) { |
| 4341 | return str; |
| 4342 | } |
| 4343 | var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length]; |
| 4344 | this.colorIndex += 1; |
| 4345 | return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m'; |
| 4346 | }; |
| 4347 | |
| 4348 | /** |
| 4349 | * Stdout helper. |
| 4350 | * |
| 4351 | * @param {string} string A message to write to stdout. |
| 4352 | */ |
| 4353 | function write(string) { |
| 4354 | process.stdout.write(string); |
| 4355 | } |
| 4356 | |
| 4357 | NyanCat.description = '"nyan cat"'; |
| 4358 | |
| 4359 | }).call(this,require('_process')) |
| 4360 | },{"../runner":34,"../utils":38,"./base":17,"_process":69}],29:[function(require,module,exports){ |
| 4361 | (function (process){ |
| 4362 | 'use strict'; |
| 4363 | /** |
| 4364 | * @module Progress |
| 4365 | */ |
| 4366 | /** |
| 4367 | * Module dependencies. |
| 4368 | */ |
| 4369 | |
| 4370 | var Base = require('./base'); |
| 4371 | var constants = require('../runner').constants; |
| 4372 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 4373 | var EVENT_TEST_END = constants.EVENT_TEST_END; |
| 4374 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 4375 | var inherits = require('../utils').inherits; |
| 4376 | var color = Base.color; |
| 4377 | var cursor = Base.cursor; |
| 4378 | |
| 4379 | /** |
| 4380 | * Expose `Progress`. |
| 4381 | */ |
| 4382 | |
| 4383 | exports = module.exports = Progress; |
| 4384 | |
| 4385 | /** |
| 4386 | * General progress bar color. |
| 4387 | */ |
| 4388 | |
| 4389 | Base.colors.progress = 90; |
| 4390 | |
| 4391 | /** |
| 4392 | * Constructs a new `Progress` reporter instance. |
| 4393 | * |
| 4394 | * @public |
| 4395 | * @class |
| 4396 | * @memberof Mocha.reporters |
| 4397 | * @extends Mocha.reporters.Base |
| 4398 | * @param {Runner} runner - Instance triggers reporter actions. |
| 4399 | * @param {Object} [options] - runner options |
| 4400 | */ |
| 4401 | function Progress(runner, options) { |
| 4402 | Base.call(this, runner, options); |
| 4403 | |
| 4404 | var self = this; |
| 4405 | var width = (Base.window.width * 0.5) | 0; |
| 4406 | var total = runner.total; |
| 4407 | var complete = 0; |
| 4408 | var lastN = -1; |
| 4409 | |
| 4410 | // default chars |
| 4411 | options = options || {}; |
| 4412 | var reporterOptions = options.reporterOptions || {}; |
| 4413 | |
| 4414 | options.open = reporterOptions.open || '['; |
| 4415 | options.complete = reporterOptions.complete || '▬'; |
| 4416 | options.incomplete = reporterOptions.incomplete || Base.symbols.dot; |
| 4417 | options.close = reporterOptions.close || ']'; |
| 4418 | options.verbose = reporterOptions.verbose || false; |
| 4419 | |
| 4420 | // tests started |
| 4421 | runner.on(EVENT_RUN_BEGIN, function() { |
| 4422 | process.stdout.write('\n'); |
| 4423 | cursor.hide(); |
| 4424 | }); |
| 4425 | |
| 4426 | // tests complete |
| 4427 | runner.on(EVENT_TEST_END, function() { |
| 4428 | complete++; |
| 4429 | |
| 4430 | var percent = complete / total; |
| 4431 | var n = (width * percent) | 0; |
| 4432 | var i = width - n; |
| 4433 | |
| 4434 | if (n === lastN && !options.verbose) { |
| 4435 | // Don't re-render the line if it hasn't changed |
| 4436 | return; |
| 4437 | } |
| 4438 | lastN = n; |
| 4439 | |
| 4440 | cursor.CR(); |
| 4441 | process.stdout.write('\u001b[J'); |
| 4442 | process.stdout.write(color('progress', ' ' + options.open)); |
| 4443 | process.stdout.write(Array(n).join(options.complete)); |
| 4444 | process.stdout.write(Array(i).join(options.incomplete)); |
| 4445 | process.stdout.write(color('progress', options.close)); |
| 4446 | if (options.verbose) { |
| 4447 | process.stdout.write(color('progress', ' ' + complete + ' of ' + total)); |
| 4448 | } |
| 4449 | }); |
| 4450 | |
| 4451 | // tests are complete, output some stats |
| 4452 | // and the failures if any |
| 4453 | runner.once(EVENT_RUN_END, function() { |
| 4454 | cursor.show(); |
| 4455 | process.stdout.write('\n'); |
| 4456 | self.epilogue(); |
| 4457 | }); |
| 4458 | } |
| 4459 | |
| 4460 | /** |
| 4461 | * Inherit from `Base.prototype`. |
| 4462 | */ |
| 4463 | inherits(Progress, Base); |
| 4464 | |
| 4465 | Progress.description = 'a progress bar'; |
| 4466 | |
| 4467 | }).call(this,require('_process')) |
| 4468 | },{"../runner":34,"../utils":38,"./base":17,"_process":69}],30:[function(require,module,exports){ |
| 4469 | 'use strict'; |
| 4470 | /** |
| 4471 | * @module Spec |
| 4472 | */ |
| 4473 | /** |
| 4474 | * Module dependencies. |
| 4475 | */ |
| 4476 | |
| 4477 | var Base = require('./base'); |
| 4478 | var constants = require('../runner').constants; |
| 4479 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 4480 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 4481 | var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; |
| 4482 | var EVENT_SUITE_END = constants.EVENT_SUITE_END; |
| 4483 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 4484 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 4485 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 4486 | var inherits = require('../utils').inherits; |
| 4487 | var color = Base.color; |
| 4488 | |
| 4489 | /** |
| 4490 | * Expose `Spec`. |
| 4491 | */ |
| 4492 | |
| 4493 | exports = module.exports = Spec; |
| 4494 | |
| 4495 | /** |
| 4496 | * Constructs a new `Spec` reporter instance. |
| 4497 | * |
| 4498 | * @public |
| 4499 | * @class |
| 4500 | * @memberof Mocha.reporters |
| 4501 | * @extends Mocha.reporters.Base |
| 4502 | * @param {Runner} runner - Instance triggers reporter actions. |
| 4503 | * @param {Object} [options] - runner options |
| 4504 | */ |
| 4505 | function Spec(runner, options) { |
| 4506 | Base.call(this, runner, options); |
| 4507 | |
| 4508 | var self = this; |
| 4509 | var indents = 0; |
| 4510 | var n = 0; |
| 4511 | |
| 4512 | function indent() { |
| 4513 | return Array(indents).join(' '); |
| 4514 | } |
| 4515 | |
| 4516 | runner.on(EVENT_RUN_BEGIN, function() { |
| 4517 | Base.consoleLog(); |
| 4518 | }); |
| 4519 | |
| 4520 | runner.on(EVENT_SUITE_BEGIN, function(suite) { |
| 4521 | ++indents; |
| 4522 | Base.consoleLog(color('suite', '%s%s'), indent(), suite.title); |
| 4523 | }); |
| 4524 | |
| 4525 | runner.on(EVENT_SUITE_END, function() { |
| 4526 | --indents; |
| 4527 | if (indents === 1) { |
| 4528 | Base.consoleLog(); |
| 4529 | } |
| 4530 | }); |
| 4531 | |
| 4532 | runner.on(EVENT_TEST_PENDING, function(test) { |
| 4533 | var fmt = indent() + color('pending', ' - %s'); |
| 4534 | Base.consoleLog(fmt, test.title); |
| 4535 | }); |
| 4536 | |
| 4537 | runner.on(EVENT_TEST_PASS, function(test) { |
| 4538 | var fmt; |
| 4539 | if (test.speed === 'fast') { |
| 4540 | fmt = |
| 4541 | indent() + |
| 4542 | color('checkmark', ' ' + Base.symbols.ok) + |
| 4543 | color('pass', ' %s'); |
| 4544 | Base.consoleLog(fmt, test.title); |
| 4545 | } else { |
| 4546 | fmt = |
| 4547 | indent() + |
| 4548 | color('checkmark', ' ' + Base.symbols.ok) + |
| 4549 | color('pass', ' %s') + |
| 4550 | color(test.speed, ' (%dms)'); |
| 4551 | Base.consoleLog(fmt, test.title, test.duration); |
| 4552 | } |
| 4553 | }); |
| 4554 | |
| 4555 | runner.on(EVENT_TEST_FAIL, function(test) { |
| 4556 | Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title); |
| 4557 | }); |
| 4558 | |
| 4559 | runner.once(EVENT_RUN_END, self.epilogue.bind(self)); |
| 4560 | } |
| 4561 | |
| 4562 | /** |
| 4563 | * Inherit from `Base.prototype`. |
| 4564 | */ |
| 4565 | inherits(Spec, Base); |
| 4566 | |
| 4567 | Spec.description = 'hierarchical & verbose [default]'; |
| 4568 | |
| 4569 | },{"../runner":34,"../utils":38,"./base":17}],31:[function(require,module,exports){ |
| 4570 | (function (process){ |
| 4571 | 'use strict'; |
| 4572 | /** |
| 4573 | * @module TAP |
| 4574 | */ |
| 4575 | /** |
| 4576 | * Module dependencies. |
| 4577 | */ |
| 4578 | |
| 4579 | var util = require('util'); |
| 4580 | var Base = require('./base'); |
| 4581 | var constants = require('../runner').constants; |
| 4582 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 4583 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 4584 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 4585 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 4586 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 4587 | var EVENT_TEST_END = constants.EVENT_TEST_END; |
| 4588 | var inherits = require('../utils').inherits; |
| 4589 | var sprintf = util.format; |
| 4590 | |
| 4591 | /** |
| 4592 | * Expose `TAP`. |
| 4593 | */ |
| 4594 | |
| 4595 | exports = module.exports = TAP; |
| 4596 | |
| 4597 | /** |
| 4598 | * Constructs a new `TAP` reporter instance. |
| 4599 | * |
| 4600 | * @public |
| 4601 | * @class |
| 4602 | * @memberof Mocha.reporters |
| 4603 | * @extends Mocha.reporters.Base |
| 4604 | * @param {Runner} runner - Instance triggers reporter actions. |
| 4605 | * @param {Object} [options] - runner options |
| 4606 | */ |
| 4607 | function TAP(runner, options) { |
| 4608 | Base.call(this, runner, options); |
| 4609 | |
| 4610 | var self = this; |
| 4611 | var n = 1; |
| 4612 | |
| 4613 | var tapVersion = '12'; |
| 4614 | if (options && options.reporterOptions) { |
| 4615 | if (options.reporterOptions.tapVersion) { |
| 4616 | tapVersion = options.reporterOptions.tapVersion.toString(); |
| 4617 | } |
| 4618 | } |
| 4619 | |
| 4620 | this._producer = createProducer(tapVersion); |
| 4621 | |
| 4622 | runner.once(EVENT_RUN_BEGIN, function() { |
| 4623 | var ntests = runner.grepTotal(runner.suite); |
| 4624 | self._producer.writeVersion(); |
| 4625 | self._producer.writePlan(ntests); |
| 4626 | }); |
| 4627 | |
| 4628 | runner.on(EVENT_TEST_END, function() { |
| 4629 | ++n; |
| 4630 | }); |
| 4631 | |
| 4632 | runner.on(EVENT_TEST_PENDING, function(test) { |
| 4633 | self._producer.writePending(n, test); |
| 4634 | }); |
| 4635 | |
| 4636 | runner.on(EVENT_TEST_PASS, function(test) { |
| 4637 | self._producer.writePass(n, test); |
| 4638 | }); |
| 4639 | |
| 4640 | runner.on(EVENT_TEST_FAIL, function(test, err) { |
| 4641 | self._producer.writeFail(n, test, err); |
| 4642 | }); |
| 4643 | |
| 4644 | runner.once(EVENT_RUN_END, function() { |
| 4645 | self._producer.writeEpilogue(runner.stats); |
| 4646 | }); |
| 4647 | } |
| 4648 | |
| 4649 | /** |
| 4650 | * Inherit from `Base.prototype`. |
| 4651 | */ |
| 4652 | inherits(TAP, Base); |
| 4653 | |
| 4654 | /** |
| 4655 | * Returns a TAP-safe title of `test`. |
| 4656 | * |
| 4657 | * @private |
| 4658 | * @param {Test} test - Test instance. |
| 4659 | * @return {String} title with any hash character removed |
| 4660 | */ |
| 4661 | function title(test) { |
| 4662 | return test.fullTitle().replace(/#/g, ''); |
| 4663 | } |
| 4664 | |
| 4665 | /** |
| 4666 | * Writes newline-terminated formatted string to reporter output stream. |
| 4667 | * |
| 4668 | * @private |
| 4669 | * @param {string} format - `printf`-like format string |
| 4670 | * @param {...*} [varArgs] - Format string arguments |
| 4671 | */ |
| 4672 | function println(format, varArgs) { |
| 4673 | var vargs = Array.from(arguments); |
| 4674 | vargs[0] += '\n'; |
| 4675 | process.stdout.write(sprintf.apply(null, vargs)); |
| 4676 | } |
| 4677 | |
| 4678 | /** |
| 4679 | * Returns a `tapVersion`-appropriate TAP producer instance, if possible. |
| 4680 | * |
| 4681 | * @private |
| 4682 | * @param {string} tapVersion - Version of TAP specification to produce. |
| 4683 | * @returns {TAPProducer} specification-appropriate instance |
| 4684 | * @throws {Error} if specification version has no associated producer. |
| 4685 | */ |
| 4686 | function createProducer(tapVersion) { |
| 4687 | var producers = { |
| 4688 | '12': new TAP12Producer(), |
| 4689 | '13': new TAP13Producer() |
| 4690 | }; |
| 4691 | var producer = producers[tapVersion]; |
| 4692 | |
| 4693 | if (!producer) { |
| 4694 | throw new Error( |
| 4695 | 'invalid or unsupported TAP version: ' + JSON.stringify(tapVersion) |
| 4696 | ); |
| 4697 | } |
| 4698 | |
| 4699 | return producer; |
| 4700 | } |
| 4701 | |
| 4702 | /** |
| 4703 | * @summary |
| 4704 | * Constructs a new TAPProducer. |
| 4705 | * |
| 4706 | * @description |
| 4707 | * <em>Only</em> to be used as an abstract base class. |
| 4708 | * |
| 4709 | * @private |
| 4710 | * @constructor |
| 4711 | */ |
| 4712 | function TAPProducer() {} |
| 4713 | |
| 4714 | /** |
| 4715 | * Writes the TAP version to reporter output stream. |
| 4716 | * |
| 4717 | * @abstract |
| 4718 | */ |
| 4719 | TAPProducer.prototype.writeVersion = function() {}; |
| 4720 | |
| 4721 | /** |
| 4722 | * Writes the plan to reporter output stream. |
| 4723 | * |
| 4724 | * @abstract |
| 4725 | * @param {number} ntests - Number of tests that are planned to run. |
| 4726 | */ |
| 4727 | TAPProducer.prototype.writePlan = function(ntests) { |
| 4728 | println('%d..%d', 1, ntests); |
| 4729 | }; |
| 4730 | |
| 4731 | /** |
| 4732 | * Writes that test passed to reporter output stream. |
| 4733 | * |
| 4734 | * @abstract |
| 4735 | * @param {number} n - Index of test that passed. |
| 4736 | * @param {Test} test - Instance containing test information. |
| 4737 | */ |
| 4738 | TAPProducer.prototype.writePass = function(n, test) { |
| 4739 | println('ok %d %s', n, title(test)); |
| 4740 | }; |
| 4741 | |
| 4742 | /** |
| 4743 | * Writes that test was skipped to reporter output stream. |
| 4744 | * |
| 4745 | * @abstract |
| 4746 | * @param {number} n - Index of test that was skipped. |
| 4747 | * @param {Test} test - Instance containing test information. |
| 4748 | */ |
| 4749 | TAPProducer.prototype.writePending = function(n, test) { |
| 4750 | println('ok %d %s # SKIP -', n, title(test)); |
| 4751 | }; |
| 4752 | |
| 4753 | /** |
| 4754 | * Writes that test failed to reporter output stream. |
| 4755 | * |
| 4756 | * @abstract |
| 4757 | * @param {number} n - Index of test that failed. |
| 4758 | * @param {Test} test - Instance containing test information. |
| 4759 | * @param {Error} err - Reason the test failed. |
| 4760 | */ |
| 4761 | TAPProducer.prototype.writeFail = function(n, test, err) { |
| 4762 | println('not ok %d %s', n, title(test)); |
| 4763 | }; |
| 4764 | |
| 4765 | /** |
| 4766 | * Writes the summary epilogue to reporter output stream. |
| 4767 | * |
| 4768 | * @abstract |
| 4769 | * @param {Object} stats - Object containing run statistics. |
| 4770 | */ |
| 4771 | TAPProducer.prototype.writeEpilogue = function(stats) { |
| 4772 | // :TBD: Why is this not counting pending tests? |
| 4773 | println('# tests ' + (stats.passes + stats.failures)); |
| 4774 | println('# pass ' + stats.passes); |
| 4775 | // :TBD: Why are we not showing pending results? |
| 4776 | println('# fail ' + stats.failures); |
| 4777 | }; |
| 4778 | |
| 4779 | /** |
| 4780 | * @summary |
| 4781 | * Constructs a new TAP12Producer. |
| 4782 | * |
| 4783 | * @description |
| 4784 | * Produces output conforming to the TAP12 specification. |
| 4785 | * |
| 4786 | * @private |
| 4787 | * @constructor |
| 4788 | * @extends TAPProducer |
| 4789 | * @see {@link https://testanything.org/tap-specification.html|Specification} |
| 4790 | */ |
| 4791 | function TAP12Producer() { |
| 4792 | /** |
| 4793 | * Writes that test failed to reporter output stream, with error formatting. |
| 4794 | * @override |
| 4795 | */ |
| 4796 | this.writeFail = function(n, test, err) { |
| 4797 | TAPProducer.prototype.writeFail.call(this, n, test, err); |
| 4798 | if (err.message) { |
| 4799 | println(err.message.replace(/^/gm, ' ')); |
| 4800 | } |
| 4801 | if (err.stack) { |
| 4802 | println(err.stack.replace(/^/gm, ' ')); |
| 4803 | } |
| 4804 | }; |
| 4805 | } |
| 4806 | |
| 4807 | /** |
| 4808 | * Inherit from `TAPProducer.prototype`. |
| 4809 | */ |
| 4810 | inherits(TAP12Producer, TAPProducer); |
| 4811 | |
| 4812 | /** |
| 4813 | * @summary |
| 4814 | * Constructs a new TAP13Producer. |
| 4815 | * |
| 4816 | * @description |
| 4817 | * Produces output conforming to the TAP13 specification. |
| 4818 | * |
| 4819 | * @private |
| 4820 | * @constructor |
| 4821 | * @extends TAPProducer |
| 4822 | * @see {@link https://testanything.org/tap-version-13-specification.html|Specification} |
| 4823 | */ |
| 4824 | function TAP13Producer() { |
| 4825 | /** |
| 4826 | * Writes the TAP version to reporter output stream. |
| 4827 | * @override |
| 4828 | */ |
| 4829 | this.writeVersion = function() { |
| 4830 | println('TAP version 13'); |
| 4831 | }; |
| 4832 | |
| 4833 | /** |
| 4834 | * Writes that test failed to reporter output stream, with error formatting. |
| 4835 | * @override |
| 4836 | */ |
| 4837 | this.writeFail = function(n, test, err) { |
| 4838 | TAPProducer.prototype.writeFail.call(this, n, test, err); |
| 4839 | var emitYamlBlock = err.message != null || err.stack != null; |
| 4840 | if (emitYamlBlock) { |
| 4841 | println(indent(1) + '---'); |
| 4842 | if (err.message) { |
| 4843 | println(indent(2) + 'message: |-'); |
| 4844 | println(err.message.replace(/^/gm, indent(3))); |
| 4845 | } |
| 4846 | if (err.stack) { |
| 4847 | println(indent(2) + 'stack: |-'); |
| 4848 | println(err.stack.replace(/^/gm, indent(3))); |
| 4849 | } |
| 4850 | println(indent(1) + '...'); |
| 4851 | } |
| 4852 | }; |
| 4853 | |
| 4854 | function indent(level) { |
| 4855 | return Array(level + 1).join(' '); |
| 4856 | } |
| 4857 | } |
| 4858 | |
| 4859 | /** |
| 4860 | * Inherit from `TAPProducer.prototype`. |
| 4861 | */ |
| 4862 | inherits(TAP13Producer, TAPProducer); |
| 4863 | |
| 4864 | TAP.description = 'TAP-compatible output'; |
| 4865 | |
| 4866 | }).call(this,require('_process')) |
| 4867 | },{"../runner":34,"../utils":38,"./base":17,"_process":69,"util":89}],32:[function(require,module,exports){ |
| 4868 | (function (process,global){ |
| 4869 | 'use strict'; |
| 4870 | /** |
| 4871 | * @module XUnit |
| 4872 | */ |
| 4873 | /** |
| 4874 | * Module dependencies. |
| 4875 | */ |
| 4876 | |
| 4877 | var Base = require('./base'); |
| 4878 | var utils = require('../utils'); |
| 4879 | var fs = require('fs'); |
| 4880 | var mkdirp = require('mkdirp'); |
| 4881 | var path = require('path'); |
| 4882 | var errors = require('../errors'); |
| 4883 | var createUnsupportedError = errors.createUnsupportedError; |
| 4884 | var constants = require('../runner').constants; |
| 4885 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 4886 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 4887 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 4888 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 4889 | var STATE_FAILED = require('../runnable').constants.STATE_FAILED; |
| 4890 | var inherits = utils.inherits; |
| 4891 | var escape = utils.escape; |
| 4892 | |
| 4893 | /** |
| 4894 | * Save timer references to avoid Sinon interfering (see GH-237). |
| 4895 | */ |
| 4896 | var Date = global.Date; |
| 4897 | |
| 4898 | /** |
| 4899 | * Expose `XUnit`. |
| 4900 | */ |
| 4901 | |
| 4902 | exports = module.exports = XUnit; |
| 4903 | |
| 4904 | /** |
| 4905 | * Constructs a new `XUnit` reporter instance. |
| 4906 | * |
| 4907 | * @public |
| 4908 | * @class |
| 4909 | * @memberof Mocha.reporters |
| 4910 | * @extends Mocha.reporters.Base |
| 4911 | * @param {Runner} runner - Instance triggers reporter actions. |
| 4912 | * @param {Object} [options] - runner options |
| 4913 | */ |
| 4914 | function XUnit(runner, options) { |
| 4915 | Base.call(this, runner, options); |
| 4916 | |
| 4917 | var stats = this.stats; |
| 4918 | var tests = []; |
| 4919 | var self = this; |
| 4920 | |
| 4921 | // the name of the test suite, as it will appear in the resulting XML file |
| 4922 | var suiteName; |
| 4923 | |
| 4924 | // the default name of the test suite if none is provided |
| 4925 | var DEFAULT_SUITE_NAME = 'Mocha Tests'; |
| 4926 | |
| 4927 | if (options && options.reporterOptions) { |
| 4928 | if (options.reporterOptions.output) { |
| 4929 | if (!fs.createWriteStream) { |
| 4930 | throw createUnsupportedError('file output not supported in browser'); |
| 4931 | } |
| 4932 | |
| 4933 | mkdirp.sync(path.dirname(options.reporterOptions.output)); |
| 4934 | self.fileStream = fs.createWriteStream(options.reporterOptions.output); |
| 4935 | } |
| 4936 | |
| 4937 | // get the suite name from the reporter options (if provided) |
| 4938 | suiteName = options.reporterOptions.suiteName; |
| 4939 | } |
| 4940 | |
| 4941 | // fall back to the default suite name |
| 4942 | suiteName = suiteName || DEFAULT_SUITE_NAME; |
| 4943 | |
| 4944 | runner.on(EVENT_TEST_PENDING, function(test) { |
| 4945 | tests.push(test); |
| 4946 | }); |
| 4947 | |
| 4948 | runner.on(EVENT_TEST_PASS, function(test) { |
| 4949 | tests.push(test); |
| 4950 | }); |
| 4951 | |
| 4952 | runner.on(EVENT_TEST_FAIL, function(test) { |
| 4953 | tests.push(test); |
| 4954 | }); |
| 4955 | |
| 4956 | runner.once(EVENT_RUN_END, function() { |
| 4957 | self.write( |
| 4958 | tag( |
| 4959 | 'testsuite', |
| 4960 | { |
| 4961 | name: suiteName, |
| 4962 | tests: stats.tests, |
| 4963 | failures: 0, |
| 4964 | errors: stats.failures, |
| 4965 | skipped: stats.tests - stats.failures - stats.passes, |
| 4966 | timestamp: new Date().toUTCString(), |
| 4967 | time: stats.duration / 1000 || 0 |
| 4968 | }, |
| 4969 | false |
| 4970 | ) |
| 4971 | ); |
| 4972 | |
| 4973 | tests.forEach(function(t) { |
| 4974 | self.test(t); |
| 4975 | }); |
| 4976 | |
| 4977 | self.write('</testsuite>'); |
| 4978 | }); |
| 4979 | } |
| 4980 | |
| 4981 | /** |
| 4982 | * Inherit from `Base.prototype`. |
| 4983 | */ |
| 4984 | inherits(XUnit, Base); |
| 4985 | |
| 4986 | /** |
| 4987 | * Override done to close the stream (if it's a file). |
| 4988 | * |
| 4989 | * @param failures |
| 4990 | * @param {Function} fn |
| 4991 | */ |
| 4992 | XUnit.prototype.done = function(failures, fn) { |
| 4993 | if (this.fileStream) { |
| 4994 | this.fileStream.end(function() { |
| 4995 | fn(failures); |
| 4996 | }); |
| 4997 | } else { |
| 4998 | fn(failures); |
| 4999 | } |
| 5000 | }; |
| 5001 | |
| 5002 | /** |
| 5003 | * Write out the given line. |
| 5004 | * |
| 5005 | * @param {string} line |
| 5006 | */ |
| 5007 | XUnit.prototype.write = function(line) { |
| 5008 | if (this.fileStream) { |
| 5009 | this.fileStream.write(line + '\n'); |
| 5010 | } else if (typeof process === 'object' && process.stdout) { |
| 5011 | process.stdout.write(line + '\n'); |
| 5012 | } else { |
| 5013 | Base.consoleLog(line); |
| 5014 | } |
| 5015 | }; |
| 5016 | |
| 5017 | /** |
| 5018 | * Output tag for the given `test.` |
| 5019 | * |
| 5020 | * @param {Test} test |
| 5021 | */ |
| 5022 | XUnit.prototype.test = function(test) { |
| 5023 | Base.useColors = false; |
| 5024 | |
| 5025 | var attrs = { |
| 5026 | classname: test.parent.fullTitle(), |
| 5027 | name: test.title, |
| 5028 | time: test.duration / 1000 || 0 |
| 5029 | }; |
| 5030 | |
| 5031 | if (test.state === STATE_FAILED) { |
| 5032 | var err = test.err; |
| 5033 | var diff = |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5034 | !Base.hideDiff && Base.showDiff(err) |
| 5035 | ? '\n' + Base.generateDiff(err.actual, err.expected) |
| 5036 | : ''; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5037 | this.write( |
| 5038 | tag( |
| 5039 | 'testcase', |
| 5040 | attrs, |
| 5041 | false, |
| 5042 | tag( |
| 5043 | 'failure', |
| 5044 | {}, |
| 5045 | false, |
| 5046 | escape(err.message) + escape(diff) + '\n' + escape(err.stack) |
| 5047 | ) |
| 5048 | ) |
| 5049 | ); |
| 5050 | } else if (test.isPending()) { |
| 5051 | this.write(tag('testcase', attrs, false, tag('skipped', {}, true))); |
| 5052 | } else { |
| 5053 | this.write(tag('testcase', attrs, true)); |
| 5054 | } |
| 5055 | }; |
| 5056 | |
| 5057 | /** |
| 5058 | * HTML tag helper. |
| 5059 | * |
| 5060 | * @param name |
| 5061 | * @param attrs |
| 5062 | * @param close |
| 5063 | * @param content |
| 5064 | * @return {string} |
| 5065 | */ |
| 5066 | function tag(name, attrs, close, content) { |
| 5067 | var end = close ? '/>' : '>'; |
| 5068 | var pairs = []; |
| 5069 | var tag; |
| 5070 | |
| 5071 | for (var key in attrs) { |
| 5072 | if (Object.prototype.hasOwnProperty.call(attrs, key)) { |
| 5073 | pairs.push(key + '="' + escape(attrs[key]) + '"'); |
| 5074 | } |
| 5075 | } |
| 5076 | |
| 5077 | tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end; |
| 5078 | if (content) { |
| 5079 | tag += content + '</' + name + end; |
| 5080 | } |
| 5081 | return tag; |
| 5082 | } |
| 5083 | |
| 5084 | XUnit.description = 'XUnit-compatible XML output'; |
| 5085 | |
| 5086 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 5087 | },{"../errors":6,"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":69,"fs":42,"mkdirp":59,"path":42}],33:[function(require,module,exports){ |
| 5088 | (function (global){ |
| 5089 | 'use strict'; |
| 5090 | |
| 5091 | var EventEmitter = require('events').EventEmitter; |
| 5092 | var Pending = require('./pending'); |
| 5093 | var debug = require('debug')('mocha:runnable'); |
| 5094 | var milliseconds = require('ms'); |
| 5095 | var utils = require('./utils'); |
| 5096 | var createInvalidExceptionError = require('./errors') |
| 5097 | .createInvalidExceptionError; |
| 5098 | |
| 5099 | /** |
| 5100 | * Save timer references to avoid Sinon interfering (see GH-237). |
| 5101 | */ |
| 5102 | var Date = global.Date; |
| 5103 | var setTimeout = global.setTimeout; |
| 5104 | var clearTimeout = global.clearTimeout; |
| 5105 | var toString = Object.prototype.toString; |
| 5106 | |
| 5107 | module.exports = Runnable; |
| 5108 | |
| 5109 | /** |
| 5110 | * Initialize a new `Runnable` with the given `title` and callback `fn`. |
| 5111 | * |
| 5112 | * @class |
| 5113 | * @extends external:EventEmitter |
| 5114 | * @public |
| 5115 | * @param {String} title |
| 5116 | * @param {Function} fn |
| 5117 | */ |
| 5118 | function Runnable(title, fn) { |
| 5119 | this.title = title; |
| 5120 | this.fn = fn; |
| 5121 | this.body = (fn || '').toString(); |
| 5122 | this.async = fn && fn.length; |
| 5123 | this.sync = !this.async; |
| 5124 | this._timeout = 2000; |
| 5125 | this._slow = 75; |
| 5126 | this._enableTimeouts = true; |
| 5127 | this.timedOut = false; |
| 5128 | this._retries = -1; |
| 5129 | this._currentRetry = 0; |
| 5130 | this.pending = false; |
| 5131 | } |
| 5132 | |
| 5133 | /** |
| 5134 | * Inherit from `EventEmitter.prototype`. |
| 5135 | */ |
| 5136 | utils.inherits(Runnable, EventEmitter); |
| 5137 | |
| 5138 | /** |
| 5139 | * Get current timeout value in msecs. |
| 5140 | * |
| 5141 | * @private |
| 5142 | * @returns {number} current timeout threshold value |
| 5143 | */ |
| 5144 | /** |
| 5145 | * @summary |
| 5146 | * Set timeout threshold value (msecs). |
| 5147 | * |
| 5148 | * @description |
| 5149 | * A string argument can use shorthand (e.g., "2s") and will be converted. |
| 5150 | * The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>]. |
| 5151 | * If clamped value matches either range endpoint, timeouts will be disabled. |
| 5152 | * |
| 5153 | * @private |
| 5154 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value} |
| 5155 | * @param {number|string} ms - Timeout threshold value. |
| 5156 | * @returns {Runnable} this |
| 5157 | * @chainable |
| 5158 | */ |
| 5159 | Runnable.prototype.timeout = function(ms) { |
| 5160 | if (!arguments.length) { |
| 5161 | return this._timeout; |
| 5162 | } |
| 5163 | if (typeof ms === 'string') { |
| 5164 | ms = milliseconds(ms); |
| 5165 | } |
| 5166 | |
| 5167 | // Clamp to range |
| 5168 | var INT_MAX = Math.pow(2, 31) - 1; |
| 5169 | var range = [0, INT_MAX]; |
| 5170 | ms = utils.clamp(ms, range); |
| 5171 | |
| 5172 | // see #1652 for reasoning |
| 5173 | if (ms === range[0] || ms === range[1]) { |
| 5174 | this._enableTimeouts = false; |
| 5175 | } |
| 5176 | debug('timeout %d', ms); |
| 5177 | this._timeout = ms; |
| 5178 | if (this.timer) { |
| 5179 | this.resetTimeout(); |
| 5180 | } |
| 5181 | return this; |
| 5182 | }; |
| 5183 | |
| 5184 | /** |
| 5185 | * Set or get slow `ms`. |
| 5186 | * |
| 5187 | * @private |
| 5188 | * @param {number|string} ms |
| 5189 | * @return {Runnable|number} ms or Runnable instance. |
| 5190 | */ |
| 5191 | Runnable.prototype.slow = function(ms) { |
| 5192 | if (!arguments.length || typeof ms === 'undefined') { |
| 5193 | return this._slow; |
| 5194 | } |
| 5195 | if (typeof ms === 'string') { |
| 5196 | ms = milliseconds(ms); |
| 5197 | } |
| 5198 | debug('slow %d', ms); |
| 5199 | this._slow = ms; |
| 5200 | return this; |
| 5201 | }; |
| 5202 | |
| 5203 | /** |
| 5204 | * Set and get whether timeout is `enabled`. |
| 5205 | * |
| 5206 | * @private |
| 5207 | * @param {boolean} enabled |
| 5208 | * @return {Runnable|boolean} enabled or Runnable instance. |
| 5209 | */ |
| 5210 | Runnable.prototype.enableTimeouts = function(enabled) { |
| 5211 | if (!arguments.length) { |
| 5212 | return this._enableTimeouts; |
| 5213 | } |
| 5214 | debug('enableTimeouts %s', enabled); |
| 5215 | this._enableTimeouts = enabled; |
| 5216 | return this; |
| 5217 | }; |
| 5218 | |
| 5219 | /** |
| 5220 | * Halt and mark as pending. |
| 5221 | * |
| 5222 | * @memberof Mocha.Runnable |
| 5223 | * @public |
| 5224 | */ |
| 5225 | Runnable.prototype.skip = function() { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5226 | this.pending = true; |
| 5227 | throw new Pending('sync skip; aborting execution'); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5228 | }; |
| 5229 | |
| 5230 | /** |
| 5231 | * Check if this runnable or its parent suite is marked as pending. |
| 5232 | * |
| 5233 | * @private |
| 5234 | */ |
| 5235 | Runnable.prototype.isPending = function() { |
| 5236 | return this.pending || (this.parent && this.parent.isPending()); |
| 5237 | }; |
| 5238 | |
| 5239 | /** |
| 5240 | * Return `true` if this Runnable has failed. |
| 5241 | * @return {boolean} |
| 5242 | * @private |
| 5243 | */ |
| 5244 | Runnable.prototype.isFailed = function() { |
| 5245 | return !this.isPending() && this.state === constants.STATE_FAILED; |
| 5246 | }; |
| 5247 | |
| 5248 | /** |
| 5249 | * Return `true` if this Runnable has passed. |
| 5250 | * @return {boolean} |
| 5251 | * @private |
| 5252 | */ |
| 5253 | Runnable.prototype.isPassed = function() { |
| 5254 | return !this.isPending() && this.state === constants.STATE_PASSED; |
| 5255 | }; |
| 5256 | |
| 5257 | /** |
| 5258 | * Set or get number of retries. |
| 5259 | * |
| 5260 | * @private |
| 5261 | */ |
| 5262 | Runnable.prototype.retries = function(n) { |
| 5263 | if (!arguments.length) { |
| 5264 | return this._retries; |
| 5265 | } |
| 5266 | this._retries = n; |
| 5267 | }; |
| 5268 | |
| 5269 | /** |
| 5270 | * Set or get current retry |
| 5271 | * |
| 5272 | * @private |
| 5273 | */ |
| 5274 | Runnable.prototype.currentRetry = function(n) { |
| 5275 | if (!arguments.length) { |
| 5276 | return this._currentRetry; |
| 5277 | } |
| 5278 | this._currentRetry = n; |
| 5279 | }; |
| 5280 | |
| 5281 | /** |
| 5282 | * Return the full title generated by recursively concatenating the parent's |
| 5283 | * full title. |
| 5284 | * |
| 5285 | * @memberof Mocha.Runnable |
| 5286 | * @public |
| 5287 | * @return {string} |
| 5288 | */ |
| 5289 | Runnable.prototype.fullTitle = function() { |
| 5290 | return this.titlePath().join(' '); |
| 5291 | }; |
| 5292 | |
| 5293 | /** |
| 5294 | * Return the title path generated by concatenating the parent's title path with the title. |
| 5295 | * |
| 5296 | * @memberof Mocha.Runnable |
| 5297 | * @public |
| 5298 | * @return {string} |
| 5299 | */ |
| 5300 | Runnable.prototype.titlePath = function() { |
| 5301 | return this.parent.titlePath().concat([this.title]); |
| 5302 | }; |
| 5303 | |
| 5304 | /** |
| 5305 | * Clear the timeout. |
| 5306 | * |
| 5307 | * @private |
| 5308 | */ |
| 5309 | Runnable.prototype.clearTimeout = function() { |
| 5310 | clearTimeout(this.timer); |
| 5311 | }; |
| 5312 | |
| 5313 | /** |
| 5314 | * Inspect the runnable void of private properties. |
| 5315 | * |
| 5316 | * @private |
| 5317 | * @return {string} |
| 5318 | */ |
| 5319 | Runnable.prototype.inspect = function() { |
| 5320 | return JSON.stringify( |
| 5321 | this, |
| 5322 | function(key, val) { |
| 5323 | if (key[0] === '_') { |
| 5324 | return; |
| 5325 | } |
| 5326 | if (key === 'parent') { |
| 5327 | return '#<Suite>'; |
| 5328 | } |
| 5329 | if (key === 'ctx') { |
| 5330 | return '#<Context>'; |
| 5331 | } |
| 5332 | return val; |
| 5333 | }, |
| 5334 | 2 |
| 5335 | ); |
| 5336 | }; |
| 5337 | |
| 5338 | /** |
| 5339 | * Reset the timeout. |
| 5340 | * |
| 5341 | * @private |
| 5342 | */ |
| 5343 | Runnable.prototype.resetTimeout = function() { |
| 5344 | var self = this; |
| 5345 | var ms = this.timeout() || 1e9; |
| 5346 | |
| 5347 | if (!this._enableTimeouts) { |
| 5348 | return; |
| 5349 | } |
| 5350 | this.clearTimeout(); |
| 5351 | this.timer = setTimeout(function() { |
| 5352 | if (!self._enableTimeouts) { |
| 5353 | return; |
| 5354 | } |
| 5355 | self.callback(self._timeoutError(ms)); |
| 5356 | self.timedOut = true; |
| 5357 | }, ms); |
| 5358 | }; |
| 5359 | |
| 5360 | /** |
| 5361 | * Set or get a list of whitelisted globals for this test run. |
| 5362 | * |
| 5363 | * @private |
| 5364 | * @param {string[]} globals |
| 5365 | */ |
| 5366 | Runnable.prototype.globals = function(globals) { |
| 5367 | if (!arguments.length) { |
| 5368 | return this._allowedGlobals; |
| 5369 | } |
| 5370 | this._allowedGlobals = globals; |
| 5371 | }; |
| 5372 | |
| 5373 | /** |
| 5374 | * Run the test and invoke `fn(err)`. |
| 5375 | * |
| 5376 | * @param {Function} fn |
| 5377 | * @private |
| 5378 | */ |
| 5379 | Runnable.prototype.run = function(fn) { |
| 5380 | var self = this; |
| 5381 | var start = new Date(); |
| 5382 | var ctx = this.ctx; |
| 5383 | var finished; |
| 5384 | var emitted; |
| 5385 | |
| 5386 | // Sometimes the ctx exists, but it is not runnable |
| 5387 | if (ctx && ctx.runnable) { |
| 5388 | ctx.runnable(this); |
| 5389 | } |
| 5390 | |
| 5391 | // called multiple times |
| 5392 | function multiple(err) { |
| 5393 | if (emitted) { |
| 5394 | return; |
| 5395 | } |
| 5396 | emitted = true; |
| 5397 | var msg = 'done() called multiple times'; |
| 5398 | if (err && err.message) { |
| 5399 | err.message += " (and Mocha's " + msg + ')'; |
| 5400 | self.emit('error', err); |
| 5401 | } else { |
| 5402 | self.emit('error', new Error(msg)); |
| 5403 | } |
| 5404 | } |
| 5405 | |
| 5406 | // finished |
| 5407 | function done(err) { |
| 5408 | var ms = self.timeout(); |
| 5409 | if (self.timedOut) { |
| 5410 | return; |
| 5411 | } |
| 5412 | |
| 5413 | if (finished) { |
| 5414 | return multiple(err); |
| 5415 | } |
| 5416 | |
| 5417 | self.clearTimeout(); |
| 5418 | self.duration = new Date() - start; |
| 5419 | finished = true; |
| 5420 | if (!err && self.duration > ms && self._enableTimeouts) { |
| 5421 | err = self._timeoutError(ms); |
| 5422 | } |
| 5423 | fn(err); |
| 5424 | } |
| 5425 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5426 | // for .resetTimeout() and Runner#uncaught() |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5427 | this.callback = done; |
| 5428 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5429 | if (this.fn && typeof this.fn.call !== 'function') { |
| 5430 | done( |
| 5431 | new TypeError( |
| 5432 | 'A runnable must be passed a function as its second argument.' |
| 5433 | ) |
| 5434 | ); |
| 5435 | return; |
| 5436 | } |
| 5437 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5438 | // explicit async with `done` argument |
| 5439 | if (this.async) { |
| 5440 | this.resetTimeout(); |
| 5441 | |
| 5442 | // allows skip() to be used in an explicit async context |
| 5443 | this.skip = function asyncSkip() { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5444 | this.pending = true; |
| 5445 | done(); |
| 5446 | // halt execution, the uncaught handler will ignore the failure. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5447 | throw new Pending('async skip; aborting execution'); |
| 5448 | }; |
| 5449 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5450 | try { |
| 5451 | callFnAsync(this.fn); |
| 5452 | } catch (err) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5453 | // handles async runnables which actually run synchronously |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5454 | emitted = true; |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5455 | if (err instanceof Pending) { |
| 5456 | return; // done() is already called in this.skip() |
| 5457 | } else if (this.allowUncaught) { |
| 5458 | throw err; |
| 5459 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5460 | done(Runnable.toValueOrError(err)); |
| 5461 | } |
| 5462 | return; |
| 5463 | } |
| 5464 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5465 | // sync or promise-returning |
| 5466 | try { |
| 5467 | if (this.isPending()) { |
| 5468 | done(); |
| 5469 | } else { |
| 5470 | callFn(this.fn); |
| 5471 | } |
| 5472 | } catch (err) { |
| 5473 | emitted = true; |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5474 | if (err instanceof Pending) { |
| 5475 | return done(); |
| 5476 | } else if (this.allowUncaught) { |
| 5477 | throw err; |
| 5478 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5479 | done(Runnable.toValueOrError(err)); |
| 5480 | } |
| 5481 | |
| 5482 | function callFn(fn) { |
| 5483 | var result = fn.call(ctx); |
| 5484 | if (result && typeof result.then === 'function') { |
| 5485 | self.resetTimeout(); |
| 5486 | result.then( |
| 5487 | function() { |
| 5488 | done(); |
| 5489 | // Return null so libraries like bluebird do not warn about |
| 5490 | // subsequently constructed Promises. |
| 5491 | return null; |
| 5492 | }, |
| 5493 | function(reason) { |
| 5494 | done(reason || new Error('Promise rejected with no or falsy reason')); |
| 5495 | } |
| 5496 | ); |
| 5497 | } else { |
| 5498 | if (self.asyncOnly) { |
| 5499 | return done( |
| 5500 | new Error( |
| 5501 | '--async-only option in use without declaring `done()` or returning a promise' |
| 5502 | ) |
| 5503 | ); |
| 5504 | } |
| 5505 | |
| 5506 | done(); |
| 5507 | } |
| 5508 | } |
| 5509 | |
| 5510 | function callFnAsync(fn) { |
| 5511 | var result = fn.call(ctx, function(err) { |
| 5512 | if (err instanceof Error || toString.call(err) === '[object Error]') { |
| 5513 | return done(err); |
| 5514 | } |
| 5515 | if (err) { |
| 5516 | if (Object.prototype.toString.call(err) === '[object Object]') { |
| 5517 | return done( |
| 5518 | new Error('done() invoked with non-Error: ' + JSON.stringify(err)) |
| 5519 | ); |
| 5520 | } |
| 5521 | return done(new Error('done() invoked with non-Error: ' + err)); |
| 5522 | } |
| 5523 | if (result && utils.isPromise(result)) { |
| 5524 | return done( |
| 5525 | new Error( |
| 5526 | 'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.' |
| 5527 | ) |
| 5528 | ); |
| 5529 | } |
| 5530 | |
| 5531 | done(); |
| 5532 | }); |
| 5533 | } |
| 5534 | }; |
| 5535 | |
| 5536 | /** |
| 5537 | * Instantiates a "timeout" error |
| 5538 | * |
| 5539 | * @param {number} ms - Timeout (in milliseconds) |
| 5540 | * @returns {Error} a "timeout" error |
| 5541 | * @private |
| 5542 | */ |
| 5543 | Runnable.prototype._timeoutError = function(ms) { |
| 5544 | var msg = |
| 5545 | 'Timeout of ' + |
| 5546 | ms + |
| 5547 | 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.'; |
| 5548 | if (this.file) { |
| 5549 | msg += ' (' + this.file + ')'; |
| 5550 | } |
| 5551 | return new Error(msg); |
| 5552 | }; |
| 5553 | |
| 5554 | var constants = utils.defineConstants( |
| 5555 | /** |
| 5556 | * {@link Runnable}-related constants. |
| 5557 | * @public |
| 5558 | * @memberof Runnable |
| 5559 | * @readonly |
| 5560 | * @static |
| 5561 | * @alias constants |
| 5562 | * @enum {string} |
| 5563 | */ |
| 5564 | { |
| 5565 | /** |
| 5566 | * Value of `state` prop when a `Runnable` has failed |
| 5567 | */ |
| 5568 | STATE_FAILED: 'failed', |
| 5569 | /** |
| 5570 | * Value of `state` prop when a `Runnable` has passed |
| 5571 | */ |
| 5572 | STATE_PASSED: 'passed' |
| 5573 | } |
| 5574 | ); |
| 5575 | |
| 5576 | /** |
| 5577 | * Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that. |
| 5578 | * @param {*} [value] - Value to return, if present |
| 5579 | * @returns {*|Error} `value`, otherwise an `Error` |
| 5580 | * @private |
| 5581 | */ |
| 5582 | Runnable.toValueOrError = function(value) { |
| 5583 | return ( |
| 5584 | value || |
| 5585 | createInvalidExceptionError( |
| 5586 | 'Runnable failed with falsy or undefined exception. Please throw an Error instead.', |
| 5587 | value |
| 5588 | ) |
| 5589 | ); |
| 5590 | }; |
| 5591 | |
| 5592 | Runnable.constants = constants; |
| 5593 | |
| 5594 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 5595 | },{"./errors":6,"./pending":16,"./utils":38,"debug":45,"events":50,"ms":60}],34:[function(require,module,exports){ |
| 5596 | (function (process,global){ |
| 5597 | 'use strict'; |
| 5598 | |
| 5599 | /** |
| 5600 | * Module dependencies. |
| 5601 | */ |
| 5602 | var util = require('util'); |
| 5603 | var EventEmitter = require('events').EventEmitter; |
| 5604 | var Pending = require('./pending'); |
| 5605 | var utils = require('./utils'); |
| 5606 | var inherits = utils.inherits; |
| 5607 | var debug = require('debug')('mocha:runner'); |
| 5608 | var Runnable = require('./runnable'); |
| 5609 | var Suite = require('./suite'); |
| 5610 | var HOOK_TYPE_BEFORE_EACH = Suite.constants.HOOK_TYPE_BEFORE_EACH; |
| 5611 | var HOOK_TYPE_AFTER_EACH = Suite.constants.HOOK_TYPE_AFTER_EACH; |
| 5612 | var HOOK_TYPE_AFTER_ALL = Suite.constants.HOOK_TYPE_AFTER_ALL; |
| 5613 | var HOOK_TYPE_BEFORE_ALL = Suite.constants.HOOK_TYPE_BEFORE_ALL; |
| 5614 | var EVENT_ROOT_SUITE_RUN = Suite.constants.EVENT_ROOT_SUITE_RUN; |
| 5615 | var STATE_FAILED = Runnable.constants.STATE_FAILED; |
| 5616 | var STATE_PASSED = Runnable.constants.STATE_PASSED; |
| 5617 | var dQuote = utils.dQuote; |
| 5618 | var ngettext = utils.ngettext; |
| 5619 | var sQuote = utils.sQuote; |
| 5620 | var stackFilter = utils.stackTraceFilter(); |
| 5621 | var stringify = utils.stringify; |
| 5622 | var type = utils.type; |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5623 | var errors = require('./errors'); |
| 5624 | var createInvalidExceptionError = errors.createInvalidExceptionError; |
| 5625 | var createUnsupportedError = errors.createUnsupportedError; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5626 | |
| 5627 | /** |
| 5628 | * Non-enumerable globals. |
| 5629 | * @readonly |
| 5630 | */ |
| 5631 | var globals = [ |
| 5632 | 'setTimeout', |
| 5633 | 'clearTimeout', |
| 5634 | 'setInterval', |
| 5635 | 'clearInterval', |
| 5636 | 'XMLHttpRequest', |
| 5637 | 'Date', |
| 5638 | 'setImmediate', |
| 5639 | 'clearImmediate' |
| 5640 | ]; |
| 5641 | |
| 5642 | var constants = utils.defineConstants( |
| 5643 | /** |
| 5644 | * {@link Runner}-related constants. |
| 5645 | * @public |
| 5646 | * @memberof Runner |
| 5647 | * @readonly |
| 5648 | * @alias constants |
| 5649 | * @static |
| 5650 | * @enum {string} |
| 5651 | */ |
| 5652 | { |
| 5653 | /** |
| 5654 | * Emitted when {@link Hook} execution begins |
| 5655 | */ |
| 5656 | EVENT_HOOK_BEGIN: 'hook', |
| 5657 | /** |
| 5658 | * Emitted when {@link Hook} execution ends |
| 5659 | */ |
| 5660 | EVENT_HOOK_END: 'hook end', |
| 5661 | /** |
| 5662 | * Emitted when Root {@link Suite} execution begins (all files have been parsed and hooks/tests are ready for execution) |
| 5663 | */ |
| 5664 | EVENT_RUN_BEGIN: 'start', |
| 5665 | /** |
| 5666 | * Emitted when Root {@link Suite} execution has been delayed via `delay` option |
| 5667 | */ |
| 5668 | EVENT_DELAY_BEGIN: 'waiting', |
| 5669 | /** |
| 5670 | * Emitted when delayed Root {@link Suite} execution is triggered by user via `global.run()` |
| 5671 | */ |
| 5672 | EVENT_DELAY_END: 'ready', |
| 5673 | /** |
| 5674 | * Emitted when Root {@link Suite} execution ends |
| 5675 | */ |
| 5676 | EVENT_RUN_END: 'end', |
| 5677 | /** |
| 5678 | * Emitted when {@link Suite} execution begins |
| 5679 | */ |
| 5680 | EVENT_SUITE_BEGIN: 'suite', |
| 5681 | /** |
| 5682 | * Emitted when {@link Suite} execution ends |
| 5683 | */ |
| 5684 | EVENT_SUITE_END: 'suite end', |
| 5685 | /** |
| 5686 | * Emitted when {@link Test} execution begins |
| 5687 | */ |
| 5688 | EVENT_TEST_BEGIN: 'test', |
| 5689 | /** |
| 5690 | * Emitted when {@link Test} execution ends |
| 5691 | */ |
| 5692 | EVENT_TEST_END: 'test end', |
| 5693 | /** |
| 5694 | * Emitted when {@link Test} execution fails |
| 5695 | */ |
| 5696 | EVENT_TEST_FAIL: 'fail', |
| 5697 | /** |
| 5698 | * Emitted when {@link Test} execution succeeds |
| 5699 | */ |
| 5700 | EVENT_TEST_PASS: 'pass', |
| 5701 | /** |
| 5702 | * Emitted when {@link Test} becomes pending |
| 5703 | */ |
| 5704 | EVENT_TEST_PENDING: 'pending', |
| 5705 | /** |
| 5706 | * Emitted when {@link Test} execution has failed, but will retry |
| 5707 | */ |
| 5708 | EVENT_TEST_RETRY: 'retry' |
| 5709 | } |
| 5710 | ); |
| 5711 | |
| 5712 | module.exports = Runner; |
| 5713 | |
| 5714 | /** |
| 5715 | * Initialize a `Runner` at the Root {@link Suite}, which represents a hierarchy of {@link Suite|Suites} and {@link Test|Tests}. |
| 5716 | * |
| 5717 | * @extends external:EventEmitter |
| 5718 | * @public |
| 5719 | * @class |
| 5720 | * @param {Suite} suite Root suite |
| 5721 | * @param {boolean} [delay] Whether or not to delay execution of root suite |
| 5722 | * until ready. |
| 5723 | */ |
| 5724 | function Runner(suite, delay) { |
| 5725 | var self = this; |
| 5726 | this._globals = []; |
| 5727 | this._abort = false; |
| 5728 | this._delay = delay; |
| 5729 | this.suite = suite; |
| 5730 | this.started = false; |
| 5731 | this.total = suite.total(); |
| 5732 | this.failures = 0; |
| 5733 | this.on(constants.EVENT_TEST_END, function(test) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5734 | if (test.retriedTest() && test.parent) { |
| 5735 | var idx = |
| 5736 | test.parent.tests && test.parent.tests.indexOf(test.retriedTest()); |
| 5737 | if (idx > -1) test.parent.tests[idx] = test; |
| 5738 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5739 | self.checkGlobals(test); |
| 5740 | }); |
| 5741 | this.on(constants.EVENT_HOOK_END, function(hook) { |
| 5742 | self.checkGlobals(hook); |
| 5743 | }); |
| 5744 | this._defaultGrep = /.*/; |
| 5745 | this.grep(this._defaultGrep); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5746 | this.globals(this.globalProps()); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5747 | } |
| 5748 | |
| 5749 | /** |
| 5750 | * Wrapper for setImmediate, process.nextTick, or browser polyfill. |
| 5751 | * |
| 5752 | * @param {Function} fn |
| 5753 | * @private |
| 5754 | */ |
| 5755 | Runner.immediately = global.setImmediate || process.nextTick; |
| 5756 | |
| 5757 | /** |
| 5758 | * Inherit from `EventEmitter.prototype`. |
| 5759 | */ |
| 5760 | inherits(Runner, EventEmitter); |
| 5761 | |
| 5762 | /** |
| 5763 | * Run tests with full titles matching `re`. Updates runner.total |
| 5764 | * with number of tests matched. |
| 5765 | * |
| 5766 | * @public |
| 5767 | * @memberof Runner |
| 5768 | * @param {RegExp} re |
| 5769 | * @param {boolean} invert |
| 5770 | * @return {Runner} Runner instance. |
| 5771 | */ |
| 5772 | Runner.prototype.grep = function(re, invert) { |
| 5773 | debug('grep %s', re); |
| 5774 | this._grep = re; |
| 5775 | this._invert = invert; |
| 5776 | this.total = this.grepTotal(this.suite); |
| 5777 | return this; |
| 5778 | }; |
| 5779 | |
| 5780 | /** |
| 5781 | * Returns the number of tests matching the grep search for the |
| 5782 | * given suite. |
| 5783 | * |
| 5784 | * @memberof Runner |
| 5785 | * @public |
| 5786 | * @param {Suite} suite |
| 5787 | * @return {number} |
| 5788 | */ |
| 5789 | Runner.prototype.grepTotal = function(suite) { |
| 5790 | var self = this; |
| 5791 | var total = 0; |
| 5792 | |
| 5793 | suite.eachTest(function(test) { |
| 5794 | var match = self._grep.test(test.fullTitle()); |
| 5795 | if (self._invert) { |
| 5796 | match = !match; |
| 5797 | } |
| 5798 | if (match) { |
| 5799 | total++; |
| 5800 | } |
| 5801 | }); |
| 5802 | |
| 5803 | return total; |
| 5804 | }; |
| 5805 | |
| 5806 | /** |
| 5807 | * Return a list of global properties. |
| 5808 | * |
| 5809 | * @return {Array} |
| 5810 | * @private |
| 5811 | */ |
| 5812 | Runner.prototype.globalProps = function() { |
| 5813 | var props = Object.keys(global); |
| 5814 | |
| 5815 | // non-enumerables |
| 5816 | for (var i = 0; i < globals.length; ++i) { |
| 5817 | if (~props.indexOf(globals[i])) { |
| 5818 | continue; |
| 5819 | } |
| 5820 | props.push(globals[i]); |
| 5821 | } |
| 5822 | |
| 5823 | return props; |
| 5824 | }; |
| 5825 | |
| 5826 | /** |
| 5827 | * Allow the given `arr` of globals. |
| 5828 | * |
| 5829 | * @public |
| 5830 | * @memberof Runner |
| 5831 | * @param {Array} arr |
| 5832 | * @return {Runner} Runner instance. |
| 5833 | */ |
| 5834 | Runner.prototype.globals = function(arr) { |
| 5835 | if (!arguments.length) { |
| 5836 | return this._globals; |
| 5837 | } |
| 5838 | debug('globals %j', arr); |
| 5839 | this._globals = this._globals.concat(arr); |
| 5840 | return this; |
| 5841 | }; |
| 5842 | |
| 5843 | /** |
| 5844 | * Check for global variable leaks. |
| 5845 | * |
| 5846 | * @private |
| 5847 | */ |
| 5848 | Runner.prototype.checkGlobals = function(test) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5849 | if (!this.checkLeaks) { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5850 | return; |
| 5851 | } |
| 5852 | var ok = this._globals; |
| 5853 | |
| 5854 | var globals = this.globalProps(); |
| 5855 | var leaks; |
| 5856 | |
| 5857 | if (test) { |
| 5858 | ok = ok.concat(test._allowedGlobals || []); |
| 5859 | } |
| 5860 | |
| 5861 | if (this.prevGlobalsLength === globals.length) { |
| 5862 | return; |
| 5863 | } |
| 5864 | this.prevGlobalsLength = globals.length; |
| 5865 | |
| 5866 | leaks = filterLeaks(ok, globals); |
| 5867 | this._globals = this._globals.concat(leaks); |
| 5868 | |
| 5869 | if (leaks.length) { |
| 5870 | var format = ngettext( |
| 5871 | leaks.length, |
| 5872 | 'global leak detected: %s', |
| 5873 | 'global leaks detected: %s' |
| 5874 | ); |
| 5875 | var error = new Error(util.format(format, leaks.map(sQuote).join(', '))); |
| 5876 | this.fail(test, error); |
| 5877 | } |
| 5878 | }; |
| 5879 | |
| 5880 | /** |
| 5881 | * Fail the given `test`. |
| 5882 | * |
| 5883 | * @private |
| 5884 | * @param {Test} test |
| 5885 | * @param {Error} err |
| 5886 | */ |
| 5887 | Runner.prototype.fail = function(test, err) { |
| 5888 | if (test.isPending()) { |
| 5889 | return; |
| 5890 | } |
| 5891 | |
| 5892 | ++this.failures; |
| 5893 | test.state = STATE_FAILED; |
| 5894 | |
| 5895 | if (!isError(err)) { |
| 5896 | err = thrown2Error(err); |
| 5897 | } |
| 5898 | |
| 5899 | try { |
| 5900 | err.stack = |
| 5901 | this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack); |
| 5902 | } catch (ignore) { |
| 5903 | // some environments do not take kindly to monkeying with the stack |
| 5904 | } |
| 5905 | |
| 5906 | this.emit(constants.EVENT_TEST_FAIL, test, err); |
| 5907 | }; |
| 5908 | |
| 5909 | /** |
| 5910 | * Fail the given `hook` with `err`. |
| 5911 | * |
| 5912 | * Hook failures work in the following pattern: |
| 5913 | * - If bail, run corresponding `after each` and `after` hooks, |
| 5914 | * then exit |
| 5915 | * - Failed `before` hook skips all tests in a suite and subsuites, |
| 5916 | * but jumps to corresponding `after` hook |
| 5917 | * - Failed `before each` hook skips remaining tests in a |
| 5918 | * suite and jumps to corresponding `after each` hook, |
| 5919 | * which is run only once |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5920 | * - Failed `after` hook does not alter execution order |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5921 | * - Failed `after each` hook skips remaining tests in a |
| 5922 | * suite and subsuites, but executes other `after each` |
| 5923 | * hooks |
| 5924 | * |
| 5925 | * @private |
| 5926 | * @param {Hook} hook |
| 5927 | * @param {Error} err |
| 5928 | */ |
| 5929 | Runner.prototype.failHook = function(hook, err) { |
| 5930 | hook.originalTitle = hook.originalTitle || hook.title; |
| 5931 | if (hook.ctx && hook.ctx.currentTest) { |
| 5932 | hook.title = |
| 5933 | hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title); |
| 5934 | } else { |
| 5935 | var parentTitle; |
| 5936 | if (hook.parent.title) { |
| 5937 | parentTitle = hook.parent.title; |
| 5938 | } else { |
| 5939 | parentTitle = hook.parent.root ? '{root}' : ''; |
| 5940 | } |
| 5941 | hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle); |
| 5942 | } |
| 5943 | |
| 5944 | this.fail(hook, err); |
| 5945 | }; |
| 5946 | |
| 5947 | /** |
| 5948 | * Run hook `name` callbacks and then invoke `fn()`. |
| 5949 | * |
| 5950 | * @private |
| 5951 | * @param {string} name |
| 5952 | * @param {Function} fn |
| 5953 | */ |
| 5954 | |
| 5955 | Runner.prototype.hook = function(name, fn) { |
| 5956 | var suite = this.suite; |
| 5957 | var hooks = suite.getHooks(name); |
| 5958 | var self = this; |
| 5959 | |
| 5960 | function next(i) { |
| 5961 | var hook = hooks[i]; |
| 5962 | if (!hook) { |
| 5963 | return fn(); |
| 5964 | } |
| 5965 | self.currentRunnable = hook; |
| 5966 | |
| 5967 | if (name === HOOK_TYPE_BEFORE_ALL) { |
| 5968 | hook.ctx.currentTest = hook.parent.tests[0]; |
| 5969 | } else if (name === HOOK_TYPE_AFTER_ALL) { |
| 5970 | hook.ctx.currentTest = hook.parent.tests[hook.parent.tests.length - 1]; |
| 5971 | } else { |
| 5972 | hook.ctx.currentTest = self.test; |
| 5973 | } |
| 5974 | |
| 5975 | hook.allowUncaught = self.allowUncaught; |
| 5976 | |
| 5977 | self.emit(constants.EVENT_HOOK_BEGIN, hook); |
| 5978 | |
| 5979 | if (!hook.listeners('error').length) { |
| 5980 | hook.on('error', function(err) { |
| 5981 | self.failHook(hook, err); |
| 5982 | }); |
| 5983 | } |
| 5984 | |
| 5985 | hook.run(function(err) { |
| 5986 | var testError = hook.error(); |
| 5987 | if (testError) { |
| 5988 | self.fail(self.test, testError); |
| 5989 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5990 | // conditional skip |
| 5991 | if (hook.pending) { |
| 5992 | if (name === HOOK_TYPE_AFTER_EACH) { |
| 5993 | // TODO define and implement use case |
| 5994 | if (self.test) { |
| 5995 | self.test.pending = true; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 5996 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 5997 | } else if (name === HOOK_TYPE_BEFORE_EACH) { |
| 5998 | if (self.test) { |
| 5999 | self.test.pending = true; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6000 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6001 | self.emit(constants.EVENT_HOOK_END, hook); |
| 6002 | hook.pending = false; // activates hook for next test |
| 6003 | return fn(new Error('abort hookDown')); |
| 6004 | } else if (name === HOOK_TYPE_BEFORE_ALL) { |
| 6005 | suite.tests.forEach(function(test) { |
| 6006 | test.pending = true; |
| 6007 | }); |
| 6008 | suite.suites.forEach(function(suite) { |
| 6009 | suite.pending = true; |
| 6010 | }); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6011 | } else { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6012 | hook.pending = false; |
| 6013 | var errForbid = createUnsupportedError('`this.skip` forbidden'); |
| 6014 | self.failHook(hook, errForbid); |
| 6015 | return fn(errForbid); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6016 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6017 | } else if (err) { |
| 6018 | self.failHook(hook, err); |
| 6019 | // stop executing hooks, notify callee of hook err |
| 6020 | return fn(err); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6021 | } |
| 6022 | self.emit(constants.EVENT_HOOK_END, hook); |
| 6023 | delete hook.ctx.currentTest; |
| 6024 | next(++i); |
| 6025 | }); |
| 6026 | } |
| 6027 | |
| 6028 | Runner.immediately(function() { |
| 6029 | next(0); |
| 6030 | }); |
| 6031 | }; |
| 6032 | |
| 6033 | /** |
| 6034 | * Run hook `name` for the given array of `suites` |
| 6035 | * in order, and callback `fn(err, errSuite)`. |
| 6036 | * |
| 6037 | * @private |
| 6038 | * @param {string} name |
| 6039 | * @param {Array} suites |
| 6040 | * @param {Function} fn |
| 6041 | */ |
| 6042 | Runner.prototype.hooks = function(name, suites, fn) { |
| 6043 | var self = this; |
| 6044 | var orig = this.suite; |
| 6045 | |
| 6046 | function next(suite) { |
| 6047 | self.suite = suite; |
| 6048 | |
| 6049 | if (!suite) { |
| 6050 | self.suite = orig; |
| 6051 | return fn(); |
| 6052 | } |
| 6053 | |
| 6054 | self.hook(name, function(err) { |
| 6055 | if (err) { |
| 6056 | var errSuite = self.suite; |
| 6057 | self.suite = orig; |
| 6058 | return fn(err, errSuite); |
| 6059 | } |
| 6060 | |
| 6061 | next(suites.pop()); |
| 6062 | }); |
| 6063 | } |
| 6064 | |
| 6065 | next(suites.pop()); |
| 6066 | }; |
| 6067 | |
| 6068 | /** |
| 6069 | * Run hooks from the top level down. |
| 6070 | * |
| 6071 | * @param {String} name |
| 6072 | * @param {Function} fn |
| 6073 | * @private |
| 6074 | */ |
| 6075 | Runner.prototype.hookUp = function(name, fn) { |
| 6076 | var suites = [this.suite].concat(this.parents()).reverse(); |
| 6077 | this.hooks(name, suites, fn); |
| 6078 | }; |
| 6079 | |
| 6080 | /** |
| 6081 | * Run hooks from the bottom up. |
| 6082 | * |
| 6083 | * @param {String} name |
| 6084 | * @param {Function} fn |
| 6085 | * @private |
| 6086 | */ |
| 6087 | Runner.prototype.hookDown = function(name, fn) { |
| 6088 | var suites = [this.suite].concat(this.parents()); |
| 6089 | this.hooks(name, suites, fn); |
| 6090 | }; |
| 6091 | |
| 6092 | /** |
| 6093 | * Return an array of parent Suites from |
| 6094 | * closest to furthest. |
| 6095 | * |
| 6096 | * @return {Array} |
| 6097 | * @private |
| 6098 | */ |
| 6099 | Runner.prototype.parents = function() { |
| 6100 | var suite = this.suite; |
| 6101 | var suites = []; |
| 6102 | while (suite.parent) { |
| 6103 | suite = suite.parent; |
| 6104 | suites.push(suite); |
| 6105 | } |
| 6106 | return suites; |
| 6107 | }; |
| 6108 | |
| 6109 | /** |
| 6110 | * Run the current test and callback `fn(err)`. |
| 6111 | * |
| 6112 | * @param {Function} fn |
| 6113 | * @private |
| 6114 | */ |
| 6115 | Runner.prototype.runTest = function(fn) { |
| 6116 | var self = this; |
| 6117 | var test = this.test; |
| 6118 | |
| 6119 | if (!test) { |
| 6120 | return; |
| 6121 | } |
| 6122 | |
| 6123 | var suite = this.parents().reverse()[0] || this.suite; |
| 6124 | if (this.forbidOnly && suite.hasOnly()) { |
| 6125 | fn(new Error('`.only` forbidden')); |
| 6126 | return; |
| 6127 | } |
| 6128 | if (this.asyncOnly) { |
| 6129 | test.asyncOnly = true; |
| 6130 | } |
| 6131 | test.on('error', function(err) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6132 | if (err instanceof Pending) { |
| 6133 | return; |
| 6134 | } |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6135 | self.fail(test, err); |
| 6136 | }); |
| 6137 | if (this.allowUncaught) { |
| 6138 | test.allowUncaught = true; |
| 6139 | return test.run(fn); |
| 6140 | } |
| 6141 | try { |
| 6142 | test.run(fn); |
| 6143 | } catch (err) { |
| 6144 | fn(err); |
| 6145 | } |
| 6146 | }; |
| 6147 | |
| 6148 | /** |
| 6149 | * Run tests in the given `suite` and invoke the callback `fn()` when complete. |
| 6150 | * |
| 6151 | * @private |
| 6152 | * @param {Suite} suite |
| 6153 | * @param {Function} fn |
| 6154 | */ |
| 6155 | Runner.prototype.runTests = function(suite, fn) { |
| 6156 | var self = this; |
| 6157 | var tests = suite.tests.slice(); |
| 6158 | var test; |
| 6159 | |
| 6160 | function hookErr(_, errSuite, after) { |
| 6161 | // before/after Each hook for errSuite failed: |
| 6162 | var orig = self.suite; |
| 6163 | |
| 6164 | // for failed 'after each' hook start from errSuite parent, |
| 6165 | // otherwise start from errSuite itself |
| 6166 | self.suite = after ? errSuite.parent : errSuite; |
| 6167 | |
| 6168 | if (self.suite) { |
| 6169 | // call hookUp afterEach |
| 6170 | self.hookUp(HOOK_TYPE_AFTER_EACH, function(err2, errSuite2) { |
| 6171 | self.suite = orig; |
| 6172 | // some hooks may fail even now |
| 6173 | if (err2) { |
| 6174 | return hookErr(err2, errSuite2, true); |
| 6175 | } |
| 6176 | // report error suite |
| 6177 | fn(errSuite); |
| 6178 | }); |
| 6179 | } else { |
| 6180 | // there is no need calling other 'after each' hooks |
| 6181 | self.suite = orig; |
| 6182 | fn(errSuite); |
| 6183 | } |
| 6184 | } |
| 6185 | |
| 6186 | function next(err, errSuite) { |
| 6187 | // if we bail after first err |
| 6188 | if (self.failures && suite._bail) { |
| 6189 | tests = []; |
| 6190 | } |
| 6191 | |
| 6192 | if (self._abort) { |
| 6193 | return fn(); |
| 6194 | } |
| 6195 | |
| 6196 | if (err) { |
| 6197 | return hookErr(err, errSuite, true); |
| 6198 | } |
| 6199 | |
| 6200 | // next test |
| 6201 | test = tests.shift(); |
| 6202 | |
| 6203 | // all done |
| 6204 | if (!test) { |
| 6205 | return fn(); |
| 6206 | } |
| 6207 | |
| 6208 | // grep |
| 6209 | var match = self._grep.test(test.fullTitle()); |
| 6210 | if (self._invert) { |
| 6211 | match = !match; |
| 6212 | } |
| 6213 | if (!match) { |
| 6214 | // Run immediately only if we have defined a grep. When we |
| 6215 | // define a grep — It can cause maximum callstack error if |
| 6216 | // the grep is doing a large recursive loop by neglecting |
| 6217 | // all tests. The run immediately function also comes with |
| 6218 | // a performance cost. So we don't want to run immediately |
| 6219 | // if we run the whole test suite, because running the whole |
| 6220 | // test suite don't do any immediate recursive loops. Thus, |
| 6221 | // allowing a JS runtime to breathe. |
| 6222 | if (self._grep !== self._defaultGrep) { |
| 6223 | Runner.immediately(next); |
| 6224 | } else { |
| 6225 | next(); |
| 6226 | } |
| 6227 | return; |
| 6228 | } |
| 6229 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6230 | // static skip, no hooks are executed |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6231 | if (test.isPending()) { |
| 6232 | if (self.forbidPending) { |
| 6233 | test.isPending = alwaysFalse; |
| 6234 | self.fail(test, new Error('Pending test forbidden')); |
| 6235 | delete test.isPending; |
| 6236 | } else { |
| 6237 | self.emit(constants.EVENT_TEST_PENDING, test); |
| 6238 | } |
| 6239 | self.emit(constants.EVENT_TEST_END, test); |
| 6240 | return next(); |
| 6241 | } |
| 6242 | |
| 6243 | // execute test and hook(s) |
| 6244 | self.emit(constants.EVENT_TEST_BEGIN, (self.test = test)); |
| 6245 | self.hookDown(HOOK_TYPE_BEFORE_EACH, function(err, errSuite) { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6246 | // conditional skip within beforeEach |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6247 | if (test.isPending()) { |
| 6248 | if (self.forbidPending) { |
| 6249 | test.isPending = alwaysFalse; |
| 6250 | self.fail(test, new Error('Pending test forbidden')); |
| 6251 | delete test.isPending; |
| 6252 | } else { |
| 6253 | self.emit(constants.EVENT_TEST_PENDING, test); |
| 6254 | } |
| 6255 | self.emit(constants.EVENT_TEST_END, test); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6256 | // skip inner afterEach hooks below errSuite level |
| 6257 | var origSuite = self.suite; |
| 6258 | self.suite = errSuite || self.suite; |
| 6259 | return self.hookUp(HOOK_TYPE_AFTER_EACH, function(e, eSuite) { |
| 6260 | self.suite = origSuite; |
| 6261 | next(e, eSuite); |
| 6262 | }); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6263 | } |
| 6264 | if (err) { |
| 6265 | return hookErr(err, errSuite, false); |
| 6266 | } |
| 6267 | self.currentRunnable = self.test; |
| 6268 | self.runTest(function(err) { |
| 6269 | test = self.test; |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6270 | // conditional skip within it |
| 6271 | if (test.pending) { |
| 6272 | if (self.forbidPending) { |
| 6273 | test.isPending = alwaysFalse; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6274 | self.fail(test, new Error('Pending test forbidden')); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6275 | delete test.isPending; |
| 6276 | } else { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6277 | self.emit(constants.EVENT_TEST_PENDING, test); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6278 | } |
| 6279 | self.emit(constants.EVENT_TEST_END, test); |
| 6280 | return self.hookUp(HOOK_TYPE_AFTER_EACH, next); |
| 6281 | } else if (err) { |
| 6282 | var retry = test.currentRetry(); |
| 6283 | if (retry < test.retries()) { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6284 | var clonedTest = test.clone(); |
| 6285 | clonedTest.currentRetry(retry + 1); |
| 6286 | tests.unshift(clonedTest); |
| 6287 | |
| 6288 | self.emit(constants.EVENT_TEST_RETRY, test, err); |
| 6289 | |
| 6290 | // Early return + hook trigger so that it doesn't |
| 6291 | // increment the count wrong |
| 6292 | return self.hookUp(HOOK_TYPE_AFTER_EACH, next); |
| 6293 | } else { |
| 6294 | self.fail(test, err); |
| 6295 | } |
| 6296 | self.emit(constants.EVENT_TEST_END, test); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6297 | return self.hookUp(HOOK_TYPE_AFTER_EACH, next); |
| 6298 | } |
| 6299 | |
| 6300 | test.state = STATE_PASSED; |
| 6301 | self.emit(constants.EVENT_TEST_PASS, test); |
| 6302 | self.emit(constants.EVENT_TEST_END, test); |
| 6303 | self.hookUp(HOOK_TYPE_AFTER_EACH, next); |
| 6304 | }); |
| 6305 | }); |
| 6306 | } |
| 6307 | |
| 6308 | this.next = next; |
| 6309 | this.hookErr = hookErr; |
| 6310 | next(); |
| 6311 | }; |
| 6312 | |
| 6313 | function alwaysFalse() { |
| 6314 | return false; |
| 6315 | } |
| 6316 | |
| 6317 | /** |
| 6318 | * Run the given `suite` and invoke the callback `fn()` when complete. |
| 6319 | * |
| 6320 | * @private |
| 6321 | * @param {Suite} suite |
| 6322 | * @param {Function} fn |
| 6323 | */ |
| 6324 | Runner.prototype.runSuite = function(suite, fn) { |
| 6325 | var i = 0; |
| 6326 | var self = this; |
| 6327 | var total = this.grepTotal(suite); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6328 | |
| 6329 | debug('run suite %s', suite.fullTitle()); |
| 6330 | |
| 6331 | if (!total || (self.failures && suite._bail)) { |
| 6332 | return fn(); |
| 6333 | } |
| 6334 | |
| 6335 | this.emit(constants.EVENT_SUITE_BEGIN, (this.suite = suite)); |
| 6336 | |
| 6337 | function next(errSuite) { |
| 6338 | if (errSuite) { |
| 6339 | // current suite failed on a hook from errSuite |
| 6340 | if (errSuite === suite) { |
| 6341 | // if errSuite is current suite |
| 6342 | // continue to the next sibling suite |
| 6343 | return done(); |
| 6344 | } |
| 6345 | // errSuite is among the parents of current suite |
| 6346 | // stop execution of errSuite and all sub-suites |
| 6347 | return done(errSuite); |
| 6348 | } |
| 6349 | |
| 6350 | if (self._abort) { |
| 6351 | return done(); |
| 6352 | } |
| 6353 | |
| 6354 | var curr = suite.suites[i++]; |
| 6355 | if (!curr) { |
| 6356 | return done(); |
| 6357 | } |
| 6358 | |
| 6359 | // Avoid grep neglecting large number of tests causing a |
| 6360 | // huge recursive loop and thus a maximum call stack error. |
| 6361 | // See comment in `this.runTests()` for more information. |
| 6362 | if (self._grep !== self._defaultGrep) { |
| 6363 | Runner.immediately(function() { |
| 6364 | self.runSuite(curr, next); |
| 6365 | }); |
| 6366 | } else { |
| 6367 | self.runSuite(curr, next); |
| 6368 | } |
| 6369 | } |
| 6370 | |
| 6371 | function done(errSuite) { |
| 6372 | self.suite = suite; |
| 6373 | self.nextSuite = next; |
| 6374 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6375 | // remove reference to test |
| 6376 | delete self.test; |
| 6377 | |
| 6378 | self.hook(HOOK_TYPE_AFTER_ALL, function() { |
| 6379 | self.emit(constants.EVENT_SUITE_END, suite); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6380 | fn(errSuite); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6381 | }); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6382 | } |
| 6383 | |
| 6384 | this.nextSuite = next; |
| 6385 | |
| 6386 | this.hook(HOOK_TYPE_BEFORE_ALL, function(err) { |
| 6387 | if (err) { |
| 6388 | return done(); |
| 6389 | } |
| 6390 | self.runTests(suite, next); |
| 6391 | }); |
| 6392 | }; |
| 6393 | |
| 6394 | /** |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6395 | * Handle uncaught exceptions within runner. |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6396 | * |
| 6397 | * @param {Error} err |
| 6398 | * @private |
| 6399 | */ |
| 6400 | Runner.prototype.uncaught = function(err) { |
| 6401 | if (err instanceof Pending) { |
| 6402 | return; |
| 6403 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6404 | // browser does not exit script when throwing in global.onerror() |
| 6405 | if (this.allowUncaught && !process.browser) { |
| 6406 | throw err; |
| 6407 | } |
| 6408 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6409 | if (err) { |
| 6410 | debug('uncaught exception %O', err); |
| 6411 | } else { |
| 6412 | debug('uncaught undefined/falsy exception'); |
| 6413 | err = createInvalidExceptionError( |
| 6414 | 'Caught falsy/undefined exception which would otherwise be uncaught. No stack trace found; try a debugger', |
| 6415 | err |
| 6416 | ); |
| 6417 | } |
| 6418 | |
| 6419 | if (!isError(err)) { |
| 6420 | err = thrown2Error(err); |
| 6421 | } |
| 6422 | err.uncaught = true; |
| 6423 | |
| 6424 | var runnable = this.currentRunnable; |
| 6425 | |
| 6426 | if (!runnable) { |
| 6427 | runnable = new Runnable('Uncaught error outside test suite'); |
| 6428 | runnable.parent = this.suite; |
| 6429 | |
| 6430 | if (this.started) { |
| 6431 | this.fail(runnable, err); |
| 6432 | } else { |
| 6433 | // Can't recover from this failure |
| 6434 | this.emit(constants.EVENT_RUN_BEGIN); |
| 6435 | this.fail(runnable, err); |
| 6436 | this.emit(constants.EVENT_RUN_END); |
| 6437 | } |
| 6438 | |
| 6439 | return; |
| 6440 | } |
| 6441 | |
| 6442 | runnable.clearTimeout(); |
| 6443 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6444 | if (runnable.isFailed()) { |
| 6445 | // Ignore error if already failed |
| 6446 | return; |
| 6447 | } else if (runnable.isPending()) { |
| 6448 | // report 'pending test' retrospectively as failed |
| 6449 | runnable.isPending = alwaysFalse; |
| 6450 | this.fail(runnable, err); |
| 6451 | delete runnable.isPending; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6452 | return; |
| 6453 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6454 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6455 | // we cannot recover gracefully if a Runnable has already passed |
| 6456 | // then fails asynchronously |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6457 | if (runnable.isPassed()) { |
| 6458 | this.fail(runnable, err); |
| 6459 | this.abort(); |
| 6460 | } else { |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6461 | debug(runnable); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6462 | return runnable.callback(err); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6463 | } |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6464 | }; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6465 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6466 | /** |
| 6467 | * Handle uncaught exceptions after runner's end event. |
| 6468 | * |
| 6469 | * @param {Error} err |
| 6470 | * @private |
| 6471 | */ |
| 6472 | Runner.prototype.uncaughtEnd = function uncaughtEnd(err) { |
| 6473 | if (err instanceof Pending) return; |
| 6474 | throw err; |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6475 | }; |
| 6476 | |
| 6477 | /** |
| 6478 | * Run the root suite and invoke `fn(failures)` |
| 6479 | * on completion. |
| 6480 | * |
| 6481 | * @public |
| 6482 | * @memberof Runner |
| 6483 | * @param {Function} fn |
| 6484 | * @return {Runner} Runner instance. |
| 6485 | */ |
| 6486 | Runner.prototype.run = function(fn) { |
| 6487 | var self = this; |
| 6488 | var rootSuite = this.suite; |
| 6489 | |
| 6490 | fn = fn || function() {}; |
| 6491 | |
| 6492 | function uncaught(err) { |
| 6493 | self.uncaught(err); |
| 6494 | } |
| 6495 | |
| 6496 | function start() { |
| 6497 | // If there is an `only` filter |
| 6498 | if (rootSuite.hasOnly()) { |
| 6499 | rootSuite.filterOnly(); |
| 6500 | } |
| 6501 | self.started = true; |
| 6502 | if (self._delay) { |
| 6503 | self.emit(constants.EVENT_DELAY_END); |
| 6504 | } |
| 6505 | self.emit(constants.EVENT_RUN_BEGIN); |
| 6506 | |
| 6507 | self.runSuite(rootSuite, function() { |
| 6508 | debug('finished running'); |
| 6509 | self.emit(constants.EVENT_RUN_END); |
| 6510 | }); |
| 6511 | } |
| 6512 | |
| 6513 | debug(constants.EVENT_RUN_BEGIN); |
| 6514 | |
| 6515 | // references cleanup to avoid memory leaks |
| 6516 | this.on(constants.EVENT_SUITE_END, function(suite) { |
| 6517 | suite.cleanReferences(); |
| 6518 | }); |
| 6519 | |
| 6520 | // callback |
| 6521 | this.on(constants.EVENT_RUN_END, function() { |
| 6522 | debug(constants.EVENT_RUN_END); |
| 6523 | process.removeListener('uncaughtException', uncaught); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6524 | process.on('uncaughtException', self.uncaughtEnd); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6525 | fn(self.failures); |
| 6526 | }); |
| 6527 | |
| 6528 | // uncaught exception |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6529 | process.removeListener('uncaughtException', self.uncaughtEnd); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6530 | process.on('uncaughtException', uncaught); |
| 6531 | |
| 6532 | if (this._delay) { |
| 6533 | // for reporters, I guess. |
| 6534 | // might be nice to debounce some dots while we wait. |
| 6535 | this.emit(constants.EVENT_DELAY_BEGIN, rootSuite); |
| 6536 | rootSuite.once(EVENT_ROOT_SUITE_RUN, start); |
| 6537 | } else { |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 6538 | Runner.immediately(function() { |
| 6539 | start(); |
| 6540 | }); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6541 | } |
| 6542 | |
| 6543 | return this; |
| 6544 | }; |
| 6545 | |
| 6546 | /** |
| 6547 | * Cleanly abort execution. |
| 6548 | * |
| 6549 | * @memberof Runner |
| 6550 | * @public |
| 6551 | * @return {Runner} Runner instance. |
| 6552 | */ |
| 6553 | Runner.prototype.abort = function() { |
| 6554 | debug('aborting'); |
| 6555 | this._abort = true; |
| 6556 | |
| 6557 | return this; |
| 6558 | }; |
| 6559 | |
| 6560 | /** |
| 6561 | * Filter leaks with the given globals flagged as `ok`. |
| 6562 | * |
| 6563 | * @private |
| 6564 | * @param {Array} ok |
| 6565 | * @param {Array} globals |
| 6566 | * @return {Array} |
| 6567 | */ |
| 6568 | function filterLeaks(ok, globals) { |
| 6569 | return globals.filter(function(key) { |
| 6570 | // Firefox and Chrome exposes iframes as index inside the window object |
| 6571 | if (/^\d+/.test(key)) { |
| 6572 | return false; |
| 6573 | } |
| 6574 | |
| 6575 | // in firefox |
| 6576 | // if runner runs in an iframe, this iframe's window.getInterface method |
| 6577 | // not init at first it is assigned in some seconds |
| 6578 | if (global.navigator && /^getInterface/.test(key)) { |
| 6579 | return false; |
| 6580 | } |
| 6581 | |
| 6582 | // an iframe could be approached by window[iframeIndex] |
| 6583 | // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak |
| 6584 | if (global.navigator && /^\d+/.test(key)) { |
| 6585 | return false; |
| 6586 | } |
| 6587 | |
| 6588 | // Opera and IE expose global variables for HTML element IDs (issue #243) |
| 6589 | if (/^mocha-/.test(key)) { |
| 6590 | return false; |
| 6591 | } |
| 6592 | |
| 6593 | var matched = ok.filter(function(ok) { |
| 6594 | if (~ok.indexOf('*')) { |
| 6595 | return key.indexOf(ok.split('*')[0]) === 0; |
| 6596 | } |
| 6597 | return key === ok; |
| 6598 | }); |
| 6599 | return !matched.length && (!global.navigator || key !== 'onerror'); |
| 6600 | }); |
| 6601 | } |
| 6602 | |
| 6603 | /** |
| 6604 | * Check if argument is an instance of Error object or a duck-typed equivalent. |
| 6605 | * |
| 6606 | * @private |
| 6607 | * @param {Object} err - object to check |
| 6608 | * @param {string} err.message - error message |
| 6609 | * @returns {boolean} |
| 6610 | */ |
| 6611 | function isError(err) { |
| 6612 | return err instanceof Error || (err && typeof err.message === 'string'); |
| 6613 | } |
| 6614 | |
| 6615 | /** |
| 6616 | * |
| 6617 | * Converts thrown non-extensible type into proper Error. |
| 6618 | * |
| 6619 | * @private |
| 6620 | * @param {*} thrown - Non-extensible type thrown by code |
| 6621 | * @return {Error} |
| 6622 | */ |
| 6623 | function thrown2Error(err) { |
| 6624 | return new Error( |
| 6625 | 'the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)' |
| 6626 | ); |
| 6627 | } |
| 6628 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 6629 | Runner.constants = constants; |
| 6630 | |
| 6631 | /** |
| 6632 | * Node.js' `EventEmitter` |
| 6633 | * @external EventEmitter |
| 6634 | * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter} |
| 6635 | */ |
| 6636 | |
| 6637 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 6638 | },{"./errors":6,"./pending":16,"./runnable":33,"./suite":36,"./utils":38,"_process":69,"debug":45,"events":50,"util":89}],35:[function(require,module,exports){ |
| 6639 | (function (global){ |
| 6640 | 'use strict'; |
| 6641 | |
| 6642 | /** |
| 6643 | * Provides a factory function for a {@link StatsCollector} object. |
| 6644 | * @module |
| 6645 | */ |
| 6646 | |
| 6647 | var constants = require('./runner').constants; |
| 6648 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; |
| 6649 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL; |
| 6650 | var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; |
| 6651 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN; |
| 6652 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING; |
| 6653 | var EVENT_RUN_END = constants.EVENT_RUN_END; |
| 6654 | var EVENT_TEST_END = constants.EVENT_TEST_END; |
| 6655 | |
| 6656 | /** |
| 6657 | * Test statistics collector. |
| 6658 | * |
| 6659 | * @public |
| 6660 | * @typedef {Object} StatsCollector |
| 6661 | * @property {number} suites - integer count of suites run. |
| 6662 | * @property {number} tests - integer count of tests run. |
| 6663 | * @property {number} passes - integer count of passing tests. |
| 6664 | * @property {number} pending - integer count of pending tests. |
| 6665 | * @property {number} failures - integer count of failed tests. |
| 6666 | * @property {Date} start - time when testing began. |
| 6667 | * @property {Date} end - time when testing concluded. |
| 6668 | * @property {number} duration - number of msecs that testing took. |
| 6669 | */ |
| 6670 | |
| 6671 | var Date = global.Date; |
| 6672 | |
| 6673 | /** |
| 6674 | * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`. |
| 6675 | * |
| 6676 | * @private |
| 6677 | * @param {Runner} runner - Runner instance |
| 6678 | * @throws {TypeError} If falsy `runner` |
| 6679 | */ |
| 6680 | function createStatsCollector(runner) { |
| 6681 | /** |
| 6682 | * @type StatsCollector |
| 6683 | */ |
| 6684 | var stats = { |
| 6685 | suites: 0, |
| 6686 | tests: 0, |
| 6687 | passes: 0, |
| 6688 | pending: 0, |
| 6689 | failures: 0 |
| 6690 | }; |
| 6691 | |
| 6692 | if (!runner) { |
| 6693 | throw new TypeError('Missing runner argument'); |
| 6694 | } |
| 6695 | |
| 6696 | runner.stats = stats; |
| 6697 | |
| 6698 | runner.once(EVENT_RUN_BEGIN, function() { |
| 6699 | stats.start = new Date(); |
| 6700 | }); |
| 6701 | runner.on(EVENT_SUITE_BEGIN, function(suite) { |
| 6702 | suite.root || stats.suites++; |
| 6703 | }); |
| 6704 | runner.on(EVENT_TEST_PASS, function() { |
| 6705 | stats.passes++; |
| 6706 | }); |
| 6707 | runner.on(EVENT_TEST_FAIL, function() { |
| 6708 | stats.failures++; |
| 6709 | }); |
| 6710 | runner.on(EVENT_TEST_PENDING, function() { |
| 6711 | stats.pending++; |
| 6712 | }); |
| 6713 | runner.on(EVENT_TEST_END, function() { |
| 6714 | stats.tests++; |
| 6715 | }); |
| 6716 | runner.once(EVENT_RUN_END, function() { |
| 6717 | stats.end = new Date(); |
| 6718 | stats.duration = stats.end - stats.start; |
| 6719 | }); |
| 6720 | } |
| 6721 | |
| 6722 | module.exports = createStatsCollector; |
| 6723 | |
| 6724 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 6725 | },{"./runner":34}],36:[function(require,module,exports){ |
| 6726 | 'use strict'; |
| 6727 | |
| 6728 | /** |
| 6729 | * Module dependencies. |
| 6730 | */ |
| 6731 | var EventEmitter = require('events').EventEmitter; |
| 6732 | var Hook = require('./hook'); |
| 6733 | var utils = require('./utils'); |
| 6734 | var inherits = utils.inherits; |
| 6735 | var debug = require('debug')('mocha:suite'); |
| 6736 | var milliseconds = require('ms'); |
| 6737 | var errors = require('./errors'); |
| 6738 | var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError; |
| 6739 | |
| 6740 | /** |
| 6741 | * Expose `Suite`. |
| 6742 | */ |
| 6743 | |
| 6744 | exports = module.exports = Suite; |
| 6745 | |
| 6746 | /** |
| 6747 | * Create a new `Suite` with the given `title` and parent `Suite`. |
| 6748 | * |
| 6749 | * @public |
| 6750 | * @param {Suite} parent - Parent suite (required!) |
| 6751 | * @param {string} title - Title |
| 6752 | * @return {Suite} |
| 6753 | */ |
| 6754 | Suite.create = function(parent, title) { |
| 6755 | var suite = new Suite(title, parent.ctx); |
| 6756 | suite.parent = parent; |
| 6757 | title = suite.fullTitle(); |
| 6758 | parent.addSuite(suite); |
| 6759 | return suite; |
| 6760 | }; |
| 6761 | |
| 6762 | /** |
| 6763 | * Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`. |
| 6764 | * |
| 6765 | * @public |
| 6766 | * @class |
| 6767 | * @extends EventEmitter |
| 6768 | * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter} |
| 6769 | * @param {string} title - Suite title. |
| 6770 | * @param {Context} parentContext - Parent context instance. |
| 6771 | * @param {boolean} [isRoot=false] - Whether this is the root suite. |
| 6772 | */ |
| 6773 | function Suite(title, parentContext, isRoot) { |
| 6774 | if (!utils.isString(title)) { |
| 6775 | throw createInvalidArgumentTypeError( |
| 6776 | 'Suite argument "title" must be a string. Received type "' + |
| 6777 | typeof title + |
| 6778 | '"', |
| 6779 | 'title', |
| 6780 | 'string' |
| 6781 | ); |
| 6782 | } |
| 6783 | this.title = title; |
| 6784 | function Context() {} |
| 6785 | Context.prototype = parentContext; |
| 6786 | this.ctx = new Context(); |
| 6787 | this.suites = []; |
| 6788 | this.tests = []; |
| 6789 | this.pending = false; |
| 6790 | this._beforeEach = []; |
| 6791 | this._beforeAll = []; |
| 6792 | this._afterEach = []; |
| 6793 | this._afterAll = []; |
| 6794 | this.root = isRoot === true; |
| 6795 | this._timeout = 2000; |
| 6796 | this._enableTimeouts = true; |
| 6797 | this._slow = 75; |
| 6798 | this._bail = false; |
| 6799 | this._retries = -1; |
| 6800 | this._onlyTests = []; |
| 6801 | this._onlySuites = []; |
| 6802 | this.delayed = false; |
| 6803 | |
| 6804 | this.on('newListener', function(event) { |
| 6805 | if (deprecatedEvents[event]) { |
| 6806 | utils.deprecate( |
| 6807 | 'Event "' + |
| 6808 | event + |
| 6809 | '" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm' |
| 6810 | ); |
| 6811 | } |
| 6812 | }); |
| 6813 | } |
| 6814 | |
| 6815 | /** |
| 6816 | * Inherit from `EventEmitter.prototype`. |
| 6817 | */ |
| 6818 | inherits(Suite, EventEmitter); |
| 6819 | |
| 6820 | /** |
| 6821 | * Return a clone of this `Suite`. |
| 6822 | * |
| 6823 | * @private |
| 6824 | * @return {Suite} |
| 6825 | */ |
| 6826 | Suite.prototype.clone = function() { |
| 6827 | var suite = new Suite(this.title); |
| 6828 | debug('clone'); |
| 6829 | suite.ctx = this.ctx; |
| 6830 | suite.root = this.root; |
| 6831 | suite.timeout(this.timeout()); |
| 6832 | suite.retries(this.retries()); |
| 6833 | suite.enableTimeouts(this.enableTimeouts()); |
| 6834 | suite.slow(this.slow()); |
| 6835 | suite.bail(this.bail()); |
| 6836 | return suite; |
| 6837 | }; |
| 6838 | |
| 6839 | /** |
| 6840 | * Set or get timeout `ms` or short-hand such as "2s". |
| 6841 | * |
| 6842 | * @private |
| 6843 | * @todo Do not attempt to set value if `ms` is undefined |
| 6844 | * @param {number|string} ms |
| 6845 | * @return {Suite|number} for chaining |
| 6846 | */ |
| 6847 | Suite.prototype.timeout = function(ms) { |
| 6848 | if (!arguments.length) { |
| 6849 | return this._timeout; |
| 6850 | } |
| 6851 | if (ms.toString() === '0') { |
| 6852 | this._enableTimeouts = false; |
| 6853 | } |
| 6854 | if (typeof ms === 'string') { |
| 6855 | ms = milliseconds(ms); |
| 6856 | } |
| 6857 | debug('timeout %d', ms); |
| 6858 | this._timeout = parseInt(ms, 10); |
| 6859 | return this; |
| 6860 | }; |
| 6861 | |
| 6862 | /** |
| 6863 | * Set or get number of times to retry a failed test. |
| 6864 | * |
| 6865 | * @private |
| 6866 | * @param {number|string} n |
| 6867 | * @return {Suite|number} for chaining |
| 6868 | */ |
| 6869 | Suite.prototype.retries = function(n) { |
| 6870 | if (!arguments.length) { |
| 6871 | return this._retries; |
| 6872 | } |
| 6873 | debug('retries %d', n); |
| 6874 | this._retries = parseInt(n, 10) || 0; |
| 6875 | return this; |
| 6876 | }; |
| 6877 | |
| 6878 | /** |
| 6879 | * Set or get timeout to `enabled`. |
| 6880 | * |
| 6881 | * @private |
| 6882 | * @param {boolean} enabled |
| 6883 | * @return {Suite|boolean} self or enabled |
| 6884 | */ |
| 6885 | Suite.prototype.enableTimeouts = function(enabled) { |
| 6886 | if (!arguments.length) { |
| 6887 | return this._enableTimeouts; |
| 6888 | } |
| 6889 | debug('enableTimeouts %s', enabled); |
| 6890 | this._enableTimeouts = enabled; |
| 6891 | return this; |
| 6892 | }; |
| 6893 | |
| 6894 | /** |
| 6895 | * Set or get slow `ms` or short-hand such as "2s". |
| 6896 | * |
| 6897 | * @private |
| 6898 | * @param {number|string} ms |
| 6899 | * @return {Suite|number} for chaining |
| 6900 | */ |
| 6901 | Suite.prototype.slow = function(ms) { |
| 6902 | if (!arguments.length) { |
| 6903 | return this._slow; |
| 6904 | } |
| 6905 | if (typeof ms === 'string') { |
| 6906 | ms = milliseconds(ms); |
| 6907 | } |
| 6908 | debug('slow %d', ms); |
| 6909 | this._slow = ms; |
| 6910 | return this; |
| 6911 | }; |
| 6912 | |
| 6913 | /** |
| 6914 | * Set or get whether to bail after first error. |
| 6915 | * |
| 6916 | * @private |
| 6917 | * @param {boolean} bail |
| 6918 | * @return {Suite|number} for chaining |
| 6919 | */ |
| 6920 | Suite.prototype.bail = function(bail) { |
| 6921 | if (!arguments.length) { |
| 6922 | return this._bail; |
| 6923 | } |
| 6924 | debug('bail %s', bail); |
| 6925 | this._bail = bail; |
| 6926 | return this; |
| 6927 | }; |
| 6928 | |
| 6929 | /** |
| 6930 | * Check if this suite or its parent suite is marked as pending. |
| 6931 | * |
| 6932 | * @private |
| 6933 | */ |
| 6934 | Suite.prototype.isPending = function() { |
| 6935 | return this.pending || (this.parent && this.parent.isPending()); |
| 6936 | }; |
| 6937 | |
| 6938 | /** |
| 6939 | * Generic hook-creator. |
| 6940 | * @private |
| 6941 | * @param {string} title - Title of hook |
| 6942 | * @param {Function} fn - Hook callback |
| 6943 | * @returns {Hook} A new hook |
| 6944 | */ |
| 6945 | Suite.prototype._createHook = function(title, fn) { |
| 6946 | var hook = new Hook(title, fn); |
| 6947 | hook.parent = this; |
| 6948 | hook.timeout(this.timeout()); |
| 6949 | hook.retries(this.retries()); |
| 6950 | hook.enableTimeouts(this.enableTimeouts()); |
| 6951 | hook.slow(this.slow()); |
| 6952 | hook.ctx = this.ctx; |
| 6953 | hook.file = this.file; |
| 6954 | return hook; |
| 6955 | }; |
| 6956 | |
| 6957 | /** |
| 6958 | * Run `fn(test[, done])` before running tests. |
| 6959 | * |
| 6960 | * @private |
| 6961 | * @param {string} title |
| 6962 | * @param {Function} fn |
| 6963 | * @return {Suite} for chaining |
| 6964 | */ |
| 6965 | Suite.prototype.beforeAll = function(title, fn) { |
| 6966 | if (this.isPending()) { |
| 6967 | return this; |
| 6968 | } |
| 6969 | if (typeof title === 'function') { |
| 6970 | fn = title; |
| 6971 | title = fn.name; |
| 6972 | } |
| 6973 | title = '"before all" hook' + (title ? ': ' + title : ''); |
| 6974 | |
| 6975 | var hook = this._createHook(title, fn); |
| 6976 | this._beforeAll.push(hook); |
| 6977 | this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook); |
| 6978 | return this; |
| 6979 | }; |
| 6980 | |
| 6981 | /** |
| 6982 | * Run `fn(test[, done])` after running tests. |
| 6983 | * |
| 6984 | * @private |
| 6985 | * @param {string} title |
| 6986 | * @param {Function} fn |
| 6987 | * @return {Suite} for chaining |
| 6988 | */ |
| 6989 | Suite.prototype.afterAll = function(title, fn) { |
| 6990 | if (this.isPending()) { |
| 6991 | return this; |
| 6992 | } |
| 6993 | if (typeof title === 'function') { |
| 6994 | fn = title; |
| 6995 | title = fn.name; |
| 6996 | } |
| 6997 | title = '"after all" hook' + (title ? ': ' + title : ''); |
| 6998 | |
| 6999 | var hook = this._createHook(title, fn); |
| 7000 | this._afterAll.push(hook); |
| 7001 | this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook); |
| 7002 | return this; |
| 7003 | }; |
| 7004 | |
| 7005 | /** |
| 7006 | * Run `fn(test[, done])` before each test case. |
| 7007 | * |
| 7008 | * @private |
| 7009 | * @param {string} title |
| 7010 | * @param {Function} fn |
| 7011 | * @return {Suite} for chaining |
| 7012 | */ |
| 7013 | Suite.prototype.beforeEach = function(title, fn) { |
| 7014 | if (this.isPending()) { |
| 7015 | return this; |
| 7016 | } |
| 7017 | if (typeof title === 'function') { |
| 7018 | fn = title; |
| 7019 | title = fn.name; |
| 7020 | } |
| 7021 | title = '"before each" hook' + (title ? ': ' + title : ''); |
| 7022 | |
| 7023 | var hook = this._createHook(title, fn); |
| 7024 | this._beforeEach.push(hook); |
| 7025 | this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook); |
| 7026 | return this; |
| 7027 | }; |
| 7028 | |
| 7029 | /** |
| 7030 | * Run `fn(test[, done])` after each test case. |
| 7031 | * |
| 7032 | * @private |
| 7033 | * @param {string} title |
| 7034 | * @param {Function} fn |
| 7035 | * @return {Suite} for chaining |
| 7036 | */ |
| 7037 | Suite.prototype.afterEach = function(title, fn) { |
| 7038 | if (this.isPending()) { |
| 7039 | return this; |
| 7040 | } |
| 7041 | if (typeof title === 'function') { |
| 7042 | fn = title; |
| 7043 | title = fn.name; |
| 7044 | } |
| 7045 | title = '"after each" hook' + (title ? ': ' + title : ''); |
| 7046 | |
| 7047 | var hook = this._createHook(title, fn); |
| 7048 | this._afterEach.push(hook); |
| 7049 | this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook); |
| 7050 | return this; |
| 7051 | }; |
| 7052 | |
| 7053 | /** |
| 7054 | * Add a test `suite`. |
| 7055 | * |
| 7056 | * @private |
| 7057 | * @param {Suite} suite |
| 7058 | * @return {Suite} for chaining |
| 7059 | */ |
| 7060 | Suite.prototype.addSuite = function(suite) { |
| 7061 | suite.parent = this; |
| 7062 | suite.root = false; |
| 7063 | suite.timeout(this.timeout()); |
| 7064 | suite.retries(this.retries()); |
| 7065 | suite.enableTimeouts(this.enableTimeouts()); |
| 7066 | suite.slow(this.slow()); |
| 7067 | suite.bail(this.bail()); |
| 7068 | this.suites.push(suite); |
| 7069 | this.emit(constants.EVENT_SUITE_ADD_SUITE, suite); |
| 7070 | return this; |
| 7071 | }; |
| 7072 | |
| 7073 | /** |
| 7074 | * Add a `test` to this suite. |
| 7075 | * |
| 7076 | * @private |
| 7077 | * @param {Test} test |
| 7078 | * @return {Suite} for chaining |
| 7079 | */ |
| 7080 | Suite.prototype.addTest = function(test) { |
| 7081 | test.parent = this; |
| 7082 | test.timeout(this.timeout()); |
| 7083 | test.retries(this.retries()); |
| 7084 | test.enableTimeouts(this.enableTimeouts()); |
| 7085 | test.slow(this.slow()); |
| 7086 | test.ctx = this.ctx; |
| 7087 | this.tests.push(test); |
| 7088 | this.emit(constants.EVENT_SUITE_ADD_TEST, test); |
| 7089 | return this; |
| 7090 | }; |
| 7091 | |
| 7092 | /** |
| 7093 | * Return the full title generated by recursively concatenating the parent's |
| 7094 | * full title. |
| 7095 | * |
| 7096 | * @memberof Suite |
| 7097 | * @public |
| 7098 | * @return {string} |
| 7099 | */ |
| 7100 | Suite.prototype.fullTitle = function() { |
| 7101 | return this.titlePath().join(' '); |
| 7102 | }; |
| 7103 | |
| 7104 | /** |
| 7105 | * Return the title path generated by recursively concatenating the parent's |
| 7106 | * title path. |
| 7107 | * |
| 7108 | * @memberof Suite |
| 7109 | * @public |
| 7110 | * @return {string} |
| 7111 | */ |
| 7112 | Suite.prototype.titlePath = function() { |
| 7113 | var result = []; |
| 7114 | if (this.parent) { |
| 7115 | result = result.concat(this.parent.titlePath()); |
| 7116 | } |
| 7117 | if (!this.root) { |
| 7118 | result.push(this.title); |
| 7119 | } |
| 7120 | return result; |
| 7121 | }; |
| 7122 | |
| 7123 | /** |
| 7124 | * Return the total number of tests. |
| 7125 | * |
| 7126 | * @memberof Suite |
| 7127 | * @public |
| 7128 | * @return {number} |
| 7129 | */ |
| 7130 | Suite.prototype.total = function() { |
| 7131 | return ( |
| 7132 | this.suites.reduce(function(sum, suite) { |
| 7133 | return sum + suite.total(); |
| 7134 | }, 0) + this.tests.length |
| 7135 | ); |
| 7136 | }; |
| 7137 | |
| 7138 | /** |
| 7139 | * Iterates through each suite recursively to find all tests. Applies a |
| 7140 | * function in the format `fn(test)`. |
| 7141 | * |
| 7142 | * @private |
| 7143 | * @param {Function} fn |
| 7144 | * @return {Suite} |
| 7145 | */ |
| 7146 | Suite.prototype.eachTest = function(fn) { |
| 7147 | this.tests.forEach(fn); |
| 7148 | this.suites.forEach(function(suite) { |
| 7149 | suite.eachTest(fn); |
| 7150 | }); |
| 7151 | return this; |
| 7152 | }; |
| 7153 | |
| 7154 | /** |
| 7155 | * This will run the root suite if we happen to be running in delayed mode. |
| 7156 | * @private |
| 7157 | */ |
| 7158 | Suite.prototype.run = function run() { |
| 7159 | if (this.root) { |
| 7160 | this.emit(constants.EVENT_ROOT_SUITE_RUN); |
| 7161 | } |
| 7162 | }; |
| 7163 | |
| 7164 | /** |
| 7165 | * Determines whether a suite has an `only` test or suite as a descendant. |
| 7166 | * |
| 7167 | * @private |
| 7168 | * @returns {Boolean} |
| 7169 | */ |
| 7170 | Suite.prototype.hasOnly = function hasOnly() { |
| 7171 | return ( |
| 7172 | this._onlyTests.length > 0 || |
| 7173 | this._onlySuites.length > 0 || |
| 7174 | this.suites.some(function(suite) { |
| 7175 | return suite.hasOnly(); |
| 7176 | }) |
| 7177 | ); |
| 7178 | }; |
| 7179 | |
| 7180 | /** |
| 7181 | * Filter suites based on `isOnly` logic. |
| 7182 | * |
| 7183 | * @private |
| 7184 | * @returns {Boolean} |
| 7185 | */ |
| 7186 | Suite.prototype.filterOnly = function filterOnly() { |
| 7187 | if (this._onlyTests.length) { |
| 7188 | // If the suite contains `only` tests, run those and ignore any nested suites. |
| 7189 | this.tests = this._onlyTests; |
| 7190 | this.suites = []; |
| 7191 | } else { |
| 7192 | // Otherwise, do not run any of the tests in this suite. |
| 7193 | this.tests = []; |
| 7194 | this._onlySuites.forEach(function(onlySuite) { |
| 7195 | // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite. |
| 7196 | // Otherwise, all of the tests on this `only` suite should be run, so don't filter it. |
| 7197 | if (onlySuite.hasOnly()) { |
| 7198 | onlySuite.filterOnly(); |
| 7199 | } |
| 7200 | }); |
| 7201 | // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants. |
| 7202 | var onlySuites = this._onlySuites; |
| 7203 | this.suites = this.suites.filter(function(childSuite) { |
| 7204 | return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly(); |
| 7205 | }); |
| 7206 | } |
| 7207 | // Keep the suite only if there is something to run |
| 7208 | return this.tests.length > 0 || this.suites.length > 0; |
| 7209 | }; |
| 7210 | |
| 7211 | /** |
| 7212 | * Adds a suite to the list of subsuites marked `only`. |
| 7213 | * |
| 7214 | * @private |
| 7215 | * @param {Suite} suite |
| 7216 | */ |
| 7217 | Suite.prototype.appendOnlySuite = function(suite) { |
| 7218 | this._onlySuites.push(suite); |
| 7219 | }; |
| 7220 | |
| 7221 | /** |
| 7222 | * Adds a test to the list of tests marked `only`. |
| 7223 | * |
| 7224 | * @private |
| 7225 | * @param {Test} test |
| 7226 | */ |
| 7227 | Suite.prototype.appendOnlyTest = function(test) { |
| 7228 | this._onlyTests.push(test); |
| 7229 | }; |
| 7230 | |
| 7231 | /** |
| 7232 | * Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants. |
| 7233 | * @private |
| 7234 | */ |
| 7235 | Suite.prototype.getHooks = function getHooks(name) { |
| 7236 | return this['_' + name]; |
| 7237 | }; |
| 7238 | |
| 7239 | /** |
| 7240 | * Cleans up the references to all the deferred functions |
| 7241 | * (before/after/beforeEach/afterEach) and tests of a Suite. |
| 7242 | * These must be deleted otherwise a memory leak can happen, |
| 7243 | * as those functions may reference variables from closures, |
| 7244 | * thus those variables can never be garbage collected as long |
| 7245 | * as the deferred functions exist. |
| 7246 | * |
| 7247 | * @private |
| 7248 | */ |
| 7249 | Suite.prototype.cleanReferences = function cleanReferences() { |
| 7250 | function cleanArrReferences(arr) { |
| 7251 | for (var i = 0; i < arr.length; i++) { |
| 7252 | delete arr[i].fn; |
| 7253 | } |
| 7254 | } |
| 7255 | |
| 7256 | if (Array.isArray(this._beforeAll)) { |
| 7257 | cleanArrReferences(this._beforeAll); |
| 7258 | } |
| 7259 | |
| 7260 | if (Array.isArray(this._beforeEach)) { |
| 7261 | cleanArrReferences(this._beforeEach); |
| 7262 | } |
| 7263 | |
| 7264 | if (Array.isArray(this._afterAll)) { |
| 7265 | cleanArrReferences(this._afterAll); |
| 7266 | } |
| 7267 | |
| 7268 | if (Array.isArray(this._afterEach)) { |
| 7269 | cleanArrReferences(this._afterEach); |
| 7270 | } |
| 7271 | |
| 7272 | for (var i = 0; i < this.tests.length; i++) { |
| 7273 | delete this.tests[i].fn; |
| 7274 | } |
| 7275 | }; |
| 7276 | |
| 7277 | var constants = utils.defineConstants( |
| 7278 | /** |
| 7279 | * {@link Suite}-related constants. |
| 7280 | * @public |
| 7281 | * @memberof Suite |
| 7282 | * @alias constants |
| 7283 | * @readonly |
| 7284 | * @static |
| 7285 | * @enum {string} |
| 7286 | */ |
| 7287 | { |
| 7288 | /** |
| 7289 | * Event emitted after a test file has been loaded Not emitted in browser. |
| 7290 | */ |
| 7291 | EVENT_FILE_POST_REQUIRE: 'post-require', |
| 7292 | /** |
| 7293 | * Event emitted before a test file has been loaded. In browser, this is emitted once an interface has been selected. |
| 7294 | */ |
| 7295 | EVENT_FILE_PRE_REQUIRE: 'pre-require', |
| 7296 | /** |
| 7297 | * Event emitted immediately after a test file has been loaded. Not emitted in browser. |
| 7298 | */ |
| 7299 | EVENT_FILE_REQUIRE: 'require', |
| 7300 | /** |
| 7301 | * Event emitted when `global.run()` is called (use with `delay` option) |
| 7302 | */ |
| 7303 | EVENT_ROOT_SUITE_RUN: 'run', |
| 7304 | |
| 7305 | /** |
| 7306 | * Namespace for collection of a `Suite`'s "after all" hooks |
| 7307 | */ |
| 7308 | HOOK_TYPE_AFTER_ALL: 'afterAll', |
| 7309 | /** |
| 7310 | * Namespace for collection of a `Suite`'s "after each" hooks |
| 7311 | */ |
| 7312 | HOOK_TYPE_AFTER_EACH: 'afterEach', |
| 7313 | /** |
| 7314 | * Namespace for collection of a `Suite`'s "before all" hooks |
| 7315 | */ |
| 7316 | HOOK_TYPE_BEFORE_ALL: 'beforeAll', |
| 7317 | /** |
| 7318 | * Namespace for collection of a `Suite`'s "before all" hooks |
| 7319 | */ |
| 7320 | HOOK_TYPE_BEFORE_EACH: 'beforeEach', |
| 7321 | |
| 7322 | // the following events are all deprecated |
| 7323 | |
| 7324 | /** |
| 7325 | * Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated |
| 7326 | */ |
| 7327 | EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll', |
| 7328 | /** |
| 7329 | * Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated |
| 7330 | */ |
| 7331 | EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach', |
| 7332 | /** |
| 7333 | * Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated |
| 7334 | */ |
| 7335 | EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll', |
| 7336 | /** |
| 7337 | * Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated |
| 7338 | */ |
| 7339 | EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach', |
| 7340 | /** |
| 7341 | * Emitted after a child `Suite` has been added to a `Suite`. Deprecated |
| 7342 | */ |
| 7343 | EVENT_SUITE_ADD_SUITE: 'suite', |
| 7344 | /** |
| 7345 | * Emitted after a `Test` has been added to a `Suite`. Deprecated |
| 7346 | */ |
| 7347 | EVENT_SUITE_ADD_TEST: 'test' |
| 7348 | } |
| 7349 | ); |
| 7350 | |
| 7351 | /** |
| 7352 | * @summary There are no known use cases for these events. |
| 7353 | * @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`. |
| 7354 | * @todo Remove eventually |
| 7355 | * @type {Object<string,boolean>} |
| 7356 | * @ignore |
| 7357 | */ |
| 7358 | var deprecatedEvents = Object.keys(constants) |
| 7359 | .filter(function(constant) { |
| 7360 | return constant.substring(0, 15) === 'EVENT_SUITE_ADD'; |
| 7361 | }) |
| 7362 | .reduce(function(acc, constant) { |
| 7363 | acc[constants[constant]] = true; |
| 7364 | return acc; |
| 7365 | }, utils.createMap()); |
| 7366 | |
| 7367 | Suite.constants = constants; |
| 7368 | |
| 7369 | },{"./errors":6,"./hook":7,"./utils":38,"debug":45,"events":50,"ms":60}],37:[function(require,module,exports){ |
| 7370 | 'use strict'; |
| 7371 | var Runnable = require('./runnable'); |
| 7372 | var utils = require('./utils'); |
| 7373 | var errors = require('./errors'); |
| 7374 | var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError; |
| 7375 | var isString = utils.isString; |
| 7376 | |
| 7377 | module.exports = Test; |
| 7378 | |
| 7379 | /** |
| 7380 | * Initialize a new `Test` with the given `title` and callback `fn`. |
| 7381 | * |
| 7382 | * @public |
| 7383 | * @class |
| 7384 | * @extends Runnable |
| 7385 | * @param {String} title - Test title (required) |
| 7386 | * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending" |
| 7387 | */ |
| 7388 | function Test(title, fn) { |
| 7389 | if (!isString(title)) { |
| 7390 | throw createInvalidArgumentTypeError( |
| 7391 | 'Test argument "title" should be a string. Received type "' + |
| 7392 | typeof title + |
| 7393 | '"', |
| 7394 | 'title', |
| 7395 | 'string' |
| 7396 | ); |
| 7397 | } |
| 7398 | Runnable.call(this, title, fn); |
| 7399 | this.pending = !fn; |
| 7400 | this.type = 'test'; |
| 7401 | } |
| 7402 | |
| 7403 | /** |
| 7404 | * Inherit from `Runnable.prototype`. |
| 7405 | */ |
| 7406 | utils.inherits(Test, Runnable); |
| 7407 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 7408 | /** |
| 7409 | * Set or get retried test |
| 7410 | * |
| 7411 | * @private |
| 7412 | */ |
| 7413 | Test.prototype.retriedTest = function(n) { |
| 7414 | if (!arguments.length) { |
| 7415 | return this._retriedTest; |
| 7416 | } |
| 7417 | this._retriedTest = n; |
| 7418 | }; |
| 7419 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 7420 | Test.prototype.clone = function() { |
| 7421 | var test = new Test(this.title, this.fn); |
| 7422 | test.timeout(this.timeout()); |
| 7423 | test.slow(this.slow()); |
| 7424 | test.enableTimeouts(this.enableTimeouts()); |
| 7425 | test.retries(this.retries()); |
| 7426 | test.currentRetry(this.currentRetry()); |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 7427 | test.retriedTest(this.retriedTest() || this); |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 7428 | test.globals(this.globals()); |
| 7429 | test.parent = this.parent; |
| 7430 | test.file = this.file; |
| 7431 | test.ctx = this.ctx; |
| 7432 | return test; |
| 7433 | }; |
| 7434 | |
| 7435 | },{"./errors":6,"./runnable":33,"./utils":38}],38:[function(require,module,exports){ |
| 7436 | (function (process,Buffer){ |
| 7437 | 'use strict'; |
| 7438 | |
| 7439 | /** |
| 7440 | * Various utility functions used throughout Mocha's codebase. |
| 7441 | * @module utils |
| 7442 | */ |
| 7443 | |
| 7444 | /** |
| 7445 | * Module dependencies. |
| 7446 | */ |
| 7447 | |
| 7448 | var fs = require('fs'); |
| 7449 | var path = require('path'); |
| 7450 | var util = require('util'); |
| 7451 | var glob = require('glob'); |
| 7452 | var he = require('he'); |
| 7453 | var errors = require('./errors'); |
| 7454 | var createNoFilesMatchPatternError = errors.createNoFilesMatchPatternError; |
| 7455 | var createMissingArgumentError = errors.createMissingArgumentError; |
| 7456 | |
| 7457 | var assign = (exports.assign = require('object.assign').getPolyfill()); |
| 7458 | |
| 7459 | /** |
| 7460 | * Inherit the prototype methods from one constructor into another. |
| 7461 | * |
| 7462 | * @param {function} ctor - Constructor function which needs to inherit the |
| 7463 | * prototype. |
| 7464 | * @param {function} superCtor - Constructor function to inherit prototype from. |
| 7465 | * @throws {TypeError} if either constructor is null, or if super constructor |
| 7466 | * lacks a prototype. |
| 7467 | */ |
| 7468 | exports.inherits = util.inherits; |
| 7469 | |
| 7470 | /** |
| 7471 | * Escape special characters in the given string of html. |
| 7472 | * |
| 7473 | * @private |
| 7474 | * @param {string} html |
| 7475 | * @return {string} |
| 7476 | */ |
| 7477 | exports.escape = function(html) { |
| 7478 | return he.encode(String(html), {useNamedReferences: false}); |
| 7479 | }; |
| 7480 | |
| 7481 | /** |
| 7482 | * Test if the given obj is type of string. |
| 7483 | * |
| 7484 | * @private |
| 7485 | * @param {Object} obj |
| 7486 | * @return {boolean} |
| 7487 | */ |
| 7488 | exports.isString = function(obj) { |
| 7489 | return typeof obj === 'string'; |
| 7490 | }; |
| 7491 | |
| 7492 | /** |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 7493 | * Compute a slug from the given `str`. |
| 7494 | * |
| 7495 | * @private |
| 7496 | * @param {string} str |
| 7497 | * @return {string} |
| 7498 | */ |
| 7499 | exports.slug = function(str) { |
| 7500 | return str |
| 7501 | .toLowerCase() |
| 7502 | .replace(/ +/g, '-') |
| 7503 | .replace(/[^-\w]/g, ''); |
| 7504 | }; |
| 7505 | |
| 7506 | /** |
| 7507 | * Strip the function definition from `str`, and re-indent for pre whitespace. |
| 7508 | * |
| 7509 | * @param {string} str |
| 7510 | * @return {string} |
| 7511 | */ |
| 7512 | exports.clean = function(str) { |
| 7513 | str = str |
| 7514 | .replace(/\r\n?|[\n\u2028\u2029]/g, '\n') |
| 7515 | .replace(/^\uFEFF/, '') |
| 7516 | // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content |
| 7517 | .replace( |
| 7518 | /^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/, |
| 7519 | '$1$2$3' |
| 7520 | ); |
| 7521 | |
| 7522 | var spaces = str.match(/^\n?( *)/)[1].length; |
| 7523 | var tabs = str.match(/^\n?(\t*)/)[1].length; |
| 7524 | var re = new RegExp( |
| 7525 | '^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', |
| 7526 | 'gm' |
| 7527 | ); |
| 7528 | |
| 7529 | str = str.replace(re, ''); |
| 7530 | |
| 7531 | return str.trim(); |
| 7532 | }; |
| 7533 | |
| 7534 | /** |
| 7535 | * Parse the given `qs`. |
| 7536 | * |
| 7537 | * @private |
| 7538 | * @param {string} qs |
| 7539 | * @return {Object} |
| 7540 | */ |
| 7541 | exports.parseQuery = function(qs) { |
| 7542 | return qs |
| 7543 | .replace('?', '') |
| 7544 | .split('&') |
| 7545 | .reduce(function(obj, pair) { |
| 7546 | var i = pair.indexOf('='); |
| 7547 | var key = pair.slice(0, i); |
| 7548 | var val = pair.slice(++i); |
| 7549 | |
| 7550 | // Due to how the URLSearchParams API treats spaces |
| 7551 | obj[key] = decodeURIComponent(val.replace(/\+/g, '%20')); |
| 7552 | |
| 7553 | return obj; |
| 7554 | }, {}); |
| 7555 | }; |
| 7556 | |
| 7557 | /** |
| 7558 | * Highlight the given string of `js`. |
| 7559 | * |
| 7560 | * @private |
| 7561 | * @param {string} js |
| 7562 | * @return {string} |
| 7563 | */ |
| 7564 | function highlight(js) { |
| 7565 | return js |
| 7566 | .replace(/</g, '<') |
| 7567 | .replace(/>/g, '>') |
| 7568 | .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>') |
| 7569 | .replace(/('.*?')/gm, '<span class="string">$1</span>') |
| 7570 | .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>') |
| 7571 | .replace(/(\d+)/gm, '<span class="number">$1</span>') |
| 7572 | .replace( |
| 7573 | /\bnew[ \t]+(\w+)/gm, |
| 7574 | '<span class="keyword">new</span> <span class="init">$1</span>' |
| 7575 | ) |
| 7576 | .replace( |
| 7577 | /\b(function|new|throw|return|var|if|else)\b/gm, |
| 7578 | '<span class="keyword">$1</span>' |
| 7579 | ); |
| 7580 | } |
| 7581 | |
| 7582 | /** |
| 7583 | * Highlight the contents of tag `name`. |
| 7584 | * |
| 7585 | * @private |
| 7586 | * @param {string} name |
| 7587 | */ |
| 7588 | exports.highlightTags = function(name) { |
| 7589 | var code = document.getElementById('mocha').getElementsByTagName(name); |
| 7590 | for (var i = 0, len = code.length; i < len; ++i) { |
| 7591 | code[i].innerHTML = highlight(code[i].innerHTML); |
| 7592 | } |
| 7593 | }; |
| 7594 | |
| 7595 | /** |
| 7596 | * If a value could have properties, and has none, this function is called, |
| 7597 | * which returns a string representation of the empty value. |
| 7598 | * |
| 7599 | * Functions w/ no properties return `'[Function]'` |
| 7600 | * Arrays w/ length === 0 return `'[]'` |
| 7601 | * Objects w/ no properties return `'{}'` |
| 7602 | * All else: return result of `value.toString()` |
| 7603 | * |
| 7604 | * @private |
| 7605 | * @param {*} value The value to inspect. |
| 7606 | * @param {string} typeHint The type of the value |
| 7607 | * @returns {string} |
| 7608 | */ |
| 7609 | function emptyRepresentation(value, typeHint) { |
| 7610 | switch (typeHint) { |
| 7611 | case 'function': |
| 7612 | return '[Function]'; |
| 7613 | case 'object': |
| 7614 | return '{}'; |
| 7615 | case 'array': |
| 7616 | return '[]'; |
| 7617 | default: |
| 7618 | return value.toString(); |
| 7619 | } |
| 7620 | } |
| 7621 | |
| 7622 | /** |
| 7623 | * Takes some variable and asks `Object.prototype.toString()` what it thinks it |
| 7624 | * is. |
| 7625 | * |
| 7626 | * @private |
| 7627 | * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString |
| 7628 | * @param {*} value The value to test. |
| 7629 | * @returns {string} Computed type |
| 7630 | * @example |
| 7631 | * type({}) // 'object' |
| 7632 | * type([]) // 'array' |
| 7633 | * type(1) // 'number' |
| 7634 | * type(false) // 'boolean' |
| 7635 | * type(Infinity) // 'number' |
| 7636 | * type(null) // 'null' |
| 7637 | * type(new Date()) // 'date' |
| 7638 | * type(/foo/) // 'regexp' |
| 7639 | * type('type') // 'string' |
| 7640 | * type(global) // 'global' |
| 7641 | * type(new String('foo') // 'object' |
| 7642 | */ |
| 7643 | var type = (exports.type = function type(value) { |
| 7644 | if (value === undefined) { |
| 7645 | return 'undefined'; |
| 7646 | } else if (value === null) { |
| 7647 | return 'null'; |
| 7648 | } else if (Buffer.isBuffer(value)) { |
| 7649 | return 'buffer'; |
| 7650 | } |
| 7651 | return Object.prototype.toString |
| 7652 | .call(value) |
| 7653 | .replace(/^\[.+\s(.+?)]$/, '$1') |
| 7654 | .toLowerCase(); |
| 7655 | }); |
| 7656 | |
| 7657 | /** |
| 7658 | * Stringify `value`. Different behavior depending on type of value: |
| 7659 | * |
| 7660 | * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. |
| 7661 | * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. |
| 7662 | * - If `value` is an *empty* object, function, or array, return result of function |
| 7663 | * {@link emptyRepresentation}. |
| 7664 | * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of |
| 7665 | * JSON.stringify(). |
| 7666 | * |
| 7667 | * @private |
| 7668 | * @see exports.type |
| 7669 | * @param {*} value |
| 7670 | * @return {string} |
| 7671 | */ |
| 7672 | exports.stringify = function(value) { |
| 7673 | var typeHint = type(value); |
| 7674 | |
| 7675 | if (!~['object', 'array', 'function'].indexOf(typeHint)) { |
| 7676 | if (typeHint === 'buffer') { |
| 7677 | var json = Buffer.prototype.toJSON.call(value); |
| 7678 | // Based on the toJSON result |
| 7679 | return jsonStringify( |
| 7680 | json.data && json.type ? json.data : json, |
| 7681 | 2 |
| 7682 | ).replace(/,(\n|$)/g, '$1'); |
| 7683 | } |
| 7684 | |
| 7685 | // IE7/IE8 has a bizarre String constructor; needs to be coerced |
| 7686 | // into an array and back to obj. |
| 7687 | if (typeHint === 'string' && typeof value === 'object') { |
| 7688 | value = value.split('').reduce(function(acc, char, idx) { |
| 7689 | acc[idx] = char; |
| 7690 | return acc; |
| 7691 | }, {}); |
| 7692 | typeHint = 'object'; |
| 7693 | } else { |
| 7694 | return jsonStringify(value); |
| 7695 | } |
| 7696 | } |
| 7697 | |
| 7698 | for (var prop in value) { |
| 7699 | if (Object.prototype.hasOwnProperty.call(value, prop)) { |
| 7700 | return jsonStringify( |
| 7701 | exports.canonicalize(value, null, typeHint), |
| 7702 | 2 |
| 7703 | ).replace(/,(\n|$)/g, '$1'); |
| 7704 | } |
| 7705 | } |
| 7706 | |
| 7707 | return emptyRepresentation(value, typeHint); |
| 7708 | }; |
| 7709 | |
| 7710 | /** |
| 7711 | * like JSON.stringify but more sense. |
| 7712 | * |
| 7713 | * @private |
| 7714 | * @param {Object} object |
| 7715 | * @param {number=} spaces |
| 7716 | * @param {number=} depth |
| 7717 | * @returns {*} |
| 7718 | */ |
| 7719 | function jsonStringify(object, spaces, depth) { |
| 7720 | if (typeof spaces === 'undefined') { |
| 7721 | // primitive types |
| 7722 | return _stringify(object); |
| 7723 | } |
| 7724 | |
| 7725 | depth = depth || 1; |
| 7726 | var space = spaces * depth; |
| 7727 | var str = Array.isArray(object) ? '[' : '{'; |
| 7728 | var end = Array.isArray(object) ? ']' : '}'; |
| 7729 | var length = |
| 7730 | typeof object.length === 'number' |
| 7731 | ? object.length |
| 7732 | : Object.keys(object).length; |
| 7733 | // `.repeat()` polyfill |
| 7734 | function repeat(s, n) { |
| 7735 | return new Array(n).join(s); |
| 7736 | } |
| 7737 | |
| 7738 | function _stringify(val) { |
| 7739 | switch (type(val)) { |
| 7740 | case 'null': |
| 7741 | case 'undefined': |
| 7742 | val = '[' + val + ']'; |
| 7743 | break; |
| 7744 | case 'array': |
| 7745 | case 'object': |
| 7746 | val = jsonStringify(val, spaces, depth + 1); |
| 7747 | break; |
| 7748 | case 'boolean': |
| 7749 | case 'regexp': |
| 7750 | case 'symbol': |
| 7751 | case 'number': |
| 7752 | val = |
| 7753 | val === 0 && 1 / val === -Infinity // `-0` |
| 7754 | ? '-0' |
| 7755 | : val.toString(); |
| 7756 | break; |
| 7757 | case 'date': |
| 7758 | var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString(); |
| 7759 | val = '[Date: ' + sDate + ']'; |
| 7760 | break; |
| 7761 | case 'buffer': |
| 7762 | var json = val.toJSON(); |
| 7763 | // Based on the toJSON result |
| 7764 | json = json.data && json.type ? json.data : json; |
| 7765 | val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']'; |
| 7766 | break; |
| 7767 | default: |
| 7768 | val = |
| 7769 | val === '[Function]' || val === '[Circular]' |
| 7770 | ? val |
| 7771 | : JSON.stringify(val); // string |
| 7772 | } |
| 7773 | return val; |
| 7774 | } |
| 7775 | |
| 7776 | for (var i in object) { |
| 7777 | if (!Object.prototype.hasOwnProperty.call(object, i)) { |
| 7778 | continue; // not my business |
| 7779 | } |
| 7780 | --length; |
| 7781 | str += |
| 7782 | '\n ' + |
| 7783 | repeat(' ', space) + |
| 7784 | (Array.isArray(object) ? '' : '"' + i + '": ') + // key |
| 7785 | _stringify(object[i]) + // value |
| 7786 | (length ? ',' : ''); // comma |
| 7787 | } |
| 7788 | |
| 7789 | return ( |
| 7790 | str + |
| 7791 | // [], {} |
| 7792 | (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end) |
| 7793 | ); |
| 7794 | } |
| 7795 | |
| 7796 | /** |
| 7797 | * Return a new Thing that has the keys in sorted order. Recursive. |
| 7798 | * |
| 7799 | * If the Thing... |
| 7800 | * - has already been seen, return string `'[Circular]'` |
| 7801 | * - is `undefined`, return string `'[undefined]'` |
| 7802 | * - is `null`, return value `null` |
| 7803 | * - is some other primitive, return the value |
| 7804 | * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method |
| 7805 | * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. |
| 7806 | * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()` |
| 7807 | * |
| 7808 | * @private |
| 7809 | * @see {@link exports.stringify} |
| 7810 | * @param {*} value Thing to inspect. May or may not have properties. |
| 7811 | * @param {Array} [stack=[]] Stack of seen values |
| 7812 | * @param {string} [typeHint] Type hint |
| 7813 | * @return {(Object|Array|Function|string|undefined)} |
| 7814 | */ |
| 7815 | exports.canonicalize = function canonicalize(value, stack, typeHint) { |
| 7816 | var canonicalizedObj; |
| 7817 | /* eslint-disable no-unused-vars */ |
| 7818 | var prop; |
| 7819 | /* eslint-enable no-unused-vars */ |
| 7820 | typeHint = typeHint || type(value); |
| 7821 | function withStack(value, fn) { |
| 7822 | stack.push(value); |
| 7823 | fn(); |
| 7824 | stack.pop(); |
| 7825 | } |
| 7826 | |
| 7827 | stack = stack || []; |
| 7828 | |
| 7829 | if (stack.indexOf(value) !== -1) { |
| 7830 | return '[Circular]'; |
| 7831 | } |
| 7832 | |
| 7833 | switch (typeHint) { |
| 7834 | case 'undefined': |
| 7835 | case 'buffer': |
| 7836 | case 'null': |
| 7837 | canonicalizedObj = value; |
| 7838 | break; |
| 7839 | case 'array': |
| 7840 | withStack(value, function() { |
| 7841 | canonicalizedObj = value.map(function(item) { |
| 7842 | return exports.canonicalize(item, stack); |
| 7843 | }); |
| 7844 | }); |
| 7845 | break; |
| 7846 | case 'function': |
| 7847 | /* eslint-disable guard-for-in */ |
| 7848 | for (prop in value) { |
| 7849 | canonicalizedObj = {}; |
| 7850 | break; |
| 7851 | } |
| 7852 | /* eslint-enable guard-for-in */ |
| 7853 | if (!canonicalizedObj) { |
| 7854 | canonicalizedObj = emptyRepresentation(value, typeHint); |
| 7855 | break; |
| 7856 | } |
| 7857 | /* falls through */ |
| 7858 | case 'object': |
| 7859 | canonicalizedObj = canonicalizedObj || {}; |
| 7860 | withStack(value, function() { |
| 7861 | Object.keys(value) |
| 7862 | .sort() |
| 7863 | .forEach(function(key) { |
| 7864 | canonicalizedObj[key] = exports.canonicalize(value[key], stack); |
| 7865 | }); |
| 7866 | }); |
| 7867 | break; |
| 7868 | case 'date': |
| 7869 | case 'number': |
| 7870 | case 'regexp': |
| 7871 | case 'boolean': |
| 7872 | case 'symbol': |
| 7873 | canonicalizedObj = value; |
| 7874 | break; |
| 7875 | default: |
| 7876 | canonicalizedObj = value + ''; |
| 7877 | } |
| 7878 | |
| 7879 | return canonicalizedObj; |
| 7880 | }; |
| 7881 | |
| 7882 | /** |
| 7883 | * Determines if pathname has a matching file extension. |
| 7884 | * |
| 7885 | * @private |
| 7886 | * @param {string} pathname - Pathname to check for match. |
| 7887 | * @param {string[]} exts - List of file extensions (sans period). |
| 7888 | * @return {boolean} whether file extension matches. |
| 7889 | * @example |
| 7890 | * hasMatchingExtname('foo.html', ['js', 'css']); // => false |
| 7891 | */ |
| 7892 | function hasMatchingExtname(pathname, exts) { |
| 7893 | var suffix = path.extname(pathname).slice(1); |
| 7894 | return exts.some(function(element) { |
| 7895 | return suffix === element; |
| 7896 | }); |
| 7897 | } |
| 7898 | |
| 7899 | /** |
| 7900 | * Determines if pathname would be a "hidden" file (or directory) on UN*X. |
| 7901 | * |
| 7902 | * @description |
| 7903 | * On UN*X, pathnames beginning with a full stop (aka dot) are hidden during |
| 7904 | * typical usage. Dotfiles, plain-text configuration files, are prime examples. |
| 7905 | * |
| 7906 | * @see {@link http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html|Origin of Dot File Names} |
| 7907 | * |
| 7908 | * @private |
| 7909 | * @param {string} pathname - Pathname to check for match. |
| 7910 | * @return {boolean} whether pathname would be considered a hidden file. |
| 7911 | * @example |
| 7912 | * isHiddenOnUnix('.profile'); // => true |
| 7913 | */ |
| 7914 | function isHiddenOnUnix(pathname) { |
| 7915 | return path.basename(pathname)[0] === '.'; |
| 7916 | } |
| 7917 | |
| 7918 | /** |
| 7919 | * Lookup file names at the given `path`. |
| 7920 | * |
| 7921 | * @description |
| 7922 | * Filenames are returned in _traversal_ order by the OS/filesystem. |
| 7923 | * **Make no assumption that the names will be sorted in any fashion.** |
| 7924 | * |
| 7925 | * @public |
| 7926 | * @memberof Mocha.utils |
| 7927 | * @param {string} filepath - Base path to start searching from. |
| 7928 | * @param {string[]} [extensions=[]] - File extensions to look for. |
| 7929 | * @param {boolean} [recursive=false] - Whether to recurse into subdirectories. |
| 7930 | * @return {string[]} An array of paths. |
| 7931 | * @throws {Error} if no files match pattern. |
| 7932 | * @throws {TypeError} if `filepath` is directory and `extensions` not provided. |
| 7933 | */ |
| 7934 | exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) { |
| 7935 | extensions = extensions || []; |
| 7936 | recursive = recursive || false; |
| 7937 | var files = []; |
| 7938 | var stat; |
| 7939 | |
| 7940 | if (!fs.existsSync(filepath)) { |
| 7941 | var pattern; |
| 7942 | if (glob.hasMagic(filepath)) { |
| 7943 | // Handle glob as is without extensions |
| 7944 | pattern = filepath; |
| 7945 | } else { |
| 7946 | // glob pattern e.g. 'filepath+(.js|.ts)' |
| 7947 | var strExtensions = extensions |
| 7948 | .map(function(v) { |
| 7949 | return '.' + v; |
| 7950 | }) |
| 7951 | .join('|'); |
| 7952 | pattern = filepath + '+(' + strExtensions + ')'; |
| 7953 | } |
| 7954 | files = glob.sync(pattern, {nodir: true}); |
| 7955 | if (!files.length) { |
| 7956 | throw createNoFilesMatchPatternError( |
| 7957 | 'Cannot find any files matching pattern ' + exports.dQuote(filepath), |
| 7958 | filepath |
| 7959 | ); |
| 7960 | } |
| 7961 | return files; |
| 7962 | } |
| 7963 | |
| 7964 | // Handle file |
| 7965 | try { |
| 7966 | stat = fs.statSync(filepath); |
| 7967 | if (stat.isFile()) { |
| 7968 | return filepath; |
| 7969 | } |
| 7970 | } catch (err) { |
| 7971 | // ignore error |
| 7972 | return; |
| 7973 | } |
| 7974 | |
| 7975 | // Handle directory |
| 7976 | fs.readdirSync(filepath).forEach(function(dirent) { |
| 7977 | var pathname = path.join(filepath, dirent); |
| 7978 | var stat; |
| 7979 | |
| 7980 | try { |
| 7981 | stat = fs.statSync(pathname); |
| 7982 | if (stat.isDirectory()) { |
| 7983 | if (recursive) { |
| 7984 | files = files.concat(lookupFiles(pathname, extensions, recursive)); |
| 7985 | } |
| 7986 | return; |
| 7987 | } |
| 7988 | } catch (err) { |
| 7989 | // ignore error |
| 7990 | return; |
| 7991 | } |
| 7992 | if (!extensions.length) { |
| 7993 | throw createMissingArgumentError( |
| 7994 | util.format( |
| 7995 | 'Argument %s required when argument %s is a directory', |
| 7996 | exports.sQuote('extensions'), |
| 7997 | exports.sQuote('filepath') |
| 7998 | ), |
| 7999 | 'extensions', |
| 8000 | 'array' |
| 8001 | ); |
| 8002 | } |
| 8003 | |
| 8004 | if ( |
| 8005 | !stat.isFile() || |
| 8006 | !hasMatchingExtname(pathname, extensions) || |
| 8007 | isHiddenOnUnix(pathname) |
| 8008 | ) { |
| 8009 | return; |
| 8010 | } |
| 8011 | files.push(pathname); |
| 8012 | }); |
| 8013 | |
| 8014 | return files; |
| 8015 | }; |
| 8016 | |
| 8017 | /** |
| 8018 | * process.emitWarning or a polyfill |
| 8019 | * @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options |
| 8020 | * @ignore |
| 8021 | */ |
| 8022 | function emitWarning(msg, type) { |
| 8023 | if (process.emitWarning) { |
| 8024 | process.emitWarning(msg, type); |
| 8025 | } else { |
| 8026 | process.nextTick(function() { |
| 8027 | console.warn(type + ': ' + msg); |
| 8028 | }); |
| 8029 | } |
| 8030 | } |
| 8031 | |
| 8032 | /** |
| 8033 | * Show a deprecation warning. Each distinct message is only displayed once. |
| 8034 | * Ignores empty messages. |
| 8035 | * |
| 8036 | * @param {string} [msg] - Warning to print |
| 8037 | * @private |
| 8038 | */ |
| 8039 | exports.deprecate = function deprecate(msg) { |
| 8040 | msg = String(msg); |
| 8041 | if (msg && !deprecate.cache[msg]) { |
| 8042 | deprecate.cache[msg] = true; |
| 8043 | emitWarning(msg, 'DeprecationWarning'); |
| 8044 | } |
| 8045 | }; |
| 8046 | exports.deprecate.cache = {}; |
| 8047 | |
| 8048 | /** |
| 8049 | * Show a generic warning. |
| 8050 | * Ignores empty messages. |
| 8051 | * |
| 8052 | * @param {string} [msg] - Warning to print |
| 8053 | * @private |
| 8054 | */ |
| 8055 | exports.warn = function warn(msg) { |
| 8056 | if (msg) { |
| 8057 | emitWarning(msg); |
| 8058 | } |
| 8059 | }; |
| 8060 | |
| 8061 | /** |
| 8062 | * @summary |
| 8063 | * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`) |
| 8064 | * @description |
| 8065 | * When invoking this function you get a filter function that get the Error.stack as an input, |
| 8066 | * and return a prettify output. |
| 8067 | * (i.e: strip Mocha and internal node functions from stack trace). |
| 8068 | * @returns {Function} |
| 8069 | */ |
| 8070 | exports.stackTraceFilter = function() { |
| 8071 | // TODO: Replace with `process.browser` |
| 8072 | var is = typeof document === 'undefined' ? {node: true} : {browser: true}; |
| 8073 | var slash = path.sep; |
| 8074 | var cwd; |
| 8075 | if (is.node) { |
| 8076 | cwd = process.cwd() + slash; |
| 8077 | } else { |
| 8078 | cwd = (typeof location === 'undefined' |
| 8079 | ? window.location |
| 8080 | : location |
| 8081 | ).href.replace(/\/[^/]*$/, '/'); |
| 8082 | slash = '/'; |
| 8083 | } |
| 8084 | |
| 8085 | function isMochaInternal(line) { |
| 8086 | return ( |
| 8087 | ~line.indexOf('node_modules' + slash + 'mocha' + slash) || |
| 8088 | ~line.indexOf(slash + 'mocha.js') || |
| 8089 | ~line.indexOf(slash + 'mocha.min.js') |
| 8090 | ); |
| 8091 | } |
| 8092 | |
| 8093 | function isNodeInternal(line) { |
| 8094 | return ( |
| 8095 | ~line.indexOf('(timers.js:') || |
| 8096 | ~line.indexOf('(events.js:') || |
| 8097 | ~line.indexOf('(node.js:') || |
| 8098 | ~line.indexOf('(module.js:') || |
| 8099 | ~line.indexOf('GeneratorFunctionPrototype.next (native)') || |
| 8100 | false |
| 8101 | ); |
| 8102 | } |
| 8103 | |
| 8104 | return function(stack) { |
| 8105 | stack = stack.split('\n'); |
| 8106 | |
| 8107 | stack = stack.reduce(function(list, line) { |
| 8108 | if (isMochaInternal(line)) { |
| 8109 | return list; |
| 8110 | } |
| 8111 | |
| 8112 | if (is.node && isNodeInternal(line)) { |
| 8113 | return list; |
| 8114 | } |
| 8115 | |
| 8116 | // Clean up cwd(absolute) |
| 8117 | if (/:\d+:\d+\)?$/.test(line)) { |
| 8118 | line = line.replace('(' + cwd, '('); |
| 8119 | } |
| 8120 | |
| 8121 | list.push(line); |
| 8122 | return list; |
| 8123 | }, []); |
| 8124 | |
| 8125 | return stack.join('\n'); |
| 8126 | }; |
| 8127 | }; |
| 8128 | |
| 8129 | /** |
| 8130 | * Crude, but effective. |
| 8131 | * @public |
| 8132 | * @param {*} value |
| 8133 | * @returns {boolean} Whether or not `value` is a Promise |
| 8134 | */ |
| 8135 | exports.isPromise = function isPromise(value) { |
| 8136 | return ( |
| 8137 | typeof value === 'object' && |
| 8138 | value !== null && |
| 8139 | typeof value.then === 'function' |
| 8140 | ); |
| 8141 | }; |
| 8142 | |
| 8143 | /** |
| 8144 | * Clamps a numeric value to an inclusive range. |
| 8145 | * |
| 8146 | * @param {number} value - Value to be clamped. |
| 8147 | * @param {numer[]} range - Two element array specifying [min, max] range. |
| 8148 | * @returns {number} clamped value |
| 8149 | */ |
| 8150 | exports.clamp = function clamp(value, range) { |
| 8151 | return Math.min(Math.max(value, range[0]), range[1]); |
| 8152 | }; |
| 8153 | |
| 8154 | /** |
| 8155 | * Single quote text by combining with undirectional ASCII quotation marks. |
| 8156 | * |
| 8157 | * @description |
| 8158 | * Provides a simple means of markup for quoting text to be used in output. |
| 8159 | * Use this to quote names of variables, methods, and packages. |
| 8160 | * |
| 8161 | * <samp>package 'foo' cannot be found</samp> |
| 8162 | * |
| 8163 | * @private |
| 8164 | * @param {string} str - Value to be quoted. |
| 8165 | * @returns {string} quoted value |
| 8166 | * @example |
| 8167 | * sQuote('n') // => 'n' |
| 8168 | */ |
| 8169 | exports.sQuote = function(str) { |
| 8170 | return "'" + str + "'"; |
| 8171 | }; |
| 8172 | |
| 8173 | /** |
| 8174 | * Double quote text by combining with undirectional ASCII quotation marks. |
| 8175 | * |
| 8176 | * @description |
| 8177 | * Provides a simple means of markup for quoting text to be used in output. |
| 8178 | * Use this to quote names of datatypes, classes, pathnames, and strings. |
| 8179 | * |
| 8180 | * <samp>argument 'value' must be "string" or "number"</samp> |
| 8181 | * |
| 8182 | * @private |
| 8183 | * @param {string} str - Value to be quoted. |
| 8184 | * @returns {string} quoted value |
| 8185 | * @example |
| 8186 | * dQuote('number') // => "number" |
| 8187 | */ |
| 8188 | exports.dQuote = function(str) { |
| 8189 | return '"' + str + '"'; |
| 8190 | }; |
| 8191 | |
| 8192 | /** |
| 8193 | * Provides simplistic message translation for dealing with plurality. |
| 8194 | * |
| 8195 | * @description |
| 8196 | * Use this to create messages which need to be singular or plural. |
| 8197 | * Some languages have several plural forms, so _complete_ message clauses |
| 8198 | * are preferable to generating the message on the fly. |
| 8199 | * |
| 8200 | * @private |
| 8201 | * @param {number} n - Non-negative integer |
| 8202 | * @param {string} msg1 - Message to be used in English for `n = 1` |
| 8203 | * @param {string} msg2 - Message to be used in English for `n = 0, 2, 3, ...` |
| 8204 | * @returns {string} message corresponding to value of `n` |
| 8205 | * @example |
| 8206 | * var sprintf = require('util').format; |
| 8207 | * var pkgs = ['one', 'two']; |
| 8208 | * var msg = sprintf( |
| 8209 | * ngettext( |
| 8210 | * pkgs.length, |
| 8211 | * 'cannot load package: %s', |
| 8212 | * 'cannot load packages: %s' |
| 8213 | * ), |
| 8214 | * pkgs.map(sQuote).join(', ') |
| 8215 | * ); |
| 8216 | * console.log(msg); // => cannot load packages: 'one', 'two' |
| 8217 | */ |
| 8218 | exports.ngettext = function(n, msg1, msg2) { |
| 8219 | if (typeof n === 'number' && n >= 0) { |
| 8220 | return n === 1 ? msg1 : msg2; |
| 8221 | } |
| 8222 | }; |
| 8223 | |
| 8224 | /** |
| 8225 | * It's a noop. |
| 8226 | * @public |
| 8227 | */ |
| 8228 | exports.noop = function() {}; |
| 8229 | |
| 8230 | /** |
| 8231 | * Creates a map-like object. |
| 8232 | * |
| 8233 | * @description |
| 8234 | * A "map" is an object with no prototype, for our purposes. In some cases |
| 8235 | * this would be more appropriate than a `Map`, especially if your environment |
| 8236 | * doesn't support it. Recommended for use in Mocha's public APIs. |
| 8237 | * |
| 8238 | * @public |
| 8239 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|MDN:Map} |
| 8240 | * @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} |
| 8241 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign|MDN:Object.assign} |
| 8242 | * @param {...*} [obj] - Arguments to `Object.assign()`. |
| 8243 | * @returns {Object} An object with no prototype, having `...obj` properties |
| 8244 | */ |
| 8245 | exports.createMap = function(obj) { |
| 8246 | return assign.apply( |
| 8247 | null, |
| 8248 | [Object.create(null)].concat(Array.prototype.slice.call(arguments)) |
| 8249 | ); |
| 8250 | }; |
| 8251 | |
| 8252 | /** |
| 8253 | * Creates a read-only map-like object. |
| 8254 | * |
| 8255 | * @description |
| 8256 | * This differs from {@link module:utils.createMap createMap} only in that |
| 8257 | * the argument must be non-empty, because the result is frozen. |
| 8258 | * |
| 8259 | * @see {@link module:utils.createMap createMap} |
| 8260 | * @param {...*} [obj] - Arguments to `Object.assign()`. |
| 8261 | * @returns {Object} A frozen object with no prototype, having `...obj` properties |
| 8262 | * @throws {TypeError} if argument is not a non-empty object. |
| 8263 | */ |
| 8264 | exports.defineConstants = function(obj) { |
| 8265 | if (type(obj) !== 'object' || !Object.keys(obj).length) { |
| 8266 | throw new TypeError('Invalid argument; expected a non-empty object'); |
| 8267 | } |
| 8268 | return Object.freeze(exports.createMap(obj)); |
| 8269 | }; |
| 8270 | |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 8271 | /** |
| 8272 | * Whether current version of Node support ES modules |
| 8273 | * |
| 8274 | * @description |
| 8275 | * Versions prior to 10 did not support ES Modules, and version 10 has an old incompatibile version of ESM. |
| 8276 | * This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs, |
| 8277 | * which is version >=12.11. |
| 8278 | * |
| 8279 | * @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatible with Mocha |
| 8280 | */ |
| 8281 | exports.supportsEsModules = function() { |
| 8282 | if (!process.browser && process.versions && process.versions.node) { |
| 8283 | var versionFields = process.versions.node.split('.'); |
| 8284 | var major = +versionFields[0]; |
| 8285 | var minor = +versionFields[1]; |
| 8286 | |
| 8287 | if (major >= 13 || (major === 12 && minor >= 11)) { |
| 8288 | return true; |
| 8289 | } |
| 8290 | } |
| 8291 | }; |
| 8292 | |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 8293 | }).call(this,require('_process'),require("buffer").Buffer) |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 8294 | },{"./errors":6,"_process":69,"buffer":43,"fs":42,"glob":42,"he":54,"object.assign":65,"path":42,"util":89}],39:[function(require,module,exports){ |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 8295 | 'use strict' |
| 8296 | |
| 8297 | exports.byteLength = byteLength |
| 8298 | exports.toByteArray = toByteArray |
| 8299 | exports.fromByteArray = fromByteArray |
| 8300 | |
| 8301 | var lookup = [] |
| 8302 | var revLookup = [] |
| 8303 | var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array |
| 8304 | |
| 8305 | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' |
| 8306 | for (var i = 0, len = code.length; i < len; ++i) { |
| 8307 | lookup[i] = code[i] |
| 8308 | revLookup[code.charCodeAt(i)] = i |
| 8309 | } |
| 8310 | |
| 8311 | // Support decoding URL-safe base64 strings, as Node.js does. |
| 8312 | // See: https://en.wikipedia.org/wiki/Base64#URL_applications |
| 8313 | revLookup['-'.charCodeAt(0)] = 62 |
| 8314 | revLookup['_'.charCodeAt(0)] = 63 |
| 8315 | |
| 8316 | function getLens (b64) { |
| 8317 | var len = b64.length |
| 8318 | |
| 8319 | if (len % 4 > 0) { |
| 8320 | throw new Error('Invalid string. Length must be a multiple of 4') |
| 8321 | } |
| 8322 | |
| 8323 | // Trim off extra bytes after placeholder bytes are found |
| 8324 | // See: https://github.com/beatgammit/base64-js/issues/42 |
| 8325 | var validLen = b64.indexOf('=') |
| 8326 | if (validLen === -1) validLen = len |
| 8327 | |
| 8328 | var placeHoldersLen = validLen === len |
| 8329 | ? 0 |
| 8330 | : 4 - (validLen % 4) |
| 8331 | |
| 8332 | return [validLen, placeHoldersLen] |
| 8333 | } |
| 8334 | |
| 8335 | // base64 is 4/3 + up to two characters of the original data |
| 8336 | function byteLength (b64) { |
| 8337 | var lens = getLens(b64) |
| 8338 | var validLen = lens[0] |
| 8339 | var placeHoldersLen = lens[1] |
| 8340 | return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen |
| 8341 | } |
| 8342 | |
| 8343 | function _byteLength (b64, validLen, placeHoldersLen) { |
| 8344 | return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen |
| 8345 | } |
| 8346 | |
| 8347 | function toByteArray (b64) { |
| 8348 | var tmp |
| 8349 | var lens = getLens(b64) |
| 8350 | var validLen = lens[0] |
| 8351 | var placeHoldersLen = lens[1] |
| 8352 | |
| 8353 | var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) |
| 8354 | |
| 8355 | var curByte = 0 |
| 8356 | |
| 8357 | // if there are placeholders, only get up to the last complete 4 chars |
| 8358 | var len = placeHoldersLen > 0 |
| 8359 | ? validLen - 4 |
| 8360 | : validLen |
| 8361 | |
| 8362 | for (var i = 0; i < len; i += 4) { |
| 8363 | tmp = |
| 8364 | (revLookup[b64.charCodeAt(i)] << 18) | |
| 8365 | (revLookup[b64.charCodeAt(i + 1)] << 12) | |
| 8366 | (revLookup[b64.charCodeAt(i + 2)] << 6) | |
| 8367 | revLookup[b64.charCodeAt(i + 3)] |
| 8368 | arr[curByte++] = (tmp >> 16) & 0xFF |
| 8369 | arr[curByte++] = (tmp >> 8) & 0xFF |
| 8370 | arr[curByte++] = tmp & 0xFF |
| 8371 | } |
| 8372 | |
| 8373 | if (placeHoldersLen === 2) { |
| 8374 | tmp = |
| 8375 | (revLookup[b64.charCodeAt(i)] << 2) | |
| 8376 | (revLookup[b64.charCodeAt(i + 1)] >> 4) |
| 8377 | arr[curByte++] = tmp & 0xFF |
| 8378 | } |
| 8379 | |
| 8380 | if (placeHoldersLen === 1) { |
| 8381 | tmp = |
| 8382 | (revLookup[b64.charCodeAt(i)] << 10) | |
| 8383 | (revLookup[b64.charCodeAt(i + 1)] << 4) | |
| 8384 | (revLookup[b64.charCodeAt(i + 2)] >> 2) |
| 8385 | arr[curByte++] = (tmp >> 8) & 0xFF |
| 8386 | arr[curByte++] = tmp & 0xFF |
| 8387 | } |
| 8388 | |
| 8389 | return arr |
| 8390 | } |
| 8391 | |
| 8392 | function tripletToBase64 (num) { |
| 8393 | return lookup[num >> 18 & 0x3F] + |
| 8394 | lookup[num >> 12 & 0x3F] + |
| 8395 | lookup[num >> 6 & 0x3F] + |
| 8396 | lookup[num & 0x3F] |
| 8397 | } |
| 8398 | |
| 8399 | function encodeChunk (uint8, start, end) { |
| 8400 | var tmp |
| 8401 | var output = [] |
| 8402 | for (var i = start; i < end; i += 3) { |
| 8403 | tmp = |
| 8404 | ((uint8[i] << 16) & 0xFF0000) + |
| 8405 | ((uint8[i + 1] << 8) & 0xFF00) + |
| 8406 | (uint8[i + 2] & 0xFF) |
| 8407 | output.push(tripletToBase64(tmp)) |
| 8408 | } |
| 8409 | return output.join('') |
| 8410 | } |
| 8411 | |
| 8412 | function fromByteArray (uint8) { |
| 8413 | var tmp |
| 8414 | var len = uint8.length |
| 8415 | var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes |
| 8416 | var parts = [] |
| 8417 | var maxChunkLength = 16383 // must be multiple of 3 |
| 8418 | |
| 8419 | // go through the array every three bytes, we'll deal with trailing stuff later |
| 8420 | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { |
| 8421 | parts.push(encodeChunk( |
| 8422 | uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) |
| 8423 | )) |
| 8424 | } |
| 8425 | |
| 8426 | // pad the end with zeros, but make sure to not forget the extra bytes |
| 8427 | if (extraBytes === 1) { |
| 8428 | tmp = uint8[len - 1] |
| 8429 | parts.push( |
| 8430 | lookup[tmp >> 2] + |
| 8431 | lookup[(tmp << 4) & 0x3F] + |
| 8432 | '==' |
| 8433 | ) |
| 8434 | } else if (extraBytes === 2) { |
| 8435 | tmp = (uint8[len - 2] << 8) + uint8[len - 1] |
| 8436 | parts.push( |
| 8437 | lookup[tmp >> 10] + |
| 8438 | lookup[(tmp >> 4) & 0x3F] + |
| 8439 | lookup[(tmp << 2) & 0x3F] + |
| 8440 | '=' |
| 8441 | ) |
| 8442 | } |
| 8443 | |
| 8444 | return parts.join('') |
| 8445 | } |
| 8446 | |
| 8447 | },{}],40:[function(require,module,exports){ |
| 8448 | |
| 8449 | },{}],41:[function(require,module,exports){ |
| 8450 | (function (process){ |
| 8451 | var WritableStream = require('stream').Writable |
| 8452 | var inherits = require('util').inherits |
| 8453 | |
| 8454 | module.exports = BrowserStdout |
| 8455 | |
| 8456 | |
| 8457 | inherits(BrowserStdout, WritableStream) |
| 8458 | |
| 8459 | function BrowserStdout(opts) { |
| 8460 | if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts) |
| 8461 | |
| 8462 | opts = opts || {} |
| 8463 | WritableStream.call(this, opts) |
| 8464 | this.label = (opts.label !== undefined) ? opts.label : 'stdout' |
| 8465 | } |
| 8466 | |
| 8467 | BrowserStdout.prototype._write = function(chunks, encoding, cb) { |
| 8468 | var output = chunks.toString ? chunks.toString() : chunks |
| 8469 | if (this.label === false) { |
| 8470 | console.log(output) |
| 8471 | } else { |
| 8472 | console.log(this.label+':', output) |
| 8473 | } |
| 8474 | process.nextTick(cb) |
| 8475 | } |
| 8476 | |
| 8477 | }).call(this,require('_process')) |
| 8478 | },{"_process":69,"stream":84,"util":89}],42:[function(require,module,exports){ |
| 8479 | arguments[4][40][0].apply(exports,arguments) |
| 8480 | },{"dup":40}],43:[function(require,module,exports){ |
| 8481 | (function (Buffer){ |
| 8482 | /*! |
| 8483 | * The buffer module from node.js, for the browser. |
| 8484 | * |
| 8485 | * @author Feross Aboukhadijeh <https://feross.org> |
| 8486 | * @license MIT |
| 8487 | */ |
| 8488 | /* eslint-disable no-proto */ |
| 8489 | |
| 8490 | 'use strict' |
| 8491 | |
| 8492 | var base64 = require('base64-js') |
| 8493 | var ieee754 = require('ieee754') |
| 8494 | |
| 8495 | exports.Buffer = Buffer |
| 8496 | exports.SlowBuffer = SlowBuffer |
| 8497 | exports.INSPECT_MAX_BYTES = 50 |
| 8498 | |
| 8499 | var K_MAX_LENGTH = 0x7fffffff |
| 8500 | exports.kMaxLength = K_MAX_LENGTH |
| 8501 | |
| 8502 | /** |
| 8503 | * If `Buffer.TYPED_ARRAY_SUPPORT`: |
| 8504 | * === true Use Uint8Array implementation (fastest) |
| 8505 | * === false Print warning and recommend using `buffer` v4.x which has an Object |
| 8506 | * implementation (most compatible, even IE6) |
| 8507 | * |
| 8508 | * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, |
| 8509 | * Opera 11.6+, iOS 4.2+. |
| 8510 | * |
| 8511 | * We report that the browser does not support typed arrays if the are not subclassable |
| 8512 | * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` |
| 8513 | * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support |
| 8514 | * for __proto__ and has a buggy typed array implementation. |
| 8515 | */ |
| 8516 | Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() |
| 8517 | |
| 8518 | if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && |
| 8519 | typeof console.error === 'function') { |
| 8520 | console.error( |
| 8521 | 'This browser lacks typed array (Uint8Array) support which is required by ' + |
| 8522 | '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' |
| 8523 | ) |
| 8524 | } |
| 8525 | |
| 8526 | function typedArraySupport () { |
| 8527 | // Can typed array instances can be augmented? |
| 8528 | try { |
| 8529 | var arr = new Uint8Array(1) |
| 8530 | arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } |
| 8531 | return arr.foo() === 42 |
| 8532 | } catch (e) { |
| 8533 | return false |
| 8534 | } |
| 8535 | } |
| 8536 | |
| 8537 | Object.defineProperty(Buffer.prototype, 'parent', { |
| 8538 | enumerable: true, |
| 8539 | get: function () { |
| 8540 | if (!Buffer.isBuffer(this)) return undefined |
| 8541 | return this.buffer |
| 8542 | } |
| 8543 | }) |
| 8544 | |
| 8545 | Object.defineProperty(Buffer.prototype, 'offset', { |
| 8546 | enumerable: true, |
| 8547 | get: function () { |
| 8548 | if (!Buffer.isBuffer(this)) return undefined |
| 8549 | return this.byteOffset |
| 8550 | } |
| 8551 | }) |
| 8552 | |
| 8553 | function createBuffer (length) { |
| 8554 | if (length > K_MAX_LENGTH) { |
| 8555 | throw new RangeError('The value "' + length + '" is invalid for option "size"') |
| 8556 | } |
| 8557 | // Return an augmented `Uint8Array` instance |
| 8558 | var buf = new Uint8Array(length) |
| 8559 | buf.__proto__ = Buffer.prototype |
| 8560 | return buf |
| 8561 | } |
| 8562 | |
| 8563 | /** |
| 8564 | * The Buffer constructor returns instances of `Uint8Array` that have their |
| 8565 | * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of |
| 8566 | * `Uint8Array`, so the returned instances will have all the node `Buffer` methods |
| 8567 | * and the `Uint8Array` methods. Square bracket notation works as expected -- it |
| 8568 | * returns a single octet. |
| 8569 | * |
| 8570 | * The `Uint8Array` prototype remains unmodified. |
| 8571 | */ |
| 8572 | |
| 8573 | function Buffer (arg, encodingOrOffset, length) { |
| 8574 | // Common case. |
| 8575 | if (typeof arg === 'number') { |
| 8576 | if (typeof encodingOrOffset === 'string') { |
| 8577 | throw new TypeError( |
| 8578 | 'The "string" argument must be of type string. Received type number' |
| 8579 | ) |
| 8580 | } |
| 8581 | return allocUnsafe(arg) |
| 8582 | } |
| 8583 | return from(arg, encodingOrOffset, length) |
| 8584 | } |
| 8585 | |
| 8586 | // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 |
| 8587 | if (typeof Symbol !== 'undefined' && Symbol.species != null && |
| 8588 | Buffer[Symbol.species] === Buffer) { |
| 8589 | Object.defineProperty(Buffer, Symbol.species, { |
| 8590 | value: null, |
| 8591 | configurable: true, |
| 8592 | enumerable: false, |
| 8593 | writable: false |
| 8594 | }) |
| 8595 | } |
| 8596 | |
| 8597 | Buffer.poolSize = 8192 // not used by this implementation |
| 8598 | |
| 8599 | function from (value, encodingOrOffset, length) { |
| 8600 | if (typeof value === 'string') { |
| 8601 | return fromString(value, encodingOrOffset) |
| 8602 | } |
| 8603 | |
| 8604 | if (ArrayBuffer.isView(value)) { |
| 8605 | return fromArrayLike(value) |
| 8606 | } |
| 8607 | |
| 8608 | if (value == null) { |
| 8609 | throw TypeError( |
| 8610 | 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + |
| 8611 | 'or Array-like Object. Received type ' + (typeof value) |
| 8612 | ) |
| 8613 | } |
| 8614 | |
| 8615 | if (isInstance(value, ArrayBuffer) || |
| 8616 | (value && isInstance(value.buffer, ArrayBuffer))) { |
| 8617 | return fromArrayBuffer(value, encodingOrOffset, length) |
| 8618 | } |
| 8619 | |
| 8620 | if (typeof value === 'number') { |
| 8621 | throw new TypeError( |
| 8622 | 'The "value" argument must not be of type number. Received type number' |
| 8623 | ) |
| 8624 | } |
| 8625 | |
| 8626 | var valueOf = value.valueOf && value.valueOf() |
| 8627 | if (valueOf != null && valueOf !== value) { |
| 8628 | return Buffer.from(valueOf, encodingOrOffset, length) |
| 8629 | } |
| 8630 | |
| 8631 | var b = fromObject(value) |
| 8632 | if (b) return b |
| 8633 | |
| 8634 | if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && |
| 8635 | typeof value[Symbol.toPrimitive] === 'function') { |
| 8636 | return Buffer.from( |
| 8637 | value[Symbol.toPrimitive]('string'), encodingOrOffset, length |
| 8638 | ) |
| 8639 | } |
| 8640 | |
| 8641 | throw new TypeError( |
| 8642 | 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + |
| 8643 | 'or Array-like Object. Received type ' + (typeof value) |
| 8644 | ) |
| 8645 | } |
| 8646 | |
| 8647 | /** |
| 8648 | * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError |
| 8649 | * if value is a number. |
| 8650 | * Buffer.from(str[, encoding]) |
| 8651 | * Buffer.from(array) |
| 8652 | * Buffer.from(buffer) |
| 8653 | * Buffer.from(arrayBuffer[, byteOffset[, length]]) |
| 8654 | **/ |
| 8655 | Buffer.from = function (value, encodingOrOffset, length) { |
| 8656 | return from(value, encodingOrOffset, length) |
| 8657 | } |
| 8658 | |
| 8659 | // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: |
| 8660 | // https://github.com/feross/buffer/pull/148 |
| 8661 | Buffer.prototype.__proto__ = Uint8Array.prototype |
| 8662 | Buffer.__proto__ = Uint8Array |
| 8663 | |
| 8664 | function assertSize (size) { |
| 8665 | if (typeof size !== 'number') { |
| 8666 | throw new TypeError('"size" argument must be of type number') |
| 8667 | } else if (size < 0) { |
| 8668 | throw new RangeError('The value "' + size + '" is invalid for option "size"') |
| 8669 | } |
| 8670 | } |
| 8671 | |
| 8672 | function alloc (size, fill, encoding) { |
| 8673 | assertSize(size) |
| 8674 | if (size <= 0) { |
| 8675 | return createBuffer(size) |
| 8676 | } |
| 8677 | if (fill !== undefined) { |
| 8678 | // Only pay attention to encoding if it's a string. This |
| 8679 | // prevents accidentally sending in a number that would |
| 8680 | // be interpretted as a start offset. |
| 8681 | return typeof encoding === 'string' |
| 8682 | ? createBuffer(size).fill(fill, encoding) |
| 8683 | : createBuffer(size).fill(fill) |
| 8684 | } |
| 8685 | return createBuffer(size) |
| 8686 | } |
| 8687 | |
| 8688 | /** |
| 8689 | * Creates a new filled Buffer instance. |
| 8690 | * alloc(size[, fill[, encoding]]) |
| 8691 | **/ |
| 8692 | Buffer.alloc = function (size, fill, encoding) { |
| 8693 | return alloc(size, fill, encoding) |
| 8694 | } |
| 8695 | |
| 8696 | function allocUnsafe (size) { |
| 8697 | assertSize(size) |
| 8698 | return createBuffer(size < 0 ? 0 : checked(size) | 0) |
| 8699 | } |
| 8700 | |
| 8701 | /** |
| 8702 | * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. |
| 8703 | * */ |
| 8704 | Buffer.allocUnsafe = function (size) { |
| 8705 | return allocUnsafe(size) |
| 8706 | } |
| 8707 | /** |
| 8708 | * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. |
| 8709 | */ |
| 8710 | Buffer.allocUnsafeSlow = function (size) { |
| 8711 | return allocUnsafe(size) |
| 8712 | } |
| 8713 | |
| 8714 | function fromString (string, encoding) { |
| 8715 | if (typeof encoding !== 'string' || encoding === '') { |
| 8716 | encoding = 'utf8' |
| 8717 | } |
| 8718 | |
| 8719 | if (!Buffer.isEncoding(encoding)) { |
| 8720 | throw new TypeError('Unknown encoding: ' + encoding) |
| 8721 | } |
| 8722 | |
| 8723 | var length = byteLength(string, encoding) | 0 |
| 8724 | var buf = createBuffer(length) |
| 8725 | |
| 8726 | var actual = buf.write(string, encoding) |
| 8727 | |
| 8728 | if (actual !== length) { |
| 8729 | // Writing a hex string, for example, that contains invalid characters will |
| 8730 | // cause everything after the first invalid character to be ignored. (e.g. |
| 8731 | // 'abxxcd' will be treated as 'ab') |
| 8732 | buf = buf.slice(0, actual) |
| 8733 | } |
| 8734 | |
| 8735 | return buf |
| 8736 | } |
| 8737 | |
| 8738 | function fromArrayLike (array) { |
| 8739 | var length = array.length < 0 ? 0 : checked(array.length) | 0 |
| 8740 | var buf = createBuffer(length) |
| 8741 | for (var i = 0; i < length; i += 1) { |
| 8742 | buf[i] = array[i] & 255 |
| 8743 | } |
| 8744 | return buf |
| 8745 | } |
| 8746 | |
| 8747 | function fromArrayBuffer (array, byteOffset, length) { |
| 8748 | if (byteOffset < 0 || array.byteLength < byteOffset) { |
| 8749 | throw new RangeError('"offset" is outside of buffer bounds') |
| 8750 | } |
| 8751 | |
| 8752 | if (array.byteLength < byteOffset + (length || 0)) { |
| 8753 | throw new RangeError('"length" is outside of buffer bounds') |
| 8754 | } |
| 8755 | |
| 8756 | var buf |
| 8757 | if (byteOffset === undefined && length === undefined) { |
| 8758 | buf = new Uint8Array(array) |
| 8759 | } else if (length === undefined) { |
| 8760 | buf = new Uint8Array(array, byteOffset) |
| 8761 | } else { |
| 8762 | buf = new Uint8Array(array, byteOffset, length) |
| 8763 | } |
| 8764 | |
| 8765 | // Return an augmented `Uint8Array` instance |
| 8766 | buf.__proto__ = Buffer.prototype |
| 8767 | return buf |
| 8768 | } |
| 8769 | |
| 8770 | function fromObject (obj) { |
| 8771 | if (Buffer.isBuffer(obj)) { |
| 8772 | var len = checked(obj.length) | 0 |
| 8773 | var buf = createBuffer(len) |
| 8774 | |
| 8775 | if (buf.length === 0) { |
| 8776 | return buf |
| 8777 | } |
| 8778 | |
| 8779 | obj.copy(buf, 0, 0, len) |
| 8780 | return buf |
| 8781 | } |
| 8782 | |
| 8783 | if (obj.length !== undefined) { |
| 8784 | if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { |
| 8785 | return createBuffer(0) |
| 8786 | } |
| 8787 | return fromArrayLike(obj) |
| 8788 | } |
| 8789 | |
| 8790 | if (obj.type === 'Buffer' && Array.isArray(obj.data)) { |
| 8791 | return fromArrayLike(obj.data) |
| 8792 | } |
| 8793 | } |
| 8794 | |
| 8795 | function checked (length) { |
| 8796 | // Note: cannot use `length < K_MAX_LENGTH` here because that fails when |
| 8797 | // length is NaN (which is otherwise coerced to zero.) |
| 8798 | if (length >= K_MAX_LENGTH) { |
| 8799 | throw new RangeError('Attempt to allocate Buffer larger than maximum ' + |
| 8800 | 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') |
| 8801 | } |
| 8802 | return length | 0 |
| 8803 | } |
| 8804 | |
| 8805 | function SlowBuffer (length) { |
| 8806 | if (+length != length) { // eslint-disable-line eqeqeq |
| 8807 | length = 0 |
| 8808 | } |
| 8809 | return Buffer.alloc(+length) |
| 8810 | } |
| 8811 | |
| 8812 | Buffer.isBuffer = function isBuffer (b) { |
| 8813 | return b != null && b._isBuffer === true && |
| 8814 | b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false |
| 8815 | } |
| 8816 | |
| 8817 | Buffer.compare = function compare (a, b) { |
| 8818 | if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) |
| 8819 | if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) |
| 8820 | if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { |
| 8821 | throw new TypeError( |
| 8822 | 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' |
| 8823 | ) |
| 8824 | } |
| 8825 | |
| 8826 | if (a === b) return 0 |
| 8827 | |
| 8828 | var x = a.length |
| 8829 | var y = b.length |
| 8830 | |
| 8831 | for (var i = 0, len = Math.min(x, y); i < len; ++i) { |
| 8832 | if (a[i] !== b[i]) { |
| 8833 | x = a[i] |
| 8834 | y = b[i] |
| 8835 | break |
| 8836 | } |
| 8837 | } |
| 8838 | |
| 8839 | if (x < y) return -1 |
| 8840 | if (y < x) return 1 |
| 8841 | return 0 |
| 8842 | } |
| 8843 | |
| 8844 | Buffer.isEncoding = function isEncoding (encoding) { |
| 8845 | switch (String(encoding).toLowerCase()) { |
| 8846 | case 'hex': |
| 8847 | case 'utf8': |
| 8848 | case 'utf-8': |
| 8849 | case 'ascii': |
| 8850 | case 'latin1': |
| 8851 | case 'binary': |
| 8852 | case 'base64': |
| 8853 | case 'ucs2': |
| 8854 | case 'ucs-2': |
| 8855 | case 'utf16le': |
| 8856 | case 'utf-16le': |
| 8857 | return true |
| 8858 | default: |
| 8859 | return false |
| 8860 | } |
| 8861 | } |
| 8862 | |
| 8863 | Buffer.concat = function concat (list, length) { |
| 8864 | if (!Array.isArray(list)) { |
| 8865 | throw new TypeError('"list" argument must be an Array of Buffers') |
| 8866 | } |
| 8867 | |
| 8868 | if (list.length === 0) { |
| 8869 | return Buffer.alloc(0) |
| 8870 | } |
| 8871 | |
| 8872 | var i |
| 8873 | if (length === undefined) { |
| 8874 | length = 0 |
| 8875 | for (i = 0; i < list.length; ++i) { |
| 8876 | length += list[i].length |
| 8877 | } |
| 8878 | } |
| 8879 | |
| 8880 | var buffer = Buffer.allocUnsafe(length) |
| 8881 | var pos = 0 |
| 8882 | for (i = 0; i < list.length; ++i) { |
| 8883 | var buf = list[i] |
| 8884 | if (isInstance(buf, Uint8Array)) { |
| 8885 | buf = Buffer.from(buf) |
| 8886 | } |
| 8887 | if (!Buffer.isBuffer(buf)) { |
| 8888 | throw new TypeError('"list" argument must be an Array of Buffers') |
| 8889 | } |
| 8890 | buf.copy(buffer, pos) |
| 8891 | pos += buf.length |
| 8892 | } |
| 8893 | return buffer |
| 8894 | } |
| 8895 | |
| 8896 | function byteLength (string, encoding) { |
| 8897 | if (Buffer.isBuffer(string)) { |
| 8898 | return string.length |
| 8899 | } |
| 8900 | if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { |
| 8901 | return string.byteLength |
| 8902 | } |
| 8903 | if (typeof string !== 'string') { |
| 8904 | throw new TypeError( |
| 8905 | 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + |
| 8906 | 'Received type ' + typeof string |
| 8907 | ) |
| 8908 | } |
| 8909 | |
| 8910 | var len = string.length |
| 8911 | var mustMatch = (arguments.length > 2 && arguments[2] === true) |
| 8912 | if (!mustMatch && len === 0) return 0 |
| 8913 | |
| 8914 | // Use a for loop to avoid recursion |
| 8915 | var loweredCase = false |
| 8916 | for (;;) { |
| 8917 | switch (encoding) { |
| 8918 | case 'ascii': |
| 8919 | case 'latin1': |
| 8920 | case 'binary': |
| 8921 | return len |
| 8922 | case 'utf8': |
| 8923 | case 'utf-8': |
| 8924 | return utf8ToBytes(string).length |
| 8925 | case 'ucs2': |
| 8926 | case 'ucs-2': |
| 8927 | case 'utf16le': |
| 8928 | case 'utf-16le': |
| 8929 | return len * 2 |
| 8930 | case 'hex': |
| 8931 | return len >>> 1 |
| 8932 | case 'base64': |
| 8933 | return base64ToBytes(string).length |
| 8934 | default: |
| 8935 | if (loweredCase) { |
| 8936 | return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 |
| 8937 | } |
| 8938 | encoding = ('' + encoding).toLowerCase() |
| 8939 | loweredCase = true |
| 8940 | } |
| 8941 | } |
| 8942 | } |
| 8943 | Buffer.byteLength = byteLength |
| 8944 | |
| 8945 | function slowToString (encoding, start, end) { |
| 8946 | var loweredCase = false |
| 8947 | |
| 8948 | // No need to verify that "this.length <= MAX_UINT32" since it's a read-only |
| 8949 | // property of a typed array. |
| 8950 | |
| 8951 | // This behaves neither like String nor Uint8Array in that we set start/end |
| 8952 | // to their upper/lower bounds if the value passed is out of range. |
| 8953 | // undefined is handled specially as per ECMA-262 6th Edition, |
| 8954 | // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. |
| 8955 | if (start === undefined || start < 0) { |
| 8956 | start = 0 |
| 8957 | } |
| 8958 | // Return early if start > this.length. Done here to prevent potential uint32 |
| 8959 | // coercion fail below. |
| 8960 | if (start > this.length) { |
| 8961 | return '' |
| 8962 | } |
| 8963 | |
| 8964 | if (end === undefined || end > this.length) { |
| 8965 | end = this.length |
| 8966 | } |
| 8967 | |
| 8968 | if (end <= 0) { |
| 8969 | return '' |
| 8970 | } |
| 8971 | |
| 8972 | // Force coersion to uint32. This will also coerce falsey/NaN values to 0. |
| 8973 | end >>>= 0 |
| 8974 | start >>>= 0 |
| 8975 | |
| 8976 | if (end <= start) { |
| 8977 | return '' |
| 8978 | } |
| 8979 | |
| 8980 | if (!encoding) encoding = 'utf8' |
| 8981 | |
| 8982 | while (true) { |
| 8983 | switch (encoding) { |
| 8984 | case 'hex': |
| 8985 | return hexSlice(this, start, end) |
| 8986 | |
| 8987 | case 'utf8': |
| 8988 | case 'utf-8': |
| 8989 | return utf8Slice(this, start, end) |
| 8990 | |
| 8991 | case 'ascii': |
| 8992 | return asciiSlice(this, start, end) |
| 8993 | |
| 8994 | case 'latin1': |
| 8995 | case 'binary': |
| 8996 | return latin1Slice(this, start, end) |
| 8997 | |
| 8998 | case 'base64': |
| 8999 | return base64Slice(this, start, end) |
| 9000 | |
| 9001 | case 'ucs2': |
| 9002 | case 'ucs-2': |
| 9003 | case 'utf16le': |
| 9004 | case 'utf-16le': |
| 9005 | return utf16leSlice(this, start, end) |
| 9006 | |
| 9007 | default: |
| 9008 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) |
| 9009 | encoding = (encoding + '').toLowerCase() |
| 9010 | loweredCase = true |
| 9011 | } |
| 9012 | } |
| 9013 | } |
| 9014 | |
| 9015 | // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) |
| 9016 | // to detect a Buffer instance. It's not possible to use `instanceof Buffer` |
| 9017 | // reliably in a browserify context because there could be multiple different |
| 9018 | // copies of the 'buffer' package in use. This method works even for Buffer |
| 9019 | // instances that were created from another copy of the `buffer` package. |
| 9020 | // See: https://github.com/feross/buffer/issues/154 |
| 9021 | Buffer.prototype._isBuffer = true |
| 9022 | |
| 9023 | function swap (b, n, m) { |
| 9024 | var i = b[n] |
| 9025 | b[n] = b[m] |
| 9026 | b[m] = i |
| 9027 | } |
| 9028 | |
| 9029 | Buffer.prototype.swap16 = function swap16 () { |
| 9030 | var len = this.length |
| 9031 | if (len % 2 !== 0) { |
| 9032 | throw new RangeError('Buffer size must be a multiple of 16-bits') |
| 9033 | } |
| 9034 | for (var i = 0; i < len; i += 2) { |
| 9035 | swap(this, i, i + 1) |
| 9036 | } |
| 9037 | return this |
| 9038 | } |
| 9039 | |
| 9040 | Buffer.prototype.swap32 = function swap32 () { |
| 9041 | var len = this.length |
| 9042 | if (len % 4 !== 0) { |
| 9043 | throw new RangeError('Buffer size must be a multiple of 32-bits') |
| 9044 | } |
| 9045 | for (var i = 0; i < len; i += 4) { |
| 9046 | swap(this, i, i + 3) |
| 9047 | swap(this, i + 1, i + 2) |
| 9048 | } |
| 9049 | return this |
| 9050 | } |
| 9051 | |
| 9052 | Buffer.prototype.swap64 = function swap64 () { |
| 9053 | var len = this.length |
| 9054 | if (len % 8 !== 0) { |
| 9055 | throw new RangeError('Buffer size must be a multiple of 64-bits') |
| 9056 | } |
| 9057 | for (var i = 0; i < len; i += 8) { |
| 9058 | swap(this, i, i + 7) |
| 9059 | swap(this, i + 1, i + 6) |
| 9060 | swap(this, i + 2, i + 5) |
| 9061 | swap(this, i + 3, i + 4) |
| 9062 | } |
| 9063 | return this |
| 9064 | } |
| 9065 | |
| 9066 | Buffer.prototype.toString = function toString () { |
| 9067 | var length = this.length |
| 9068 | if (length === 0) return '' |
| 9069 | if (arguments.length === 0) return utf8Slice(this, 0, length) |
| 9070 | return slowToString.apply(this, arguments) |
| 9071 | } |
| 9072 | |
| 9073 | Buffer.prototype.toLocaleString = Buffer.prototype.toString |
| 9074 | |
| 9075 | Buffer.prototype.equals = function equals (b) { |
| 9076 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') |
| 9077 | if (this === b) return true |
| 9078 | return Buffer.compare(this, b) === 0 |
| 9079 | } |
| 9080 | |
| 9081 | Buffer.prototype.inspect = function inspect () { |
| 9082 | var str = '' |
| 9083 | var max = exports.INSPECT_MAX_BYTES |
| 9084 | str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() |
| 9085 | if (this.length > max) str += ' ... ' |
| 9086 | return '<Buffer ' + str + '>' |
| 9087 | } |
| 9088 | |
| 9089 | Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { |
| 9090 | if (isInstance(target, Uint8Array)) { |
| 9091 | target = Buffer.from(target, target.offset, target.byteLength) |
| 9092 | } |
| 9093 | if (!Buffer.isBuffer(target)) { |
| 9094 | throw new TypeError( |
| 9095 | 'The "target" argument must be one of type Buffer or Uint8Array. ' + |
| 9096 | 'Received type ' + (typeof target) |
| 9097 | ) |
| 9098 | } |
| 9099 | |
| 9100 | if (start === undefined) { |
| 9101 | start = 0 |
| 9102 | } |
| 9103 | if (end === undefined) { |
| 9104 | end = target ? target.length : 0 |
| 9105 | } |
| 9106 | if (thisStart === undefined) { |
| 9107 | thisStart = 0 |
| 9108 | } |
| 9109 | if (thisEnd === undefined) { |
| 9110 | thisEnd = this.length |
| 9111 | } |
| 9112 | |
| 9113 | if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { |
| 9114 | throw new RangeError('out of range index') |
| 9115 | } |
| 9116 | |
| 9117 | if (thisStart >= thisEnd && start >= end) { |
| 9118 | return 0 |
| 9119 | } |
| 9120 | if (thisStart >= thisEnd) { |
| 9121 | return -1 |
| 9122 | } |
| 9123 | if (start >= end) { |
| 9124 | return 1 |
| 9125 | } |
| 9126 | |
| 9127 | start >>>= 0 |
| 9128 | end >>>= 0 |
| 9129 | thisStart >>>= 0 |
| 9130 | thisEnd >>>= 0 |
| 9131 | |
| 9132 | if (this === target) return 0 |
| 9133 | |
| 9134 | var x = thisEnd - thisStart |
| 9135 | var y = end - start |
| 9136 | var len = Math.min(x, y) |
| 9137 | |
| 9138 | var thisCopy = this.slice(thisStart, thisEnd) |
| 9139 | var targetCopy = target.slice(start, end) |
| 9140 | |
| 9141 | for (var i = 0; i < len; ++i) { |
| 9142 | if (thisCopy[i] !== targetCopy[i]) { |
| 9143 | x = thisCopy[i] |
| 9144 | y = targetCopy[i] |
| 9145 | break |
| 9146 | } |
| 9147 | } |
| 9148 | |
| 9149 | if (x < y) return -1 |
| 9150 | if (y < x) return 1 |
| 9151 | return 0 |
| 9152 | } |
| 9153 | |
| 9154 | // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, |
| 9155 | // OR the last index of `val` in `buffer` at offset <= `byteOffset`. |
| 9156 | // |
| 9157 | // Arguments: |
| 9158 | // - buffer - a Buffer to search |
| 9159 | // - val - a string, Buffer, or number |
| 9160 | // - byteOffset - an index into `buffer`; will be clamped to an int32 |
| 9161 | // - encoding - an optional encoding, relevant is val is a string |
| 9162 | // - dir - true for indexOf, false for lastIndexOf |
| 9163 | function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { |
| 9164 | // Empty buffer means no match |
| 9165 | if (buffer.length === 0) return -1 |
| 9166 | |
| 9167 | // Normalize byteOffset |
| 9168 | if (typeof byteOffset === 'string') { |
| 9169 | encoding = byteOffset |
| 9170 | byteOffset = 0 |
| 9171 | } else if (byteOffset > 0x7fffffff) { |
| 9172 | byteOffset = 0x7fffffff |
| 9173 | } else if (byteOffset < -0x80000000) { |
| 9174 | byteOffset = -0x80000000 |
| 9175 | } |
| 9176 | byteOffset = +byteOffset // Coerce to Number. |
| 9177 | if (numberIsNaN(byteOffset)) { |
| 9178 | // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer |
| 9179 | byteOffset = dir ? 0 : (buffer.length - 1) |
| 9180 | } |
| 9181 | |
| 9182 | // Normalize byteOffset: negative offsets start from the end of the buffer |
| 9183 | if (byteOffset < 0) byteOffset = buffer.length + byteOffset |
| 9184 | if (byteOffset >= buffer.length) { |
| 9185 | if (dir) return -1 |
| 9186 | else byteOffset = buffer.length - 1 |
| 9187 | } else if (byteOffset < 0) { |
| 9188 | if (dir) byteOffset = 0 |
| 9189 | else return -1 |
| 9190 | } |
| 9191 | |
| 9192 | // Normalize val |
| 9193 | if (typeof val === 'string') { |
| 9194 | val = Buffer.from(val, encoding) |
| 9195 | } |
| 9196 | |
| 9197 | // Finally, search either indexOf (if dir is true) or lastIndexOf |
| 9198 | if (Buffer.isBuffer(val)) { |
| 9199 | // Special case: looking for empty string/buffer always fails |
| 9200 | if (val.length === 0) { |
| 9201 | return -1 |
| 9202 | } |
| 9203 | return arrayIndexOf(buffer, val, byteOffset, encoding, dir) |
| 9204 | } else if (typeof val === 'number') { |
| 9205 | val = val & 0xFF // Search for a byte value [0-255] |
| 9206 | if (typeof Uint8Array.prototype.indexOf === 'function') { |
| 9207 | if (dir) { |
| 9208 | return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) |
| 9209 | } else { |
| 9210 | return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) |
| 9211 | } |
| 9212 | } |
| 9213 | return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) |
| 9214 | } |
| 9215 | |
| 9216 | throw new TypeError('val must be string, number or Buffer') |
| 9217 | } |
| 9218 | |
| 9219 | function arrayIndexOf (arr, val, byteOffset, encoding, dir) { |
| 9220 | var indexSize = 1 |
| 9221 | var arrLength = arr.length |
| 9222 | var valLength = val.length |
| 9223 | |
| 9224 | if (encoding !== undefined) { |
| 9225 | encoding = String(encoding).toLowerCase() |
| 9226 | if (encoding === 'ucs2' || encoding === 'ucs-2' || |
| 9227 | encoding === 'utf16le' || encoding === 'utf-16le') { |
| 9228 | if (arr.length < 2 || val.length < 2) { |
| 9229 | return -1 |
| 9230 | } |
| 9231 | indexSize = 2 |
| 9232 | arrLength /= 2 |
| 9233 | valLength /= 2 |
| 9234 | byteOffset /= 2 |
| 9235 | } |
| 9236 | } |
| 9237 | |
| 9238 | function read (buf, i) { |
| 9239 | if (indexSize === 1) { |
| 9240 | return buf[i] |
| 9241 | } else { |
| 9242 | return buf.readUInt16BE(i * indexSize) |
| 9243 | } |
| 9244 | } |
| 9245 | |
| 9246 | var i |
| 9247 | if (dir) { |
| 9248 | var foundIndex = -1 |
| 9249 | for (i = byteOffset; i < arrLength; i++) { |
| 9250 | if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { |
| 9251 | if (foundIndex === -1) foundIndex = i |
| 9252 | if (i - foundIndex + 1 === valLength) return foundIndex * indexSize |
| 9253 | } else { |
| 9254 | if (foundIndex !== -1) i -= i - foundIndex |
| 9255 | foundIndex = -1 |
| 9256 | } |
| 9257 | } |
| 9258 | } else { |
| 9259 | if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength |
| 9260 | for (i = byteOffset; i >= 0; i--) { |
| 9261 | var found = true |
| 9262 | for (var j = 0; j < valLength; j++) { |
| 9263 | if (read(arr, i + j) !== read(val, j)) { |
| 9264 | found = false |
| 9265 | break |
| 9266 | } |
| 9267 | } |
| 9268 | if (found) return i |
| 9269 | } |
| 9270 | } |
| 9271 | |
| 9272 | return -1 |
| 9273 | } |
| 9274 | |
| 9275 | Buffer.prototype.includes = function includes (val, byteOffset, encoding) { |
| 9276 | return this.indexOf(val, byteOffset, encoding) !== -1 |
| 9277 | } |
| 9278 | |
| 9279 | Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { |
| 9280 | return bidirectionalIndexOf(this, val, byteOffset, encoding, true) |
| 9281 | } |
| 9282 | |
| 9283 | Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { |
| 9284 | return bidirectionalIndexOf(this, val, byteOffset, encoding, false) |
| 9285 | } |
| 9286 | |
| 9287 | function hexWrite (buf, string, offset, length) { |
| 9288 | offset = Number(offset) || 0 |
| 9289 | var remaining = buf.length - offset |
| 9290 | if (!length) { |
| 9291 | length = remaining |
| 9292 | } else { |
| 9293 | length = Number(length) |
| 9294 | if (length > remaining) { |
| 9295 | length = remaining |
| 9296 | } |
| 9297 | } |
| 9298 | |
| 9299 | var strLen = string.length |
| 9300 | |
| 9301 | if (length > strLen / 2) { |
| 9302 | length = strLen / 2 |
| 9303 | } |
| 9304 | for (var i = 0; i < length; ++i) { |
| 9305 | var parsed = parseInt(string.substr(i * 2, 2), 16) |
| 9306 | if (numberIsNaN(parsed)) return i |
| 9307 | buf[offset + i] = parsed |
| 9308 | } |
| 9309 | return i |
| 9310 | } |
| 9311 | |
| 9312 | function utf8Write (buf, string, offset, length) { |
| 9313 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) |
| 9314 | } |
| 9315 | |
| 9316 | function asciiWrite (buf, string, offset, length) { |
| 9317 | return blitBuffer(asciiToBytes(string), buf, offset, length) |
| 9318 | } |
| 9319 | |
| 9320 | function latin1Write (buf, string, offset, length) { |
| 9321 | return asciiWrite(buf, string, offset, length) |
| 9322 | } |
| 9323 | |
| 9324 | function base64Write (buf, string, offset, length) { |
| 9325 | return blitBuffer(base64ToBytes(string), buf, offset, length) |
| 9326 | } |
| 9327 | |
| 9328 | function ucs2Write (buf, string, offset, length) { |
| 9329 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) |
| 9330 | } |
| 9331 | |
| 9332 | Buffer.prototype.write = function write (string, offset, length, encoding) { |
| 9333 | // Buffer#write(string) |
| 9334 | if (offset === undefined) { |
| 9335 | encoding = 'utf8' |
| 9336 | length = this.length |
| 9337 | offset = 0 |
| 9338 | // Buffer#write(string, encoding) |
| 9339 | } else if (length === undefined && typeof offset === 'string') { |
| 9340 | encoding = offset |
| 9341 | length = this.length |
| 9342 | offset = 0 |
| 9343 | // Buffer#write(string, offset[, length][, encoding]) |
| 9344 | } else if (isFinite(offset)) { |
| 9345 | offset = offset >>> 0 |
| 9346 | if (isFinite(length)) { |
| 9347 | length = length >>> 0 |
| 9348 | if (encoding === undefined) encoding = 'utf8' |
| 9349 | } else { |
| 9350 | encoding = length |
| 9351 | length = undefined |
| 9352 | } |
| 9353 | } else { |
| 9354 | throw new Error( |
| 9355 | 'Buffer.write(string, encoding, offset[, length]) is no longer supported' |
| 9356 | ) |
| 9357 | } |
| 9358 | |
| 9359 | var remaining = this.length - offset |
| 9360 | if (length === undefined || length > remaining) length = remaining |
| 9361 | |
| 9362 | if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { |
| 9363 | throw new RangeError('Attempt to write outside buffer bounds') |
| 9364 | } |
| 9365 | |
| 9366 | if (!encoding) encoding = 'utf8' |
| 9367 | |
| 9368 | var loweredCase = false |
| 9369 | for (;;) { |
| 9370 | switch (encoding) { |
| 9371 | case 'hex': |
| 9372 | return hexWrite(this, string, offset, length) |
| 9373 | |
| 9374 | case 'utf8': |
| 9375 | case 'utf-8': |
| 9376 | return utf8Write(this, string, offset, length) |
| 9377 | |
| 9378 | case 'ascii': |
| 9379 | return asciiWrite(this, string, offset, length) |
| 9380 | |
| 9381 | case 'latin1': |
| 9382 | case 'binary': |
| 9383 | return latin1Write(this, string, offset, length) |
| 9384 | |
| 9385 | case 'base64': |
| 9386 | // Warning: maxLength not taken into account in base64Write |
| 9387 | return base64Write(this, string, offset, length) |
| 9388 | |
| 9389 | case 'ucs2': |
| 9390 | case 'ucs-2': |
| 9391 | case 'utf16le': |
| 9392 | case 'utf-16le': |
| 9393 | return ucs2Write(this, string, offset, length) |
| 9394 | |
| 9395 | default: |
| 9396 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) |
| 9397 | encoding = ('' + encoding).toLowerCase() |
| 9398 | loweredCase = true |
| 9399 | } |
| 9400 | } |
| 9401 | } |
| 9402 | |
| 9403 | Buffer.prototype.toJSON = function toJSON () { |
| 9404 | return { |
| 9405 | type: 'Buffer', |
| 9406 | data: Array.prototype.slice.call(this._arr || this, 0) |
| 9407 | } |
| 9408 | } |
| 9409 | |
| 9410 | function base64Slice (buf, start, end) { |
| 9411 | if (start === 0 && end === buf.length) { |
| 9412 | return base64.fromByteArray(buf) |
| 9413 | } else { |
| 9414 | return base64.fromByteArray(buf.slice(start, end)) |
| 9415 | } |
| 9416 | } |
| 9417 | |
| 9418 | function utf8Slice (buf, start, end) { |
| 9419 | end = Math.min(buf.length, end) |
| 9420 | var res = [] |
| 9421 | |
| 9422 | var i = start |
| 9423 | while (i < end) { |
| 9424 | var firstByte = buf[i] |
| 9425 | var codePoint = null |
| 9426 | var bytesPerSequence = (firstByte > 0xEF) ? 4 |
| 9427 | : (firstByte > 0xDF) ? 3 |
| 9428 | : (firstByte > 0xBF) ? 2 |
| 9429 | : 1 |
| 9430 | |
| 9431 | if (i + bytesPerSequence <= end) { |
| 9432 | var secondByte, thirdByte, fourthByte, tempCodePoint |
| 9433 | |
| 9434 | switch (bytesPerSequence) { |
| 9435 | case 1: |
| 9436 | if (firstByte < 0x80) { |
| 9437 | codePoint = firstByte |
| 9438 | } |
| 9439 | break |
| 9440 | case 2: |
| 9441 | secondByte = buf[i + 1] |
| 9442 | if ((secondByte & 0xC0) === 0x80) { |
| 9443 | tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) |
| 9444 | if (tempCodePoint > 0x7F) { |
| 9445 | codePoint = tempCodePoint |
| 9446 | } |
| 9447 | } |
| 9448 | break |
| 9449 | case 3: |
| 9450 | secondByte = buf[i + 1] |
| 9451 | thirdByte = buf[i + 2] |
| 9452 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { |
| 9453 | tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) |
| 9454 | if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { |
| 9455 | codePoint = tempCodePoint |
| 9456 | } |
| 9457 | } |
| 9458 | break |
| 9459 | case 4: |
| 9460 | secondByte = buf[i + 1] |
| 9461 | thirdByte = buf[i + 2] |
| 9462 | fourthByte = buf[i + 3] |
| 9463 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { |
| 9464 | tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) |
| 9465 | if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { |
| 9466 | codePoint = tempCodePoint |
| 9467 | } |
| 9468 | } |
| 9469 | } |
| 9470 | } |
| 9471 | |
| 9472 | if (codePoint === null) { |
| 9473 | // we did not generate a valid codePoint so insert a |
| 9474 | // replacement char (U+FFFD) and advance only 1 byte |
| 9475 | codePoint = 0xFFFD |
| 9476 | bytesPerSequence = 1 |
| 9477 | } else if (codePoint > 0xFFFF) { |
| 9478 | // encode to utf16 (surrogate pair dance) |
| 9479 | codePoint -= 0x10000 |
| 9480 | res.push(codePoint >>> 10 & 0x3FF | 0xD800) |
| 9481 | codePoint = 0xDC00 | codePoint & 0x3FF |
| 9482 | } |
| 9483 | |
| 9484 | res.push(codePoint) |
| 9485 | i += bytesPerSequence |
| 9486 | } |
| 9487 | |
| 9488 | return decodeCodePointsArray(res) |
| 9489 | } |
| 9490 | |
| 9491 | // Based on http://stackoverflow.com/a/22747272/680742, the browser with |
| 9492 | // the lowest limit is Chrome, with 0x10000 args. |
| 9493 | // We go 1 magnitude less, for safety |
| 9494 | var MAX_ARGUMENTS_LENGTH = 0x1000 |
| 9495 | |
| 9496 | function decodeCodePointsArray (codePoints) { |
| 9497 | var len = codePoints.length |
| 9498 | if (len <= MAX_ARGUMENTS_LENGTH) { |
| 9499 | return String.fromCharCode.apply(String, codePoints) // avoid extra slice() |
| 9500 | } |
| 9501 | |
| 9502 | // Decode in chunks to avoid "call stack size exceeded". |
| 9503 | var res = '' |
| 9504 | var i = 0 |
| 9505 | while (i < len) { |
| 9506 | res += String.fromCharCode.apply( |
| 9507 | String, |
| 9508 | codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) |
| 9509 | ) |
| 9510 | } |
| 9511 | return res |
| 9512 | } |
| 9513 | |
| 9514 | function asciiSlice (buf, start, end) { |
| 9515 | var ret = '' |
| 9516 | end = Math.min(buf.length, end) |
| 9517 | |
| 9518 | for (var i = start; i < end; ++i) { |
| 9519 | ret += String.fromCharCode(buf[i] & 0x7F) |
| 9520 | } |
| 9521 | return ret |
| 9522 | } |
| 9523 | |
| 9524 | function latin1Slice (buf, start, end) { |
| 9525 | var ret = '' |
| 9526 | end = Math.min(buf.length, end) |
| 9527 | |
| 9528 | for (var i = start; i < end; ++i) { |
| 9529 | ret += String.fromCharCode(buf[i]) |
| 9530 | } |
| 9531 | return ret |
| 9532 | } |
| 9533 | |
| 9534 | function hexSlice (buf, start, end) { |
| 9535 | var len = buf.length |
| 9536 | |
| 9537 | if (!start || start < 0) start = 0 |
| 9538 | if (!end || end < 0 || end > len) end = len |
| 9539 | |
| 9540 | var out = '' |
| 9541 | for (var i = start; i < end; ++i) { |
| 9542 | out += toHex(buf[i]) |
| 9543 | } |
| 9544 | return out |
| 9545 | } |
| 9546 | |
| 9547 | function utf16leSlice (buf, start, end) { |
| 9548 | var bytes = buf.slice(start, end) |
| 9549 | var res = '' |
| 9550 | for (var i = 0; i < bytes.length; i += 2) { |
| 9551 | res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) |
| 9552 | } |
| 9553 | return res |
| 9554 | } |
| 9555 | |
| 9556 | Buffer.prototype.slice = function slice (start, end) { |
| 9557 | var len = this.length |
| 9558 | start = ~~start |
| 9559 | end = end === undefined ? len : ~~end |
| 9560 | |
| 9561 | if (start < 0) { |
| 9562 | start += len |
| 9563 | if (start < 0) start = 0 |
| 9564 | } else if (start > len) { |
| 9565 | start = len |
| 9566 | } |
| 9567 | |
| 9568 | if (end < 0) { |
| 9569 | end += len |
| 9570 | if (end < 0) end = 0 |
| 9571 | } else if (end > len) { |
| 9572 | end = len |
| 9573 | } |
| 9574 | |
| 9575 | if (end < start) end = start |
| 9576 | |
| 9577 | var newBuf = this.subarray(start, end) |
| 9578 | // Return an augmented `Uint8Array` instance |
| 9579 | newBuf.__proto__ = Buffer.prototype |
| 9580 | return newBuf |
| 9581 | } |
| 9582 | |
| 9583 | /* |
| 9584 | * Need to make sure that buffer isn't trying to write out of bounds. |
| 9585 | */ |
| 9586 | function checkOffset (offset, ext, length) { |
| 9587 | if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') |
| 9588 | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') |
| 9589 | } |
| 9590 | |
| 9591 | Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { |
| 9592 | offset = offset >>> 0 |
| 9593 | byteLength = byteLength >>> 0 |
| 9594 | if (!noAssert) checkOffset(offset, byteLength, this.length) |
| 9595 | |
| 9596 | var val = this[offset] |
| 9597 | var mul = 1 |
| 9598 | var i = 0 |
| 9599 | while (++i < byteLength && (mul *= 0x100)) { |
| 9600 | val += this[offset + i] * mul |
| 9601 | } |
| 9602 | |
| 9603 | return val |
| 9604 | } |
| 9605 | |
| 9606 | Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { |
| 9607 | offset = offset >>> 0 |
| 9608 | byteLength = byteLength >>> 0 |
| 9609 | if (!noAssert) { |
| 9610 | checkOffset(offset, byteLength, this.length) |
| 9611 | } |
| 9612 | |
| 9613 | var val = this[offset + --byteLength] |
| 9614 | var mul = 1 |
| 9615 | while (byteLength > 0 && (mul *= 0x100)) { |
| 9616 | val += this[offset + --byteLength] * mul |
| 9617 | } |
| 9618 | |
| 9619 | return val |
| 9620 | } |
| 9621 | |
| 9622 | Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { |
| 9623 | offset = offset >>> 0 |
| 9624 | if (!noAssert) checkOffset(offset, 1, this.length) |
| 9625 | return this[offset] |
| 9626 | } |
| 9627 | |
| 9628 | Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { |
| 9629 | offset = offset >>> 0 |
| 9630 | if (!noAssert) checkOffset(offset, 2, this.length) |
| 9631 | return this[offset] | (this[offset + 1] << 8) |
| 9632 | } |
| 9633 | |
| 9634 | Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { |
| 9635 | offset = offset >>> 0 |
| 9636 | if (!noAssert) checkOffset(offset, 2, this.length) |
| 9637 | return (this[offset] << 8) | this[offset + 1] |
| 9638 | } |
| 9639 | |
| 9640 | Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { |
| 9641 | offset = offset >>> 0 |
| 9642 | if (!noAssert) checkOffset(offset, 4, this.length) |
| 9643 | |
| 9644 | return ((this[offset]) | |
| 9645 | (this[offset + 1] << 8) | |
| 9646 | (this[offset + 2] << 16)) + |
| 9647 | (this[offset + 3] * 0x1000000) |
| 9648 | } |
| 9649 | |
| 9650 | Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { |
| 9651 | offset = offset >>> 0 |
| 9652 | if (!noAssert) checkOffset(offset, 4, this.length) |
| 9653 | |
| 9654 | return (this[offset] * 0x1000000) + |
| 9655 | ((this[offset + 1] << 16) | |
| 9656 | (this[offset + 2] << 8) | |
| 9657 | this[offset + 3]) |
| 9658 | } |
| 9659 | |
| 9660 | Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { |
| 9661 | offset = offset >>> 0 |
| 9662 | byteLength = byteLength >>> 0 |
| 9663 | if (!noAssert) checkOffset(offset, byteLength, this.length) |
| 9664 | |
| 9665 | var val = this[offset] |
| 9666 | var mul = 1 |
| 9667 | var i = 0 |
| 9668 | while (++i < byteLength && (mul *= 0x100)) { |
| 9669 | val += this[offset + i] * mul |
| 9670 | } |
| 9671 | mul *= 0x80 |
| 9672 | |
| 9673 | if (val >= mul) val -= Math.pow(2, 8 * byteLength) |
| 9674 | |
| 9675 | return val |
| 9676 | } |
| 9677 | |
| 9678 | Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { |
| 9679 | offset = offset >>> 0 |
| 9680 | byteLength = byteLength >>> 0 |
| 9681 | if (!noAssert) checkOffset(offset, byteLength, this.length) |
| 9682 | |
| 9683 | var i = byteLength |
| 9684 | var mul = 1 |
| 9685 | var val = this[offset + --i] |
| 9686 | while (i > 0 && (mul *= 0x100)) { |
| 9687 | val += this[offset + --i] * mul |
| 9688 | } |
| 9689 | mul *= 0x80 |
| 9690 | |
| 9691 | if (val >= mul) val -= Math.pow(2, 8 * byteLength) |
| 9692 | |
| 9693 | return val |
| 9694 | } |
| 9695 | |
| 9696 | Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { |
| 9697 | offset = offset >>> 0 |
| 9698 | if (!noAssert) checkOffset(offset, 1, this.length) |
| 9699 | if (!(this[offset] & 0x80)) return (this[offset]) |
| 9700 | return ((0xff - this[offset] + 1) * -1) |
| 9701 | } |
| 9702 | |
| 9703 | Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { |
| 9704 | offset = offset >>> 0 |
| 9705 | if (!noAssert) checkOffset(offset, 2, this.length) |
| 9706 | var val = this[offset] | (this[offset + 1] << 8) |
| 9707 | return (val & 0x8000) ? val | 0xFFFF0000 : val |
| 9708 | } |
| 9709 | |
| 9710 | Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { |
| 9711 | offset = offset >>> 0 |
| 9712 | if (!noAssert) checkOffset(offset, 2, this.length) |
| 9713 | var val = this[offset + 1] | (this[offset] << 8) |
| 9714 | return (val & 0x8000) ? val | 0xFFFF0000 : val |
| 9715 | } |
| 9716 | |
| 9717 | Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { |
| 9718 | offset = offset >>> 0 |
| 9719 | if (!noAssert) checkOffset(offset, 4, this.length) |
| 9720 | |
| 9721 | return (this[offset]) | |
| 9722 | (this[offset + 1] << 8) | |
| 9723 | (this[offset + 2] << 16) | |
| 9724 | (this[offset + 3] << 24) |
| 9725 | } |
| 9726 | |
| 9727 | Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { |
| 9728 | offset = offset >>> 0 |
| 9729 | if (!noAssert) checkOffset(offset, 4, this.length) |
| 9730 | |
| 9731 | return (this[offset] << 24) | |
| 9732 | (this[offset + 1] << 16) | |
| 9733 | (this[offset + 2] << 8) | |
| 9734 | (this[offset + 3]) |
| 9735 | } |
| 9736 | |
| 9737 | Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { |
| 9738 | offset = offset >>> 0 |
| 9739 | if (!noAssert) checkOffset(offset, 4, this.length) |
| 9740 | return ieee754.read(this, offset, true, 23, 4) |
| 9741 | } |
| 9742 | |
| 9743 | Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { |
| 9744 | offset = offset >>> 0 |
| 9745 | if (!noAssert) checkOffset(offset, 4, this.length) |
| 9746 | return ieee754.read(this, offset, false, 23, 4) |
| 9747 | } |
| 9748 | |
| 9749 | Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { |
| 9750 | offset = offset >>> 0 |
| 9751 | if (!noAssert) checkOffset(offset, 8, this.length) |
| 9752 | return ieee754.read(this, offset, true, 52, 8) |
| 9753 | } |
| 9754 | |
| 9755 | Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { |
| 9756 | offset = offset >>> 0 |
| 9757 | if (!noAssert) checkOffset(offset, 8, this.length) |
| 9758 | return ieee754.read(this, offset, false, 52, 8) |
| 9759 | } |
| 9760 | |
| 9761 | function checkInt (buf, value, offset, ext, max, min) { |
| 9762 | if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') |
| 9763 | if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') |
| 9764 | if (offset + ext > buf.length) throw new RangeError('Index out of range') |
| 9765 | } |
| 9766 | |
| 9767 | Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { |
| 9768 | value = +value |
| 9769 | offset = offset >>> 0 |
| 9770 | byteLength = byteLength >>> 0 |
| 9771 | if (!noAssert) { |
| 9772 | var maxBytes = Math.pow(2, 8 * byteLength) - 1 |
| 9773 | checkInt(this, value, offset, byteLength, maxBytes, 0) |
| 9774 | } |
| 9775 | |
| 9776 | var mul = 1 |
| 9777 | var i = 0 |
| 9778 | this[offset] = value & 0xFF |
| 9779 | while (++i < byteLength && (mul *= 0x100)) { |
| 9780 | this[offset + i] = (value / mul) & 0xFF |
| 9781 | } |
| 9782 | |
| 9783 | return offset + byteLength |
| 9784 | } |
| 9785 | |
| 9786 | Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { |
| 9787 | value = +value |
| 9788 | offset = offset >>> 0 |
| 9789 | byteLength = byteLength >>> 0 |
| 9790 | if (!noAssert) { |
| 9791 | var maxBytes = Math.pow(2, 8 * byteLength) - 1 |
| 9792 | checkInt(this, value, offset, byteLength, maxBytes, 0) |
| 9793 | } |
| 9794 | |
| 9795 | var i = byteLength - 1 |
| 9796 | var mul = 1 |
| 9797 | this[offset + i] = value & 0xFF |
| 9798 | while (--i >= 0 && (mul *= 0x100)) { |
| 9799 | this[offset + i] = (value / mul) & 0xFF |
| 9800 | } |
| 9801 | |
| 9802 | return offset + byteLength |
| 9803 | } |
| 9804 | |
| 9805 | Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { |
| 9806 | value = +value |
| 9807 | offset = offset >>> 0 |
| 9808 | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) |
| 9809 | this[offset] = (value & 0xff) |
| 9810 | return offset + 1 |
| 9811 | } |
| 9812 | |
| 9813 | Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { |
| 9814 | value = +value |
| 9815 | offset = offset >>> 0 |
| 9816 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) |
| 9817 | this[offset] = (value & 0xff) |
| 9818 | this[offset + 1] = (value >>> 8) |
| 9819 | return offset + 2 |
| 9820 | } |
| 9821 | |
| 9822 | Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { |
| 9823 | value = +value |
| 9824 | offset = offset >>> 0 |
| 9825 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) |
| 9826 | this[offset] = (value >>> 8) |
| 9827 | this[offset + 1] = (value & 0xff) |
| 9828 | return offset + 2 |
| 9829 | } |
| 9830 | |
| 9831 | Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { |
| 9832 | value = +value |
| 9833 | offset = offset >>> 0 |
| 9834 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) |
| 9835 | this[offset + 3] = (value >>> 24) |
| 9836 | this[offset + 2] = (value >>> 16) |
| 9837 | this[offset + 1] = (value >>> 8) |
| 9838 | this[offset] = (value & 0xff) |
| 9839 | return offset + 4 |
| 9840 | } |
| 9841 | |
| 9842 | Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { |
| 9843 | value = +value |
| 9844 | offset = offset >>> 0 |
| 9845 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) |
| 9846 | this[offset] = (value >>> 24) |
| 9847 | this[offset + 1] = (value >>> 16) |
| 9848 | this[offset + 2] = (value >>> 8) |
| 9849 | this[offset + 3] = (value & 0xff) |
| 9850 | return offset + 4 |
| 9851 | } |
| 9852 | |
| 9853 | Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { |
| 9854 | value = +value |
| 9855 | offset = offset >>> 0 |
| 9856 | if (!noAssert) { |
| 9857 | var limit = Math.pow(2, (8 * byteLength) - 1) |
| 9858 | |
| 9859 | checkInt(this, value, offset, byteLength, limit - 1, -limit) |
| 9860 | } |
| 9861 | |
| 9862 | var i = 0 |
| 9863 | var mul = 1 |
| 9864 | var sub = 0 |
| 9865 | this[offset] = value & 0xFF |
| 9866 | while (++i < byteLength && (mul *= 0x100)) { |
| 9867 | if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { |
| 9868 | sub = 1 |
| 9869 | } |
| 9870 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF |
| 9871 | } |
| 9872 | |
| 9873 | return offset + byteLength |
| 9874 | } |
| 9875 | |
| 9876 | Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { |
| 9877 | value = +value |
| 9878 | offset = offset >>> 0 |
| 9879 | if (!noAssert) { |
| 9880 | var limit = Math.pow(2, (8 * byteLength) - 1) |
| 9881 | |
| 9882 | checkInt(this, value, offset, byteLength, limit - 1, -limit) |
| 9883 | } |
| 9884 | |
| 9885 | var i = byteLength - 1 |
| 9886 | var mul = 1 |
| 9887 | var sub = 0 |
| 9888 | this[offset + i] = value & 0xFF |
| 9889 | while (--i >= 0 && (mul *= 0x100)) { |
| 9890 | if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { |
| 9891 | sub = 1 |
| 9892 | } |
| 9893 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF |
| 9894 | } |
| 9895 | |
| 9896 | return offset + byteLength |
| 9897 | } |
| 9898 | |
| 9899 | Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { |
| 9900 | value = +value |
| 9901 | offset = offset >>> 0 |
| 9902 | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) |
| 9903 | if (value < 0) value = 0xff + value + 1 |
| 9904 | this[offset] = (value & 0xff) |
| 9905 | return offset + 1 |
| 9906 | } |
| 9907 | |
| 9908 | Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { |
| 9909 | value = +value |
| 9910 | offset = offset >>> 0 |
| 9911 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) |
| 9912 | this[offset] = (value & 0xff) |
| 9913 | this[offset + 1] = (value >>> 8) |
| 9914 | return offset + 2 |
| 9915 | } |
| 9916 | |
| 9917 | Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { |
| 9918 | value = +value |
| 9919 | offset = offset >>> 0 |
| 9920 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) |
| 9921 | this[offset] = (value >>> 8) |
| 9922 | this[offset + 1] = (value & 0xff) |
| 9923 | return offset + 2 |
| 9924 | } |
| 9925 | |
| 9926 | Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { |
| 9927 | value = +value |
| 9928 | offset = offset >>> 0 |
| 9929 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) |
| 9930 | this[offset] = (value & 0xff) |
| 9931 | this[offset + 1] = (value >>> 8) |
| 9932 | this[offset + 2] = (value >>> 16) |
| 9933 | this[offset + 3] = (value >>> 24) |
| 9934 | return offset + 4 |
| 9935 | } |
| 9936 | |
| 9937 | Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { |
| 9938 | value = +value |
| 9939 | offset = offset >>> 0 |
| 9940 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) |
| 9941 | if (value < 0) value = 0xffffffff + value + 1 |
| 9942 | this[offset] = (value >>> 24) |
| 9943 | this[offset + 1] = (value >>> 16) |
| 9944 | this[offset + 2] = (value >>> 8) |
| 9945 | this[offset + 3] = (value & 0xff) |
| 9946 | return offset + 4 |
| 9947 | } |
| 9948 | |
| 9949 | function checkIEEE754 (buf, value, offset, ext, max, min) { |
| 9950 | if (offset + ext > buf.length) throw new RangeError('Index out of range') |
| 9951 | if (offset < 0) throw new RangeError('Index out of range') |
| 9952 | } |
| 9953 | |
| 9954 | function writeFloat (buf, value, offset, littleEndian, noAssert) { |
| 9955 | value = +value |
| 9956 | offset = offset >>> 0 |
| 9957 | if (!noAssert) { |
| 9958 | checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) |
| 9959 | } |
| 9960 | ieee754.write(buf, value, offset, littleEndian, 23, 4) |
| 9961 | return offset + 4 |
| 9962 | } |
| 9963 | |
| 9964 | Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { |
| 9965 | return writeFloat(this, value, offset, true, noAssert) |
| 9966 | } |
| 9967 | |
| 9968 | Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { |
| 9969 | return writeFloat(this, value, offset, false, noAssert) |
| 9970 | } |
| 9971 | |
| 9972 | function writeDouble (buf, value, offset, littleEndian, noAssert) { |
| 9973 | value = +value |
| 9974 | offset = offset >>> 0 |
| 9975 | if (!noAssert) { |
| 9976 | checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) |
| 9977 | } |
| 9978 | ieee754.write(buf, value, offset, littleEndian, 52, 8) |
| 9979 | return offset + 8 |
| 9980 | } |
| 9981 | |
| 9982 | Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { |
| 9983 | return writeDouble(this, value, offset, true, noAssert) |
| 9984 | } |
| 9985 | |
| 9986 | Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { |
| 9987 | return writeDouble(this, value, offset, false, noAssert) |
| 9988 | } |
| 9989 | |
| 9990 | // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) |
| 9991 | Buffer.prototype.copy = function copy (target, targetStart, start, end) { |
| 9992 | if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') |
| 9993 | if (!start) start = 0 |
| 9994 | if (!end && end !== 0) end = this.length |
| 9995 | if (targetStart >= target.length) targetStart = target.length |
| 9996 | if (!targetStart) targetStart = 0 |
| 9997 | if (end > 0 && end < start) end = start |
| 9998 | |
| 9999 | // Copy 0 bytes; we're done |
| 10000 | if (end === start) return 0 |
| 10001 | if (target.length === 0 || this.length === 0) return 0 |
| 10002 | |
| 10003 | // Fatal error conditions |
| 10004 | if (targetStart < 0) { |
| 10005 | throw new RangeError('targetStart out of bounds') |
| 10006 | } |
| 10007 | if (start < 0 || start >= this.length) throw new RangeError('Index out of range') |
| 10008 | if (end < 0) throw new RangeError('sourceEnd out of bounds') |
| 10009 | |
| 10010 | // Are we oob? |
| 10011 | if (end > this.length) end = this.length |
| 10012 | if (target.length - targetStart < end - start) { |
| 10013 | end = target.length - targetStart + start |
| 10014 | } |
| 10015 | |
| 10016 | var len = end - start |
| 10017 | |
| 10018 | if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { |
| 10019 | // Use built-in when available, missing from IE11 |
| 10020 | this.copyWithin(targetStart, start, end) |
| 10021 | } else if (this === target && start < targetStart && targetStart < end) { |
| 10022 | // descending copy from end |
| 10023 | for (var i = len - 1; i >= 0; --i) { |
| 10024 | target[i + targetStart] = this[i + start] |
| 10025 | } |
| 10026 | } else { |
| 10027 | Uint8Array.prototype.set.call( |
| 10028 | target, |
| 10029 | this.subarray(start, end), |
| 10030 | targetStart |
| 10031 | ) |
| 10032 | } |
| 10033 | |
| 10034 | return len |
| 10035 | } |
| 10036 | |
| 10037 | // Usage: |
| 10038 | // buffer.fill(number[, offset[, end]]) |
| 10039 | // buffer.fill(buffer[, offset[, end]]) |
| 10040 | // buffer.fill(string[, offset[, end]][, encoding]) |
| 10041 | Buffer.prototype.fill = function fill (val, start, end, encoding) { |
| 10042 | // Handle string cases: |
| 10043 | if (typeof val === 'string') { |
| 10044 | if (typeof start === 'string') { |
| 10045 | encoding = start |
| 10046 | start = 0 |
| 10047 | end = this.length |
| 10048 | } else if (typeof end === 'string') { |
| 10049 | encoding = end |
| 10050 | end = this.length |
| 10051 | } |
| 10052 | if (encoding !== undefined && typeof encoding !== 'string') { |
| 10053 | throw new TypeError('encoding must be a string') |
| 10054 | } |
| 10055 | if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { |
| 10056 | throw new TypeError('Unknown encoding: ' + encoding) |
| 10057 | } |
| 10058 | if (val.length === 1) { |
| 10059 | var code = val.charCodeAt(0) |
| 10060 | if ((encoding === 'utf8' && code < 128) || |
| 10061 | encoding === 'latin1') { |
| 10062 | // Fast path: If `val` fits into a single byte, use that numeric value. |
| 10063 | val = code |
| 10064 | } |
| 10065 | } |
| 10066 | } else if (typeof val === 'number') { |
| 10067 | val = val & 255 |
| 10068 | } |
| 10069 | |
| 10070 | // Invalid ranges are not set to a default, so can range check early. |
| 10071 | if (start < 0 || this.length < start || this.length < end) { |
| 10072 | throw new RangeError('Out of range index') |
| 10073 | } |
| 10074 | |
| 10075 | if (end <= start) { |
| 10076 | return this |
| 10077 | } |
| 10078 | |
| 10079 | start = start >>> 0 |
| 10080 | end = end === undefined ? this.length : end >>> 0 |
| 10081 | |
| 10082 | if (!val) val = 0 |
| 10083 | |
| 10084 | var i |
| 10085 | if (typeof val === 'number') { |
| 10086 | for (i = start; i < end; ++i) { |
| 10087 | this[i] = val |
| 10088 | } |
| 10089 | } else { |
| 10090 | var bytes = Buffer.isBuffer(val) |
| 10091 | ? val |
| 10092 | : Buffer.from(val, encoding) |
| 10093 | var len = bytes.length |
| 10094 | if (len === 0) { |
| 10095 | throw new TypeError('The value "' + val + |
| 10096 | '" is invalid for argument "value"') |
| 10097 | } |
| 10098 | for (i = 0; i < end - start; ++i) { |
| 10099 | this[i + start] = bytes[i % len] |
| 10100 | } |
| 10101 | } |
| 10102 | |
| 10103 | return this |
| 10104 | } |
| 10105 | |
| 10106 | // HELPER FUNCTIONS |
| 10107 | // ================ |
| 10108 | |
| 10109 | var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g |
| 10110 | |
| 10111 | function base64clean (str) { |
| 10112 | // Node takes equal signs as end of the Base64 encoding |
| 10113 | str = str.split('=')[0] |
| 10114 | // Node strips out invalid characters like \n and \t from the string, base64-js does not |
| 10115 | str = str.trim().replace(INVALID_BASE64_RE, '') |
| 10116 | // Node converts strings with length < 2 to '' |
| 10117 | if (str.length < 2) return '' |
| 10118 | // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not |
| 10119 | while (str.length % 4 !== 0) { |
| 10120 | str = str + '=' |
| 10121 | } |
| 10122 | return str |
| 10123 | } |
| 10124 | |
| 10125 | function toHex (n) { |
| 10126 | if (n < 16) return '0' + n.toString(16) |
| 10127 | return n.toString(16) |
| 10128 | } |
| 10129 | |
| 10130 | function utf8ToBytes (string, units) { |
| 10131 | units = units || Infinity |
| 10132 | var codePoint |
| 10133 | var length = string.length |
| 10134 | var leadSurrogate = null |
| 10135 | var bytes = [] |
| 10136 | |
| 10137 | for (var i = 0; i < length; ++i) { |
| 10138 | codePoint = string.charCodeAt(i) |
| 10139 | |
| 10140 | // is surrogate component |
| 10141 | if (codePoint > 0xD7FF && codePoint < 0xE000) { |
| 10142 | // last char was a lead |
| 10143 | if (!leadSurrogate) { |
| 10144 | // no lead yet |
| 10145 | if (codePoint > 0xDBFF) { |
| 10146 | // unexpected trail |
| 10147 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) |
| 10148 | continue |
| 10149 | } else if (i + 1 === length) { |
| 10150 | // unpaired lead |
| 10151 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) |
| 10152 | continue |
| 10153 | } |
| 10154 | |
| 10155 | // valid lead |
| 10156 | leadSurrogate = codePoint |
| 10157 | |
| 10158 | continue |
| 10159 | } |
| 10160 | |
| 10161 | // 2 leads in a row |
| 10162 | if (codePoint < 0xDC00) { |
| 10163 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) |
| 10164 | leadSurrogate = codePoint |
| 10165 | continue |
| 10166 | } |
| 10167 | |
| 10168 | // valid surrogate pair |
| 10169 | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 |
| 10170 | } else if (leadSurrogate) { |
| 10171 | // valid bmp char, but last char was a lead |
| 10172 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) |
| 10173 | } |
| 10174 | |
| 10175 | leadSurrogate = null |
| 10176 | |
| 10177 | // encode utf8 |
| 10178 | if (codePoint < 0x80) { |
| 10179 | if ((units -= 1) < 0) break |
| 10180 | bytes.push(codePoint) |
| 10181 | } else if (codePoint < 0x800) { |
| 10182 | if ((units -= 2) < 0) break |
| 10183 | bytes.push( |
| 10184 | codePoint >> 0x6 | 0xC0, |
| 10185 | codePoint & 0x3F | 0x80 |
| 10186 | ) |
| 10187 | } else if (codePoint < 0x10000) { |
| 10188 | if ((units -= 3) < 0) break |
| 10189 | bytes.push( |
| 10190 | codePoint >> 0xC | 0xE0, |
| 10191 | codePoint >> 0x6 & 0x3F | 0x80, |
| 10192 | codePoint & 0x3F | 0x80 |
| 10193 | ) |
| 10194 | } else if (codePoint < 0x110000) { |
| 10195 | if ((units -= 4) < 0) break |
| 10196 | bytes.push( |
| 10197 | codePoint >> 0x12 | 0xF0, |
| 10198 | codePoint >> 0xC & 0x3F | 0x80, |
| 10199 | codePoint >> 0x6 & 0x3F | 0x80, |
| 10200 | codePoint & 0x3F | 0x80 |
| 10201 | ) |
| 10202 | } else { |
| 10203 | throw new Error('Invalid code point') |
| 10204 | } |
| 10205 | } |
| 10206 | |
| 10207 | return bytes |
| 10208 | } |
| 10209 | |
| 10210 | function asciiToBytes (str) { |
| 10211 | var byteArray = [] |
| 10212 | for (var i = 0; i < str.length; ++i) { |
| 10213 | // Node's code seems to be doing this and not & 0x7F.. |
| 10214 | byteArray.push(str.charCodeAt(i) & 0xFF) |
| 10215 | } |
| 10216 | return byteArray |
| 10217 | } |
| 10218 | |
| 10219 | function utf16leToBytes (str, units) { |
| 10220 | var c, hi, lo |
| 10221 | var byteArray = [] |
| 10222 | for (var i = 0; i < str.length; ++i) { |
| 10223 | if ((units -= 2) < 0) break |
| 10224 | |
| 10225 | c = str.charCodeAt(i) |
| 10226 | hi = c >> 8 |
| 10227 | lo = c % 256 |
| 10228 | byteArray.push(lo) |
| 10229 | byteArray.push(hi) |
| 10230 | } |
| 10231 | |
| 10232 | return byteArray |
| 10233 | } |
| 10234 | |
| 10235 | function base64ToBytes (str) { |
| 10236 | return base64.toByteArray(base64clean(str)) |
| 10237 | } |
| 10238 | |
| 10239 | function blitBuffer (src, dst, offset, length) { |
| 10240 | for (var i = 0; i < length; ++i) { |
| 10241 | if ((i + offset >= dst.length) || (i >= src.length)) break |
| 10242 | dst[i + offset] = src[i] |
| 10243 | } |
| 10244 | return i |
| 10245 | } |
| 10246 | |
| 10247 | // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass |
| 10248 | // the `instanceof` check but they should be treated as of that type. |
| 10249 | // See: https://github.com/feross/buffer/issues/166 |
| 10250 | function isInstance (obj, type) { |
| 10251 | return obj instanceof type || |
| 10252 | (obj != null && obj.constructor != null && obj.constructor.name != null && |
| 10253 | obj.constructor.name === type.name) |
| 10254 | } |
| 10255 | function numberIsNaN (obj) { |
| 10256 | // For IE11 support |
| 10257 | return obj !== obj // eslint-disable-line no-self-compare |
| 10258 | } |
| 10259 | |
| 10260 | }).call(this,require("buffer").Buffer) |
| 10261 | },{"base64-js":39,"buffer":43,"ieee754":55}],44:[function(require,module,exports){ |
| 10262 | (function (Buffer){ |
| 10263 | // Copyright Joyent, Inc. and other Node contributors. |
| 10264 | // |
| 10265 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 10266 | // copy of this software and associated documentation files (the |
| 10267 | // "Software"), to deal in the Software without restriction, including |
| 10268 | // without limitation the rights to use, copy, modify, merge, publish, |
| 10269 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 10270 | // persons to whom the Software is furnished to do so, subject to the |
| 10271 | // following conditions: |
| 10272 | // |
| 10273 | // The above copyright notice and this permission notice shall be included |
| 10274 | // in all copies or substantial portions of the Software. |
| 10275 | // |
| 10276 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 10277 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 10278 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 10279 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 10280 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 10281 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 10282 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 10283 | |
| 10284 | // NOTE: These type checking functions intentionally don't use `instanceof` |
| 10285 | // because it is fragile and can be easily faked with `Object.create()`. |
| 10286 | |
| 10287 | function isArray(arg) { |
| 10288 | if (Array.isArray) { |
| 10289 | return Array.isArray(arg); |
| 10290 | } |
| 10291 | return objectToString(arg) === '[object Array]'; |
| 10292 | } |
| 10293 | exports.isArray = isArray; |
| 10294 | |
| 10295 | function isBoolean(arg) { |
| 10296 | return typeof arg === 'boolean'; |
| 10297 | } |
| 10298 | exports.isBoolean = isBoolean; |
| 10299 | |
| 10300 | function isNull(arg) { |
| 10301 | return arg === null; |
| 10302 | } |
| 10303 | exports.isNull = isNull; |
| 10304 | |
| 10305 | function isNullOrUndefined(arg) { |
| 10306 | return arg == null; |
| 10307 | } |
| 10308 | exports.isNullOrUndefined = isNullOrUndefined; |
| 10309 | |
| 10310 | function isNumber(arg) { |
| 10311 | return typeof arg === 'number'; |
| 10312 | } |
| 10313 | exports.isNumber = isNumber; |
| 10314 | |
| 10315 | function isString(arg) { |
| 10316 | return typeof arg === 'string'; |
| 10317 | } |
| 10318 | exports.isString = isString; |
| 10319 | |
| 10320 | function isSymbol(arg) { |
| 10321 | return typeof arg === 'symbol'; |
| 10322 | } |
| 10323 | exports.isSymbol = isSymbol; |
| 10324 | |
| 10325 | function isUndefined(arg) { |
| 10326 | return arg === void 0; |
| 10327 | } |
| 10328 | exports.isUndefined = isUndefined; |
| 10329 | |
| 10330 | function isRegExp(re) { |
| 10331 | return objectToString(re) === '[object RegExp]'; |
| 10332 | } |
| 10333 | exports.isRegExp = isRegExp; |
| 10334 | |
| 10335 | function isObject(arg) { |
| 10336 | return typeof arg === 'object' && arg !== null; |
| 10337 | } |
| 10338 | exports.isObject = isObject; |
| 10339 | |
| 10340 | function isDate(d) { |
| 10341 | return objectToString(d) === '[object Date]'; |
| 10342 | } |
| 10343 | exports.isDate = isDate; |
| 10344 | |
| 10345 | function isError(e) { |
| 10346 | return (objectToString(e) === '[object Error]' || e instanceof Error); |
| 10347 | } |
| 10348 | exports.isError = isError; |
| 10349 | |
| 10350 | function isFunction(arg) { |
| 10351 | return typeof arg === 'function'; |
| 10352 | } |
| 10353 | exports.isFunction = isFunction; |
| 10354 | |
| 10355 | function isPrimitive(arg) { |
| 10356 | return arg === null || |
| 10357 | typeof arg === 'boolean' || |
| 10358 | typeof arg === 'number' || |
| 10359 | typeof arg === 'string' || |
| 10360 | typeof arg === 'symbol' || // ES6 symbol |
| 10361 | typeof arg === 'undefined'; |
| 10362 | } |
| 10363 | exports.isPrimitive = isPrimitive; |
| 10364 | |
| 10365 | exports.isBuffer = Buffer.isBuffer; |
| 10366 | |
| 10367 | function objectToString(o) { |
| 10368 | return Object.prototype.toString.call(o); |
| 10369 | } |
| 10370 | |
| 10371 | }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) |
| 10372 | },{"../../is-buffer/index.js":57}],45:[function(require,module,exports){ |
| 10373 | (function (process){ |
| 10374 | "use strict"; |
| 10375 | |
| 10376 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } |
| 10377 | |
| 10378 | /* eslint-env browser */ |
| 10379 | |
| 10380 | /** |
| 10381 | * This is the web browser implementation of `debug()`. |
| 10382 | */ |
| 10383 | exports.log = log; |
| 10384 | exports.formatArgs = formatArgs; |
| 10385 | exports.save = save; |
| 10386 | exports.load = load; |
| 10387 | exports.useColors = useColors; |
| 10388 | exports.storage = localstorage(); |
| 10389 | /** |
| 10390 | * Colors. |
| 10391 | */ |
| 10392 | |
| 10393 | 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']; |
| 10394 | /** |
| 10395 | * Currently only WebKit-based Web Inspectors, Firefox >= v31, |
| 10396 | * and the Firebug extension (any Firefox version) are known |
| 10397 | * to support "%c" CSS customizations. |
| 10398 | * |
| 10399 | * TODO: add a `localStorage` variable to explicitly enable/disable colors |
| 10400 | */ |
| 10401 | // eslint-disable-next-line complexity |
| 10402 | |
| 10403 | function useColors() { |
| 10404 | // NB: In an Electron preload script, document will be defined but not fully |
| 10405 | // initialized. Since we know we're in Chrome, we'll just detect this case |
| 10406 | // explicitly |
| 10407 | if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { |
| 10408 | return true; |
| 10409 | } // Internet Explorer and Edge do not support colors. |
| 10410 | |
| 10411 | |
| 10412 | if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { |
| 10413 | return false; |
| 10414 | } // Is webkit? http://stackoverflow.com/a/16459606/376773 |
| 10415 | // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 |
| 10416 | |
| 10417 | |
| 10418 | return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 |
| 10419 | typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? |
| 10420 | // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages |
| 10421 | 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 |
| 10422 | typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); |
| 10423 | } |
| 10424 | /** |
| 10425 | * Colorize log arguments if enabled. |
| 10426 | * |
| 10427 | * @api public |
| 10428 | */ |
| 10429 | |
| 10430 | |
| 10431 | function formatArgs(args) { |
| 10432 | args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); |
| 10433 | |
| 10434 | if (!this.useColors) { |
| 10435 | return; |
| 10436 | } |
| 10437 | |
| 10438 | var c = 'color: ' + this.color; |
| 10439 | args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other |
| 10440 | // arguments passed either before or after the %c, so we need to |
| 10441 | // figure out the correct index to insert the CSS into |
| 10442 | |
| 10443 | var index = 0; |
| 10444 | var lastC = 0; |
| 10445 | args[0].replace(/%[a-zA-Z%]/g, function (match) { |
| 10446 | if (match === '%%') { |
| 10447 | return; |
| 10448 | } |
| 10449 | |
| 10450 | index++; |
| 10451 | |
| 10452 | if (match === '%c') { |
| 10453 | // We only are interested in the *last* %c |
| 10454 | // (the user may have provided their own) |
| 10455 | lastC = index; |
| 10456 | } |
| 10457 | }); |
| 10458 | args.splice(lastC, 0, c); |
| 10459 | } |
| 10460 | /** |
| 10461 | * Invokes `console.log()` when available. |
| 10462 | * No-op when `console.log` is not a "function". |
| 10463 | * |
| 10464 | * @api public |
| 10465 | */ |
| 10466 | |
| 10467 | |
| 10468 | function log() { |
| 10469 | var _console; |
| 10470 | |
| 10471 | // This hackery is required for IE8/9, where |
| 10472 | // the `console.log` function doesn't have 'apply' |
| 10473 | return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments); |
| 10474 | } |
| 10475 | /** |
| 10476 | * Save `namespaces`. |
| 10477 | * |
| 10478 | * @param {String} namespaces |
| 10479 | * @api private |
| 10480 | */ |
| 10481 | |
| 10482 | |
| 10483 | function save(namespaces) { |
| 10484 | try { |
| 10485 | if (namespaces) { |
| 10486 | exports.storage.setItem('debug', namespaces); |
| 10487 | } else { |
| 10488 | exports.storage.removeItem('debug'); |
| 10489 | } |
| 10490 | } catch (error) {// Swallow |
| 10491 | // XXX (@Qix-) should we be logging these? |
| 10492 | } |
| 10493 | } |
| 10494 | /** |
| 10495 | * Load `namespaces`. |
| 10496 | * |
| 10497 | * @return {String} returns the previously persisted debug modes |
| 10498 | * @api private |
| 10499 | */ |
| 10500 | |
| 10501 | |
| 10502 | function load() { |
| 10503 | var r; |
| 10504 | |
| 10505 | try { |
| 10506 | r = exports.storage.getItem('debug'); |
| 10507 | } catch (error) {} // Swallow |
| 10508 | // XXX (@Qix-) should we be logging these? |
| 10509 | // If debug isn't set in LS, and we're in Electron, try to load $DEBUG |
| 10510 | |
| 10511 | |
| 10512 | if (!r && typeof process !== 'undefined' && 'env' in process) { |
| 10513 | r = process.env.DEBUG; |
| 10514 | } |
| 10515 | |
| 10516 | return r; |
| 10517 | } |
| 10518 | /** |
| 10519 | * Localstorage attempts to return the localstorage. |
| 10520 | * |
| 10521 | * This is necessary because safari throws |
| 10522 | * when a user disables cookies/localstorage |
| 10523 | * and you attempt to access it. |
| 10524 | * |
| 10525 | * @return {LocalStorage} |
| 10526 | * @api private |
| 10527 | */ |
| 10528 | |
| 10529 | |
| 10530 | function localstorage() { |
| 10531 | try { |
| 10532 | // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context |
| 10533 | // The Browser also has localStorage in the global context. |
| 10534 | return localStorage; |
| 10535 | } catch (error) {// Swallow |
| 10536 | // XXX (@Qix-) should we be logging these? |
| 10537 | } |
| 10538 | } |
| 10539 | |
| 10540 | module.exports = require('./common')(exports); |
| 10541 | var formatters = module.exports.formatters; |
| 10542 | /** |
| 10543 | * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. |
| 10544 | */ |
| 10545 | |
| 10546 | formatters.j = function (v) { |
| 10547 | try { |
| 10548 | return JSON.stringify(v); |
| 10549 | } catch (error) { |
| 10550 | return '[UnexpectedJSONParseError]: ' + error.message; |
| 10551 | } |
| 10552 | }; |
| 10553 | |
| 10554 | |
| 10555 | }).call(this,require('_process')) |
| 10556 | },{"./common":46,"_process":69}],46:[function(require,module,exports){ |
| 10557 | "use strict"; |
| 10558 | |
| 10559 | /** |
| 10560 | * This is the common logic for both the Node.js and web browser |
| 10561 | * implementations of `debug()`. |
| 10562 | */ |
| 10563 | function setup(env) { |
| 10564 | createDebug.debug = createDebug; |
| 10565 | createDebug.default = createDebug; |
| 10566 | createDebug.coerce = coerce; |
| 10567 | createDebug.disable = disable; |
| 10568 | createDebug.enable = enable; |
| 10569 | createDebug.enabled = enabled; |
| 10570 | createDebug.humanize = require('ms'); |
| 10571 | Object.keys(env).forEach(function (key) { |
| 10572 | createDebug[key] = env[key]; |
| 10573 | }); |
| 10574 | /** |
| 10575 | * Active `debug` instances. |
| 10576 | */ |
| 10577 | |
| 10578 | createDebug.instances = []; |
| 10579 | /** |
| 10580 | * The currently active debug mode names, and names to skip. |
| 10581 | */ |
| 10582 | |
| 10583 | createDebug.names = []; |
| 10584 | createDebug.skips = []; |
| 10585 | /** |
| 10586 | * Map of special "%n" handling functions, for the debug "format" argument. |
| 10587 | * |
| 10588 | * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". |
| 10589 | */ |
| 10590 | |
| 10591 | createDebug.formatters = {}; |
| 10592 | /** |
| 10593 | * Selects a color for a debug namespace |
| 10594 | * @param {String} namespace The namespace string for the for the debug instance to be colored |
| 10595 | * @return {Number|String} An ANSI color code for the given namespace |
| 10596 | * @api private |
| 10597 | */ |
| 10598 | |
| 10599 | function selectColor(namespace) { |
| 10600 | var hash = 0; |
| 10601 | |
| 10602 | for (var i = 0; i < namespace.length; i++) { |
| 10603 | hash = (hash << 5) - hash + namespace.charCodeAt(i); |
| 10604 | hash |= 0; // Convert to 32bit integer |
| 10605 | } |
| 10606 | |
| 10607 | return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; |
| 10608 | } |
| 10609 | |
| 10610 | createDebug.selectColor = selectColor; |
| 10611 | /** |
| 10612 | * Create a debugger with the given `namespace`. |
| 10613 | * |
| 10614 | * @param {String} namespace |
| 10615 | * @return {Function} |
| 10616 | * @api public |
| 10617 | */ |
| 10618 | |
| 10619 | function createDebug(namespace) { |
| 10620 | var prevTime; |
| 10621 | |
| 10622 | function debug() { |
| 10623 | // Disabled? |
| 10624 | if (!debug.enabled) { |
| 10625 | return; |
| 10626 | } |
| 10627 | |
| 10628 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| 10629 | args[_key] = arguments[_key]; |
| 10630 | } |
| 10631 | |
| 10632 | var self = debug; // Set `diff` timestamp |
| 10633 | |
| 10634 | var curr = Number(new Date()); |
| 10635 | var ms = curr - (prevTime || curr); |
| 10636 | self.diff = ms; |
| 10637 | self.prev = prevTime; |
| 10638 | self.curr = curr; |
| 10639 | prevTime = curr; |
| 10640 | args[0] = createDebug.coerce(args[0]); |
| 10641 | |
| 10642 | if (typeof args[0] !== 'string') { |
| 10643 | // Anything else let's inspect with %O |
| 10644 | args.unshift('%O'); |
| 10645 | } // Apply any `formatters` transformations |
| 10646 | |
| 10647 | |
| 10648 | var index = 0; |
| 10649 | args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) { |
| 10650 | // If we encounter an escaped % then don't increase the array index |
| 10651 | if (match === '%%') { |
| 10652 | return match; |
| 10653 | } |
| 10654 | |
| 10655 | index++; |
| 10656 | var formatter = createDebug.formatters[format]; |
| 10657 | |
| 10658 | if (typeof formatter === 'function') { |
| 10659 | var val = args[index]; |
| 10660 | match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format` |
| 10661 | |
| 10662 | args.splice(index, 1); |
| 10663 | index--; |
| 10664 | } |
| 10665 | |
| 10666 | return match; |
| 10667 | }); // Apply env-specific formatting (colors, etc.) |
| 10668 | |
| 10669 | createDebug.formatArgs.call(self, args); |
| 10670 | var logFn = self.log || createDebug.log; |
| 10671 | logFn.apply(self, args); |
| 10672 | } |
| 10673 | |
| 10674 | debug.namespace = namespace; |
| 10675 | debug.enabled = createDebug.enabled(namespace); |
| 10676 | debug.useColors = createDebug.useColors(); |
| 10677 | debug.color = selectColor(namespace); |
| 10678 | debug.destroy = destroy; |
| 10679 | debug.extend = extend; // Debug.formatArgs = formatArgs; |
| 10680 | // debug.rawLog = rawLog; |
| 10681 | // env-specific initialization logic for debug instances |
| 10682 | |
| 10683 | if (typeof createDebug.init === 'function') { |
| 10684 | createDebug.init(debug); |
| 10685 | } |
| 10686 | |
| 10687 | createDebug.instances.push(debug); |
| 10688 | return debug; |
| 10689 | } |
| 10690 | |
| 10691 | function destroy() { |
| 10692 | var index = createDebug.instances.indexOf(this); |
| 10693 | |
| 10694 | if (index !== -1) { |
| 10695 | createDebug.instances.splice(index, 1); |
| 10696 | return true; |
| 10697 | } |
| 10698 | |
| 10699 | return false; |
| 10700 | } |
| 10701 | |
| 10702 | function extend(namespace, delimiter) { |
| 10703 | return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); |
| 10704 | } |
| 10705 | /** |
| 10706 | * Enables a debug mode by namespaces. This can include modes |
| 10707 | * separated by a colon and wildcards. |
| 10708 | * |
| 10709 | * @param {String} namespaces |
| 10710 | * @api public |
| 10711 | */ |
| 10712 | |
| 10713 | |
| 10714 | function enable(namespaces) { |
| 10715 | createDebug.save(namespaces); |
| 10716 | createDebug.names = []; |
| 10717 | createDebug.skips = []; |
| 10718 | var i; |
| 10719 | var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); |
| 10720 | var len = split.length; |
| 10721 | |
| 10722 | for (i = 0; i < len; i++) { |
| 10723 | if (!split[i]) { |
| 10724 | // ignore empty strings |
| 10725 | continue; |
| 10726 | } |
| 10727 | |
| 10728 | namespaces = split[i].replace(/\*/g, '.*?'); |
| 10729 | |
| 10730 | if (namespaces[0] === '-') { |
| 10731 | createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); |
| 10732 | } else { |
| 10733 | createDebug.names.push(new RegExp('^' + namespaces + '$')); |
| 10734 | } |
| 10735 | } |
| 10736 | |
| 10737 | for (i = 0; i < createDebug.instances.length; i++) { |
| 10738 | var instance = createDebug.instances[i]; |
| 10739 | instance.enabled = createDebug.enabled(instance.namespace); |
| 10740 | } |
| 10741 | } |
| 10742 | /** |
| 10743 | * Disable debug output. |
| 10744 | * |
| 10745 | * @api public |
| 10746 | */ |
| 10747 | |
| 10748 | |
| 10749 | function disable() { |
| 10750 | createDebug.enable(''); |
| 10751 | } |
| 10752 | /** |
| 10753 | * Returns true if the given mode name is enabled, false otherwise. |
| 10754 | * |
| 10755 | * @param {String} name |
| 10756 | * @return {Boolean} |
| 10757 | * @api public |
| 10758 | */ |
| 10759 | |
| 10760 | |
| 10761 | function enabled(name) { |
| 10762 | if (name[name.length - 1] === '*') { |
| 10763 | return true; |
| 10764 | } |
| 10765 | |
| 10766 | var i; |
| 10767 | var len; |
| 10768 | |
| 10769 | for (i = 0, len = createDebug.skips.length; i < len; i++) { |
| 10770 | if (createDebug.skips[i].test(name)) { |
| 10771 | return false; |
| 10772 | } |
| 10773 | } |
| 10774 | |
| 10775 | for (i = 0, len = createDebug.names.length; i < len; i++) { |
| 10776 | if (createDebug.names[i].test(name)) { |
| 10777 | return true; |
| 10778 | } |
| 10779 | } |
| 10780 | |
| 10781 | return false; |
| 10782 | } |
| 10783 | /** |
| 10784 | * Coerce `val`. |
| 10785 | * |
| 10786 | * @param {Mixed} val |
| 10787 | * @return {Mixed} |
| 10788 | * @api private |
| 10789 | */ |
| 10790 | |
| 10791 | |
| 10792 | function coerce(val) { |
| 10793 | if (val instanceof Error) { |
| 10794 | return val.stack || val.message; |
| 10795 | } |
| 10796 | |
| 10797 | return val; |
| 10798 | } |
| 10799 | |
| 10800 | createDebug.enable(createDebug.load()); |
| 10801 | return createDebug; |
| 10802 | } |
| 10803 | |
| 10804 | module.exports = setup; |
| 10805 | |
| 10806 | |
| 10807 | },{"ms":60}],47:[function(require,module,exports){ |
| 10808 | 'use strict'; |
| 10809 | |
| 10810 | var keys = require('object-keys'); |
| 10811 | var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; |
| 10812 | |
| 10813 | var toStr = Object.prototype.toString; |
| 10814 | var concat = Array.prototype.concat; |
| 10815 | var origDefineProperty = Object.defineProperty; |
| 10816 | |
| 10817 | var isFunction = function (fn) { |
| 10818 | return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; |
| 10819 | }; |
| 10820 | |
| 10821 | var arePropertyDescriptorsSupported = function () { |
| 10822 | var obj = {}; |
| 10823 | try { |
| 10824 | origDefineProperty(obj, 'x', { enumerable: false, value: obj }); |
| 10825 | // eslint-disable-next-line no-unused-vars, no-restricted-syntax |
| 10826 | for (var _ in obj) { // jscs:ignore disallowUnusedVariables |
| 10827 | return false; |
| 10828 | } |
| 10829 | return obj.x === obj; |
| 10830 | } catch (e) { /* this is IE 8. */ |
| 10831 | return false; |
| 10832 | } |
| 10833 | }; |
| 10834 | var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported(); |
| 10835 | |
| 10836 | var defineProperty = function (object, name, value, predicate) { |
| 10837 | if (name in object && (!isFunction(predicate) || !predicate())) { |
| 10838 | return; |
| 10839 | } |
| 10840 | if (supportsDescriptors) { |
| 10841 | origDefineProperty(object, name, { |
| 10842 | configurable: true, |
| 10843 | enumerable: false, |
| 10844 | value: value, |
| 10845 | writable: true |
| 10846 | }); |
| 10847 | } else { |
| 10848 | object[name] = value; |
| 10849 | } |
| 10850 | }; |
| 10851 | |
| 10852 | var defineProperties = function (object, map) { |
| 10853 | var predicates = arguments.length > 2 ? arguments[2] : {}; |
| 10854 | var props = keys(map); |
| 10855 | if (hasSymbols) { |
| 10856 | props = concat.call(props, Object.getOwnPropertySymbols(map)); |
| 10857 | } |
| 10858 | for (var i = 0; i < props.length; i += 1) { |
| 10859 | defineProperty(object, props[i], map[props[i]], predicates[props[i]]); |
| 10860 | } |
| 10861 | }; |
| 10862 | |
| 10863 | defineProperties.supportsDescriptors = !!supportsDescriptors; |
| 10864 | |
| 10865 | module.exports = defineProperties; |
| 10866 | |
| 10867 | },{"object-keys":62}],48:[function(require,module,exports){ |
| 10868 | /*! |
| 10869 | |
| 10870 | diff v3.5.0 |
| 10871 | |
| 10872 | Software License Agreement (BSD License) |
| 10873 | |
| 10874 | Copyright (c) 2009-2015, Kevin Decker <[email protected]> |
| 10875 | |
| 10876 | All rights reserved. |
| 10877 | |
| 10878 | Redistribution and use of this software in source and binary forms, with or without modification, |
| 10879 | are permitted provided that the following conditions are met: |
| 10880 | |
| 10881 | * Redistributions of source code must retain the above |
| 10882 | copyright notice, this list of conditions and the |
| 10883 | following disclaimer. |
| 10884 | |
| 10885 | * Redistributions in binary form must reproduce the above |
| 10886 | copyright notice, this list of conditions and the |
| 10887 | following disclaimer in the documentation and/or other |
| 10888 | materials provided with the distribution. |
| 10889 | |
| 10890 | * Neither the name of Kevin Decker nor the names of its |
| 10891 | contributors may be used to endorse or promote products |
| 10892 | derived from this software without specific prior |
| 10893 | written permission. |
| 10894 | |
| 10895 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR |
| 10896 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 10897 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 10898 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 10899 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 10900 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 10901 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 10902 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 10903 | @license |
| 10904 | */ |
| 10905 | (function webpackUniversalModuleDefinition(root, factory) { |
| 10906 | if(typeof exports === 'object' && typeof module === 'object') |
| 10907 | module.exports = factory(); |
| 10908 | else if(false) |
| 10909 | define([], factory); |
| 10910 | else if(typeof exports === 'object') |
| 10911 | exports["JsDiff"] = factory(); |
| 10912 | else |
| 10913 | root["JsDiff"] = factory(); |
| 10914 | })(this, function() { |
| 10915 | return /******/ (function(modules) { // webpackBootstrap |
| 10916 | /******/ // The module cache |
| 10917 | /******/ var installedModules = {}; |
| 10918 | |
| 10919 | /******/ // The require function |
| 10920 | /******/ function __webpack_require__(moduleId) { |
| 10921 | |
| 10922 | /******/ // Check if module is in cache |
| 10923 | /******/ if(installedModules[moduleId]) |
| 10924 | /******/ return installedModules[moduleId].exports; |
| 10925 | |
| 10926 | /******/ // Create a new module (and put it into the cache) |
| 10927 | /******/ var module = installedModules[moduleId] = { |
| 10928 | /******/ exports: {}, |
| 10929 | /******/ id: moduleId, |
| 10930 | /******/ loaded: false |
| 10931 | /******/ }; |
| 10932 | |
| 10933 | /******/ // Execute the module function |
| 10934 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
| 10935 | |
| 10936 | /******/ // Flag the module as loaded |
| 10937 | /******/ module.loaded = true; |
| 10938 | |
| 10939 | /******/ // Return the exports of the module |
| 10940 | /******/ return module.exports; |
| 10941 | /******/ } |
| 10942 | |
| 10943 | |
| 10944 | /******/ // expose the modules object (__webpack_modules__) |
| 10945 | /******/ __webpack_require__.m = modules; |
| 10946 | |
| 10947 | /******/ // expose the module cache |
| 10948 | /******/ __webpack_require__.c = installedModules; |
| 10949 | |
| 10950 | /******/ // __webpack_public_path__ |
| 10951 | /******/ __webpack_require__.p = ""; |
| 10952 | |
| 10953 | /******/ // Load entry module and return exports |
| 10954 | /******/ return __webpack_require__(0); |
| 10955 | /******/ }) |
| 10956 | /************************************************************************/ |
| 10957 | /******/ ([ |
| 10958 | /* 0 */ |
| 10959 | /***/ (function(module, exports, __webpack_require__) { |
| 10960 | |
| 10961 | /*istanbul ignore start*/'use strict'; |
| 10962 | |
| 10963 | exports.__esModule = true; |
| 10964 | exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.merge = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined; |
| 10965 | |
| 10966 | /*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 10967 | |
| 10968 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 10969 | |
| 10970 | /*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/; |
| 10971 | |
| 10972 | var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/; |
| 10973 | |
| 10974 | var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/; |
| 10975 | |
| 10976 | var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/; |
| 10977 | |
| 10978 | var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/; |
| 10979 | |
| 10980 | var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/; |
| 10981 | |
| 10982 | var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/; |
| 10983 | |
| 10984 | var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/; |
| 10985 | |
| 10986 | var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/; |
| 10987 | |
| 10988 | var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/; |
| 10989 | |
| 10990 | var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/; |
| 10991 | |
| 10992 | var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/; |
| 10993 | |
| 10994 | var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/; |
| 10995 | |
| 10996 | /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 10997 | |
| 10998 | /* See LICENSE file for terms of use */ |
| 10999 | |
| 11000 | /* |
| 11001 | * Text diff implementation. |
| 11002 | * |
| 11003 | * This library supports the following APIS: |
| 11004 | * JsDiff.diffChars: Character by character diff |
| 11005 | * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace |
| 11006 | * JsDiff.diffLines: Line based diff |
| 11007 | * |
| 11008 | * JsDiff.diffCss: Diff targeted at CSS content |
| 11009 | * |
| 11010 | * These methods are based on the implementation proposed in |
| 11011 | * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986). |
| 11012 | * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927 |
| 11013 | */ |
| 11014 | exports. /*istanbul ignore end*/Diff = _base2['default']; |
| 11015 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars; |
| 11016 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords; |
| 11017 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace; |
| 11018 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines; |
| 11019 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines; |
| 11020 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences; |
| 11021 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss; |
| 11022 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson; |
| 11023 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays; |
| 11024 | /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch; |
| 11025 | /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch; |
| 11026 | /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch; |
| 11027 | /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch; |
| 11028 | /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches; |
| 11029 | /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch; |
| 11030 | /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge; |
| 11031 | /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP; |
| 11032 | /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML; |
| 11033 | /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize; |
| 11034 | |
| 11035 | |
| 11036 | |
| 11037 | /***/ }), |
| 11038 | /* 1 */ |
| 11039 | /***/ (function(module, exports) { |
| 11040 | |
| 11041 | /*istanbul ignore start*/'use strict'; |
| 11042 | |
| 11043 | exports.__esModule = true; |
| 11044 | exports['default'] = /*istanbul ignore end*/Diff; |
| 11045 | function Diff() {} |
| 11046 | |
| 11047 | Diff.prototype = { |
| 11048 | /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) { |
| 11049 | /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
| 11050 | |
| 11051 | var callback = options.callback; |
| 11052 | if (typeof options === 'function') { |
| 11053 | callback = options; |
| 11054 | options = {}; |
| 11055 | } |
| 11056 | this.options = options; |
| 11057 | |
| 11058 | var self = this; |
| 11059 | |
| 11060 | function done(value) { |
| 11061 | if (callback) { |
| 11062 | setTimeout(function () { |
| 11063 | callback(undefined, value); |
| 11064 | }, 0); |
| 11065 | return true; |
| 11066 | } else { |
| 11067 | return value; |
| 11068 | } |
| 11069 | } |
| 11070 | |
| 11071 | // Allow subclasses to massage the input prior to running |
| 11072 | oldString = this.castInput(oldString); |
| 11073 | newString = this.castInput(newString); |
| 11074 | |
| 11075 | oldString = this.removeEmpty(this.tokenize(oldString)); |
| 11076 | newString = this.removeEmpty(this.tokenize(newString)); |
| 11077 | |
| 11078 | var newLen = newString.length, |
| 11079 | oldLen = oldString.length; |
| 11080 | var editLength = 1; |
| 11081 | var maxEditLength = newLen + oldLen; |
| 11082 | var bestPath = [{ newPos: -1, components: [] }]; |
| 11083 | |
| 11084 | // Seed editLength = 0, i.e. the content starts with the same values |
| 11085 | var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); |
| 11086 | if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { |
| 11087 | // Identity per the equality and tokenizer |
| 11088 | return done([{ value: this.join(newString), count: newString.length }]); |
| 11089 | } |
| 11090 | |
| 11091 | // Main worker method. checks all permutations of a given edit length for acceptance. |
| 11092 | function execEditLength() { |
| 11093 | for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { |
| 11094 | var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
| 11095 | var addPath = bestPath[diagonalPath - 1], |
| 11096 | removePath = bestPath[diagonalPath + 1], |
| 11097 | _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; |
| 11098 | if (addPath) { |
| 11099 | // No one else is going to attempt to use this value, clear it |
| 11100 | bestPath[diagonalPath - 1] = undefined; |
| 11101 | } |
| 11102 | |
| 11103 | var canAdd = addPath && addPath.newPos + 1 < newLen, |
| 11104 | canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; |
| 11105 | if (!canAdd && !canRemove) { |
| 11106 | // If this path is a terminal then prune |
| 11107 | bestPath[diagonalPath] = undefined; |
| 11108 | continue; |
| 11109 | } |
| 11110 | |
| 11111 | // Select the diagonal that we want to branch from. We select the prior |
| 11112 | // path whose position in the new string is the farthest from the origin |
| 11113 | // and does not pass the bounds of the diff graph |
| 11114 | if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { |
| 11115 | basePath = clonePath(removePath); |
| 11116 | self.pushComponent(basePath.components, undefined, true); |
| 11117 | } else { |
| 11118 | basePath = addPath; // No need to clone, we've pulled it from the list |
| 11119 | basePath.newPos++; |
| 11120 | self.pushComponent(basePath.components, true, undefined); |
| 11121 | } |
| 11122 | |
| 11123 | _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); |
| 11124 | |
| 11125 | // If we have hit the end of both strings, then we are done |
| 11126 | if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { |
| 11127 | return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); |
| 11128 | } else { |
| 11129 | // Otherwise track this path as a potential candidate and continue. |
| 11130 | bestPath[diagonalPath] = basePath; |
| 11131 | } |
| 11132 | } |
| 11133 | |
| 11134 | editLength++; |
| 11135 | } |
| 11136 | |
| 11137 | // Performs the length of edit iteration. Is a bit fugly as this has to support the |
| 11138 | // sync and async mode which is never fun. Loops over execEditLength until a value |
| 11139 | // is produced. |
| 11140 | if (callback) { |
| 11141 | (function exec() { |
| 11142 | setTimeout(function () { |
| 11143 | // This should not happen, but we want to be safe. |
| 11144 | /* istanbul ignore next */ |
| 11145 | if (editLength > maxEditLength) { |
| 11146 | return callback(); |
| 11147 | } |
| 11148 | |
| 11149 | if (!execEditLength()) { |
| 11150 | exec(); |
| 11151 | } |
| 11152 | }, 0); |
| 11153 | })(); |
| 11154 | } else { |
| 11155 | while (editLength <= maxEditLength) { |
| 11156 | var ret = execEditLength(); |
| 11157 | if (ret) { |
| 11158 | return ret; |
| 11159 | } |
| 11160 | } |
| 11161 | } |
| 11162 | }, |
| 11163 | /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) { |
| 11164 | var last = components[components.length - 1]; |
| 11165 | if (last && last.added === added && last.removed === removed) { |
| 11166 | // We need to clone here as the component clone operation is just |
| 11167 | // as shallow array clone |
| 11168 | components[components.length - 1] = { count: last.count + 1, added: added, removed: removed }; |
| 11169 | } else { |
| 11170 | components.push({ count: 1, added: added, removed: removed }); |
| 11171 | } |
| 11172 | }, |
| 11173 | /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { |
| 11174 | var newLen = newString.length, |
| 11175 | oldLen = oldString.length, |
| 11176 | newPos = basePath.newPos, |
| 11177 | oldPos = newPos - diagonalPath, |
| 11178 | commonCount = 0; |
| 11179 | while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { |
| 11180 | newPos++; |
| 11181 | oldPos++; |
| 11182 | commonCount++; |
| 11183 | } |
| 11184 | |
| 11185 | if (commonCount) { |
| 11186 | basePath.components.push({ count: commonCount }); |
| 11187 | } |
| 11188 | |
| 11189 | basePath.newPos = newPos; |
| 11190 | return oldPos; |
| 11191 | }, |
| 11192 | /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) { |
| 11193 | if (this.options.comparator) { |
| 11194 | return this.options.comparator(left, right); |
| 11195 | } else { |
| 11196 | return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); |
| 11197 | } |
| 11198 | }, |
| 11199 | /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) { |
| 11200 | var ret = []; |
| 11201 | for (var i = 0; i < array.length; i++) { |
| 11202 | if (array[i]) { |
| 11203 | ret.push(array[i]); |
| 11204 | } |
| 11205 | } |
| 11206 | return ret; |
| 11207 | }, |
| 11208 | /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) { |
| 11209 | return value; |
| 11210 | }, |
| 11211 | /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) { |
| 11212 | return value.split(''); |
| 11213 | }, |
| 11214 | /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) { |
| 11215 | return chars.join(''); |
| 11216 | } |
| 11217 | }; |
| 11218 | |
| 11219 | function buildValues(diff, components, newString, oldString, useLongestToken) { |
| 11220 | var componentPos = 0, |
| 11221 | componentLen = components.length, |
| 11222 | newPos = 0, |
| 11223 | oldPos = 0; |
| 11224 | |
| 11225 | for (; componentPos < componentLen; componentPos++) { |
| 11226 | var component = components[componentPos]; |
| 11227 | if (!component.removed) { |
| 11228 | if (!component.added && useLongestToken) { |
| 11229 | var value = newString.slice(newPos, newPos + component.count); |
| 11230 | value = value.map(function (value, i) { |
| 11231 | var oldValue = oldString[oldPos + i]; |
| 11232 | return oldValue.length > value.length ? oldValue : value; |
| 11233 | }); |
| 11234 | |
| 11235 | component.value = diff.join(value); |
| 11236 | } else { |
| 11237 | component.value = diff.join(newString.slice(newPos, newPos + component.count)); |
| 11238 | } |
| 11239 | newPos += component.count; |
| 11240 | |
| 11241 | // Common case |
| 11242 | if (!component.added) { |
| 11243 | oldPos += component.count; |
| 11244 | } |
| 11245 | } else { |
| 11246 | component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); |
| 11247 | oldPos += component.count; |
| 11248 | |
| 11249 | // Reverse add and remove so removes are output first to match common convention |
| 11250 | // The diffing algorithm is tied to add then remove output and this is the simplest |
| 11251 | // route to get the desired output with minimal overhead. |
| 11252 | if (componentPos && components[componentPos - 1].added) { |
| 11253 | var tmp = components[componentPos - 1]; |
| 11254 | components[componentPos - 1] = components[componentPos]; |
| 11255 | components[componentPos] = tmp; |
| 11256 | } |
| 11257 | } |
| 11258 | } |
| 11259 | |
| 11260 | // Special case handle for when one terminal is ignored (i.e. whitespace). |
| 11261 | // For this case we merge the terminal into the prior string and drop the change. |
| 11262 | // This is only available for string mode. |
| 11263 | var lastComponent = components[componentLen - 1]; |
| 11264 | if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { |
| 11265 | components[componentLen - 2].value += lastComponent.value; |
| 11266 | components.pop(); |
| 11267 | } |
| 11268 | |
| 11269 | return components; |
| 11270 | } |
| 11271 | |
| 11272 | function clonePath(path) { |
| 11273 | return { newPos: path.newPos, components: path.components.slice(0) }; |
| 11274 | } |
| 11275 | |
| 11276 | |
| 11277 | |
| 11278 | /***/ }), |
| 11279 | /* 2 */ |
| 11280 | /***/ (function(module, exports, __webpack_require__) { |
| 11281 | |
| 11282 | /*istanbul ignore start*/'use strict'; |
| 11283 | |
| 11284 | exports.__esModule = true; |
| 11285 | exports.characterDiff = undefined; |
| 11286 | exports. /*istanbul ignore end*/diffChars = diffChars; |
| 11287 | |
| 11288 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11289 | |
| 11290 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11291 | |
| 11292 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11293 | |
| 11294 | /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11295 | function diffChars(oldStr, newStr, options) { |
| 11296 | return characterDiff.diff(oldStr, newStr, options); |
| 11297 | } |
| 11298 | |
| 11299 | |
| 11300 | |
| 11301 | /***/ }), |
| 11302 | /* 3 */ |
| 11303 | /***/ (function(module, exports, __webpack_require__) { |
| 11304 | |
| 11305 | /*istanbul ignore start*/'use strict'; |
| 11306 | |
| 11307 | exports.__esModule = true; |
| 11308 | exports.wordDiff = undefined; |
| 11309 | exports. /*istanbul ignore end*/diffWords = diffWords; |
| 11310 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace; |
| 11311 | |
| 11312 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11313 | |
| 11314 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11315 | |
| 11316 | /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/; |
| 11317 | |
| 11318 | /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11319 | |
| 11320 | /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode |
| 11321 | // |
| 11322 | // Ranges and exceptions: |
| 11323 | // Latin-1 Supplement, 0080–00FF |
| 11324 | // - U+00D7 × Multiplication sign |
| 11325 | // - U+00F7 ÷ Division sign |
| 11326 | // Latin Extended-A, 0100–017F |
| 11327 | // Latin Extended-B, 0180–024F |
| 11328 | // IPA Extensions, 0250–02AF |
| 11329 | // Spacing Modifier Letters, 02B0–02FF |
| 11330 | // - U+02C7 ˇ ˇ Caron |
| 11331 | // - U+02D8 ˘ ˘ Breve |
| 11332 | // - U+02D9 ˙ ˙ Dot Above |
| 11333 | // - U+02DA ˚ ˚ Ring Above |
| 11334 | // - U+02DB ˛ ˛ Ogonek |
| 11335 | // - U+02DC ˜ ˜ Small Tilde |
| 11336 | // - U+02DD ˝ ˝ Double Acute Accent |
| 11337 | // Latin Extended Additional, 1E00–1EFF |
| 11338 | var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; |
| 11339 | |
| 11340 | var reWhitespace = /\S/; |
| 11341 | |
| 11342 | var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11343 | wordDiff.equals = function (left, right) { |
| 11344 | if (this.options.ignoreCase) { |
| 11345 | left = left.toLowerCase(); |
| 11346 | right = right.toLowerCase(); |
| 11347 | } |
| 11348 | return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); |
| 11349 | }; |
| 11350 | wordDiff.tokenize = function (value) { |
| 11351 | var tokens = value.split(/(\s+|\b)/); |
| 11352 | |
| 11353 | // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. |
| 11354 | for (var i = 0; i < tokens.length - 1; i++) { |
| 11355 | // If we have an empty string in the next field and we have only word chars before and after, merge |
| 11356 | if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { |
| 11357 | tokens[i] += tokens[i + 2]; |
| 11358 | tokens.splice(i + 1, 2); |
| 11359 | i--; |
| 11360 | } |
| 11361 | } |
| 11362 | |
| 11363 | return tokens; |
| 11364 | }; |
| 11365 | |
| 11366 | function diffWords(oldStr, newStr, options) { |
| 11367 | options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true }); |
| 11368 | return wordDiff.diff(oldStr, newStr, options); |
| 11369 | } |
| 11370 | |
| 11371 | function diffWordsWithSpace(oldStr, newStr, options) { |
| 11372 | return wordDiff.diff(oldStr, newStr, options); |
| 11373 | } |
| 11374 | |
| 11375 | |
| 11376 | |
| 11377 | /***/ }), |
| 11378 | /* 4 */ |
| 11379 | /***/ (function(module, exports) { |
| 11380 | |
| 11381 | /*istanbul ignore start*/'use strict'; |
| 11382 | |
| 11383 | exports.__esModule = true; |
| 11384 | exports. /*istanbul ignore end*/generateOptions = generateOptions; |
| 11385 | function generateOptions(options, defaults) { |
| 11386 | if (typeof options === 'function') { |
| 11387 | defaults.callback = options; |
| 11388 | } else if (options) { |
| 11389 | for (var name in options) { |
| 11390 | /* istanbul ignore else */ |
| 11391 | if (options.hasOwnProperty(name)) { |
| 11392 | defaults[name] = options[name]; |
| 11393 | } |
| 11394 | } |
| 11395 | } |
| 11396 | return defaults; |
| 11397 | } |
| 11398 | |
| 11399 | |
| 11400 | |
| 11401 | /***/ }), |
| 11402 | /* 5 */ |
| 11403 | /***/ (function(module, exports, __webpack_require__) { |
| 11404 | |
| 11405 | /*istanbul ignore start*/'use strict'; |
| 11406 | |
| 11407 | exports.__esModule = true; |
| 11408 | exports.lineDiff = undefined; |
| 11409 | exports. /*istanbul ignore end*/diffLines = diffLines; |
| 11410 | /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines; |
| 11411 | |
| 11412 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11413 | |
| 11414 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11415 | |
| 11416 | /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/; |
| 11417 | |
| 11418 | /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11419 | |
| 11420 | /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11421 | lineDiff.tokenize = function (value) { |
| 11422 | var retLines = [], |
| 11423 | linesAndNewlines = value.split(/(\n|\r\n)/); |
| 11424 | |
| 11425 | // Ignore the final empty token that occurs if the string ends with a new line |
| 11426 | if (!linesAndNewlines[linesAndNewlines.length - 1]) { |
| 11427 | linesAndNewlines.pop(); |
| 11428 | } |
| 11429 | |
| 11430 | // Merge the content and line separators into single tokens |
| 11431 | for (var i = 0; i < linesAndNewlines.length; i++) { |
| 11432 | var line = linesAndNewlines[i]; |
| 11433 | |
| 11434 | if (i % 2 && !this.options.newlineIsToken) { |
| 11435 | retLines[retLines.length - 1] += line; |
| 11436 | } else { |
| 11437 | if (this.options.ignoreWhitespace) { |
| 11438 | line = line.trim(); |
| 11439 | } |
| 11440 | retLines.push(line); |
| 11441 | } |
| 11442 | } |
| 11443 | |
| 11444 | return retLines; |
| 11445 | }; |
| 11446 | |
| 11447 | function diffLines(oldStr, newStr, callback) { |
| 11448 | return lineDiff.diff(oldStr, newStr, callback); |
| 11449 | } |
| 11450 | function diffTrimmedLines(oldStr, newStr, callback) { |
| 11451 | var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true }); |
| 11452 | return lineDiff.diff(oldStr, newStr, options); |
| 11453 | } |
| 11454 | |
| 11455 | |
| 11456 | |
| 11457 | /***/ }), |
| 11458 | /* 6 */ |
| 11459 | /***/ (function(module, exports, __webpack_require__) { |
| 11460 | |
| 11461 | /*istanbul ignore start*/'use strict'; |
| 11462 | |
| 11463 | exports.__esModule = true; |
| 11464 | exports.sentenceDiff = undefined; |
| 11465 | exports. /*istanbul ignore end*/diffSentences = diffSentences; |
| 11466 | |
| 11467 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11468 | |
| 11469 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11470 | |
| 11471 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11472 | |
| 11473 | /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11474 | sentenceDiff.tokenize = function (value) { |
| 11475 | return value.split(/(\S.+?[.!?])(?=\s+|$)/); |
| 11476 | }; |
| 11477 | |
| 11478 | function diffSentences(oldStr, newStr, callback) { |
| 11479 | return sentenceDiff.diff(oldStr, newStr, callback); |
| 11480 | } |
| 11481 | |
| 11482 | |
| 11483 | |
| 11484 | /***/ }), |
| 11485 | /* 7 */ |
| 11486 | /***/ (function(module, exports, __webpack_require__) { |
| 11487 | |
| 11488 | /*istanbul ignore start*/'use strict'; |
| 11489 | |
| 11490 | exports.__esModule = true; |
| 11491 | exports.cssDiff = undefined; |
| 11492 | exports. /*istanbul ignore end*/diffCss = diffCss; |
| 11493 | |
| 11494 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11495 | |
| 11496 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11497 | |
| 11498 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11499 | |
| 11500 | /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11501 | cssDiff.tokenize = function (value) { |
| 11502 | return value.split(/([{}:;,]|\s+)/); |
| 11503 | }; |
| 11504 | |
| 11505 | function diffCss(oldStr, newStr, callback) { |
| 11506 | return cssDiff.diff(oldStr, newStr, callback); |
| 11507 | } |
| 11508 | |
| 11509 | |
| 11510 | |
| 11511 | /***/ }), |
| 11512 | /* 8 */ |
| 11513 | /***/ (function(module, exports, __webpack_require__) { |
| 11514 | |
| 11515 | /*istanbul ignore start*/'use strict'; |
| 11516 | |
| 11517 | exports.__esModule = true; |
| 11518 | exports.jsonDiff = undefined; |
| 11519 | |
| 11520 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
| 11521 | |
| 11522 | exports. /*istanbul ignore end*/diffJson = diffJson; |
| 11523 | /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize; |
| 11524 | |
| 11525 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11526 | |
| 11527 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11528 | |
| 11529 | /*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/; |
| 11530 | |
| 11531 | /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11532 | |
| 11533 | /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString; |
| 11534 | |
| 11535 | var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11536 | // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a |
| 11537 | // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: |
| 11538 | jsonDiff.useLongestToken = true; |
| 11539 | |
| 11540 | jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize; |
| 11541 | jsonDiff.castInput = function (value) { |
| 11542 | /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options, |
| 11543 | undefinedReplacement = _options.undefinedReplacement, |
| 11544 | _options$stringifyRep = _options.stringifyReplacer, |
| 11545 | stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{ |
| 11546 | return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v |
| 11547 | ); |
| 11548 | } : _options$stringifyRep; |
| 11549 | |
| 11550 | |
| 11551 | return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); |
| 11552 | }; |
| 11553 | jsonDiff.equals = function (left, right) { |
| 11554 | return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')) |
| 11555 | ); |
| 11556 | }; |
| 11557 | |
| 11558 | function diffJson(oldObj, newObj, options) { |
| 11559 | return jsonDiff.diff(oldObj, newObj, options); |
| 11560 | } |
| 11561 | |
| 11562 | // This function handles the presence of circular references by bailing out when encountering an |
| 11563 | // object that is already on the "stack" of items being processed. Accepts an optional replacer |
| 11564 | function canonicalize(obj, stack, replacementStack, replacer, key) { |
| 11565 | stack = stack || []; |
| 11566 | replacementStack = replacementStack || []; |
| 11567 | |
| 11568 | if (replacer) { |
| 11569 | obj = replacer(key, obj); |
| 11570 | } |
| 11571 | |
| 11572 | var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
| 11573 | |
| 11574 | for (i = 0; i < stack.length; i += 1) { |
| 11575 | if (stack[i] === obj) { |
| 11576 | return replacementStack[i]; |
| 11577 | } |
| 11578 | } |
| 11579 | |
| 11580 | var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
| 11581 | |
| 11582 | if ('[object Array]' === objectPrototypeToString.call(obj)) { |
| 11583 | stack.push(obj); |
| 11584 | canonicalizedObj = new Array(obj.length); |
| 11585 | replacementStack.push(canonicalizedObj); |
| 11586 | for (i = 0; i < obj.length; i += 1) { |
| 11587 | canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); |
| 11588 | } |
| 11589 | stack.pop(); |
| 11590 | replacementStack.pop(); |
| 11591 | return canonicalizedObj; |
| 11592 | } |
| 11593 | |
| 11594 | if (obj && obj.toJSON) { |
| 11595 | obj = obj.toJSON(); |
| 11596 | } |
| 11597 | |
| 11598 | if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) { |
| 11599 | stack.push(obj); |
| 11600 | canonicalizedObj = {}; |
| 11601 | replacementStack.push(canonicalizedObj); |
| 11602 | var sortedKeys = [], |
| 11603 | _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
| 11604 | for (_key in obj) { |
| 11605 | /* istanbul ignore else */ |
| 11606 | if (obj.hasOwnProperty(_key)) { |
| 11607 | sortedKeys.push(_key); |
| 11608 | } |
| 11609 | } |
| 11610 | sortedKeys.sort(); |
| 11611 | for (i = 0; i < sortedKeys.length; i += 1) { |
| 11612 | _key = sortedKeys[i]; |
| 11613 | canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); |
| 11614 | } |
| 11615 | stack.pop(); |
| 11616 | replacementStack.pop(); |
| 11617 | } else { |
| 11618 | canonicalizedObj = obj; |
| 11619 | } |
| 11620 | return canonicalizedObj; |
| 11621 | } |
| 11622 | |
| 11623 | |
| 11624 | |
| 11625 | /***/ }), |
| 11626 | /* 9 */ |
| 11627 | /***/ (function(module, exports, __webpack_require__) { |
| 11628 | |
| 11629 | /*istanbul ignore start*/'use strict'; |
| 11630 | |
| 11631 | exports.__esModule = true; |
| 11632 | exports.arrayDiff = undefined; |
| 11633 | exports. /*istanbul ignore end*/diffArrays = diffArrays; |
| 11634 | |
| 11635 | var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
| 11636 | |
| 11637 | /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
| 11638 | |
| 11639 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11640 | |
| 11641 | /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
| 11642 | arrayDiff.tokenize = function (value) { |
| 11643 | return value.slice(); |
| 11644 | }; |
| 11645 | arrayDiff.join = arrayDiff.removeEmpty = function (value) { |
| 11646 | return value; |
| 11647 | }; |
| 11648 | |
| 11649 | function diffArrays(oldArr, newArr, callback) { |
| 11650 | return arrayDiff.diff(oldArr, newArr, callback); |
| 11651 | } |
| 11652 | |
| 11653 | |
| 11654 | |
| 11655 | /***/ }), |
| 11656 | /* 10 */ |
| 11657 | /***/ (function(module, exports, __webpack_require__) { |
| 11658 | |
| 11659 | /*istanbul ignore start*/'use strict'; |
| 11660 | |
| 11661 | exports.__esModule = true; |
| 11662 | exports. /*istanbul ignore end*/applyPatch = applyPatch; |
| 11663 | /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches; |
| 11664 | |
| 11665 | var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/; |
| 11666 | |
| 11667 | var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/; |
| 11668 | |
| 11669 | /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator); |
| 11670 | |
| 11671 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
| 11672 | |
| 11673 | /*istanbul ignore end*/function applyPatch(source, uniDiff) { |
| 11674 | /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
| 11675 | |
| 11676 | if (typeof uniDiff === 'string') { |
| 11677 | uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff); |
| 11678 | } |
| 11679 | |
| 11680 | if (Array.isArray(uniDiff)) { |
| 11681 | if (uniDiff.length > 1) { |
| 11682 | throw new Error('applyPatch only works with a single input.'); |
| 11683 | } |
| 11684 | |
| 11685 | uniDiff = uniDiff[0]; |
| 11686 | } |
| 11687 | |
| 11688 | // Apply the diff to the input |
| 11689 | var lines = source.split(/\r\n|[\n\v\f\r\x85]/), |
| 11690 | delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
| 11691 | hunks = uniDiff.hunks, |
| 11692 | compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{ |
| 11693 | return (/*istanbul ignore end*/line === patchContent |
| 11694 | ); |
| 11695 | }, |
| 11696 | errorCount = 0, |
| 11697 | fuzzFactor = options.fuzzFactor || 0, |
| 11698 | minLine = 0, |
| 11699 | offset = 0, |
| 11700 | removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/, |
| 11701 | addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
| 11702 | |
| 11703 | /** |
| 11704 | * Checks if the hunk exactly fits on the provided location |
| 11705 | */ |
| 11706 | function hunkFits(hunk, toPos) { |
| 11707 | for (var j = 0; j < hunk.lines.length; j++) { |
| 11708 | var line = hunk.lines[j], |
| 11709 | operation = line.length > 0 ? line[0] : ' ', |
| 11710 | content = line.length > 0 ? line.substr(1) : line; |
| 11711 | |
| 11712 | if (operation === ' ' || operation === '-') { |
| 11713 | // Context sanity check |
| 11714 | if (!compareLine(toPos + 1, lines[toPos], operation, content)) { |
| 11715 | errorCount++; |
| 11716 | |
| 11717 | if (errorCount > fuzzFactor) { |
| 11718 | return false; |
| 11719 | } |
| 11720 | } |
| 11721 | toPos++; |
| 11722 | } |
| 11723 | } |
| 11724 | |
| 11725 | return true; |
| 11726 | } |
| 11727 | |
| 11728 | // Search best fit offsets for each hunk based on the previous ones |
| 11729 | for (var i = 0; i < hunks.length; i++) { |
| 11730 | var hunk = hunks[i], |
| 11731 | maxLine = lines.length - hunk.oldLines, |
| 11732 | localOffset = 0, |
| 11733 | toPos = offset + hunk.oldStart - 1; |
| 11734 | |
| 11735 | var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine); |
| 11736 | |
| 11737 | for (; localOffset !== undefined; localOffset = iterator()) { |
| 11738 | if (hunkFits(hunk, toPos + localOffset)) { |
| 11739 | hunk.offset = offset += localOffset; |
| 11740 | break; |
| 11741 | } |
| 11742 | } |
| 11743 | |
| 11744 | if (localOffset === undefined) { |
| 11745 | return false; |
| 11746 | } |
| 11747 | |
| 11748 | // Set lower text limit to end of the current hunk, so next ones don't try |
| 11749 | // to fit over already patched text |
| 11750 | minLine = hunk.offset + hunk.oldStart + hunk.oldLines; |
| 11751 | } |
| 11752 | |
| 11753 | // Apply patch hunks |
| 11754 | var diffOffset = 0; |
| 11755 | for (var _i = 0; _i < hunks.length; _i++) { |
| 11756 | var _hunk = hunks[_i], |
| 11757 | _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; |
| 11758 | diffOffset += _hunk.newLines - _hunk.oldLines; |
| 11759 | |
| 11760 | if (_toPos < 0) { |
| 11761 | // Creating a new file |
| 11762 | _toPos = 0; |
| 11763 | } |
| 11764 | |
| 11765 | for (var j = 0; j < _hunk.lines.length; j++) { |
| 11766 | var line = _hunk.lines[j], |
| 11767 | operation = line.length > 0 ? line[0] : ' ', |
| 11768 | content = line.length > 0 ? line.substr(1) : line, |
| 11769 | delimiter = _hunk.linedelimiters[j]; |
| 11770 | |
| 11771 | if (operation === ' ') { |
| 11772 | _toPos++; |
| 11773 | } else if (operation === '-') { |
| 11774 | lines.splice(_toPos, 1); |
| 11775 | delimiters.splice(_toPos, 1); |
| 11776 | /* istanbul ignore else */ |
| 11777 | } else if (operation === '+') { |
| 11778 | lines.splice(_toPos, 0, content); |
| 11779 | delimiters.splice(_toPos, 0, delimiter); |
| 11780 | _toPos++; |
| 11781 | } else if (operation === '\\') { |
| 11782 | var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; |
| 11783 | if (previousOperation === '+') { |
| 11784 | removeEOFNL = true; |
| 11785 | } else if (previousOperation === '-') { |
| 11786 | addEOFNL = true; |
| 11787 | } |
| 11788 | } |
| 11789 | } |
| 11790 | } |
| 11791 | |
| 11792 | // Handle EOFNL insertion/removal |
| 11793 | if (removeEOFNL) { |
| 11794 | while (!lines[lines.length - 1]) { |
| 11795 | lines.pop(); |
| 11796 | delimiters.pop(); |
| 11797 | } |
| 11798 | } else if (addEOFNL) { |
| 11799 | lines.push(''); |
| 11800 | delimiters.push('\n'); |
| 11801 | } |
| 11802 | for (var _k = 0; _k < lines.length - 1; _k++) { |
| 11803 | lines[_k] = lines[_k] + delimiters[_k]; |
| 11804 | } |
| 11805 | return lines.join(''); |
| 11806 | } |
| 11807 | |
| 11808 | // Wrapper that supports multiple file patches via callbacks. |
| 11809 | function applyPatches(uniDiff, options) { |
| 11810 | if (typeof uniDiff === 'string') { |
| 11811 | uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff); |
| 11812 | } |
| 11813 | |
| 11814 | var currentIndex = 0; |
| 11815 | function processIndex() { |
| 11816 | var index = uniDiff[currentIndex++]; |
| 11817 | if (!index) { |
| 11818 | return options.complete(); |
| 11819 | } |
| 11820 | |
| 11821 | options.loadFile(index, function (err, data) { |
| 11822 | if (err) { |
| 11823 | return options.complete(err); |
| 11824 | } |
| 11825 | |
| 11826 | var updatedContent = applyPatch(data, index, options); |
| 11827 | options.patched(index, updatedContent, function (err) { |
| 11828 | if (err) { |
| 11829 | return options.complete(err); |
| 11830 | } |
| 11831 | |
| 11832 | processIndex(); |
| 11833 | }); |
| 11834 | }); |
| 11835 | } |
| 11836 | processIndex(); |
| 11837 | } |
| 11838 | |
| 11839 | |
| 11840 | |
| 11841 | /***/ }), |
| 11842 | /* 11 */ |
| 11843 | /***/ (function(module, exports) { |
| 11844 | |
| 11845 | /*istanbul ignore start*/'use strict'; |
| 11846 | |
| 11847 | exports.__esModule = true; |
| 11848 | exports. /*istanbul ignore end*/parsePatch = parsePatch; |
| 11849 | function parsePatch(uniDiff) { |
| 11850 | /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
| 11851 | |
| 11852 | var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), |
| 11853 | delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
| 11854 | list = [], |
| 11855 | i = 0; |
| 11856 | |
| 11857 | function parseIndex() { |
| 11858 | var index = {}; |
| 11859 | list.push(index); |
| 11860 | |
| 11861 | // Parse diff metadata |
| 11862 | while (i < diffstr.length) { |
| 11863 | var line = diffstr[i]; |
| 11864 | |
| 11865 | // File header found, end parsing diff metadata |
| 11866 | if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { |
| 11867 | break; |
| 11868 | } |
| 11869 | |
| 11870 | // Diff index |
| 11871 | var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); |
| 11872 | if (header) { |
| 11873 | index.index = header[1]; |
| 11874 | } |
| 11875 | |
| 11876 | i++; |
| 11877 | } |
| 11878 | |
| 11879 | // Parse file headers if they are defined. Unified diff requires them, but |
| 11880 | // there's no technical issues to have an isolated hunk without file header |
| 11881 | parseFileHeader(index); |
| 11882 | parseFileHeader(index); |
| 11883 | |
| 11884 | // Parse hunks |
| 11885 | index.hunks = []; |
| 11886 | |
| 11887 | while (i < diffstr.length) { |
| 11888 | var _line = diffstr[i]; |
| 11889 | |
| 11890 | if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { |
| 11891 | break; |
| 11892 | } else if (/^@@/.test(_line)) { |
| 11893 | index.hunks.push(parseHunk()); |
| 11894 | } else if (_line && options.strict) { |
| 11895 | // Ignore unexpected content unless in strict mode |
| 11896 | throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); |
| 11897 | } else { |
| 11898 | i++; |
| 11899 | } |
| 11900 | } |
| 11901 | } |
| 11902 | |
| 11903 | // Parses the --- and +++ headers, if none are found, no lines |
| 11904 | // are consumed. |
| 11905 | function parseFileHeader(index) { |
| 11906 | var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]); |
| 11907 | if (fileHeader) { |
| 11908 | var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; |
| 11909 | var data = fileHeader[2].split('\t', 2); |
| 11910 | var fileName = data[0].replace(/\\\\/g, '\\'); |
| 11911 | if (/^".*"$/.test(fileName)) { |
| 11912 | fileName = fileName.substr(1, fileName.length - 2); |
| 11913 | } |
| 11914 | index[keyPrefix + 'FileName'] = fileName; |
| 11915 | index[keyPrefix + 'Header'] = (data[1] || '').trim(); |
| 11916 | |
| 11917 | i++; |
| 11918 | } |
| 11919 | } |
| 11920 | |
| 11921 | // Parses a hunk |
| 11922 | // This assumes that we are at the start of a hunk. |
| 11923 | function parseHunk() { |
| 11924 | var chunkHeaderIndex = i, |
| 11925 | chunkHeaderLine = diffstr[i++], |
| 11926 | chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); |
| 11927 | |
| 11928 | var hunk = { |
| 11929 | oldStart: +chunkHeader[1], |
| 11930 | oldLines: +chunkHeader[2] || 1, |
| 11931 | newStart: +chunkHeader[3], |
| 11932 | newLines: +chunkHeader[4] || 1, |
| 11933 | lines: [], |
| 11934 | linedelimiters: [] |
| 11935 | }; |
| 11936 | |
| 11937 | var addCount = 0, |
| 11938 | removeCount = 0; |
| 11939 | for (; i < diffstr.length; i++) { |
| 11940 | // Lines starting with '---' could be mistaken for the "remove line" operation |
| 11941 | // But they could be the header for the next file. Therefore prune such cases out. |
| 11942 | if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { |
| 11943 | break; |
| 11944 | } |
| 11945 | var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; |
| 11946 | |
| 11947 | if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { |
| 11948 | hunk.lines.push(diffstr[i]); |
| 11949 | hunk.linedelimiters.push(delimiters[i] || '\n'); |
| 11950 | |
| 11951 | if (operation === '+') { |
| 11952 | addCount++; |
| 11953 | } else if (operation === '-') { |
| 11954 | removeCount++; |
| 11955 | } else if (operation === ' ') { |
| 11956 | addCount++; |
| 11957 | removeCount++; |
| 11958 | } |
| 11959 | } else { |
| 11960 | break; |
| 11961 | } |
| 11962 | } |
| 11963 | |
| 11964 | // Handle the empty block count case |
| 11965 | if (!addCount && hunk.newLines === 1) { |
| 11966 | hunk.newLines = 0; |
| 11967 | } |
| 11968 | if (!removeCount && hunk.oldLines === 1) { |
| 11969 | hunk.oldLines = 0; |
| 11970 | } |
| 11971 | |
| 11972 | // Perform optional sanity checking |
| 11973 | if (options.strict) { |
| 11974 | if (addCount !== hunk.newLines) { |
| 11975 | throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
| 11976 | } |
| 11977 | if (removeCount !== hunk.oldLines) { |
| 11978 | throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
| 11979 | } |
| 11980 | } |
| 11981 | |
| 11982 | return hunk; |
| 11983 | } |
| 11984 | |
| 11985 | while (i < diffstr.length) { |
| 11986 | parseIndex(); |
| 11987 | } |
| 11988 | |
| 11989 | return list; |
| 11990 | } |
| 11991 | |
| 11992 | |
| 11993 | |
| 11994 | /***/ }), |
| 11995 | /* 12 */ |
| 11996 | /***/ (function(module, exports) { |
| 11997 | |
| 11998 | /*istanbul ignore start*/"use strict"; |
| 11999 | |
| 12000 | exports.__esModule = true; |
| 12001 | |
| 12002 | exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) { |
| 12003 | var wantForward = true, |
| 12004 | backwardExhausted = false, |
| 12005 | forwardExhausted = false, |
| 12006 | localOffset = 1; |
| 12007 | |
| 12008 | return function iterator() { |
| 12009 | if (wantForward && !forwardExhausted) { |
| 12010 | if (backwardExhausted) { |
| 12011 | localOffset++; |
| 12012 | } else { |
| 12013 | wantForward = false; |
| 12014 | } |
| 12015 | |
| 12016 | // Check if trying to fit beyond text length, and if not, check it fits |
| 12017 | // after offset location (or desired location on first iteration) |
| 12018 | if (start + localOffset <= maxLine) { |
| 12019 | return localOffset; |
| 12020 | } |
| 12021 | |
| 12022 | forwardExhausted = true; |
| 12023 | } |
| 12024 | |
| 12025 | if (!backwardExhausted) { |
| 12026 | if (!forwardExhausted) { |
| 12027 | wantForward = true; |
| 12028 | } |
| 12029 | |
| 12030 | // Check if trying to fit before text beginning, and if not, check it fits |
| 12031 | // before offset location |
| 12032 | if (minLine <= start - localOffset) { |
| 12033 | return -localOffset++; |
| 12034 | } |
| 12035 | |
| 12036 | backwardExhausted = true; |
| 12037 | return iterator(); |
| 12038 | } |
| 12039 | |
| 12040 | // We tried to fit hunk before text beginning and beyond text length, then |
| 12041 | // hunk can't fit on the text. Return undefined |
| 12042 | }; |
| 12043 | }; |
| 12044 | |
| 12045 | |
| 12046 | |
| 12047 | /***/ }), |
| 12048 | /* 13 */ |
| 12049 | /***/ (function(module, exports, __webpack_require__) { |
| 12050 | |
| 12051 | /*istanbul ignore start*/'use strict'; |
| 12052 | |
| 12053 | exports.__esModule = true; |
| 12054 | exports. /*istanbul ignore end*/calcLineCount = calcLineCount; |
| 12055 | /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge; |
| 12056 | |
| 12057 | var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/; |
| 12058 | |
| 12059 | var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/; |
| 12060 | |
| 12061 | var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/; |
| 12062 | |
| 12063 | /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } |
| 12064 | |
| 12065 | /*istanbul ignore end*/function calcLineCount(hunk) { |
| 12066 | /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines), |
| 12067 | oldLines = _calcOldNewLineCount.oldLines, |
| 12068 | newLines = _calcOldNewLineCount.newLines; |
| 12069 | |
| 12070 | if (oldLines !== undefined) { |
| 12071 | hunk.oldLines = oldLines; |
| 12072 | } else { |
| 12073 | delete hunk.oldLines; |
| 12074 | } |
| 12075 | |
| 12076 | if (newLines !== undefined) { |
| 12077 | hunk.newLines = newLines; |
| 12078 | } else { |
| 12079 | delete hunk.newLines; |
| 12080 | } |
| 12081 | } |
| 12082 | |
| 12083 | function merge(mine, theirs, base) { |
| 12084 | mine = loadPatch(mine, base); |
| 12085 | theirs = loadPatch(theirs, base); |
| 12086 | |
| 12087 | var ret = {}; |
| 12088 | |
| 12089 | // For index we just let it pass through as it doesn't have any necessary meaning. |
| 12090 | // Leaving sanity checks on this to the API consumer that may know more about the |
| 12091 | // meaning in their own context. |
| 12092 | if (mine.index || theirs.index) { |
| 12093 | ret.index = mine.index || theirs.index; |
| 12094 | } |
| 12095 | |
| 12096 | if (mine.newFileName || theirs.newFileName) { |
| 12097 | if (!fileNameChanged(mine)) { |
| 12098 | // No header or no change in ours, use theirs (and ours if theirs does not exist) |
| 12099 | ret.oldFileName = theirs.oldFileName || mine.oldFileName; |
| 12100 | ret.newFileName = theirs.newFileName || mine.newFileName; |
| 12101 | ret.oldHeader = theirs.oldHeader || mine.oldHeader; |
| 12102 | ret.newHeader = theirs.newHeader || mine.newHeader; |
| 12103 | } else if (!fileNameChanged(theirs)) { |
| 12104 | // No header or no change in theirs, use ours |
| 12105 | ret.oldFileName = mine.oldFileName; |
| 12106 | ret.newFileName = mine.newFileName; |
| 12107 | ret.oldHeader = mine.oldHeader; |
| 12108 | ret.newHeader = mine.newHeader; |
| 12109 | } else { |
| 12110 | // Both changed... figure it out |
| 12111 | ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); |
| 12112 | ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); |
| 12113 | ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); |
| 12114 | ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); |
| 12115 | } |
| 12116 | } |
| 12117 | |
| 12118 | ret.hunks = []; |
| 12119 | |
| 12120 | var mineIndex = 0, |
| 12121 | theirsIndex = 0, |
| 12122 | mineOffset = 0, |
| 12123 | theirsOffset = 0; |
| 12124 | |
| 12125 | while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { |
| 12126 | var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity }, |
| 12127 | theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity }; |
| 12128 | |
| 12129 | if (hunkBefore(mineCurrent, theirsCurrent)) { |
| 12130 | // This patch does not overlap with any of the others, yay. |
| 12131 | ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); |
| 12132 | mineIndex++; |
| 12133 | theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; |
| 12134 | } else if (hunkBefore(theirsCurrent, mineCurrent)) { |
| 12135 | // This patch does not overlap with any of the others, yay. |
| 12136 | ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); |
| 12137 | theirsIndex++; |
| 12138 | mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; |
| 12139 | } else { |
| 12140 | // Overlap, merge as best we can |
| 12141 | var mergedHunk = { |
| 12142 | oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), |
| 12143 | oldLines: 0, |
| 12144 | newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), |
| 12145 | newLines: 0, |
| 12146 | lines: [] |
| 12147 | }; |
| 12148 | mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); |
| 12149 | theirsIndex++; |
| 12150 | mineIndex++; |
| 12151 | |
| 12152 | ret.hunks.push(mergedHunk); |
| 12153 | } |
| 12154 | } |
| 12155 | |
| 12156 | return ret; |
| 12157 | } |
| 12158 | |
| 12159 | function loadPatch(param, base) { |
| 12160 | if (typeof param === 'string') { |
| 12161 | if (/^@@/m.test(param) || /^Index:/m.test(param)) { |
| 12162 | return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0] |
| 12163 | ); |
| 12164 | } |
| 12165 | |
| 12166 | if (!base) { |
| 12167 | throw new Error('Must provide a base reference or pass in a patch'); |
| 12168 | } |
| 12169 | return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param) |
| 12170 | ); |
| 12171 | } |
| 12172 | |
| 12173 | return param; |
| 12174 | } |
| 12175 | |
| 12176 | function fileNameChanged(patch) { |
| 12177 | return patch.newFileName && patch.newFileName !== patch.oldFileName; |
| 12178 | } |
| 12179 | |
| 12180 | function selectField(index, mine, theirs) { |
| 12181 | if (mine === theirs) { |
| 12182 | return mine; |
| 12183 | } else { |
| 12184 | index.conflict = true; |
| 12185 | return { mine: mine, theirs: theirs }; |
| 12186 | } |
| 12187 | } |
| 12188 | |
| 12189 | function hunkBefore(test, check) { |
| 12190 | return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; |
| 12191 | } |
| 12192 | |
| 12193 | function cloneHunk(hunk, offset) { |
| 12194 | return { |
| 12195 | oldStart: hunk.oldStart, oldLines: hunk.oldLines, |
| 12196 | newStart: hunk.newStart + offset, newLines: hunk.newLines, |
| 12197 | lines: hunk.lines |
| 12198 | }; |
| 12199 | } |
| 12200 | |
| 12201 | function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { |
| 12202 | // This will generally result in a conflicted hunk, but there are cases where the context |
| 12203 | // is the only overlap where we can successfully merge the content here. |
| 12204 | var mine = { offset: mineOffset, lines: mineLines, index: 0 }, |
| 12205 | their = { offset: theirOffset, lines: theirLines, index: 0 }; |
| 12206 | |
| 12207 | // Handle any leading content |
| 12208 | insertLeading(hunk, mine, their); |
| 12209 | insertLeading(hunk, their, mine); |
| 12210 | |
| 12211 | // Now in the overlap content. Scan through and select the best changes from each. |
| 12212 | while (mine.index < mine.lines.length && their.index < their.lines.length) { |
| 12213 | var mineCurrent = mine.lines[mine.index], |
| 12214 | theirCurrent = their.lines[their.index]; |
| 12215 | |
| 12216 | if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { |
| 12217 | // Both modified ... |
| 12218 | mutualChange(hunk, mine, their); |
| 12219 | } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { |
| 12220 | /*istanbul ignore start*/var _hunk$lines; |
| 12221 | |
| 12222 | /*istanbul ignore end*/ // Mine inserted |
| 12223 | /*istanbul ignore start*/(_hunk$lines = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(mine))); |
| 12224 | } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { |
| 12225 | /*istanbul ignore start*/var _hunk$lines2; |
| 12226 | |
| 12227 | /*istanbul ignore end*/ // Theirs inserted |
| 12228 | /*istanbul ignore start*/(_hunk$lines2 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(their))); |
| 12229 | } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { |
| 12230 | // Mine removed or edited |
| 12231 | removal(hunk, mine, their); |
| 12232 | } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { |
| 12233 | // Their removed or edited |
| 12234 | removal(hunk, their, mine, true); |
| 12235 | } else if (mineCurrent === theirCurrent) { |
| 12236 | // Context identity |
| 12237 | hunk.lines.push(mineCurrent); |
| 12238 | mine.index++; |
| 12239 | their.index++; |
| 12240 | } else { |
| 12241 | // Context mismatch |
| 12242 | conflict(hunk, collectChange(mine), collectChange(their)); |
| 12243 | } |
| 12244 | } |
| 12245 | |
| 12246 | // Now push anything that may be remaining |
| 12247 | insertTrailing(hunk, mine); |
| 12248 | insertTrailing(hunk, their); |
| 12249 | |
| 12250 | calcLineCount(hunk); |
| 12251 | } |
| 12252 | |
| 12253 | function mutualChange(hunk, mine, their) { |
| 12254 | var myChanges = collectChange(mine), |
| 12255 | theirChanges = collectChange(their); |
| 12256 | |
| 12257 | if (allRemoves(myChanges) && allRemoves(theirChanges)) { |
| 12258 | // Special case for remove changes that are supersets of one another |
| 12259 | if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { |
| 12260 | /*istanbul ignore start*/var _hunk$lines3; |
| 12261 | |
| 12262 | /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines3 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges)); |
| 12263 | return; |
| 12264 | } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { |
| 12265 | /*istanbul ignore start*/var _hunk$lines4; |
| 12266 | |
| 12267 | /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines4 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines4 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges)); |
| 12268 | return; |
| 12269 | } |
| 12270 | } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) { |
| 12271 | /*istanbul ignore start*/var _hunk$lines5; |
| 12272 | |
| 12273 | /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines5 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines5 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges)); |
| 12274 | return; |
| 12275 | } |
| 12276 | |
| 12277 | conflict(hunk, myChanges, theirChanges); |
| 12278 | } |
| 12279 | |
| 12280 | function removal(hunk, mine, their, swap) { |
| 12281 | var myChanges = collectChange(mine), |
| 12282 | theirChanges = collectContext(their, myChanges); |
| 12283 | if (theirChanges.merged) { |
| 12284 | /*istanbul ignore start*/var _hunk$lines6; |
| 12285 | |
| 12286 | /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines6 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines6 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges.merged)); |
| 12287 | } else { |
| 12288 | conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); |
| 12289 | } |
| 12290 | } |
| 12291 | |
| 12292 | function conflict(hunk, mine, their) { |
| 12293 | hunk.conflict = true; |
| 12294 | hunk.lines.push({ |
| 12295 | conflict: true, |
| 12296 | mine: mine, |
| 12297 | theirs: their |
| 12298 | }); |
| 12299 | } |
| 12300 | |
| 12301 | function insertLeading(hunk, insert, their) { |
| 12302 | while (insert.offset < their.offset && insert.index < insert.lines.length) { |
| 12303 | var line = insert.lines[insert.index++]; |
| 12304 | hunk.lines.push(line); |
| 12305 | insert.offset++; |
| 12306 | } |
| 12307 | } |
| 12308 | function insertTrailing(hunk, insert) { |
| 12309 | while (insert.index < insert.lines.length) { |
| 12310 | var line = insert.lines[insert.index++]; |
| 12311 | hunk.lines.push(line); |
| 12312 | } |
| 12313 | } |
| 12314 | |
| 12315 | function collectChange(state) { |
| 12316 | var ret = [], |
| 12317 | operation = state.lines[state.index][0]; |
| 12318 | while (state.index < state.lines.length) { |
| 12319 | var line = state.lines[state.index]; |
| 12320 | |
| 12321 | // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. |
| 12322 | if (operation === '-' && line[0] === '+') { |
| 12323 | operation = '+'; |
| 12324 | } |
| 12325 | |
| 12326 | if (operation === line[0]) { |
| 12327 | ret.push(line); |
| 12328 | state.index++; |
| 12329 | } else { |
| 12330 | break; |
| 12331 | } |
| 12332 | } |
| 12333 | |
| 12334 | return ret; |
| 12335 | } |
| 12336 | function collectContext(state, matchChanges) { |
| 12337 | var changes = [], |
| 12338 | merged = [], |
| 12339 | matchIndex = 0, |
| 12340 | contextChanges = false, |
| 12341 | conflicted = false; |
| 12342 | while (matchIndex < matchChanges.length && state.index < state.lines.length) { |
| 12343 | var change = state.lines[state.index], |
| 12344 | match = matchChanges[matchIndex]; |
| 12345 | |
| 12346 | // Once we've hit our add, then we are done |
| 12347 | if (match[0] === '+') { |
| 12348 | break; |
| 12349 | } |
| 12350 | |
| 12351 | contextChanges = contextChanges || change[0] !== ' '; |
| 12352 | |
| 12353 | merged.push(match); |
| 12354 | matchIndex++; |
| 12355 | |
| 12356 | // Consume any additions in the other block as a conflict to attempt |
| 12357 | // to pull in the remaining context after this |
| 12358 | if (change[0] === '+') { |
| 12359 | conflicted = true; |
| 12360 | |
| 12361 | while (change[0] === '+') { |
| 12362 | changes.push(change); |
| 12363 | change = state.lines[++state.index]; |
| 12364 | } |
| 12365 | } |
| 12366 | |
| 12367 | if (match.substr(1) === change.substr(1)) { |
| 12368 | changes.push(change); |
| 12369 | state.index++; |
| 12370 | } else { |
| 12371 | conflicted = true; |
| 12372 | } |
| 12373 | } |
| 12374 | |
| 12375 | if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { |
| 12376 | conflicted = true; |
| 12377 | } |
| 12378 | |
| 12379 | if (conflicted) { |
| 12380 | return changes; |
| 12381 | } |
| 12382 | |
| 12383 | while (matchIndex < matchChanges.length) { |
| 12384 | merged.push(matchChanges[matchIndex++]); |
| 12385 | } |
| 12386 | |
| 12387 | return { |
| 12388 | merged: merged, |
| 12389 | changes: changes |
| 12390 | }; |
| 12391 | } |
| 12392 | |
| 12393 | function allRemoves(changes) { |
| 12394 | return changes.reduce(function (prev, change) { |
| 12395 | return prev && change[0] === '-'; |
| 12396 | }, true); |
| 12397 | } |
| 12398 | function skipRemoveSuperset(state, removeChanges, delta) { |
| 12399 | for (var i = 0; i < delta; i++) { |
| 12400 | var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); |
| 12401 | if (state.lines[state.index + i] !== ' ' + changeContent) { |
| 12402 | return false; |
| 12403 | } |
| 12404 | } |
| 12405 | |
| 12406 | state.index += delta; |
| 12407 | return true; |
| 12408 | } |
| 12409 | |
| 12410 | function calcOldNewLineCount(lines) { |
| 12411 | var oldLines = 0; |
| 12412 | var newLines = 0; |
| 12413 | |
| 12414 | lines.forEach(function (line) { |
| 12415 | if (typeof line !== 'string') { |
| 12416 | var myCount = calcOldNewLineCount(line.mine); |
| 12417 | var theirCount = calcOldNewLineCount(line.theirs); |
| 12418 | |
| 12419 | if (oldLines !== undefined) { |
| 12420 | if (myCount.oldLines === theirCount.oldLines) { |
| 12421 | oldLines += myCount.oldLines; |
| 12422 | } else { |
| 12423 | oldLines = undefined; |
| 12424 | } |
| 12425 | } |
| 12426 | |
| 12427 | if (newLines !== undefined) { |
| 12428 | if (myCount.newLines === theirCount.newLines) { |
| 12429 | newLines += myCount.newLines; |
| 12430 | } else { |
| 12431 | newLines = undefined; |
| 12432 | } |
| 12433 | } |
| 12434 | } else { |
| 12435 | if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { |
| 12436 | newLines++; |
| 12437 | } |
| 12438 | if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { |
| 12439 | oldLines++; |
| 12440 | } |
| 12441 | } |
| 12442 | }); |
| 12443 | |
| 12444 | return { oldLines: oldLines, newLines: newLines }; |
| 12445 | } |
| 12446 | |
| 12447 | |
| 12448 | |
| 12449 | /***/ }), |
| 12450 | /* 14 */ |
| 12451 | /***/ (function(module, exports, __webpack_require__) { |
| 12452 | |
| 12453 | /*istanbul ignore start*/'use strict'; |
| 12454 | |
| 12455 | exports.__esModule = true; |
| 12456 | exports. /*istanbul ignore end*/structuredPatch = structuredPatch; |
| 12457 | /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch; |
| 12458 | /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch; |
| 12459 | |
| 12460 | var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/; |
| 12461 | |
| 12462 | /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } |
| 12463 | |
| 12464 | /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
| 12465 | if (!options) { |
| 12466 | options = {}; |
| 12467 | } |
| 12468 | if (typeof options.context === 'undefined') { |
| 12469 | options.context = 4; |
| 12470 | } |
| 12471 | |
| 12472 | var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options); |
| 12473 | diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier |
| 12474 | |
| 12475 | function contextLines(lines) { |
| 12476 | return lines.map(function (entry) { |
| 12477 | return ' ' + entry; |
| 12478 | }); |
| 12479 | } |
| 12480 | |
| 12481 | var hunks = []; |
| 12482 | var oldRangeStart = 0, |
| 12483 | newRangeStart = 0, |
| 12484 | curRange = [], |
| 12485 | oldLine = 1, |
| 12486 | newLine = 1; |
| 12487 | |
| 12488 | /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) { |
| 12489 | var current = diff[i], |
| 12490 | lines = current.lines || current.value.replace(/\n$/, '').split('\n'); |
| 12491 | current.lines = lines; |
| 12492 | |
| 12493 | if (current.added || current.removed) { |
| 12494 | /*istanbul ignore start*/var _curRange; |
| 12495 | |
| 12496 | /*istanbul ignore end*/ // If we have previous context, start with that |
| 12497 | if (!oldRangeStart) { |
| 12498 | var prev = diff[i - 1]; |
| 12499 | oldRangeStart = oldLine; |
| 12500 | newRangeStart = newLine; |
| 12501 | |
| 12502 | if (prev) { |
| 12503 | curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; |
| 12504 | oldRangeStart -= curRange.length; |
| 12505 | newRangeStart -= curRange.length; |
| 12506 | } |
| 12507 | } |
| 12508 | |
| 12509 | // Output our changes |
| 12510 | /*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) { |
| 12511 | return (current.added ? '+' : '-') + entry; |
| 12512 | }))); |
| 12513 | |
| 12514 | // Track the updated file position |
| 12515 | if (current.added) { |
| 12516 | newLine += lines.length; |
| 12517 | } else { |
| 12518 | oldLine += lines.length; |
| 12519 | } |
| 12520 | } else { |
| 12521 | // Identical context lines. Track line changes |
| 12522 | if (oldRangeStart) { |
| 12523 | // Close out any changes that have been output (or join overlapping) |
| 12524 | if (lines.length <= options.context * 2 && i < diff.length - 2) { |
| 12525 | /*istanbul ignore start*/var _curRange2; |
| 12526 | |
| 12527 | /*istanbul ignore end*/ // Overlapping |
| 12528 | /*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines))); |
| 12529 | } else { |
| 12530 | /*istanbul ignore start*/var _curRange3; |
| 12531 | |
| 12532 | /*istanbul ignore end*/ // end the range and output |
| 12533 | var contextSize = Math.min(lines.length, options.context); |
| 12534 | /*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize)))); |
| 12535 | |
| 12536 | var hunk = { |
| 12537 | oldStart: oldRangeStart, |
| 12538 | oldLines: oldLine - oldRangeStart + contextSize, |
| 12539 | newStart: newRangeStart, |
| 12540 | newLines: newLine - newRangeStart + contextSize, |
| 12541 | lines: curRange |
| 12542 | }; |
| 12543 | if (i >= diff.length - 2 && lines.length <= options.context) { |
| 12544 | // EOF is inside this hunk |
| 12545 | var oldEOFNewline = /\n$/.test(oldStr); |
| 12546 | var newEOFNewline = /\n$/.test(newStr); |
| 12547 | if (lines.length == 0 && !oldEOFNewline) { |
| 12548 | // special case: old has no eol and no trailing context; no-nl can end up before adds |
| 12549 | curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); |
| 12550 | } else if (!oldEOFNewline || !newEOFNewline) { |
| 12551 | curRange.push('\\ No newline at end of file'); |
| 12552 | } |
| 12553 | } |
| 12554 | hunks.push(hunk); |
| 12555 | |
| 12556 | oldRangeStart = 0; |
| 12557 | newRangeStart = 0; |
| 12558 | curRange = []; |
| 12559 | } |
| 12560 | } |
| 12561 | oldLine += lines.length; |
| 12562 | newLine += lines.length; |
| 12563 | } |
| 12564 | }; |
| 12565 | |
| 12566 | for (var i = 0; i < diff.length; i++) { |
| 12567 | /*istanbul ignore start*/_loop( /*istanbul ignore end*/i); |
| 12568 | } |
| 12569 | |
| 12570 | return { |
| 12571 | oldFileName: oldFileName, newFileName: newFileName, |
| 12572 | oldHeader: oldHeader, newHeader: newHeader, |
| 12573 | hunks: hunks |
| 12574 | }; |
| 12575 | } |
| 12576 | |
| 12577 | function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
| 12578 | var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); |
| 12579 | |
| 12580 | var ret = []; |
| 12581 | if (oldFileName == newFileName) { |
| 12582 | ret.push('Index: ' + oldFileName); |
| 12583 | } |
| 12584 | ret.push('==================================================================='); |
| 12585 | ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); |
| 12586 | ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); |
| 12587 | |
| 12588 | for (var i = 0; i < diff.hunks.length; i++) { |
| 12589 | var hunk = diff.hunks[i]; |
| 12590 | ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); |
| 12591 | ret.push.apply(ret, hunk.lines); |
| 12592 | } |
| 12593 | |
| 12594 | return ret.join('\n') + '\n'; |
| 12595 | } |
| 12596 | |
| 12597 | function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { |
| 12598 | return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); |
| 12599 | } |
| 12600 | |
| 12601 | |
| 12602 | |
| 12603 | /***/ }), |
| 12604 | /* 15 */ |
| 12605 | /***/ (function(module, exports) { |
| 12606 | |
| 12607 | /*istanbul ignore start*/"use strict"; |
| 12608 | |
| 12609 | exports.__esModule = true; |
| 12610 | exports. /*istanbul ignore end*/arrayEqual = arrayEqual; |
| 12611 | /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith; |
| 12612 | function arrayEqual(a, b) { |
| 12613 | if (a.length !== b.length) { |
| 12614 | return false; |
| 12615 | } |
| 12616 | |
| 12617 | return arrayStartsWith(a, b); |
| 12618 | } |
| 12619 | |
| 12620 | function arrayStartsWith(array, start) { |
| 12621 | if (start.length > array.length) { |
| 12622 | return false; |
| 12623 | } |
| 12624 | |
| 12625 | for (var i = 0; i < start.length; i++) { |
| 12626 | if (start[i] !== array[i]) { |
| 12627 | return false; |
| 12628 | } |
| 12629 | } |
| 12630 | |
| 12631 | return true; |
| 12632 | } |
| 12633 | |
| 12634 | |
| 12635 | |
| 12636 | /***/ }), |
| 12637 | /* 16 */ |
| 12638 | /***/ (function(module, exports) { |
| 12639 | |
| 12640 | /*istanbul ignore start*/"use strict"; |
| 12641 | |
| 12642 | exports.__esModule = true; |
| 12643 | exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP; |
| 12644 | // See: http://code.google.com/p/google-diff-match-patch/wiki/API |
| 12645 | function convertChangesToDMP(changes) { |
| 12646 | var ret = [], |
| 12647 | change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/, |
| 12648 | operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
| 12649 | for (var i = 0; i < changes.length; i++) { |
| 12650 | change = changes[i]; |
| 12651 | if (change.added) { |
| 12652 | operation = 1; |
| 12653 | } else if (change.removed) { |
| 12654 | operation = -1; |
| 12655 | } else { |
| 12656 | operation = 0; |
| 12657 | } |
| 12658 | |
| 12659 | ret.push([operation, change.value]); |
| 12660 | } |
| 12661 | return ret; |
| 12662 | } |
| 12663 | |
| 12664 | |
| 12665 | |
| 12666 | /***/ }), |
| 12667 | /* 17 */ |
| 12668 | /***/ (function(module, exports) { |
| 12669 | |
| 12670 | /*istanbul ignore start*/'use strict'; |
| 12671 | |
| 12672 | exports.__esModule = true; |
| 12673 | exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML; |
| 12674 | function convertChangesToXML(changes) { |
| 12675 | var ret = []; |
| 12676 | for (var i = 0; i < changes.length; i++) { |
| 12677 | var change = changes[i]; |
| 12678 | if (change.added) { |
| 12679 | ret.push('<ins>'); |
| 12680 | } else if (change.removed) { |
| 12681 | ret.push('<del>'); |
| 12682 | } |
| 12683 | |
| 12684 | ret.push(escapeHTML(change.value)); |
| 12685 | |
| 12686 | if (change.added) { |
| 12687 | ret.push('</ins>'); |
| 12688 | } else if (change.removed) { |
| 12689 | ret.push('</del>'); |
| 12690 | } |
| 12691 | } |
| 12692 | return ret.join(''); |
| 12693 | } |
| 12694 | |
| 12695 | function escapeHTML(s) { |
| 12696 | var n = s; |
| 12697 | n = n.replace(/&/g, '&'); |
| 12698 | n = n.replace(/</g, '<'); |
| 12699 | n = n.replace(/>/g, '>'); |
| 12700 | n = n.replace(/"/g, '"'); |
| 12701 | |
| 12702 | return n; |
| 12703 | } |
| 12704 | |
| 12705 | |
| 12706 | |
| 12707 | /***/ }) |
| 12708 | /******/ ]) |
| 12709 | }); |
| 12710 | ; |
| 12711 | },{}],49:[function(require,module,exports){ |
| 12712 | 'use strict'; |
| 12713 | |
| 12714 | var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; |
| 12715 | |
| 12716 | module.exports = function (str) { |
| 12717 | if (typeof str !== 'string') { |
| 12718 | throw new TypeError('Expected a string'); |
| 12719 | } |
| 12720 | |
| 12721 | return str.replace(matchOperatorsRe, '\\$&'); |
| 12722 | }; |
| 12723 | |
| 12724 | },{}],50:[function(require,module,exports){ |
| 12725 | // Copyright Joyent, Inc. and other Node contributors. |
| 12726 | // |
| 12727 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 12728 | // copy of this software and associated documentation files (the |
| 12729 | // "Software"), to deal in the Software without restriction, including |
| 12730 | // without limitation the rights to use, copy, modify, merge, publish, |
| 12731 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 12732 | // persons to whom the Software is furnished to do so, subject to the |
| 12733 | // following conditions: |
| 12734 | // |
| 12735 | // The above copyright notice and this permission notice shall be included |
| 12736 | // in all copies or substantial portions of the Software. |
| 12737 | // |
| 12738 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 12739 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 12740 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 12741 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 12742 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 12743 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 12744 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 12745 | |
| 12746 | var objectCreate = Object.create || objectCreatePolyfill |
| 12747 | var objectKeys = Object.keys || objectKeysPolyfill |
| 12748 | var bind = Function.prototype.bind || functionBindPolyfill |
| 12749 | |
| 12750 | function EventEmitter() { |
| 12751 | if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) { |
| 12752 | this._events = objectCreate(null); |
| 12753 | this._eventsCount = 0; |
| 12754 | } |
| 12755 | |
| 12756 | this._maxListeners = this._maxListeners || undefined; |
| 12757 | } |
| 12758 | module.exports = EventEmitter; |
| 12759 | |
| 12760 | // Backwards-compat with node 0.10.x |
| 12761 | EventEmitter.EventEmitter = EventEmitter; |
| 12762 | |
| 12763 | EventEmitter.prototype._events = undefined; |
| 12764 | EventEmitter.prototype._maxListeners = undefined; |
| 12765 | |
| 12766 | // By default EventEmitters will print a warning if more than 10 listeners are |
| 12767 | // added to it. This is a useful default which helps finding memory leaks. |
| 12768 | var defaultMaxListeners = 10; |
| 12769 | |
| 12770 | var hasDefineProperty; |
| 12771 | try { |
| 12772 | var o = {}; |
| 12773 | if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 }); |
| 12774 | hasDefineProperty = o.x === 0; |
| 12775 | } catch (err) { hasDefineProperty = false } |
| 12776 | if (hasDefineProperty) { |
| 12777 | Object.defineProperty(EventEmitter, 'defaultMaxListeners', { |
| 12778 | enumerable: true, |
| 12779 | get: function() { |
| 12780 | return defaultMaxListeners; |
| 12781 | }, |
| 12782 | set: function(arg) { |
| 12783 | // check whether the input is a positive number (whose value is zero or |
| 12784 | // greater and not a NaN). |
| 12785 | if (typeof arg !== 'number' || arg < 0 || arg !== arg) |
| 12786 | throw new TypeError('"defaultMaxListeners" must be a positive number'); |
| 12787 | defaultMaxListeners = arg; |
| 12788 | } |
| 12789 | }); |
| 12790 | } else { |
| 12791 | EventEmitter.defaultMaxListeners = defaultMaxListeners; |
| 12792 | } |
| 12793 | |
| 12794 | // Obviously not all Emitters should be limited to 10. This function allows |
| 12795 | // that to be increased. Set to zero for unlimited. |
| 12796 | EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { |
| 12797 | if (typeof n !== 'number' || n < 0 || isNaN(n)) |
| 12798 | throw new TypeError('"n" argument must be a positive number'); |
| 12799 | this._maxListeners = n; |
| 12800 | return this; |
| 12801 | }; |
| 12802 | |
| 12803 | function $getMaxListeners(that) { |
| 12804 | if (that._maxListeners === undefined) |
| 12805 | return EventEmitter.defaultMaxListeners; |
| 12806 | return that._maxListeners; |
| 12807 | } |
| 12808 | |
| 12809 | EventEmitter.prototype.getMaxListeners = function getMaxListeners() { |
| 12810 | return $getMaxListeners(this); |
| 12811 | }; |
| 12812 | |
| 12813 | // These standalone emit* functions are used to optimize calling of event |
| 12814 | // handlers for fast cases because emit() itself often has a variable number of |
| 12815 | // arguments and can be deoptimized because of that. These functions always have |
| 12816 | // the same number of arguments and thus do not get deoptimized, so the code |
| 12817 | // inside them can execute faster. |
| 12818 | function emitNone(handler, isFn, self) { |
| 12819 | if (isFn) |
| 12820 | handler.call(self); |
| 12821 | else { |
| 12822 | var len = handler.length; |
| 12823 | var listeners = arrayClone(handler, len); |
| 12824 | for (var i = 0; i < len; ++i) |
| 12825 | listeners[i].call(self); |
| 12826 | } |
| 12827 | } |
| 12828 | function emitOne(handler, isFn, self, arg1) { |
| 12829 | if (isFn) |
| 12830 | handler.call(self, arg1); |
| 12831 | else { |
| 12832 | var len = handler.length; |
| 12833 | var listeners = arrayClone(handler, len); |
| 12834 | for (var i = 0; i < len; ++i) |
| 12835 | listeners[i].call(self, arg1); |
| 12836 | } |
| 12837 | } |
| 12838 | function emitTwo(handler, isFn, self, arg1, arg2) { |
| 12839 | if (isFn) |
| 12840 | handler.call(self, arg1, arg2); |
| 12841 | else { |
| 12842 | var len = handler.length; |
| 12843 | var listeners = arrayClone(handler, len); |
| 12844 | for (var i = 0; i < len; ++i) |
| 12845 | listeners[i].call(self, arg1, arg2); |
| 12846 | } |
| 12847 | } |
| 12848 | function emitThree(handler, isFn, self, arg1, arg2, arg3) { |
| 12849 | if (isFn) |
| 12850 | handler.call(self, arg1, arg2, arg3); |
| 12851 | else { |
| 12852 | var len = handler.length; |
| 12853 | var listeners = arrayClone(handler, len); |
| 12854 | for (var i = 0; i < len; ++i) |
| 12855 | listeners[i].call(self, arg1, arg2, arg3); |
| 12856 | } |
| 12857 | } |
| 12858 | |
| 12859 | function emitMany(handler, isFn, self, args) { |
| 12860 | if (isFn) |
| 12861 | handler.apply(self, args); |
| 12862 | else { |
| 12863 | var len = handler.length; |
| 12864 | var listeners = arrayClone(handler, len); |
| 12865 | for (var i = 0; i < len; ++i) |
| 12866 | listeners[i].apply(self, args); |
| 12867 | } |
| 12868 | } |
| 12869 | |
| 12870 | EventEmitter.prototype.emit = function emit(type) { |
| 12871 | var er, handler, len, args, i, events; |
| 12872 | var doError = (type === 'error'); |
| 12873 | |
| 12874 | events = this._events; |
| 12875 | if (events) |
| 12876 | doError = (doError && events.error == null); |
| 12877 | else if (!doError) |
| 12878 | return false; |
| 12879 | |
| 12880 | // If there is no 'error' event listener then throw. |
| 12881 | if (doError) { |
| 12882 | if (arguments.length > 1) |
| 12883 | er = arguments[1]; |
| 12884 | if (er instanceof Error) { |
| 12885 | throw er; // Unhandled 'error' event |
| 12886 | } else { |
| 12887 | // At least give some kind of context to the user |
| 12888 | var err = new Error('Unhandled "error" event. (' + er + ')'); |
| 12889 | err.context = er; |
| 12890 | throw err; |
| 12891 | } |
| 12892 | return false; |
| 12893 | } |
| 12894 | |
| 12895 | handler = events[type]; |
| 12896 | |
| 12897 | if (!handler) |
| 12898 | return false; |
| 12899 | |
| 12900 | var isFn = typeof handler === 'function'; |
| 12901 | len = arguments.length; |
| 12902 | switch (len) { |
| 12903 | // fast cases |
| 12904 | case 1: |
| 12905 | emitNone(handler, isFn, this); |
| 12906 | break; |
| 12907 | case 2: |
| 12908 | emitOne(handler, isFn, this, arguments[1]); |
| 12909 | break; |
| 12910 | case 3: |
| 12911 | emitTwo(handler, isFn, this, arguments[1], arguments[2]); |
| 12912 | break; |
| 12913 | case 4: |
| 12914 | emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); |
| 12915 | break; |
| 12916 | // slower |
| 12917 | default: |
| 12918 | args = new Array(len - 1); |
| 12919 | for (i = 1; i < len; i++) |
| 12920 | args[i - 1] = arguments[i]; |
| 12921 | emitMany(handler, isFn, this, args); |
| 12922 | } |
| 12923 | |
| 12924 | return true; |
| 12925 | }; |
| 12926 | |
| 12927 | function _addListener(target, type, listener, prepend) { |
| 12928 | var m; |
| 12929 | var events; |
| 12930 | var existing; |
| 12931 | |
| 12932 | if (typeof listener !== 'function') |
| 12933 | throw new TypeError('"listener" argument must be a function'); |
| 12934 | |
| 12935 | events = target._events; |
| 12936 | if (!events) { |
| 12937 | events = target._events = objectCreate(null); |
| 12938 | target._eventsCount = 0; |
| 12939 | } else { |
| 12940 | // To avoid recursion in the case that type === "newListener"! Before |
| 12941 | // adding it to the listeners, first emit "newListener". |
| 12942 | if (events.newListener) { |
| 12943 | target.emit('newListener', type, |
| 12944 | listener.listener ? listener.listener : listener); |
| 12945 | |
| 12946 | // Re-assign `events` because a newListener handler could have caused the |
| 12947 | // this._events to be assigned to a new object |
| 12948 | events = target._events; |
| 12949 | } |
| 12950 | existing = events[type]; |
| 12951 | } |
| 12952 | |
| 12953 | if (!existing) { |
| 12954 | // Optimize the case of one listener. Don't need the extra array object. |
| 12955 | existing = events[type] = listener; |
| 12956 | ++target._eventsCount; |
| 12957 | } else { |
| 12958 | if (typeof existing === 'function') { |
| 12959 | // Adding the second element, need to change to array. |
| 12960 | existing = events[type] = |
| 12961 | prepend ? [listener, existing] : [existing, listener]; |
| 12962 | } else { |
| 12963 | // If we've already got an array, just append. |
| 12964 | if (prepend) { |
| 12965 | existing.unshift(listener); |
| 12966 | } else { |
| 12967 | existing.push(listener); |
| 12968 | } |
| 12969 | } |
| 12970 | |
| 12971 | // Check for listener leak |
| 12972 | if (!existing.warned) { |
| 12973 | m = $getMaxListeners(target); |
| 12974 | if (m && m > 0 && existing.length > m) { |
| 12975 | existing.warned = true; |
| 12976 | var w = new Error('Possible EventEmitter memory leak detected. ' + |
| 12977 | existing.length + ' "' + String(type) + '" listeners ' + |
| 12978 | 'added. Use emitter.setMaxListeners() to ' + |
| 12979 | 'increase limit.'); |
| 12980 | w.name = 'MaxListenersExceededWarning'; |
| 12981 | w.emitter = target; |
| 12982 | w.type = type; |
| 12983 | w.count = existing.length; |
| 12984 | if (typeof console === 'object' && console.warn) { |
| 12985 | console.warn('%s: %s', w.name, w.message); |
| 12986 | } |
| 12987 | } |
| 12988 | } |
| 12989 | } |
| 12990 | |
| 12991 | return target; |
| 12992 | } |
| 12993 | |
| 12994 | EventEmitter.prototype.addListener = function addListener(type, listener) { |
| 12995 | return _addListener(this, type, listener, false); |
| 12996 | }; |
| 12997 | |
| 12998 | EventEmitter.prototype.on = EventEmitter.prototype.addListener; |
| 12999 | |
| 13000 | EventEmitter.prototype.prependListener = |
| 13001 | function prependListener(type, listener) { |
| 13002 | return _addListener(this, type, listener, true); |
| 13003 | }; |
| 13004 | |
| 13005 | function onceWrapper() { |
| 13006 | if (!this.fired) { |
| 13007 | this.target.removeListener(this.type, this.wrapFn); |
| 13008 | this.fired = true; |
| 13009 | switch (arguments.length) { |
| 13010 | case 0: |
| 13011 | return this.listener.call(this.target); |
| 13012 | case 1: |
| 13013 | return this.listener.call(this.target, arguments[0]); |
| 13014 | case 2: |
| 13015 | return this.listener.call(this.target, arguments[0], arguments[1]); |
| 13016 | case 3: |
| 13017 | return this.listener.call(this.target, arguments[0], arguments[1], |
| 13018 | arguments[2]); |
| 13019 | default: |
| 13020 | var args = new Array(arguments.length); |
| 13021 | for (var i = 0; i < args.length; ++i) |
| 13022 | args[i] = arguments[i]; |
| 13023 | this.listener.apply(this.target, args); |
| 13024 | } |
| 13025 | } |
| 13026 | } |
| 13027 | |
| 13028 | function _onceWrap(target, type, listener) { |
| 13029 | var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; |
| 13030 | var wrapped = bind.call(onceWrapper, state); |
| 13031 | wrapped.listener = listener; |
| 13032 | state.wrapFn = wrapped; |
| 13033 | return wrapped; |
| 13034 | } |
| 13035 | |
| 13036 | EventEmitter.prototype.once = function once(type, listener) { |
| 13037 | if (typeof listener !== 'function') |
| 13038 | throw new TypeError('"listener" argument must be a function'); |
| 13039 | this.on(type, _onceWrap(this, type, listener)); |
| 13040 | return this; |
| 13041 | }; |
| 13042 | |
| 13043 | EventEmitter.prototype.prependOnceListener = |
| 13044 | function prependOnceListener(type, listener) { |
| 13045 | if (typeof listener !== 'function') |
| 13046 | throw new TypeError('"listener" argument must be a function'); |
| 13047 | this.prependListener(type, _onceWrap(this, type, listener)); |
| 13048 | return this; |
| 13049 | }; |
| 13050 | |
| 13051 | // Emits a 'removeListener' event if and only if the listener was removed. |
| 13052 | EventEmitter.prototype.removeListener = |
| 13053 | function removeListener(type, listener) { |
| 13054 | var list, events, position, i, originalListener; |
| 13055 | |
| 13056 | if (typeof listener !== 'function') |
| 13057 | throw new TypeError('"listener" argument must be a function'); |
| 13058 | |
| 13059 | events = this._events; |
| 13060 | if (!events) |
| 13061 | return this; |
| 13062 | |
| 13063 | list = events[type]; |
| 13064 | if (!list) |
| 13065 | return this; |
| 13066 | |
| 13067 | if (list === listener || list.listener === listener) { |
| 13068 | if (--this._eventsCount === 0) |
| 13069 | this._events = objectCreate(null); |
| 13070 | else { |
| 13071 | delete events[type]; |
| 13072 | if (events.removeListener) |
| 13073 | this.emit('removeListener', type, list.listener || listener); |
| 13074 | } |
| 13075 | } else if (typeof list !== 'function') { |
| 13076 | position = -1; |
| 13077 | |
| 13078 | for (i = list.length - 1; i >= 0; i--) { |
| 13079 | if (list[i] === listener || list[i].listener === listener) { |
| 13080 | originalListener = list[i].listener; |
| 13081 | position = i; |
| 13082 | break; |
| 13083 | } |
| 13084 | } |
| 13085 | |
| 13086 | if (position < 0) |
| 13087 | return this; |
| 13088 | |
| 13089 | if (position === 0) |
| 13090 | list.shift(); |
| 13091 | else |
| 13092 | spliceOne(list, position); |
| 13093 | |
| 13094 | if (list.length === 1) |
| 13095 | events[type] = list[0]; |
| 13096 | |
| 13097 | if (events.removeListener) |
| 13098 | this.emit('removeListener', type, originalListener || listener); |
| 13099 | } |
| 13100 | |
| 13101 | return this; |
| 13102 | }; |
| 13103 | |
| 13104 | EventEmitter.prototype.removeAllListeners = |
| 13105 | function removeAllListeners(type) { |
| 13106 | var listeners, events, i; |
| 13107 | |
| 13108 | events = this._events; |
| 13109 | if (!events) |
| 13110 | return this; |
| 13111 | |
| 13112 | // not listening for removeListener, no need to emit |
| 13113 | if (!events.removeListener) { |
| 13114 | if (arguments.length === 0) { |
| 13115 | this._events = objectCreate(null); |
| 13116 | this._eventsCount = 0; |
| 13117 | } else if (events[type]) { |
| 13118 | if (--this._eventsCount === 0) |
| 13119 | this._events = objectCreate(null); |
| 13120 | else |
| 13121 | delete events[type]; |
| 13122 | } |
| 13123 | return this; |
| 13124 | } |
| 13125 | |
| 13126 | // emit removeListener for all listeners on all events |
| 13127 | if (arguments.length === 0) { |
| 13128 | var keys = objectKeys(events); |
| 13129 | var key; |
| 13130 | for (i = 0; i < keys.length; ++i) { |
| 13131 | key = keys[i]; |
| 13132 | if (key === 'removeListener') continue; |
| 13133 | this.removeAllListeners(key); |
| 13134 | } |
| 13135 | this.removeAllListeners('removeListener'); |
| 13136 | this._events = objectCreate(null); |
| 13137 | this._eventsCount = 0; |
| 13138 | return this; |
| 13139 | } |
| 13140 | |
| 13141 | listeners = events[type]; |
| 13142 | |
| 13143 | if (typeof listeners === 'function') { |
| 13144 | this.removeListener(type, listeners); |
| 13145 | } else if (listeners) { |
| 13146 | // LIFO order |
| 13147 | for (i = listeners.length - 1; i >= 0; i--) { |
| 13148 | this.removeListener(type, listeners[i]); |
| 13149 | } |
| 13150 | } |
| 13151 | |
| 13152 | return this; |
| 13153 | }; |
| 13154 | |
| 13155 | function _listeners(target, type, unwrap) { |
| 13156 | var events = target._events; |
| 13157 | |
| 13158 | if (!events) |
| 13159 | return []; |
| 13160 | |
| 13161 | var evlistener = events[type]; |
| 13162 | if (!evlistener) |
| 13163 | return []; |
| 13164 | |
| 13165 | if (typeof evlistener === 'function') |
| 13166 | return unwrap ? [evlistener.listener || evlistener] : [evlistener]; |
| 13167 | |
| 13168 | return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); |
| 13169 | } |
| 13170 | |
| 13171 | EventEmitter.prototype.listeners = function listeners(type) { |
| 13172 | return _listeners(this, type, true); |
| 13173 | }; |
| 13174 | |
| 13175 | EventEmitter.prototype.rawListeners = function rawListeners(type) { |
| 13176 | return _listeners(this, type, false); |
| 13177 | }; |
| 13178 | |
| 13179 | EventEmitter.listenerCount = function(emitter, type) { |
| 13180 | if (typeof emitter.listenerCount === 'function') { |
| 13181 | return emitter.listenerCount(type); |
| 13182 | } else { |
| 13183 | return listenerCount.call(emitter, type); |
| 13184 | } |
| 13185 | }; |
| 13186 | |
| 13187 | EventEmitter.prototype.listenerCount = listenerCount; |
| 13188 | function listenerCount(type) { |
| 13189 | var events = this._events; |
| 13190 | |
| 13191 | if (events) { |
| 13192 | var evlistener = events[type]; |
| 13193 | |
| 13194 | if (typeof evlistener === 'function') { |
| 13195 | return 1; |
| 13196 | } else if (evlistener) { |
| 13197 | return evlistener.length; |
| 13198 | } |
| 13199 | } |
| 13200 | |
| 13201 | return 0; |
| 13202 | } |
| 13203 | |
| 13204 | EventEmitter.prototype.eventNames = function eventNames() { |
| 13205 | return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; |
| 13206 | }; |
| 13207 | |
| 13208 | // About 1.5x faster than the two-arg version of Array#splice(). |
| 13209 | function spliceOne(list, index) { |
| 13210 | for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) |
| 13211 | list[i] = list[k]; |
| 13212 | list.pop(); |
| 13213 | } |
| 13214 | |
| 13215 | function arrayClone(arr, n) { |
| 13216 | var copy = new Array(n); |
| 13217 | for (var i = 0; i < n; ++i) |
| 13218 | copy[i] = arr[i]; |
| 13219 | return copy; |
| 13220 | } |
| 13221 | |
| 13222 | function unwrapListeners(arr) { |
| 13223 | var ret = new Array(arr.length); |
| 13224 | for (var i = 0; i < ret.length; ++i) { |
| 13225 | ret[i] = arr[i].listener || arr[i]; |
| 13226 | } |
| 13227 | return ret; |
| 13228 | } |
| 13229 | |
| 13230 | function objectCreatePolyfill(proto) { |
| 13231 | var F = function() {}; |
| 13232 | F.prototype = proto; |
| 13233 | return new F; |
| 13234 | } |
| 13235 | function objectKeysPolyfill(obj) { |
| 13236 | var keys = []; |
| 13237 | for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) { |
| 13238 | keys.push(k); |
| 13239 | } |
| 13240 | return k; |
| 13241 | } |
| 13242 | function functionBindPolyfill(context) { |
| 13243 | var fn = this; |
| 13244 | return function () { |
| 13245 | return fn.apply(context, arguments); |
| 13246 | }; |
| 13247 | } |
| 13248 | |
| 13249 | },{}],51:[function(require,module,exports){ |
| 13250 | 'use strict'; |
| 13251 | |
| 13252 | /* eslint no-invalid-this: 1 */ |
| 13253 | |
| 13254 | var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; |
| 13255 | var slice = Array.prototype.slice; |
| 13256 | var toStr = Object.prototype.toString; |
| 13257 | var funcType = '[object Function]'; |
| 13258 | |
| 13259 | module.exports = function bind(that) { |
| 13260 | var target = this; |
| 13261 | if (typeof target !== 'function' || toStr.call(target) !== funcType) { |
| 13262 | throw new TypeError(ERROR_MESSAGE + target); |
| 13263 | } |
| 13264 | var args = slice.call(arguments, 1); |
| 13265 | |
| 13266 | var bound; |
| 13267 | var binder = function () { |
| 13268 | if (this instanceof bound) { |
| 13269 | var result = target.apply( |
| 13270 | this, |
| 13271 | args.concat(slice.call(arguments)) |
| 13272 | ); |
| 13273 | if (Object(result) === result) { |
| 13274 | return result; |
| 13275 | } |
| 13276 | return this; |
| 13277 | } else { |
| 13278 | return target.apply( |
| 13279 | that, |
| 13280 | args.concat(slice.call(arguments)) |
| 13281 | ); |
| 13282 | } |
| 13283 | }; |
| 13284 | |
| 13285 | var boundLength = Math.max(0, target.length - args.length); |
| 13286 | var boundArgs = []; |
| 13287 | for (var i = 0; i < boundLength; i++) { |
| 13288 | boundArgs.push('$' + i); |
| 13289 | } |
| 13290 | |
| 13291 | bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder); |
| 13292 | |
| 13293 | if (target.prototype) { |
| 13294 | var Empty = function Empty() {}; |
| 13295 | Empty.prototype = target.prototype; |
| 13296 | bound.prototype = new Empty(); |
| 13297 | Empty.prototype = null; |
| 13298 | } |
| 13299 | |
| 13300 | return bound; |
| 13301 | }; |
| 13302 | |
| 13303 | },{}],52:[function(require,module,exports){ |
| 13304 | 'use strict'; |
| 13305 | |
| 13306 | var implementation = require('./implementation'); |
| 13307 | |
| 13308 | module.exports = Function.prototype.bind || implementation; |
| 13309 | |
| 13310 | },{"./implementation":51}],53:[function(require,module,exports){ |
| 13311 | 'use strict'; |
| 13312 | |
| 13313 | /* eslint complexity: [2, 17], max-statements: [2, 33] */ |
| 13314 | module.exports = function hasSymbols() { |
| 13315 | if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } |
| 13316 | if (typeof Symbol.iterator === 'symbol') { return true; } |
| 13317 | |
| 13318 | var obj = {}; |
| 13319 | var sym = Symbol('test'); |
| 13320 | var symObj = Object(sym); |
| 13321 | if (typeof sym === 'string') { return false; } |
| 13322 | |
| 13323 | if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } |
| 13324 | if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } |
| 13325 | |
| 13326 | // temp disabled per https://github.com/ljharb/object.assign/issues/17 |
| 13327 | // if (sym instanceof Symbol) { return false; } |
| 13328 | // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 |
| 13329 | // if (!(symObj instanceof Symbol)) { return false; } |
| 13330 | |
| 13331 | // if (typeof Symbol.prototype.toString !== 'function') { return false; } |
| 13332 | // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } |
| 13333 | |
| 13334 | var symVal = 42; |
| 13335 | obj[sym] = symVal; |
| 13336 | for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax |
| 13337 | if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } |
| 13338 | |
| 13339 | if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } |
| 13340 | |
| 13341 | var syms = Object.getOwnPropertySymbols(obj); |
| 13342 | if (syms.length !== 1 || syms[0] !== sym) { return false; } |
| 13343 | |
| 13344 | if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } |
| 13345 | |
| 13346 | if (typeof Object.getOwnPropertyDescriptor === 'function') { |
| 13347 | var descriptor = Object.getOwnPropertyDescriptor(obj, sym); |
| 13348 | if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } |
| 13349 | } |
| 13350 | |
| 13351 | return true; |
| 13352 | }; |
| 13353 | |
| 13354 | },{}],54:[function(require,module,exports){ |
| 13355 | (function (global){ |
| 13356 | /*! https://mths.be/he v1.2.0 by @mathias | MIT license */ |
| 13357 | ;(function(root) { |
| 13358 | |
| 13359 | // Detect free variables `exports`. |
| 13360 | var freeExports = typeof exports == 'object' && exports; |
| 13361 | |
| 13362 | // Detect free variable `module`. |
| 13363 | var freeModule = typeof module == 'object' && module && |
| 13364 | module.exports == freeExports && module; |
| 13365 | |
| 13366 | // Detect free variable `global`, from Node.js or Browserified code, |
| 13367 | // and use it as `root`. |
| 13368 | var freeGlobal = typeof global == 'object' && global; |
| 13369 | if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { |
| 13370 | root = freeGlobal; |
| 13371 | } |
| 13372 | |
| 13373 | /*--------------------------------------------------------------------------*/ |
| 13374 | |
| 13375 | // All astral symbols. |
| 13376 | var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; |
| 13377 | // All ASCII symbols (not just printable ASCII) except those listed in the |
| 13378 | // first column of the overrides table. |
| 13379 | // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides |
| 13380 | var regexAsciiWhitelist = /[\x01-\x7F]/g; |
| 13381 | // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or |
| 13382 | // code points listed in the first column of the overrides table on |
| 13383 | // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides. |
| 13384 | var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g; |
| 13385 | |
| 13386 | 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; |
| 13387 | var encodeMap = {'\xAD':'shy','\u200C':'zwnj','\u200D':'zwj','\u200E':'lrm','\u2063':'ic','\u2062':'it','\u2061':'af','\u200F':'rlm','\u200B':'ZeroWidthSpace','\u2060':'NoBreak','\u0311':'DownBreve','\u20DB':'tdot','\u20DC':'DotDot','\t':'Tab','\n':'NewLine','\u2008':'puncsp','\u205F':'MediumSpace','\u2009':'thinsp','\u200A':'hairsp','\u2004':'emsp13','\u2002':'ensp','\u2005':'emsp14','\u2003':'emsp','\u2007':'numsp','\xA0':'nbsp','\u205F\u200A':'ThickSpace','\u203E':'oline','_':'lowbar','\u2010':'dash','\u2013':'ndash','\u2014':'mdash','\u2015':'horbar',',':'comma',';':'semi','\u204F':'bsemi',':':'colon','\u2A74':'Colone','!':'excl','\xA1':'iexcl','?':'quest','\xBF':'iquest','.':'period','\u2025':'nldr','\u2026':'mldr','\xB7':'middot','\'':'apos','\u2018':'lsquo','\u2019':'rsquo','\u201A':'sbquo','\u2039':'lsaquo','\u203A':'rsaquo','"':'quot','\u201C':'ldquo','\u201D':'rdquo','\u201E':'bdquo','\xAB':'laquo','\xBB':'raquo','(':'lpar',')':'rpar','[':'lsqb',']':'rsqb','{':'lcub','}':'rcub','\u2308':'lceil','\u2309':'rceil','\u230A':'lfloor','\u230B':'rfloor','\u2985':'lopar','\u2986':'ropar','\u298B':'lbrke','\u298C':'rbrke','\u298D':'lbrkslu','\u298E':'rbrksld','\u298F':'lbrksld','\u2990':'rbrkslu','\u2991':'langd','\u2992':'rangd','\u2993':'lparlt','\u2994':'rpargt','\u2995':'gtlPar','\u2996':'ltrPar','\u27E6':'lobrk','\u27E7':'robrk','\u27E8':'lang','\u27E9':'rang','\u27EA':'Lang','\u27EB':'Rang','\u27EC':'loang','\u27ED':'roang','\u2772':'lbbrk','\u2773':'rbbrk','\u2016':'Vert','\xA7':'sect','\xB6':'para','@':'commat','*':'ast','/':'sol','undefined':null,'&':'amp','#':'num','%':'percnt','\u2030':'permil','\u2031':'pertenk','\u2020':'dagger','\u2021':'Dagger','\u2022':'bull','\u2043':'hybull','\u2032':'prime','\u2033':'Prime','\u2034':'tprime','\u2057':'qprime','\u2035':'bprime','\u2041':'caret','`':'grave','\xB4':'acute','\u02DC':'tilde','^':'Hat','\xAF':'macr','\u02D8':'breve','\u02D9':'dot','\xA8':'die','\u02DA':'ring','\u02DD':'dblac','\xB8':'cedil','\u02DB':'ogon','\u02C6':'circ','\u02C7':'caron','\xB0':'deg','\xA9':'copy','\xAE':'reg','\u2117':'copysr','\u2118':'wp','\u211E':'rx','\u2127':'mho','\u2129':'iiota','\u2190':'larr','\u219A':'nlarr','\u2192':'rarr','\u219B':'nrarr','\u2191':'uarr','\u2193':'darr','\u2194':'harr','\u21AE':'nharr','\u2195':'varr','\u2196':'nwarr','\u2197':'nearr','\u2198':'searr','\u2199':'swarr','\u219D':'rarrw','\u219D\u0338':'nrarrw','\u219E':'Larr','\u219F':'Uarr','\u21A0':'Rarr','\u21A1':'Darr','\u21A2':'larrtl','\u21A3':'rarrtl','\u21A4':'mapstoleft','\u21A5':'mapstoup','\u21A6':'map','\u21A7':'mapstodown','\u21A9':'larrhk','\u21AA':'rarrhk','\u21AB':'larrlp','\u21AC':'rarrlp','\u21AD':'harrw','\u21B0':'lsh','\u21B1':'rsh','\u21B2':'ldsh','\u21B3':'rdsh','\u21B5':'crarr','\u21B6':'cularr','\u21B7':'curarr','\u21BA':'olarr','\u21BB':'orarr','\u21BC':'lharu','\u21BD':'lhard','\u21BE':'uharr','\u21BF':'uharl','\u21C0':'rharu','\u21C1':'rhard','\u21C2':'dharr','\u21C3':'dharl','\u21C4':'rlarr','\u21C5':'udarr','\u21C6':'lrarr','\u21C7':'llarr','\u21C8':'uuarr','\u21C9':'rrarr','\u21CA':'ddarr','\u21CB':'lrhar','\u21CC':'rlhar','\u21D0':'lArr','\u21CD':'nlArr','\u21D1':'uArr','\u21D2':'rArr','\u21CF':'nrArr','\u21D3':'dArr','\u21D4':'iff','\u21CE':'nhArr','\u21D5':'vArr','\u21D6':'nwArr','\u21D7':'neArr','\u21D8':'seArr','\u21D9':'swArr','\u21DA':'lAarr','\u21DB':'rAarr','\u21DD':'zigrarr','\u21E4':'larrb','\u21E5':'rarrb','\u21F5':'duarr','\u21FD':'loarr','\u21FE':'roarr','\u21FF':'hoarr','\u2200':'forall','\u2201':'comp','\u2202':'part','\u2202\u0338':'npart','\u2203':'exist','\u2204':'nexist','\u2205':'empty','\u2207':'Del','\u2208':'in','\u2209':'notin','\u220B':'ni','\u220C':'notni','\u03F6':'bepsi','\u220F':'prod','\u2210':'coprod','\u2211':'sum','+':'plus','\xB1':'pm','\xF7':'div','\xD7':'times','<':'lt','\u226E':'nlt','<\u20D2':'nvlt','=':'equals','\u2260':'ne','=\u20E5':'bne','\u2A75':'Equal','>':'gt','\u226F':'ngt','>\u20D2':'nvgt','\xAC':'not','|':'vert','\xA6':'brvbar','\u2212':'minus','\u2213':'mp','\u2214':'plusdo','\u2044':'frasl','\u2216':'setmn','\u2217':'lowast','\u2218':'compfn','\u221A':'Sqrt','\u221D':'prop','\u221E':'infin','\u221F':'angrt','\u2220':'ang','\u2220\u20D2':'nang','\u2221':'angmsd','\u2222':'angsph','\u2223':'mid','\u2224':'nmid','\u2225':'par','\u2226':'npar','\u2227':'and','\u2228':'or','\u2229':'cap','\u2229\uFE00':'caps','\u222A':'cup','\u222A\uFE00':'cups','\u222B':'int','\u222C':'Int','\u222D':'tint','\u2A0C':'qint','\u222E':'oint','\u222F':'Conint','\u2230':'Cconint','\u2231':'cwint','\u2232':'cwconint','\u2233':'awconint','\u2234':'there4','\u2235':'becaus','\u2236':'ratio','\u2237':'Colon','\u2238':'minusd','\u223A':'mDDot','\u223B':'homtht','\u223C':'sim','\u2241':'nsim','\u223C\u20D2':'nvsim','\u223D':'bsim','\u223D\u0331':'race','\u223E':'ac','\u223E\u0333':'acE','\u223F':'acd','\u2240':'wr','\u2242':'esim','\u2242\u0338':'nesim','\u2243':'sime','\u2244':'nsime','\u2245':'cong','\u2247':'ncong','\u2246':'simne','\u2248':'ap','\u2249':'nap','\u224A':'ape','\u224B':'apid','\u224B\u0338':'napid','\u224C':'bcong','\u224D':'CupCap','\u226D':'NotCupCap','\u224D\u20D2':'nvap','\u224E':'bump','\u224E\u0338':'nbump','\u224F':'bumpe','\u224F\u0338':'nbumpe','\u2250':'doteq','\u2250\u0338':'nedot','\u2251':'eDot','\u2252':'efDot','\u2253':'erDot','\u2254':'colone','\u2255':'ecolon','\u2256':'ecir','\u2257':'cire','\u2259':'wedgeq','\u225A':'veeeq','\u225C':'trie','\u225F':'equest','\u2261':'equiv','\u2262':'nequiv','\u2261\u20E5':'bnequiv','\u2264':'le','\u2270':'nle','\u2264\u20D2':'nvle','\u2265':'ge','\u2271':'nge','\u2265\u20D2':'nvge','\u2266':'lE','\u2266\u0338':'nlE','\u2267':'gE','\u2267\u0338':'ngE','\u2268\uFE00':'lvnE','\u2268':'lnE','\u2269':'gnE','\u2269\uFE00':'gvnE','\u226A':'ll','\u226A\u0338':'nLtv','\u226A\u20D2':'nLt','\u226B':'gg','\u226B\u0338':'nGtv','\u226B\u20D2':'nGt','\u226C':'twixt','\u2272':'lsim','\u2274':'nlsim','\u2273':'gsim','\u2275':'ngsim','\u2276':'lg','\u2278':'ntlg','\u2277':'gl','\u2279':'ntgl','\u227A':'pr','\u2280':'npr','\u227B':'sc','\u2281':'nsc','\u227C':'prcue','\u22E0':'nprcue','\u227D':'sccue','\u22E1':'nsccue','\u227E':'prsim','\u227F':'scsim','\u227F\u0338':'NotSucceedsTilde','\u2282':'sub','\u2284':'nsub','\u2282\u20D2':'vnsub','\u2283':'sup','\u2285':'nsup','\u2283\u20D2':'vnsup','\u2286':'sube','\u2288':'nsube','\u2287':'supe','\u2289':'nsupe','\u228A\uFE00':'vsubne','\u228A':'subne','\u228B\uFE00':'vsupne','\u228B':'supne','\u228D':'cupdot','\u228E':'uplus','\u228F':'sqsub','\u228F\u0338':'NotSquareSubset','\u2290':'sqsup','\u2290\u0338':'NotSquareSuperset','\u2291':'sqsube','\u22E2':'nsqsube','\u2292':'sqsupe','\u22E3':'nsqsupe','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u2295':'oplus','\u2296':'ominus','\u2297':'otimes','\u2298':'osol','\u2299':'odot','\u229A':'ocir','\u229B':'oast','\u229D':'odash','\u229E':'plusb','\u229F':'minusb','\u22A0':'timesb','\u22A1':'sdotb','\u22A2':'vdash','\u22AC':'nvdash','\u22A3':'dashv','\u22A4':'top','\u22A5':'bot','\u22A7':'models','\u22A8':'vDash','\u22AD':'nvDash','\u22A9':'Vdash','\u22AE':'nVdash','\u22AA':'Vvdash','\u22AB':'VDash','\u22AF':'nVDash','\u22B0':'prurel','\u22B2':'vltri','\u22EA':'nltri','\u22B3':'vrtri','\u22EB':'nrtri','\u22B4':'ltrie','\u22EC':'nltrie','\u22B4\u20D2':'nvltrie','\u22B5':'rtrie','\u22ED':'nrtrie','\u22B5\u20D2':'nvrtrie','\u22B6':'origof','\u22B7':'imof','\u22B8':'mumap','\u22B9':'hercon','\u22BA':'intcal','\u22BB':'veebar','\u22BD':'barvee','\u22BE':'angrtvb','\u22BF':'lrtri','\u22C0':'Wedge','\u22C1':'Vee','\u22C2':'xcap','\u22C3':'xcup','\u22C4':'diam','\u22C5':'sdot','\u22C6':'Star','\u22C7':'divonx','\u22C8':'bowtie','\u22C9':'ltimes','\u22CA':'rtimes','\u22CB':'lthree','\u22CC':'rthree','\u22CD':'bsime','\u22CE':'cuvee','\u22CF':'cuwed','\u22D0':'Sub','\u22D1':'Sup','\u22D2':'Cap','\u22D3':'Cup','\u22D4':'fork','\u22D5':'epar','\u22D6':'ltdot','\u22D7':'gtdot','\u22D8':'Ll','\u22D8\u0338':'nLl','\u22D9':'Gg','\u22D9\u0338':'nGg','\u22DA\uFE00':'lesg','\u22DA':'leg','\u22DB':'gel','\u22DB\uFE00':'gesl','\u22DE':'cuepr','\u22DF':'cuesc','\u22E6':'lnsim','\u22E7':'gnsim','\u22E8':'prnsim','\u22E9':'scnsim','\u22EE':'vellip','\u22EF':'ctdot','\u22F0':'utdot','\u22F1':'dtdot','\u22F2':'disin','\u22F3':'isinsv','\u22F4':'isins','\u22F5':'isindot','\u22F5\u0338':'notindot','\u22F6':'notinvc','\u22F7':'notinvb','\u22F9':'isinE','\u22F9\u0338':'notinE','\u22FA':'nisd','\u22FB':'xnis','\u22FC':'nis','\u22FD':'notnivc','\u22FE':'notnivb','\u2305':'barwed','\u2306':'Barwed','\u230C':'drcrop','\u230D':'dlcrop','\u230E':'urcrop','\u230F':'ulcrop','\u2310':'bnot','\u2312':'profline','\u2313':'profsurf','\u2315':'telrec','\u2316':'target','\u231C':'ulcorn','\u231D':'urcorn','\u231E':'dlcorn','\u231F':'drcorn','\u2322':'frown','\u2323':'smile','\u232D':'cylcty','\u232E':'profalar','\u2336':'topbot','\u233D':'ovbar','\u233F':'solbar','\u237C':'angzarr','\u23B0':'lmoust','\u23B1':'rmoust','\u23B4':'tbrk','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u23DC':'OverParenthesis','\u23DD':'UnderParenthesis','\u23DE':'OverBrace','\u23DF':'UnderBrace','\u23E2':'trpezium','\u23E7':'elinters','\u2423':'blank','\u2500':'boxh','\u2502':'boxv','\u250C':'boxdr','\u2510':'boxdl','\u2514':'boxur','\u2518':'boxul','\u251C':'boxvr','\u2524':'boxvl','\u252C':'boxhd','\u2534':'boxhu','\u253C':'boxvh','\u2550':'boxH','\u2551':'boxV','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2580':'uhblk','\u2584':'lhblk','\u2588':'block','\u2591':'blk14','\u2592':'blk12','\u2593':'blk34','\u25A1':'squ','\u25AA':'squf','\u25AB':'EmptyVerySmallSquare','\u25AD':'rect','\u25AE':'marker','\u25B1':'fltns','\u25B3':'xutri','\u25B4':'utrif','\u25B5':'utri','\u25B8':'rtrif','\u25B9':'rtri','\u25BD':'xdtri','\u25BE':'dtrif','\u25BF':'dtri','\u25C2':'ltrif','\u25C3':'ltri','\u25CA':'loz','\u25CB':'cir','\u25EC':'tridot','\u25EF':'xcirc','\u25F8':'ultri','\u25F9':'urtri','\u25FA':'lltri','\u25FB':'EmptySmallSquare','\u25FC':'FilledSmallSquare','\u2605':'starf','\u2606':'star','\u260E':'phone','\u2640':'female','\u2642':'male','\u2660':'spades','\u2663':'clubs','\u2665':'hearts','\u2666':'diams','\u266A':'sung','\u2713':'check','\u2717':'cross','\u2720':'malt','\u2736':'sext','\u2758':'VerticalSeparator','\u27C8':'bsolhsub','\u27C9':'suphsol','\u27F5':'xlarr','\u27F6':'xrarr','\u27F7':'xharr','\u27F8':'xlArr','\u27F9':'xrArr','\u27FA':'xhArr','\u27FC':'xmap','\u27FF':'dzigrarr','\u2902':'nvlArr','\u2903':'nvrArr','\u2904':'nvHarr','\u2905':'Map','\u290C':'lbarr','\u290D':'rbarr','\u290E':'lBarr','\u290F':'rBarr','\u2910':'RBarr','\u2911':'DDotrahd','\u2912':'UpArrowBar','\u2913':'DownArrowBar','\u2916':'Rarrtl','\u2919':'latail','\u291A':'ratail','\u291B':'lAtail','\u291C':'rAtail','\u291D':'larrfs','\u291E':'rarrfs','\u291F':'larrbfs','\u2920':'rarrbfs','\u2923':'nwarhk','\u2924':'nearhk','\u2925':'searhk','\u2926':'swarhk','\u2927':'nwnear','\u2928':'toea','\u2929':'tosa','\u292A':'swnwar','\u2933':'rarrc','\u2933\u0338':'nrarrc','\u2935':'cudarrr','\u2936':'ldca','\u2937':'rdca','\u2938':'cudarrl','\u2939':'larrpl','\u293C':'curarrm','\u293D':'cularrp','\u2945':'rarrpl','\u2948':'harrcir','\u2949':'Uarrocir','\u294A':'lurdshar','\u294B':'ldrushar','\u294E':'LeftRightVector','\u294F':'RightUpDownVector','\u2950':'DownLeftRightVector','\u2951':'LeftUpDownVector','\u2952':'LeftVectorBar','\u2953':'RightVectorBar','\u2954':'RightUpVectorBar','\u2955':'RightDownVectorBar','\u2956':'DownLeftVectorBar','\u2957':'DownRightVectorBar','\u2958':'LeftUpVectorBar','\u2959':'LeftDownVectorBar','\u295A':'LeftTeeVector','\u295B':'RightTeeVector','\u295C':'RightUpTeeVector','\u295D':'RightDownTeeVector','\u295E':'DownLeftTeeVector','\u295F':'DownRightTeeVector','\u2960':'LeftUpTeeVector','\u2961':'LeftDownTeeVector','\u2962':'lHar','\u2963':'uHar','\u2964':'rHar','\u2965':'dHar','\u2966':'luruhar','\u2967':'ldrdhar','\u2968':'ruluhar','\u2969':'rdldhar','\u296A':'lharul','\u296B':'llhard','\u296C':'rharul','\u296D':'lrhard','\u296E':'udhar','\u296F':'duhar','\u2970':'RoundImplies','\u2971':'erarr','\u2972':'simrarr','\u2973':'larrsim','\u2974':'rarrsim','\u2975':'rarrap','\u2976':'ltlarr','\u2978':'gtrarr','\u2979':'subrarr','\u297B':'suplarr','\u297C':'lfisht','\u297D':'rfisht','\u297E':'ufisht','\u297F':'dfisht','\u299A':'vzigzag','\u299C':'vangrt','\u299D':'angrtvbd','\u29A4':'ange','\u29A5':'range','\u29A6':'dwangle','\u29A7':'uwangle','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u29B0':'bemptyv','\u29B1':'demptyv','\u29B2':'cemptyv','\u29B3':'raemptyv','\u29B4':'laemptyv','\u29B5':'ohbar','\u29B6':'omid','\u29B7':'opar','\u29B9':'operp','\u29BB':'olcross','\u29BC':'odsold','\u29BE':'olcir','\u29BF':'ofcir','\u29C0':'olt','\u29C1':'ogt','\u29C2':'cirscir','\u29C3':'cirE','\u29C4':'solb','\u29C5':'bsolb','\u29C9':'boxbox','\u29CD':'trisb','\u29CE':'rtriltri','\u29CF':'LeftTriangleBar','\u29CF\u0338':'NotLeftTriangleBar','\u29D0':'RightTriangleBar','\u29D0\u0338':'NotRightTriangleBar','\u29DC':'iinfin','\u29DD':'infintie','\u29DE':'nvinfin','\u29E3':'eparsl','\u29E4':'smeparsl','\u29E5':'eqvparsl','\u29EB':'lozf','\u29F4':'RuleDelayed','\u29F6':'dsol','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A04':'xuplus','\u2A06':'xsqcup','\u2A0D':'fpartint','\u2A10':'cirfnint','\u2A11':'awint','\u2A12':'rppolint','\u2A13':'scpolint','\u2A14':'npolint','\u2A15':'pointint','\u2A16':'quatint','\u2A17':'intlarhk','\u2A22':'pluscir','\u2A23':'plusacir','\u2A24':'simplus','\u2A25':'plusdu','\u2A26':'plussim','\u2A27':'plustwo','\u2A29':'mcomma','\u2A2A':'minusdu','\u2A2D':'loplus','\u2A2E':'roplus','\u2A2F':'Cross','\u2A30':'timesd','\u2A31':'timesbar','\u2A33':'smashp','\u2A34':'lotimes','\u2A35':'rotimes','\u2A36':'otimesas','\u2A37':'Otimes','\u2A38':'odiv','\u2A39':'triplus','\u2A3A':'triminus','\u2A3B':'tritime','\u2A3C':'iprod','\u2A3F':'amalg','\u2A40':'capdot','\u2A42':'ncup','\u2A43':'ncap','\u2A44':'capand','\u2A45':'cupor','\u2A46':'cupcap','\u2A47':'capcup','\u2A48':'cupbrcap','\u2A49':'capbrcup','\u2A4A':'cupcup','\u2A4B':'capcap','\u2A4C':'ccups','\u2A4D':'ccaps','\u2A50':'ccupssm','\u2A53':'And','\u2A54':'Or','\u2A55':'andand','\u2A56':'oror','\u2A57':'orslope','\u2A58':'andslope','\u2A5A':'andv','\u2A5B':'orv','\u2A5C':'andd','\u2A5D':'ord','\u2A5F':'wedbar','\u2A66':'sdote','\u2A6A':'simdot','\u2A6D':'congdot','\u2A6D\u0338':'ncongdot','\u2A6E':'easter','\u2A6F':'apacir','\u2A70':'apE','\u2A70\u0338':'napE','\u2A71':'eplus','\u2A72':'pluse','\u2A73':'Esim','\u2A77':'eDDot','\u2A78':'equivDD','\u2A79':'ltcir','\u2A7A':'gtcir','\u2A7B':'ltquest','\u2A7C':'gtquest','\u2A7D':'les','\u2A7D\u0338':'nles','\u2A7E':'ges','\u2A7E\u0338':'nges','\u2A7F':'lesdot','\u2A80':'gesdot','\u2A81':'lesdoto','\u2A82':'gesdoto','\u2A83':'lesdotor','\u2A84':'gesdotol','\u2A85':'lap','\u2A86':'gap','\u2A87':'lne','\u2A88':'gne','\u2A89':'lnap','\u2A8A':'gnap','\u2A8B':'lEg','\u2A8C':'gEl','\u2A8D':'lsime','\u2A8E':'gsime','\u2A8F':'lsimg','\u2A90':'gsiml','\u2A91':'lgE','\u2A92':'glE','\u2A93':'lesges','\u2A94':'gesles','\u2A95':'els','\u2A96':'egs','\u2A97':'elsdot','\u2A98':'egsdot','\u2A99':'el','\u2A9A':'eg','\u2A9D':'siml','\u2A9E':'simg','\u2A9F':'simlE','\u2AA0':'simgE','\u2AA1':'LessLess','\u2AA1\u0338':'NotNestedLessLess','\u2AA2':'GreaterGreater','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA4':'glj','\u2AA5':'gla','\u2AA6':'ltcc','\u2AA7':'gtcc','\u2AA8':'lescc','\u2AA9':'gescc','\u2AAA':'smt','\u2AAB':'lat','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u2AAD':'late','\u2AAD\uFE00':'lates','\u2AAE':'bumpE','\u2AAF':'pre','\u2AAF\u0338':'npre','\u2AB0':'sce','\u2AB0\u0338':'nsce','\u2AB3':'prE','\u2AB4':'scE','\u2AB5':'prnE','\u2AB6':'scnE','\u2AB7':'prap','\u2AB8':'scap','\u2AB9':'prnap','\u2ABA':'scnap','\u2ABB':'Pr','\u2ABC':'Sc','\u2ABD':'subdot','\u2ABE':'supdot','\u2ABF':'subplus','\u2AC0':'supplus','\u2AC1':'submult','\u2AC2':'supmult','\u2AC3':'subedot','\u2AC4':'supedot','\u2AC5':'subE','\u2AC5\u0338':'nsubE','\u2AC6':'supE','\u2AC6\u0338':'nsupE','\u2AC7':'subsim','\u2AC8':'supsim','\u2ACB\uFE00':'vsubnE','\u2ACB':'subnE','\u2ACC\uFE00':'vsupnE','\u2ACC':'supnE','\u2ACF':'csub','\u2AD0':'csup','\u2AD1':'csube','\u2AD2':'csupe','\u2AD3':'subsup','\u2AD4':'supsub','\u2AD5':'subsub','\u2AD6':'supsup','\u2AD7':'suphsub','\u2AD8':'supdsub','\u2AD9':'forkv','\u2ADA':'topfork','\u2ADB':'mlcp','\u2AE4':'Dashv','\u2AE6':'Vdashl','\u2AE7':'Barv','\u2AE8':'vBar','\u2AE9':'vBarv','\u2AEB':'Vbar','\u2AEC':'Not','\u2AED':'bNot','\u2AEE':'rnmid','\u2AEF':'cirmid','\u2AF0':'midcir','\u2AF1':'topcir','\u2AF2':'nhpar','\u2AF3':'parsim','\u2AFD':'parsl','\u2AFD\u20E5':'nparsl','\u266D':'flat','\u266E':'natur','\u266F':'sharp','\xA4':'curren','\xA2':'cent','$':'dollar','\xA3':'pound','\xA5':'yen','\u20AC':'euro','\xB9':'sup1','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\xB2':'sup2','\u2154':'frac23','\u2156':'frac25','\xB3':'sup3','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\uD835\uDCB6':'ascr','\uD835\uDD52':'aopf','\uD835\uDD1E':'afr','\uD835\uDD38':'Aopf','\uD835\uDD04':'Afr','\uD835\uDC9C':'Ascr','\xAA':'ordf','\xE1':'aacute','\xC1':'Aacute','\xE0':'agrave','\xC0':'Agrave','\u0103':'abreve','\u0102':'Abreve','\xE2':'acirc','\xC2':'Acirc','\xE5':'aring','\xC5':'angst','\xE4':'auml','\xC4':'Auml','\xE3':'atilde','\xC3':'Atilde','\u0105':'aogon','\u0104':'Aogon','\u0101':'amacr','\u0100':'Amacr','\xE6':'aelig','\xC6':'AElig','\uD835\uDCB7':'bscr','\uD835\uDD53':'bopf','\uD835\uDD1F':'bfr','\uD835\uDD39':'Bopf','\u212C':'Bscr','\uD835\uDD05':'Bfr','\uD835\uDD20':'cfr','\uD835\uDCB8':'cscr','\uD835\uDD54':'copf','\u212D':'Cfr','\uD835\uDC9E':'Cscr','\u2102':'Copf','\u0107':'cacute','\u0106':'Cacute','\u0109':'ccirc','\u0108':'Ccirc','\u010D':'ccaron','\u010C':'Ccaron','\u010B':'cdot','\u010A':'Cdot','\xE7':'ccedil','\xC7':'Ccedil','\u2105':'incare','\uD835\uDD21':'dfr','\u2146':'dd','\uD835\uDD55':'dopf','\uD835\uDCB9':'dscr','\uD835\uDC9F':'Dscr','\uD835\uDD07':'Dfr','\u2145':'DD','\uD835\uDD3B':'Dopf','\u010F':'dcaron','\u010E':'Dcaron','\u0111':'dstrok','\u0110':'Dstrok','\xF0':'eth','\xD0':'ETH','\u2147':'ee','\u212F':'escr','\uD835\uDD22':'efr','\uD835\uDD56':'eopf','\u2130':'Escr','\uD835\uDD08':'Efr','\uD835\uDD3C':'Eopf','\xE9':'eacute','\xC9':'Eacute','\xE8':'egrave','\xC8':'Egrave','\xEA':'ecirc','\xCA':'Ecirc','\u011B':'ecaron','\u011A':'Ecaron','\xEB':'euml','\xCB':'Euml','\u0117':'edot','\u0116':'Edot','\u0119':'eogon','\u0118':'Eogon','\u0113':'emacr','\u0112':'Emacr','\uD835\uDD23':'ffr','\uD835\uDD57':'fopf','\uD835\uDCBB':'fscr','\uD835\uDD09':'Ffr','\uD835\uDD3D':'Fopf','\u2131':'Fscr','\uFB00':'fflig','\uFB03':'ffilig','\uFB04':'ffllig','\uFB01':'filig','fj':'fjlig','\uFB02':'fllig','\u0192':'fnof','\u210A':'gscr','\uD835\uDD58':'gopf','\uD835\uDD24':'gfr','\uD835\uDCA2':'Gscr','\uD835\uDD3E':'Gopf','\uD835\uDD0A':'Gfr','\u01F5':'gacute','\u011F':'gbreve','\u011E':'Gbreve','\u011D':'gcirc','\u011C':'Gcirc','\u0121':'gdot','\u0120':'Gdot','\u0122':'Gcedil','\uD835\uDD25':'hfr','\u210E':'planckh','\uD835\uDCBD':'hscr','\uD835\uDD59':'hopf','\u210B':'Hscr','\u210C':'Hfr','\u210D':'Hopf','\u0125':'hcirc','\u0124':'Hcirc','\u210F':'hbar','\u0127':'hstrok','\u0126':'Hstrok','\uD835\uDD5A':'iopf','\uD835\uDD26':'ifr','\uD835\uDCBE':'iscr','\u2148':'ii','\uD835\uDD40':'Iopf','\u2110':'Iscr','\u2111':'Im','\xED':'iacute','\xCD':'Iacute','\xEC':'igrave','\xCC':'Igrave','\xEE':'icirc','\xCE':'Icirc','\xEF':'iuml','\xCF':'Iuml','\u0129':'itilde','\u0128':'Itilde','\u0130':'Idot','\u012F':'iogon','\u012E':'Iogon','\u012B':'imacr','\u012A':'Imacr','\u0133':'ijlig','\u0132':'IJlig','\u0131':'imath','\uD835\uDCBF':'jscr','\uD835\uDD5B':'jopf','\uD835\uDD27':'jfr','\uD835\uDCA5':'Jscr','\uD835\uDD0D':'Jfr','\uD835\uDD41':'Jopf','\u0135':'jcirc','\u0134':'Jcirc','\u0237':'jmath','\uD835\uDD5C':'kopf','\uD835\uDCC0':'kscr','\uD835\uDD28':'kfr','\uD835\uDCA6':'Kscr','\uD835\uDD42':'Kopf','\uD835\uDD0E':'Kfr','\u0137':'kcedil','\u0136':'Kcedil','\uD835\uDD29':'lfr','\uD835\uDCC1':'lscr','\u2113':'ell','\uD835\uDD5D':'lopf','\u2112':'Lscr','\uD835\uDD0F':'Lfr','\uD835\uDD43':'Lopf','\u013A':'lacute','\u0139':'Lacute','\u013E':'lcaron','\u013D':'Lcaron','\u013C':'lcedil','\u013B':'Lcedil','\u0142':'lstrok','\u0141':'Lstrok','\u0140':'lmidot','\u013F':'Lmidot','\uD835\uDD2A':'mfr','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\uD835\uDD10':'Mfr','\uD835\uDD44':'Mopf','\u2133':'Mscr','\uD835\uDD2B':'nfr','\uD835\uDD5F':'nopf','\uD835\uDCC3':'nscr','\u2115':'Nopf','\uD835\uDCA9':'Nscr','\uD835\uDD11':'Nfr','\u0144':'nacute','\u0143':'Nacute','\u0148':'ncaron','\u0147':'Ncaron','\xF1':'ntilde','\xD1':'Ntilde','\u0146':'ncedil','\u0145':'Ncedil','\u2116':'numero','\u014B':'eng','\u014A':'ENG','\uD835\uDD60':'oopf','\uD835\uDD2C':'ofr','\u2134':'oscr','\uD835\uDCAA':'Oscr','\uD835\uDD12':'Ofr','\uD835\uDD46':'Oopf','\xBA':'ordm','\xF3':'oacute','\xD3':'Oacute','\xF2':'ograve','\xD2':'Ograve','\xF4':'ocirc','\xD4':'Ocirc','\xF6':'ouml','\xD6':'Ouml','\u0151':'odblac','\u0150':'Odblac','\xF5':'otilde','\xD5':'Otilde','\xF8':'oslash','\xD8':'Oslash','\u014D':'omacr','\u014C':'Omacr','\u0153':'oelig','\u0152':'OElig','\uD835\uDD2D':'pfr','\uD835\uDCC5':'pscr','\uD835\uDD61':'popf','\u2119':'Popf','\uD835\uDD13':'Pfr','\uD835\uDCAB':'Pscr','\uD835\uDD62':'qopf','\uD835\uDD2E':'qfr','\uD835\uDCC6':'qscr','\uD835\uDCAC':'Qscr','\uD835\uDD14':'Qfr','\u211A':'Qopf','\u0138':'kgreen','\uD835\uDD2F':'rfr','\uD835\uDD63':'ropf','\uD835\uDCC7':'rscr','\u211B':'Rscr','\u211C':'Re','\u211D':'Ropf','\u0155':'racute','\u0154':'Racute','\u0159':'rcaron','\u0158':'Rcaron','\u0157':'rcedil','\u0156':'Rcedil','\uD835\uDD64':'sopf','\uD835\uDCC8':'sscr','\uD835\uDD30':'sfr','\uD835\uDD4A':'Sopf','\uD835\uDD16':'Sfr','\uD835\uDCAE':'Sscr','\u24C8':'oS','\u015B':'sacute','\u015A':'Sacute','\u015D':'scirc','\u015C':'Scirc','\u0161':'scaron','\u0160':'Scaron','\u015F':'scedil','\u015E':'Scedil','\xDF':'szlig','\uD835\uDD31':'tfr','\uD835\uDCC9':'tscr','\uD835\uDD65':'topf','\uD835\uDCAF':'Tscr','\uD835\uDD17':'Tfr','\uD835\uDD4B':'Topf','\u0165':'tcaron','\u0164':'Tcaron','\u0163':'tcedil','\u0162':'Tcedil','\u2122':'trade','\u0167':'tstrok','\u0166':'Tstrok','\uD835\uDCCA':'uscr','\uD835\uDD66':'uopf','\uD835\uDD32':'ufr','\uD835\uDD4C':'Uopf','\uD835\uDD18':'Ufr','\uD835\uDCB0':'Uscr','\xFA':'uacute','\xDA':'Uacute','\xF9':'ugrave','\xD9':'Ugrave','\u016D':'ubreve','\u016C':'Ubreve','\xFB':'ucirc','\xDB':'Ucirc','\u016F':'uring','\u016E':'Uring','\xFC':'uuml','\xDC':'Uuml','\u0171':'udblac','\u0170':'Udblac','\u0169':'utilde','\u0168':'Utilde','\u0173':'uogon','\u0172':'Uogon','\u016B':'umacr','\u016A':'Umacr','\uD835\uDD33':'vfr','\uD835\uDD67':'vopf','\uD835\uDCCB':'vscr','\uD835\uDD19':'Vfr','\uD835\uDD4D':'Vopf','\uD835\uDCB1':'Vscr','\uD835\uDD68':'wopf','\uD835\uDCCC':'wscr','\uD835\uDD34':'wfr','\uD835\uDCB2':'Wscr','\uD835\uDD4E':'Wopf','\uD835\uDD1A':'Wfr','\u0175':'wcirc','\u0174':'Wcirc','\uD835\uDD35':'xfr','\uD835\uDCCD':'xscr','\uD835\uDD69':'xopf','\uD835\uDD4F':'Xopf','\uD835\uDD1B':'Xfr','\uD835\uDCB3':'Xscr','\uD835\uDD36':'yfr','\uD835\uDCCE':'yscr','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDD1C':'Yfr','\uD835\uDD50':'Yopf','\xFD':'yacute','\xDD':'Yacute','\u0177':'ycirc','\u0176':'Ycirc','\xFF':'yuml','\u0178':'Yuml','\uD835\uDCCF':'zscr','\uD835\uDD37':'zfr','\uD835\uDD6B':'zopf','\u2128':'Zfr','\u2124':'Zopf','\uD835\uDCB5':'Zscr','\u017A':'zacute','\u0179':'Zacute','\u017E':'zcaron','\u017D':'Zcaron','\u017C':'zdot','\u017B':'Zdot','\u01B5':'imped','\xFE':'thorn','\xDE':'THORN','\u0149':'napos','\u03B1':'alpha','\u0391':'Alpha','\u03B2':'beta','\u0392':'Beta','\u03B3':'gamma','\u0393':'Gamma','\u03B4':'delta','\u0394':'Delta','\u03B5':'epsi','\u03F5':'epsiv','\u0395':'Epsilon','\u03DD':'gammad','\u03DC':'Gammad','\u03B6':'zeta','\u0396':'Zeta','\u03B7':'eta','\u0397':'Eta','\u03B8':'theta','\u03D1':'thetav','\u0398':'Theta','\u03B9':'iota','\u0399':'Iota','\u03BA':'kappa','\u03F0':'kappav','\u039A':'Kappa','\u03BB':'lambda','\u039B':'Lambda','\u03BC':'mu','\xB5':'micro','\u039C':'Mu','\u03BD':'nu','\u039D':'Nu','\u03BE':'xi','\u039E':'Xi','\u03BF':'omicron','\u039F':'Omicron','\u03C0':'pi','\u03D6':'piv','\u03A0':'Pi','\u03C1':'rho','\u03F1':'rhov','\u03A1':'Rho','\u03C3':'sigma','\u03A3':'Sigma','\u03C2':'sigmaf','\u03C4':'tau','\u03A4':'Tau','\u03C5':'upsi','\u03A5':'Upsilon','\u03D2':'Upsi','\u03C6':'phi','\u03D5':'phiv','\u03A6':'Phi','\u03C7':'chi','\u03A7':'Chi','\u03C8':'psi','\u03A8':'Psi','\u03C9':'omega','\u03A9':'ohm','\u0430':'acy','\u0410':'Acy','\u0431':'bcy','\u0411':'Bcy','\u0432':'vcy','\u0412':'Vcy','\u0433':'gcy','\u0413':'Gcy','\u0453':'gjcy','\u0403':'GJcy','\u0434':'dcy','\u0414':'Dcy','\u0452':'djcy','\u0402':'DJcy','\u0435':'iecy','\u0415':'IEcy','\u0451':'iocy','\u0401':'IOcy','\u0454':'jukcy','\u0404':'Jukcy','\u0436':'zhcy','\u0416':'ZHcy','\u0437':'zcy','\u0417':'Zcy','\u0455':'dscy','\u0405':'DScy','\u0438':'icy','\u0418':'Icy','\u0456':'iukcy','\u0406':'Iukcy','\u0457':'yicy','\u0407':'YIcy','\u0439':'jcy','\u0419':'Jcy','\u0458':'jsercy','\u0408':'Jsercy','\u043A':'kcy','\u041A':'Kcy','\u045C':'kjcy','\u040C':'KJcy','\u043B':'lcy','\u041B':'Lcy','\u0459':'ljcy','\u0409':'LJcy','\u043C':'mcy','\u041C':'Mcy','\u043D':'ncy','\u041D':'Ncy','\u045A':'njcy','\u040A':'NJcy','\u043E':'ocy','\u041E':'Ocy','\u043F':'pcy','\u041F':'Pcy','\u0440':'rcy','\u0420':'Rcy','\u0441':'scy','\u0421':'Scy','\u0442':'tcy','\u0422':'Tcy','\u045B':'tshcy','\u040B':'TSHcy','\u0443':'ucy','\u0423':'Ucy','\u045E':'ubrcy','\u040E':'Ubrcy','\u0444':'fcy','\u0424':'Fcy','\u0445':'khcy','\u0425':'KHcy','\u0446':'tscy','\u0426':'TScy','\u0447':'chcy','\u0427':'CHcy','\u045F':'dzcy','\u040F':'DZcy','\u0448':'shcy','\u0428':'SHcy','\u0449':'shchcy','\u0429':'SHCHcy','\u044A':'hardcy','\u042A':'HARDcy','\u044B':'ycy','\u042B':'Ycy','\u044C':'softcy','\u042C':'SOFTcy','\u044D':'ecy','\u042D':'Ecy','\u044E':'yucy','\u042E':'YUcy','\u044F':'yacy','\u042F':'YAcy','\u2135':'aleph','\u2136':'beth','\u2137':'gimel','\u2138':'daleth'}; |
| 13388 | |
| 13389 | var regexEscape = /["&'<>`]/g; |
| 13390 | var escapeMap = { |
| 13391 | '"': '"', |
| 13392 | '&': '&', |
| 13393 | '\'': ''', |
| 13394 | '<': '<', |
| 13395 | // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the |
| 13396 | // following is not strictly necessary unless it’s part of a tag or an |
| 13397 | // unquoted attribute value. We’re only escaping it to support those |
| 13398 | // situations, and for XML support. |
| 13399 | '>': '>', |
| 13400 | // In Internet Explorer ≤ 8, the backtick character can be used |
| 13401 | // to break out of (un)quoted attribute values or HTML comments. |
| 13402 | // See http://html5sec.org/#102, http://html5sec.org/#108, and |
| 13403 | // http://html5sec.org/#133. |
| 13404 | '`': '`' |
| 13405 | }; |
| 13406 | |
| 13407 | var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/; |
| 13408 | 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]/; |
| 13409 | 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; |
| 13410 | var decodeMap = {'aacute':'\xE1','Aacute':'\xC1','abreve':'\u0103','Abreve':'\u0102','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','acy':'\u0430','Acy':'\u0410','aelig':'\xE6','AElig':'\xC6','af':'\u2061','afr':'\uD835\uDD1E','Afr':'\uD835\uDD04','agrave':'\xE0','Agrave':'\xC0','alefsym':'\u2135','aleph':'\u2135','alpha':'\u03B1','Alpha':'\u0391','amacr':'\u0101','Amacr':'\u0100','amalg':'\u2A3F','amp':'&','AMP':'&','and':'\u2227','And':'\u2A53','andand':'\u2A55','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsd':'\u2221','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','aogon':'\u0105','Aogon':'\u0104','aopf':'\uD835\uDD52','Aopf':'\uD835\uDD38','ap':'\u2248','apacir':'\u2A6F','ape':'\u224A','apE':'\u2A70','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','aring':'\xE5','Aring':'\xC5','ascr':'\uD835\uDCB6','Ascr':'\uD835\uDC9C','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','bcy':'\u0431','Bcy':'\u0411','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','beta':'\u03B2','Beta':'\u0392','beth':'\u2136','between':'\u226C','bfr':'\uD835\uDD1F','Bfr':'\uD835\uDD05','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bnot':'\u2310','bNot':'\u2AED','bopf':'\uD835\uDD53','Bopf':'\uD835\uDD39','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxhD':'\u2565','boxHd':'\u2564','boxHD':'\u2566','boxhu':'\u2534','boxhU':'\u2568','boxHu':'\u2567','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsol':'\\','bsolb':'\u29C5','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpe':'\u224F','bumpE':'\u2AAE','bumpeq':'\u224F','Bumpeq':'\u224E','cacute':'\u0107','Cacute':'\u0106','cap':'\u2229','Cap':'\u22D2','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','ccaron':'\u010D','Ccaron':'\u010C','ccedil':'\xE7','Ccedil':'\xC7','ccirc':'\u0109','Ccirc':'\u0108','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','cdot':'\u010B','Cdot':'\u010A','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','chcy':'\u0447','CHcy':'\u0427','check':'\u2713','checkmark':'\u2713','chi':'\u03C7','Chi':'\u03A7','cir':'\u25CB','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cire':'\u2257','cirE':'\u29C3','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','colone':'\u2254','Colone':'\u2A74','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','cscr':'\uD835\uDCB8','Cscr':'\uD835\uDC9E','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cup':'\u222A','Cup':'\u22D3','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','dArr':'\u21D3','Darr':'\u21A1','dash':'\u2010','dashv':'\u22A3','Dashv':'\u2AE4','dbkarow':'\u290F','dblac':'\u02DD','dcaron':'\u010F','Dcaron':'\u010E','dcy':'\u0434','Dcy':'\u0414','dd':'\u2146','DD':'\u2145','ddagger':'\u2021','ddarr':'\u21CA','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','delta':'\u03B4','Delta':'\u0394','demptyv':'\u29B1','dfisht':'\u297F','dfr':'\uD835\uDD21','Dfr':'\uD835\uDD07','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','djcy':'\u0452','DJcy':'\u0402','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','dopf':'\uD835\uDD55','Dopf':'\uD835\uDD3B','dot':'\u02D9','Dot':'\xA8','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','downarrow':'\u2193','Downarrow':'\u21D3','DownArrow':'\u2193','DownArrowBar':'\u2913','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVector':'\u21BD','DownLeftVectorBar':'\u2956','DownRightTeeVector':'\u295F','DownRightVector':'\u21C1','DownRightVectorBar':'\u2957','DownTee':'\u22A4','DownTeeArrow':'\u21A7','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','dscr':'\uD835\uDCB9','Dscr':'\uD835\uDC9F','dscy':'\u0455','DScy':'\u0405','dsol':'\u29F6','dstrok':'\u0111','Dstrok':'\u0110','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','dzcy':'\u045F','DZcy':'\u040F','dzigrarr':'\u27FF','eacute':'\xE9','Eacute':'\xC9','easter':'\u2A6E','ecaron':'\u011B','Ecaron':'\u011A','ecir':'\u2256','ecirc':'\xEA','Ecirc':'\xCA','ecolon':'\u2255','ecy':'\u044D','Ecy':'\u042D','eDDot':'\u2A77','edot':'\u0117','eDot':'\u2251','Edot':'\u0116','ee':'\u2147','efDot':'\u2252','efr':'\uD835\uDD22','Efr':'\uD835\uDD08','eg':'\u2A9A','egrave':'\xE8','Egrave':'\xC8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','emacr':'\u0113','Emacr':'\u0112','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp':'\u2003','emsp13':'\u2004','emsp14':'\u2005','eng':'\u014B','ENG':'\u014A','ensp':'\u2002','eogon':'\u0119','Eogon':'\u0118','eopf':'\uD835\uDD56','Eopf':'\uD835\uDD3C','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','epsilon':'\u03B5','Epsilon':'\u0395','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','esim':'\u2242','Esim':'\u2A73','eta':'\u03B7','Eta':'\u0397','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','fcy':'\u0444','Fcy':'\u0424','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','ffr':'\uD835\uDD23','Ffr':'\uD835\uDD09','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','fopf':'\uD835\uDD57','Fopf':'\uD835\uDD3D','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','gamma':'\u03B3','Gamma':'\u0393','gammad':'\u03DD','Gammad':'\u03DC','gap':'\u2A86','gbreve':'\u011F','Gbreve':'\u011E','Gcedil':'\u0122','gcirc':'\u011D','Gcirc':'\u011C','gcy':'\u0433','Gcy':'\u0413','gdot':'\u0121','Gdot':'\u0120','ge':'\u2265','gE':'\u2267','gel':'\u22DB','gEl':'\u2A8C','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','ges':'\u2A7E','gescc':'\u2AA9','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','gfr':'\uD835\uDD24','Gfr':'\uD835\uDD0A','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','gjcy':'\u0453','GJcy':'\u0403','gl':'\u2277','gla':'\u2AA5','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','gopf':'\uD835\uDD58','Gopf':'\uD835\uDD3E','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','gscr':'\u210A','Gscr':'\uD835\uDCA2','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gt':'>','Gt':'\u226B','GT':'>','gtcc':'\u2AA7','gtcir':'\u2A7A','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','hardcy':'\u044A','HARDcy':'\u042A','harr':'\u2194','hArr':'\u21D4','harrcir':'\u2948','harrw':'\u21AD','Hat':'^','hbar':'\u210F','hcirc':'\u0125','Hcirc':'\u0124','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','hstrok':'\u0127','Hstrok':'\u0126','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','iacute':'\xED','Iacute':'\xCD','ic':'\u2063','icirc':'\xEE','Icirc':'\xCE','icy':'\u0438','Icy':'\u0418','Idot':'\u0130','iecy':'\u0435','IEcy':'\u0415','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','igrave':'\xEC','Igrave':'\xCC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','ijlig':'\u0133','IJlig':'\u0132','Im':'\u2111','imacr':'\u012B','Imacr':'\u012A','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','in':'\u2208','incare':'\u2105','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','int':'\u222B','Int':'\u222C','intcal':'\u22BA','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','iocy':'\u0451','IOcy':'\u0401','iogon':'\u012F','Iogon':'\u012E','iopf':'\uD835\uDD5A','Iopf':'\uD835\uDD40','iota':'\u03B9','Iota':'\u0399','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','itilde':'\u0129','Itilde':'\u0128','iukcy':'\u0456','Iukcy':'\u0406','iuml':'\xEF','Iuml':'\xCF','jcirc':'\u0135','Jcirc':'\u0134','jcy':'\u0439','Jcy':'\u0419','jfr':'\uD835\uDD27','Jfr':'\uD835\uDD0D','jmath':'\u0237','jopf':'\uD835\uDD5B','Jopf':'\uD835\uDD41','jscr':'\uD835\uDCBF','Jscr':'\uD835\uDCA5','jsercy':'\u0458','Jsercy':'\u0408','jukcy':'\u0454','Jukcy':'\u0404','kappa':'\u03BA','Kappa':'\u039A','kappav':'\u03F0','kcedil':'\u0137','Kcedil':'\u0136','kcy':'\u043A','Kcy':'\u041A','kfr':'\uD835\uDD28','Kfr':'\uD835\uDD0E','kgreen':'\u0138','khcy':'\u0445','KHcy':'\u0425','kjcy':'\u045C','KJcy':'\u040C','kopf':'\uD835\uDD5C','Kopf':'\uD835\uDD42','kscr':'\uD835\uDCC0','Kscr':'\uD835\uDCA6','lAarr':'\u21DA','lacute':'\u013A','Lacute':'\u0139','laemptyv':'\u29B4','lagran':'\u2112','lambda':'\u03BB','Lambda':'\u039B','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larr':'\u2190','lArr':'\u21D0','Larr':'\u219E','larrb':'\u21E4','larrbfs':'\u291F','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','lat':'\u2AAB','latail':'\u2919','lAtail':'\u291B','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','lcaron':'\u013E','Lcaron':'\u013D','lcedil':'\u013C','Lcedil':'\u013B','lceil':'\u2308','lcub':'{','lcy':'\u043B','Lcy':'\u041B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','leftarrow':'\u2190','Leftarrow':'\u21D0','LeftArrow':'\u2190','LeftArrowBar':'\u21E4','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVector':'\u21C3','LeftDownVectorBar':'\u2959','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','Leftrightarrow':'\u21D4','LeftRightArrow':'\u2194','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTee':'\u22A3','LeftTeeArrow':'\u21A4','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangle':'\u22B2','LeftTriangleBar':'\u29CF','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVector':'\u21BF','LeftUpVectorBar':'\u2958','LeftVector':'\u21BC','LeftVectorBar':'\u2952','leg':'\u22DA','lEg':'\u2A8B','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','les':'\u2A7D','lescc':'\u2AA8','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','lfr':'\uD835\uDD29','Lfr':'\uD835\uDD0F','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','ljcy':'\u0459','LJcy':'\u0409','ll':'\u226A','Ll':'\u22D8','llarr':'\u21C7','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','lmidot':'\u0140','Lmidot':'\u013F','lmoust':'\u23B0','lmoustache':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','Longleftarrow':'\u27F8','LongLeftArrow':'\u27F5','longleftrightarrow':'\u27F7','Longleftrightarrow':'\u27FA','LongLeftRightArrow':'\u27F7','longmapsto':'\u27FC','longrightarrow':'\u27F6','Longrightarrow':'\u27F9','LongRightArrow':'\u27F6','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','lopf':'\uD835\uDD5D','Lopf':'\uD835\uDD43','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','lstrok':'\u0142','Lstrok':'\u0141','lt':'<','Lt':'\u226A','LT':'<','ltcc':'\u2AA6','ltcir':'\u2A79','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','map':'\u21A6','Map':'\u2905','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','mcy':'\u043C','Mcy':'\u041C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','mfr':'\uD835\uDD2A','Mfr':'\uD835\uDD10','mho':'\u2127','micro':'\xB5','mid':'\u2223','midast':'*','midcir':'\u2AF0','middot':'\xB7','minus':'\u2212','minusb':'\u229F','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','mopf':'\uD835\uDD5E','Mopf':'\uD835\uDD44','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','mu':'\u03BC','Mu':'\u039C','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','nacute':'\u0144','Nacute':'\u0143','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natur':'\u266E','natural':'\u266E','naturals':'\u2115','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','ncaron':'\u0148','Ncaron':'\u0147','ncedil':'\u0146','Ncedil':'\u0145','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','ncy':'\u043D','Ncy':'\u041D','ndash':'\u2013','ne':'\u2260','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','nfr':'\uD835\uDD2B','Nfr':'\uD835\uDD11','nge':'\u2271','ngE':'\u2267\u0338','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','ngt':'\u226F','nGt':'\u226B\u20D2','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','njcy':'\u045A','NJcy':'\u040A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nle':'\u2270','nlE':'\u2266\u0338','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nlt':'\u226E','nLt':'\u226A\u20D2','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','not':'\xAC','Not':'\u2AEC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangle':'\u22EA','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangle':'\u22EB','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','npar':'\u2226','nparallel':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','npre':'\u2AAF\u0338','nprec':'\u2280','npreceq':'\u2AAF\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrc':'\u2933\u0338','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','nscr':'\uD835\uDCC3','Nscr':'\uD835\uDCA9','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsube':'\u2288','nsubE':'\u2AC5\u0338','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupe':'\u2289','nsupE':'\u2AC6\u0338','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','ntilde':'\xF1','Ntilde':'\xD1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','nu':'\u03BD','Nu':'\u039D','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','oacute':'\xF3','Oacute':'\xD3','oast':'\u229B','ocir':'\u229A','ocirc':'\xF4','Ocirc':'\xD4','ocy':'\u043E','Ocy':'\u041E','odash':'\u229D','odblac':'\u0151','Odblac':'\u0150','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','oelig':'\u0153','OElig':'\u0152','ofcir':'\u29BF','ofr':'\uD835\uDD2C','Ofr':'\uD835\uDD12','ogon':'\u02DB','ograve':'\xF2','Ograve':'\xD2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','omacr':'\u014D','Omacr':'\u014C','omega':'\u03C9','Omega':'\u03A9','omicron':'\u03BF','Omicron':'\u039F','omid':'\u29B6','ominus':'\u2296','oopf':'\uD835\uDD60','Oopf':'\uD835\uDD46','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','or':'\u2228','Or':'\u2A54','orarr':'\u21BB','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','oscr':'\u2134','Oscr':'\uD835\uDCAA','oslash':'\xF8','Oslash':'\xD8','osol':'\u2298','otilde':'\xF5','Otilde':'\xD5','otimes':'\u2297','Otimes':'\u2A37','otimesas':'\u2A36','ouml':'\xF6','Ouml':'\xD6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','par':'\u2225','para':'\xB6','parallel':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','pcy':'\u043F','Pcy':'\u041F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','pfr':'\uD835\uDD2D','Pfr':'\uD835\uDD13','phi':'\u03C6','Phi':'\u03A6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','pi':'\u03C0','Pi':'\u03A0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plus':'+','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','pr':'\u227A','Pr':'\u2ABB','prap':'\u2AB7','prcue':'\u227C','pre':'\u2AAF','prE':'\u2AB3','prec':'\u227A','precapprox':'\u2AB7','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportion':'\u2237','Proportional':'\u221D','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','pscr':'\uD835\uDCC5','Pscr':'\uD835\uDCAB','psi':'\u03C8','Psi':'\u03A8','puncsp':'\u2008','qfr':'\uD835\uDD2E','Qfr':'\uD835\uDD14','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','qscr':'\uD835\uDCC6','Qscr':'\uD835\uDCAC','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','racute':'\u0155','Racute':'\u0154','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarr':'\u2192','rArr':'\u21D2','Rarr':'\u21A0','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','rarrtl':'\u21A3','Rarrtl':'\u2916','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','rcaron':'\u0159','Rcaron':'\u0158','rcedil':'\u0157','Rcedil':'\u0156','rceil':'\u2309','rcub':'}','rcy':'\u0440','Rcy':'\u0420','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','Re':'\u211C','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','rho':'\u03C1','Rho':'\u03A1','rhov':'\u03F1','RightAngleBracket':'\u27E9','rightarrow':'\u2192','Rightarrow':'\u21D2','RightArrow':'\u2192','RightArrowBar':'\u21E5','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVector':'\u21C2','RightDownVectorBar':'\u2955','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTee':'\u22A2','RightTeeArrow':'\u21A6','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangle':'\u22B3','RightTriangleBar':'\u29D0','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVector':'\u21BE','RightUpVectorBar':'\u2954','RightVector':'\u21C0','RightVectorBar':'\u2953','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoust':'\u23B1','rmoustache':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','sacute':'\u015B','Sacute':'\u015A','sbquo':'\u201A','sc':'\u227B','Sc':'\u2ABC','scap':'\u2AB8','scaron':'\u0161','Scaron':'\u0160','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','scedil':'\u015F','Scedil':'\u015E','scirc':'\u015D','Scirc':'\u015C','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','scy':'\u0441','Scy':'\u0421','sdot':'\u22C5','sdotb':'\u22A1','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','sfr':'\uD835\uDD30','Sfr':'\uD835\uDD16','sfrown':'\u2322','sharp':'\u266F','shchcy':'\u0449','SHCHcy':'\u0429','shcy':'\u0448','SHcy':'\u0428','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','sigma':'\u03C3','Sigma':'\u03A3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','softcy':'\u044C','SOFTcy':'\u042C','sol':'/','solb':'\u29C4','solbar':'\u233F','sopf':'\uD835\uDD64','Sopf':'\uD835\uDD4A','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','squ':'\u25A1','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squf':'\u25AA','srarr':'\u2192','sscr':'\uD835\uDCC8','Sscr':'\uD835\uDCAE','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','star':'\u2606','Star':'\u22C6','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','sube':'\u2286','subE':'\u2AC5','subedot':'\u2AC3','submult':'\u2AC1','subne':'\u228A','subnE':'\u2ACB','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succ':'\u227B','succapprox':'\u2AB8','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup':'\u2283','Sup':'\u22D1','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','supdot':'\u2ABE','supdsub':'\u2AD8','supe':'\u2287','supE':'\u2AC6','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supne':'\u228B','supnE':'\u2ACC','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','tau':'\u03C4','Tau':'\u03A4','tbrk':'\u23B4','tcaron':'\u0165','Tcaron':'\u0164','tcedil':'\u0163','Tcedil':'\u0162','tcy':'\u0442','Tcy':'\u0422','tdot':'\u20DB','telrec':'\u2315','tfr':'\uD835\uDD31','Tfr':'\uD835\uDD17','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','theta':'\u03B8','Theta':'\u0398','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','thinsp':'\u2009','ThinSpace':'\u2009','thkap':'\u2248','thksim':'\u223C','thorn':'\xFE','THORN':'\xDE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','times':'\xD7','timesb':'\u22A0','timesbar':'\u2A31','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','top':'\u22A4','topbot':'\u2336','topcir':'\u2AF1','topf':'\uD835\uDD65','Topf':'\uD835\uDD4B','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','tscr':'\uD835\uDCC9','Tscr':'\uD835\uDCAF','tscy':'\u0446','TScy':'\u0426','tshcy':'\u045B','TSHcy':'\u040B','tstrok':'\u0167','Tstrok':'\u0166','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','uacute':'\xFA','Uacute':'\xDA','uarr':'\u2191','uArr':'\u21D1','Uarr':'\u219F','Uarrocir':'\u2949','ubrcy':'\u045E','Ubrcy':'\u040E','ubreve':'\u016D','Ubreve':'\u016C','ucirc':'\xFB','Ucirc':'\xDB','ucy':'\u0443','Ucy':'\u0423','udarr':'\u21C5','udblac':'\u0171','Udblac':'\u0170','udhar':'\u296E','ufisht':'\u297E','ufr':'\uD835\uDD32','Ufr':'\uD835\uDD18','ugrave':'\xF9','Ugrave':'\xD9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','umacr':'\u016B','Umacr':'\u016A','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','uogon':'\u0173','Uogon':'\u0172','uopf':'\uD835\uDD66','Uopf':'\uD835\uDD4C','uparrow':'\u2191','Uparrow':'\u21D1','UpArrow':'\u2191','UpArrowBar':'\u2912','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','Updownarrow':'\u21D5','UpDownArrow':'\u2195','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','upsilon':'\u03C5','Upsilon':'\u03A5','UpTee':'\u22A5','UpTeeArrow':'\u21A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','uring':'\u016F','Uring':'\u016E','urtri':'\u25F9','uscr':'\uD835\uDCCA','Uscr':'\uD835\uDCB0','utdot':'\u22F0','utilde':'\u0169','Utilde':'\u0168','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','uuml':'\xFC','Uuml':'\xDC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','vcy':'\u0432','Vcy':'\u0412','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','vee':'\u2228','Vee':'\u22C1','veebar':'\u22BB','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','vfr':'\uD835\uDD33','Vfr':'\uD835\uDD19','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','vopf':'\uD835\uDD67','Vopf':'\uD835\uDD4D','vprop':'\u221D','vrtri':'\u22B3','vscr':'\uD835\uDCCB','Vscr':'\uD835\uDCB1','vsubne':'\u228A\uFE00','vsubnE':'\u2ACB\uFE00','vsupne':'\u228B\uFE00','vsupnE':'\u2ACC\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','wcirc':'\u0175','Wcirc':'\u0174','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','wfr':'\uD835\uDD34','Wfr':'\uD835\uDD1A','wopf':'\uD835\uDD68','Wopf':'\uD835\uDD4E','wp':'\u2118','wr':'\u2240','wreath':'\u2240','wscr':'\uD835\uDCCC','Wscr':'\uD835\uDCB2','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','xfr':'\uD835\uDD35','Xfr':'\uD835\uDD1B','xharr':'\u27F7','xhArr':'\u27FA','xi':'\u03BE','Xi':'\u039E','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','xopf':'\uD835\uDD69','Xopf':'\uD835\uDD4F','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','xscr':'\uD835\uDCCD','Xscr':'\uD835\uDCB3','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','yacute':'\xFD','Yacute':'\xDD','yacy':'\u044F','YAcy':'\u042F','ycirc':'\u0177','Ycirc':'\u0176','ycy':'\u044B','Ycy':'\u042B','yen':'\xA5','yfr':'\uD835\uDD36','Yfr':'\uD835\uDD1C','yicy':'\u0457','YIcy':'\u0407','yopf':'\uD835\uDD6A','Yopf':'\uD835\uDD50','yscr':'\uD835\uDCCE','Yscr':'\uD835\uDCB4','yucy':'\u044E','YUcy':'\u042E','yuml':'\xFF','Yuml':'\u0178','zacute':'\u017A','Zacute':'\u0179','zcaron':'\u017E','Zcaron':'\u017D','zcy':'\u0437','Zcy':'\u0417','zdot':'\u017C','Zdot':'\u017B','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','zeta':'\u03B6','Zeta':'\u0396','zfr':'\uD835\uDD37','Zfr':'\u2128','zhcy':'\u0436','ZHcy':'\u0416','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','zscr':'\uD835\uDCCF','Zscr':'\uD835\uDCB5','zwj':'\u200D','zwnj':'\u200C'}; |
| 13411 | var decodeMapLegacy = {'aacute':'\xE1','Aacute':'\xC1','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','aelig':'\xE6','AElig':'\xC6','agrave':'\xE0','Agrave':'\xC0','amp':'&','AMP':'&','aring':'\xE5','Aring':'\xC5','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','brvbar':'\xA6','ccedil':'\xE7','Ccedil':'\xC7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','eacute':'\xE9','Eacute':'\xC9','ecirc':'\xEA','Ecirc':'\xCA','egrave':'\xE8','Egrave':'\xC8','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','iacute':'\xED','Iacute':'\xCD','icirc':'\xEE','Icirc':'\xCE','iexcl':'\xA1','igrave':'\xEC','Igrave':'\xCC','iquest':'\xBF','iuml':'\xEF','Iuml':'\xCF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','ntilde':'\xF1','Ntilde':'\xD1','oacute':'\xF3','Oacute':'\xD3','ocirc':'\xF4','Ocirc':'\xD4','ograve':'\xF2','Ograve':'\xD2','ordf':'\xAA','ordm':'\xBA','oslash':'\xF8','Oslash':'\xD8','otilde':'\xF5','Otilde':'\xD5','ouml':'\xF6','Ouml':'\xD6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','thorn':'\xFE','THORN':'\xDE','times':'\xD7','uacute':'\xFA','Uacute':'\xDA','ucirc':'\xFB','Ucirc':'\xDB','ugrave':'\xF9','Ugrave':'\xD9','uml':'\xA8','uuml':'\xFC','Uuml':'\xDC','yacute':'\xFD','Yacute':'\xDD','yen':'\xA5','yuml':'\xFF'}; |
| 13412 | var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'}; |
| 13413 | 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]; |
| 13414 | |
| 13415 | /*--------------------------------------------------------------------------*/ |
| 13416 | |
| 13417 | var stringFromCharCode = String.fromCharCode; |
| 13418 | |
| 13419 | var object = {}; |
| 13420 | var hasOwnProperty = object.hasOwnProperty; |
| 13421 | var has = function(object, propertyName) { |
| 13422 | return hasOwnProperty.call(object, propertyName); |
| 13423 | }; |
| 13424 | |
| 13425 | var contains = function(array, value) { |
| 13426 | var index = -1; |
| 13427 | var length = array.length; |
| 13428 | while (++index < length) { |
| 13429 | if (array[index] == value) { |
| 13430 | return true; |
| 13431 | } |
| 13432 | } |
| 13433 | return false; |
| 13434 | }; |
| 13435 | |
| 13436 | var merge = function(options, defaults) { |
| 13437 | if (!options) { |
| 13438 | return defaults; |
| 13439 | } |
| 13440 | var result = {}; |
| 13441 | var key; |
| 13442 | for (key in defaults) { |
| 13443 | // A `hasOwnProperty` check is not needed here, since only recognized |
| 13444 | // option names are used anyway. Any others are ignored. |
| 13445 | result[key] = has(options, key) ? options[key] : defaults[key]; |
| 13446 | } |
| 13447 | return result; |
| 13448 | }; |
| 13449 | |
| 13450 | // Modified version of `ucs2encode`; see https://mths.be/punycode. |
| 13451 | var codePointToSymbol = function(codePoint, strict) { |
| 13452 | var output = ''; |
| 13453 | if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) { |
| 13454 | // See issue #4: |
| 13455 | // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is |
| 13456 | // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD |
| 13457 | // REPLACEMENT CHARACTER.” |
| 13458 | if (strict) { |
| 13459 | parseError('character reference outside the permissible Unicode range'); |
| 13460 | } |
| 13461 | return '\uFFFD'; |
| 13462 | } |
| 13463 | if (has(decodeMapNumeric, codePoint)) { |
| 13464 | if (strict) { |
| 13465 | parseError('disallowed character reference'); |
| 13466 | } |
| 13467 | return decodeMapNumeric[codePoint]; |
| 13468 | } |
| 13469 | if (strict && contains(invalidReferenceCodePoints, codePoint)) { |
| 13470 | parseError('disallowed character reference'); |
| 13471 | } |
| 13472 | if (codePoint > 0xFFFF) { |
| 13473 | codePoint -= 0x10000; |
| 13474 | output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800); |
| 13475 | codePoint = 0xDC00 | codePoint & 0x3FF; |
| 13476 | } |
| 13477 | output += stringFromCharCode(codePoint); |
| 13478 | return output; |
| 13479 | }; |
| 13480 | |
| 13481 | var hexEscape = function(codePoint) { |
| 13482 | return '&#x' + codePoint.toString(16).toUpperCase() + ';'; |
| 13483 | }; |
| 13484 | |
| 13485 | var decEscape = function(codePoint) { |
| 13486 | return '&#' + codePoint + ';'; |
| 13487 | }; |
| 13488 | |
| 13489 | var parseError = function(message) { |
| 13490 | throw Error('Parse error: ' + message); |
| 13491 | }; |
| 13492 | |
| 13493 | /*--------------------------------------------------------------------------*/ |
| 13494 | |
| 13495 | var encode = function(string, options) { |
| 13496 | options = merge(options, encode.options); |
| 13497 | var strict = options.strict; |
| 13498 | if (strict && regexInvalidRawCodePoint.test(string)) { |
| 13499 | parseError('forbidden code point'); |
| 13500 | } |
| 13501 | var encodeEverything = options.encodeEverything; |
| 13502 | var useNamedReferences = options.useNamedReferences; |
| 13503 | var allowUnsafeSymbols = options.allowUnsafeSymbols; |
| 13504 | var escapeCodePoint = options.decimal ? decEscape : hexEscape; |
| 13505 | |
| 13506 | var escapeBmpSymbol = function(symbol) { |
| 13507 | return escapeCodePoint(symbol.charCodeAt(0)); |
| 13508 | }; |
| 13509 | |
| 13510 | if (encodeEverything) { |
| 13511 | // Encode ASCII symbols. |
| 13512 | string = string.replace(regexAsciiWhitelist, function(symbol) { |
| 13513 | // Use named references if requested & possible. |
| 13514 | if (useNamedReferences && has(encodeMap, symbol)) { |
| 13515 | return '&' + encodeMap[symbol] + ';'; |
| 13516 | } |
| 13517 | return escapeBmpSymbol(symbol); |
| 13518 | }); |
| 13519 | // Shorten a few escapes that represent two symbols, of which at least one |
| 13520 | // is within the ASCII range. |
| 13521 | if (useNamedReferences) { |
| 13522 | string = string |
| 13523 | .replace(/>\u20D2/g, '>⃒') |
| 13524 | .replace(/<\u20D2/g, '<⃒') |
| 13525 | .replace(/fj/g, 'fj'); |
| 13526 | } |
| 13527 | // Encode non-ASCII symbols. |
| 13528 | if (useNamedReferences) { |
| 13529 | // Encode non-ASCII symbols that can be replaced with a named reference. |
| 13530 | string = string.replace(regexEncodeNonAscii, function(string) { |
| 13531 | // Note: there is no need to check `has(encodeMap, string)` here. |
| 13532 | return '&' + encodeMap[string] + ';'; |
| 13533 | }); |
| 13534 | } |
| 13535 | // Note: any remaining non-ASCII symbols are handled outside of the `if`. |
| 13536 | } else if (useNamedReferences) { |
| 13537 | // Apply named character references. |
| 13538 | // Encode `<>"'&` using named character references. |
| 13539 | if (!allowUnsafeSymbols) { |
| 13540 | string = string.replace(regexEscape, function(string) { |
| 13541 | return '&' + encodeMap[string] + ';'; // no need to check `has()` here |
| 13542 | }); |
| 13543 | } |
| 13544 | // Shorten escapes that represent two symbols, of which at least one is |
| 13545 | // `<>"'&`. |
| 13546 | string = string |
| 13547 | .replace(/>\u20D2/g, '>⃒') |
| 13548 | .replace(/<\u20D2/g, '<⃒'); |
| 13549 | // Encode non-ASCII symbols that can be replaced with a named reference. |
| 13550 | string = string.replace(regexEncodeNonAscii, function(string) { |
| 13551 | // Note: there is no need to check `has(encodeMap, string)` here. |
| 13552 | return '&' + encodeMap[string] + ';'; |
| 13553 | }); |
| 13554 | } else if (!allowUnsafeSymbols) { |
| 13555 | // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled |
| 13556 | // using named character references. |
| 13557 | string = string.replace(regexEscape, escapeBmpSymbol); |
| 13558 | } |
| 13559 | return string |
| 13560 | // Encode astral symbols. |
| 13561 | .replace(regexAstralSymbols, function($0) { |
| 13562 | // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae |
| 13563 | var high = $0.charCodeAt(0); |
| 13564 | var low = $0.charCodeAt(1); |
| 13565 | var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000; |
| 13566 | return escapeCodePoint(codePoint); |
| 13567 | }) |
| 13568 | // Encode any remaining BMP symbols that are not printable ASCII symbols |
| 13569 | // using a hexadecimal escape. |
| 13570 | .replace(regexBmpWhitelist, escapeBmpSymbol); |
| 13571 | }; |
| 13572 | // Expose default options (so they can be overridden globally). |
| 13573 | encode.options = { |
| 13574 | 'allowUnsafeSymbols': false, |
| 13575 | 'encodeEverything': false, |
| 13576 | 'strict': false, |
| 13577 | 'useNamedReferences': false, |
| 13578 | 'decimal' : false |
| 13579 | }; |
| 13580 | |
| 13581 | var decode = function(html, options) { |
| 13582 | options = merge(options, decode.options); |
| 13583 | var strict = options.strict; |
| 13584 | if (strict && regexInvalidEntity.test(html)) { |
| 13585 | parseError('malformed character reference'); |
| 13586 | } |
| 13587 | return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) { |
| 13588 | var codePoint; |
| 13589 | var semicolon; |
| 13590 | var decDigits; |
| 13591 | var hexDigits; |
| 13592 | var reference; |
| 13593 | var next; |
| 13594 | |
| 13595 | if ($1) { |
| 13596 | reference = $1; |
| 13597 | // Note: there is no need to check `has(decodeMap, reference)`. |
| 13598 | return decodeMap[reference]; |
| 13599 | } |
| 13600 | |
| 13601 | if ($2) { |
| 13602 | // Decode named character references without trailing `;`, e.g. `&`. |
| 13603 | // This is only a parse error if it gets converted to `&`, or if it is |
| 13604 | // followed by `=` in an attribute context. |
| 13605 | reference = $2; |
| 13606 | next = $3; |
| 13607 | if (next && options.isAttributeValue) { |
| 13608 | if (strict && next == '=') { |
| 13609 | parseError('`&` did not start a character reference'); |
| 13610 | } |
| 13611 | return $0; |
| 13612 | } else { |
| 13613 | if (strict) { |
| 13614 | parseError( |
| 13615 | 'named character reference was not terminated by a semicolon' |
| 13616 | ); |
| 13617 | } |
| 13618 | // Note: there is no need to check `has(decodeMapLegacy, reference)`. |
| 13619 | return decodeMapLegacy[reference] + (next || ''); |
| 13620 | } |
| 13621 | } |
| 13622 | |
| 13623 | if ($4) { |
| 13624 | // Decode decimal escapes, e.g. `𝌆`. |
| 13625 | decDigits = $4; |
| 13626 | semicolon = $5; |
| 13627 | if (strict && !semicolon) { |
| 13628 | parseError('character reference was not terminated by a semicolon'); |
| 13629 | } |
| 13630 | codePoint = parseInt(decDigits, 10); |
| 13631 | return codePointToSymbol(codePoint, strict); |
| 13632 | } |
| 13633 | |
| 13634 | if ($6) { |
| 13635 | // Decode hexadecimal escapes, e.g. `𝌆`. |
| 13636 | hexDigits = $6; |
| 13637 | semicolon = $7; |
| 13638 | if (strict && !semicolon) { |
| 13639 | parseError('character reference was not terminated by a semicolon'); |
| 13640 | } |
| 13641 | codePoint = parseInt(hexDigits, 16); |
| 13642 | return codePointToSymbol(codePoint, strict); |
| 13643 | } |
| 13644 | |
| 13645 | // If we’re still here, `if ($7)` is implied; it’s an ambiguous |
| 13646 | // ampersand for sure. https://mths.be/notes/ambiguous-ampersands |
| 13647 | if (strict) { |
| 13648 | parseError( |
| 13649 | 'named character reference was not terminated by a semicolon' |
| 13650 | ); |
| 13651 | } |
| 13652 | return $0; |
| 13653 | }); |
| 13654 | }; |
| 13655 | // Expose default options (so they can be overridden globally). |
| 13656 | decode.options = { |
| 13657 | 'isAttributeValue': false, |
| 13658 | 'strict': false |
| 13659 | }; |
| 13660 | |
| 13661 | var escape = function(string) { |
| 13662 | return string.replace(regexEscape, function($0) { |
| 13663 | // Note: there is no need to check `has(escapeMap, $0)` here. |
| 13664 | return escapeMap[$0]; |
| 13665 | }); |
| 13666 | }; |
| 13667 | |
| 13668 | /*--------------------------------------------------------------------------*/ |
| 13669 | |
| 13670 | var he = { |
| 13671 | 'version': '1.2.0', |
| 13672 | 'encode': encode, |
| 13673 | 'decode': decode, |
| 13674 | 'escape': escape, |
| 13675 | 'unescape': decode |
| 13676 | }; |
| 13677 | |
| 13678 | // Some AMD build optimizers, like r.js, check for specific condition patterns |
| 13679 | // like the following: |
| 13680 | if ( |
| 13681 | false |
| 13682 | ) { |
| 13683 | define(function() { |
| 13684 | return he; |
| 13685 | }); |
| 13686 | } else if (freeExports && !freeExports.nodeType) { |
| 13687 | if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+ |
| 13688 | freeModule.exports = he; |
| 13689 | } else { // in Narwhal or RingoJS v0.7.0- |
| 13690 | for (var key in he) { |
| 13691 | has(he, key) && (freeExports[key] = he[key]); |
| 13692 | } |
| 13693 | } |
| 13694 | } else { // in Rhino or a web browser |
| 13695 | root.he = he; |
| 13696 | } |
| 13697 | |
| 13698 | }(this)); |
| 13699 | |
| 13700 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 13701 | },{}],55:[function(require,module,exports){ |
| 13702 | exports.read = function (buffer, offset, isLE, mLen, nBytes) { |
| 13703 | var e, m |
| 13704 | var eLen = (nBytes * 8) - mLen - 1 |
| 13705 | var eMax = (1 << eLen) - 1 |
| 13706 | var eBias = eMax >> 1 |
| 13707 | var nBits = -7 |
| 13708 | var i = isLE ? (nBytes - 1) : 0 |
| 13709 | var d = isLE ? -1 : 1 |
| 13710 | var s = buffer[offset + i] |
| 13711 | |
| 13712 | i += d |
| 13713 | |
| 13714 | e = s & ((1 << (-nBits)) - 1) |
| 13715 | s >>= (-nBits) |
| 13716 | nBits += eLen |
| 13717 | for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} |
| 13718 | |
| 13719 | m = e & ((1 << (-nBits)) - 1) |
| 13720 | e >>= (-nBits) |
| 13721 | nBits += mLen |
| 13722 | for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} |
| 13723 | |
| 13724 | if (e === 0) { |
| 13725 | e = 1 - eBias |
| 13726 | } else if (e === eMax) { |
| 13727 | return m ? NaN : ((s ? -1 : 1) * Infinity) |
| 13728 | } else { |
| 13729 | m = m + Math.pow(2, mLen) |
| 13730 | e = e - eBias |
| 13731 | } |
| 13732 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen) |
| 13733 | } |
| 13734 | |
| 13735 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { |
| 13736 | var e, m, c |
| 13737 | var eLen = (nBytes * 8) - mLen - 1 |
| 13738 | var eMax = (1 << eLen) - 1 |
| 13739 | var eBias = eMax >> 1 |
| 13740 | var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) |
| 13741 | var i = isLE ? 0 : (nBytes - 1) |
| 13742 | var d = isLE ? 1 : -1 |
| 13743 | var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 |
| 13744 | |
| 13745 | value = Math.abs(value) |
| 13746 | |
| 13747 | if (isNaN(value) || value === Infinity) { |
| 13748 | m = isNaN(value) ? 1 : 0 |
| 13749 | e = eMax |
| 13750 | } else { |
| 13751 | e = Math.floor(Math.log(value) / Math.LN2) |
| 13752 | if (value * (c = Math.pow(2, -e)) < 1) { |
| 13753 | e-- |
| 13754 | c *= 2 |
| 13755 | } |
| 13756 | if (e + eBias >= 1) { |
| 13757 | value += rt / c |
| 13758 | } else { |
| 13759 | value += rt * Math.pow(2, 1 - eBias) |
| 13760 | } |
| 13761 | if (value * c >= 2) { |
| 13762 | e++ |
| 13763 | c /= 2 |
| 13764 | } |
| 13765 | |
| 13766 | if (e + eBias >= eMax) { |
| 13767 | m = 0 |
| 13768 | e = eMax |
| 13769 | } else if (e + eBias >= 1) { |
| 13770 | m = ((value * c) - 1) * Math.pow(2, mLen) |
| 13771 | e = e + eBias |
| 13772 | } else { |
| 13773 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) |
| 13774 | e = 0 |
| 13775 | } |
| 13776 | } |
| 13777 | |
| 13778 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} |
| 13779 | |
| 13780 | e = (e << mLen) | m |
| 13781 | eLen += mLen |
| 13782 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} |
| 13783 | |
| 13784 | buffer[offset + i - d] |= s * 128 |
| 13785 | } |
| 13786 | |
| 13787 | },{}],56:[function(require,module,exports){ |
| 13788 | if (typeof Object.create === 'function') { |
| 13789 | // implementation from standard node.js 'util' module |
| 13790 | module.exports = function inherits(ctor, superCtor) { |
| 13791 | ctor.super_ = superCtor |
| 13792 | ctor.prototype = Object.create(superCtor.prototype, { |
| 13793 | constructor: { |
| 13794 | value: ctor, |
| 13795 | enumerable: false, |
| 13796 | writable: true, |
| 13797 | configurable: true |
| 13798 | } |
| 13799 | }); |
| 13800 | }; |
| 13801 | } else { |
| 13802 | // old school shim for old browsers |
| 13803 | module.exports = function inherits(ctor, superCtor) { |
| 13804 | ctor.super_ = superCtor |
| 13805 | var TempCtor = function () {} |
| 13806 | TempCtor.prototype = superCtor.prototype |
| 13807 | ctor.prototype = new TempCtor() |
| 13808 | ctor.prototype.constructor = ctor |
| 13809 | } |
| 13810 | } |
| 13811 | |
| 13812 | },{}],57:[function(require,module,exports){ |
| 13813 | /*! |
| 13814 | * Determine if an object is a Buffer |
| 13815 | * |
| 13816 | * @author Feross Aboukhadijeh <https://feross.org> |
| 13817 | * @license MIT |
| 13818 | */ |
| 13819 | |
| 13820 | // The _isBuffer check is for Safari 5-7 support, because it's missing |
| 13821 | // Object.prototype.constructor. Remove this eventually |
| 13822 | module.exports = function (obj) { |
| 13823 | return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) |
| 13824 | } |
| 13825 | |
| 13826 | function isBuffer (obj) { |
| 13827 | return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) |
| 13828 | } |
| 13829 | |
| 13830 | // For Node v0.10 support. Remove this eventually. |
| 13831 | function isSlowBuffer (obj) { |
| 13832 | return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) |
| 13833 | } |
| 13834 | |
| 13835 | },{}],58:[function(require,module,exports){ |
| 13836 | var toString = {}.toString; |
| 13837 | |
| 13838 | module.exports = Array.isArray || function (arr) { |
| 13839 | return toString.call(arr) == '[object Array]'; |
| 13840 | }; |
| 13841 | |
| 13842 | },{}],59:[function(require,module,exports){ |
| 13843 | (function (process){ |
| 13844 | var path = require('path'); |
| 13845 | var fs = require('fs'); |
| 13846 | var _0777 = parseInt('0777', 8); |
| 13847 | |
| 13848 | module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; |
| 13849 | |
| 13850 | function mkdirP (p, opts, f, made) { |
| 13851 | if (typeof opts === 'function') { |
| 13852 | f = opts; |
| 13853 | opts = {}; |
| 13854 | } |
| 13855 | else if (!opts || typeof opts !== 'object') { |
| 13856 | opts = { mode: opts }; |
| 13857 | } |
| 13858 | |
| 13859 | var mode = opts.mode; |
| 13860 | var xfs = opts.fs || fs; |
| 13861 | |
| 13862 | if (mode === undefined) { |
| 13863 | mode = _0777 & (~process.umask()); |
| 13864 | } |
| 13865 | if (!made) made = null; |
| 13866 | |
| 13867 | var cb = f || function () {}; |
| 13868 | p = path.resolve(p); |
| 13869 | |
| 13870 | xfs.mkdir(p, mode, function (er) { |
| 13871 | if (!er) { |
| 13872 | made = made || p; |
| 13873 | return cb(null, made); |
| 13874 | } |
| 13875 | switch (er.code) { |
| 13876 | case 'ENOENT': |
| 13877 | mkdirP(path.dirname(p), opts, function (er, made) { |
| 13878 | if (er) cb(er, made); |
| 13879 | else mkdirP(p, opts, cb, made); |
| 13880 | }); |
| 13881 | break; |
| 13882 | |
| 13883 | // In the case of any other error, just see if there's a dir |
| 13884 | // there already. If so, then hooray! If not, then something |
| 13885 | // is borked. |
| 13886 | default: |
| 13887 | xfs.stat(p, function (er2, stat) { |
| 13888 | // if the stat fails, then that's super weird. |
| 13889 | // let the original error be the failure reason. |
| 13890 | if (er2 || !stat.isDirectory()) cb(er, made) |
| 13891 | else cb(null, made); |
| 13892 | }); |
| 13893 | break; |
| 13894 | } |
| 13895 | }); |
| 13896 | } |
| 13897 | |
| 13898 | mkdirP.sync = function sync (p, opts, made) { |
| 13899 | if (!opts || typeof opts !== 'object') { |
| 13900 | opts = { mode: opts }; |
| 13901 | } |
| 13902 | |
| 13903 | var mode = opts.mode; |
| 13904 | var xfs = opts.fs || fs; |
| 13905 | |
| 13906 | if (mode === undefined) { |
| 13907 | mode = _0777 & (~process.umask()); |
| 13908 | } |
| 13909 | if (!made) made = null; |
| 13910 | |
| 13911 | p = path.resolve(p); |
| 13912 | |
| 13913 | try { |
| 13914 | xfs.mkdirSync(p, mode); |
| 13915 | made = made || p; |
| 13916 | } |
| 13917 | catch (err0) { |
| 13918 | switch (err0.code) { |
| 13919 | case 'ENOENT' : |
| 13920 | made = sync(path.dirname(p), opts, made); |
| 13921 | sync(p, opts, made); |
| 13922 | break; |
| 13923 | |
| 13924 | // In the case of any other error, just see if there's a dir |
| 13925 | // there already. If so, then hooray! If not, then something |
| 13926 | // is borked. |
| 13927 | default: |
| 13928 | var stat; |
| 13929 | try { |
| 13930 | stat = xfs.statSync(p); |
| 13931 | } |
| 13932 | catch (err1) { |
| 13933 | throw err0; |
| 13934 | } |
| 13935 | if (!stat.isDirectory()) throw err0; |
| 13936 | break; |
| 13937 | } |
| 13938 | } |
| 13939 | |
| 13940 | return made; |
| 13941 | }; |
| 13942 | |
| 13943 | }).call(this,require('_process')) |
| 13944 | },{"_process":69,"fs":42,"path":42}],60:[function(require,module,exports){ |
| 13945 | /** |
| 13946 | * Helpers. |
| 13947 | */ |
| 13948 | |
| 13949 | var s = 1000; |
| 13950 | var m = s * 60; |
| 13951 | var h = m * 60; |
| 13952 | var d = h * 24; |
| 13953 | var w = d * 7; |
| 13954 | var y = d * 365.25; |
| 13955 | |
| 13956 | /** |
| 13957 | * Parse or format the given `val`. |
| 13958 | * |
| 13959 | * Options: |
| 13960 | * |
| 13961 | * - `long` verbose formatting [false] |
| 13962 | * |
| 13963 | * @param {String|Number} val |
| 13964 | * @param {Object} [options] |
| 13965 | * @throws {Error} throw an error if val is not a non-empty string or a number |
| 13966 | * @return {String|Number} |
| 13967 | * @api public |
| 13968 | */ |
| 13969 | |
| 13970 | module.exports = function(val, options) { |
| 13971 | options = options || {}; |
| 13972 | var type = typeof val; |
| 13973 | if (type === 'string' && val.length > 0) { |
| 13974 | return parse(val); |
| 13975 | } else if (type === 'number' && isNaN(val) === false) { |
| 13976 | return options.long ? fmtLong(val) : fmtShort(val); |
| 13977 | } |
| 13978 | throw new Error( |
| 13979 | 'val is not a non-empty string or a valid number. val=' + |
| 13980 | JSON.stringify(val) |
| 13981 | ); |
| 13982 | }; |
| 13983 | |
| 13984 | /** |
| 13985 | * Parse the given `str` and return milliseconds. |
| 13986 | * |
| 13987 | * @param {String} str |
| 13988 | * @return {Number} |
| 13989 | * @api private |
| 13990 | */ |
| 13991 | |
| 13992 | function parse(str) { |
| 13993 | str = String(str); |
| 13994 | if (str.length > 100) { |
| 13995 | return; |
| 13996 | } |
| 13997 | var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( |
| 13998 | str |
| 13999 | ); |
| 14000 | if (!match) { |
| 14001 | return; |
| 14002 | } |
| 14003 | var n = parseFloat(match[1]); |
| 14004 | var type = (match[2] || 'ms').toLowerCase(); |
| 14005 | switch (type) { |
| 14006 | case 'years': |
| 14007 | case 'year': |
| 14008 | case 'yrs': |
| 14009 | case 'yr': |
| 14010 | case 'y': |
| 14011 | return n * y; |
| 14012 | case 'weeks': |
| 14013 | case 'week': |
| 14014 | case 'w': |
| 14015 | return n * w; |
| 14016 | case 'days': |
| 14017 | case 'day': |
| 14018 | case 'd': |
| 14019 | return n * d; |
| 14020 | case 'hours': |
| 14021 | case 'hour': |
| 14022 | case 'hrs': |
| 14023 | case 'hr': |
| 14024 | case 'h': |
| 14025 | return n * h; |
| 14026 | case 'minutes': |
| 14027 | case 'minute': |
| 14028 | case 'mins': |
| 14029 | case 'min': |
| 14030 | case 'm': |
| 14031 | return n * m; |
| 14032 | case 'seconds': |
| 14033 | case 'second': |
| 14034 | case 'secs': |
| 14035 | case 'sec': |
| 14036 | case 's': |
| 14037 | return n * s; |
| 14038 | case 'milliseconds': |
| 14039 | case 'millisecond': |
| 14040 | case 'msecs': |
| 14041 | case 'msec': |
| 14042 | case 'ms': |
| 14043 | return n; |
| 14044 | default: |
| 14045 | return undefined; |
| 14046 | } |
| 14047 | } |
| 14048 | |
| 14049 | /** |
| 14050 | * Short format for `ms`. |
| 14051 | * |
| 14052 | * @param {Number} ms |
| 14053 | * @return {String} |
| 14054 | * @api private |
| 14055 | */ |
| 14056 | |
| 14057 | function fmtShort(ms) { |
| 14058 | var msAbs = Math.abs(ms); |
| 14059 | if (msAbs >= d) { |
| 14060 | return Math.round(ms / d) + 'd'; |
| 14061 | } |
| 14062 | if (msAbs >= h) { |
| 14063 | return Math.round(ms / h) + 'h'; |
| 14064 | } |
| 14065 | if (msAbs >= m) { |
| 14066 | return Math.round(ms / m) + 'm'; |
| 14067 | } |
| 14068 | if (msAbs >= s) { |
| 14069 | return Math.round(ms / s) + 's'; |
| 14070 | } |
| 14071 | return ms + 'ms'; |
| 14072 | } |
| 14073 | |
| 14074 | /** |
| 14075 | * Long format for `ms`. |
| 14076 | * |
| 14077 | * @param {Number} ms |
| 14078 | * @return {String} |
| 14079 | * @api private |
| 14080 | */ |
| 14081 | |
| 14082 | function fmtLong(ms) { |
| 14083 | var msAbs = Math.abs(ms); |
| 14084 | if (msAbs >= d) { |
| 14085 | return plural(ms, msAbs, d, 'day'); |
| 14086 | } |
| 14087 | if (msAbs >= h) { |
| 14088 | return plural(ms, msAbs, h, 'hour'); |
| 14089 | } |
| 14090 | if (msAbs >= m) { |
| 14091 | return plural(ms, msAbs, m, 'minute'); |
| 14092 | } |
| 14093 | if (msAbs >= s) { |
| 14094 | return plural(ms, msAbs, s, 'second'); |
| 14095 | } |
| 14096 | return ms + ' ms'; |
| 14097 | } |
| 14098 | |
| 14099 | /** |
| 14100 | * Pluralization helper. |
| 14101 | */ |
| 14102 | |
| 14103 | function plural(ms, msAbs, n, name) { |
| 14104 | var isPlural = msAbs >= n * 1.5; |
| 14105 | return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); |
| 14106 | } |
| 14107 | |
| 14108 | },{}],61:[function(require,module,exports){ |
| 14109 | 'use strict'; |
| 14110 | |
| 14111 | var keysShim; |
| 14112 | if (!Object.keys) { |
| 14113 | // modified from https://github.com/es-shims/es5-shim |
| 14114 | var has = Object.prototype.hasOwnProperty; |
| 14115 | var toStr = Object.prototype.toString; |
| 14116 | var isArgs = require('./isArguments'); // eslint-disable-line global-require |
| 14117 | var isEnumerable = Object.prototype.propertyIsEnumerable; |
| 14118 | var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); |
| 14119 | var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); |
| 14120 | var dontEnums = [ |
| 14121 | 'toString', |
| 14122 | 'toLocaleString', |
| 14123 | 'valueOf', |
| 14124 | 'hasOwnProperty', |
| 14125 | 'isPrototypeOf', |
| 14126 | 'propertyIsEnumerable', |
| 14127 | 'constructor' |
| 14128 | ]; |
| 14129 | var equalsConstructorPrototype = function (o) { |
| 14130 | var ctor = o.constructor; |
| 14131 | return ctor && ctor.prototype === o; |
| 14132 | }; |
| 14133 | var excludedKeys = { |
| 14134 | $applicationCache: true, |
| 14135 | $console: true, |
| 14136 | $external: true, |
| 14137 | $frame: true, |
| 14138 | $frameElement: true, |
| 14139 | $frames: true, |
| 14140 | $innerHeight: true, |
| 14141 | $innerWidth: true, |
| 14142 | $outerHeight: true, |
| 14143 | $outerWidth: true, |
| 14144 | $pageXOffset: true, |
| 14145 | $pageYOffset: true, |
| 14146 | $parent: true, |
| 14147 | $scrollLeft: true, |
| 14148 | $scrollTop: true, |
| 14149 | $scrollX: true, |
| 14150 | $scrollY: true, |
| 14151 | $self: true, |
| 14152 | $webkitIndexedDB: true, |
| 14153 | $webkitStorageInfo: true, |
| 14154 | $window: true |
| 14155 | }; |
| 14156 | var hasAutomationEqualityBug = (function () { |
| 14157 | /* global window */ |
| 14158 | if (typeof window === 'undefined') { return false; } |
| 14159 | for (var k in window) { |
| 14160 | try { |
| 14161 | if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { |
| 14162 | try { |
| 14163 | equalsConstructorPrototype(window[k]); |
| 14164 | } catch (e) { |
| 14165 | return true; |
| 14166 | } |
| 14167 | } |
| 14168 | } catch (e) { |
| 14169 | return true; |
| 14170 | } |
| 14171 | } |
| 14172 | return false; |
| 14173 | }()); |
| 14174 | var equalsConstructorPrototypeIfNotBuggy = function (o) { |
| 14175 | /* global window */ |
| 14176 | if (typeof window === 'undefined' || !hasAutomationEqualityBug) { |
| 14177 | return equalsConstructorPrototype(o); |
| 14178 | } |
| 14179 | try { |
| 14180 | return equalsConstructorPrototype(o); |
| 14181 | } catch (e) { |
| 14182 | return false; |
| 14183 | } |
| 14184 | }; |
| 14185 | |
| 14186 | keysShim = function keys(object) { |
| 14187 | var isObject = object !== null && typeof object === 'object'; |
| 14188 | var isFunction = toStr.call(object) === '[object Function]'; |
| 14189 | var isArguments = isArgs(object); |
| 14190 | var isString = isObject && toStr.call(object) === '[object String]'; |
| 14191 | var theKeys = []; |
| 14192 | |
| 14193 | if (!isObject && !isFunction && !isArguments) { |
| 14194 | throw new TypeError('Object.keys called on a non-object'); |
| 14195 | } |
| 14196 | |
| 14197 | var skipProto = hasProtoEnumBug && isFunction; |
| 14198 | if (isString && object.length > 0 && !has.call(object, 0)) { |
| 14199 | for (var i = 0; i < object.length; ++i) { |
| 14200 | theKeys.push(String(i)); |
| 14201 | } |
| 14202 | } |
| 14203 | |
| 14204 | if (isArguments && object.length > 0) { |
| 14205 | for (var j = 0; j < object.length; ++j) { |
| 14206 | theKeys.push(String(j)); |
| 14207 | } |
| 14208 | } else { |
| 14209 | for (var name in object) { |
| 14210 | if (!(skipProto && name === 'prototype') && has.call(object, name)) { |
| 14211 | theKeys.push(String(name)); |
| 14212 | } |
| 14213 | } |
| 14214 | } |
| 14215 | |
| 14216 | if (hasDontEnumBug) { |
| 14217 | var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); |
| 14218 | |
| 14219 | for (var k = 0; k < dontEnums.length; ++k) { |
| 14220 | if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { |
| 14221 | theKeys.push(dontEnums[k]); |
| 14222 | } |
| 14223 | } |
| 14224 | } |
| 14225 | return theKeys; |
| 14226 | }; |
| 14227 | } |
| 14228 | module.exports = keysShim; |
| 14229 | |
| 14230 | },{"./isArguments":63}],62:[function(require,module,exports){ |
| 14231 | 'use strict'; |
| 14232 | |
| 14233 | var slice = Array.prototype.slice; |
| 14234 | var isArgs = require('./isArguments'); |
| 14235 | |
| 14236 | var origKeys = Object.keys; |
| 14237 | var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation'); |
| 14238 | |
| 14239 | var originalKeys = Object.keys; |
| 14240 | |
| 14241 | keysShim.shim = function shimObjectKeys() { |
| 14242 | if (Object.keys) { |
| 14243 | var keysWorksWithArguments = (function () { |
| 14244 | // Safari 5.0 bug |
| 14245 | var args = Object.keys(arguments); |
| 14246 | return args && args.length === arguments.length; |
| 14247 | }(1, 2)); |
| 14248 | if (!keysWorksWithArguments) { |
| 14249 | Object.keys = function keys(object) { // eslint-disable-line func-name-matching |
| 14250 | if (isArgs(object)) { |
| 14251 | return originalKeys(slice.call(object)); |
| 14252 | } |
| 14253 | return originalKeys(object); |
| 14254 | }; |
| 14255 | } |
| 14256 | } else { |
| 14257 | Object.keys = keysShim; |
| 14258 | } |
| 14259 | return Object.keys || keysShim; |
| 14260 | }; |
| 14261 | |
| 14262 | module.exports = keysShim; |
| 14263 | |
| 14264 | },{"./implementation":61,"./isArguments":63}],63:[function(require,module,exports){ |
| 14265 | 'use strict'; |
| 14266 | |
| 14267 | var toStr = Object.prototype.toString; |
| 14268 | |
| 14269 | module.exports = function isArguments(value) { |
| 14270 | var str = toStr.call(value); |
| 14271 | var isArgs = str === '[object Arguments]'; |
| 14272 | if (!isArgs) { |
| 14273 | isArgs = str !== '[object Array]' && |
| 14274 | value !== null && |
| 14275 | typeof value === 'object' && |
| 14276 | typeof value.length === 'number' && |
| 14277 | value.length >= 0 && |
| 14278 | toStr.call(value.callee) === '[object Function]'; |
| 14279 | } |
| 14280 | return isArgs; |
| 14281 | }; |
| 14282 | |
| 14283 | },{}],64:[function(require,module,exports){ |
| 14284 | 'use strict'; |
| 14285 | |
| 14286 | // modified from https://github.com/es-shims/es6-shim |
| 14287 | var keys = require('object-keys'); |
| 14288 | var bind = require('function-bind'); |
| 14289 | var canBeObject = function (obj) { |
| 14290 | return typeof obj !== 'undefined' && obj !== null; |
| 14291 | }; |
| 14292 | var hasSymbols = require('has-symbols/shams')(); |
| 14293 | var toObject = Object; |
| 14294 | var push = bind.call(Function.call, Array.prototype.push); |
| 14295 | var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable); |
| 14296 | var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null; |
| 14297 | |
| 14298 | module.exports = function assign(target, source1) { |
| 14299 | if (!canBeObject(target)) { throw new TypeError('target must be an object'); } |
| 14300 | var objTarget = toObject(target); |
| 14301 | var s, source, i, props, syms, value, key; |
| 14302 | for (s = 1; s < arguments.length; ++s) { |
| 14303 | source = toObject(arguments[s]); |
| 14304 | props = keys(source); |
| 14305 | var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols); |
| 14306 | if (getSymbols) { |
| 14307 | syms = getSymbols(source); |
| 14308 | for (i = 0; i < syms.length; ++i) { |
| 14309 | key = syms[i]; |
| 14310 | if (propIsEnumerable(source, key)) { |
| 14311 | push(props, key); |
| 14312 | } |
| 14313 | } |
| 14314 | } |
| 14315 | for (i = 0; i < props.length; ++i) { |
| 14316 | key = props[i]; |
| 14317 | value = source[key]; |
| 14318 | if (propIsEnumerable(source, key)) { |
| 14319 | objTarget[key] = value; |
| 14320 | } |
| 14321 | } |
| 14322 | } |
| 14323 | return objTarget; |
| 14324 | }; |
| 14325 | |
| 14326 | },{"function-bind":52,"has-symbols/shams":53,"object-keys":62}],65:[function(require,module,exports){ |
| 14327 | 'use strict'; |
| 14328 | |
| 14329 | var defineProperties = require('define-properties'); |
| 14330 | |
| 14331 | var implementation = require('./implementation'); |
| 14332 | var getPolyfill = require('./polyfill'); |
| 14333 | var shim = require('./shim'); |
| 14334 | |
| 14335 | var polyfill = getPolyfill(); |
| 14336 | |
| 14337 | defineProperties(polyfill, { |
| 14338 | getPolyfill: getPolyfill, |
| 14339 | implementation: implementation, |
| 14340 | shim: shim |
| 14341 | }); |
| 14342 | |
| 14343 | module.exports = polyfill; |
| 14344 | |
| 14345 | },{"./implementation":64,"./polyfill":66,"./shim":67,"define-properties":47}],66:[function(require,module,exports){ |
| 14346 | 'use strict'; |
| 14347 | |
| 14348 | var implementation = require('./implementation'); |
| 14349 | |
| 14350 | var lacksProperEnumerationOrder = function () { |
| 14351 | if (!Object.assign) { |
| 14352 | return false; |
| 14353 | } |
| 14354 | // v8, specifically in node 4.x, has a bug with incorrect property enumeration order |
| 14355 | // note: this does not detect the bug unless there's 20 characters |
| 14356 | var str = 'abcdefghijklmnopqrst'; |
| 14357 | var letters = str.split(''); |
| 14358 | var map = {}; |
| 14359 | for (var i = 0; i < letters.length; ++i) { |
| 14360 | map[letters[i]] = letters[i]; |
| 14361 | } |
| 14362 | var obj = Object.assign({}, map); |
| 14363 | var actual = ''; |
| 14364 | for (var k in obj) { |
| 14365 | actual += k; |
| 14366 | } |
| 14367 | return str !== actual; |
| 14368 | }; |
| 14369 | |
| 14370 | var assignHasPendingExceptions = function () { |
| 14371 | if (!Object.assign || !Object.preventExtensions) { |
| 14372 | return false; |
| 14373 | } |
| 14374 | // Firefox 37 still has "pending exception" logic in its Object.assign implementation, |
| 14375 | // which is 72% slower than our shim, and Firefox 40's native implementation. |
| 14376 | var thrower = Object.preventExtensions({ 1: 2 }); |
| 14377 | try { |
| 14378 | Object.assign(thrower, 'xy'); |
| 14379 | } catch (e) { |
| 14380 | return thrower[1] === 'y'; |
| 14381 | } |
| 14382 | return false; |
| 14383 | }; |
| 14384 | |
| 14385 | module.exports = function getPolyfill() { |
| 14386 | if (!Object.assign) { |
| 14387 | return implementation; |
| 14388 | } |
| 14389 | if (lacksProperEnumerationOrder()) { |
| 14390 | return implementation; |
| 14391 | } |
| 14392 | if (assignHasPendingExceptions()) { |
| 14393 | return implementation; |
| 14394 | } |
| 14395 | return Object.assign; |
| 14396 | }; |
| 14397 | |
| 14398 | },{"./implementation":64}],67:[function(require,module,exports){ |
| 14399 | 'use strict'; |
| 14400 | |
| 14401 | var define = require('define-properties'); |
| 14402 | var getPolyfill = require('./polyfill'); |
| 14403 | |
| 14404 | module.exports = function shimAssign() { |
| 14405 | var polyfill = getPolyfill(); |
| 14406 | define( |
| 14407 | Object, |
| 14408 | { assign: polyfill }, |
| 14409 | { assign: function () { return Object.assign !== polyfill; } } |
| 14410 | ); |
| 14411 | return polyfill; |
| 14412 | }; |
| 14413 | |
| 14414 | },{"./polyfill":66,"define-properties":47}],68:[function(require,module,exports){ |
| 14415 | (function (process){ |
| 14416 | 'use strict'; |
| 14417 | |
| 14418 | if (!process.version || |
| 14419 | process.version.indexOf('v0.') === 0 || |
| 14420 | process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { |
| 14421 | module.exports = { nextTick: nextTick }; |
| 14422 | } else { |
| 14423 | module.exports = process |
| 14424 | } |
| 14425 | |
| 14426 | function nextTick(fn, arg1, arg2, arg3) { |
| 14427 | if (typeof fn !== 'function') { |
| 14428 | throw new TypeError('"callback" argument must be a function'); |
| 14429 | } |
| 14430 | var len = arguments.length; |
| 14431 | var args, i; |
| 14432 | switch (len) { |
| 14433 | case 0: |
| 14434 | case 1: |
| 14435 | return process.nextTick(fn); |
| 14436 | case 2: |
| 14437 | return process.nextTick(function afterTickOne() { |
| 14438 | fn.call(null, arg1); |
| 14439 | }); |
| 14440 | case 3: |
| 14441 | return process.nextTick(function afterTickTwo() { |
| 14442 | fn.call(null, arg1, arg2); |
| 14443 | }); |
| 14444 | case 4: |
| 14445 | return process.nextTick(function afterTickThree() { |
| 14446 | fn.call(null, arg1, arg2, arg3); |
| 14447 | }); |
| 14448 | default: |
| 14449 | args = new Array(len - 1); |
| 14450 | i = 0; |
| 14451 | while (i < args.length) { |
| 14452 | args[i++] = arguments[i]; |
| 14453 | } |
| 14454 | return process.nextTick(function afterTick() { |
| 14455 | fn.apply(null, args); |
| 14456 | }); |
| 14457 | } |
| 14458 | } |
| 14459 | |
| 14460 | |
| 14461 | }).call(this,require('_process')) |
| 14462 | },{"_process":69}],69:[function(require,module,exports){ |
| 14463 | // shim for using process in browser |
| 14464 | var process = module.exports = {}; |
| 14465 | |
| 14466 | // cached from whatever global is present so that test runners that stub it |
| 14467 | // don't break things. But we need to wrap it in a try catch in case it is |
| 14468 | // wrapped in strict mode code which doesn't define any globals. It's inside a |
| 14469 | // function because try/catches deoptimize in certain engines. |
| 14470 | |
| 14471 | var cachedSetTimeout; |
| 14472 | var cachedClearTimeout; |
| 14473 | |
| 14474 | function defaultSetTimout() { |
| 14475 | throw new Error('setTimeout has not been defined'); |
| 14476 | } |
| 14477 | function defaultClearTimeout () { |
| 14478 | throw new Error('clearTimeout has not been defined'); |
| 14479 | } |
| 14480 | (function () { |
| 14481 | try { |
| 14482 | if (typeof setTimeout === 'function') { |
| 14483 | cachedSetTimeout = setTimeout; |
| 14484 | } else { |
| 14485 | cachedSetTimeout = defaultSetTimout; |
| 14486 | } |
| 14487 | } catch (e) { |
| 14488 | cachedSetTimeout = defaultSetTimout; |
| 14489 | } |
| 14490 | try { |
| 14491 | if (typeof clearTimeout === 'function') { |
| 14492 | cachedClearTimeout = clearTimeout; |
| 14493 | } else { |
| 14494 | cachedClearTimeout = defaultClearTimeout; |
| 14495 | } |
| 14496 | } catch (e) { |
| 14497 | cachedClearTimeout = defaultClearTimeout; |
| 14498 | } |
| 14499 | } ()) |
| 14500 | function runTimeout(fun) { |
| 14501 | if (cachedSetTimeout === setTimeout) { |
| 14502 | //normal enviroments in sane situations |
| 14503 | return setTimeout(fun, 0); |
| 14504 | } |
| 14505 | // if setTimeout wasn't available but was latter defined |
| 14506 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { |
| 14507 | cachedSetTimeout = setTimeout; |
| 14508 | return setTimeout(fun, 0); |
| 14509 | } |
| 14510 | try { |
| 14511 | // when when somebody has screwed with setTimeout but no I.E. maddness |
| 14512 | return cachedSetTimeout(fun, 0); |
| 14513 | } catch(e){ |
| 14514 | try { |
| 14515 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| 14516 | return cachedSetTimeout.call(null, fun, 0); |
| 14517 | } catch(e){ |
| 14518 | // 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 |
| 14519 | return cachedSetTimeout.call(this, fun, 0); |
| 14520 | } |
| 14521 | } |
| 14522 | |
| 14523 | |
| 14524 | } |
| 14525 | function runClearTimeout(marker) { |
| 14526 | if (cachedClearTimeout === clearTimeout) { |
| 14527 | //normal enviroments in sane situations |
| 14528 | return clearTimeout(marker); |
| 14529 | } |
| 14530 | // if clearTimeout wasn't available but was latter defined |
| 14531 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { |
| 14532 | cachedClearTimeout = clearTimeout; |
| 14533 | return clearTimeout(marker); |
| 14534 | } |
| 14535 | try { |
| 14536 | // when when somebody has screwed with setTimeout but no I.E. maddness |
| 14537 | return cachedClearTimeout(marker); |
| 14538 | } catch (e){ |
| 14539 | try { |
| 14540 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| 14541 | return cachedClearTimeout.call(null, marker); |
| 14542 | } catch (e){ |
| 14543 | // 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. |
| 14544 | // Some versions of I.E. have different rules for clearTimeout vs setTimeout |
| 14545 | return cachedClearTimeout.call(this, marker); |
| 14546 | } |
| 14547 | } |
| 14548 | |
| 14549 | |
| 14550 | |
| 14551 | } |
| 14552 | var queue = []; |
| 14553 | var draining = false; |
| 14554 | var currentQueue; |
| 14555 | var queueIndex = -1; |
| 14556 | |
| 14557 | function cleanUpNextTick() { |
| 14558 | if (!draining || !currentQueue) { |
| 14559 | return; |
| 14560 | } |
| 14561 | draining = false; |
| 14562 | if (currentQueue.length) { |
| 14563 | queue = currentQueue.concat(queue); |
| 14564 | } else { |
| 14565 | queueIndex = -1; |
| 14566 | } |
| 14567 | if (queue.length) { |
| 14568 | drainQueue(); |
| 14569 | } |
| 14570 | } |
| 14571 | |
| 14572 | function drainQueue() { |
| 14573 | if (draining) { |
| 14574 | return; |
| 14575 | } |
| 14576 | var timeout = runTimeout(cleanUpNextTick); |
| 14577 | draining = true; |
| 14578 | |
| 14579 | var len = queue.length; |
| 14580 | while(len) { |
| 14581 | currentQueue = queue; |
| 14582 | queue = []; |
| 14583 | while (++queueIndex < len) { |
| 14584 | if (currentQueue) { |
| 14585 | currentQueue[queueIndex].run(); |
| 14586 | } |
| 14587 | } |
| 14588 | queueIndex = -1; |
| 14589 | len = queue.length; |
| 14590 | } |
| 14591 | currentQueue = null; |
| 14592 | draining = false; |
| 14593 | runClearTimeout(timeout); |
| 14594 | } |
| 14595 | |
| 14596 | process.nextTick = function (fun) { |
| 14597 | var args = new Array(arguments.length - 1); |
| 14598 | if (arguments.length > 1) { |
| 14599 | for (var i = 1; i < arguments.length; i++) { |
| 14600 | args[i - 1] = arguments[i]; |
| 14601 | } |
| 14602 | } |
| 14603 | queue.push(new Item(fun, args)); |
| 14604 | if (queue.length === 1 && !draining) { |
| 14605 | runTimeout(drainQueue); |
| 14606 | } |
| 14607 | }; |
| 14608 | |
| 14609 | // v8 likes predictible objects |
| 14610 | function Item(fun, array) { |
| 14611 | this.fun = fun; |
| 14612 | this.array = array; |
| 14613 | } |
| 14614 | Item.prototype.run = function () { |
| 14615 | this.fun.apply(null, this.array); |
| 14616 | }; |
| 14617 | process.title = 'browser'; |
| 14618 | process.browser = true; |
| 14619 | process.env = {}; |
| 14620 | process.argv = []; |
| 14621 | process.version = ''; // empty string to avoid regexp issues |
| 14622 | process.versions = {}; |
| 14623 | |
| 14624 | function noop() {} |
| 14625 | |
| 14626 | process.on = noop; |
| 14627 | process.addListener = noop; |
| 14628 | process.once = noop; |
| 14629 | process.off = noop; |
| 14630 | process.removeListener = noop; |
| 14631 | process.removeAllListeners = noop; |
| 14632 | process.emit = noop; |
| 14633 | process.prependListener = noop; |
| 14634 | process.prependOnceListener = noop; |
| 14635 | |
| 14636 | process.listeners = function (name) { return [] } |
| 14637 | |
| 14638 | process.binding = function (name) { |
| 14639 | throw new Error('process.binding is not supported'); |
| 14640 | }; |
| 14641 | |
| 14642 | process.cwd = function () { return '/' }; |
| 14643 | process.chdir = function (dir) { |
| 14644 | throw new Error('process.chdir is not supported'); |
| 14645 | }; |
| 14646 | process.umask = function() { return 0; }; |
| 14647 | |
| 14648 | },{}],70:[function(require,module,exports){ |
| 14649 | module.exports = require('./lib/_stream_duplex.js'); |
| 14650 | |
| 14651 | },{"./lib/_stream_duplex.js":71}],71:[function(require,module,exports){ |
| 14652 | // Copyright Joyent, Inc. and other Node contributors. |
| 14653 | // |
| 14654 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 14655 | // copy of this software and associated documentation files (the |
| 14656 | // "Software"), to deal in the Software without restriction, including |
| 14657 | // without limitation the rights to use, copy, modify, merge, publish, |
| 14658 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 14659 | // persons to whom the Software is furnished to do so, subject to the |
| 14660 | // following conditions: |
| 14661 | // |
| 14662 | // The above copyright notice and this permission notice shall be included |
| 14663 | // in all copies or substantial portions of the Software. |
| 14664 | // |
| 14665 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 14666 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 14667 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 14668 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 14669 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 14670 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 14671 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 14672 | |
| 14673 | // a duplex stream is just a stream that is both readable and writable. |
| 14674 | // Since JS doesn't have multiple prototypal inheritance, this class |
| 14675 | // prototypally inherits from Readable, and then parasitically from |
| 14676 | // Writable. |
| 14677 | |
| 14678 | 'use strict'; |
| 14679 | |
| 14680 | /*<replacement>*/ |
| 14681 | |
| 14682 | var pna = require('process-nextick-args'); |
| 14683 | /*</replacement>*/ |
| 14684 | |
| 14685 | /*<replacement>*/ |
| 14686 | var objectKeys = Object.keys || function (obj) { |
| 14687 | var keys = []; |
| 14688 | for (var key in obj) { |
| 14689 | keys.push(key); |
| 14690 | }return keys; |
| 14691 | }; |
| 14692 | /*</replacement>*/ |
| 14693 | |
| 14694 | module.exports = Duplex; |
| 14695 | |
| 14696 | /*<replacement>*/ |
| 14697 | var util = require('core-util-is'); |
| 14698 | util.inherits = require('inherits'); |
| 14699 | /*</replacement>*/ |
| 14700 | |
| 14701 | var Readable = require('./_stream_readable'); |
| 14702 | var Writable = require('./_stream_writable'); |
| 14703 | |
| 14704 | util.inherits(Duplex, Readable); |
| 14705 | |
| 14706 | { |
| 14707 | // avoid scope creep, the keys array can then be collected |
| 14708 | var keys = objectKeys(Writable.prototype); |
| 14709 | for (var v = 0; v < keys.length; v++) { |
| 14710 | var method = keys[v]; |
| 14711 | if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; |
| 14712 | } |
| 14713 | } |
| 14714 | |
| 14715 | function Duplex(options) { |
| 14716 | if (!(this instanceof Duplex)) return new Duplex(options); |
| 14717 | |
| 14718 | Readable.call(this, options); |
| 14719 | Writable.call(this, options); |
| 14720 | |
| 14721 | if (options && options.readable === false) this.readable = false; |
| 14722 | |
| 14723 | if (options && options.writable === false) this.writable = false; |
| 14724 | |
| 14725 | this.allowHalfOpen = true; |
| 14726 | if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; |
| 14727 | |
| 14728 | this.once('end', onend); |
| 14729 | } |
| 14730 | |
| 14731 | Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { |
| 14732 | // making it explicit this property is not enumerable |
| 14733 | // because otherwise some prototype manipulation in |
| 14734 | // userland will fail |
| 14735 | enumerable: false, |
| 14736 | get: function () { |
| 14737 | return this._writableState.highWaterMark; |
| 14738 | } |
| 14739 | }); |
| 14740 | |
| 14741 | // the no-half-open enforcer |
| 14742 | function onend() { |
| 14743 | // if we allow half-open state, or if the writable side ended, |
| 14744 | // then we're ok. |
| 14745 | if (this.allowHalfOpen || this._writableState.ended) return; |
| 14746 | |
| 14747 | // no more data can be written. |
| 14748 | // But allow more writes to happen in this tick. |
| 14749 | pna.nextTick(onEndNT, this); |
| 14750 | } |
| 14751 | |
| 14752 | function onEndNT(self) { |
| 14753 | self.end(); |
| 14754 | } |
| 14755 | |
| 14756 | Object.defineProperty(Duplex.prototype, 'destroyed', { |
| 14757 | get: function () { |
| 14758 | if (this._readableState === undefined || this._writableState === undefined) { |
| 14759 | return false; |
| 14760 | } |
| 14761 | return this._readableState.destroyed && this._writableState.destroyed; |
| 14762 | }, |
| 14763 | set: function (value) { |
| 14764 | // we ignore the value if the stream |
| 14765 | // has not been initialized yet |
| 14766 | if (this._readableState === undefined || this._writableState === undefined) { |
| 14767 | return; |
| 14768 | } |
| 14769 | |
| 14770 | // backward compatibility, the user is explicitly |
| 14771 | // managing destroyed |
| 14772 | this._readableState.destroyed = value; |
| 14773 | this._writableState.destroyed = value; |
| 14774 | } |
| 14775 | }); |
| 14776 | |
| 14777 | Duplex.prototype._destroy = function (err, cb) { |
| 14778 | this.push(null); |
| 14779 | this.end(); |
| 14780 | |
| 14781 | pna.nextTick(cb, err); |
| 14782 | }; |
| 14783 | },{"./_stream_readable":73,"./_stream_writable":75,"core-util-is":44,"inherits":56,"process-nextick-args":68}],72:[function(require,module,exports){ |
| 14784 | // Copyright Joyent, Inc. and other Node contributors. |
| 14785 | // |
| 14786 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 14787 | // copy of this software and associated documentation files (the |
| 14788 | // "Software"), to deal in the Software without restriction, including |
| 14789 | // without limitation the rights to use, copy, modify, merge, publish, |
| 14790 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 14791 | // persons to whom the Software is furnished to do so, subject to the |
| 14792 | // following conditions: |
| 14793 | // |
| 14794 | // The above copyright notice and this permission notice shall be included |
| 14795 | // in all copies or substantial portions of the Software. |
| 14796 | // |
| 14797 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 14798 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 14799 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 14800 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 14801 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 14802 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 14803 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 14804 | |
| 14805 | // a passthrough stream. |
| 14806 | // basically just the most minimal sort of Transform stream. |
| 14807 | // Every written chunk gets output as-is. |
| 14808 | |
| 14809 | 'use strict'; |
| 14810 | |
| 14811 | module.exports = PassThrough; |
| 14812 | |
| 14813 | var Transform = require('./_stream_transform'); |
| 14814 | |
| 14815 | /*<replacement>*/ |
| 14816 | var util = require('core-util-is'); |
| 14817 | util.inherits = require('inherits'); |
| 14818 | /*</replacement>*/ |
| 14819 | |
| 14820 | util.inherits(PassThrough, Transform); |
| 14821 | |
| 14822 | function PassThrough(options) { |
| 14823 | if (!(this instanceof PassThrough)) return new PassThrough(options); |
| 14824 | |
| 14825 | Transform.call(this, options); |
| 14826 | } |
| 14827 | |
| 14828 | PassThrough.prototype._transform = function (chunk, encoding, cb) { |
| 14829 | cb(null, chunk); |
| 14830 | }; |
| 14831 | },{"./_stream_transform":74,"core-util-is":44,"inherits":56}],73:[function(require,module,exports){ |
| 14832 | (function (process,global){ |
| 14833 | // Copyright Joyent, Inc. and other Node contributors. |
| 14834 | // |
| 14835 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 14836 | // copy of this software and associated documentation files (the |
| 14837 | // "Software"), to deal in the Software without restriction, including |
| 14838 | // without limitation the rights to use, copy, modify, merge, publish, |
| 14839 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 14840 | // persons to whom the Software is furnished to do so, subject to the |
| 14841 | // following conditions: |
| 14842 | // |
| 14843 | // The above copyright notice and this permission notice shall be included |
| 14844 | // in all copies or substantial portions of the Software. |
| 14845 | // |
| 14846 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 14847 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 14848 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 14849 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 14850 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 14851 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 14852 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 14853 | |
| 14854 | 'use strict'; |
| 14855 | |
| 14856 | /*<replacement>*/ |
| 14857 | |
| 14858 | var pna = require('process-nextick-args'); |
| 14859 | /*</replacement>*/ |
| 14860 | |
| 14861 | module.exports = Readable; |
| 14862 | |
| 14863 | /*<replacement>*/ |
| 14864 | var isArray = require('isarray'); |
| 14865 | /*</replacement>*/ |
| 14866 | |
| 14867 | /*<replacement>*/ |
| 14868 | var Duplex; |
| 14869 | /*</replacement>*/ |
| 14870 | |
| 14871 | Readable.ReadableState = ReadableState; |
| 14872 | |
| 14873 | /*<replacement>*/ |
| 14874 | var EE = require('events').EventEmitter; |
| 14875 | |
| 14876 | var EElistenerCount = function (emitter, type) { |
| 14877 | return emitter.listeners(type).length; |
| 14878 | }; |
| 14879 | /*</replacement>*/ |
| 14880 | |
| 14881 | /*<replacement>*/ |
| 14882 | var Stream = require('./internal/streams/stream'); |
| 14883 | /*</replacement>*/ |
| 14884 | |
| 14885 | /*<replacement>*/ |
| 14886 | |
| 14887 | var Buffer = require('safe-buffer').Buffer; |
| 14888 | var OurUint8Array = global.Uint8Array || function () {}; |
| 14889 | function _uint8ArrayToBuffer(chunk) { |
| 14890 | return Buffer.from(chunk); |
| 14891 | } |
| 14892 | function _isUint8Array(obj) { |
| 14893 | return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; |
| 14894 | } |
| 14895 | |
| 14896 | /*</replacement>*/ |
| 14897 | |
| 14898 | /*<replacement>*/ |
| 14899 | var util = require('core-util-is'); |
| 14900 | util.inherits = require('inherits'); |
| 14901 | /*</replacement>*/ |
| 14902 | |
| 14903 | /*<replacement>*/ |
| 14904 | var debugUtil = require('util'); |
| 14905 | var debug = void 0; |
| 14906 | if (debugUtil && debugUtil.debuglog) { |
| 14907 | debug = debugUtil.debuglog('stream'); |
| 14908 | } else { |
| 14909 | debug = function () {}; |
| 14910 | } |
| 14911 | /*</replacement>*/ |
| 14912 | |
| 14913 | var BufferList = require('./internal/streams/BufferList'); |
| 14914 | var destroyImpl = require('./internal/streams/destroy'); |
| 14915 | var StringDecoder; |
| 14916 | |
| 14917 | util.inherits(Readable, Stream); |
| 14918 | |
| 14919 | var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; |
| 14920 | |
| 14921 | function prependListener(emitter, event, fn) { |
| 14922 | // Sadly this is not cacheable as some libraries bundle their own |
| 14923 | // event emitter implementation with them. |
| 14924 | if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); |
| 14925 | |
| 14926 | // This is a hack to make sure that our error handler is attached before any |
| 14927 | // userland ones. NEVER DO THIS. This is here only because this code needs |
| 14928 | // to continue to work with older versions of Node.js that do not include |
| 14929 | // the prependListener() method. The goal is to eventually remove this hack. |
| 14930 | if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; |
| 14931 | } |
| 14932 | |
| 14933 | function ReadableState(options, stream) { |
| 14934 | Duplex = Duplex || require('./_stream_duplex'); |
| 14935 | |
| 14936 | options = options || {}; |
| 14937 | |
| 14938 | // Duplex streams are both readable and writable, but share |
| 14939 | // the same options object. |
| 14940 | // However, some cases require setting options to different |
| 14941 | // values for the readable and the writable sides of the duplex stream. |
| 14942 | // These options can be provided separately as readableXXX and writableXXX. |
| 14943 | var isDuplex = stream instanceof Duplex; |
| 14944 | |
| 14945 | // object stream flag. Used to make read(n) ignore n and to |
| 14946 | // make all the buffer merging and length checks go away |
| 14947 | this.objectMode = !!options.objectMode; |
| 14948 | |
| 14949 | if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; |
| 14950 | |
| 14951 | // the point at which it stops calling _read() to fill the buffer |
| 14952 | // Note: 0 is a valid value, means "don't call _read preemptively ever" |
| 14953 | var hwm = options.highWaterMark; |
| 14954 | var readableHwm = options.readableHighWaterMark; |
| 14955 | var defaultHwm = this.objectMode ? 16 : 16 * 1024; |
| 14956 | |
| 14957 | if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; |
| 14958 | |
| 14959 | // cast to ints. |
| 14960 | this.highWaterMark = Math.floor(this.highWaterMark); |
| 14961 | |
| 14962 | // A linked list is used to store data chunks instead of an array because the |
| 14963 | // linked list can remove elements from the beginning faster than |
| 14964 | // array.shift() |
| 14965 | this.buffer = new BufferList(); |
| 14966 | this.length = 0; |
| 14967 | this.pipes = null; |
| 14968 | this.pipesCount = 0; |
| 14969 | this.flowing = null; |
| 14970 | this.ended = false; |
| 14971 | this.endEmitted = false; |
| 14972 | this.reading = false; |
| 14973 | |
| 14974 | // a flag to be able to tell if the event 'readable'/'data' is emitted |
| 14975 | // immediately, or on a later tick. We set this to true at first, because |
| 14976 | // any actions that shouldn't happen until "later" should generally also |
| 14977 | // not happen before the first read call. |
| 14978 | this.sync = true; |
| 14979 | |
| 14980 | // whenever we return null, then we set a flag to say |
| 14981 | // that we're awaiting a 'readable' event emission. |
| 14982 | this.needReadable = false; |
| 14983 | this.emittedReadable = false; |
| 14984 | this.readableListening = false; |
| 14985 | this.resumeScheduled = false; |
| 14986 | |
| 14987 | // has it been destroyed |
| 14988 | this.destroyed = false; |
| 14989 | |
| 14990 | // Crypto is kind of old and crusty. Historically, its default string |
| 14991 | // encoding is 'binary' so we have to make this configurable. |
| 14992 | // Everything else in the universe uses 'utf8', though. |
| 14993 | this.defaultEncoding = options.defaultEncoding || 'utf8'; |
| 14994 | |
| 14995 | // the number of writers that are awaiting a drain event in .pipe()s |
| 14996 | this.awaitDrain = 0; |
| 14997 | |
| 14998 | // if true, a maybeReadMore has been scheduled |
| 14999 | this.readingMore = false; |
| 15000 | |
| 15001 | this.decoder = null; |
| 15002 | this.encoding = null; |
| 15003 | if (options.encoding) { |
| 15004 | if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; |
| 15005 | this.decoder = new StringDecoder(options.encoding); |
| 15006 | this.encoding = options.encoding; |
| 15007 | } |
| 15008 | } |
| 15009 | |
| 15010 | function Readable(options) { |
| 15011 | Duplex = Duplex || require('./_stream_duplex'); |
| 15012 | |
| 15013 | if (!(this instanceof Readable)) return new Readable(options); |
| 15014 | |
| 15015 | this._readableState = new ReadableState(options, this); |
| 15016 | |
| 15017 | // legacy |
| 15018 | this.readable = true; |
| 15019 | |
| 15020 | if (options) { |
| 15021 | if (typeof options.read === 'function') this._read = options.read; |
| 15022 | |
| 15023 | if (typeof options.destroy === 'function') this._destroy = options.destroy; |
| 15024 | } |
| 15025 | |
| 15026 | Stream.call(this); |
| 15027 | } |
| 15028 | |
| 15029 | Object.defineProperty(Readable.prototype, 'destroyed', { |
| 15030 | get: function () { |
| 15031 | if (this._readableState === undefined) { |
| 15032 | return false; |
| 15033 | } |
| 15034 | return this._readableState.destroyed; |
| 15035 | }, |
| 15036 | set: function (value) { |
| 15037 | // we ignore the value if the stream |
| 15038 | // has not been initialized yet |
| 15039 | if (!this._readableState) { |
| 15040 | return; |
| 15041 | } |
| 15042 | |
| 15043 | // backward compatibility, the user is explicitly |
| 15044 | // managing destroyed |
| 15045 | this._readableState.destroyed = value; |
| 15046 | } |
| 15047 | }); |
| 15048 | |
| 15049 | Readable.prototype.destroy = destroyImpl.destroy; |
| 15050 | Readable.prototype._undestroy = destroyImpl.undestroy; |
| 15051 | Readable.prototype._destroy = function (err, cb) { |
| 15052 | this.push(null); |
| 15053 | cb(err); |
| 15054 | }; |
| 15055 | |
| 15056 | // Manually shove something into the read() buffer. |
| 15057 | // This returns true if the highWaterMark has not been hit yet, |
| 15058 | // similar to how Writable.write() returns true if you should |
| 15059 | // write() some more. |
| 15060 | Readable.prototype.push = function (chunk, encoding) { |
| 15061 | var state = this._readableState; |
| 15062 | var skipChunkCheck; |
| 15063 | |
| 15064 | if (!state.objectMode) { |
| 15065 | if (typeof chunk === 'string') { |
| 15066 | encoding = encoding || state.defaultEncoding; |
| 15067 | if (encoding !== state.encoding) { |
| 15068 | chunk = Buffer.from(chunk, encoding); |
| 15069 | encoding = ''; |
| 15070 | } |
| 15071 | skipChunkCheck = true; |
| 15072 | } |
| 15073 | } else { |
| 15074 | skipChunkCheck = true; |
| 15075 | } |
| 15076 | |
| 15077 | return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); |
| 15078 | }; |
| 15079 | |
| 15080 | // Unshift should *always* be something directly out of read() |
| 15081 | Readable.prototype.unshift = function (chunk) { |
| 15082 | return readableAddChunk(this, chunk, null, true, false); |
| 15083 | }; |
| 15084 | |
| 15085 | function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { |
| 15086 | var state = stream._readableState; |
| 15087 | if (chunk === null) { |
| 15088 | state.reading = false; |
| 15089 | onEofChunk(stream, state); |
| 15090 | } else { |
| 15091 | var er; |
| 15092 | if (!skipChunkCheck) er = chunkInvalid(state, chunk); |
| 15093 | if (er) { |
| 15094 | stream.emit('error', er); |
| 15095 | } else if (state.objectMode || chunk && chunk.length > 0) { |
| 15096 | if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { |
| 15097 | chunk = _uint8ArrayToBuffer(chunk); |
| 15098 | } |
| 15099 | |
| 15100 | if (addToFront) { |
| 15101 | if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); |
| 15102 | } else if (state.ended) { |
| 15103 | stream.emit('error', new Error('stream.push() after EOF')); |
| 15104 | } else { |
| 15105 | state.reading = false; |
| 15106 | if (state.decoder && !encoding) { |
| 15107 | chunk = state.decoder.write(chunk); |
| 15108 | if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); |
| 15109 | } else { |
| 15110 | addChunk(stream, state, chunk, false); |
| 15111 | } |
| 15112 | } |
| 15113 | } else if (!addToFront) { |
| 15114 | state.reading = false; |
| 15115 | } |
| 15116 | } |
| 15117 | |
| 15118 | return needMoreData(state); |
| 15119 | } |
| 15120 | |
| 15121 | function addChunk(stream, state, chunk, addToFront) { |
| 15122 | if (state.flowing && state.length === 0 && !state.sync) { |
| 15123 | stream.emit('data', chunk); |
| 15124 | stream.read(0); |
| 15125 | } else { |
| 15126 | // update the buffer info. |
| 15127 | state.length += state.objectMode ? 1 : chunk.length; |
| 15128 | if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); |
| 15129 | |
| 15130 | if (state.needReadable) emitReadable(stream); |
| 15131 | } |
| 15132 | maybeReadMore(stream, state); |
| 15133 | } |
| 15134 | |
| 15135 | function chunkInvalid(state, chunk) { |
| 15136 | var er; |
| 15137 | if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { |
| 15138 | er = new TypeError('Invalid non-string/buffer chunk'); |
| 15139 | } |
| 15140 | return er; |
| 15141 | } |
| 15142 | |
| 15143 | // if it's past the high water mark, we can push in some more. |
| 15144 | // Also, if we have no data yet, we can stand some |
| 15145 | // more bytes. This is to work around cases where hwm=0, |
| 15146 | // such as the repl. Also, if the push() triggered a |
| 15147 | // readable event, and the user called read(largeNumber) such that |
| 15148 | // needReadable was set, then we ought to push more, so that another |
| 15149 | // 'readable' event will be triggered. |
| 15150 | function needMoreData(state) { |
| 15151 | return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); |
| 15152 | } |
| 15153 | |
| 15154 | Readable.prototype.isPaused = function () { |
| 15155 | return this._readableState.flowing === false; |
| 15156 | }; |
| 15157 | |
| 15158 | // backwards compatibility. |
| 15159 | Readable.prototype.setEncoding = function (enc) { |
| 15160 | if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; |
| 15161 | this._readableState.decoder = new StringDecoder(enc); |
| 15162 | this._readableState.encoding = enc; |
| 15163 | return this; |
| 15164 | }; |
| 15165 | |
| 15166 | // Don't raise the hwm > 8MB |
| 15167 | var MAX_HWM = 0x800000; |
| 15168 | function computeNewHighWaterMark(n) { |
| 15169 | if (n >= MAX_HWM) { |
| 15170 | n = MAX_HWM; |
| 15171 | } else { |
| 15172 | // Get the next highest power of 2 to prevent increasing hwm excessively in |
| 15173 | // tiny amounts |
| 15174 | n--; |
| 15175 | n |= n >>> 1; |
| 15176 | n |= n >>> 2; |
| 15177 | n |= n >>> 4; |
| 15178 | n |= n >>> 8; |
| 15179 | n |= n >>> 16; |
| 15180 | n++; |
| 15181 | } |
| 15182 | return n; |
| 15183 | } |
| 15184 | |
| 15185 | // This function is designed to be inlinable, so please take care when making |
| 15186 | // changes to the function body. |
| 15187 | function howMuchToRead(n, state) { |
| 15188 | if (n <= 0 || state.length === 0 && state.ended) return 0; |
| 15189 | if (state.objectMode) return 1; |
| 15190 | if (n !== n) { |
| 15191 | // Only flow one buffer at a time |
| 15192 | if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; |
| 15193 | } |
| 15194 | // If we're asking for more than the current hwm, then raise the hwm. |
| 15195 | if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); |
| 15196 | if (n <= state.length) return n; |
| 15197 | // Don't have enough |
| 15198 | if (!state.ended) { |
| 15199 | state.needReadable = true; |
| 15200 | return 0; |
| 15201 | } |
| 15202 | return state.length; |
| 15203 | } |
| 15204 | |
| 15205 | // you can override either this method, or the async _read(n) below. |
| 15206 | Readable.prototype.read = function (n) { |
| 15207 | debug('read', n); |
| 15208 | n = parseInt(n, 10); |
| 15209 | var state = this._readableState; |
| 15210 | var nOrig = n; |
| 15211 | |
| 15212 | if (n !== 0) state.emittedReadable = false; |
| 15213 | |
| 15214 | // if we're doing read(0) to trigger a readable event, but we |
| 15215 | // already have a bunch of data in the buffer, then just trigger |
| 15216 | // the 'readable' event and move on. |
| 15217 | if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { |
| 15218 | debug('read: emitReadable', state.length, state.ended); |
| 15219 | if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); |
| 15220 | return null; |
| 15221 | } |
| 15222 | |
| 15223 | n = howMuchToRead(n, state); |
| 15224 | |
| 15225 | // if we've ended, and we're now clear, then finish it up. |
| 15226 | if (n === 0 && state.ended) { |
| 15227 | if (state.length === 0) endReadable(this); |
| 15228 | return null; |
| 15229 | } |
| 15230 | |
| 15231 | // All the actual chunk generation logic needs to be |
| 15232 | // *below* the call to _read. The reason is that in certain |
| 15233 | // synthetic stream cases, such as passthrough streams, _read |
| 15234 | // may be a completely synchronous operation which may change |
| 15235 | // the state of the read buffer, providing enough data when |
| 15236 | // before there was *not* enough. |
| 15237 | // |
| 15238 | // So, the steps are: |
| 15239 | // 1. Figure out what the state of things will be after we do |
| 15240 | // a read from the buffer. |
| 15241 | // |
| 15242 | // 2. If that resulting state will trigger a _read, then call _read. |
| 15243 | // Note that this may be asynchronous, or synchronous. Yes, it is |
| 15244 | // deeply ugly to write APIs this way, but that still doesn't mean |
| 15245 | // that the Readable class should behave improperly, as streams are |
| 15246 | // designed to be sync/async agnostic. |
| 15247 | // Take note if the _read call is sync or async (ie, if the read call |
| 15248 | // has returned yet), so that we know whether or not it's safe to emit |
| 15249 | // 'readable' etc. |
| 15250 | // |
| 15251 | // 3. Actually pull the requested chunks out of the buffer and return. |
| 15252 | |
| 15253 | // if we need a readable event, then we need to do some reading. |
| 15254 | var doRead = state.needReadable; |
| 15255 | debug('need readable', doRead); |
| 15256 | |
| 15257 | // if we currently have less than the highWaterMark, then also read some |
| 15258 | if (state.length === 0 || state.length - n < state.highWaterMark) { |
| 15259 | doRead = true; |
| 15260 | debug('length less than watermark', doRead); |
| 15261 | } |
| 15262 | |
| 15263 | // however, if we've ended, then there's no point, and if we're already |
| 15264 | // reading, then it's unnecessary. |
| 15265 | if (state.ended || state.reading) { |
| 15266 | doRead = false; |
| 15267 | debug('reading or ended', doRead); |
| 15268 | } else if (doRead) { |
| 15269 | debug('do read'); |
| 15270 | state.reading = true; |
| 15271 | state.sync = true; |
| 15272 | // if the length is currently zero, then we *need* a readable event. |
| 15273 | if (state.length === 0) state.needReadable = true; |
| 15274 | // call internal read method |
| 15275 | this._read(state.highWaterMark); |
| 15276 | state.sync = false; |
| 15277 | // If _read pushed data synchronously, then `reading` will be false, |
| 15278 | // and we need to re-evaluate how much data we can return to the user. |
| 15279 | if (!state.reading) n = howMuchToRead(nOrig, state); |
| 15280 | } |
| 15281 | |
| 15282 | var ret; |
| 15283 | if (n > 0) ret = fromList(n, state);else ret = null; |
| 15284 | |
| 15285 | if (ret === null) { |
| 15286 | state.needReadable = true; |
| 15287 | n = 0; |
| 15288 | } else { |
| 15289 | state.length -= n; |
| 15290 | } |
| 15291 | |
| 15292 | if (state.length === 0) { |
| 15293 | // If we have nothing in the buffer, then we want to know |
| 15294 | // as soon as we *do* get something into the buffer. |
| 15295 | if (!state.ended) state.needReadable = true; |
| 15296 | |
| 15297 | // If we tried to read() past the EOF, then emit end on the next tick. |
| 15298 | if (nOrig !== n && state.ended) endReadable(this); |
| 15299 | } |
| 15300 | |
| 15301 | if (ret !== null) this.emit('data', ret); |
| 15302 | |
| 15303 | return ret; |
| 15304 | }; |
| 15305 | |
| 15306 | function onEofChunk(stream, state) { |
| 15307 | if (state.ended) return; |
| 15308 | if (state.decoder) { |
| 15309 | var chunk = state.decoder.end(); |
| 15310 | if (chunk && chunk.length) { |
| 15311 | state.buffer.push(chunk); |
| 15312 | state.length += state.objectMode ? 1 : chunk.length; |
| 15313 | } |
| 15314 | } |
| 15315 | state.ended = true; |
| 15316 | |
| 15317 | // emit 'readable' now to make sure it gets picked up. |
| 15318 | emitReadable(stream); |
| 15319 | } |
| 15320 | |
| 15321 | // Don't emit readable right away in sync mode, because this can trigger |
| 15322 | // another read() call => stack overflow. This way, it might trigger |
| 15323 | // a nextTick recursion warning, but that's not so bad. |
| 15324 | function emitReadable(stream) { |
| 15325 | var state = stream._readableState; |
| 15326 | state.needReadable = false; |
| 15327 | if (!state.emittedReadable) { |
| 15328 | debug('emitReadable', state.flowing); |
| 15329 | state.emittedReadable = true; |
| 15330 | if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); |
| 15331 | } |
| 15332 | } |
| 15333 | |
| 15334 | function emitReadable_(stream) { |
| 15335 | debug('emit readable'); |
| 15336 | stream.emit('readable'); |
| 15337 | flow(stream); |
| 15338 | } |
| 15339 | |
| 15340 | // at this point, the user has presumably seen the 'readable' event, |
| 15341 | // and called read() to consume some data. that may have triggered |
| 15342 | // in turn another _read(n) call, in which case reading = true if |
| 15343 | // it's in progress. |
| 15344 | // However, if we're not ended, or reading, and the length < hwm, |
| 15345 | // then go ahead and try to read some more preemptively. |
| 15346 | function maybeReadMore(stream, state) { |
| 15347 | if (!state.readingMore) { |
| 15348 | state.readingMore = true; |
| 15349 | pna.nextTick(maybeReadMore_, stream, state); |
| 15350 | } |
| 15351 | } |
| 15352 | |
| 15353 | function maybeReadMore_(stream, state) { |
| 15354 | var len = state.length; |
| 15355 | while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { |
| 15356 | debug('maybeReadMore read 0'); |
| 15357 | stream.read(0); |
| 15358 | if (len === state.length) |
| 15359 | // didn't get any data, stop spinning. |
| 15360 | break;else len = state.length; |
| 15361 | } |
| 15362 | state.readingMore = false; |
| 15363 | } |
| 15364 | |
| 15365 | // abstract method. to be overridden in specific implementation classes. |
| 15366 | // call cb(er, data) where data is <= n in length. |
| 15367 | // for virtual (non-string, non-buffer) streams, "length" is somewhat |
| 15368 | // arbitrary, and perhaps not very meaningful. |
| 15369 | Readable.prototype._read = function (n) { |
| 15370 | this.emit('error', new Error('_read() is not implemented')); |
| 15371 | }; |
| 15372 | |
| 15373 | Readable.prototype.pipe = function (dest, pipeOpts) { |
| 15374 | var src = this; |
| 15375 | var state = this._readableState; |
| 15376 | |
| 15377 | switch (state.pipesCount) { |
| 15378 | case 0: |
| 15379 | state.pipes = dest; |
| 15380 | break; |
| 15381 | case 1: |
| 15382 | state.pipes = [state.pipes, dest]; |
| 15383 | break; |
| 15384 | default: |
| 15385 | state.pipes.push(dest); |
| 15386 | break; |
| 15387 | } |
| 15388 | state.pipesCount += 1; |
| 15389 | debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); |
| 15390 | |
| 15391 | var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; |
| 15392 | |
| 15393 | var endFn = doEnd ? onend : unpipe; |
| 15394 | if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); |
| 15395 | |
| 15396 | dest.on('unpipe', onunpipe); |
| 15397 | function onunpipe(readable, unpipeInfo) { |
| 15398 | debug('onunpipe'); |
| 15399 | if (readable === src) { |
| 15400 | if (unpipeInfo && unpipeInfo.hasUnpiped === false) { |
| 15401 | unpipeInfo.hasUnpiped = true; |
| 15402 | cleanup(); |
| 15403 | } |
| 15404 | } |
| 15405 | } |
| 15406 | |
| 15407 | function onend() { |
| 15408 | debug('onend'); |
| 15409 | dest.end(); |
| 15410 | } |
| 15411 | |
| 15412 | // when the dest drains, it reduces the awaitDrain counter |
| 15413 | // on the source. This would be more elegant with a .once() |
| 15414 | // handler in flow(), but adding and removing repeatedly is |
| 15415 | // too slow. |
| 15416 | var ondrain = pipeOnDrain(src); |
| 15417 | dest.on('drain', ondrain); |
| 15418 | |
| 15419 | var cleanedUp = false; |
| 15420 | function cleanup() { |
| 15421 | debug('cleanup'); |
| 15422 | // cleanup event handlers once the pipe is broken |
| 15423 | dest.removeListener('close', onclose); |
| 15424 | dest.removeListener('finish', onfinish); |
| 15425 | dest.removeListener('drain', ondrain); |
| 15426 | dest.removeListener('error', onerror); |
| 15427 | dest.removeListener('unpipe', onunpipe); |
| 15428 | src.removeListener('end', onend); |
| 15429 | src.removeListener('end', unpipe); |
| 15430 | src.removeListener('data', ondata); |
| 15431 | |
| 15432 | cleanedUp = true; |
| 15433 | |
| 15434 | // if the reader is waiting for a drain event from this |
| 15435 | // specific writer, then it would cause it to never start |
| 15436 | // flowing again. |
| 15437 | // So, if this is awaiting a drain, then we just call it now. |
| 15438 | // If we don't know, then assume that we are waiting for one. |
| 15439 | if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); |
| 15440 | } |
| 15441 | |
| 15442 | // If the user pushes more data while we're writing to dest then we'll end up |
| 15443 | // in ondata again. However, we only want to increase awaitDrain once because |
| 15444 | // dest will only emit one 'drain' event for the multiple writes. |
| 15445 | // => Introduce a guard on increasing awaitDrain. |
| 15446 | var increasedAwaitDrain = false; |
| 15447 | src.on('data', ondata); |
| 15448 | function ondata(chunk) { |
| 15449 | debug('ondata'); |
| 15450 | increasedAwaitDrain = false; |
| 15451 | var ret = dest.write(chunk); |
| 15452 | if (false === ret && !increasedAwaitDrain) { |
| 15453 | // If the user unpiped during `dest.write()`, it is possible |
| 15454 | // to get stuck in a permanently paused state if that write |
| 15455 | // also returned false. |
| 15456 | // => Check whether `dest` is still a piping destination. |
| 15457 | if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { |
| 15458 | debug('false write response, pause', src._readableState.awaitDrain); |
| 15459 | src._readableState.awaitDrain++; |
| 15460 | increasedAwaitDrain = true; |
| 15461 | } |
| 15462 | src.pause(); |
| 15463 | } |
| 15464 | } |
| 15465 | |
| 15466 | // if the dest has an error, then stop piping into it. |
| 15467 | // however, don't suppress the throwing behavior for this. |
| 15468 | function onerror(er) { |
| 15469 | debug('onerror', er); |
| 15470 | unpipe(); |
| 15471 | dest.removeListener('error', onerror); |
| 15472 | if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); |
| 15473 | } |
| 15474 | |
| 15475 | // Make sure our error handler is attached before userland ones. |
| 15476 | prependListener(dest, 'error', onerror); |
| 15477 | |
| 15478 | // Both close and finish should trigger unpipe, but only once. |
| 15479 | function onclose() { |
| 15480 | dest.removeListener('finish', onfinish); |
| 15481 | unpipe(); |
| 15482 | } |
| 15483 | dest.once('close', onclose); |
| 15484 | function onfinish() { |
| 15485 | debug('onfinish'); |
| 15486 | dest.removeListener('close', onclose); |
| 15487 | unpipe(); |
| 15488 | } |
| 15489 | dest.once('finish', onfinish); |
| 15490 | |
| 15491 | function unpipe() { |
| 15492 | debug('unpipe'); |
| 15493 | src.unpipe(dest); |
| 15494 | } |
| 15495 | |
| 15496 | // tell the dest that it's being piped to |
| 15497 | dest.emit('pipe', src); |
| 15498 | |
| 15499 | // start the flow if it hasn't been started already. |
| 15500 | if (!state.flowing) { |
| 15501 | debug('pipe resume'); |
| 15502 | src.resume(); |
| 15503 | } |
| 15504 | |
| 15505 | return dest; |
| 15506 | }; |
| 15507 | |
| 15508 | function pipeOnDrain(src) { |
| 15509 | return function () { |
| 15510 | var state = src._readableState; |
| 15511 | debug('pipeOnDrain', state.awaitDrain); |
| 15512 | if (state.awaitDrain) state.awaitDrain--; |
| 15513 | if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { |
| 15514 | state.flowing = true; |
| 15515 | flow(src); |
| 15516 | } |
| 15517 | }; |
| 15518 | } |
| 15519 | |
| 15520 | Readable.prototype.unpipe = function (dest) { |
| 15521 | var state = this._readableState; |
| 15522 | var unpipeInfo = { hasUnpiped: false }; |
| 15523 | |
| 15524 | // if we're not piping anywhere, then do nothing. |
| 15525 | if (state.pipesCount === 0) return this; |
| 15526 | |
| 15527 | // just one destination. most common case. |
| 15528 | if (state.pipesCount === 1) { |
| 15529 | // passed in one, but it's not the right one. |
| 15530 | if (dest && dest !== state.pipes) return this; |
| 15531 | |
| 15532 | if (!dest) dest = state.pipes; |
| 15533 | |
| 15534 | // got a match. |
| 15535 | state.pipes = null; |
| 15536 | state.pipesCount = 0; |
| 15537 | state.flowing = false; |
| 15538 | if (dest) dest.emit('unpipe', this, unpipeInfo); |
| 15539 | return this; |
| 15540 | } |
| 15541 | |
| 15542 | // slow case. multiple pipe destinations. |
| 15543 | |
| 15544 | if (!dest) { |
| 15545 | // remove all. |
| 15546 | var dests = state.pipes; |
| 15547 | var len = state.pipesCount; |
| 15548 | state.pipes = null; |
| 15549 | state.pipesCount = 0; |
| 15550 | state.flowing = false; |
| 15551 | |
| 15552 | for (var i = 0; i < len; i++) { |
| 15553 | dests[i].emit('unpipe', this, unpipeInfo); |
| 15554 | }return this; |
| 15555 | } |
| 15556 | |
| 15557 | // try to find the right one. |
| 15558 | var index = indexOf(state.pipes, dest); |
| 15559 | if (index === -1) return this; |
| 15560 | |
| 15561 | state.pipes.splice(index, 1); |
| 15562 | state.pipesCount -= 1; |
| 15563 | if (state.pipesCount === 1) state.pipes = state.pipes[0]; |
| 15564 | |
| 15565 | dest.emit('unpipe', this, unpipeInfo); |
| 15566 | |
| 15567 | return this; |
| 15568 | }; |
| 15569 | |
| 15570 | // set up data events if they are asked for |
| 15571 | // Ensure readable listeners eventually get something |
| 15572 | Readable.prototype.on = function (ev, fn) { |
| 15573 | var res = Stream.prototype.on.call(this, ev, fn); |
| 15574 | |
| 15575 | if (ev === 'data') { |
| 15576 | // Start flowing on next tick if stream isn't explicitly paused |
| 15577 | if (this._readableState.flowing !== false) this.resume(); |
| 15578 | } else if (ev === 'readable') { |
| 15579 | var state = this._readableState; |
| 15580 | if (!state.endEmitted && !state.readableListening) { |
| 15581 | state.readableListening = state.needReadable = true; |
| 15582 | state.emittedReadable = false; |
| 15583 | if (!state.reading) { |
| 15584 | pna.nextTick(nReadingNextTick, this); |
| 15585 | } else if (state.length) { |
| 15586 | emitReadable(this); |
| 15587 | } |
| 15588 | } |
| 15589 | } |
| 15590 | |
| 15591 | return res; |
| 15592 | }; |
| 15593 | Readable.prototype.addListener = Readable.prototype.on; |
| 15594 | |
| 15595 | function nReadingNextTick(self) { |
| 15596 | debug('readable nexttick read 0'); |
| 15597 | self.read(0); |
| 15598 | } |
| 15599 | |
| 15600 | // pause() and resume() are remnants of the legacy readable stream API |
| 15601 | // If the user uses them, then switch into old mode. |
| 15602 | Readable.prototype.resume = function () { |
| 15603 | var state = this._readableState; |
| 15604 | if (!state.flowing) { |
| 15605 | debug('resume'); |
| 15606 | state.flowing = true; |
| 15607 | resume(this, state); |
| 15608 | } |
| 15609 | return this; |
| 15610 | }; |
| 15611 | |
| 15612 | function resume(stream, state) { |
| 15613 | if (!state.resumeScheduled) { |
| 15614 | state.resumeScheduled = true; |
| 15615 | pna.nextTick(resume_, stream, state); |
| 15616 | } |
| 15617 | } |
| 15618 | |
| 15619 | function resume_(stream, state) { |
| 15620 | if (!state.reading) { |
| 15621 | debug('resume read 0'); |
| 15622 | stream.read(0); |
| 15623 | } |
| 15624 | |
| 15625 | state.resumeScheduled = false; |
| 15626 | state.awaitDrain = 0; |
| 15627 | stream.emit('resume'); |
| 15628 | flow(stream); |
| 15629 | if (state.flowing && !state.reading) stream.read(0); |
| 15630 | } |
| 15631 | |
| 15632 | Readable.prototype.pause = function () { |
| 15633 | debug('call pause flowing=%j', this._readableState.flowing); |
| 15634 | if (false !== this._readableState.flowing) { |
| 15635 | debug('pause'); |
| 15636 | this._readableState.flowing = false; |
| 15637 | this.emit('pause'); |
| 15638 | } |
| 15639 | return this; |
| 15640 | }; |
| 15641 | |
| 15642 | function flow(stream) { |
| 15643 | var state = stream._readableState; |
| 15644 | debug('flow', state.flowing); |
| 15645 | while (state.flowing && stream.read() !== null) {} |
| 15646 | } |
| 15647 | |
| 15648 | // wrap an old-style stream as the async data source. |
| 15649 | // This is *not* part of the readable stream interface. |
| 15650 | // It is an ugly unfortunate mess of history. |
| 15651 | Readable.prototype.wrap = function (stream) { |
| 15652 | var _this = this; |
| 15653 | |
| 15654 | var state = this._readableState; |
| 15655 | var paused = false; |
| 15656 | |
| 15657 | stream.on('end', function () { |
| 15658 | debug('wrapped end'); |
| 15659 | if (state.decoder && !state.ended) { |
| 15660 | var chunk = state.decoder.end(); |
| 15661 | if (chunk && chunk.length) _this.push(chunk); |
| 15662 | } |
| 15663 | |
| 15664 | _this.push(null); |
| 15665 | }); |
| 15666 | |
| 15667 | stream.on('data', function (chunk) { |
| 15668 | debug('wrapped data'); |
| 15669 | if (state.decoder) chunk = state.decoder.write(chunk); |
| 15670 | |
| 15671 | // don't skip over falsy values in objectMode |
| 15672 | if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; |
| 15673 | |
| 15674 | var ret = _this.push(chunk); |
| 15675 | if (!ret) { |
| 15676 | paused = true; |
| 15677 | stream.pause(); |
| 15678 | } |
| 15679 | }); |
| 15680 | |
| 15681 | // proxy all the other methods. |
| 15682 | // important when wrapping filters and duplexes. |
| 15683 | for (var i in stream) { |
| 15684 | if (this[i] === undefined && typeof stream[i] === 'function') { |
| 15685 | this[i] = function (method) { |
| 15686 | return function () { |
| 15687 | return stream[method].apply(stream, arguments); |
| 15688 | }; |
| 15689 | }(i); |
| 15690 | } |
| 15691 | } |
| 15692 | |
| 15693 | // proxy certain important events. |
| 15694 | for (var n = 0; n < kProxyEvents.length; n++) { |
| 15695 | stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); |
| 15696 | } |
| 15697 | |
| 15698 | // when we try to consume some more bytes, simply unpause the |
| 15699 | // underlying stream. |
| 15700 | this._read = function (n) { |
| 15701 | debug('wrapped _read', n); |
| 15702 | if (paused) { |
| 15703 | paused = false; |
| 15704 | stream.resume(); |
| 15705 | } |
| 15706 | }; |
| 15707 | |
| 15708 | return this; |
| 15709 | }; |
| 15710 | |
| 15711 | Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { |
| 15712 | // making it explicit this property is not enumerable |
| 15713 | // because otherwise some prototype manipulation in |
| 15714 | // userland will fail |
| 15715 | enumerable: false, |
| 15716 | get: function () { |
| 15717 | return this._readableState.highWaterMark; |
| 15718 | } |
| 15719 | }); |
| 15720 | |
| 15721 | // exposed for testing purposes only. |
| 15722 | Readable._fromList = fromList; |
| 15723 | |
| 15724 | // Pluck off n bytes from an array of buffers. |
| 15725 | // Length is the combined lengths of all the buffers in the list. |
| 15726 | // This function is designed to be inlinable, so please take care when making |
| 15727 | // changes to the function body. |
| 15728 | function fromList(n, state) { |
| 15729 | // nothing buffered |
| 15730 | if (state.length === 0) return null; |
| 15731 | |
| 15732 | var ret; |
| 15733 | if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { |
| 15734 | // read it all, truncate the list |
| 15735 | 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); |
| 15736 | state.buffer.clear(); |
| 15737 | } else { |
| 15738 | // read part of list |
| 15739 | ret = fromListPartial(n, state.buffer, state.decoder); |
| 15740 | } |
| 15741 | |
| 15742 | return ret; |
| 15743 | } |
| 15744 | |
| 15745 | // Extracts only enough buffered data to satisfy the amount requested. |
| 15746 | // This function is designed to be inlinable, so please take care when making |
| 15747 | // changes to the function body. |
| 15748 | function fromListPartial(n, list, hasStrings) { |
| 15749 | var ret; |
| 15750 | if (n < list.head.data.length) { |
| 15751 | // slice is the same for buffers and strings |
| 15752 | ret = list.head.data.slice(0, n); |
| 15753 | list.head.data = list.head.data.slice(n); |
| 15754 | } else if (n === list.head.data.length) { |
| 15755 | // first chunk is a perfect match |
| 15756 | ret = list.shift(); |
| 15757 | } else { |
| 15758 | // result spans more than one buffer |
| 15759 | ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); |
| 15760 | } |
| 15761 | return ret; |
| 15762 | } |
| 15763 | |
| 15764 | // Copies a specified amount of characters from the list of buffered data |
| 15765 | // chunks. |
| 15766 | // This function is designed to be inlinable, so please take care when making |
| 15767 | // changes to the function body. |
| 15768 | function copyFromBufferString(n, list) { |
| 15769 | var p = list.head; |
| 15770 | var c = 1; |
| 15771 | var ret = p.data; |
| 15772 | n -= ret.length; |
| 15773 | while (p = p.next) { |
| 15774 | var str = p.data; |
| 15775 | var nb = n > str.length ? str.length : n; |
| 15776 | if (nb === str.length) ret += str;else ret += str.slice(0, n); |
| 15777 | n -= nb; |
| 15778 | if (n === 0) { |
| 15779 | if (nb === str.length) { |
| 15780 | ++c; |
| 15781 | if (p.next) list.head = p.next;else list.head = list.tail = null; |
| 15782 | } else { |
| 15783 | list.head = p; |
| 15784 | p.data = str.slice(nb); |
| 15785 | } |
| 15786 | break; |
| 15787 | } |
| 15788 | ++c; |
| 15789 | } |
| 15790 | list.length -= c; |
| 15791 | return ret; |
| 15792 | } |
| 15793 | |
| 15794 | // Copies a specified amount of bytes from the list of buffered data chunks. |
| 15795 | // This function is designed to be inlinable, so please take care when making |
| 15796 | // changes to the function body. |
| 15797 | function copyFromBuffer(n, list) { |
| 15798 | var ret = Buffer.allocUnsafe(n); |
| 15799 | var p = list.head; |
| 15800 | var c = 1; |
| 15801 | p.data.copy(ret); |
| 15802 | n -= p.data.length; |
| 15803 | while (p = p.next) { |
| 15804 | var buf = p.data; |
| 15805 | var nb = n > buf.length ? buf.length : n; |
| 15806 | buf.copy(ret, ret.length - n, 0, nb); |
| 15807 | n -= nb; |
| 15808 | if (n === 0) { |
| 15809 | if (nb === buf.length) { |
| 15810 | ++c; |
| 15811 | if (p.next) list.head = p.next;else list.head = list.tail = null; |
| 15812 | } else { |
| 15813 | list.head = p; |
| 15814 | p.data = buf.slice(nb); |
| 15815 | } |
| 15816 | break; |
| 15817 | } |
| 15818 | ++c; |
| 15819 | } |
| 15820 | list.length -= c; |
| 15821 | return ret; |
| 15822 | } |
| 15823 | |
| 15824 | function endReadable(stream) { |
| 15825 | var state = stream._readableState; |
| 15826 | |
| 15827 | // If we get here before consuming all the bytes, then that is a |
| 15828 | // bug in node. Should never happen. |
| 15829 | if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); |
| 15830 | |
| 15831 | if (!state.endEmitted) { |
| 15832 | state.ended = true; |
| 15833 | pna.nextTick(endReadableNT, state, stream); |
| 15834 | } |
| 15835 | } |
| 15836 | |
| 15837 | function endReadableNT(state, stream) { |
| 15838 | // Check that we didn't get one last unshift. |
| 15839 | if (!state.endEmitted && state.length === 0) { |
| 15840 | state.endEmitted = true; |
| 15841 | stream.readable = false; |
| 15842 | stream.emit('end'); |
| 15843 | } |
| 15844 | } |
| 15845 | |
| 15846 | function indexOf(xs, x) { |
| 15847 | for (var i = 0, l = xs.length; i < l; i++) { |
| 15848 | if (xs[i] === x) return i; |
| 15849 | } |
| 15850 | return -1; |
| 15851 | } |
| 15852 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 15853 | },{"./_stream_duplex":71,"./internal/streams/BufferList":76,"./internal/streams/destroy":77,"./internal/streams/stream":78,"_process":69,"core-util-is":44,"events":50,"inherits":56,"isarray":58,"process-nextick-args":68,"safe-buffer":83,"string_decoder/":85,"util":40}],74:[function(require,module,exports){ |
| 15854 | // Copyright Joyent, Inc. and other Node contributors. |
| 15855 | // |
| 15856 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 15857 | // copy of this software and associated documentation files (the |
| 15858 | // "Software"), to deal in the Software without restriction, including |
| 15859 | // without limitation the rights to use, copy, modify, merge, publish, |
| 15860 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 15861 | // persons to whom the Software is furnished to do so, subject to the |
| 15862 | // following conditions: |
| 15863 | // |
| 15864 | // The above copyright notice and this permission notice shall be included |
| 15865 | // in all copies or substantial portions of the Software. |
| 15866 | // |
| 15867 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15868 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 15869 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 15870 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 15871 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 15872 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 15873 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 15874 | |
| 15875 | // a transform stream is a readable/writable stream where you do |
| 15876 | // something with the data. Sometimes it's called a "filter", |
| 15877 | // but that's not a great name for it, since that implies a thing where |
| 15878 | // some bits pass through, and others are simply ignored. (That would |
| 15879 | // be a valid example of a transform, of course.) |
| 15880 | // |
| 15881 | // While the output is causally related to the input, it's not a |
| 15882 | // necessarily symmetric or synchronous transformation. For example, |
| 15883 | // a zlib stream might take multiple plain-text writes(), and then |
| 15884 | // emit a single compressed chunk some time in the future. |
| 15885 | // |
| 15886 | // Here's how this works: |
| 15887 | // |
| 15888 | // The Transform stream has all the aspects of the readable and writable |
| 15889 | // stream classes. When you write(chunk), that calls _write(chunk,cb) |
| 15890 | // internally, and returns false if there's a lot of pending writes |
| 15891 | // buffered up. When you call read(), that calls _read(n) until |
| 15892 | // there's enough pending readable data buffered up. |
| 15893 | // |
| 15894 | // In a transform stream, the written data is placed in a buffer. When |
| 15895 | // _read(n) is called, it transforms the queued up data, calling the |
| 15896 | // buffered _write cb's as it consumes chunks. If consuming a single |
| 15897 | // written chunk would result in multiple output chunks, then the first |
| 15898 | // outputted bit calls the readcb, and subsequent chunks just go into |
| 15899 | // the read buffer, and will cause it to emit 'readable' if necessary. |
| 15900 | // |
| 15901 | // This way, back-pressure is actually determined by the reading side, |
| 15902 | // since _read has to be called to start processing a new chunk. However, |
| 15903 | // a pathological inflate type of transform can cause excessive buffering |
| 15904 | // here. For example, imagine a stream where every byte of input is |
| 15905 | // interpreted as an integer from 0-255, and then results in that many |
| 15906 | // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in |
| 15907 | // 1kb of data being output. In this case, you could write a very small |
| 15908 | // amount of input, and end up with a very large amount of output. In |
| 15909 | // such a pathological inflating mechanism, there'd be no way to tell |
| 15910 | // the system to stop doing the transform. A single 4MB write could |
| 15911 | // cause the system to run out of memory. |
| 15912 | // |
| 15913 | // However, even in such a pathological case, only a single written chunk |
| 15914 | // would be consumed, and then the rest would wait (un-transformed) until |
| 15915 | // the results of the previous transformed chunk were consumed. |
| 15916 | |
| 15917 | 'use strict'; |
| 15918 | |
| 15919 | module.exports = Transform; |
| 15920 | |
| 15921 | var Duplex = require('./_stream_duplex'); |
| 15922 | |
| 15923 | /*<replacement>*/ |
| 15924 | var util = require('core-util-is'); |
| 15925 | util.inherits = require('inherits'); |
| 15926 | /*</replacement>*/ |
| 15927 | |
| 15928 | util.inherits(Transform, Duplex); |
| 15929 | |
| 15930 | function afterTransform(er, data) { |
| 15931 | var ts = this._transformState; |
| 15932 | ts.transforming = false; |
| 15933 | |
| 15934 | var cb = ts.writecb; |
| 15935 | |
| 15936 | if (!cb) { |
| 15937 | return this.emit('error', new Error('write callback called multiple times')); |
| 15938 | } |
| 15939 | |
| 15940 | ts.writechunk = null; |
| 15941 | ts.writecb = null; |
| 15942 | |
| 15943 | if (data != null) // single equals check for both `null` and `undefined` |
| 15944 | this.push(data); |
| 15945 | |
| 15946 | cb(er); |
| 15947 | |
| 15948 | var rs = this._readableState; |
| 15949 | rs.reading = false; |
| 15950 | if (rs.needReadable || rs.length < rs.highWaterMark) { |
| 15951 | this._read(rs.highWaterMark); |
| 15952 | } |
| 15953 | } |
| 15954 | |
| 15955 | function Transform(options) { |
| 15956 | if (!(this instanceof Transform)) return new Transform(options); |
| 15957 | |
| 15958 | Duplex.call(this, options); |
| 15959 | |
| 15960 | this._transformState = { |
| 15961 | afterTransform: afterTransform.bind(this), |
| 15962 | needTransform: false, |
| 15963 | transforming: false, |
| 15964 | writecb: null, |
| 15965 | writechunk: null, |
| 15966 | writeencoding: null |
| 15967 | }; |
| 15968 | |
| 15969 | // start out asking for a readable event once data is transformed. |
| 15970 | this._readableState.needReadable = true; |
| 15971 | |
| 15972 | // we have implemented the _read method, and done the other things |
| 15973 | // that Readable wants before the first _read call, so unset the |
| 15974 | // sync guard flag. |
| 15975 | this._readableState.sync = false; |
| 15976 | |
| 15977 | if (options) { |
| 15978 | if (typeof options.transform === 'function') this._transform = options.transform; |
| 15979 | |
| 15980 | if (typeof options.flush === 'function') this._flush = options.flush; |
| 15981 | } |
| 15982 | |
| 15983 | // When the writable side finishes, then flush out anything remaining. |
| 15984 | this.on('prefinish', prefinish); |
| 15985 | } |
| 15986 | |
| 15987 | function prefinish() { |
| 15988 | var _this = this; |
| 15989 | |
| 15990 | if (typeof this._flush === 'function') { |
| 15991 | this._flush(function (er, data) { |
| 15992 | done(_this, er, data); |
| 15993 | }); |
| 15994 | } else { |
| 15995 | done(this, null, null); |
| 15996 | } |
| 15997 | } |
| 15998 | |
| 15999 | Transform.prototype.push = function (chunk, encoding) { |
| 16000 | this._transformState.needTransform = false; |
| 16001 | return Duplex.prototype.push.call(this, chunk, encoding); |
| 16002 | }; |
| 16003 | |
| 16004 | // This is the part where you do stuff! |
| 16005 | // override this function in implementation classes. |
| 16006 | // 'chunk' is an input chunk. |
| 16007 | // |
| 16008 | // Call `push(newChunk)` to pass along transformed output |
| 16009 | // to the readable side. You may call 'push' zero or more times. |
| 16010 | // |
| 16011 | // Call `cb(err)` when you are done with this chunk. If you pass |
| 16012 | // an error, then that'll put the hurt on the whole operation. If you |
| 16013 | // never call cb(), then you'll never get another chunk. |
| 16014 | Transform.prototype._transform = function (chunk, encoding, cb) { |
| 16015 | throw new Error('_transform() is not implemented'); |
| 16016 | }; |
| 16017 | |
| 16018 | Transform.prototype._write = function (chunk, encoding, cb) { |
| 16019 | var ts = this._transformState; |
| 16020 | ts.writecb = cb; |
| 16021 | ts.writechunk = chunk; |
| 16022 | ts.writeencoding = encoding; |
| 16023 | if (!ts.transforming) { |
| 16024 | var rs = this._readableState; |
| 16025 | if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); |
| 16026 | } |
| 16027 | }; |
| 16028 | |
| 16029 | // Doesn't matter what the args are here. |
| 16030 | // _transform does all the work. |
| 16031 | // That we got here means that the readable side wants more data. |
| 16032 | Transform.prototype._read = function (n) { |
| 16033 | var ts = this._transformState; |
| 16034 | |
| 16035 | if (ts.writechunk !== null && ts.writecb && !ts.transforming) { |
| 16036 | ts.transforming = true; |
| 16037 | this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); |
| 16038 | } else { |
| 16039 | // mark that we need a transform, so that any data that comes in |
| 16040 | // will get processed, now that we've asked for it. |
| 16041 | ts.needTransform = true; |
| 16042 | } |
| 16043 | }; |
| 16044 | |
| 16045 | Transform.prototype._destroy = function (err, cb) { |
| 16046 | var _this2 = this; |
| 16047 | |
| 16048 | Duplex.prototype._destroy.call(this, err, function (err2) { |
| 16049 | cb(err2); |
| 16050 | _this2.emit('close'); |
| 16051 | }); |
| 16052 | }; |
| 16053 | |
| 16054 | function done(stream, er, data) { |
| 16055 | if (er) return stream.emit('error', er); |
| 16056 | |
| 16057 | if (data != null) // single equals check for both `null` and `undefined` |
| 16058 | stream.push(data); |
| 16059 | |
| 16060 | // if there's nothing in the write buffer, then that means |
| 16061 | // that nothing more will ever be provided |
| 16062 | if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); |
| 16063 | |
| 16064 | if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); |
| 16065 | |
| 16066 | return stream.push(null); |
| 16067 | } |
| 16068 | },{"./_stream_duplex":71,"core-util-is":44,"inherits":56}],75:[function(require,module,exports){ |
| 16069 | (function (process,global,setImmediate){ |
| 16070 | // Copyright Joyent, Inc. and other Node contributors. |
| 16071 | // |
| 16072 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 16073 | // copy of this software and associated documentation files (the |
| 16074 | // "Software"), to deal in the Software without restriction, including |
| 16075 | // without limitation the rights to use, copy, modify, merge, publish, |
| 16076 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 16077 | // persons to whom the Software is furnished to do so, subject to the |
| 16078 | // following conditions: |
| 16079 | // |
| 16080 | // The above copyright notice and this permission notice shall be included |
| 16081 | // in all copies or substantial portions of the Software. |
| 16082 | // |
| 16083 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16084 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16085 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 16086 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 16087 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 16088 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 16089 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 16090 | |
| 16091 | // A bit simpler than readable streams. |
| 16092 | // Implement an async ._write(chunk, encoding, cb), and it'll handle all |
| 16093 | // the drain event emission and buffering. |
| 16094 | |
| 16095 | 'use strict'; |
| 16096 | |
| 16097 | /*<replacement>*/ |
| 16098 | |
| 16099 | var pna = require('process-nextick-args'); |
| 16100 | /*</replacement>*/ |
| 16101 | |
| 16102 | module.exports = Writable; |
| 16103 | |
| 16104 | /* <replacement> */ |
| 16105 | function WriteReq(chunk, encoding, cb) { |
| 16106 | this.chunk = chunk; |
| 16107 | this.encoding = encoding; |
| 16108 | this.callback = cb; |
| 16109 | this.next = null; |
| 16110 | } |
| 16111 | |
| 16112 | // It seems a linked list but it is not |
| 16113 | // there will be only 2 of these for each stream |
| 16114 | function CorkedRequest(state) { |
| 16115 | var _this = this; |
| 16116 | |
| 16117 | this.next = null; |
| 16118 | this.entry = null; |
| 16119 | this.finish = function () { |
| 16120 | onCorkedFinish(_this, state); |
| 16121 | }; |
| 16122 | } |
| 16123 | /* </replacement> */ |
| 16124 | |
| 16125 | /*<replacement>*/ |
| 16126 | var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; |
| 16127 | /*</replacement>*/ |
| 16128 | |
| 16129 | /*<replacement>*/ |
| 16130 | var Duplex; |
| 16131 | /*</replacement>*/ |
| 16132 | |
| 16133 | Writable.WritableState = WritableState; |
| 16134 | |
| 16135 | /*<replacement>*/ |
| 16136 | var util = require('core-util-is'); |
| 16137 | util.inherits = require('inherits'); |
| 16138 | /*</replacement>*/ |
| 16139 | |
| 16140 | /*<replacement>*/ |
| 16141 | var internalUtil = { |
| 16142 | deprecate: require('util-deprecate') |
| 16143 | }; |
| 16144 | /*</replacement>*/ |
| 16145 | |
| 16146 | /*<replacement>*/ |
| 16147 | var Stream = require('./internal/streams/stream'); |
| 16148 | /*</replacement>*/ |
| 16149 | |
| 16150 | /*<replacement>*/ |
| 16151 | |
| 16152 | var Buffer = require('safe-buffer').Buffer; |
| 16153 | var OurUint8Array = global.Uint8Array || function () {}; |
| 16154 | function _uint8ArrayToBuffer(chunk) { |
| 16155 | return Buffer.from(chunk); |
| 16156 | } |
| 16157 | function _isUint8Array(obj) { |
| 16158 | return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; |
| 16159 | } |
| 16160 | |
| 16161 | /*</replacement>*/ |
| 16162 | |
| 16163 | var destroyImpl = require('./internal/streams/destroy'); |
| 16164 | |
| 16165 | util.inherits(Writable, Stream); |
| 16166 | |
| 16167 | function nop() {} |
| 16168 | |
| 16169 | function WritableState(options, stream) { |
| 16170 | Duplex = Duplex || require('./_stream_duplex'); |
| 16171 | |
| 16172 | options = options || {}; |
| 16173 | |
| 16174 | // Duplex streams are both readable and writable, but share |
| 16175 | // the same options object. |
| 16176 | // However, some cases require setting options to different |
| 16177 | // values for the readable and the writable sides of the duplex stream. |
| 16178 | // These options can be provided separately as readableXXX and writableXXX. |
| 16179 | var isDuplex = stream instanceof Duplex; |
| 16180 | |
| 16181 | // object stream flag to indicate whether or not this stream |
| 16182 | // contains buffers or objects. |
| 16183 | this.objectMode = !!options.objectMode; |
| 16184 | |
| 16185 | if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; |
| 16186 | |
| 16187 | // the point at which write() starts returning false |
| 16188 | // Note: 0 is a valid value, means that we always return false if |
| 16189 | // the entire buffer is not flushed immediately on write() |
| 16190 | var hwm = options.highWaterMark; |
| 16191 | var writableHwm = options.writableHighWaterMark; |
| 16192 | var defaultHwm = this.objectMode ? 16 : 16 * 1024; |
| 16193 | |
| 16194 | if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; |
| 16195 | |
| 16196 | // cast to ints. |
| 16197 | this.highWaterMark = Math.floor(this.highWaterMark); |
| 16198 | |
| 16199 | // if _final has been called |
| 16200 | this.finalCalled = false; |
| 16201 | |
| 16202 | // drain event flag. |
| 16203 | this.needDrain = false; |
| 16204 | // at the start of calling end() |
| 16205 | this.ending = false; |
| 16206 | // when end() has been called, and returned |
| 16207 | this.ended = false; |
| 16208 | // when 'finish' is emitted |
| 16209 | this.finished = false; |
| 16210 | |
| 16211 | // has it been destroyed |
| 16212 | this.destroyed = false; |
| 16213 | |
| 16214 | // should we decode strings into buffers before passing to _write? |
| 16215 | // this is here so that some node-core streams can optimize string |
| 16216 | // handling at a lower level. |
| 16217 | var noDecode = options.decodeStrings === false; |
| 16218 | this.decodeStrings = !noDecode; |
| 16219 | |
| 16220 | // Crypto is kind of old and crusty. Historically, its default string |
| 16221 | // encoding is 'binary' so we have to make this configurable. |
| 16222 | // Everything else in the universe uses 'utf8', though. |
| 16223 | this.defaultEncoding = options.defaultEncoding || 'utf8'; |
| 16224 | |
| 16225 | // not an actual buffer we keep track of, but a measurement |
| 16226 | // of how much we're waiting to get pushed to some underlying |
| 16227 | // socket or file. |
| 16228 | this.length = 0; |
| 16229 | |
| 16230 | // a flag to see when we're in the middle of a write. |
| 16231 | this.writing = false; |
| 16232 | |
| 16233 | // when true all writes will be buffered until .uncork() call |
| 16234 | this.corked = 0; |
| 16235 | |
| 16236 | // a flag to be able to tell if the onwrite cb is called immediately, |
| 16237 | // or on a later tick. We set this to true at first, because any |
| 16238 | // actions that shouldn't happen until "later" should generally also |
| 16239 | // not happen before the first write call. |
| 16240 | this.sync = true; |
| 16241 | |
| 16242 | // a flag to know if we're processing previously buffered items, which |
| 16243 | // may call the _write() callback in the same tick, so that we don't |
| 16244 | // end up in an overlapped onwrite situation. |
| 16245 | this.bufferProcessing = false; |
| 16246 | |
| 16247 | // the callback that's passed to _write(chunk,cb) |
| 16248 | this.onwrite = function (er) { |
| 16249 | onwrite(stream, er); |
| 16250 | }; |
| 16251 | |
| 16252 | // the callback that the user supplies to write(chunk,encoding,cb) |
| 16253 | this.writecb = null; |
| 16254 | |
| 16255 | // the amount that is being written when _write is called. |
| 16256 | this.writelen = 0; |
| 16257 | |
| 16258 | this.bufferedRequest = null; |
| 16259 | this.lastBufferedRequest = null; |
| 16260 | |
| 16261 | // number of pending user-supplied write callbacks |
| 16262 | // this must be 0 before 'finish' can be emitted |
| 16263 | this.pendingcb = 0; |
| 16264 | |
| 16265 | // emit prefinish if the only thing we're waiting for is _write cbs |
| 16266 | // This is relevant for synchronous Transform streams |
| 16267 | this.prefinished = false; |
| 16268 | |
| 16269 | // True if the error was already emitted and should not be thrown again |
| 16270 | this.errorEmitted = false; |
| 16271 | |
| 16272 | // count buffered requests |
| 16273 | this.bufferedRequestCount = 0; |
| 16274 | |
| 16275 | // allocate the first CorkedRequest, there is always |
| 16276 | // one allocated and free to use, and we maintain at most two |
| 16277 | this.corkedRequestsFree = new CorkedRequest(this); |
| 16278 | } |
| 16279 | |
| 16280 | WritableState.prototype.getBuffer = function getBuffer() { |
| 16281 | var current = this.bufferedRequest; |
| 16282 | var out = []; |
| 16283 | while (current) { |
| 16284 | out.push(current); |
| 16285 | current = current.next; |
| 16286 | } |
| 16287 | return out; |
| 16288 | }; |
| 16289 | |
| 16290 | (function () { |
| 16291 | try { |
| 16292 | Object.defineProperty(WritableState.prototype, 'buffer', { |
| 16293 | get: internalUtil.deprecate(function () { |
| 16294 | return this.getBuffer(); |
| 16295 | }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') |
| 16296 | }); |
| 16297 | } catch (_) {} |
| 16298 | })(); |
| 16299 | |
| 16300 | // Test _writableState for inheritance to account for Duplex streams, |
| 16301 | // whose prototype chain only points to Readable. |
| 16302 | var realHasInstance; |
| 16303 | if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { |
| 16304 | realHasInstance = Function.prototype[Symbol.hasInstance]; |
| 16305 | Object.defineProperty(Writable, Symbol.hasInstance, { |
| 16306 | value: function (object) { |
| 16307 | if (realHasInstance.call(this, object)) return true; |
| 16308 | if (this !== Writable) return false; |
| 16309 | |
| 16310 | return object && object._writableState instanceof WritableState; |
| 16311 | } |
| 16312 | }); |
| 16313 | } else { |
| 16314 | realHasInstance = function (object) { |
| 16315 | return object instanceof this; |
| 16316 | }; |
| 16317 | } |
| 16318 | |
| 16319 | function Writable(options) { |
| 16320 | Duplex = Duplex || require('./_stream_duplex'); |
| 16321 | |
| 16322 | // Writable ctor is applied to Duplexes, too. |
| 16323 | // `realHasInstance` is necessary because using plain `instanceof` |
| 16324 | // would return false, as no `_writableState` property is attached. |
| 16325 | |
| 16326 | // Trying to use the custom `instanceof` for Writable here will also break the |
| 16327 | // Node.js LazyTransform implementation, which has a non-trivial getter for |
| 16328 | // `_writableState` that would lead to infinite recursion. |
| 16329 | if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { |
| 16330 | return new Writable(options); |
| 16331 | } |
| 16332 | |
| 16333 | this._writableState = new WritableState(options, this); |
| 16334 | |
| 16335 | // legacy. |
| 16336 | this.writable = true; |
| 16337 | |
| 16338 | if (options) { |
| 16339 | if (typeof options.write === 'function') this._write = options.write; |
| 16340 | |
| 16341 | if (typeof options.writev === 'function') this._writev = options.writev; |
| 16342 | |
| 16343 | if (typeof options.destroy === 'function') this._destroy = options.destroy; |
| 16344 | |
| 16345 | if (typeof options.final === 'function') this._final = options.final; |
| 16346 | } |
| 16347 | |
| 16348 | Stream.call(this); |
| 16349 | } |
| 16350 | |
| 16351 | // Otherwise people can pipe Writable streams, which is just wrong. |
| 16352 | Writable.prototype.pipe = function () { |
| 16353 | this.emit('error', new Error('Cannot pipe, not readable')); |
| 16354 | }; |
| 16355 | |
| 16356 | function writeAfterEnd(stream, cb) { |
| 16357 | var er = new Error('write after end'); |
| 16358 | // TODO: defer error events consistently everywhere, not just the cb |
| 16359 | stream.emit('error', er); |
| 16360 | pna.nextTick(cb, er); |
| 16361 | } |
| 16362 | |
| 16363 | // Checks that a user-supplied chunk is valid, especially for the particular |
| 16364 | // mode the stream is in. Currently this means that `null` is never accepted |
| 16365 | // and undefined/non-string values are only allowed in object mode. |
| 16366 | function validChunk(stream, state, chunk, cb) { |
| 16367 | var valid = true; |
| 16368 | var er = false; |
| 16369 | |
| 16370 | if (chunk === null) { |
| 16371 | er = new TypeError('May not write null values to stream'); |
| 16372 | } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { |
| 16373 | er = new TypeError('Invalid non-string/buffer chunk'); |
| 16374 | } |
| 16375 | if (er) { |
| 16376 | stream.emit('error', er); |
| 16377 | pna.nextTick(cb, er); |
| 16378 | valid = false; |
| 16379 | } |
| 16380 | return valid; |
| 16381 | } |
| 16382 | |
| 16383 | Writable.prototype.write = function (chunk, encoding, cb) { |
| 16384 | var state = this._writableState; |
| 16385 | var ret = false; |
| 16386 | var isBuf = !state.objectMode && _isUint8Array(chunk); |
| 16387 | |
| 16388 | if (isBuf && !Buffer.isBuffer(chunk)) { |
| 16389 | chunk = _uint8ArrayToBuffer(chunk); |
| 16390 | } |
| 16391 | |
| 16392 | if (typeof encoding === 'function') { |
| 16393 | cb = encoding; |
| 16394 | encoding = null; |
| 16395 | } |
| 16396 | |
| 16397 | if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; |
| 16398 | |
| 16399 | if (typeof cb !== 'function') cb = nop; |
| 16400 | |
| 16401 | if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { |
| 16402 | state.pendingcb++; |
| 16403 | ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); |
| 16404 | } |
| 16405 | |
| 16406 | return ret; |
| 16407 | }; |
| 16408 | |
| 16409 | Writable.prototype.cork = function () { |
| 16410 | var state = this._writableState; |
| 16411 | |
| 16412 | state.corked++; |
| 16413 | }; |
| 16414 | |
| 16415 | Writable.prototype.uncork = function () { |
| 16416 | var state = this._writableState; |
| 16417 | |
| 16418 | if (state.corked) { |
| 16419 | state.corked--; |
| 16420 | |
| 16421 | if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); |
| 16422 | } |
| 16423 | }; |
| 16424 | |
| 16425 | Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { |
| 16426 | // node::ParseEncoding() requires lower case. |
| 16427 | if (typeof encoding === 'string') encoding = encoding.toLowerCase(); |
| 16428 | 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); |
| 16429 | this._writableState.defaultEncoding = encoding; |
| 16430 | return this; |
| 16431 | }; |
| 16432 | |
| 16433 | function decodeChunk(state, chunk, encoding) { |
| 16434 | if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { |
| 16435 | chunk = Buffer.from(chunk, encoding); |
| 16436 | } |
| 16437 | return chunk; |
| 16438 | } |
| 16439 | |
| 16440 | Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { |
| 16441 | // making it explicit this property is not enumerable |
| 16442 | // because otherwise some prototype manipulation in |
| 16443 | // userland will fail |
| 16444 | enumerable: false, |
| 16445 | get: function () { |
| 16446 | return this._writableState.highWaterMark; |
| 16447 | } |
| 16448 | }); |
| 16449 | |
| 16450 | // if we're already writing something, then just put this |
| 16451 | // in the queue, and wait our turn. Otherwise, call _write |
| 16452 | // If we return false, then we need a drain event, so set that flag. |
| 16453 | function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { |
| 16454 | if (!isBuf) { |
| 16455 | var newChunk = decodeChunk(state, chunk, encoding); |
| 16456 | if (chunk !== newChunk) { |
| 16457 | isBuf = true; |
| 16458 | encoding = 'buffer'; |
| 16459 | chunk = newChunk; |
| 16460 | } |
| 16461 | } |
| 16462 | var len = state.objectMode ? 1 : chunk.length; |
| 16463 | |
| 16464 | state.length += len; |
| 16465 | |
| 16466 | var ret = state.length < state.highWaterMark; |
| 16467 | // we must ensure that previous needDrain will not be reset to false. |
| 16468 | if (!ret) state.needDrain = true; |
| 16469 | |
| 16470 | if (state.writing || state.corked) { |
| 16471 | var last = state.lastBufferedRequest; |
| 16472 | state.lastBufferedRequest = { |
| 16473 | chunk: chunk, |
| 16474 | encoding: encoding, |
| 16475 | isBuf: isBuf, |
| 16476 | callback: cb, |
| 16477 | next: null |
| 16478 | }; |
| 16479 | if (last) { |
| 16480 | last.next = state.lastBufferedRequest; |
| 16481 | } else { |
| 16482 | state.bufferedRequest = state.lastBufferedRequest; |
| 16483 | } |
| 16484 | state.bufferedRequestCount += 1; |
| 16485 | } else { |
| 16486 | doWrite(stream, state, false, len, chunk, encoding, cb); |
| 16487 | } |
| 16488 | |
| 16489 | return ret; |
| 16490 | } |
| 16491 | |
| 16492 | function doWrite(stream, state, writev, len, chunk, encoding, cb) { |
| 16493 | state.writelen = len; |
| 16494 | state.writecb = cb; |
| 16495 | state.writing = true; |
| 16496 | state.sync = true; |
| 16497 | if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); |
| 16498 | state.sync = false; |
| 16499 | } |
| 16500 | |
| 16501 | function onwriteError(stream, state, sync, er, cb) { |
| 16502 | --state.pendingcb; |
| 16503 | |
| 16504 | if (sync) { |
| 16505 | // defer the callback if we are being called synchronously |
| 16506 | // to avoid piling up things on the stack |
| 16507 | pna.nextTick(cb, er); |
| 16508 | // this can emit finish, and it will always happen |
| 16509 | // after error |
| 16510 | pna.nextTick(finishMaybe, stream, state); |
| 16511 | stream._writableState.errorEmitted = true; |
| 16512 | stream.emit('error', er); |
| 16513 | } else { |
| 16514 | // the caller expect this to happen before if |
| 16515 | // it is async |
| 16516 | cb(er); |
| 16517 | stream._writableState.errorEmitted = true; |
| 16518 | stream.emit('error', er); |
| 16519 | // this can emit finish, but finish must |
| 16520 | // always follow error |
| 16521 | finishMaybe(stream, state); |
| 16522 | } |
| 16523 | } |
| 16524 | |
| 16525 | function onwriteStateUpdate(state) { |
| 16526 | state.writing = false; |
| 16527 | state.writecb = null; |
| 16528 | state.length -= state.writelen; |
| 16529 | state.writelen = 0; |
| 16530 | } |
| 16531 | |
| 16532 | function onwrite(stream, er) { |
| 16533 | var state = stream._writableState; |
| 16534 | var sync = state.sync; |
| 16535 | var cb = state.writecb; |
| 16536 | |
| 16537 | onwriteStateUpdate(state); |
| 16538 | |
| 16539 | if (er) onwriteError(stream, state, sync, er, cb);else { |
| 16540 | // Check if we're actually ready to finish, but don't emit yet |
| 16541 | var finished = needFinish(state); |
| 16542 | |
| 16543 | if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { |
| 16544 | clearBuffer(stream, state); |
| 16545 | } |
| 16546 | |
| 16547 | if (sync) { |
| 16548 | /*<replacement>*/ |
| 16549 | asyncWrite(afterWrite, stream, state, finished, cb); |
| 16550 | /*</replacement>*/ |
| 16551 | } else { |
| 16552 | afterWrite(stream, state, finished, cb); |
| 16553 | } |
| 16554 | } |
| 16555 | } |
| 16556 | |
| 16557 | function afterWrite(stream, state, finished, cb) { |
| 16558 | if (!finished) onwriteDrain(stream, state); |
| 16559 | state.pendingcb--; |
| 16560 | cb(); |
| 16561 | finishMaybe(stream, state); |
| 16562 | } |
| 16563 | |
| 16564 | // Must force callback to be called on nextTick, so that we don't |
| 16565 | // emit 'drain' before the write() consumer gets the 'false' return |
| 16566 | // value, and has a chance to attach a 'drain' listener. |
| 16567 | function onwriteDrain(stream, state) { |
| 16568 | if (state.length === 0 && state.needDrain) { |
| 16569 | state.needDrain = false; |
| 16570 | stream.emit('drain'); |
| 16571 | } |
| 16572 | } |
| 16573 | |
| 16574 | // if there's something in the buffer waiting, then process it |
| 16575 | function clearBuffer(stream, state) { |
| 16576 | state.bufferProcessing = true; |
| 16577 | var entry = state.bufferedRequest; |
| 16578 | |
| 16579 | if (stream._writev && entry && entry.next) { |
| 16580 | // Fast case, write everything using _writev() |
| 16581 | var l = state.bufferedRequestCount; |
| 16582 | var buffer = new Array(l); |
| 16583 | var holder = state.corkedRequestsFree; |
| 16584 | holder.entry = entry; |
| 16585 | |
| 16586 | var count = 0; |
| 16587 | var allBuffers = true; |
| 16588 | while (entry) { |
| 16589 | buffer[count] = entry; |
| 16590 | if (!entry.isBuf) allBuffers = false; |
| 16591 | entry = entry.next; |
| 16592 | count += 1; |
| 16593 | } |
| 16594 | buffer.allBuffers = allBuffers; |
| 16595 | |
| 16596 | doWrite(stream, state, true, state.length, buffer, '', holder.finish); |
| 16597 | |
| 16598 | // doWrite is almost always async, defer these to save a bit of time |
| 16599 | // as the hot path ends with doWrite |
| 16600 | state.pendingcb++; |
| 16601 | state.lastBufferedRequest = null; |
| 16602 | if (holder.next) { |
| 16603 | state.corkedRequestsFree = holder.next; |
| 16604 | holder.next = null; |
| 16605 | } else { |
| 16606 | state.corkedRequestsFree = new CorkedRequest(state); |
| 16607 | } |
| 16608 | state.bufferedRequestCount = 0; |
| 16609 | } else { |
| 16610 | // Slow case, write chunks one-by-one |
| 16611 | while (entry) { |
| 16612 | var chunk = entry.chunk; |
| 16613 | var encoding = entry.encoding; |
| 16614 | var cb = entry.callback; |
| 16615 | var len = state.objectMode ? 1 : chunk.length; |
| 16616 | |
| 16617 | doWrite(stream, state, false, len, chunk, encoding, cb); |
| 16618 | entry = entry.next; |
| 16619 | state.bufferedRequestCount--; |
| 16620 | // if we didn't call the onwrite immediately, then |
| 16621 | // it means that we need to wait until it does. |
| 16622 | // also, that means that the chunk and cb are currently |
| 16623 | // being processed, so move the buffer counter past them. |
| 16624 | if (state.writing) { |
| 16625 | break; |
| 16626 | } |
| 16627 | } |
| 16628 | |
| 16629 | if (entry === null) state.lastBufferedRequest = null; |
| 16630 | } |
| 16631 | |
| 16632 | state.bufferedRequest = entry; |
| 16633 | state.bufferProcessing = false; |
| 16634 | } |
| 16635 | |
| 16636 | Writable.prototype._write = function (chunk, encoding, cb) { |
| 16637 | cb(new Error('_write() is not implemented')); |
| 16638 | }; |
| 16639 | |
| 16640 | Writable.prototype._writev = null; |
| 16641 | |
| 16642 | Writable.prototype.end = function (chunk, encoding, cb) { |
| 16643 | var state = this._writableState; |
| 16644 | |
| 16645 | if (typeof chunk === 'function') { |
| 16646 | cb = chunk; |
| 16647 | chunk = null; |
| 16648 | encoding = null; |
| 16649 | } else if (typeof encoding === 'function') { |
| 16650 | cb = encoding; |
| 16651 | encoding = null; |
| 16652 | } |
| 16653 | |
| 16654 | if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); |
| 16655 | |
| 16656 | // .end() fully uncorks |
| 16657 | if (state.corked) { |
| 16658 | state.corked = 1; |
| 16659 | this.uncork(); |
| 16660 | } |
| 16661 | |
| 16662 | // ignore unnecessary end() calls. |
| 16663 | if (!state.ending && !state.finished) endWritable(this, state, cb); |
| 16664 | }; |
| 16665 | |
| 16666 | function needFinish(state) { |
| 16667 | return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; |
| 16668 | } |
| 16669 | function callFinal(stream, state) { |
| 16670 | stream._final(function (err) { |
| 16671 | state.pendingcb--; |
| 16672 | if (err) { |
| 16673 | stream.emit('error', err); |
| 16674 | } |
| 16675 | state.prefinished = true; |
| 16676 | stream.emit('prefinish'); |
| 16677 | finishMaybe(stream, state); |
| 16678 | }); |
| 16679 | } |
| 16680 | function prefinish(stream, state) { |
| 16681 | if (!state.prefinished && !state.finalCalled) { |
| 16682 | if (typeof stream._final === 'function') { |
| 16683 | state.pendingcb++; |
| 16684 | state.finalCalled = true; |
| 16685 | pna.nextTick(callFinal, stream, state); |
| 16686 | } else { |
| 16687 | state.prefinished = true; |
| 16688 | stream.emit('prefinish'); |
| 16689 | } |
| 16690 | } |
| 16691 | } |
| 16692 | |
| 16693 | function finishMaybe(stream, state) { |
| 16694 | var need = needFinish(state); |
| 16695 | if (need) { |
| 16696 | prefinish(stream, state); |
| 16697 | if (state.pendingcb === 0) { |
| 16698 | state.finished = true; |
| 16699 | stream.emit('finish'); |
| 16700 | } |
| 16701 | } |
| 16702 | return need; |
| 16703 | } |
| 16704 | |
| 16705 | function endWritable(stream, state, cb) { |
| 16706 | state.ending = true; |
| 16707 | finishMaybe(stream, state); |
| 16708 | if (cb) { |
| 16709 | if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); |
| 16710 | } |
| 16711 | state.ended = true; |
| 16712 | stream.writable = false; |
| 16713 | } |
| 16714 | |
| 16715 | function onCorkedFinish(corkReq, state, err) { |
| 16716 | var entry = corkReq.entry; |
| 16717 | corkReq.entry = null; |
| 16718 | while (entry) { |
| 16719 | var cb = entry.callback; |
| 16720 | state.pendingcb--; |
| 16721 | cb(err); |
| 16722 | entry = entry.next; |
| 16723 | } |
| 16724 | if (state.corkedRequestsFree) { |
| 16725 | state.corkedRequestsFree.next = corkReq; |
| 16726 | } else { |
| 16727 | state.corkedRequestsFree = corkReq; |
| 16728 | } |
| 16729 | } |
| 16730 | |
| 16731 | Object.defineProperty(Writable.prototype, 'destroyed', { |
| 16732 | get: function () { |
| 16733 | if (this._writableState === undefined) { |
| 16734 | return false; |
| 16735 | } |
| 16736 | return this._writableState.destroyed; |
| 16737 | }, |
| 16738 | set: function (value) { |
| 16739 | // we ignore the value if the stream |
| 16740 | // has not been initialized yet |
| 16741 | if (!this._writableState) { |
| 16742 | return; |
| 16743 | } |
| 16744 | |
| 16745 | // backward compatibility, the user is explicitly |
| 16746 | // managing destroyed |
| 16747 | this._writableState.destroyed = value; |
| 16748 | } |
| 16749 | }); |
| 16750 | |
| 16751 | Writable.prototype.destroy = destroyImpl.destroy; |
| 16752 | Writable.prototype._undestroy = destroyImpl.undestroy; |
| 16753 | Writable.prototype._destroy = function (err, cb) { |
| 16754 | this.end(); |
| 16755 | cb(err); |
| 16756 | }; |
| 16757 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) |
| 16758 | },{"./_stream_duplex":71,"./internal/streams/destroy":77,"./internal/streams/stream":78,"_process":69,"core-util-is":44,"inherits":56,"process-nextick-args":68,"safe-buffer":83,"timers":86,"util-deprecate":87}],76:[function(require,module,exports){ |
| 16759 | 'use strict'; |
| 16760 | |
| 16761 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 16762 | |
| 16763 | var Buffer = require('safe-buffer').Buffer; |
| 16764 | var util = require('util'); |
| 16765 | |
| 16766 | function copyBuffer(src, target, offset) { |
| 16767 | src.copy(target, offset); |
| 16768 | } |
| 16769 | |
| 16770 | module.exports = function () { |
| 16771 | function BufferList() { |
| 16772 | _classCallCheck(this, BufferList); |
| 16773 | |
| 16774 | this.head = null; |
| 16775 | this.tail = null; |
| 16776 | this.length = 0; |
| 16777 | } |
| 16778 | |
| 16779 | BufferList.prototype.push = function push(v) { |
| 16780 | var entry = { data: v, next: null }; |
| 16781 | if (this.length > 0) this.tail.next = entry;else this.head = entry; |
| 16782 | this.tail = entry; |
| 16783 | ++this.length; |
| 16784 | }; |
| 16785 | |
| 16786 | BufferList.prototype.unshift = function unshift(v) { |
| 16787 | var entry = { data: v, next: this.head }; |
| 16788 | if (this.length === 0) this.tail = entry; |
| 16789 | this.head = entry; |
| 16790 | ++this.length; |
| 16791 | }; |
| 16792 | |
| 16793 | BufferList.prototype.shift = function shift() { |
| 16794 | if (this.length === 0) return; |
| 16795 | var ret = this.head.data; |
| 16796 | if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; |
| 16797 | --this.length; |
| 16798 | return ret; |
| 16799 | }; |
| 16800 | |
| 16801 | BufferList.prototype.clear = function clear() { |
| 16802 | this.head = this.tail = null; |
| 16803 | this.length = 0; |
| 16804 | }; |
| 16805 | |
| 16806 | BufferList.prototype.join = function join(s) { |
| 16807 | if (this.length === 0) return ''; |
| 16808 | var p = this.head; |
| 16809 | var ret = '' + p.data; |
| 16810 | while (p = p.next) { |
| 16811 | ret += s + p.data; |
| 16812 | }return ret; |
| 16813 | }; |
| 16814 | |
| 16815 | BufferList.prototype.concat = function concat(n) { |
| 16816 | if (this.length === 0) return Buffer.alloc(0); |
| 16817 | if (this.length === 1) return this.head.data; |
| 16818 | var ret = Buffer.allocUnsafe(n >>> 0); |
| 16819 | var p = this.head; |
| 16820 | var i = 0; |
| 16821 | while (p) { |
| 16822 | copyBuffer(p.data, ret, i); |
| 16823 | i += p.data.length; |
| 16824 | p = p.next; |
| 16825 | } |
| 16826 | return ret; |
| 16827 | }; |
| 16828 | |
| 16829 | return BufferList; |
| 16830 | }(); |
| 16831 | |
| 16832 | if (util && util.inspect && util.inspect.custom) { |
| 16833 | module.exports.prototype[util.inspect.custom] = function () { |
| 16834 | var obj = util.inspect({ length: this.length }); |
| 16835 | return this.constructor.name + ' ' + obj; |
| 16836 | }; |
| 16837 | } |
| 16838 | },{"safe-buffer":83,"util":40}],77:[function(require,module,exports){ |
| 16839 | 'use strict'; |
| 16840 | |
| 16841 | /*<replacement>*/ |
| 16842 | |
| 16843 | var pna = require('process-nextick-args'); |
| 16844 | /*</replacement>*/ |
| 16845 | |
| 16846 | // undocumented cb() API, needed for core, not for public API |
| 16847 | function destroy(err, cb) { |
| 16848 | var _this = this; |
| 16849 | |
| 16850 | var readableDestroyed = this._readableState && this._readableState.destroyed; |
| 16851 | var writableDestroyed = this._writableState && this._writableState.destroyed; |
| 16852 | |
| 16853 | if (readableDestroyed || writableDestroyed) { |
| 16854 | if (cb) { |
| 16855 | cb(err); |
| 16856 | } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { |
| 16857 | pna.nextTick(emitErrorNT, this, err); |
| 16858 | } |
| 16859 | return this; |
| 16860 | } |
| 16861 | |
| 16862 | // we set destroyed to true before firing error callbacks in order |
| 16863 | // to make it re-entrance safe in case destroy() is called within callbacks |
| 16864 | |
| 16865 | if (this._readableState) { |
| 16866 | this._readableState.destroyed = true; |
| 16867 | } |
| 16868 | |
| 16869 | // if this is a duplex stream mark the writable part as destroyed as well |
| 16870 | if (this._writableState) { |
| 16871 | this._writableState.destroyed = true; |
| 16872 | } |
| 16873 | |
| 16874 | this._destroy(err || null, function (err) { |
| 16875 | if (!cb && err) { |
| 16876 | pna.nextTick(emitErrorNT, _this, err); |
| 16877 | if (_this._writableState) { |
| 16878 | _this._writableState.errorEmitted = true; |
| 16879 | } |
| 16880 | } else if (cb) { |
| 16881 | cb(err); |
| 16882 | } |
| 16883 | }); |
| 16884 | |
| 16885 | return this; |
| 16886 | } |
| 16887 | |
| 16888 | function undestroy() { |
| 16889 | if (this._readableState) { |
| 16890 | this._readableState.destroyed = false; |
| 16891 | this._readableState.reading = false; |
| 16892 | this._readableState.ended = false; |
| 16893 | this._readableState.endEmitted = false; |
| 16894 | } |
| 16895 | |
| 16896 | if (this._writableState) { |
| 16897 | this._writableState.destroyed = false; |
| 16898 | this._writableState.ended = false; |
| 16899 | this._writableState.ending = false; |
| 16900 | this._writableState.finished = false; |
| 16901 | this._writableState.errorEmitted = false; |
| 16902 | } |
| 16903 | } |
| 16904 | |
| 16905 | function emitErrorNT(self, err) { |
| 16906 | self.emit('error', err); |
| 16907 | } |
| 16908 | |
| 16909 | module.exports = { |
| 16910 | destroy: destroy, |
| 16911 | undestroy: undestroy |
| 16912 | }; |
| 16913 | },{"process-nextick-args":68}],78:[function(require,module,exports){ |
| 16914 | module.exports = require('events').EventEmitter; |
| 16915 | |
| 16916 | },{"events":50}],79:[function(require,module,exports){ |
| 16917 | module.exports = require('./readable').PassThrough |
| 16918 | |
| 16919 | },{"./readable":80}],80:[function(require,module,exports){ |
| 16920 | exports = module.exports = require('./lib/_stream_readable.js'); |
| 16921 | exports.Stream = exports; |
| 16922 | exports.Readable = exports; |
| 16923 | exports.Writable = require('./lib/_stream_writable.js'); |
| 16924 | exports.Duplex = require('./lib/_stream_duplex.js'); |
| 16925 | exports.Transform = require('./lib/_stream_transform.js'); |
| 16926 | exports.PassThrough = require('./lib/_stream_passthrough.js'); |
| 16927 | |
| 16928 | },{"./lib/_stream_duplex.js":71,"./lib/_stream_passthrough.js":72,"./lib/_stream_readable.js":73,"./lib/_stream_transform.js":74,"./lib/_stream_writable.js":75}],81:[function(require,module,exports){ |
| 16929 | module.exports = require('./readable').Transform |
| 16930 | |
| 16931 | },{"./readable":80}],82:[function(require,module,exports){ |
| 16932 | module.exports = require('./lib/_stream_writable.js'); |
| 16933 | |
| 16934 | },{"./lib/_stream_writable.js":75}],83:[function(require,module,exports){ |
| 16935 | /* eslint-disable node/no-deprecated-api */ |
| 16936 | var buffer = require('buffer') |
| 16937 | var Buffer = buffer.Buffer |
| 16938 | |
| 16939 | // alternative to using Object.keys for old browsers |
| 16940 | function copyProps (src, dst) { |
| 16941 | for (var key in src) { |
| 16942 | dst[key] = src[key] |
| 16943 | } |
| 16944 | } |
| 16945 | if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { |
| 16946 | module.exports = buffer |
| 16947 | } else { |
| 16948 | // Copy properties from require('buffer') |
| 16949 | copyProps(buffer, exports) |
| 16950 | exports.Buffer = SafeBuffer |
| 16951 | } |
| 16952 | |
| 16953 | function SafeBuffer (arg, encodingOrOffset, length) { |
| 16954 | return Buffer(arg, encodingOrOffset, length) |
| 16955 | } |
| 16956 | |
| 16957 | // Copy static methods from Buffer |
| 16958 | copyProps(Buffer, SafeBuffer) |
| 16959 | |
| 16960 | SafeBuffer.from = function (arg, encodingOrOffset, length) { |
| 16961 | if (typeof arg === 'number') { |
| 16962 | throw new TypeError('Argument must not be a number') |
| 16963 | } |
| 16964 | return Buffer(arg, encodingOrOffset, length) |
| 16965 | } |
| 16966 | |
| 16967 | SafeBuffer.alloc = function (size, fill, encoding) { |
| 16968 | if (typeof size !== 'number') { |
| 16969 | throw new TypeError('Argument must be a number') |
| 16970 | } |
| 16971 | var buf = Buffer(size) |
| 16972 | if (fill !== undefined) { |
| 16973 | if (typeof encoding === 'string') { |
| 16974 | buf.fill(fill, encoding) |
| 16975 | } else { |
| 16976 | buf.fill(fill) |
| 16977 | } |
| 16978 | } else { |
| 16979 | buf.fill(0) |
| 16980 | } |
| 16981 | return buf |
| 16982 | } |
| 16983 | |
| 16984 | SafeBuffer.allocUnsafe = function (size) { |
| 16985 | if (typeof size !== 'number') { |
| 16986 | throw new TypeError('Argument must be a number') |
| 16987 | } |
| 16988 | return Buffer(size) |
| 16989 | } |
| 16990 | |
| 16991 | SafeBuffer.allocUnsafeSlow = function (size) { |
| 16992 | if (typeof size !== 'number') { |
| 16993 | throw new TypeError('Argument must be a number') |
| 16994 | } |
| 16995 | return buffer.SlowBuffer(size) |
| 16996 | } |
| 16997 | |
| 16998 | },{"buffer":43}],84:[function(require,module,exports){ |
| 16999 | // Copyright Joyent, Inc. and other Node contributors. |
| 17000 | // |
| 17001 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 17002 | // copy of this software and associated documentation files (the |
| 17003 | // "Software"), to deal in the Software without restriction, including |
| 17004 | // without limitation the rights to use, copy, modify, merge, publish, |
| 17005 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 17006 | // persons to whom the Software is furnished to do so, subject to the |
| 17007 | // following conditions: |
| 17008 | // |
| 17009 | // The above copyright notice and this permission notice shall be included |
| 17010 | // in all copies or substantial portions of the Software. |
| 17011 | // |
| 17012 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 17013 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17014 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 17015 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 17016 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 17017 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 17018 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 17019 | |
| 17020 | module.exports = Stream; |
| 17021 | |
| 17022 | var EE = require('events').EventEmitter; |
| 17023 | var inherits = require('inherits'); |
| 17024 | |
| 17025 | inherits(Stream, EE); |
| 17026 | Stream.Readable = require('readable-stream/readable.js'); |
| 17027 | Stream.Writable = require('readable-stream/writable.js'); |
| 17028 | Stream.Duplex = require('readable-stream/duplex.js'); |
| 17029 | Stream.Transform = require('readable-stream/transform.js'); |
| 17030 | Stream.PassThrough = require('readable-stream/passthrough.js'); |
| 17031 | |
| 17032 | // Backwards-compat with node 0.4.x |
| 17033 | Stream.Stream = Stream; |
| 17034 | |
| 17035 | |
| 17036 | |
| 17037 | // old-style streams. Note that the pipe method (the only relevant |
| 17038 | // part of this class) is overridden in the Readable class. |
| 17039 | |
| 17040 | function Stream() { |
| 17041 | EE.call(this); |
| 17042 | } |
| 17043 | |
| 17044 | Stream.prototype.pipe = function(dest, options) { |
| 17045 | var source = this; |
| 17046 | |
| 17047 | function ondata(chunk) { |
| 17048 | if (dest.writable) { |
| 17049 | if (false === dest.write(chunk) && source.pause) { |
| 17050 | source.pause(); |
| 17051 | } |
| 17052 | } |
| 17053 | } |
| 17054 | |
| 17055 | source.on('data', ondata); |
| 17056 | |
| 17057 | function ondrain() { |
| 17058 | if (source.readable && source.resume) { |
| 17059 | source.resume(); |
| 17060 | } |
| 17061 | } |
| 17062 | |
| 17063 | dest.on('drain', ondrain); |
| 17064 | |
| 17065 | // If the 'end' option is not supplied, dest.end() will be called when |
| 17066 | // source gets the 'end' or 'close' events. Only dest.end() once. |
| 17067 | if (!dest._isStdio && (!options || options.end !== false)) { |
| 17068 | source.on('end', onend); |
| 17069 | source.on('close', onclose); |
| 17070 | } |
| 17071 | |
| 17072 | var didOnEnd = false; |
| 17073 | function onend() { |
| 17074 | if (didOnEnd) return; |
| 17075 | didOnEnd = true; |
| 17076 | |
| 17077 | dest.end(); |
| 17078 | } |
| 17079 | |
| 17080 | |
| 17081 | function onclose() { |
| 17082 | if (didOnEnd) return; |
| 17083 | didOnEnd = true; |
| 17084 | |
| 17085 | if (typeof dest.destroy === 'function') dest.destroy(); |
| 17086 | } |
| 17087 | |
| 17088 | // don't leave dangling pipes when there are errors. |
| 17089 | function onerror(er) { |
| 17090 | cleanup(); |
| 17091 | if (EE.listenerCount(this, 'error') === 0) { |
| 17092 | throw er; // Unhandled stream error in pipe. |
| 17093 | } |
| 17094 | } |
| 17095 | |
| 17096 | source.on('error', onerror); |
| 17097 | dest.on('error', onerror); |
| 17098 | |
| 17099 | // remove all the event listeners that were added. |
| 17100 | function cleanup() { |
| 17101 | source.removeListener('data', ondata); |
| 17102 | dest.removeListener('drain', ondrain); |
| 17103 | |
| 17104 | source.removeListener('end', onend); |
| 17105 | source.removeListener('close', onclose); |
| 17106 | |
| 17107 | source.removeListener('error', onerror); |
| 17108 | dest.removeListener('error', onerror); |
| 17109 | |
| 17110 | source.removeListener('end', cleanup); |
| 17111 | source.removeListener('close', cleanup); |
| 17112 | |
| 17113 | dest.removeListener('close', cleanup); |
| 17114 | } |
| 17115 | |
| 17116 | source.on('end', cleanup); |
| 17117 | source.on('close', cleanup); |
| 17118 | |
| 17119 | dest.on('close', cleanup); |
| 17120 | |
| 17121 | dest.emit('pipe', source); |
| 17122 | |
| 17123 | // Allow for unix-like usage: A.pipe(B).pipe(C) |
| 17124 | return dest; |
| 17125 | }; |
| 17126 | |
| 17127 | },{"events":50,"inherits":56,"readable-stream/duplex.js":70,"readable-stream/passthrough.js":79,"readable-stream/readable.js":80,"readable-stream/transform.js":81,"readable-stream/writable.js":82}],85:[function(require,module,exports){ |
| 17128 | // Copyright Joyent, Inc. and other Node contributors. |
| 17129 | // |
| 17130 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 17131 | // copy of this software and associated documentation files (the |
| 17132 | // "Software"), to deal in the Software without restriction, including |
| 17133 | // without limitation the rights to use, copy, modify, merge, publish, |
| 17134 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 17135 | // persons to whom the Software is furnished to do so, subject to the |
| 17136 | // following conditions: |
| 17137 | // |
| 17138 | // The above copyright notice and this permission notice shall be included |
| 17139 | // in all copies or substantial portions of the Software. |
| 17140 | // |
| 17141 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 17142 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17143 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 17144 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 17145 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 17146 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 17147 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 17148 | |
| 17149 | 'use strict'; |
| 17150 | |
| 17151 | /*<replacement>*/ |
| 17152 | |
| 17153 | var Buffer = require('safe-buffer').Buffer; |
| 17154 | /*</replacement>*/ |
| 17155 | |
| 17156 | var isEncoding = Buffer.isEncoding || function (encoding) { |
| 17157 | encoding = '' + encoding; |
| 17158 | switch (encoding && encoding.toLowerCase()) { |
| 17159 | case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': |
| 17160 | return true; |
| 17161 | default: |
| 17162 | return false; |
| 17163 | } |
| 17164 | }; |
| 17165 | |
| 17166 | function _normalizeEncoding(enc) { |
| 17167 | if (!enc) return 'utf8'; |
| 17168 | var retried; |
| 17169 | while (true) { |
| 17170 | switch (enc) { |
| 17171 | case 'utf8': |
| 17172 | case 'utf-8': |
| 17173 | return 'utf8'; |
| 17174 | case 'ucs2': |
| 17175 | case 'ucs-2': |
| 17176 | case 'utf16le': |
| 17177 | case 'utf-16le': |
| 17178 | return 'utf16le'; |
| 17179 | case 'latin1': |
| 17180 | case 'binary': |
| 17181 | return 'latin1'; |
| 17182 | case 'base64': |
| 17183 | case 'ascii': |
| 17184 | case 'hex': |
| 17185 | return enc; |
| 17186 | default: |
| 17187 | if (retried) return; // undefined |
| 17188 | enc = ('' + enc).toLowerCase(); |
| 17189 | retried = true; |
| 17190 | } |
| 17191 | } |
| 17192 | }; |
| 17193 | |
| 17194 | // Do not cache `Buffer.isEncoding` when checking encoding names as some |
| 17195 | // modules monkey-patch it to support additional encodings |
| 17196 | function normalizeEncoding(enc) { |
| 17197 | var nenc = _normalizeEncoding(enc); |
| 17198 | if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); |
| 17199 | return nenc || enc; |
| 17200 | } |
| 17201 | |
| 17202 | // StringDecoder provides an interface for efficiently splitting a series of |
| 17203 | // buffers into a series of JS strings without breaking apart multi-byte |
| 17204 | // characters. |
| 17205 | exports.StringDecoder = StringDecoder; |
| 17206 | function StringDecoder(encoding) { |
| 17207 | this.encoding = normalizeEncoding(encoding); |
| 17208 | var nb; |
| 17209 | switch (this.encoding) { |
| 17210 | case 'utf16le': |
| 17211 | this.text = utf16Text; |
| 17212 | this.end = utf16End; |
| 17213 | nb = 4; |
| 17214 | break; |
| 17215 | case 'utf8': |
| 17216 | this.fillLast = utf8FillLast; |
| 17217 | nb = 4; |
| 17218 | break; |
| 17219 | case 'base64': |
| 17220 | this.text = base64Text; |
| 17221 | this.end = base64End; |
| 17222 | nb = 3; |
| 17223 | break; |
| 17224 | default: |
| 17225 | this.write = simpleWrite; |
| 17226 | this.end = simpleEnd; |
| 17227 | return; |
| 17228 | } |
| 17229 | this.lastNeed = 0; |
| 17230 | this.lastTotal = 0; |
| 17231 | this.lastChar = Buffer.allocUnsafe(nb); |
| 17232 | } |
| 17233 | |
| 17234 | StringDecoder.prototype.write = function (buf) { |
| 17235 | if (buf.length === 0) return ''; |
| 17236 | var r; |
| 17237 | var i; |
| 17238 | if (this.lastNeed) { |
| 17239 | r = this.fillLast(buf); |
| 17240 | if (r === undefined) return ''; |
| 17241 | i = this.lastNeed; |
| 17242 | this.lastNeed = 0; |
| 17243 | } else { |
| 17244 | i = 0; |
| 17245 | } |
| 17246 | if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); |
| 17247 | return r || ''; |
| 17248 | }; |
| 17249 | |
| 17250 | StringDecoder.prototype.end = utf8End; |
| 17251 | |
| 17252 | // Returns only complete characters in a Buffer |
| 17253 | StringDecoder.prototype.text = utf8Text; |
| 17254 | |
| 17255 | // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer |
| 17256 | StringDecoder.prototype.fillLast = function (buf) { |
| 17257 | if (this.lastNeed <= buf.length) { |
| 17258 | buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); |
| 17259 | return this.lastChar.toString(this.encoding, 0, this.lastTotal); |
| 17260 | } |
| 17261 | buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); |
| 17262 | this.lastNeed -= buf.length; |
| 17263 | }; |
| 17264 | |
| 17265 | // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a |
| 17266 | // continuation byte. If an invalid byte is detected, -2 is returned. |
| 17267 | function utf8CheckByte(byte) { |
| 17268 | if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; |
| 17269 | return byte >> 6 === 0x02 ? -1 : -2; |
| 17270 | } |
| 17271 | |
| 17272 | // Checks at most 3 bytes at the end of a Buffer in order to detect an |
| 17273 | // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) |
| 17274 | // needed to complete the UTF-8 character (if applicable) are returned. |
| 17275 | function utf8CheckIncomplete(self, buf, i) { |
| 17276 | var j = buf.length - 1; |
| 17277 | if (j < i) return 0; |
| 17278 | var nb = utf8CheckByte(buf[j]); |
| 17279 | if (nb >= 0) { |
| 17280 | if (nb > 0) self.lastNeed = nb - 1; |
| 17281 | return nb; |
| 17282 | } |
| 17283 | if (--j < i || nb === -2) return 0; |
| 17284 | nb = utf8CheckByte(buf[j]); |
| 17285 | if (nb >= 0) { |
| 17286 | if (nb > 0) self.lastNeed = nb - 2; |
| 17287 | return nb; |
| 17288 | } |
| 17289 | if (--j < i || nb === -2) return 0; |
| 17290 | nb = utf8CheckByte(buf[j]); |
| 17291 | if (nb >= 0) { |
| 17292 | if (nb > 0) { |
| 17293 | if (nb === 2) nb = 0;else self.lastNeed = nb - 3; |
| 17294 | } |
| 17295 | return nb; |
| 17296 | } |
| 17297 | return 0; |
| 17298 | } |
| 17299 | |
| 17300 | // Validates as many continuation bytes for a multi-byte UTF-8 character as |
| 17301 | // needed or are available. If we see a non-continuation byte where we expect |
| 17302 | // one, we "replace" the validated continuation bytes we've seen so far with |
| 17303 | // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding |
| 17304 | // behavior. The continuation byte check is included three times in the case |
| 17305 | // where all of the continuation bytes for a character exist in the same buffer. |
| 17306 | // It is also done this way as a slight performance increase instead of using a |
| 17307 | // loop. |
| 17308 | function utf8CheckExtraBytes(self, buf, p) { |
| 17309 | if ((buf[0] & 0xC0) !== 0x80) { |
| 17310 | self.lastNeed = 0; |
| 17311 | return '\ufffd'; |
| 17312 | } |
| 17313 | if (self.lastNeed > 1 && buf.length > 1) { |
| 17314 | if ((buf[1] & 0xC0) !== 0x80) { |
| 17315 | self.lastNeed = 1; |
| 17316 | return '\ufffd'; |
| 17317 | } |
| 17318 | if (self.lastNeed > 2 && buf.length > 2) { |
| 17319 | if ((buf[2] & 0xC0) !== 0x80) { |
| 17320 | self.lastNeed = 2; |
| 17321 | return '\ufffd'; |
| 17322 | } |
| 17323 | } |
| 17324 | } |
| 17325 | } |
| 17326 | |
| 17327 | // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. |
| 17328 | function utf8FillLast(buf) { |
| 17329 | var p = this.lastTotal - this.lastNeed; |
| 17330 | var r = utf8CheckExtraBytes(this, buf, p); |
| 17331 | if (r !== undefined) return r; |
| 17332 | if (this.lastNeed <= buf.length) { |
| 17333 | buf.copy(this.lastChar, p, 0, this.lastNeed); |
| 17334 | return this.lastChar.toString(this.encoding, 0, this.lastTotal); |
| 17335 | } |
| 17336 | buf.copy(this.lastChar, p, 0, buf.length); |
| 17337 | this.lastNeed -= buf.length; |
| 17338 | } |
| 17339 | |
| 17340 | // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a |
| 17341 | // partial character, the character's bytes are buffered until the required |
| 17342 | // number of bytes are available. |
| 17343 | function utf8Text(buf, i) { |
| 17344 | var total = utf8CheckIncomplete(this, buf, i); |
| 17345 | if (!this.lastNeed) return buf.toString('utf8', i); |
| 17346 | this.lastTotal = total; |
| 17347 | var end = buf.length - (total - this.lastNeed); |
| 17348 | buf.copy(this.lastChar, 0, end); |
| 17349 | return buf.toString('utf8', i, end); |
| 17350 | } |
| 17351 | |
| 17352 | // For UTF-8, a replacement character is added when ending on a partial |
| 17353 | // character. |
| 17354 | function utf8End(buf) { |
| 17355 | var r = buf && buf.length ? this.write(buf) : ''; |
| 17356 | if (this.lastNeed) return r + '\ufffd'; |
| 17357 | return r; |
| 17358 | } |
| 17359 | |
| 17360 | // UTF-16LE typically needs two bytes per character, but even if we have an even |
| 17361 | // number of bytes available, we need to check if we end on a leading/high |
| 17362 | // surrogate. In that case, we need to wait for the next two bytes in order to |
| 17363 | // decode the last character properly. |
| 17364 | function utf16Text(buf, i) { |
| 17365 | if ((buf.length - i) % 2 === 0) { |
| 17366 | var r = buf.toString('utf16le', i); |
| 17367 | if (r) { |
| 17368 | var c = r.charCodeAt(r.length - 1); |
| 17369 | if (c >= 0xD800 && c <= 0xDBFF) { |
| 17370 | this.lastNeed = 2; |
| 17371 | this.lastTotal = 4; |
| 17372 | this.lastChar[0] = buf[buf.length - 2]; |
| 17373 | this.lastChar[1] = buf[buf.length - 1]; |
| 17374 | return r.slice(0, -1); |
| 17375 | } |
| 17376 | } |
| 17377 | return r; |
| 17378 | } |
| 17379 | this.lastNeed = 1; |
| 17380 | this.lastTotal = 2; |
| 17381 | this.lastChar[0] = buf[buf.length - 1]; |
| 17382 | return buf.toString('utf16le', i, buf.length - 1); |
| 17383 | } |
| 17384 | |
| 17385 | // For UTF-16LE we do not explicitly append special replacement characters if we |
| 17386 | // end on a partial character, we simply let v8 handle that. |
| 17387 | function utf16End(buf) { |
| 17388 | var r = buf && buf.length ? this.write(buf) : ''; |
| 17389 | if (this.lastNeed) { |
| 17390 | var end = this.lastTotal - this.lastNeed; |
| 17391 | return r + this.lastChar.toString('utf16le', 0, end); |
| 17392 | } |
| 17393 | return r; |
| 17394 | } |
| 17395 | |
| 17396 | function base64Text(buf, i) { |
| 17397 | var n = (buf.length - i) % 3; |
| 17398 | if (n === 0) return buf.toString('base64', i); |
| 17399 | this.lastNeed = 3 - n; |
| 17400 | this.lastTotal = 3; |
| 17401 | if (n === 1) { |
| 17402 | this.lastChar[0] = buf[buf.length - 1]; |
| 17403 | } else { |
| 17404 | this.lastChar[0] = buf[buf.length - 2]; |
| 17405 | this.lastChar[1] = buf[buf.length - 1]; |
| 17406 | } |
| 17407 | return buf.toString('base64', i, buf.length - n); |
| 17408 | } |
| 17409 | |
| 17410 | function base64End(buf) { |
| 17411 | var r = buf && buf.length ? this.write(buf) : ''; |
| 17412 | if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); |
| 17413 | return r; |
| 17414 | } |
| 17415 | |
| 17416 | // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) |
| 17417 | function simpleWrite(buf) { |
| 17418 | return buf.toString(this.encoding); |
| 17419 | } |
| 17420 | |
| 17421 | function simpleEnd(buf) { |
| 17422 | return buf && buf.length ? this.write(buf) : ''; |
| 17423 | } |
| 17424 | },{"safe-buffer":83}],86:[function(require,module,exports){ |
| 17425 | (function (setImmediate,clearImmediate){ |
| 17426 | var nextTick = require('process/browser.js').nextTick; |
| 17427 | var apply = Function.prototype.apply; |
| 17428 | var slice = Array.prototype.slice; |
| 17429 | var immediateIds = {}; |
| 17430 | var nextImmediateId = 0; |
| 17431 | |
| 17432 | // DOM APIs, for completeness |
| 17433 | |
| 17434 | exports.setTimeout = function() { |
| 17435 | return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); |
| 17436 | }; |
| 17437 | exports.setInterval = function() { |
| 17438 | return new Timeout(apply.call(setInterval, window, arguments), clearInterval); |
| 17439 | }; |
| 17440 | exports.clearTimeout = |
| 17441 | exports.clearInterval = function(timeout) { timeout.close(); }; |
| 17442 | |
| 17443 | function Timeout(id, clearFn) { |
| 17444 | this._id = id; |
| 17445 | this._clearFn = clearFn; |
| 17446 | } |
| 17447 | Timeout.prototype.unref = Timeout.prototype.ref = function() {}; |
| 17448 | Timeout.prototype.close = function() { |
| 17449 | this._clearFn.call(window, this._id); |
| 17450 | }; |
| 17451 | |
| 17452 | // Does not start the time, just sets up the members needed. |
| 17453 | exports.enroll = function(item, msecs) { |
| 17454 | clearTimeout(item._idleTimeoutId); |
| 17455 | item._idleTimeout = msecs; |
| 17456 | }; |
| 17457 | |
| 17458 | exports.unenroll = function(item) { |
| 17459 | clearTimeout(item._idleTimeoutId); |
| 17460 | item._idleTimeout = -1; |
| 17461 | }; |
| 17462 | |
| 17463 | exports._unrefActive = exports.active = function(item) { |
| 17464 | clearTimeout(item._idleTimeoutId); |
| 17465 | |
| 17466 | var msecs = item._idleTimeout; |
| 17467 | if (msecs >= 0) { |
| 17468 | item._idleTimeoutId = setTimeout(function onTimeout() { |
| 17469 | if (item._onTimeout) |
| 17470 | item._onTimeout(); |
| 17471 | }, msecs); |
| 17472 | } |
| 17473 | }; |
| 17474 | |
| 17475 | // That's not how node.js implements it but the exposed api is the same. |
| 17476 | exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { |
| 17477 | var id = nextImmediateId++; |
| 17478 | var args = arguments.length < 2 ? false : slice.call(arguments, 1); |
| 17479 | |
| 17480 | immediateIds[id] = true; |
| 17481 | |
| 17482 | nextTick(function onNextTick() { |
| 17483 | if (immediateIds[id]) { |
| 17484 | // fn.call() is faster so we optimize for the common use-case |
| 17485 | // @see http://jsperf.com/call-apply-segu |
| 17486 | if (args) { |
| 17487 | fn.apply(null, args); |
| 17488 | } else { |
| 17489 | fn.call(null); |
| 17490 | } |
| 17491 | // Prevent ids from leaking |
| 17492 | exports.clearImmediate(id); |
| 17493 | } |
| 17494 | }); |
| 17495 | |
| 17496 | return id; |
| 17497 | }; |
| 17498 | |
| 17499 | exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { |
| 17500 | delete immediateIds[id]; |
| 17501 | }; |
| 17502 | }).call(this,require("timers").setImmediate,require("timers").clearImmediate) |
| 17503 | },{"process/browser.js":69,"timers":86}],87:[function(require,module,exports){ |
| 17504 | (function (global){ |
| 17505 | |
| 17506 | /** |
| 17507 | * Module exports. |
| 17508 | */ |
| 17509 | |
| 17510 | module.exports = deprecate; |
| 17511 | |
| 17512 | /** |
| 17513 | * Mark that a method should not be used. |
| 17514 | * Returns a modified function which warns once by default. |
| 17515 | * |
| 17516 | * If `localStorage.noDeprecation = true` is set, then it is a no-op. |
| 17517 | * |
| 17518 | * If `localStorage.throwDeprecation = true` is set, then deprecated functions |
| 17519 | * will throw an Error when invoked. |
| 17520 | * |
| 17521 | * If `localStorage.traceDeprecation = true` is set, then deprecated functions |
| 17522 | * will invoke `console.trace()` instead of `console.error()`. |
| 17523 | * |
| 17524 | * @param {Function} fn - the function to deprecate |
| 17525 | * @param {String} msg - the string to print to the console when `fn` is invoked |
| 17526 | * @returns {Function} a new "deprecated" version of `fn` |
| 17527 | * @api public |
| 17528 | */ |
| 17529 | |
| 17530 | function deprecate (fn, msg) { |
| 17531 | if (config('noDeprecation')) { |
| 17532 | return fn; |
| 17533 | } |
| 17534 | |
| 17535 | var warned = false; |
| 17536 | function deprecated() { |
| 17537 | if (!warned) { |
| 17538 | if (config('throwDeprecation')) { |
| 17539 | throw new Error(msg); |
| 17540 | } else if (config('traceDeprecation')) { |
| 17541 | console.trace(msg); |
| 17542 | } else { |
| 17543 | console.warn(msg); |
| 17544 | } |
| 17545 | warned = true; |
| 17546 | } |
| 17547 | return fn.apply(this, arguments); |
| 17548 | } |
| 17549 | |
| 17550 | return deprecated; |
| 17551 | } |
| 17552 | |
| 17553 | /** |
| 17554 | * Checks `localStorage` for boolean values for the given `name`. |
| 17555 | * |
| 17556 | * @param {String} name |
| 17557 | * @returns {Boolean} |
| 17558 | * @api private |
| 17559 | */ |
| 17560 | |
| 17561 | function config (name) { |
| 17562 | // accessing global.localStorage can trigger a DOMException in sandboxed iframes |
| 17563 | try { |
| 17564 | if (!global.localStorage) return false; |
| 17565 | } catch (_) { |
| 17566 | return false; |
| 17567 | } |
| 17568 | var val = global.localStorage[name]; |
| 17569 | if (null == val) return false; |
| 17570 | return String(val).toLowerCase() === 'true'; |
| 17571 | } |
| 17572 | |
| 17573 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 17574 | },{}],88:[function(require,module,exports){ |
| 17575 | module.exports = function isBuffer(arg) { |
| 17576 | return arg && typeof arg === 'object' |
| 17577 | && typeof arg.copy === 'function' |
| 17578 | && typeof arg.fill === 'function' |
| 17579 | && typeof arg.readUInt8 === 'function'; |
| 17580 | } |
| 17581 | },{}],89:[function(require,module,exports){ |
| 17582 | (function (process,global){ |
| 17583 | // Copyright Joyent, Inc. and other Node contributors. |
| 17584 | // |
| 17585 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 17586 | // copy of this software and associated documentation files (the |
| 17587 | // "Software"), to deal in the Software without restriction, including |
| 17588 | // without limitation the rights to use, copy, modify, merge, publish, |
| 17589 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 17590 | // persons to whom the Software is furnished to do so, subject to the |
| 17591 | // following conditions: |
| 17592 | // |
| 17593 | // The above copyright notice and this permission notice shall be included |
| 17594 | // in all copies or substantial portions of the Software. |
| 17595 | // |
| 17596 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 17597 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17598 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 17599 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 17600 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 17601 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 17602 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 17603 | |
| 17604 | var formatRegExp = /%[sdj%]/g; |
| 17605 | exports.format = function(f) { |
| 17606 | if (!isString(f)) { |
| 17607 | var objects = []; |
| 17608 | for (var i = 0; i < arguments.length; i++) { |
| 17609 | objects.push(inspect(arguments[i])); |
| 17610 | } |
| 17611 | return objects.join(' '); |
| 17612 | } |
| 17613 | |
| 17614 | var i = 1; |
| 17615 | var args = arguments; |
| 17616 | var len = args.length; |
| 17617 | var str = String(f).replace(formatRegExp, function(x) { |
| 17618 | if (x === '%%') return '%'; |
| 17619 | if (i >= len) return x; |
| 17620 | switch (x) { |
| 17621 | case '%s': return String(args[i++]); |
| 17622 | case '%d': return Number(args[i++]); |
| 17623 | case '%j': |
| 17624 | try { |
| 17625 | return JSON.stringify(args[i++]); |
| 17626 | } catch (_) { |
| 17627 | return '[Circular]'; |
| 17628 | } |
| 17629 | default: |
| 17630 | return x; |
| 17631 | } |
| 17632 | }); |
| 17633 | for (var x = args[i]; i < len; x = args[++i]) { |
| 17634 | if (isNull(x) || !isObject(x)) { |
| 17635 | str += ' ' + x; |
| 17636 | } else { |
| 17637 | str += ' ' + inspect(x); |
| 17638 | } |
| 17639 | } |
| 17640 | return str; |
| 17641 | }; |
| 17642 | |
| 17643 | |
| 17644 | // Mark that a method should not be used. |
| 17645 | // Returns a modified function which warns once by default. |
| 17646 | // If --no-deprecation is set, then it is a no-op. |
| 17647 | exports.deprecate = function(fn, msg) { |
| 17648 | // Allow for deprecating things in the process of starting up. |
| 17649 | if (isUndefined(global.process)) { |
| 17650 | return function() { |
| 17651 | return exports.deprecate(fn, msg).apply(this, arguments); |
| 17652 | }; |
| 17653 | } |
| 17654 | |
| 17655 | if (process.noDeprecation === true) { |
| 17656 | return fn; |
| 17657 | } |
| 17658 | |
| 17659 | var warned = false; |
| 17660 | function deprecated() { |
| 17661 | if (!warned) { |
| 17662 | if (process.throwDeprecation) { |
| 17663 | throw new Error(msg); |
| 17664 | } else if (process.traceDeprecation) { |
| 17665 | console.trace(msg); |
| 17666 | } else { |
| 17667 | console.error(msg); |
| 17668 | } |
| 17669 | warned = true; |
| 17670 | } |
| 17671 | return fn.apply(this, arguments); |
| 17672 | } |
| 17673 | |
| 17674 | return deprecated; |
| 17675 | }; |
| 17676 | |
| 17677 | |
| 17678 | var debugs = {}; |
| 17679 | var debugEnviron; |
| 17680 | exports.debuglog = function(set) { |
| 17681 | if (isUndefined(debugEnviron)) |
| 17682 | debugEnviron = process.env.NODE_DEBUG || ''; |
| 17683 | set = set.toUpperCase(); |
| 17684 | if (!debugs[set]) { |
| 17685 | if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { |
| 17686 | var pid = process.pid; |
| 17687 | debugs[set] = function() { |
| 17688 | var msg = exports.format.apply(exports, arguments); |
| 17689 | console.error('%s %d: %s', set, pid, msg); |
| 17690 | }; |
| 17691 | } else { |
| 17692 | debugs[set] = function() {}; |
| 17693 | } |
| 17694 | } |
| 17695 | return debugs[set]; |
| 17696 | }; |
| 17697 | |
| 17698 | |
| 17699 | /** |
| 17700 | * Echos the value of a value. Trys to print the value out |
| 17701 | * in the best way possible given the different types. |
| 17702 | * |
| 17703 | * @param {Object} obj The object to print out. |
| 17704 | * @param {Object} opts Optional options object that alters the output. |
| 17705 | */ |
| 17706 | /* legacy: obj, showHidden, depth, colors*/ |
| 17707 | function inspect(obj, opts) { |
| 17708 | // default options |
| 17709 | var ctx = { |
| 17710 | seen: [], |
| 17711 | stylize: stylizeNoColor |
| 17712 | }; |
| 17713 | // legacy... |
| 17714 | if (arguments.length >= 3) ctx.depth = arguments[2]; |
| 17715 | if (arguments.length >= 4) ctx.colors = arguments[3]; |
| 17716 | if (isBoolean(opts)) { |
| 17717 | // legacy... |
| 17718 | ctx.showHidden = opts; |
| 17719 | } else if (opts) { |
| 17720 | // got an "options" object |
| 17721 | exports._extend(ctx, opts); |
| 17722 | } |
| 17723 | // set default options |
| 17724 | if (isUndefined(ctx.showHidden)) ctx.showHidden = false; |
| 17725 | if (isUndefined(ctx.depth)) ctx.depth = 2; |
| 17726 | if (isUndefined(ctx.colors)) ctx.colors = false; |
| 17727 | if (isUndefined(ctx.customInspect)) ctx.customInspect = true; |
| 17728 | if (ctx.colors) ctx.stylize = stylizeWithColor; |
| 17729 | return formatValue(ctx, obj, ctx.depth); |
| 17730 | } |
| 17731 | exports.inspect = inspect; |
| 17732 | |
| 17733 | |
| 17734 | // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics |
| 17735 | inspect.colors = { |
| 17736 | 'bold' : [1, 22], |
| 17737 | 'italic' : [3, 23], |
| 17738 | 'underline' : [4, 24], |
| 17739 | 'inverse' : [7, 27], |
| 17740 | 'white' : [37, 39], |
| 17741 | 'grey' : [90, 39], |
| 17742 | 'black' : [30, 39], |
| 17743 | 'blue' : [34, 39], |
| 17744 | 'cyan' : [36, 39], |
| 17745 | 'green' : [32, 39], |
| 17746 | 'magenta' : [35, 39], |
| 17747 | 'red' : [31, 39], |
| 17748 | 'yellow' : [33, 39] |
| 17749 | }; |
| 17750 | |
| 17751 | // Don't use 'blue' not visible on cmd.exe |
| 17752 | inspect.styles = { |
| 17753 | 'special': 'cyan', |
| 17754 | 'number': 'yellow', |
| 17755 | 'boolean': 'yellow', |
| 17756 | 'undefined': 'grey', |
| 17757 | 'null': 'bold', |
| 17758 | 'string': 'green', |
| 17759 | 'date': 'magenta', |
| 17760 | // "name": intentionally not styling |
| 17761 | 'regexp': 'red' |
| 17762 | }; |
| 17763 | |
| 17764 | |
| 17765 | function stylizeWithColor(str, styleType) { |
| 17766 | var style = inspect.styles[styleType]; |
| 17767 | |
| 17768 | if (style) { |
| 17769 | return '\u001b[' + inspect.colors[style][0] + 'm' + str + |
| 17770 | '\u001b[' + inspect.colors[style][1] + 'm'; |
| 17771 | } else { |
| 17772 | return str; |
| 17773 | } |
| 17774 | } |
| 17775 | |
| 17776 | |
| 17777 | function stylizeNoColor(str, styleType) { |
| 17778 | return str; |
| 17779 | } |
| 17780 | |
| 17781 | |
| 17782 | function arrayToHash(array) { |
| 17783 | var hash = {}; |
| 17784 | |
| 17785 | array.forEach(function(val, idx) { |
| 17786 | hash[val] = true; |
| 17787 | }); |
| 17788 | |
| 17789 | return hash; |
| 17790 | } |
| 17791 | |
| 17792 | |
| 17793 | function formatValue(ctx, value, recurseTimes) { |
| 17794 | // Provide a hook for user-specified inspect functions. |
| 17795 | // Check that value is an object with an inspect function on it |
| 17796 | if (ctx.customInspect && |
| 17797 | value && |
| 17798 | isFunction(value.inspect) && |
| 17799 | // Filter out the util module, it's inspect function is special |
| 17800 | value.inspect !== exports.inspect && |
| 17801 | // Also filter out any prototype objects using the circular check. |
| 17802 | !(value.constructor && value.constructor.prototype === value)) { |
| 17803 | var ret = value.inspect(recurseTimes, ctx); |
| 17804 | if (!isString(ret)) { |
| 17805 | ret = formatValue(ctx, ret, recurseTimes); |
| 17806 | } |
| 17807 | return ret; |
| 17808 | } |
| 17809 | |
| 17810 | // Primitive types cannot have properties |
| 17811 | var primitive = formatPrimitive(ctx, value); |
| 17812 | if (primitive) { |
| 17813 | return primitive; |
| 17814 | } |
| 17815 | |
| 17816 | // Look up the keys of the object. |
| 17817 | var keys = Object.keys(value); |
| 17818 | var visibleKeys = arrayToHash(keys); |
| 17819 | |
| 17820 | if (ctx.showHidden) { |
| 17821 | keys = Object.getOwnPropertyNames(value); |
| 17822 | } |
| 17823 | |
| 17824 | // IE doesn't make error fields non-enumerable |
| 17825 | // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx |
| 17826 | if (isError(value) |
| 17827 | && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { |
| 17828 | return formatError(value); |
| 17829 | } |
| 17830 | |
| 17831 | // Some type of object without properties can be shortcutted. |
| 17832 | if (keys.length === 0) { |
| 17833 | if (isFunction(value)) { |
| 17834 | var name = value.name ? ': ' + value.name : ''; |
| 17835 | return ctx.stylize('[Function' + name + ']', 'special'); |
| 17836 | } |
| 17837 | if (isRegExp(value)) { |
| 17838 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); |
| 17839 | } |
| 17840 | if (isDate(value)) { |
| 17841 | return ctx.stylize(Date.prototype.toString.call(value), 'date'); |
| 17842 | } |
| 17843 | if (isError(value)) { |
| 17844 | return formatError(value); |
| 17845 | } |
| 17846 | } |
| 17847 | |
| 17848 | var base = '', array = false, braces = ['{', '}']; |
| 17849 | |
| 17850 | // Make Array say that they are Array |
| 17851 | if (isArray(value)) { |
| 17852 | array = true; |
| 17853 | braces = ['[', ']']; |
| 17854 | } |
| 17855 | |
| 17856 | // Make functions say that they are functions |
| 17857 | if (isFunction(value)) { |
| 17858 | var n = value.name ? ': ' + value.name : ''; |
| 17859 | base = ' [Function' + n + ']'; |
| 17860 | } |
| 17861 | |
| 17862 | // Make RegExps say that they are RegExps |
| 17863 | if (isRegExp(value)) { |
| 17864 | base = ' ' + RegExp.prototype.toString.call(value); |
| 17865 | } |
| 17866 | |
| 17867 | // Make dates with properties first say the date |
| 17868 | if (isDate(value)) { |
| 17869 | base = ' ' + Date.prototype.toUTCString.call(value); |
| 17870 | } |
| 17871 | |
| 17872 | // Make error with message first say the error |
| 17873 | if (isError(value)) { |
| 17874 | base = ' ' + formatError(value); |
| 17875 | } |
| 17876 | |
| 17877 | if (keys.length === 0 && (!array || value.length == 0)) { |
| 17878 | return braces[0] + base + braces[1]; |
| 17879 | } |
| 17880 | |
| 17881 | if (recurseTimes < 0) { |
| 17882 | if (isRegExp(value)) { |
| 17883 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); |
| 17884 | } else { |
| 17885 | return ctx.stylize('[Object]', 'special'); |
| 17886 | } |
| 17887 | } |
| 17888 | |
| 17889 | ctx.seen.push(value); |
| 17890 | |
| 17891 | var output; |
| 17892 | if (array) { |
| 17893 | output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); |
| 17894 | } else { |
| 17895 | output = keys.map(function(key) { |
| 17896 | return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); |
| 17897 | }); |
| 17898 | } |
| 17899 | |
| 17900 | ctx.seen.pop(); |
| 17901 | |
| 17902 | return reduceToSingleString(output, base, braces); |
| 17903 | } |
| 17904 | |
| 17905 | |
| 17906 | function formatPrimitive(ctx, value) { |
| 17907 | if (isUndefined(value)) |
| 17908 | return ctx.stylize('undefined', 'undefined'); |
| 17909 | if (isString(value)) { |
| 17910 | var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') |
| 17911 | .replace(/'/g, "\\'") |
| 17912 | .replace(/\\"/g, '"') + '\''; |
| 17913 | return ctx.stylize(simple, 'string'); |
| 17914 | } |
| 17915 | if (isNumber(value)) |
| 17916 | return ctx.stylize('' + value, 'number'); |
| 17917 | if (isBoolean(value)) |
| 17918 | return ctx.stylize('' + value, 'boolean'); |
| 17919 | // For some reason typeof null is "object", so special case here. |
| 17920 | if (isNull(value)) |
| 17921 | return ctx.stylize('null', 'null'); |
| 17922 | } |
| 17923 | |
| 17924 | |
| 17925 | function formatError(value) { |
| 17926 | return '[' + Error.prototype.toString.call(value) + ']'; |
| 17927 | } |
| 17928 | |
| 17929 | |
| 17930 | function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { |
| 17931 | var output = []; |
| 17932 | for (var i = 0, l = value.length; i < l; ++i) { |
| 17933 | if (hasOwnProperty(value, String(i))) { |
| 17934 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, |
| 17935 | String(i), true)); |
| 17936 | } else { |
| 17937 | output.push(''); |
| 17938 | } |
| 17939 | } |
| 17940 | keys.forEach(function(key) { |
| 17941 | if (!key.match(/^\d+$/)) { |
| 17942 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, |
| 17943 | key, true)); |
| 17944 | } |
| 17945 | }); |
| 17946 | return output; |
| 17947 | } |
| 17948 | |
| 17949 | |
| 17950 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { |
| 17951 | var name, str, desc; |
| 17952 | desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; |
| 17953 | if (desc.get) { |
| 17954 | if (desc.set) { |
| 17955 | str = ctx.stylize('[Getter/Setter]', 'special'); |
| 17956 | } else { |
| 17957 | str = ctx.stylize('[Getter]', 'special'); |
| 17958 | } |
| 17959 | } else { |
| 17960 | if (desc.set) { |
| 17961 | str = ctx.stylize('[Setter]', 'special'); |
| 17962 | } |
| 17963 | } |
| 17964 | if (!hasOwnProperty(visibleKeys, key)) { |
| 17965 | name = '[' + key + ']'; |
| 17966 | } |
| 17967 | if (!str) { |
| 17968 | if (ctx.seen.indexOf(desc.value) < 0) { |
| 17969 | if (isNull(recurseTimes)) { |
| 17970 | str = formatValue(ctx, desc.value, null); |
| 17971 | } else { |
| 17972 | str = formatValue(ctx, desc.value, recurseTimes - 1); |
| 17973 | } |
| 17974 | if (str.indexOf('\n') > -1) { |
| 17975 | if (array) { |
| 17976 | str = str.split('\n').map(function(line) { |
| 17977 | return ' ' + line; |
| 17978 | }).join('\n').substr(2); |
| 17979 | } else { |
| 17980 | str = '\n' + str.split('\n').map(function(line) { |
| 17981 | return ' ' + line; |
| 17982 | }).join('\n'); |
| 17983 | } |
| 17984 | } |
| 17985 | } else { |
| 17986 | str = ctx.stylize('[Circular]', 'special'); |
| 17987 | } |
| 17988 | } |
| 17989 | if (isUndefined(name)) { |
| 17990 | if (array && key.match(/^\d+$/)) { |
| 17991 | return str; |
| 17992 | } |
| 17993 | name = JSON.stringify('' + key); |
| 17994 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { |
| 17995 | name = name.substr(1, name.length - 2); |
| 17996 | name = ctx.stylize(name, 'name'); |
| 17997 | } else { |
| 17998 | name = name.replace(/'/g, "\\'") |
| 17999 | .replace(/\\"/g, '"') |
| 18000 | .replace(/(^"|"$)/g, "'"); |
| 18001 | name = ctx.stylize(name, 'string'); |
| 18002 | } |
| 18003 | } |
| 18004 | |
| 18005 | return name + ': ' + str; |
| 18006 | } |
| 18007 | |
| 18008 | |
| 18009 | function reduceToSingleString(output, base, braces) { |
| 18010 | var numLinesEst = 0; |
| 18011 | var length = output.reduce(function(prev, cur) { |
| 18012 | numLinesEst++; |
| 18013 | if (cur.indexOf('\n') >= 0) numLinesEst++; |
| 18014 | return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; |
| 18015 | }, 0); |
| 18016 | |
| 18017 | if (length > 60) { |
| 18018 | return braces[0] + |
| 18019 | (base === '' ? '' : base + '\n ') + |
| 18020 | ' ' + |
| 18021 | output.join(',\n ') + |
| 18022 | ' ' + |
| 18023 | braces[1]; |
| 18024 | } |
| 18025 | |
| 18026 | return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; |
| 18027 | } |
| 18028 | |
| 18029 | |
| 18030 | // NOTE: These type checking functions intentionally don't use `instanceof` |
| 18031 | // because it is fragile and can be easily faked with `Object.create()`. |
| 18032 | function isArray(ar) { |
| 18033 | return Array.isArray(ar); |
| 18034 | } |
| 18035 | exports.isArray = isArray; |
| 18036 | |
| 18037 | function isBoolean(arg) { |
| 18038 | return typeof arg === 'boolean'; |
| 18039 | } |
| 18040 | exports.isBoolean = isBoolean; |
| 18041 | |
| 18042 | function isNull(arg) { |
| 18043 | return arg === null; |
| 18044 | } |
| 18045 | exports.isNull = isNull; |
| 18046 | |
| 18047 | function isNullOrUndefined(arg) { |
| 18048 | return arg == null; |
| 18049 | } |
| 18050 | exports.isNullOrUndefined = isNullOrUndefined; |
| 18051 | |
| 18052 | function isNumber(arg) { |
| 18053 | return typeof arg === 'number'; |
| 18054 | } |
| 18055 | exports.isNumber = isNumber; |
| 18056 | |
| 18057 | function isString(arg) { |
| 18058 | return typeof arg === 'string'; |
| 18059 | } |
| 18060 | exports.isString = isString; |
| 18061 | |
| 18062 | function isSymbol(arg) { |
| 18063 | return typeof arg === 'symbol'; |
| 18064 | } |
| 18065 | exports.isSymbol = isSymbol; |
| 18066 | |
| 18067 | function isUndefined(arg) { |
| 18068 | return arg === void 0; |
| 18069 | } |
| 18070 | exports.isUndefined = isUndefined; |
| 18071 | |
| 18072 | function isRegExp(re) { |
| 18073 | return isObject(re) && objectToString(re) === '[object RegExp]'; |
| 18074 | } |
| 18075 | exports.isRegExp = isRegExp; |
| 18076 | |
| 18077 | function isObject(arg) { |
| 18078 | return typeof arg === 'object' && arg !== null; |
| 18079 | } |
| 18080 | exports.isObject = isObject; |
| 18081 | |
| 18082 | function isDate(d) { |
| 18083 | return isObject(d) && objectToString(d) === '[object Date]'; |
| 18084 | } |
| 18085 | exports.isDate = isDate; |
| 18086 | |
| 18087 | function isError(e) { |
| 18088 | return isObject(e) && |
| 18089 | (objectToString(e) === '[object Error]' || e instanceof Error); |
| 18090 | } |
| 18091 | exports.isError = isError; |
| 18092 | |
| 18093 | function isFunction(arg) { |
| 18094 | return typeof arg === 'function'; |
| 18095 | } |
| 18096 | exports.isFunction = isFunction; |
| 18097 | |
| 18098 | function isPrimitive(arg) { |
| 18099 | return arg === null || |
| 18100 | typeof arg === 'boolean' || |
| 18101 | typeof arg === 'number' || |
| 18102 | typeof arg === 'string' || |
| 18103 | typeof arg === 'symbol' || // ES6 symbol |
| 18104 | typeof arg === 'undefined'; |
| 18105 | } |
| 18106 | exports.isPrimitive = isPrimitive; |
| 18107 | |
| 18108 | exports.isBuffer = require('./support/isBuffer'); |
| 18109 | |
| 18110 | function objectToString(o) { |
| 18111 | return Object.prototype.toString.call(o); |
| 18112 | } |
| 18113 | |
| 18114 | |
| 18115 | function pad(n) { |
| 18116 | return n < 10 ? '0' + n.toString(10) : n.toString(10); |
| 18117 | } |
| 18118 | |
| 18119 | |
| 18120 | var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', |
| 18121 | 'Oct', 'Nov', 'Dec']; |
| 18122 | |
| 18123 | // 26 Feb 16:19:34 |
| 18124 | function timestamp() { |
| 18125 | var d = new Date(); |
| 18126 | var time = [pad(d.getHours()), |
| 18127 | pad(d.getMinutes()), |
| 18128 | pad(d.getSeconds())].join(':'); |
| 18129 | return [d.getDate(), months[d.getMonth()], time].join(' '); |
| 18130 | } |
| 18131 | |
| 18132 | |
| 18133 | // log is just a thin wrapper to console.log that prepends a timestamp |
| 18134 | exports.log = function() { |
| 18135 | console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); |
| 18136 | }; |
| 18137 | |
| 18138 | |
| 18139 | /** |
| 18140 | * Inherit the prototype methods from one constructor into another. |
| 18141 | * |
| 18142 | * The Function.prototype.inherits from lang.js rewritten as a standalone |
| 18143 | * function (not on Function.prototype). NOTE: If this file is to be loaded |
| 18144 | * during bootstrapping this function needs to be rewritten using some native |
| 18145 | * functions as prototype setup using normal JavaScript does not work as |
| 18146 | * expected during bootstrapping (see mirror.js in r114903). |
| 18147 | * |
| 18148 | * @param {function} ctor Constructor function which needs to inherit the |
| 18149 | * prototype. |
| 18150 | * @param {function} superCtor Constructor function to inherit prototype from. |
| 18151 | */ |
| 18152 | exports.inherits = require('inherits'); |
| 18153 | |
| 18154 | exports._extend = function(origin, add) { |
| 18155 | // Don't do anything if add isn't an object |
| 18156 | if (!add || !isObject(add)) return origin; |
| 18157 | |
| 18158 | var keys = Object.keys(add); |
| 18159 | var i = keys.length; |
| 18160 | while (i--) { |
| 18161 | origin[keys[i]] = add[keys[i]]; |
| 18162 | } |
| 18163 | return origin; |
| 18164 | }; |
| 18165 | |
| 18166 | function hasOwnProperty(obj, prop) { |
| 18167 | return Object.prototype.hasOwnProperty.call(obj, prop); |
| 18168 | } |
| 18169 | |
| 18170 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 18171 | },{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){ |
| 18172 | module.exports={ |
| 18173 | "name": "mocha", |
Tim van der Lippe | 99190c9 | 2020-04-07 15:46:32 | [diff] [blame] | 18174 | "version": "7.1.1", |
Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame] | 18175 | "homepage": "https://mochajs.org/", |
| 18176 | "notifyLogo": "https://ibin.co/4QuRuGjXvl36.png" |
| 18177 | } |
| 18178 | },{}]},{},[1]); |