UNPKG

576 kBJavaScriptView Raw
1/******/ (() => { // webpackBootstrap
2/******/ var __webpack_modules__ = ({
3
4/***/ "./node_modules/assertion-error/index.js":
5/*!***********************************************!*\
6 !*** ./node_modules/assertion-error/index.js ***!
7 \***********************************************/
8/***/ ((module) => {
9
10/*!
11 * assertion-error
12 * Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
13 * MIT Licensed
14 */
15
16/*!
17 * Return a function that will copy properties from
18 * one object to another excluding any originally
19 * listed. Returned function will create a new `{}`.
20 *
21 * @param {String} excluded properties ...
22 * @return {Function}
23 */
24
25function exclude () {
26 var excludes = [].slice.call(arguments);
27
28 function excludeProps (res, obj) {
29 Object.keys(obj).forEach(function (key) {
30 if (!~excludes.indexOf(key)) res[key] = obj[key];
31 });
32 }
33
34 return function extendExclude () {
35 var args = [].slice.call(arguments)
36 , i = 0
37 , res = {};
38
39 for (; i < args.length; i++) {
40 excludeProps(res, args[i]);
41 }
42
43 return res;
44 };
45};
46
47/*!
48 * Primary Exports
49 */
50
51module.exports = AssertionError;
52
53/**
54 * ### AssertionError
55 *
56 * An extension of the JavaScript `Error` constructor for
57 * assertion and validation scenarios.
58 *
59 * @param {String} message
60 * @param {Object} properties to include (optional)
61 * @param {callee} start stack function (optional)
62 */
63
64function AssertionError (message, _props, ssf) {
65 var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
66 , props = extend(_props || {});
67
68 // default values
69 this.message = message || 'Unspecified AssertionError';
70 this.showDiff = false;
71
72 // copy from properties
73 for (var key in props) {
74 this[key] = props[key];
75 }
76
77 // capture stack trace
78 ssf = ssf || AssertionError;
79 if (Error.captureStackTrace) {
80 Error.captureStackTrace(this, ssf);
81 } else {
82 try {
83 throw new Error();
84 } catch(e) {
85 this.stack = e.stack;
86 }
87 }
88}
89
90/*!
91 * Inherit from Error.prototype
92 */
93
94AssertionError.prototype = Object.create(Error.prototype);
95
96/*!
97 * Statically set name
98 */
99
100AssertionError.prototype.name = 'AssertionError';
101
102/*!
103 * Ensure correct constructor
104 */
105
106AssertionError.prototype.constructor = AssertionError;
107
108/**
109 * Allow errors to be converted to JSON for static transfer.
110 *
111 * @param {Boolean} include stack (default: `true`)
112 * @return {Object} object that can be `JSON.stringify`
113 */
114
115AssertionError.prototype.toJSON = function (stack) {
116 var extend = exclude('constructor', 'toJSON', 'stack')
117 , props = extend({ name: this.name }, this);
118
119 // include stack if exists and not turned off
120 if (false !== stack && this.stack) {
121 props.stack = this.stack;
122 }
123
124 return props;
125};
126
127
128/***/ }),
129
130/***/ "./node_modules/call-bind/callBound.js":
131/*!*********************************************!*\
132 !*** ./node_modules/call-bind/callBound.js ***!
133 \*********************************************/
134/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
135
136"use strict";
137
138
139var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "./node_modules/get-intrinsic/index.js");
140
141var callBind = __webpack_require__(/*! ./ */ "./node_modules/call-bind/index.js");
142
143var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
144
145module.exports = function callBoundIntrinsic(name, allowMissing) {
146 var intrinsic = GetIntrinsic(name, !!allowMissing);
147 if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
148 return callBind(intrinsic);
149 }
150 return intrinsic;
151};
152
153
154/***/ }),
155
156/***/ "./node_modules/call-bind/index.js":
157/*!*****************************************!*\
158 !*** ./node_modules/call-bind/index.js ***!
159 \*****************************************/
160/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
161
162"use strict";
163
164
165var bind = __webpack_require__(/*! function-bind */ "./node_modules/function-bind/index.js");
166var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "./node_modules/get-intrinsic/index.js");
167
168var $apply = GetIntrinsic('%Function.prototype.apply%');
169var $call = GetIntrinsic('%Function.prototype.call%');
170var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
171
172var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
173var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
174var $max = GetIntrinsic('%Math.max%');
175
176if ($defineProperty) {
177 try {
178 $defineProperty({}, 'a', { value: 1 });
179 } catch (e) {
180 // IE 8 has a broken defineProperty
181 $defineProperty = null;
182 }
183}
184
185module.exports = function callBind(originalFunction) {
186 var func = $reflectApply(bind, $call, arguments);
187 if ($gOPD && $defineProperty) {
188 var desc = $gOPD(func, 'length');
189 if (desc.configurable) {
190 // original length, plus the receiver, minus any additional arguments (after the receiver)
191 $defineProperty(
192 func,
193 'length',
194 { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
195 );
196 }
197 }
198 return func;
199};
200
201var applyBind = function applyBind() {
202 return $reflectApply(bind, $apply, arguments);
203};
204
205if ($defineProperty) {
206 $defineProperty(module.exports, 'apply', { value: applyBind });
207} else {
208 module.exports.apply = applyBind;
209}
210
211
212/***/ }),
213
214/***/ "./node_modules/chai/index.js":
215/*!************************************!*\
216 !*** ./node_modules/chai/index.js ***!
217 \************************************/
218/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
219
220module.exports = __webpack_require__(/*! ./lib/chai */ "./node_modules/chai/lib/chai.js");
221
222
223/***/ }),
224
225/***/ "./node_modules/chai/lib/chai.js":
226/*!***************************************!*\
227 !*** ./node_modules/chai/lib/chai.js ***!
228 \***************************************/
229/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
230
231/*!
232 * chai
233 * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
234 * MIT Licensed
235 */
236
237var used = [];
238
239/*!
240 * Chai version
241 */
242
243exports.version = '4.3.3';
244
245/*!
246 * Assertion Error
247 */
248
249exports.AssertionError = __webpack_require__(/*! assertion-error */ "./node_modules/assertion-error/index.js");
250
251/*!
252 * Utils for plugins (not exported)
253 */
254
255var util = __webpack_require__(/*! ./chai/utils */ "./node_modules/chai/lib/chai/utils/index.js");
256
257/**
258 * # .use(function)
259 *
260 * Provides a way to extend the internals of Chai.
261 *
262 * @param {Function}
263 * @returns {this} for chaining
264 * @api public
265 */
266
267exports.use = function (fn) {
268 if (!~used.indexOf(fn)) {
269 fn(exports, util);
270 used.push(fn);
271 }
272
273 return exports;
274};
275
276/*!
277 * Utility Functions
278 */
279
280exports.util = util;
281
282/*!
283 * Configuration
284 */
285
286var config = __webpack_require__(/*! ./chai/config */ "./node_modules/chai/lib/chai/config.js");
287exports.config = config;
288
289/*!
290 * Primary `Assertion` prototype
291 */
292
293var assertion = __webpack_require__(/*! ./chai/assertion */ "./node_modules/chai/lib/chai/assertion.js");
294exports.use(assertion);
295
296/*!
297 * Core Assertions
298 */
299
300var core = __webpack_require__(/*! ./chai/core/assertions */ "./node_modules/chai/lib/chai/core/assertions.js");
301exports.use(core);
302
303/*!
304 * Expect interface
305 */
306
307var expect = __webpack_require__(/*! ./chai/interface/expect */ "./node_modules/chai/lib/chai/interface/expect.js");
308exports.use(expect);
309
310/*!
311 * Should interface
312 */
313
314var should = __webpack_require__(/*! ./chai/interface/should */ "./node_modules/chai/lib/chai/interface/should.js");
315exports.use(should);
316
317/*!
318 * Assert interface
319 */
320
321var assert = __webpack_require__(/*! ./chai/interface/assert */ "./node_modules/chai/lib/chai/interface/assert.js");
322exports.use(assert);
323
324
325/***/ }),
326
327/***/ "./node_modules/chai/lib/chai/assertion.js":
328/*!*************************************************!*\
329 !*** ./node_modules/chai/lib/chai/assertion.js ***!
330 \*************************************************/
331/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
332
333/*!
334 * chai
335 * http://chaijs.com
336 * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
337 * MIT Licensed
338 */
339
340var config = __webpack_require__(/*! ./config */ "./node_modules/chai/lib/chai/config.js");
341
342module.exports = function (_chai, util) {
343 /*!
344 * Module dependencies.
345 */
346
347 var AssertionError = _chai.AssertionError
348 , flag = util.flag;
349
350 /*!
351 * Module export.
352 */
353
354 _chai.Assertion = Assertion;
355
356 /*!
357 * Assertion Constructor
358 *
359 * Creates object for chaining.
360 *
361 * `Assertion` objects contain metadata in the form of flags. Three flags can
362 * be assigned during instantiation by passing arguments to this constructor:
363 *
364 * - `object`: This flag contains the target of the assertion. For example, in
365 * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
366 * contain `numKittens` so that the `equal` assertion can reference it when
367 * needed.
368 *
369 * - `message`: This flag contains an optional custom error message to be
370 * prepended to the error message that's generated by the assertion when it
371 * fails.
372 *
373 * - `ssfi`: This flag stands for "start stack function indicator". It
374 * contains a function reference that serves as the starting point for
375 * removing frames from the stack trace of the error that's created by the
376 * assertion when it fails. The goal is to provide a cleaner stack trace to
377 * end users by removing Chai's internal functions. Note that it only works
378 * in environments that support `Error.captureStackTrace`, and only when
379 * `Chai.config.includeStack` hasn't been set to `false`.
380 *
381 * - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
382 * should retain its current value, even as assertions are chained off of
383 * this object. This is usually set to `true` when creating a new assertion
384 * from within another assertion. It's also temporarily set to `true` before
385 * an overwritten assertion gets called by the overwriting assertion.
386 *
387 * @param {Mixed} obj target of the assertion
388 * @param {String} msg (optional) custom error message
389 * @param {Function} ssfi (optional) starting point for removing stack frames
390 * @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
391 * @api private
392 */
393
394 function Assertion (obj, msg, ssfi, lockSsfi) {
395 flag(this, 'ssfi', ssfi || Assertion);
396 flag(this, 'lockSsfi', lockSsfi);
397 flag(this, 'object', obj);
398 flag(this, 'message', msg);
399
400 return util.proxify(this);
401 }
402
403 Object.defineProperty(Assertion, 'includeStack', {
404 get: function() {
405 console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
406 return config.includeStack;
407 },
408 set: function(value) {
409 console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
410 config.includeStack = value;
411 }
412 });
413
414 Object.defineProperty(Assertion, 'showDiff', {
415 get: function() {
416 console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
417 return config.showDiff;
418 },
419 set: function(value) {
420 console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
421 config.showDiff = value;
422 }
423 });
424
425 Assertion.addProperty = function (name, fn) {
426 util.addProperty(this.prototype, name, fn);
427 };
428
429 Assertion.addMethod = function (name, fn) {
430 util.addMethod(this.prototype, name, fn);
431 };
432
433 Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
434 util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
435 };
436
437 Assertion.overwriteProperty = function (name, fn) {
438 util.overwriteProperty(this.prototype, name, fn);
439 };
440
441 Assertion.overwriteMethod = function (name, fn) {
442 util.overwriteMethod(this.prototype, name, fn);
443 };
444
445 Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
446 util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
447 };
448
449 /**
450 * ### .assert(expression, message, negateMessage, expected, actual, showDiff)
451 *
452 * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
453 *
454 * @name assert
455 * @param {Philosophical} expression to be tested
456 * @param {String|Function} message or function that returns message to display if expression fails
457 * @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
458 * @param {Mixed} expected value (remember to check for negation)
459 * @param {Mixed} actual (optional) will default to `this.obj`
460 * @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
461 * @api private
462 */
463
464 Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
465 var ok = util.test(this, arguments);
466 if (false !== showDiff) showDiff = true;
467 if (undefined === expected && undefined === _actual) showDiff = false;
468 if (true !== config.showDiff) showDiff = false;
469
470 if (!ok) {
471 msg = util.getMessage(this, arguments);
472 var actual = util.getActual(this, arguments);
473 var assertionErrorObjectProperties = {
474 actual: actual
475 , expected: expected
476 , showDiff: showDiff
477 };
478
479 var operator = util.getOperator(this, arguments);
480 if (operator) {
481 assertionErrorObjectProperties.operator = operator;
482 }
483
484 throw new AssertionError(
485 msg,
486 assertionErrorObjectProperties,
487 (config.includeStack) ? this.assert : flag(this, 'ssfi'));
488 }
489 };
490
491 /*!
492 * ### ._obj
493 *
494 * Quick reference to stored `actual` value for plugin developers.
495 *
496 * @api private
497 */
498
499 Object.defineProperty(Assertion.prototype, '_obj',
500 { get: function () {
501 return flag(this, 'object');
502 }
503 , set: function (val) {
504 flag(this, 'object', val);
505 }
506 });
507};
508
509
510/***/ }),
511
512/***/ "./node_modules/chai/lib/chai/config.js":
513/*!**********************************************!*\
514 !*** ./node_modules/chai/lib/chai/config.js ***!
515 \**********************************************/
516/***/ ((module) => {
517
518module.exports = {
519
520 /**
521 * ### config.includeStack
522 *
523 * User configurable property, influences whether stack trace
524 * is included in Assertion error message. Default of false
525 * suppresses stack trace in the error message.
526 *
527 * chai.config.includeStack = true; // enable stack on error
528 *
529 * @param {Boolean}
530 * @api public
531 */
532
533 includeStack: false,
534
535 /**
536 * ### config.showDiff
537 *
538 * User configurable property, influences whether or not
539 * the `showDiff` flag should be included in the thrown
540 * AssertionErrors. `false` will always be `false`; `true`
541 * will be true when the assertion has requested a diff
542 * be shown.
543 *
544 * @param {Boolean}
545 * @api public
546 */
547
548 showDiff: true,
549
550 /**
551 * ### config.truncateThreshold
552 *
553 * User configurable property, sets length threshold for actual and
554 * expected values in assertion errors. If this threshold is exceeded, for
555 * example for large data structures, the value is replaced with something
556 * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
557 *
558 * Set it to zero if you want to disable truncating altogether.
559 *
560 * This is especially userful when doing assertions on arrays: having this
561 * set to a reasonable large value makes the failure messages readily
562 * inspectable.
563 *
564 * chai.config.truncateThreshold = 0; // disable truncating
565 *
566 * @param {Number}
567 * @api public
568 */
569
570 truncateThreshold: 40,
571
572 /**
573 * ### config.useProxy
574 *
575 * User configurable property, defines if chai will use a Proxy to throw
576 * an error when a non-existent property is read, which protects users
577 * from typos when using property-based assertions.
578 *
579 * Set it to false if you want to disable this feature.
580 *
581 * chai.config.useProxy = false; // disable use of Proxy
582 *
583 * This feature is automatically disabled regardless of this config value
584 * in environments that don't support proxies.
585 *
586 * @param {Boolean}
587 * @api public
588 */
589
590 useProxy: true,
591
592 /**
593 * ### config.proxyExcludedKeys
594 *
595 * User configurable property, defines which properties should be ignored
596 * instead of throwing an error if they do not exist on the assertion.
597 * This is only applied if the environment Chai is running in supports proxies and
598 * if the `useProxy` configuration setting is enabled.
599 * By default, `then` and `inspect` will not throw an error if they do not exist on the
600 * assertion object because the `.inspect` property is read by `util.inspect` (for example, when
601 * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking.
602 *
603 * // By default these keys will not throw an error if they do not exist on the assertion object
604 * chai.config.proxyExcludedKeys = ['then', 'inspect'];
605 *
606 * @param {Array}
607 * @api public
608 */
609
610 proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON']
611};
612
613
614/***/ }),
615
616/***/ "./node_modules/chai/lib/chai/core/assertions.js":
617/*!*******************************************************!*\
618 !*** ./node_modules/chai/lib/chai/core/assertions.js ***!
619 \*******************************************************/
620/***/ ((module) => {
621
622/*!
623 * chai
624 * http://chaijs.com
625 * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
626 * MIT Licensed
627 */
628
629module.exports = function (chai, _) {
630 var Assertion = chai.Assertion
631 , AssertionError = chai.AssertionError
632 , flag = _.flag;
633
634 /**
635 * ### Language Chains
636 *
637 * The following are provided as chainable getters to improve the readability
638 * of your assertions.
639 *
640 * **Chains**
641 *
642 * - to
643 * - be
644 * - been
645 * - is
646 * - that
647 * - which
648 * - and
649 * - has
650 * - have
651 * - with
652 * - at
653 * - of
654 * - same
655 * - but
656 * - does
657 * - still
658 * - also
659 *
660 * @name language chains
661 * @namespace BDD
662 * @api public
663 */
664
665 [ 'to', 'be', 'been', 'is'
666 , 'and', 'has', 'have', 'with'
667 , 'that', 'which', 'at', 'of'
668 , 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) {
669 Assertion.addProperty(chain);
670 });
671
672 /**
673 * ### .not
674 *
675 * Negates all assertions that follow in the chain.
676 *
677 * expect(function () {}).to.not.throw();
678 * expect({a: 1}).to.not.have.property('b');
679 * expect([1, 2]).to.be.an('array').that.does.not.include(3);
680 *
681 * Just because you can negate any assertion with `.not` doesn't mean you
682 * should. With great power comes great responsibility. It's often best to
683 * assert that the one expected output was produced, rather than asserting
684 * that one of countless unexpected outputs wasn't produced. See individual
685 * assertions for specific guidance.
686 *
687 * expect(2).to.equal(2); // Recommended
688 * expect(2).to.not.equal(1); // Not recommended
689 *
690 * @name not
691 * @namespace BDD
692 * @api public
693 */
694
695 Assertion.addProperty('not', function () {
696 flag(this, 'negate', true);
697 });
698
699 /**
700 * ### .deep
701 *
702 * Causes all `.equal`, `.include`, `.members`, `.keys`, and `.property`
703 * assertions that follow in the chain to use deep equality instead of strict
704 * (`===`) equality. See the `deep-eql` project page for info on the deep
705 * equality algorithm: https://github.com/chaijs/deep-eql.
706 *
707 * // Target object deeply (but not strictly) equals `{a: 1}`
708 * expect({a: 1}).to.deep.equal({a: 1});
709 * expect({a: 1}).to.not.equal({a: 1});
710 *
711 * // Target array deeply (but not strictly) includes `{a: 1}`
712 * expect([{a: 1}]).to.deep.include({a: 1});
713 * expect([{a: 1}]).to.not.include({a: 1});
714 *
715 * // Target object deeply (but not strictly) includes `x: {a: 1}`
716 * expect({x: {a: 1}}).to.deep.include({x: {a: 1}});
717 * expect({x: {a: 1}}).to.not.include({x: {a: 1}});
718 *
719 * // Target array deeply (but not strictly) has member `{a: 1}`
720 * expect([{a: 1}]).to.have.deep.members([{a: 1}]);
721 * expect([{a: 1}]).to.not.have.members([{a: 1}]);
722 *
723 * // Target set deeply (but not strictly) has key `{a: 1}`
724 * expect(new Set([{a: 1}])).to.have.deep.keys([{a: 1}]);
725 * expect(new Set([{a: 1}])).to.not.have.keys([{a: 1}]);
726 *
727 * // Target object deeply (but not strictly) has property `x: {a: 1}`
728 * expect({x: {a: 1}}).to.have.deep.property('x', {a: 1});
729 * expect({x: {a: 1}}).to.not.have.property('x', {a: 1});
730 *
731 * @name deep
732 * @namespace BDD
733 * @api public
734 */
735
736 Assertion.addProperty('deep', function () {
737 flag(this, 'deep', true);
738 });
739
740 /**
741 * ### .nested
742 *
743 * Enables dot- and bracket-notation in all `.property` and `.include`
744 * assertions that follow in the chain.
745 *
746 * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]');
747 * expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'});
748 *
749 * If `.` or `[]` are part of an actual property name, they can be escaped by
750 * adding two backslashes before them.
751 *
752 * expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]');
753 * expect({'.a': {'[b]': 'x'}}).to.nested.include({'\\.a.\\[b\\]': 'x'});
754 *
755 * `.nested` cannot be combined with `.own`.
756 *
757 * @name nested
758 * @namespace BDD
759 * @api public
760 */
761
762 Assertion.addProperty('nested', function () {
763 flag(this, 'nested', true);
764 });
765
766 /**
767 * ### .own
768 *
769 * Causes all `.property` and `.include` assertions that follow in the chain
770 * to ignore inherited properties.
771 *
772 * Object.prototype.b = 2;
773 *
774 * expect({a: 1}).to.have.own.property('a');
775 * expect({a: 1}).to.have.property('b');
776 * expect({a: 1}).to.not.have.own.property('b');
777 *
778 * expect({a: 1}).to.own.include({a: 1});
779 * expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2});
780 *
781 * `.own` cannot be combined with `.nested`.
782 *
783 * @name own
784 * @namespace BDD
785 * @api public
786 */
787
788 Assertion.addProperty('own', function () {
789 flag(this, 'own', true);
790 });
791
792 /**
793 * ### .ordered
794 *
795 * Causes all `.members` assertions that follow in the chain to require that
796 * members be in the same order.
797 *
798 * expect([1, 2]).to.have.ordered.members([1, 2])
799 * .but.not.have.ordered.members([2, 1]);
800 *
801 * When `.include` and `.ordered` are combined, the ordering begins at the
802 * start of both arrays.
803 *
804 * expect([1, 2, 3]).to.include.ordered.members([1, 2])
805 * .but.not.include.ordered.members([2, 3]);
806 *
807 * @name ordered
808 * @namespace BDD
809 * @api public
810 */
811
812 Assertion.addProperty('ordered', function () {
813 flag(this, 'ordered', true);
814 });
815
816 /**
817 * ### .any
818 *
819 * Causes all `.keys` assertions that follow in the chain to only require that
820 * the target have at least one of the given keys. This is the opposite of
821 * `.all`, which requires that the target have all of the given keys.
822 *
823 * expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd');
824 *
825 * See the `.keys` doc for guidance on when to use `.any` or `.all`.
826 *
827 * @name any
828 * @namespace BDD
829 * @api public
830 */
831
832 Assertion.addProperty('any', function () {
833 flag(this, 'any', true);
834 flag(this, 'all', false);
835 });
836
837 /**
838 * ### .all
839 *
840 * Causes all `.keys` assertions that follow in the chain to require that the
841 * target have all of the given keys. This is the opposite of `.any`, which
842 * only requires that the target have at least one of the given keys.
843 *
844 * expect({a: 1, b: 2}).to.have.all.keys('a', 'b');
845 *
846 * Note that `.all` is used by default when neither `.all` nor `.any` are
847 * added earlier in the chain. However, it's often best to add `.all` anyway
848 * because it improves readability.
849 *
850 * See the `.keys` doc for guidance on when to use `.any` or `.all`.
851 *
852 * @name all
853 * @namespace BDD
854 * @api public
855 */
856
857 Assertion.addProperty('all', function () {
858 flag(this, 'all', true);
859 flag(this, 'any', false);
860 });
861
862 /**
863 * ### .a(type[, msg])
864 *
865 * Asserts that the target's type is equal to the given string `type`. Types
866 * are case insensitive. See the `type-detect` project page for info on the
867 * type detection algorithm: https://github.com/chaijs/type-detect.
868 *
869 * expect('foo').to.be.a('string');
870 * expect({a: 1}).to.be.an('object');
871 * expect(null).to.be.a('null');
872 * expect(undefined).to.be.an('undefined');
873 * expect(new Error).to.be.an('error');
874 * expect(Promise.resolve()).to.be.a('promise');
875 * expect(new Float32Array).to.be.a('float32array');
876 * expect(Symbol()).to.be.a('symbol');
877 *
878 * `.a` supports objects that have a custom type set via `Symbol.toStringTag`.
879 *
880 * var myObj = {
881 * [Symbol.toStringTag]: 'myCustomType'
882 * };
883 *
884 * expect(myObj).to.be.a('myCustomType').but.not.an('object');
885 *
886 * It's often best to use `.a` to check a target's type before making more
887 * assertions on the same target. That way, you avoid unexpected behavior from
888 * any assertion that does different things based on the target's type.
889 *
890 * expect([1, 2, 3]).to.be.an('array').that.includes(2);
891 * expect([]).to.be.an('array').that.is.empty;
892 *
893 * Add `.not` earlier in the chain to negate `.a`. However, it's often best to
894 * assert that the target is the expected type, rather than asserting that it
895 * isn't one of many unexpected types.
896 *
897 * expect('foo').to.be.a('string'); // Recommended
898 * expect('foo').to.not.be.an('array'); // Not recommended
899 *
900 * `.a` accepts an optional `msg` argument which is a custom error message to
901 * show when the assertion fails. The message can also be given as the second
902 * argument to `expect`.
903 *
904 * expect(1).to.be.a('string', 'nooo why fail??');
905 * expect(1, 'nooo why fail??').to.be.a('string');
906 *
907 * `.a` can also be used as a language chain to improve the readability of
908 * your assertions.
909 *
910 * expect({b: 2}).to.have.a.property('b');
911 *
912 * The alias `.an` can be used interchangeably with `.a`.
913 *
914 * @name a
915 * @alias an
916 * @param {String} type
917 * @param {String} msg _optional_
918 * @namespace BDD
919 * @api public
920 */
921
922 function an (type, msg) {
923 if (msg) flag(this, 'message', msg);
924 type = type.toLowerCase();
925 var obj = flag(this, 'object')
926 , article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a ';
927
928 this.assert(
929 type === _.type(obj).toLowerCase()
930 , 'expected #{this} to be ' + article + type
931 , 'expected #{this} not to be ' + article + type
932 );
933 }
934
935 Assertion.addChainableMethod('an', an);
936 Assertion.addChainableMethod('a', an);
937
938 /**
939 * ### .include(val[, msg])
940 *
941 * When the target is a string, `.include` asserts that the given string `val`
942 * is a substring of the target.
943 *
944 * expect('foobar').to.include('foo');
945 *
946 * When the target is an array, `.include` asserts that the given `val` is a
947 * member of the target.
948 *
949 * expect([1, 2, 3]).to.include(2);
950 *
951 * When the target is an object, `.include` asserts that the given object
952 * `val`'s properties are a subset of the target's properties.
953 *
954 * expect({a: 1, b: 2, c: 3}).to.include({a: 1, b: 2});
955 *
956 * When the target is a Set or WeakSet, `.include` asserts that the given `val` is a
957 * member of the target. SameValueZero equality algorithm is used.
958 *
959 * expect(new Set([1, 2])).to.include(2);
960 *
961 * When the target is a Map, `.include` asserts that the given `val` is one of
962 * the values of the target. SameValueZero equality algorithm is used.
963 *
964 * expect(new Map([['a', 1], ['b', 2]])).to.include(2);
965 *
966 * Because `.include` does different things based on the target's type, it's
967 * important to check the target's type before using `.include`. See the `.a`
968 * doc for info on testing a target's type.
969 *
970 * expect([1, 2, 3]).to.be.an('array').that.includes(2);
971 *
972 * By default, strict (`===`) equality is used to compare array members and
973 * object properties. Add `.deep` earlier in the chain to use deep equality
974 * instead (WeakSet targets are not supported). See the `deep-eql` project
975 * page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql.
976 *
977 * // Target array deeply (but not strictly) includes `{a: 1}`
978 * expect([{a: 1}]).to.deep.include({a: 1});
979 * expect([{a: 1}]).to.not.include({a: 1});
980 *
981 * // Target object deeply (but not strictly) includes `x: {a: 1}`
982 * expect({x: {a: 1}}).to.deep.include({x: {a: 1}});
983 * expect({x: {a: 1}}).to.not.include({x: {a: 1}});
984 *
985 * By default, all of the target's properties are searched when working with
986 * objects. This includes properties that are inherited and/or non-enumerable.
987 * Add `.own` earlier in the chain to exclude the target's inherited
988 * properties from the search.
989 *
990 * Object.prototype.b = 2;
991 *
992 * expect({a: 1}).to.own.include({a: 1});
993 * expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2});
994 *
995 * Note that a target object is always only searched for `val`'s own
996 * enumerable properties.
997 *
998 * `.deep` and `.own` can be combined.
999 *
1000 * expect({a: {b: 2}}).to.deep.own.include({a: {b: 2}});
1001 *
1002 * Add `.nested` earlier in the chain to enable dot- and bracket-notation when
1003 * referencing nested properties.
1004 *
1005 * expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'});
1006 *
1007 * If `.` or `[]` are part of an actual property name, they can be escaped by
1008 * adding two backslashes before them.
1009 *
1010 * expect({'.a': {'[b]': 2}}).to.nested.include({'\\.a.\\[b\\]': 2});
1011 *
1012 * `.deep` and `.nested` can be combined.
1013 *
1014 * expect({a: {b: [{c: 3}]}}).to.deep.nested.include({'a.b[0]': {c: 3}});
1015 *
1016 * `.own` and `.nested` cannot be combined.
1017 *
1018 * Add `.not` earlier in the chain to negate `.include`.
1019 *
1020 * expect('foobar').to.not.include('taco');
1021 * expect([1, 2, 3]).to.not.include(4);
1022 *
1023 * However, it's dangerous to negate `.include` when the target is an object.
1024 * The problem is that it creates uncertain expectations by asserting that the
1025 * target object doesn't have all of `val`'s key/value pairs but may or may
1026 * not have some of them. It's often best to identify the exact output that's
1027 * expected, and then write an assertion that only accepts that exact output.
1028 *
1029 * When the target object isn't even expected to have `val`'s keys, it's
1030 * often best to assert exactly that.
1031 *
1032 * expect({c: 3}).to.not.have.any.keys('a', 'b'); // Recommended
1033 * expect({c: 3}).to.not.include({a: 1, b: 2}); // Not recommended
1034 *
1035 * When the target object is expected to have `val`'s keys, it's often best to
1036 * assert that each of the properties has its expected value, rather than
1037 * asserting that each property doesn't have one of many unexpected values.
1038 *
1039 * expect({a: 3, b: 4}).to.include({a: 3, b: 4}); // Recommended
1040 * expect({a: 3, b: 4}).to.not.include({a: 1, b: 2}); // Not recommended
1041 *
1042 * `.include` accepts an optional `msg` argument which is a custom error
1043 * message to show when the assertion fails. The message can also be given as
1044 * the second argument to `expect`.
1045 *
1046 * expect([1, 2, 3]).to.include(4, 'nooo why fail??');
1047 * expect([1, 2, 3], 'nooo why fail??').to.include(4);
1048 *
1049 * `.include` can also be used as a language chain, causing all `.members` and
1050 * `.keys` assertions that follow in the chain to require the target to be a
1051 * superset of the expected set, rather than an identical set. Note that
1052 * `.members` ignores duplicates in the subset when `.include` is added.
1053 *
1054 * // Target object's keys are a superset of ['a', 'b'] but not identical
1055 * expect({a: 1, b: 2, c: 3}).to.include.all.keys('a', 'b');
1056 * expect({a: 1, b: 2, c: 3}).to.not.have.all.keys('a', 'b');
1057 *
1058 * // Target array is a superset of [1, 2] but not identical
1059 * expect([1, 2, 3]).to.include.members([1, 2]);
1060 * expect([1, 2, 3]).to.not.have.members([1, 2]);
1061 *
1062 * // Duplicates in the subset are ignored
1063 * expect([1, 2, 3]).to.include.members([1, 2, 2, 2]);
1064 *
1065 * Note that adding `.any` earlier in the chain causes the `.keys` assertion
1066 * to ignore `.include`.
1067 *
1068 * // Both assertions are identical
1069 * expect({a: 1}).to.include.any.keys('a', 'b');
1070 * expect({a: 1}).to.have.any.keys('a', 'b');
1071 *
1072 * The aliases `.includes`, `.contain`, and `.contains` can be used
1073 * interchangeably with `.include`.
1074 *
1075 * @name include
1076 * @alias contain
1077 * @alias includes
1078 * @alias contains
1079 * @param {Mixed} val
1080 * @param {String} msg _optional_
1081 * @namespace BDD
1082 * @api public
1083 */
1084
1085 function SameValueZero(a, b) {
1086 return (_.isNaN(a) && _.isNaN(b)) || a === b;
1087 }
1088
1089 function includeChainingBehavior () {
1090 flag(this, 'contains', true);
1091 }
1092
1093 function include (val, msg) {
1094 if (msg) flag(this, 'message', msg);
1095
1096 var obj = flag(this, 'object')
1097 , objType = _.type(obj).toLowerCase()
1098 , flagMsg = flag(this, 'message')
1099 , negate = flag(this, 'negate')
1100 , ssfi = flag(this, 'ssfi')
1101 , isDeep = flag(this, 'deep')
1102 , descriptor = isDeep ? 'deep ' : '';
1103
1104 flagMsg = flagMsg ? flagMsg + ': ' : '';
1105
1106 var included = false;
1107
1108 switch (objType) {
1109 case 'string':
1110 included = obj.indexOf(val) !== -1;
1111 break;
1112
1113 case 'weakset':
1114 if (isDeep) {
1115 throw new AssertionError(
1116 flagMsg + 'unable to use .deep.include with WeakSet',
1117 undefined,
1118 ssfi
1119 );
1120 }
1121
1122 included = obj.has(val);
1123 break;
1124
1125 case 'map':
1126 var isEql = isDeep ? _.eql : SameValueZero;
1127 obj.forEach(function (item) {
1128 included = included || isEql(item, val);
1129 });
1130 break;
1131
1132 case 'set':
1133 if (isDeep) {
1134 obj.forEach(function (item) {
1135 included = included || _.eql(item, val);
1136 });
1137 } else {
1138 included = obj.has(val);
1139 }
1140 break;
1141
1142 case 'array':
1143 if (isDeep) {
1144 included = obj.some(function (item) {
1145 return _.eql(item, val);
1146 })
1147 } else {
1148 included = obj.indexOf(val) !== -1;
1149 }
1150 break;
1151
1152 default:
1153 // This block is for asserting a subset of properties in an object.
1154 // `_.expectTypes` isn't used here because `.include` should work with
1155 // objects with a custom `@@toStringTag`.
1156 if (val !== Object(val)) {
1157 throw new AssertionError(
1158 flagMsg + 'the given combination of arguments ('
1159 + objType + ' and '
1160 + _.type(val).toLowerCase() + ')'
1161 + ' is invalid for this assertion. '
1162 + 'You can use an array, a map, an object, a set, a string, '
1163 + 'or a weakset instead of a '
1164 + _.type(val).toLowerCase(),
1165 undefined,
1166 ssfi
1167 );
1168 }
1169
1170 var props = Object.keys(val)
1171 , firstErr = null
1172 , numErrs = 0;
1173
1174 props.forEach(function (prop) {
1175 var propAssertion = new Assertion(obj);
1176 _.transferFlags(this, propAssertion, true);
1177 flag(propAssertion, 'lockSsfi', true);
1178
1179 if (!negate || props.length === 1) {
1180 propAssertion.property(prop, val[prop]);
1181 return;
1182 }
1183
1184 try {
1185 propAssertion.property(prop, val[prop]);
1186 } catch (err) {
1187 if (!_.checkError.compatibleConstructor(err, AssertionError)) {
1188 throw err;
1189 }
1190 if (firstErr === null) firstErr = err;
1191 numErrs++;
1192 }
1193 }, this);
1194
1195 // When validating .not.include with multiple properties, we only want
1196 // to throw an assertion error if all of the properties are included,
1197 // in which case we throw the first property assertion error that we
1198 // encountered.
1199 if (negate && props.length > 1 && numErrs === props.length) {
1200 throw firstErr;
1201 }
1202 return;
1203 }
1204
1205 // Assert inclusion in collection or substring in a string.
1206 this.assert(
1207 included
1208 , 'expected #{this} to ' + descriptor + 'include ' + _.inspect(val)
1209 , 'expected #{this} to not ' + descriptor + 'include ' + _.inspect(val));
1210 }
1211
1212 Assertion.addChainableMethod('include', include, includeChainingBehavior);
1213 Assertion.addChainableMethod('contain', include, includeChainingBehavior);
1214 Assertion.addChainableMethod('contains', include, includeChainingBehavior);
1215 Assertion.addChainableMethod('includes', include, includeChainingBehavior);
1216
1217 /**
1218 * ### .ok
1219 *
1220 * Asserts that the target is a truthy value (considered `true` in boolean context).
1221 * However, it's often best to assert that the target is strictly (`===`) or
1222 * deeply equal to its expected value.
1223 *
1224 * expect(1).to.equal(1); // Recommended
1225 * expect(1).to.be.ok; // Not recommended
1226 *
1227 * expect(true).to.be.true; // Recommended
1228 * expect(true).to.be.ok; // Not recommended
1229 *
1230 * Add `.not` earlier in the chain to negate `.ok`.
1231 *
1232 * expect(0).to.equal(0); // Recommended
1233 * expect(0).to.not.be.ok; // Not recommended
1234 *
1235 * expect(false).to.be.false; // Recommended
1236 * expect(false).to.not.be.ok; // Not recommended
1237 *
1238 * expect(null).to.be.null; // Recommended
1239 * expect(null).to.not.be.ok; // Not recommended
1240 *
1241 * expect(undefined).to.be.undefined; // Recommended
1242 * expect(undefined).to.not.be.ok; // Not recommended
1243 *
1244 * A custom error message can be given as the second argument to `expect`.
1245 *
1246 * expect(false, 'nooo why fail??').to.be.ok;
1247 *
1248 * @name ok
1249 * @namespace BDD
1250 * @api public
1251 */
1252
1253 Assertion.addProperty('ok', function () {
1254 this.assert(
1255 flag(this, 'object')
1256 , 'expected #{this} to be truthy'
1257 , 'expected #{this} to be falsy');
1258 });
1259
1260 /**
1261 * ### .true
1262 *
1263 * Asserts that the target is strictly (`===`) equal to `true`.
1264 *
1265 * expect(true).to.be.true;
1266 *
1267 * Add `.not` earlier in the chain to negate `.true`. However, it's often best
1268 * to assert that the target is equal to its expected value, rather than not
1269 * equal to `true`.
1270 *
1271 * expect(false).to.be.false; // Recommended
1272 * expect(false).to.not.be.true; // Not recommended
1273 *
1274 * expect(1).to.equal(1); // Recommended
1275 * expect(1).to.not.be.true; // Not recommended
1276 *
1277 * A custom error message can be given as the second argument to `expect`.
1278 *
1279 * expect(false, 'nooo why fail??').to.be.true;
1280 *
1281 * @name true
1282 * @namespace BDD
1283 * @api public
1284 */
1285
1286 Assertion.addProperty('true', function () {
1287 this.assert(
1288 true === flag(this, 'object')
1289 , 'expected #{this} to be true'
1290 , 'expected #{this} to be false'
1291 , flag(this, 'negate') ? false : true
1292 );
1293 });
1294
1295 /**
1296 * ### .false
1297 *
1298 * Asserts that the target is strictly (`===`) equal to `false`.
1299 *
1300 * expect(false).to.be.false;
1301 *
1302 * Add `.not` earlier in the chain to negate `.false`. However, it's often
1303 * best to assert that the target is equal to its expected value, rather than
1304 * not equal to `false`.
1305 *
1306 * expect(true).to.be.true; // Recommended
1307 * expect(true).to.not.be.false; // Not recommended
1308 *
1309 * expect(1).to.equal(1); // Recommended
1310 * expect(1).to.not.be.false; // Not recommended
1311 *
1312 * A custom error message can be given as the second argument to `expect`.
1313 *
1314 * expect(true, 'nooo why fail??').to.be.false;
1315 *
1316 * @name false
1317 * @namespace BDD
1318 * @api public
1319 */
1320
1321 Assertion.addProperty('false', function () {
1322 this.assert(
1323 false === flag(this, 'object')
1324 , 'expected #{this} to be false'
1325 , 'expected #{this} to be true'
1326 , flag(this, 'negate') ? true : false
1327 );
1328 });
1329
1330 /**
1331 * ### .null
1332 *
1333 * Asserts that the target is strictly (`===`) equal to `null`.
1334 *
1335 * expect(null).to.be.null;
1336 *
1337 * Add `.not` earlier in the chain to negate `.null`. However, it's often best
1338 * to assert that the target is equal to its expected value, rather than not
1339 * equal to `null`.
1340 *
1341 * expect(1).to.equal(1); // Recommended
1342 * expect(1).to.not.be.null; // Not recommended
1343 *
1344 * A custom error message can be given as the second argument to `expect`.
1345 *
1346 * expect(42, 'nooo why fail??').to.be.null;
1347 *
1348 * @name null
1349 * @namespace BDD
1350 * @api public
1351 */
1352
1353 Assertion.addProperty('null', function () {
1354 this.assert(
1355 null === flag(this, 'object')
1356 , 'expected #{this} to be null'
1357 , 'expected #{this} not to be null'
1358 );
1359 });
1360
1361 /**
1362 * ### .undefined
1363 *
1364 * Asserts that the target is strictly (`===`) equal to `undefined`.
1365 *
1366 * expect(undefined).to.be.undefined;
1367 *
1368 * Add `.not` earlier in the chain to negate `.undefined`. However, it's often
1369 * best to assert that the target is equal to its expected value, rather than
1370 * not equal to `undefined`.
1371 *
1372 * expect(1).to.equal(1); // Recommended
1373 * expect(1).to.not.be.undefined; // Not recommended
1374 *
1375 * A custom error message can be given as the second argument to `expect`.
1376 *
1377 * expect(42, 'nooo why fail??').to.be.undefined;
1378 *
1379 * @name undefined
1380 * @namespace BDD
1381 * @api public
1382 */
1383
1384 Assertion.addProperty('undefined', function () {
1385 this.assert(
1386 undefined === flag(this, 'object')
1387 , 'expected #{this} to be undefined'
1388 , 'expected #{this} not to be undefined'
1389 );
1390 });
1391
1392 /**
1393 * ### .NaN
1394 *
1395 * Asserts that the target is exactly `NaN`.
1396 *
1397 * expect(NaN).to.be.NaN;
1398 *
1399 * Add `.not` earlier in the chain to negate `.NaN`. However, it's often best
1400 * to assert that the target is equal to its expected value, rather than not
1401 * equal to `NaN`.
1402 *
1403 * expect('foo').to.equal('foo'); // Recommended
1404 * expect('foo').to.not.be.NaN; // Not recommended
1405 *
1406 * A custom error message can be given as the second argument to `expect`.
1407 *
1408 * expect(42, 'nooo why fail??').to.be.NaN;
1409 *
1410 * @name NaN
1411 * @namespace BDD
1412 * @api public
1413 */
1414
1415 Assertion.addProperty('NaN', function () {
1416 this.assert(
1417 _.isNaN(flag(this, 'object'))
1418 , 'expected #{this} to be NaN'
1419 , 'expected #{this} not to be NaN'
1420 );
1421 });
1422
1423 /**
1424 * ### .exist
1425 *
1426 * Asserts that the target is not strictly (`===`) equal to either `null` or
1427 * `undefined`. However, it's often best to assert that the target is equal to
1428 * its expected value.
1429 *
1430 * expect(1).to.equal(1); // Recommended
1431 * expect(1).to.exist; // Not recommended
1432 *
1433 * expect(0).to.equal(0); // Recommended
1434 * expect(0).to.exist; // Not recommended
1435 *
1436 * Add `.not` earlier in the chain to negate `.exist`.
1437 *
1438 * expect(null).to.be.null; // Recommended
1439 * expect(null).to.not.exist; // Not recommended
1440 *
1441 * expect(undefined).to.be.undefined; // Recommended
1442 * expect(undefined).to.not.exist; // Not recommended
1443 *
1444 * A custom error message can be given as the second argument to `expect`.
1445 *
1446 * expect(null, 'nooo why fail??').to.exist;
1447 *
1448 * The alias `.exists` can be used interchangeably with `.exist`.
1449 *
1450 * @name exist
1451 * @alias exists
1452 * @namespace BDD
1453 * @api public
1454 */
1455
1456 function assertExist () {
1457 var val = flag(this, 'object');
1458 this.assert(
1459 val !== null && val !== undefined
1460 , 'expected #{this} to exist'
1461 , 'expected #{this} to not exist'
1462 );
1463 }
1464
1465 Assertion.addProperty('exist', assertExist);
1466 Assertion.addProperty('exists', assertExist);
1467
1468 /**
1469 * ### .empty
1470 *
1471 * When the target is a string or array, `.empty` asserts that the target's
1472 * `length` property is strictly (`===`) equal to `0`.
1473 *
1474 * expect([]).to.be.empty;
1475 * expect('').to.be.empty;
1476 *
1477 * When the target is a map or set, `.empty` asserts that the target's `size`
1478 * property is strictly equal to `0`.
1479 *
1480 * expect(new Set()).to.be.empty;
1481 * expect(new Map()).to.be.empty;
1482 *
1483 * When the target is a non-function object, `.empty` asserts that the target
1484 * doesn't have any own enumerable properties. Properties with Symbol-based
1485 * keys are excluded from the count.
1486 *
1487 * expect({}).to.be.empty;
1488 *
1489 * Because `.empty` does different things based on the target's type, it's
1490 * important to check the target's type before using `.empty`. See the `.a`
1491 * doc for info on testing a target's type.
1492 *
1493 * expect([]).to.be.an('array').that.is.empty;
1494 *
1495 * Add `.not` earlier in the chain to negate `.empty`. However, it's often
1496 * best to assert that the target contains its expected number of values,
1497 * rather than asserting that it's not empty.
1498 *
1499 * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended
1500 * expect([1, 2, 3]).to.not.be.empty; // Not recommended
1501 *
1502 * expect(new Set([1, 2, 3])).to.have.property('size', 3); // Recommended
1503 * expect(new Set([1, 2, 3])).to.not.be.empty; // Not recommended
1504 *
1505 * expect(Object.keys({a: 1})).to.have.lengthOf(1); // Recommended
1506 * expect({a: 1}).to.not.be.empty; // Not recommended
1507 *
1508 * A custom error message can be given as the second argument to `expect`.
1509 *
1510 * expect([1, 2, 3], 'nooo why fail??').to.be.empty;
1511 *
1512 * @name empty
1513 * @namespace BDD
1514 * @api public
1515 */
1516
1517 Assertion.addProperty('empty', function () {
1518 var val = flag(this, 'object')
1519 , ssfi = flag(this, 'ssfi')
1520 , flagMsg = flag(this, 'message')
1521 , itemsCount;
1522
1523 flagMsg = flagMsg ? flagMsg + ': ' : '';
1524
1525 switch (_.type(val).toLowerCase()) {
1526 case 'array':
1527 case 'string':
1528 itemsCount = val.length;
1529 break;
1530 case 'map':
1531 case 'set':
1532 itemsCount = val.size;
1533 break;
1534 case 'weakmap':
1535 case 'weakset':
1536 throw new AssertionError(
1537 flagMsg + '.empty was passed a weak collection',
1538 undefined,
1539 ssfi
1540 );
1541 case 'function':
1542 var msg = flagMsg + '.empty was passed a function ' + _.getName(val);
1543 throw new AssertionError(msg.trim(), undefined, ssfi);
1544 default:
1545 if (val !== Object(val)) {
1546 throw new AssertionError(
1547 flagMsg + '.empty was passed non-string primitive ' + _.inspect(val),
1548 undefined,
1549 ssfi
1550 );
1551 }
1552 itemsCount = Object.keys(val).length;
1553 }
1554
1555 this.assert(
1556 0 === itemsCount
1557 , 'expected #{this} to be empty'
1558 , 'expected #{this} not to be empty'
1559 );
1560 });
1561
1562 /**
1563 * ### .arguments
1564 *
1565 * Asserts that the target is an `arguments` object.
1566 *
1567 * function test () {
1568 * expect(arguments).to.be.arguments;
1569 * }
1570 *
1571 * test();
1572 *
1573 * Add `.not` earlier in the chain to negate `.arguments`. However, it's often
1574 * best to assert which type the target is expected to be, rather than
1575 * asserting that it’s not an `arguments` object.
1576 *
1577 * expect('foo').to.be.a('string'); // Recommended
1578 * expect('foo').to.not.be.arguments; // Not recommended
1579 *
1580 * A custom error message can be given as the second argument to `expect`.
1581 *
1582 * expect({}, 'nooo why fail??').to.be.arguments;
1583 *
1584 * The alias `.Arguments` can be used interchangeably with `.arguments`.
1585 *
1586 * @name arguments
1587 * @alias Arguments
1588 * @namespace BDD
1589 * @api public
1590 */
1591
1592 function checkArguments () {
1593 var obj = flag(this, 'object')
1594 , type = _.type(obj);
1595 this.assert(
1596 'Arguments' === type
1597 , 'expected #{this} to be arguments but got ' + type
1598 , 'expected #{this} to not be arguments'
1599 );
1600 }
1601
1602 Assertion.addProperty('arguments', checkArguments);
1603 Assertion.addProperty('Arguments', checkArguments);
1604
1605 /**
1606 * ### .equal(val[, msg])
1607 *
1608 * Asserts that the target is strictly (`===`) equal to the given `val`.
1609 *
1610 * expect(1).to.equal(1);
1611 * expect('foo').to.equal('foo');
1612 *
1613 * Add `.deep` earlier in the chain to use deep equality instead. See the
1614 * `deep-eql` project page for info on the deep equality algorithm:
1615 * https://github.com/chaijs/deep-eql.
1616 *
1617 * // Target object deeply (but not strictly) equals `{a: 1}`
1618 * expect({a: 1}).to.deep.equal({a: 1});
1619 * expect({a: 1}).to.not.equal({a: 1});
1620 *
1621 * // Target array deeply (but not strictly) equals `[1, 2]`
1622 * expect([1, 2]).to.deep.equal([1, 2]);
1623 * expect([1, 2]).to.not.equal([1, 2]);
1624 *
1625 * Add `.not` earlier in the chain to negate `.equal`. However, it's often
1626 * best to assert that the target is equal to its expected value, rather than
1627 * not equal to one of countless unexpected values.
1628 *
1629 * expect(1).to.equal(1); // Recommended
1630 * expect(1).to.not.equal(2); // Not recommended
1631 *
1632 * `.equal` accepts an optional `msg` argument which is a custom error message
1633 * to show when the assertion fails. The message can also be given as the
1634 * second argument to `expect`.
1635 *
1636 * expect(1).to.equal(2, 'nooo why fail??');
1637 * expect(1, 'nooo why fail??').to.equal(2);
1638 *
1639 * The aliases `.equals` and `eq` can be used interchangeably with `.equal`.
1640 *
1641 * @name equal
1642 * @alias equals
1643 * @alias eq
1644 * @param {Mixed} val
1645 * @param {String} msg _optional_
1646 * @namespace BDD
1647 * @api public
1648 */
1649
1650 function assertEqual (val, msg) {
1651 if (msg) flag(this, 'message', msg);
1652 var obj = flag(this, 'object');
1653 if (flag(this, 'deep')) {
1654 var prevLockSsfi = flag(this, 'lockSsfi');
1655 flag(this, 'lockSsfi', true);
1656 this.eql(val);
1657 flag(this, 'lockSsfi', prevLockSsfi);
1658 } else {
1659 this.assert(
1660 val === obj
1661 , 'expected #{this} to equal #{exp}'
1662 , 'expected #{this} to not equal #{exp}'
1663 , val
1664 , this._obj
1665 , true
1666 );
1667 }
1668 }
1669
1670 Assertion.addMethod('equal', assertEqual);
1671 Assertion.addMethod('equals', assertEqual);
1672 Assertion.addMethod('eq', assertEqual);
1673
1674 /**
1675 * ### .eql(obj[, msg])
1676 *
1677 * Asserts that the target is deeply equal to the given `obj`. See the
1678 * `deep-eql` project page for info on the deep equality algorithm:
1679 * https://github.com/chaijs/deep-eql.
1680 *
1681 * // Target object is deeply (but not strictly) equal to {a: 1}
1682 * expect({a: 1}).to.eql({a: 1}).but.not.equal({a: 1});
1683 *
1684 * // Target array is deeply (but not strictly) equal to [1, 2]
1685 * expect([1, 2]).to.eql([1, 2]).but.not.equal([1, 2]);
1686 *
1687 * Add `.not` earlier in the chain to negate `.eql`. However, it's often best
1688 * to assert that the target is deeply equal to its expected value, rather
1689 * than not deeply equal to one of countless unexpected values.
1690 *
1691 * expect({a: 1}).to.eql({a: 1}); // Recommended
1692 * expect({a: 1}).to.not.eql({b: 2}); // Not recommended
1693 *
1694 * `.eql` accepts an optional `msg` argument which is a custom error message
1695 * to show when the assertion fails. The message can also be given as the
1696 * second argument to `expect`.
1697 *
1698 * expect({a: 1}).to.eql({b: 2}, 'nooo why fail??');
1699 * expect({a: 1}, 'nooo why fail??').to.eql({b: 2});
1700 *
1701 * The alias `.eqls` can be used interchangeably with `.eql`.
1702 *
1703 * The `.deep.equal` assertion is almost identical to `.eql` but with one
1704 * difference: `.deep.equal` causes deep equality comparisons to also be used
1705 * for any other assertions that follow in the chain.
1706 *
1707 * @name eql
1708 * @alias eqls
1709 * @param {Mixed} obj
1710 * @param {String} msg _optional_
1711 * @namespace BDD
1712 * @api public
1713 */
1714
1715 function assertEql(obj, msg) {
1716 if (msg) flag(this, 'message', msg);
1717 this.assert(
1718 _.eql(obj, flag(this, 'object'))
1719 , 'expected #{this} to deeply equal #{exp}'
1720 , 'expected #{this} to not deeply equal #{exp}'
1721 , obj
1722 , this._obj
1723 , true
1724 );
1725 }
1726
1727 Assertion.addMethod('eql', assertEql);
1728 Assertion.addMethod('eqls', assertEql);
1729
1730 /**
1731 * ### .above(n[, msg])
1732 *
1733 * Asserts that the target is a number or a date greater than the given number or date `n` respectively.
1734 * However, it's often best to assert that the target is equal to its expected
1735 * value.
1736 *
1737 * expect(2).to.equal(2); // Recommended
1738 * expect(2).to.be.above(1); // Not recommended
1739 *
1740 * Add `.lengthOf` earlier in the chain to assert that the target's `length`
1741 * or `size` is greater than the given number `n`.
1742 *
1743 * expect('foo').to.have.lengthOf(3); // Recommended
1744 * expect('foo').to.have.lengthOf.above(2); // Not recommended
1745 *
1746 * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended
1747 * expect([1, 2, 3]).to.have.lengthOf.above(2); // Not recommended
1748 *
1749 * Add `.not` earlier in the chain to negate `.above`.
1750 *
1751 * expect(2).to.equal(2); // Recommended
1752 * expect(1).to.not.be.above(2); // Not recommended
1753 *
1754 * `.above` accepts an optional `msg` argument which is a custom error message
1755 * to show when the assertion fails. The message can also be given as the
1756 * second argument to `expect`.
1757 *
1758 * expect(1).to.be.above(2, 'nooo why fail??');
1759 * expect(1, 'nooo why fail??').to.be.above(2);
1760 *
1761 * The aliases `.gt` and `.greaterThan` can be used interchangeably with
1762 * `.above`.
1763 *
1764 * @name above
1765 * @alias gt
1766 * @alias greaterThan
1767 * @param {Number} n
1768 * @param {String} msg _optional_
1769 * @namespace BDD
1770 * @api public
1771 */
1772
1773 function assertAbove (n, msg) {
1774 if (msg) flag(this, 'message', msg);
1775 var obj = flag(this, 'object')
1776 , doLength = flag(this, 'doLength')
1777 , flagMsg = flag(this, 'message')
1778 , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
1779 , ssfi = flag(this, 'ssfi')
1780 , objType = _.type(obj).toLowerCase()
1781 , nType = _.type(n).toLowerCase()
1782 , errorMessage
1783 , shouldThrow = true;
1784
1785 if (doLength && objType !== 'map' && objType !== 'set') {
1786 new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
1787 }
1788
1789 if (!doLength && (objType === 'date' && nType !== 'date')) {
1790 errorMessage = msgPrefix + 'the argument to above must be a date';
1791 } else if (nType !== 'number' && (doLength || objType === 'number')) {
1792 errorMessage = msgPrefix + 'the argument to above must be a number';
1793 } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1794 var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1795 errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1796 } else {
1797 shouldThrow = false;
1798 }
1799
1800 if (shouldThrow) {
1801 throw new AssertionError(errorMessage, undefined, ssfi);
1802 }
1803
1804 if (doLength) {
1805 var descriptor = 'length'
1806 , itemsCount;
1807 if (objType === 'map' || objType === 'set') {
1808 descriptor = 'size';
1809 itemsCount = obj.size;
1810 } else {
1811 itemsCount = obj.length;
1812 }
1813 this.assert(
1814 itemsCount > n
1815 , 'expected #{this} to have a ' + descriptor + ' above #{exp} but got #{act}'
1816 , 'expected #{this} to not have a ' + descriptor + ' above #{exp}'
1817 , n
1818 , itemsCount
1819 );
1820 } else {
1821 this.assert(
1822 obj > n
1823 , 'expected #{this} to be above #{exp}'
1824 , 'expected #{this} to be at most #{exp}'
1825 , n
1826 );
1827 }
1828 }
1829
1830 Assertion.addMethod('above', assertAbove);
1831 Assertion.addMethod('gt', assertAbove);
1832 Assertion.addMethod('greaterThan', assertAbove);
1833
1834 /**
1835 * ### .least(n[, msg])
1836 *
1837 * Asserts that the target is a number or a date greater than or equal to the given
1838 * number or date `n` respectively. However, it's often best to assert that the target is equal to
1839 * its expected value.
1840 *
1841 * expect(2).to.equal(2); // Recommended
1842 * expect(2).to.be.at.least(1); // Not recommended
1843 * expect(2).to.be.at.least(2); // Not recommended
1844 *
1845 * Add `.lengthOf` earlier in the chain to assert that the target's `length`
1846 * or `size` is greater than or equal to the given number `n`.
1847 *
1848 * expect('foo').to.have.lengthOf(3); // Recommended
1849 * expect('foo').to.have.lengthOf.at.least(2); // Not recommended
1850 *
1851 * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended
1852 * expect([1, 2, 3]).to.have.lengthOf.at.least(2); // Not recommended
1853 *
1854 * Add `.not` earlier in the chain to negate `.least`.
1855 *
1856 * expect(1).to.equal(1); // Recommended
1857 * expect(1).to.not.be.at.least(2); // Not recommended
1858 *
1859 * `.least` accepts an optional `msg` argument which is a custom error message
1860 * to show when the assertion fails. The message can also be given as the
1861 * second argument to `expect`.
1862 *
1863 * expect(1).to.be.at.least(2, 'nooo why fail??');
1864 * expect(1, 'nooo why fail??').to.be.at.least(2);
1865 *
1866 * The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with
1867 * `.least`.
1868 *
1869 * @name least
1870 * @alias gte
1871 * @alias greaterThanOrEqual
1872 * @param {Number} n
1873 * @param {String} msg _optional_
1874 * @namespace BDD
1875 * @api public
1876 */
1877
1878 function assertLeast (n, msg) {
1879 if (msg) flag(this, 'message', msg);
1880 var obj = flag(this, 'object')
1881 , doLength = flag(this, 'doLength')
1882 , flagMsg = flag(this, 'message')
1883 , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
1884 , ssfi = flag(this, 'ssfi')
1885 , objType = _.type(obj).toLowerCase()
1886 , nType = _.type(n).toLowerCase()
1887 , errorMessage
1888 , shouldThrow = true;
1889
1890 if (doLength && objType !== 'map' && objType !== 'set') {
1891 new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
1892 }
1893
1894 if (!doLength && (objType === 'date' && nType !== 'date')) {
1895 errorMessage = msgPrefix + 'the argument to least must be a date';
1896 } else if (nType !== 'number' && (doLength || objType === 'number')) {
1897 errorMessage = msgPrefix + 'the argument to least must be a number';
1898 } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1899 var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1900 errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1901 } else {
1902 shouldThrow = false;
1903 }
1904
1905 if (shouldThrow) {
1906 throw new AssertionError(errorMessage, undefined, ssfi);
1907 }
1908
1909 if (doLength) {
1910 var descriptor = 'length'
1911 , itemsCount;
1912 if (objType === 'map' || objType === 'set') {
1913 descriptor = 'size';
1914 itemsCount = obj.size;
1915 } else {
1916 itemsCount = obj.length;
1917 }
1918 this.assert(
1919 itemsCount >= n
1920 , 'expected #{this} to have a ' + descriptor + ' at least #{exp} but got #{act}'
1921 , 'expected #{this} to have a ' + descriptor + ' below #{exp}'
1922 , n
1923 , itemsCount
1924 );
1925 } else {
1926 this.assert(
1927 obj >= n
1928 , 'expected #{this} to be at least #{exp}'
1929 , 'expected #{this} to be below #{exp}'
1930 , n
1931 );
1932 }
1933 }
1934
1935 Assertion.addMethod('least', assertLeast);
1936 Assertion.addMethod('gte', assertLeast);
1937 Assertion.addMethod('greaterThanOrEqual', assertLeast);
1938
1939 /**
1940 * ### .below(n[, msg])
1941 *
1942 * Asserts that the target is a number or a date less than the given number or date `n` respectively.
1943 * However, it's often best to assert that the target is equal to its expected
1944 * value.
1945 *
1946 * expect(1).to.equal(1); // Recommended
1947 * expect(1).to.be.below(2); // Not recommended
1948 *
1949 * Add `.lengthOf` earlier in the chain to assert that the target's `length`
1950 * or `size` is less than the given number `n`.
1951 *
1952 * expect('foo').to.have.lengthOf(3); // Recommended
1953 * expect('foo').to.have.lengthOf.below(4); // Not recommended
1954 *
1955 * expect([1, 2, 3]).to.have.length(3); // Recommended
1956 * expect([1, 2, 3]).to.have.lengthOf.below(4); // Not recommended
1957 *
1958 * Add `.not` earlier in the chain to negate `.below`.
1959 *
1960 * expect(2).to.equal(2); // Recommended
1961 * expect(2).to.not.be.below(1); // Not recommended
1962 *
1963 * `.below` accepts an optional `msg` argument which is a custom error message
1964 * to show when the assertion fails. The message can also be given as the
1965 * second argument to `expect`.
1966 *
1967 * expect(2).to.be.below(1, 'nooo why fail??');
1968 * expect(2, 'nooo why fail??').to.be.below(1);
1969 *
1970 * The aliases `.lt` and `.lessThan` can be used interchangeably with
1971 * `.below`.
1972 *
1973 * @name below
1974 * @alias lt
1975 * @alias lessThan
1976 * @param {Number} n
1977 * @param {String} msg _optional_
1978 * @namespace BDD
1979 * @api public
1980 */
1981
1982 function assertBelow (n, msg) {
1983 if (msg) flag(this, 'message', msg);
1984 var obj = flag(this, 'object')
1985 , doLength = flag(this, 'doLength')
1986 , flagMsg = flag(this, 'message')
1987 , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
1988 , ssfi = flag(this, 'ssfi')
1989 , objType = _.type(obj).toLowerCase()
1990 , nType = _.type(n).toLowerCase()
1991 , errorMessage
1992 , shouldThrow = true;
1993
1994 if (doLength && objType !== 'map' && objType !== 'set') {
1995 new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
1996 }
1997
1998 if (!doLength && (objType === 'date' && nType !== 'date')) {
1999 errorMessage = msgPrefix + 'the argument to below must be a date';
2000 } else if (nType !== 'number' && (doLength || objType === 'number')) {
2001 errorMessage = msgPrefix + 'the argument to below must be a number';
2002 } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
2003 var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
2004 errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
2005 } else {
2006 shouldThrow = false;
2007 }
2008
2009 if (shouldThrow) {
2010 throw new AssertionError(errorMessage, undefined, ssfi);
2011 }
2012
2013 if (doLength) {
2014 var descriptor = 'length'
2015 , itemsCount;
2016 if (objType === 'map' || objType === 'set') {
2017 descriptor = 'size';
2018 itemsCount = obj.size;
2019 } else {
2020 itemsCount = obj.length;
2021 }
2022 this.assert(
2023 itemsCount < n
2024 , 'expected #{this} to have a ' + descriptor + ' below #{exp} but got #{act}'
2025 , 'expected #{this} to not have a ' + descriptor + ' below #{exp}'
2026 , n
2027 , itemsCount
2028 );
2029 } else {
2030 this.assert(
2031 obj < n
2032 , 'expected #{this} to be below #{exp}'
2033 , 'expected #{this} to be at least #{exp}'
2034 , n
2035 );
2036 }
2037 }
2038
2039 Assertion.addMethod('below', assertBelow);
2040 Assertion.addMethod('lt', assertBelow);
2041 Assertion.addMethod('lessThan', assertBelow);
2042
2043 /**
2044 * ### .most(n[, msg])
2045 *
2046 * Asserts that the target is a number or a date less than or equal to the given number
2047 * or date `n` respectively. However, it's often best to assert that the target is equal to its
2048 * expected value.
2049 *
2050 * expect(1).to.equal(1); // Recommended
2051 * expect(1).to.be.at.most(2); // Not recommended
2052 * expect(1).to.be.at.most(1); // Not recommended
2053 *
2054 * Add `.lengthOf` earlier in the chain to assert that the target's `length`
2055 * or `size` is less than or equal to the given number `n`.
2056 *
2057 * expect('foo').to.have.lengthOf(3); // Recommended
2058 * expect('foo').to.have.lengthOf.at.most(4); // Not recommended
2059 *
2060 * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended
2061 * expect([1, 2, 3]).to.have.lengthOf.at.most(4); // Not recommended
2062 *
2063 * Add `.not` earlier in the chain to negate `.most`.
2064 *
2065 * expect(2).to.equal(2); // Recommended
2066 * expect(2).to.not.be.at.most(1); // Not recommended
2067 *
2068 * `.most` accepts an optional `msg` argument which is a custom error message
2069 * to show when the assertion fails. The message can also be given as the
2070 * second argument to `expect`.
2071 *
2072 * expect(2).to.be.at.most(1, 'nooo why fail??');
2073 * expect(2, 'nooo why fail??').to.be.at.most(1);
2074 *
2075 * The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with
2076 * `.most`.
2077 *
2078 * @name most
2079 * @alias lte
2080 * @alias lessThanOrEqual
2081 * @param {Number} n
2082 * @param {String} msg _optional_
2083 * @namespace BDD
2084 * @api public
2085 */
2086
2087 function assertMost (n, msg) {
2088 if (msg) flag(this, 'message', msg);
2089 var obj = flag(this, 'object')
2090 , doLength = flag(this, 'doLength')
2091 , flagMsg = flag(this, 'message')
2092 , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
2093 , ssfi = flag(this, 'ssfi')
2094 , objType = _.type(obj).toLowerCase()
2095 , nType = _.type(n).toLowerCase()
2096 , errorMessage
2097 , shouldThrow = true;
2098
2099 if (doLength && objType !== 'map' && objType !== 'set') {
2100 new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
2101 }
2102
2103 if (!doLength && (objType === 'date' && nType !== 'date')) {
2104 errorMessage = msgPrefix + 'the argument to most must be a date';
2105 } else if (nType !== 'number' && (doLength || objType === 'number')) {
2106 errorMessage = msgPrefix + 'the argument to most must be a number';
2107 } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
2108 var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
2109 errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
2110 } else {
2111 shouldThrow = false;
2112 }
2113
2114 if (shouldThrow) {
2115 throw new AssertionError(errorMessage, undefined, ssfi);
2116 }
2117
2118 if (doLength) {
2119 var descriptor = 'length'
2120 , itemsCount;
2121 if (objType === 'map' || objType === 'set') {
2122 descriptor = 'size';
2123 itemsCount = obj.size;
2124 } else {
2125 itemsCount = obj.length;
2126 }
2127 this.assert(
2128 itemsCount <= n
2129 , 'expected #{this} to have a ' + descriptor + ' at most #{exp} but got #{act}'
2130 , 'expected #{this} to have a ' + descriptor + ' above #{exp}'
2131 , n
2132 , itemsCount
2133 );
2134 } else {
2135 this.assert(
2136 obj <= n
2137 , 'expected #{this} to be at most #{exp}'
2138 , 'expected #{this} to be above #{exp}'
2139 , n
2140 );
2141 }
2142 }
2143
2144 Assertion.addMethod('most', assertMost);
2145 Assertion.addMethod('lte', assertMost);
2146 Assertion.addMethod('lessThanOrEqual', assertMost);
2147
2148 /**
2149 * ### .within(start, finish[, msg])
2150 *
2151 * Asserts that the target is a number or a date greater than or equal to the given
2152 * number or date `start`, and less than or equal to the given number or date `finish` respectively.
2153 * However, it's often best to assert that the target is equal to its expected
2154 * value.
2155 *
2156 * expect(2).to.equal(2); // Recommended
2157 * expect(2).to.be.within(1, 3); // Not recommended
2158 * expect(2).to.be.within(2, 3); // Not recommended
2159 * expect(2).to.be.within(1, 2); // Not recommended
2160 *
2161 * Add `.lengthOf` earlier in the chain to assert that the target's `length`
2162 * or `size` is greater than or equal to the given number `start`, and less
2163 * than or equal to the given number `finish`.
2164 *
2165 * expect('foo').to.have.lengthOf(3); // Recommended
2166 * expect('foo').to.have.lengthOf.within(2, 4); // Not recommended
2167 *
2168 * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended
2169 * expect([1, 2, 3]).to.have.lengthOf.within(2, 4); // Not recommended
2170 *
2171 * Add `.not` earlier in the chain to negate `.within`.
2172 *
2173 * expect(1).to.equal(1); // Recommended
2174 * expect(1).to.not.be.within(2, 4); // Not recommended
2175 *
2176 * `.within` accepts an optional `msg` argument which is a custom error
2177 * message to show when the assertion fails. The message can also be given as
2178 * the second argument to `expect`.
2179 *
2180 * expect(4).to.be.within(1, 3, 'nooo why fail??');
2181 * expect(4, 'nooo why fail??').to.be.within(1, 3);
2182 *
2183 * @name within
2184 * @param {Number} start lower bound inclusive
2185 * @param {Number} finish upper bound inclusive
2186 * @param {String} msg _optional_
2187 * @namespace BDD
2188 * @api public
2189 */
2190
2191 Assertion.addMethod('within', function (start, finish, msg) {
2192 if (msg) flag(this, 'message', msg);
2193 var obj = flag(this, 'object')
2194 , doLength = flag(this, 'doLength')
2195 , flagMsg = flag(this, 'message')
2196 , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
2197 , ssfi = flag(this, 'ssfi')
2198 , objType = _.type(obj).toLowerCase()
2199 , startType = _.type(start).toLowerCase()
2200 , finishType = _.type(finish).toLowerCase()
2201 , errorMessage
2202 , shouldThrow = true
2203 , range = (startType === 'date' && finishType === 'date')
2204 ? start.toISOString() + '..' + finish.toISOString()
2205 : start + '..' + finish;
2206
2207 if (doLength && objType !== 'map' && objType !== 'set') {
2208 new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
2209 }
2210
2211 if (!doLength && (objType === 'date' && (startType !== 'date' || finishType !== 'date'))) {
2212 errorMessage = msgPrefix + 'the arguments to within must be dates';
2213 } else if ((startType !== 'number' || finishType !== 'number') && (doLength || objType === 'number')) {
2214 errorMessage = msgPrefix + 'the arguments to within must be numbers';
2215 } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
2216 var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
2217 errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
2218 } else {
2219 shouldThrow = false;
2220 }
2221
2222 if (shouldThrow) {
2223 throw new AssertionError(errorMessage, undefined, ssfi);
2224 }
2225
2226 if (doLength) {
2227 var descriptor = 'length'
2228 , itemsCount;
2229 if (objType === 'map' || objType === 'set') {
2230 descriptor = 'size';
2231 itemsCount = obj.size;
2232 } else {
2233 itemsCount = obj.length;
2234 }
2235 this.assert(
2236 itemsCount >= start && itemsCount <= finish
2237 , 'expected #{this} to have a ' + descriptor + ' within ' + range
2238 , 'expected #{this} to not have a ' + descriptor + ' within ' + range
2239 );
2240 } else {
2241 this.assert(
2242 obj >= start && obj <= finish
2243 , 'expected #{this} to be within ' + range
2244 , 'expected #{this} to not be within ' + range
2245 );
2246 }
2247 });
2248
2249 /**
2250 * ### .instanceof(constructor[, msg])
2251 *
2252 * Asserts that the target is an instance of the given `constructor`.
2253 *
2254 * function Cat () { }
2255 *
2256 * expect(new Cat()).to.be.an.instanceof(Cat);
2257 * expect([1, 2]).to.be.an.instanceof(Array);
2258 *
2259 * Add `.not` earlier in the chain to negate `.instanceof`.
2260 *
2261 * expect({a: 1}).to.not.be.an.instanceof(Array);
2262 *
2263 * `.instanceof` accepts an optional `msg` argument which is a custom error
2264 * message to show when the assertion fails. The message can also be given as
2265 * the second argument to `expect`.
2266 *
2267 * expect(1).to.be.an.instanceof(Array, 'nooo why fail??');
2268 * expect(1, 'nooo why fail??').to.be.an.instanceof(Array);
2269 *
2270 * Due to limitations in ES5, `.instanceof` may not always work as expected
2271 * when using a transpiler such as Babel or TypeScript. In particular, it may
2272 * produce unexpected results when subclassing built-in object such as
2273 * `Array`, `Error`, and `Map`. See your transpiler's docs for details:
2274 *
2275 * - ([Babel](https://babeljs.io/docs/usage/caveats/#classes))
2276 * - ([TypeScript](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work))
2277 *
2278 * The alias `.instanceOf` can be used interchangeably with `.instanceof`.
2279 *
2280 * @name instanceof
2281 * @param {Constructor} constructor
2282 * @param {String} msg _optional_
2283 * @alias instanceOf
2284 * @namespace BDD
2285 * @api public
2286 */
2287
2288 function assertInstanceOf (constructor, msg) {
2289 if (msg) flag(this, 'message', msg);
2290
2291 var target = flag(this, 'object')
2292 var ssfi = flag(this, 'ssfi');
2293 var flagMsg = flag(this, 'message');
2294
2295 try {
2296 var isInstanceOf = target instanceof constructor;
2297 } catch (err) {
2298 if (err instanceof TypeError) {
2299 flagMsg = flagMsg ? flagMsg + ': ' : '';
2300 throw new AssertionError(
2301 flagMsg + 'The instanceof assertion needs a constructor but '
2302 + _.type(constructor) + ' was given.',
2303 undefined,
2304 ssfi
2305 );
2306 }
2307 throw err;
2308 }
2309
2310 var name = _.getName(constructor);
2311 if (name === null) {
2312 name = 'an unnamed constructor';
2313 }
2314
2315 this.assert(
2316 isInstanceOf
2317 , 'expected #{this} to be an instance of ' + name
2318 , 'expected #{this} to not be an instance of ' + name
2319 );
2320 };
2321
2322 Assertion.addMethod('instanceof', assertInstanceOf);
2323 Assertion.addMethod('instanceOf', assertInstanceOf);
2324
2325 /**
2326 * ### .property(name[, val[, msg]])
2327 *
2328 * Asserts that the target has a property with the given key `name`.
2329 *
2330 * expect({a: 1}).to.have.property('a');
2331 *
2332 * When `val` is provided, `.property` also asserts that the property's value
2333 * is equal to the given `val`.
2334 *
2335 * expect({a: 1}).to.have.property('a', 1);
2336 *
2337 * By default, strict (`===`) equality is used. Add `.deep` earlier in the
2338 * chain to use deep equality instead. See the `deep-eql` project page for
2339 * info on the deep equality algorithm: https://github.com/chaijs/deep-eql.
2340 *
2341 * // Target object deeply (but not strictly) has property `x: {a: 1}`
2342 * expect({x: {a: 1}}).to.have.deep.property('x', {a: 1});
2343 * expect({x: {a: 1}}).to.not.have.property('x', {a: 1});
2344 *
2345 * The target's enumerable and non-enumerable properties are always included
2346 * in the search. By default, both own and inherited properties are included.
2347 * Add `.own` earlier in the chain to exclude inherited properties from the
2348 * search.
2349 *
2350 * Object.prototype.b = 2;
2351 *
2352 * expect({a: 1}).to.have.own.property('a');
2353 * expect({a: 1}).to.have.own.property('a', 1);
2354 * expect({a: 1}).to.have.property('b');
2355 * expect({a: 1}).to.not.have.own.property('b');
2356 *
2357 * `.deep` and `.own` can be combined.
2358 *
2359 * expect({x: {a: 1}}).to.have.deep.own.property('x', {a: 1});
2360 *
2361 * Add `.nested` earlier in the chain to enable dot- and bracket-notation when
2362 * referencing nested properties.
2363 *
2364 * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]');
2365 * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]', 'y');
2366 *
2367 * If `.` or `[]` are part of an actual property name, they can be escaped by
2368 * adding two backslashes before them.
2369 *
2370 * expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]');
2371 *
2372 * `.deep` and `.nested` can be combined.
2373 *
2374 * expect({a: {b: [{c: 3}]}})
2375 * .to.have.deep.nested.property('a.b[0]', {c: 3});
2376 *
2377 * `.own` and `.nested` cannot be combined.
2378 *
2379 * Add `.not` earlier in the chain to negate `.property`.
2380 *
2381 * expect({a: 1}).to.not.have.property('b');
2382 *
2383 * However, it's dangerous to negate `.property` when providing `val`. The
2384 * problem is that it creates uncertain expectations by asserting that the
2385 * target either doesn't have a property with the given key `name`, or that it
2386 * does have a property with the given key `name` but its value isn't equal to
2387 * the given `val`. It's often best to identify the exact output that's
2388 * expected, and then write an assertion that only accepts that exact output.
2389 *
2390 * When the target isn't expected to have a property with the given key
2391 * `name`, it's often best to assert exactly that.
2392 *
2393 * expect({b: 2}).to.not.have.property('a'); // Recommended
2394 * expect({b: 2}).to.not.have.property('a', 1); // Not recommended
2395 *
2396 * When the target is expected to have a property with the given key `name`,
2397 * it's often best to assert that the property has its expected value, rather
2398 * than asserting that it doesn't have one of many unexpected values.
2399 *
2400 * expect({a: 3}).to.have.property('a', 3); // Recommended
2401 * expect({a: 3}).to.not.have.property('a', 1); // Not recommended
2402 *
2403 * `.property` changes the target of any assertions that follow in the chain
2404 * to be the value of the property from the original target object.
2405 *
2406 * expect({a: 1}).to.have.property('a').that.is.a('number');
2407 *
2408 * `.property` accepts an optional `msg` argument which is a custom error
2409 * message to show when the assertion fails. The message can also be given as
2410 * the second argument to `expect`. When not providing `val`, only use the
2411 * second form.
2412 *
2413 * // Recommended
2414 * expect({a: 1}).to.have.property('a', 2, 'nooo why fail??');
2415 * expect({a: 1}, 'nooo why fail??').to.have.property('a', 2);
2416 * expect({a: 1}, 'nooo why fail??').to.have.property('b');
2417 *
2418 * // Not recommended
2419 * expect({a: 1}).to.have.property('b', undefined, 'nooo why fail??');
2420 *
2421 * The above assertion isn't the same thing as not providing `val`. Instead,
2422 * it's asserting that the target object has a `b` property that's equal to
2423 * `undefined`.
2424 *
2425 * The assertions `.ownProperty` and `.haveOwnProperty` can be used
2426 * interchangeably with `.own.property`.
2427 *
2428 * @name property
2429 * @param {String} name
2430 * @param {Mixed} val (optional)
2431 * @param {String} msg _optional_
2432 * @returns value of property for chaining
2433 * @namespace BDD
2434 * @api public
2435 */
2436
2437 function assertProperty (name, val, msg) {
2438 if (msg) flag(this, 'message', msg);
2439
2440 var isNested = flag(this, 'nested')
2441 , isOwn = flag(this, 'own')
2442 , flagMsg = flag(this, 'message')
2443 , obj = flag(this, 'object')
2444 , ssfi = flag(this, 'ssfi')
2445 , nameType = typeof name;
2446
2447 flagMsg = flagMsg ? flagMsg + ': ' : '';
2448
2449 if (isNested) {
2450 if (nameType !== 'string') {
2451 throw new AssertionError(
2452 flagMsg + 'the argument to property must be a string when using nested syntax',
2453 undefined,
2454 ssfi
2455 );
2456 }
2457 } else {
2458 if (nameType !== 'string' && nameType !== 'number' && nameType !== 'symbol') {
2459 throw new AssertionError(
2460 flagMsg + 'the argument to property must be a string, number, or symbol',
2461 undefined,
2462 ssfi
2463 );
2464 }
2465 }
2466
2467 if (isNested && isOwn) {
2468 throw new AssertionError(
2469 flagMsg + 'The "nested" and "own" flags cannot be combined.',
2470 undefined,
2471 ssfi
2472 );
2473 }
2474
2475 if (obj === null || obj === undefined) {
2476 throw new AssertionError(
2477 flagMsg + 'Target cannot be null or undefined.',
2478 undefined,
2479 ssfi
2480 );
2481 }
2482
2483 var isDeep = flag(this, 'deep')
2484 , negate = flag(this, 'negate')
2485 , pathInfo = isNested ? _.getPathInfo(obj, name) : null
2486 , value = isNested ? pathInfo.value : obj[name];
2487
2488 var descriptor = '';
2489 if (isDeep) descriptor += 'deep ';
2490 if (isOwn) descriptor += 'own ';
2491 if (isNested) descriptor += 'nested ';
2492 descriptor += 'property ';
2493
2494 var hasProperty;
2495 if (isOwn) hasProperty = Object.prototype.hasOwnProperty.call(obj, name);
2496 else if (isNested) hasProperty = pathInfo.exists;
2497 else hasProperty = _.hasProperty(obj, name);
2498
2499 // When performing a negated assertion for both name and val, merely having
2500 // a property with the given name isn't enough to cause the assertion to
2501 // fail. It must both have a property with the given name, and the value of
2502 // that property must equal the given val. Therefore, skip this assertion in
2503 // favor of the next.
2504 if (!negate || arguments.length === 1) {
2505 this.assert(
2506 hasProperty
2507 , 'expected #{this} to have ' + descriptor + _.inspect(name)
2508 , 'expected #{this} to not have ' + descriptor + _.inspect(name));
2509 }
2510
2511 if (arguments.length > 1) {
2512 this.assert(
2513 hasProperty && (isDeep ? _.eql(val, value) : val === value)
2514 , 'expected #{this} to have ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}'
2515 , 'expected #{this} to not have ' + descriptor + _.inspect(name) + ' of #{act}'
2516 , val
2517 , value
2518 );
2519 }
2520
2521 flag(this, 'object', value);
2522 }
2523
2524 Assertion.addMethod('property', assertProperty);
2525
2526 function assertOwnProperty (name, value, msg) {
2527 flag(this, 'own', true);
2528 assertProperty.apply(this, arguments);
2529 }
2530
2531 Assertion.addMethod('ownProperty', assertOwnProperty);
2532 Assertion.addMethod('haveOwnProperty', assertOwnProperty);
2533
2534 /**
2535 * ### .ownPropertyDescriptor(name[, descriptor[, msg]])
2536 *
2537 * Asserts that the target has its own property descriptor with the given key
2538 * `name`. Enumerable and non-enumerable properties are included in the
2539 * search.
2540 *
2541 * expect({a: 1}).to.have.ownPropertyDescriptor('a');
2542 *
2543 * When `descriptor` is provided, `.ownPropertyDescriptor` also asserts that
2544 * the property's descriptor is deeply equal to the given `descriptor`. See
2545 * the `deep-eql` project page for info on the deep equality algorithm:
2546 * https://github.com/chaijs/deep-eql.
2547 *
2548 * expect({a: 1}).to.have.ownPropertyDescriptor('a', {
2549 * configurable: true,
2550 * enumerable: true,
2551 * writable: true,
2552 * value: 1,
2553 * });
2554 *
2555 * Add `.not` earlier in the chain to negate `.ownPropertyDescriptor`.
2556 *
2557 * expect({a: 1}).to.not.have.ownPropertyDescriptor('b');
2558 *
2559 * However, it's dangerous to negate `.ownPropertyDescriptor` when providing
2560 * a `descriptor`. The problem is that it creates uncertain expectations by
2561 * asserting that the target either doesn't have a property descriptor with
2562 * the given key `name`, or that it does have a property descriptor with the
2563 * given key `name` but it’s not deeply equal to the given `descriptor`. It's
2564 * often best to identify the exact output that's expected, and then write an
2565 * assertion that only accepts that exact output.
2566 *
2567 * When the target isn't expected to have a property descriptor with the given
2568 * key `name`, it's often best to assert exactly that.
2569 *
2570 * // Recommended
2571 * expect({b: 2}).to.not.have.ownPropertyDescriptor('a');
2572 *
2573 * // Not recommended
2574 * expect({b: 2}).to.not.have.ownPropertyDescriptor('a', {
2575 * configurable: true,
2576 * enumerable: true,
2577 * writable: true,
2578 * value: 1,
2579 * });
2580 *
2581 * When the target is expected to have a property descriptor with the given
2582 * key `name`, it's often best to assert that the property has its expected
2583 * descriptor, rather than asserting that it doesn't have one of many
2584 * unexpected descriptors.
2585 *
2586 * // Recommended
2587 * expect({a: 3}).to.have.ownPropertyDescriptor('a', {
2588 * configurable: true,
2589 * enumerable: true,
2590 * writable: true,
2591 * value: 3,
2592 * });
2593 *
2594 * // Not recommended
2595 * expect({a: 3}).to.not.have.ownPropertyDescriptor('a', {
2596 * configurable: true,
2597 * enumerable: true,
2598 * writable: true,
2599 * value: 1,
2600 * });
2601 *
2602 * `.ownPropertyDescriptor` changes the target of any assertions that follow
2603 * in the chain to be the value of the property descriptor from the original
2604 * target object.
2605 *
2606 * expect({a: 1}).to.have.ownPropertyDescriptor('a')
2607 * .that.has.property('enumerable', true);
2608 *
2609 * `.ownPropertyDescriptor` accepts an optional `msg` argument which is a
2610 * custom error message to show when the assertion fails. The message can also
2611 * be given as the second argument to `expect`. When not providing
2612 * `descriptor`, only use the second form.
2613 *
2614 * // Recommended
2615 * expect({a: 1}).to.have.ownPropertyDescriptor('a', {
2616 * configurable: true,
2617 * enumerable: true,
2618 * writable: true,
2619 * value: 2,
2620 * }, 'nooo why fail??');
2621 *
2622 * // Recommended
2623 * expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('a', {
2624 * configurable: true,
2625 * enumerable: true,
2626 * writable: true,
2627 * value: 2,
2628 * });
2629 *
2630 * // Recommended
2631 * expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('b');
2632 *
2633 * // Not recommended
2634 * expect({a: 1})
2635 * .to.have.ownPropertyDescriptor('b', undefined, 'nooo why fail??');
2636 *
2637 * The above assertion isn't the same thing as not providing `descriptor`.
2638 * Instead, it's asserting that the target object has a `b` property
2639 * descriptor that's deeply equal to `undefined`.
2640 *
2641 * The alias `.haveOwnPropertyDescriptor` can be used interchangeably with
2642 * `.ownPropertyDescriptor`.
2643 *
2644 * @name ownPropertyDescriptor
2645 * @alias haveOwnPropertyDescriptor
2646 * @param {String} name
2647 * @param {Object} descriptor _optional_
2648 * @param {String} msg _optional_
2649 * @namespace BDD
2650 * @api public
2651 */
2652
2653 function assertOwnPropertyDescriptor (name, descriptor, msg) {
2654 if (typeof descriptor === 'string') {
2655 msg = descriptor;
2656 descriptor = null;
2657 }
2658 if (msg) flag(this, 'message', msg);
2659 var obj = flag(this, 'object');
2660 var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
2661 if (actualDescriptor && descriptor) {
2662 this.assert(
2663 _.eql(descriptor, actualDescriptor)
2664 , 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor)
2665 , 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor)
2666 , descriptor
2667 , actualDescriptor
2668 , true
2669 );
2670 } else {
2671 this.assert(
2672 actualDescriptor
2673 , 'expected #{this} to have an own property descriptor for ' + _.inspect(name)
2674 , 'expected #{this} to not have an own property descriptor for ' + _.inspect(name)
2675 );
2676 }
2677 flag(this, 'object', actualDescriptor);
2678 }
2679
2680 Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
2681 Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);
2682
2683 /**
2684 * ### .lengthOf(n[, msg])
2685 *
2686 * Asserts that the target's `length` or `size` is equal to the given number
2687 * `n`.
2688 *
2689 * expect([1, 2, 3]).to.have.lengthOf(3);
2690 * expect('foo').to.have.lengthOf(3);
2691 * expect(new Set([1, 2, 3])).to.have.lengthOf(3);
2692 * expect(new Map([['a', 1], ['b', 2], ['c', 3]])).to.have.lengthOf(3);
2693 *
2694 * Add `.not` earlier in the chain to negate `.lengthOf`. However, it's often
2695 * best to assert that the target's `length` property is equal to its expected
2696 * value, rather than not equal to one of many unexpected values.
2697 *
2698 * expect('foo').to.have.lengthOf(3); // Recommended
2699 * expect('foo').to.not.have.lengthOf(4); // Not recommended
2700 *
2701 * `.lengthOf` accepts an optional `msg` argument which is a custom error
2702 * message to show when the assertion fails. The message can also be given as
2703 * the second argument to `expect`.
2704 *
2705 * expect([1, 2, 3]).to.have.lengthOf(2, 'nooo why fail??');
2706 * expect([1, 2, 3], 'nooo why fail??').to.have.lengthOf(2);
2707 *
2708 * `.lengthOf` can also be used as a language chain, causing all `.above`,
2709 * `.below`, `.least`, `.most`, and `.within` assertions that follow in the
2710 * chain to use the target's `length` property as the target. However, it's
2711 * often best to assert that the target's `length` property is equal to its
2712 * expected length, rather than asserting that its `length` property falls
2713 * within some range of values.
2714 *
2715 * // Recommended
2716 * expect([1, 2, 3]).to.have.lengthOf(3);
2717 *
2718 * // Not recommended
2719 * expect([1, 2, 3]).to.have.lengthOf.above(2);
2720 * expect([1, 2, 3]).to.have.lengthOf.below(4);
2721 * expect([1, 2, 3]).to.have.lengthOf.at.least(3);
2722 * expect([1, 2, 3]).to.have.lengthOf.at.most(3);
2723 * expect([1, 2, 3]).to.have.lengthOf.within(2,4);
2724 *
2725 * Due to a compatibility issue, the alias `.length` can't be chained directly
2726 * off of an uninvoked method such as `.a`. Therefore, `.length` can't be used
2727 * interchangeably with `.lengthOf` in every situation. It's recommended to
2728 * always use `.lengthOf` instead of `.length`.
2729 *
2730 * expect([1, 2, 3]).to.have.a.length(3); // incompatible; throws error
2731 * expect([1, 2, 3]).to.have.a.lengthOf(3); // passes as expected
2732 *
2733 * @name lengthOf
2734 * @alias length
2735 * @param {Number} n
2736 * @param {String} msg _optional_
2737 * @namespace BDD
2738 * @api public
2739 */
2740
2741 function assertLengthChain () {
2742 flag(this, 'doLength', true);
2743 }
2744
2745 function assertLength (n, msg) {
2746 if (msg) flag(this, 'message', msg);
2747 var obj = flag(this, 'object')
2748 , objType = _.type(obj).toLowerCase()
2749 , flagMsg = flag(this, 'message')
2750 , ssfi = flag(this, 'ssfi')
2751 , descriptor = 'length'
2752 , itemsCount;
2753
2754 switch (objType) {
2755 case 'map':
2756 case 'set':
2757 descriptor = 'size';
2758 itemsCount = obj.size;
2759 break;
2760 default:
2761 new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
2762 itemsCount = obj.length;
2763 }
2764
2765 this.assert(
2766 itemsCount == n
2767 , 'expected #{this} to have a ' + descriptor + ' of #{exp} but got #{act}'
2768 , 'expected #{this} to not have a ' + descriptor + ' of #{act}'
2769 , n
2770 , itemsCount
2771 );
2772 }
2773
2774 Assertion.addChainableMethod('length', assertLength, assertLengthChain);
2775 Assertion.addChainableMethod('lengthOf', assertLength, assertLengthChain);
2776
2777 /**
2778 * ### .match(re[, msg])
2779 *
2780 * Asserts that the target matches the given regular expression `re`.
2781 *
2782 * expect('foobar').to.match(/^foo/);
2783 *
2784 * Add `.not` earlier in the chain to negate `.match`.
2785 *
2786 * expect('foobar').to.not.match(/taco/);
2787 *
2788 * `.match` accepts an optional `msg` argument which is a custom error message
2789 * to show when the assertion fails. The message can also be given as the
2790 * second argument to `expect`.
2791 *
2792 * expect('foobar').to.match(/taco/, 'nooo why fail??');
2793 * expect('foobar', 'nooo why fail??').to.match(/taco/);
2794 *
2795 * The alias `.matches` can be used interchangeably with `.match`.
2796 *
2797 * @name match
2798 * @alias matches
2799 * @param {RegExp} re
2800 * @param {String} msg _optional_
2801 * @namespace BDD
2802 * @api public
2803 */
2804 function assertMatch(re, msg) {
2805 if (msg) flag(this, 'message', msg);
2806 var obj = flag(this, 'object');
2807 this.assert(
2808 re.exec(obj)
2809 , 'expected #{this} to match ' + re
2810 , 'expected #{this} not to match ' + re
2811 );
2812 }
2813
2814 Assertion.addMethod('match', assertMatch);
2815 Assertion.addMethod('matches', assertMatch);
2816
2817 /**
2818 * ### .string(str[, msg])
2819 *
2820 * Asserts that the target string contains the given substring `str`.
2821 *
2822 * expect('foobar').to.have.string('bar');
2823 *
2824 * Add `.not` earlier in the chain to negate `.string`.
2825 *
2826 * expect('foobar').to.not.have.string('taco');
2827 *
2828 * `.string` accepts an optional `msg` argument which is a custom error
2829 * message to show when the assertion fails. The message can also be given as
2830 * the second argument to `expect`.
2831 *
2832 * expect('foobar').to.have.string('taco', 'nooo why fail??');
2833 * expect('foobar', 'nooo why fail??').to.have.string('taco');
2834 *
2835 * @name string
2836 * @param {String} str
2837 * @param {String} msg _optional_
2838 * @namespace BDD
2839 * @api public
2840 */
2841
2842 Assertion.addMethod('string', function (str, msg) {
2843 if (msg) flag(this, 'message', msg);
2844 var obj = flag(this, 'object')
2845 , flagMsg = flag(this, 'message')
2846 , ssfi = flag(this, 'ssfi');
2847 new Assertion(obj, flagMsg, ssfi, true).is.a('string');
2848
2849 this.assert(
2850 ~obj.indexOf(str)
2851 , 'expected #{this} to contain ' + _.inspect(str)
2852 , 'expected #{this} to not contain ' + _.inspect(str)
2853 );
2854 });
2855
2856 /**
2857 * ### .keys(key1[, key2[, ...]])
2858 *
2859 * Asserts that the target object, array, map, or set has the given keys. Only
2860 * the target's own inherited properties are included in the search.
2861 *
2862 * When the target is an object or array, keys can be provided as one or more
2863 * string arguments, a single array argument, or a single object argument. In
2864 * the latter case, only the keys in the given object matter; the values are
2865 * ignored.
2866 *
2867 * expect({a: 1, b: 2}).to.have.all.keys('a', 'b');
2868 * expect(['x', 'y']).to.have.all.keys(0, 1);
2869 *
2870 * expect({a: 1, b: 2}).to.have.all.keys(['a', 'b']);
2871 * expect(['x', 'y']).to.have.all.keys([0, 1]);
2872 *
2873 * expect({a: 1, b: 2}).to.have.all.keys({a: 4, b: 5}); // ignore 4 and 5
2874 * expect(['x', 'y']).to.have.all.keys({0: 4, 1: 5}); // ignore 4 and 5
2875 *
2876 * When the target is a map or set, each key must be provided as a separate
2877 * argument.
2878 *
2879 * expect(new Map([['a', 1], ['b', 2]])).to.have.all.keys('a', 'b');
2880 * expect(new Set(['a', 'b'])).to.have.all.keys('a', 'b');
2881 *
2882 * Because `.keys` does different things based on the target's type, it's
2883 * important to check the target's type before using `.keys`. See the `.a` doc
2884 * for info on testing a target's type.
2885 *
2886 * expect({a: 1, b: 2}).to.be.an('object').that.has.all.keys('a', 'b');
2887 *
2888 * By default, strict (`===`) equality is used to compare keys of maps and
2889 * sets. Add `.deep` earlier in the chain to use deep equality instead. See
2890 * the `deep-eql` project page for info on the deep equality algorithm:
2891 * https://github.com/chaijs/deep-eql.
2892 *
2893 * // Target set deeply (but not strictly) has key `{a: 1}`
2894 * expect(new Set([{a: 1}])).to.have.all.deep.keys([{a: 1}]);
2895 * expect(new Set([{a: 1}])).to.not.have.all.keys([{a: 1}]);
2896 *
2897 * By default, the target must have all of the given keys and no more. Add
2898 * `.any` earlier in the chain to only require that the target have at least
2899 * one of the given keys. Also, add `.not` earlier in the chain to negate
2900 * `.keys`. It's often best to add `.any` when negating `.keys`, and to use
2901 * `.all` when asserting `.keys` without negation.
2902 *
2903 * When negating `.keys`, `.any` is preferred because `.not.any.keys` asserts
2904 * exactly what's expected of the output, whereas `.not.all.keys` creates
2905 * uncertain expectations.
2906 *
2907 * // Recommended; asserts that target doesn't have any of the given keys
2908 * expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd');
2909 *
2910 * // Not recommended; asserts that target doesn't have all of the given
2911 * // keys but may or may not have some of them
2912 * expect({a: 1, b: 2}).to.not.have.all.keys('c', 'd');
2913 *
2914 * When asserting `.keys` without negation, `.all` is preferred because
2915 * `.all.keys` asserts exactly what's expected of the output, whereas
2916 * `.any.keys` creates uncertain expectations.
2917 *
2918 * // Recommended; asserts that target has all the given keys
2919 * expect({a: 1, b: 2}).to.have.all.keys('a', 'b');
2920 *
2921 * // Not recommended; asserts that target has at least one of the given
2922 * // keys but may or may not have more of them
2923 * expect({a: 1, b: 2}).to.have.any.keys('a', 'b');
2924 *
2925 * Note that `.all` is used by default when neither `.all` nor `.any` appear
2926 * earlier in the chain. However, it's often best to add `.all` anyway because
2927 * it improves readability.
2928 *
2929 * // Both assertions are identical
2930 * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); // Recommended
2931 * expect({a: 1, b: 2}).to.have.keys('a', 'b'); // Not recommended
2932 *
2933 * Add `.include` earlier in the chain to require that the target's keys be a
2934 * superset of the expected keys, rather than identical sets.
2935 *
2936 * // Target object's keys are a superset of ['a', 'b'] but not identical
2937 * expect({a: 1, b: 2, c: 3}).to.include.all.keys('a', 'b');
2938 * expect({a: 1, b: 2, c: 3}).to.not.have.all.keys('a', 'b');
2939 *
2940 * However, if `.any` and `.include` are combined, only the `.any` takes
2941 * effect. The `.include` is ignored in this case.
2942 *
2943 * // Both assertions are identical
2944 * expect({a: 1}).to.have.any.keys('a', 'b');
2945 * expect({a: 1}).to.include.any.keys('a', 'b');
2946 *
2947 * A custom error message can be given as the second argument to `expect`.
2948 *
2949 * expect({a: 1}, 'nooo why fail??').to.have.key('b');
2950 *
2951 * The alias `.key` can be used interchangeably with `.keys`.
2952 *
2953 * @name keys
2954 * @alias key
2955 * @param {...String|Array|Object} keys
2956 * @namespace BDD
2957 * @api public
2958 */
2959
2960 function assertKeys (keys) {
2961 var obj = flag(this, 'object')
2962 , objType = _.type(obj)
2963 , keysType = _.type(keys)
2964 , ssfi = flag(this, 'ssfi')
2965 , isDeep = flag(this, 'deep')
2966 , str
2967 , deepStr = ''
2968 , actual
2969 , ok = true
2970 , flagMsg = flag(this, 'message');
2971
2972 flagMsg = flagMsg ? flagMsg + ': ' : '';
2973 var mixedArgsMsg = flagMsg + 'when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments';
2974
2975 if (objType === 'Map' || objType === 'Set') {
2976 deepStr = isDeep ? 'deeply ' : '';
2977 actual = [];
2978
2979 // Map and Set '.keys' aren't supported in IE 11. Therefore, use .forEach.
2980 obj.forEach(function (val, key) { actual.push(key) });
2981
2982 if (keysType !== 'Array') {
2983 keys = Array.prototype.slice.call(arguments);
2984 }
2985 } else {
2986 actual = _.getOwnEnumerableProperties(obj);
2987
2988 switch (keysType) {
2989 case 'Array':
2990 if (arguments.length > 1) {
2991 throw new AssertionError(mixedArgsMsg, undefined, ssfi);
2992 }
2993 break;
2994 case 'Object':
2995 if (arguments.length > 1) {
2996 throw new AssertionError(mixedArgsMsg, undefined, ssfi);
2997 }
2998 keys = Object.keys(keys);
2999 break;
3000 default:
3001 keys = Array.prototype.slice.call(arguments);
3002 }
3003
3004 // Only stringify non-Symbols because Symbols would become "Symbol()"
3005 keys = keys.map(function (val) {
3006 return typeof val === 'symbol' ? val : String(val);
3007 });
3008 }
3009
3010 if (!keys.length) {
3011 throw new AssertionError(flagMsg + 'keys required', undefined, ssfi);
3012 }
3013
3014 var len = keys.length
3015 , any = flag(this, 'any')
3016 , all = flag(this, 'all')
3017 , expected = keys;
3018
3019 if (!any && !all) {
3020 all = true;
3021 }
3022
3023 // Has any
3024 if (any) {
3025 ok = expected.some(function(expectedKey) {
3026 return actual.some(function(actualKey) {
3027 if (isDeep) {
3028 return _.eql(expectedKey, actualKey);
3029 } else {
3030 return expectedKey === actualKey;
3031 }
3032 });
3033 });
3034 }
3035
3036 // Has all
3037 if (all) {
3038 ok = expected.every(function(expectedKey) {
3039 return actual.some(function(actualKey) {
3040 if (isDeep) {
3041 return _.eql(expectedKey, actualKey);
3042 } else {
3043 return expectedKey === actualKey;
3044 }
3045 });
3046 });
3047
3048 if (!flag(this, 'contains')) {
3049 ok = ok && keys.length == actual.length;
3050 }
3051 }
3052
3053 // Key string
3054 if (len > 1) {
3055 keys = keys.map(function(key) {
3056 return _.inspect(key);
3057 });
3058 var last = keys.pop();
3059 if (all) {
3060 str = keys.join(', ') + ', and ' + last;
3061 }
3062 if (any) {
3063 str = keys.join(', ') + ', or ' + last;
3064 }
3065 } else {
3066 str = _.inspect(keys[0]);
3067 }
3068
3069 // Form
3070 str = (len > 1 ? 'keys ' : 'key ') + str;
3071
3072 // Have / include
3073 str = (flag(this, 'contains') ? 'contain ' : 'have ') + str;
3074
3075 // Assertion
3076 this.assert(
3077 ok
3078 , 'expected #{this} to ' + deepStr + str
3079 , 'expected #{this} to not ' + deepStr + str
3080 , expected.slice(0).sort(_.compareByInspect)
3081 , actual.sort(_.compareByInspect)
3082 , true
3083 );
3084 }
3085
3086 Assertion.addMethod('keys', assertKeys);
3087 Assertion.addMethod('key', assertKeys);
3088
3089 /**
3090 * ### .throw([errorLike], [errMsgMatcher], [msg])
3091 *
3092 * When no arguments are provided, `.throw` invokes the target function and
3093 * asserts that an error is thrown.
3094 *
3095 * var badFn = function () { throw new TypeError('Illegal salmon!'); };
3096 *
3097 * expect(badFn).to.throw();
3098 *
3099 * When one argument is provided, and it's an error constructor, `.throw`
3100 * invokes the target function and asserts that an error is thrown that's an
3101 * instance of that error constructor.
3102 *
3103 * var badFn = function () { throw new TypeError('Illegal salmon!'); };
3104 *
3105 * expect(badFn).to.throw(TypeError);
3106 *
3107 * When one argument is provided, and it's an error instance, `.throw` invokes
3108 * the target function and asserts that an error is thrown that's strictly
3109 * (`===`) equal to that error instance.
3110 *
3111 * var err = new TypeError('Illegal salmon!');
3112 * var badFn = function () { throw err; };
3113 *
3114 * expect(badFn).to.throw(err);
3115 *
3116 * When one argument is provided, and it's a string, `.throw` invokes the
3117 * target function and asserts that an error is thrown with a message that
3118 * contains that string.
3119 *
3120 * var badFn = function () { throw new TypeError('Illegal salmon!'); };
3121 *
3122 * expect(badFn).to.throw('salmon');
3123 *
3124 * When one argument is provided, and it's a regular expression, `.throw`
3125 * invokes the target function and asserts that an error is thrown with a
3126 * message that matches that regular expression.
3127 *
3128 * var badFn = function () { throw new TypeError('Illegal salmon!'); };
3129 *
3130 * expect(badFn).to.throw(/salmon/);
3131 *
3132 * When two arguments are provided, and the first is an error instance or
3133 * constructor, and the second is a string or regular expression, `.throw`
3134 * invokes the function and asserts that an error is thrown that fulfills both
3135 * conditions as described above.
3136 *
3137 * var err = new TypeError('Illegal salmon!');
3138 * var badFn = function () { throw err; };
3139 *
3140 * expect(badFn).to.throw(TypeError, 'salmon');
3141 * expect(badFn).to.throw(TypeError, /salmon/);
3142 * expect(badFn).to.throw(err, 'salmon');
3143 * expect(badFn).to.throw(err, /salmon/);
3144 *
3145 * Add `.not` earlier in the chain to negate `.throw`.
3146 *
3147 * var goodFn = function () {};
3148 *
3149 * expect(goodFn).to.not.throw();
3150 *
3151 * However, it's dangerous to negate `.throw` when providing any arguments.
3152 * The problem is that it creates uncertain expectations by asserting that the
3153 * target either doesn't throw an error, or that it throws an error but of a
3154 * different type than the given type, or that it throws an error of the given
3155 * type but with a message that doesn't include the given string. It's often
3156 * best to identify the exact output that's expected, and then write an
3157 * assertion that only accepts that exact output.
3158 *
3159 * When the target isn't expected to throw an error, it's often best to assert
3160 * exactly that.
3161 *
3162 * var goodFn = function () {};
3163 *
3164 * expect(goodFn).to.not.throw(); // Recommended
3165 * expect(goodFn).to.not.throw(ReferenceError, 'x'); // Not recommended
3166 *
3167 * When the target is expected to throw an error, it's often best to assert
3168 * that the error is of its expected type, and has a message that includes an
3169 * expected string, rather than asserting that it doesn't have one of many
3170 * unexpected types, and doesn't have a message that includes some string.
3171 *
3172 * var badFn = function () { throw new TypeError('Illegal salmon!'); };
3173 *
3174 * expect(badFn).to.throw(TypeError, 'salmon'); // Recommended
3175 * expect(badFn).to.not.throw(ReferenceError, 'x'); // Not recommended
3176 *
3177 * `.throw` changes the target of any assertions that follow in the chain to
3178 * be the error object that's thrown.
3179 *
3180 * var err = new TypeError('Illegal salmon!');
3181 * err.code = 42;
3182 * var badFn = function () { throw err; };
3183 *
3184 * expect(badFn).to.throw(TypeError).with.property('code', 42);
3185 *
3186 * `.throw` accepts an optional `msg` argument which is a custom error message
3187 * to show when the assertion fails. The message can also be given as the
3188 * second argument to `expect`. When not providing two arguments, always use
3189 * the second form.
3190 *
3191 * var goodFn = function () {};
3192 *
3193 * expect(goodFn).to.throw(TypeError, 'x', 'nooo why fail??');
3194 * expect(goodFn, 'nooo why fail??').to.throw();
3195 *
3196 * Due to limitations in ES5, `.throw` may not always work as expected when
3197 * using a transpiler such as Babel or TypeScript. In particular, it may
3198 * produce unexpected results when subclassing the built-in `Error` object and
3199 * then passing the subclassed constructor to `.throw`. See your transpiler's
3200 * docs for details:
3201 *
3202 * - ([Babel](https://babeljs.io/docs/usage/caveats/#classes))
3203 * - ([TypeScript](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work))
3204 *
3205 * Beware of some common mistakes when using the `throw` assertion. One common
3206 * mistake is to accidentally invoke the function yourself instead of letting
3207 * the `throw` assertion invoke the function for you. For example, when
3208 * testing if a function named `fn` throws, provide `fn` instead of `fn()` as
3209 * the target for the assertion.
3210 *
3211 * expect(fn).to.throw(); // Good! Tests `fn` as desired
3212 * expect(fn()).to.throw(); // Bad! Tests result of `fn()`, not `fn`
3213 *
3214 * If you need to assert that your function `fn` throws when passed certain
3215 * arguments, then wrap a call to `fn` inside of another function.
3216 *
3217 * expect(function () { fn(42); }).to.throw(); // Function expression
3218 * expect(() => fn(42)).to.throw(); // ES6 arrow function
3219 *
3220 * Another common mistake is to provide an object method (or any stand-alone
3221 * function that relies on `this`) as the target of the assertion. Doing so is
3222 * problematic because the `this` context will be lost when the function is
3223 * invoked by `.throw`; there's no way for it to know what `this` is supposed
3224 * to be. There are two ways around this problem. One solution is to wrap the
3225 * method or function call inside of another function. Another solution is to
3226 * use `bind`.
3227 *
3228 * expect(function () { cat.meow(); }).to.throw(); // Function expression
3229 * expect(() => cat.meow()).to.throw(); // ES6 arrow function
3230 * expect(cat.meow.bind(cat)).to.throw(); // Bind
3231 *
3232 * Finally, it's worth mentioning that it's a best practice in JavaScript to
3233 * only throw `Error` and derivatives of `Error` such as `ReferenceError`,
3234 * `TypeError`, and user-defined objects that extend `Error`. No other type of
3235 * value will generate a stack trace when initialized. With that said, the
3236 * `throw` assertion does technically support any type of value being thrown,
3237 * not just `Error` and its derivatives.
3238 *
3239 * The aliases `.throws` and `.Throw` can be used interchangeably with
3240 * `.throw`.
3241 *
3242 * @name throw
3243 * @alias throws
3244 * @alias Throw
3245 * @param {Error|ErrorConstructor} errorLike
3246 * @param {String|RegExp} errMsgMatcher error message
3247 * @param {String} msg _optional_
3248 * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
3249 * @returns error for chaining (null if no error)
3250 * @namespace BDD
3251 * @api public
3252 */
3253
3254 function assertThrows (errorLike, errMsgMatcher, msg) {
3255 if (msg) flag(this, 'message', msg);
3256 var obj = flag(this, 'object')
3257 , ssfi = flag(this, 'ssfi')
3258 , flagMsg = flag(this, 'message')
3259 , negate = flag(this, 'negate') || false;
3260 new Assertion(obj, flagMsg, ssfi, true).is.a('function');
3261
3262 if (errorLike instanceof RegExp || typeof errorLike === 'string') {
3263 errMsgMatcher = errorLike;
3264 errorLike = null;
3265 }
3266
3267 var caughtErr;
3268 try {
3269 obj();
3270 } catch (err) {
3271 caughtErr = err;
3272 }
3273
3274 // If we have the negate flag enabled and at least one valid argument it means we do expect an error
3275 // but we want it to match a given set of criteria
3276 var everyArgIsUndefined = errorLike === undefined && errMsgMatcher === undefined;
3277
3278 // If we've got the negate flag enabled and both args, we should only fail if both aren't compatible
3279 // See Issue #551 and PR #683@GitHub
3280 var everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
3281 var errorLikeFail = false;
3282 var errMsgMatcherFail = false;
3283
3284 // Checking if error was thrown
3285 if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
3286 // We need this to display results correctly according to their types
3287 var errorLikeString = 'an error';
3288 if (errorLike instanceof Error) {
3289 errorLikeString = '#{exp}';
3290 } else if (errorLike) {
3291 errorLikeString = _.checkError.getConstructorName(errorLike);
3292 }
3293
3294 this.assert(
3295 caughtErr
3296 , 'expected #{this} to throw ' + errorLikeString
3297 , 'expected #{this} to not throw an error but #{act} was thrown'
3298 , errorLike && errorLike.toString()
3299 , (caughtErr instanceof Error ?
3300 caughtErr.toString() : (typeof caughtErr === 'string' ? caughtErr : caughtErr &&
3301 _.checkError.getConstructorName(caughtErr)))
3302 );
3303 }
3304
3305 if (errorLike && caughtErr) {
3306 // We should compare instances only if `errorLike` is an instance of `Error`
3307 if (errorLike instanceof Error) {
3308 var isCompatibleInstance = _.checkError.compatibleInstance(caughtErr, errorLike);
3309
3310 if (isCompatibleInstance === negate) {
3311 // These checks were created to ensure we won't fail too soon when we've got both args and a negate
3312 // See Issue #551 and PR #683@GitHub
3313 if (everyArgIsDefined && negate) {
3314 errorLikeFail = true;
3315 } else {
3316 this.assert(
3317 negate
3318 , 'expected #{this} to throw #{exp} but #{act} was thrown'
3319 , 'expected #{this} to not throw #{exp}' + (caughtErr && !negate ? ' but #{act} was thrown' : '')
3320 , errorLike.toString()
3321 , caughtErr.toString()
3322 );
3323 }
3324 }
3325 }
3326
3327 var isCompatibleConstructor = _.checkError.compatibleConstructor(caughtErr, errorLike);
3328 if (isCompatibleConstructor === negate) {
3329 if (everyArgIsDefined && negate) {
3330 errorLikeFail = true;
3331 } else {
3332 this.assert(
3333 negate
3334 , 'expected #{this} to throw #{exp} but #{act} was thrown'
3335 , 'expected #{this} to not throw #{exp}' + (caughtErr ? ' but #{act} was thrown' : '')
3336 , (errorLike instanceof Error ? errorLike.toString() : errorLike && _.checkError.getConstructorName(errorLike))
3337 , (caughtErr instanceof Error ? caughtErr.toString() : caughtErr && _.checkError.getConstructorName(caughtErr))
3338 );
3339 }
3340 }
3341 }
3342
3343 if (caughtErr && errMsgMatcher !== undefined && errMsgMatcher !== null) {
3344 // Here we check compatible messages
3345 var placeholder = 'including';
3346 if (errMsgMatcher instanceof RegExp) {
3347 placeholder = 'matching'
3348 }
3349
3350 var isCompatibleMessage = _.checkError.compatibleMessage(caughtErr, errMsgMatcher);
3351 if (isCompatibleMessage === negate) {
3352 if (everyArgIsDefined && negate) {
3353 errMsgMatcherFail = true;
3354 } else {
3355 this.assert(
3356 negate
3357 , 'expected #{this} to throw error ' + placeholder + ' #{exp} but got #{act}'
3358 , 'expected #{this} to throw error not ' + placeholder + ' #{exp}'
3359 , errMsgMatcher
3360 , _.checkError.getMessage(caughtErr)
3361 );
3362 }
3363 }
3364 }
3365
3366 // If both assertions failed and both should've matched we throw an error
3367 if (errorLikeFail && errMsgMatcherFail) {
3368 this.assert(
3369 negate
3370 , 'expected #{this} to throw #{exp} but #{act} was thrown'
3371 , 'expected #{this} to not throw #{exp}' + (caughtErr ? ' but #{act} was thrown' : '')
3372 , (errorLike instanceof Error ? errorLike.toString() : errorLike && _.checkError.getConstructorName(errorLike))
3373 , (caughtErr instanceof Error ? caughtErr.toString() : caughtErr && _.checkError.getConstructorName(caughtErr))
3374 );
3375 }
3376
3377 flag(this, 'object', caughtErr);
3378 };
3379
3380 Assertion.addMethod('throw', assertThrows);
3381 Assertion.addMethod('throws', assertThrows);
3382 Assertion.addMethod('Throw', assertThrows);
3383
3384 /**
3385 * ### .respondTo(method[, msg])
3386 *
3387 * When the target is a non-function object, `.respondTo` asserts that the
3388 * target has a method with the given name `method`. The method can be own or
3389 * inherited, and it can be enumerable or non-enumerable.
3390 *
3391 * function Cat () {}
3392 * Cat.prototype.meow = function () {};
3393 *
3394 * expect(new Cat()).to.respondTo('meow');
3395 *
3396 * When the target is a function, `.respondTo` asserts that the target's
3397 * `prototype` property has a method with the given name `method`. Again, the
3398 * method can be own or inherited, and it can be enumerable or non-enumerable.
3399 *
3400 * function Cat () {}
3401 * Cat.prototype.meow = function () {};
3402 *
3403 * expect(Cat).to.respondTo('meow');
3404 *
3405 * Add `.itself` earlier in the chain to force `.respondTo` to treat the
3406 * target as a non-function object, even if it's a function. Thus, it asserts
3407 * that the target has a method with the given name `method`, rather than
3408 * asserting that the target's `prototype` property has a method with the
3409 * given name `method`.
3410 *
3411 * function Cat () {}
3412 * Cat.prototype.meow = function () {};
3413 * Cat.hiss = function () {};
3414 *
3415 * expect(Cat).itself.to.respondTo('hiss').but.not.respondTo('meow');
3416 *
3417 * When not adding `.itself`, it's important to check the target's type before
3418 * using `.respondTo`. See the `.a` doc for info on checking a target's type.
3419 *
3420 * function Cat () {}
3421 * Cat.prototype.meow = function () {};
3422 *
3423 * expect(new Cat()).to.be.an('object').that.respondsTo('meow');
3424 *
3425 * Add `.not` earlier in the chain to negate `.respondTo`.
3426 *
3427 * function Dog () {}
3428 * Dog.prototype.bark = function () {};
3429 *
3430 * expect(new Dog()).to.not.respondTo('meow');
3431 *
3432 * `.respondTo` accepts an optional `msg` argument which is a custom error
3433 * message to show when the assertion fails. The message can also be given as
3434 * the second argument to `expect`.
3435 *
3436 * expect({}).to.respondTo('meow', 'nooo why fail??');
3437 * expect({}, 'nooo why fail??').to.respondTo('meow');
3438 *
3439 * The alias `.respondsTo` can be used interchangeably with `.respondTo`.
3440 *
3441 * @name respondTo
3442 * @alias respondsTo
3443 * @param {String} method
3444 * @param {String} msg _optional_
3445 * @namespace BDD
3446 * @api public
3447 */
3448
3449 function respondTo (method, msg) {
3450 if (msg) flag(this, 'message', msg);
3451 var obj = flag(this, 'object')
3452 , itself = flag(this, 'itself')
3453 , context = ('function' === typeof obj && !itself)
3454 ? obj.prototype[method]
3455 : obj[method];
3456
3457 this.assert(
3458 'function' === typeof context
3459 , 'expected #{this} to respond to ' + _.inspect(method)
3460 , 'expected #{this} to not respond to ' + _.inspect(method)
3461 );
3462 }
3463
3464 Assertion.addMethod('respondTo', respondTo);
3465 Assertion.addMethod('respondsTo', respondTo);
3466
3467 /**
3468 * ### .itself
3469 *
3470 * Forces all `.respondTo` assertions that follow in the chain to behave as if
3471 * the target is a non-function object, even if it's a function. Thus, it
3472 * causes `.respondTo` to assert that the target has a method with the given
3473 * name, rather than asserting that the target's `prototype` property has a
3474 * method with the given name.
3475 *
3476 * function Cat () {}
3477 * Cat.prototype.meow = function () {};
3478 * Cat.hiss = function () {};
3479 *
3480 * expect(Cat).itself.to.respondTo('hiss').but.not.respondTo('meow');
3481 *
3482 * @name itself
3483 * @namespace BDD
3484 * @api public
3485 */
3486
3487 Assertion.addProperty('itself', function () {
3488 flag(this, 'itself', true);
3489 });
3490
3491 /**
3492 * ### .satisfy(matcher[, msg])
3493 *
3494 * Invokes the given `matcher` function with the target being passed as the
3495 * first argument, and asserts that the value returned is truthy.
3496 *
3497 * expect(1).to.satisfy(function(num) {
3498 * return num > 0;
3499 * });
3500 *
3501 * Add `.not` earlier in the chain to negate `.satisfy`.
3502 *
3503 * expect(1).to.not.satisfy(function(num) {
3504 * return num > 2;
3505 * });
3506 *
3507 * `.satisfy` accepts an optional `msg` argument which is a custom error
3508 * message to show when the assertion fails. The message can also be given as
3509 * the second argument to `expect`.
3510 *
3511 * expect(1).to.satisfy(function(num) {
3512 * return num > 2;
3513 * }, 'nooo why fail??');
3514 *
3515 * expect(1, 'nooo why fail??').to.satisfy(function(num) {
3516 * return num > 2;
3517 * });
3518 *
3519 * The alias `.satisfies` can be used interchangeably with `.satisfy`.
3520 *
3521 * @name satisfy
3522 * @alias satisfies
3523 * @param {Function} matcher
3524 * @param {String} msg _optional_
3525 * @namespace BDD
3526 * @api public
3527 */
3528
3529 function satisfy (matcher, msg) {
3530 if (msg) flag(this, 'message', msg);
3531 var obj = flag(this, 'object');
3532 var result = matcher(obj);
3533 this.assert(
3534 result
3535 , 'expected #{this} to satisfy ' + _.objDisplay(matcher)
3536 , 'expected #{this} to not satisfy' + _.objDisplay(matcher)
3537 , flag(this, 'negate') ? false : true
3538 , result
3539 );
3540 }
3541
3542 Assertion.addMethod('satisfy', satisfy);
3543 Assertion.addMethod('satisfies', satisfy);
3544
3545 /**
3546 * ### .closeTo(expected, delta[, msg])
3547 *
3548 * Asserts that the target is a number that's within a given +/- `delta` range
3549 * of the given number `expected`. However, it's often best to assert that the
3550 * target is equal to its expected value.
3551 *
3552 * // Recommended
3553 * expect(1.5).to.equal(1.5);
3554 *
3555 * // Not recommended
3556 * expect(1.5).to.be.closeTo(1, 0.5);
3557 * expect(1.5).to.be.closeTo(2, 0.5);
3558 * expect(1.5).to.be.closeTo(1, 1);
3559 *
3560 * Add `.not` earlier in the chain to negate `.closeTo`.
3561 *
3562 * expect(1.5).to.equal(1.5); // Recommended
3563 * expect(1.5).to.not.be.closeTo(3, 1); // Not recommended
3564 *
3565 * `.closeTo` accepts an optional `msg` argument which is a custom error
3566 * message to show when the assertion fails. The message can also be given as
3567 * the second argument to `expect`.
3568 *
3569 * expect(1.5).to.be.closeTo(3, 1, 'nooo why fail??');
3570 * expect(1.5, 'nooo why fail??').to.be.closeTo(3, 1);
3571 *
3572 * The alias `.approximately` can be used interchangeably with `.closeTo`.
3573 *
3574 * @name closeTo
3575 * @alias approximately
3576 * @param {Number} expected
3577 * @param {Number} delta
3578 * @param {String} msg _optional_
3579 * @namespace BDD
3580 * @api public
3581 */
3582
3583 function closeTo(expected, delta, msg) {
3584 if (msg) flag(this, 'message', msg);
3585 var obj = flag(this, 'object')
3586 , flagMsg = flag(this, 'message')
3587 , ssfi = flag(this, 'ssfi');
3588
3589 new Assertion(obj, flagMsg, ssfi, true).is.a('number');
3590 if (typeof expected !== 'number' || typeof delta !== 'number') {
3591 flagMsg = flagMsg ? flagMsg + ': ' : '';
3592 var deltaMessage = delta === undefined ? ", and a delta is required" : "";
3593 throw new AssertionError(
3594 flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
3595 undefined,
3596 ssfi
3597 );
3598 }
3599
3600 this.assert(
3601 Math.abs(obj - expected) <= delta
3602 , 'expected #{this} to be close to ' + expected + ' +/- ' + delta
3603 , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta
3604 );
3605 }
3606
3607 Assertion.addMethod('closeTo', closeTo);
3608 Assertion.addMethod('approximately', closeTo);
3609
3610 // Note: Duplicates are ignored if testing for inclusion instead of sameness.
3611 function isSubsetOf(subset, superset, cmp, contains, ordered) {
3612 if (!contains) {
3613 if (subset.length !== superset.length) return false;
3614 superset = superset.slice();
3615 }
3616
3617 return subset.every(function(elem, idx) {
3618 if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
3619
3620 if (!cmp) {
3621 var matchIdx = superset.indexOf(elem);
3622 if (matchIdx === -1) return false;
3623
3624 // Remove match from superset so not counted twice if duplicate in subset.
3625 if (!contains) superset.splice(matchIdx, 1);
3626 return true;
3627 }
3628
3629 return superset.some(function(elem2, matchIdx) {
3630 if (!cmp(elem, elem2)) return false;
3631
3632 // Remove match from superset so not counted twice if duplicate in subset.
3633 if (!contains) superset.splice(matchIdx, 1);
3634 return true;
3635 });
3636 });
3637 }
3638
3639 /**
3640 * ### .members(set[, msg])
3641 *
3642 * Asserts that the target array has the same members as the given array
3643 * `set`.
3644 *
3645 * expect([1, 2, 3]).to.have.members([2, 1, 3]);
3646 * expect([1, 2, 2]).to.have.members([2, 1, 2]);
3647 *
3648 * By default, members are compared using strict (`===`) equality. Add `.deep`
3649 * earlier in the chain to use deep equality instead. See the `deep-eql`
3650 * project page for info on the deep equality algorithm:
3651 * https://github.com/chaijs/deep-eql.
3652 *
3653 * // Target array deeply (but not strictly) has member `{a: 1}`
3654 * expect([{a: 1}]).to.have.deep.members([{a: 1}]);
3655 * expect([{a: 1}]).to.not.have.members([{a: 1}]);
3656 *
3657 * By default, order doesn't matter. Add `.ordered` earlier in the chain to
3658 * require that members appear in the same order.
3659 *
3660 * expect([1, 2, 3]).to.have.ordered.members([1, 2, 3]);
3661 * expect([1, 2, 3]).to.have.members([2, 1, 3])
3662 * .but.not.ordered.members([2, 1, 3]);
3663 *
3664 * By default, both arrays must be the same size. Add `.include` earlier in
3665 * the chain to require that the target's members be a superset of the
3666 * expected members. Note that duplicates are ignored in the subset when
3667 * `.include` is added.
3668 *
3669 * // Target array is a superset of [1, 2] but not identical
3670 * expect([1, 2, 3]).to.include.members([1, 2]);
3671 * expect([1, 2, 3]).to.not.have.members([1, 2]);
3672 *
3673 * // Duplicates in the subset are ignored
3674 * expect([1, 2, 3]).to.include.members([1, 2, 2, 2]);
3675 *
3676 * `.deep`, `.ordered`, and `.include` can all be combined. However, if
3677 * `.include` and `.ordered` are combined, the ordering begins at the start of
3678 * both arrays.
3679 *
3680 * expect([{a: 1}, {b: 2}, {c: 3}])
3681 * .to.include.deep.ordered.members([{a: 1}, {b: 2}])
3682 * .but.not.include.deep.ordered.members([{b: 2}, {c: 3}]);
3683 *
3684 * Add `.not` earlier in the chain to negate `.members`. However, it's
3685 * dangerous to do so. The problem is that it creates uncertain expectations
3686 * by asserting that the target array doesn't have all of the same members as
3687 * the given array `set` but may or may not have some of them. It's often best
3688 * to identify the exact output that's expected, and then write an assertion
3689 * that only accepts that exact output.
3690 *
3691 * expect([1, 2]).to.not.include(3).and.not.include(4); // Recommended
3692 * expect([1, 2]).to.not.have.members([3, 4]); // Not recommended
3693 *
3694 * `.members` accepts an optional `msg` argument which is a custom error
3695 * message to show when the assertion fails. The message can also be given as
3696 * the second argument to `expect`.
3697 *
3698 * expect([1, 2]).to.have.members([1, 2, 3], 'nooo why fail??');
3699 * expect([1, 2], 'nooo why fail??').to.have.members([1, 2, 3]);
3700 *
3701 * @name members
3702 * @param {Array} set
3703 * @param {String} msg _optional_
3704 * @namespace BDD
3705 * @api public
3706 */
3707
3708 Assertion.addMethod('members', function (subset, msg) {
3709 if (msg) flag(this, 'message', msg);
3710 var obj = flag(this, 'object')
3711 , flagMsg = flag(this, 'message')
3712 , ssfi = flag(this, 'ssfi');
3713
3714 new Assertion(obj, flagMsg, ssfi, true).to.be.an('array');
3715 new Assertion(subset, flagMsg, ssfi, true).to.be.an('array');
3716
3717 var contains = flag(this, 'contains');
3718 var ordered = flag(this, 'ordered');
3719
3720 var subject, failMsg, failNegateMsg;
3721
3722 if (contains) {
3723 subject = ordered ? 'an ordered superset' : 'a superset';
3724 failMsg = 'expected #{this} to be ' + subject + ' of #{exp}';
3725 failNegateMsg = 'expected #{this} to not be ' + subject + ' of #{exp}';
3726 } else {
3727 subject = ordered ? 'ordered members' : 'members';
3728 failMsg = 'expected #{this} to have the same ' + subject + ' as #{exp}';
3729 failNegateMsg = 'expected #{this} to not have the same ' + subject + ' as #{exp}';
3730 }
3731
3732 var cmp = flag(this, 'deep') ? _.eql : undefined;
3733
3734 this.assert(
3735 isSubsetOf(subset, obj, cmp, contains, ordered)
3736 , failMsg
3737 , failNegateMsg
3738 , subset
3739 , obj
3740 , true
3741 );
3742 });
3743
3744 /**
3745 * ### .oneOf(list[, msg])
3746 *
3747 * Asserts that the target is a member of the given array `list`. However,
3748 * it's often best to assert that the target is equal to its expected value.
3749 *
3750 * expect(1).to.equal(1); // Recommended
3751 * expect(1).to.be.oneOf([1, 2, 3]); // Not recommended
3752 *
3753 * Comparisons are performed using strict (`===`) equality.
3754 *
3755 * Add `.not` earlier in the chain to negate `.oneOf`.
3756 *
3757 * expect(1).to.equal(1); // Recommended
3758 * expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
3759 *
3760 * It can also be chained with `.contain` or `.include`, which will work with
3761 * both arrays and strings:
3762 *
3763 * expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
3764 * expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
3765 * expect([1,2,3]).to.contain.oneOf([3,4,5])
3766 * expect([1,2,3]).to.not.contain.oneOf([4,5,6])
3767 *
3768 * `.oneOf` accepts an optional `msg` argument which is a custom error message
3769 * to show when the assertion fails. The message can also be given as the
3770 * second argument to `expect`.
3771 *
3772 * expect(1).to.be.oneOf([2, 3, 4], 'nooo why fail??');
3773 * expect(1, 'nooo why fail??').to.be.oneOf([2, 3, 4]);
3774 *
3775 * @name oneOf
3776 * @param {Array<*>} list
3777 * @param {String} msg _optional_
3778 * @namespace BDD
3779 * @api public
3780 */
3781
3782 function oneOf (list, msg) {
3783 if (msg) flag(this, 'message', msg);
3784 var expected = flag(this, 'object')
3785 , flagMsg = flag(this, 'message')
3786 , ssfi = flag(this, 'ssfi')
3787 , contains = flag(this, 'contains')
3788 , isDeep = flag(this, 'deep');
3789 new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
3790
3791 if (contains) {
3792 this.assert(
3793 list.some(function(possibility) { return expected.indexOf(possibility) > -1 })
3794 , 'expected #{this} to contain one of #{exp}'
3795 , 'expected #{this} to not contain one of #{exp}'
3796 , list
3797 , expected
3798 );
3799 } else {
3800 if (isDeep) {
3801 this.assert(
3802 list.some(function(possibility) { return _.eql(expected, possibility) })
3803 , 'expected #{this} to deeply equal one of #{exp}'
3804 , 'expected #{this} to deeply equal one of #{exp}'
3805 , list
3806 , expected
3807 );
3808 } else {
3809 this.assert(
3810 list.indexOf(expected) > -1
3811 , 'expected #{this} to be one of #{exp}'
3812 , 'expected #{this} to not be one of #{exp}'
3813 , list
3814 , expected
3815 );
3816 }
3817 }
3818 }
3819
3820 Assertion.addMethod('oneOf', oneOf);
3821
3822 /**
3823 * ### .change(subject[, prop[, msg]])
3824 *
3825 * When one argument is provided, `.change` asserts that the given function
3826 * `subject` returns a different value when it's invoked before the target
3827 * function compared to when it's invoked afterward. However, it's often best
3828 * to assert that `subject` is equal to its expected value.
3829 *
3830 * var dots = ''
3831 * , addDot = function () { dots += '.'; }
3832 * , getDots = function () { return dots; };
3833 *
3834 * // Recommended
3835 * expect(getDots()).to.equal('');
3836 * addDot();
3837 * expect(getDots()).to.equal('.');
3838 *
3839 * // Not recommended
3840 * expect(addDot).to.change(getDots);
3841 *
3842 * When two arguments are provided, `.change` asserts that the value of the
3843 * given object `subject`'s `prop` property is different before invoking the
3844 * target function compared to afterward.
3845 *
3846 * var myObj = {dots: ''}
3847 * , addDot = function () { myObj.dots += '.'; };
3848 *
3849 * // Recommended
3850 * expect(myObj).to.have.property('dots', '');
3851 * addDot();
3852 * expect(myObj).to.have.property('dots', '.');
3853 *
3854 * // Not recommended
3855 * expect(addDot).to.change(myObj, 'dots');
3856 *
3857 * Strict (`===`) equality is used to compare before and after values.
3858 *
3859 * Add `.not` earlier in the chain to negate `.change`.
3860 *
3861 * var dots = ''
3862 * , noop = function () {}
3863 * , getDots = function () { return dots; };
3864 *
3865 * expect(noop).to.not.change(getDots);
3866 *
3867 * var myObj = {dots: ''}
3868 * , noop = function () {};
3869 *
3870 * expect(noop).to.not.change(myObj, 'dots');
3871 *
3872 * `.change` accepts an optional `msg` argument which is a custom error
3873 * message to show when the assertion fails. The message can also be given as
3874 * the second argument to `expect`. When not providing two arguments, always
3875 * use the second form.
3876 *
3877 * var myObj = {dots: ''}
3878 * , addDot = function () { myObj.dots += '.'; };
3879 *
3880 * expect(addDot).to.not.change(myObj, 'dots', 'nooo why fail??');
3881 *
3882 * var dots = ''
3883 * , addDot = function () { dots += '.'; }
3884 * , getDots = function () { return dots; };
3885 *
3886 * expect(addDot, 'nooo why fail??').to.not.change(getDots);
3887 *
3888 * `.change` also causes all `.by` assertions that follow in the chain to
3889 * assert how much a numeric subject was increased or decreased by. However,
3890 * it's dangerous to use `.change.by`. The problem is that it creates
3891 * uncertain expectations by asserting that the subject either increases by
3892 * the given delta, or that it decreases by the given delta. It's often best
3893 * to identify the exact output that's expected, and then write an assertion
3894 * that only accepts that exact output.
3895 *
3896 * var myObj = {val: 1}
3897 * , addTwo = function () { myObj.val += 2; }
3898 * , subtractTwo = function () { myObj.val -= 2; };
3899 *
3900 * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended
3901 * expect(addTwo).to.change(myObj, 'val').by(2); // Not recommended
3902 *
3903 * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended
3904 * expect(subtractTwo).to.change(myObj, 'val').by(2); // Not recommended
3905 *
3906 * The alias `.changes` can be used interchangeably with `.change`.
3907 *
3908 * @name change
3909 * @alias changes
3910 * @param {String} subject
3911 * @param {String} prop name _optional_
3912 * @param {String} msg _optional_
3913 * @namespace BDD
3914 * @api public
3915 */
3916
3917 function assertChanges (subject, prop, msg) {
3918 if (msg) flag(this, 'message', msg);
3919 var fn = flag(this, 'object')
3920 , flagMsg = flag(this, 'message')
3921 , ssfi = flag(this, 'ssfi');
3922 new Assertion(fn, flagMsg, ssfi, true).is.a('function');
3923
3924 var initial;
3925 if (!prop) {
3926 new Assertion(subject, flagMsg, ssfi, true).is.a('function');
3927 initial = subject();
3928 } else {
3929 new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
3930 initial = subject[prop];
3931 }
3932
3933 fn();
3934
3935 var final = prop === undefined || prop === null ? subject() : subject[prop];
3936 var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3937
3938 // This gets flagged because of the .by(delta) assertion
3939 flag(this, 'deltaMsgObj', msgObj);
3940 flag(this, 'initialDeltaValue', initial);
3941 flag(this, 'finalDeltaValue', final);
3942 flag(this, 'deltaBehavior', 'change');
3943 flag(this, 'realDelta', final !== initial);
3944
3945 this.assert(
3946 initial !== final
3947 , 'expected ' + msgObj + ' to change'
3948 , 'expected ' + msgObj + ' to not change'
3949 );
3950 }
3951
3952 Assertion.addMethod('change', assertChanges);
3953 Assertion.addMethod('changes', assertChanges);
3954
3955 /**
3956 * ### .increase(subject[, prop[, msg]])
3957 *
3958 * When one argument is provided, `.increase` asserts that the given function
3959 * `subject` returns a greater number when it's invoked after invoking the
3960 * target function compared to when it's invoked beforehand. `.increase` also
3961 * causes all `.by` assertions that follow in the chain to assert how much
3962 * greater of a number is returned. It's often best to assert that the return
3963 * value increased by the expected amount, rather than asserting it increased
3964 * by any amount.
3965 *
3966 * var val = 1
3967 * , addTwo = function () { val += 2; }
3968 * , getVal = function () { return val; };
3969 *
3970 * expect(addTwo).to.increase(getVal).by(2); // Recommended
3971 * expect(addTwo).to.increase(getVal); // Not recommended
3972 *
3973 * When two arguments are provided, `.increase` asserts that the value of the
3974 * given object `subject`'s `prop` property is greater after invoking the
3975 * target function compared to beforehand.
3976 *
3977 * var myObj = {val: 1}
3978 * , addTwo = function () { myObj.val += 2; };
3979 *
3980 * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended
3981 * expect(addTwo).to.increase(myObj, 'val'); // Not recommended
3982 *
3983 * Add `.not` earlier in the chain to negate `.increase`. However, it's
3984 * dangerous to do so. The problem is that it creates uncertain expectations
3985 * by asserting that the subject either decreases, or that it stays the same.
3986 * It's often best to identify the exact output that's expected, and then
3987 * write an assertion that only accepts that exact output.
3988 *
3989 * When the subject is expected to decrease, it's often best to assert that it
3990 * decreased by the expected amount.
3991 *
3992 * var myObj = {val: 1}
3993 * , subtractTwo = function () { myObj.val -= 2; };
3994 *
3995 * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended
3996 * expect(subtractTwo).to.not.increase(myObj, 'val'); // Not recommended
3997 *
3998 * When the subject is expected to stay the same, it's often best to assert
3999 * exactly that.
4000 *
4001 * var myObj = {val: 1}
4002 * , noop = function () {};
4003 *
4004 * expect(noop).to.not.change(myObj, 'val'); // Recommended
4005 * expect(noop).to.not.increase(myObj, 'val'); // Not recommended
4006 *
4007 * `.increase` accepts an optional `msg` argument which is a custom error
4008 * message to show when the assertion fails. The message can also be given as
4009 * the second argument to `expect`. When not providing two arguments, always
4010 * use the second form.
4011 *
4012 * var myObj = {val: 1}
4013 * , noop = function () {};
4014 *
4015 * expect(noop).to.increase(myObj, 'val', 'nooo why fail??');
4016 *
4017 * var val = 1
4018 * , noop = function () {}
4019 * , getVal = function () { return val; };
4020 *
4021 * expect(noop, 'nooo why fail??').to.increase(getVal);
4022 *
4023 * The alias `.increases` can be used interchangeably with `.increase`.
4024 *
4025 * @name increase
4026 * @alias increases
4027 * @param {String|Function} subject
4028 * @param {String} prop name _optional_
4029 * @param {String} msg _optional_
4030 * @namespace BDD
4031 * @api public
4032 */
4033
4034 function assertIncreases (subject, prop, msg) {
4035 if (msg) flag(this, 'message', msg);
4036 var fn = flag(this, 'object')
4037 , flagMsg = flag(this, 'message')
4038 , ssfi = flag(this, 'ssfi');
4039 new Assertion(fn, flagMsg, ssfi, true).is.a('function');
4040
4041 var initial;
4042 if (!prop) {
4043 new Assertion(subject, flagMsg, ssfi, true).is.a('function');
4044 initial = subject();
4045 } else {
4046 new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
4047 initial = subject[prop];
4048 }
4049
4050 // Make sure that the target is a number
4051 new Assertion(initial, flagMsg, ssfi, true).is.a('number');
4052
4053 fn();
4054
4055 var final = prop === undefined || prop === null ? subject() : subject[prop];
4056 var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
4057
4058 flag(this, 'deltaMsgObj', msgObj);
4059 flag(this, 'initialDeltaValue', initial);
4060 flag(this, 'finalDeltaValue', final);
4061 flag(this, 'deltaBehavior', 'increase');
4062 flag(this, 'realDelta', final - initial);
4063
4064 this.assert(
4065 final - initial > 0
4066 , 'expected ' + msgObj + ' to increase'
4067 , 'expected ' + msgObj + ' to not increase'
4068 );
4069 }
4070
4071 Assertion.addMethod('increase', assertIncreases);
4072 Assertion.addMethod('increases', assertIncreases);
4073
4074 /**
4075 * ### .decrease(subject[, prop[, msg]])
4076 *
4077 * When one argument is provided, `.decrease` asserts that the given function
4078 * `subject` returns a lesser number when it's invoked after invoking the
4079 * target function compared to when it's invoked beforehand. `.decrease` also
4080 * causes all `.by` assertions that follow in the chain to assert how much
4081 * lesser of a number is returned. It's often best to assert that the return
4082 * value decreased by the expected amount, rather than asserting it decreased
4083 * by any amount.
4084 *
4085 * var val = 1
4086 * , subtractTwo = function () { val -= 2; }
4087 * , getVal = function () { return val; };
4088 *
4089 * expect(subtractTwo).to.decrease(getVal).by(2); // Recommended
4090 * expect(subtractTwo).to.decrease(getVal); // Not recommended
4091 *
4092 * When two arguments are provided, `.decrease` asserts that the value of the
4093 * given object `subject`'s `prop` property is lesser after invoking the
4094 * target function compared to beforehand.
4095 *
4096 * var myObj = {val: 1}
4097 * , subtractTwo = function () { myObj.val -= 2; };
4098 *
4099 * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended
4100 * expect(subtractTwo).to.decrease(myObj, 'val'); // Not recommended
4101 *
4102 * Add `.not` earlier in the chain to negate `.decrease`. However, it's
4103 * dangerous to do so. The problem is that it creates uncertain expectations
4104 * by asserting that the subject either increases, or that it stays the same.
4105 * It's often best to identify the exact output that's expected, and then
4106 * write an assertion that only accepts that exact output.
4107 *
4108 * When the subject is expected to increase, it's often best to assert that it
4109 * increased by the expected amount.
4110 *
4111 * var myObj = {val: 1}
4112 * , addTwo = function () { myObj.val += 2; };
4113 *
4114 * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended
4115 * expect(addTwo).to.not.decrease(myObj, 'val'); // Not recommended
4116 *
4117 * When the subject is expected to stay the same, it's often best to assert
4118 * exactly that.
4119 *
4120 * var myObj = {val: 1}
4121 * , noop = function () {};
4122 *
4123 * expect(noop).to.not.change(myObj, 'val'); // Recommended
4124 * expect(noop).to.not.decrease(myObj, 'val'); // Not recommended
4125 *
4126 * `.decrease` accepts an optional `msg` argument which is a custom error
4127 * message to show when the assertion fails. The message can also be given as
4128 * the second argument to `expect`. When not providing two arguments, always
4129 * use the second form.
4130 *
4131 * var myObj = {val: 1}
4132 * , noop = function () {};
4133 *
4134 * expect(noop).to.decrease(myObj, 'val', 'nooo why fail??');
4135 *
4136 * var val = 1
4137 * , noop = function () {}
4138 * , getVal = function () { return val; };
4139 *
4140 * expect(noop, 'nooo why fail??').to.decrease(getVal);
4141 *
4142 * The alias `.decreases` can be used interchangeably with `.decrease`.
4143 *
4144 * @name decrease
4145 * @alias decreases
4146 * @param {String|Function} subject
4147 * @param {String} prop name _optional_
4148 * @param {String} msg _optional_
4149 * @namespace BDD
4150 * @api public
4151 */
4152
4153 function assertDecreases (subject, prop, msg) {
4154 if (msg) flag(this, 'message', msg);
4155 var fn = flag(this, 'object')
4156 , flagMsg = flag(this, 'message')
4157 , ssfi = flag(this, 'ssfi');
4158 new Assertion(fn, flagMsg, ssfi, true).is.a('function');
4159
4160 var initial;
4161 if (!prop) {
4162 new Assertion(subject, flagMsg, ssfi, true).is.a('function');
4163 initial = subject();
4164 } else {
4165 new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
4166 initial = subject[prop];
4167 }
4168
4169 // Make sure that the target is a number
4170 new Assertion(initial, flagMsg, ssfi, true).is.a('number');
4171
4172 fn();
4173
4174 var final = prop === undefined || prop === null ? subject() : subject[prop];
4175 var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
4176
4177 flag(this, 'deltaMsgObj', msgObj);
4178 flag(this, 'initialDeltaValue', initial);
4179 flag(this, 'finalDeltaValue', final);
4180 flag(this, 'deltaBehavior', 'decrease');
4181 flag(this, 'realDelta', initial - final);
4182
4183 this.assert(
4184 final - initial < 0
4185 , 'expected ' + msgObj + ' to decrease'
4186 , 'expected ' + msgObj + ' to not decrease'
4187 );
4188 }
4189
4190 Assertion.addMethod('decrease', assertDecreases);
4191 Assertion.addMethod('decreases', assertDecreases);
4192
4193 /**
4194 * ### .by(delta[, msg])
4195 *
4196 * When following an `.increase` assertion in the chain, `.by` asserts that
4197 * the subject of the `.increase` assertion increased by the given `delta`.
4198 *
4199 * var myObj = {val: 1}
4200 * , addTwo = function () { myObj.val += 2; };
4201 *
4202 * expect(addTwo).to.increase(myObj, 'val').by(2);
4203 *
4204 * When following a `.decrease` assertion in the chain, `.by` asserts that the
4205 * subject of the `.decrease` assertion decreased by the given `delta`.
4206 *
4207 * var myObj = {val: 1}
4208 * , subtractTwo = function () { myObj.val -= 2; };
4209 *
4210 * expect(subtractTwo).to.decrease(myObj, 'val').by(2);
4211 *
4212 * When following a `.change` assertion in the chain, `.by` asserts that the
4213 * subject of the `.change` assertion either increased or decreased by the
4214 * given `delta`. However, it's dangerous to use `.change.by`. The problem is
4215 * that it creates uncertain expectations. It's often best to identify the
4216 * exact output that's expected, and then write an assertion that only accepts
4217 * that exact output.
4218 *
4219 * var myObj = {val: 1}
4220 * , addTwo = function () { myObj.val += 2; }
4221 * , subtractTwo = function () { myObj.val -= 2; };
4222 *
4223 * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended
4224 * expect(addTwo).to.change(myObj, 'val').by(2); // Not recommended
4225 *
4226 * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended
4227 * expect(subtractTwo).to.change(myObj, 'val').by(2); // Not recommended
4228 *
4229 * Add `.not` earlier in the chain to negate `.by`. However, it's often best
4230 * to assert that the subject changed by its expected delta, rather than
4231 * asserting that it didn't change by one of countless unexpected deltas.
4232 *
4233 * var myObj = {val: 1}
4234 * , addTwo = function () { myObj.val += 2; };
4235 *
4236 * // Recommended
4237 * expect(addTwo).to.increase(myObj, 'val').by(2);
4238 *
4239 * // Not recommended
4240 * expect(addTwo).to.increase(myObj, 'val').but.not.by(3);
4241 *
4242 * `.by` accepts an optional `msg` argument which is a custom error message to
4243 * show when the assertion fails. The message can also be given as the second
4244 * argument to `expect`.
4245 *
4246 * var myObj = {val: 1}
4247 * , addTwo = function () { myObj.val += 2; };
4248 *
4249 * expect(addTwo).to.increase(myObj, 'val').by(3, 'nooo why fail??');
4250 * expect(addTwo, 'nooo why fail??').to.increase(myObj, 'val').by(3);
4251 *
4252 * @name by
4253 * @param {Number} delta
4254 * @param {String} msg _optional_
4255 * @namespace BDD
4256 * @api public
4257 */
4258
4259 function assertDelta(delta, msg) {
4260 if (msg) flag(this, 'message', msg);
4261
4262 var msgObj = flag(this, 'deltaMsgObj');
4263 var initial = flag(this, 'initialDeltaValue');
4264 var final = flag(this, 'finalDeltaValue');
4265 var behavior = flag(this, 'deltaBehavior');
4266 var realDelta = flag(this, 'realDelta');
4267
4268 var expression;
4269 if (behavior === 'change') {
4270 expression = Math.abs(final - initial) === Math.abs(delta);
4271 } else {
4272 expression = realDelta === Math.abs(delta);
4273 }
4274
4275 this.assert(
4276 expression
4277 , 'expected ' + msgObj + ' to ' + behavior + ' by ' + delta
4278 , 'expected ' + msgObj + ' to not ' + behavior + ' by ' + delta
4279 );
4280 }
4281
4282 Assertion.addMethod('by', assertDelta);
4283
4284 /**
4285 * ### .extensible
4286 *
4287 * Asserts that the target is extensible, which means that new properties can
4288 * be added to it. Primitives are never extensible.
4289 *
4290 * expect({a: 1}).to.be.extensible;
4291 *
4292 * Add `.not` earlier in the chain to negate `.extensible`.
4293 *
4294 * var nonExtensibleObject = Object.preventExtensions({})
4295 * , sealedObject = Object.seal({})
4296 * , frozenObject = Object.freeze({});
4297 *
4298 * expect(nonExtensibleObject).to.not.be.extensible;
4299 * expect(sealedObject).to.not.be.extensible;
4300 * expect(frozenObject).to.not.be.extensible;
4301 * expect(1).to.not.be.extensible;
4302 *
4303 * A custom error message can be given as the second argument to `expect`.
4304 *
4305 * expect(1, 'nooo why fail??').to.be.extensible;
4306 *
4307 * @name extensible
4308 * @namespace BDD
4309 * @api public
4310 */
4311
4312 Assertion.addProperty('extensible', function() {
4313 var obj = flag(this, 'object');
4314
4315 // In ES5, if the argument to this method is a primitive, then it will cause a TypeError.
4316 // In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false.
4317 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible
4318 // The following provides ES6 behavior for ES5 environments.
4319
4320 var isExtensible = obj === Object(obj) && Object.isExtensible(obj);
4321
4322 this.assert(
4323 isExtensible
4324 , 'expected #{this} to be extensible'
4325 , 'expected #{this} to not be extensible'
4326 );
4327 });
4328
4329 /**
4330 * ### .sealed
4331 *
4332 * Asserts that the target is sealed, which means that new properties can't be
4333 * added to it, and its existing properties can't be reconfigured or deleted.
4334 * However, it's possible that its existing properties can still be reassigned
4335 * to different values. Primitives are always sealed.
4336 *
4337 * var sealedObject = Object.seal({});
4338 * var frozenObject = Object.freeze({});
4339 *
4340 * expect(sealedObject).to.be.sealed;
4341 * expect(frozenObject).to.be.sealed;
4342 * expect(1).to.be.sealed;
4343 *
4344 * Add `.not` earlier in the chain to negate `.sealed`.
4345 *
4346 * expect({a: 1}).to.not.be.sealed;
4347 *
4348 * A custom error message can be given as the second argument to `expect`.
4349 *
4350 * expect({a: 1}, 'nooo why fail??').to.be.sealed;
4351 *
4352 * @name sealed
4353 * @namespace BDD
4354 * @api public
4355 */
4356
4357 Assertion.addProperty('sealed', function() {
4358 var obj = flag(this, 'object');
4359
4360 // In ES5, if the argument to this method is a primitive, then it will cause a TypeError.
4361 // In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true.
4362 // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed
4363 // The following provides ES6 behavior for ES5 environments.
4364
4365 var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
4366
4367 this.assert(
4368 isSealed
4369 , 'expected #{this} to be sealed'
4370 , 'expected #{this} to not be sealed'
4371 );
4372 });
4373
4374 /**
4375 * ### .frozen
4376 *
4377 * Asserts that the target is frozen, which means that new properties can't be
4378 * added to it, and its existing properties can't be reassigned to different
4379 * values, reconfigured, or deleted. Primitives are always frozen.
4380 *
4381 * var frozenObject = Object.freeze({});
4382 *
4383 * expect(frozenObject).to.be.frozen;
4384 * expect(1).to.be.frozen;
4385 *
4386 * Add `.not` earlier in the chain to negate `.frozen`.
4387 *
4388 * expect({a: 1}).to.not.be.frozen;
4389 *
4390 * A custom error message can be given as the second argument to `expect`.
4391 *
4392 * expect({a: 1}, 'nooo why fail??').to.be.frozen;
4393 *
4394 * @name frozen
4395 * @namespace BDD
4396 * @api public
4397 */
4398
4399 Assertion.addProperty('frozen', function() {
4400 var obj = flag(this, 'object');
4401
4402 // In ES5, if the argument to this method is a primitive, then it will cause a TypeError.
4403 // In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true.
4404 // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen
4405 // The following provides ES6 behavior for ES5 environments.
4406
4407 var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
4408
4409 this.assert(
4410 isFrozen
4411 , 'expected #{this} to be frozen'
4412 , 'expected #{this} to not be frozen'
4413 );
4414 });
4415
4416 /**
4417 * ### .finite
4418 *
4419 * Asserts that the target is a number, and isn't `NaN` or positive/negative
4420 * `Infinity`.
4421 *
4422 * expect(1).to.be.finite;
4423 *
4424 * Add `.not` earlier in the chain to negate `.finite`. However, it's
4425 * dangerous to do so. The problem is that it creates uncertain expectations
4426 * by asserting that the subject either isn't a number, or that it's `NaN`, or
4427 * that it's positive `Infinity`, or that it's negative `Infinity`. It's often
4428 * best to identify the exact output that's expected, and then write an
4429 * assertion that only accepts that exact output.
4430 *
4431 * When the target isn't expected to be a number, it's often best to assert
4432 * that it's the expected type, rather than asserting that it isn't one of
4433 * many unexpected types.
4434 *
4435 * expect('foo').to.be.a('string'); // Recommended
4436 * expect('foo').to.not.be.finite; // Not recommended
4437 *
4438 * When the target is expected to be `NaN`, it's often best to assert exactly
4439 * that.
4440 *
4441 * expect(NaN).to.be.NaN; // Recommended
4442 * expect(NaN).to.not.be.finite; // Not recommended
4443 *
4444 * When the target is expected to be positive infinity, it's often best to
4445 * assert exactly that.
4446 *
4447 * expect(Infinity).to.equal(Infinity); // Recommended
4448 * expect(Infinity).to.not.be.finite; // Not recommended
4449 *
4450 * When the target is expected to be negative infinity, it's often best to
4451 * assert exactly that.
4452 *
4453 * expect(-Infinity).to.equal(-Infinity); // Recommended
4454 * expect(-Infinity).to.not.be.finite; // Not recommended
4455 *
4456 * A custom error message can be given as the second argument to `expect`.
4457 *
4458 * expect('foo', 'nooo why fail??').to.be.finite;
4459 *
4460 * @name finite
4461 * @namespace BDD
4462 * @api public
4463 */
4464
4465 Assertion.addProperty('finite', function(msg) {
4466 var obj = flag(this, 'object');
4467
4468 this.assert(
4469 typeof obj === 'number' && isFinite(obj)
4470 , 'expected #{this} to be a finite number'
4471 , 'expected #{this} to not be a finite number'
4472 );
4473 });
4474};
4475
4476
4477/***/ }),
4478
4479/***/ "./node_modules/chai/lib/chai/interface/assert.js":
4480/*!********************************************************!*\
4481 !*** ./node_modules/chai/lib/chai/interface/assert.js ***!
4482 \********************************************************/
4483/***/ ((module) => {
4484
4485/*!
4486 * chai
4487 * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
4488 * MIT Licensed
4489 */
4490
4491module.exports = function (chai, util) {
4492 /*!
4493 * Chai dependencies.
4494 */
4495
4496 var Assertion = chai.Assertion
4497 , flag = util.flag;
4498
4499 /*!
4500 * Module export.
4501 */
4502
4503 /**
4504 * ### assert(expression, message)
4505 *
4506 * Write your own test expressions.
4507 *
4508 * assert('foo' !== 'bar', 'foo is not bar');
4509 * assert(Array.isArray([]), 'empty arrays are arrays');
4510 *
4511 * @param {Mixed} expression to test for truthiness
4512 * @param {String} message to display on error
4513 * @name assert
4514 * @namespace Assert
4515 * @api public
4516 */
4517
4518 var assert = chai.assert = function (express, errmsg) {
4519 var test = new Assertion(null, null, chai.assert, true);
4520 test.assert(
4521 express
4522 , errmsg
4523 , '[ negation message unavailable ]'
4524 );
4525 };
4526
4527 /**
4528 * ### .fail([message])
4529 * ### .fail(actual, expected, [message], [operator])
4530 *
4531 * Throw a failure. Node.js `assert` module-compatible.
4532 *
4533 * assert.fail();
4534 * assert.fail("custom error message");
4535 * assert.fail(1, 2);
4536 * assert.fail(1, 2, "custom error message");
4537 * assert.fail(1, 2, "custom error message", ">");
4538 * assert.fail(1, 2, undefined, ">");
4539 *
4540 * @name fail
4541 * @param {Mixed} actual
4542 * @param {Mixed} expected
4543 * @param {String} message
4544 * @param {String} operator
4545 * @namespace Assert
4546 * @api public
4547 */
4548
4549 assert.fail = function (actual, expected, message, operator) {
4550 if (arguments.length < 2) {
4551 // Comply with Node's fail([message]) interface
4552
4553 message = actual;
4554 actual = undefined;
4555 }
4556
4557 message = message || 'assert.fail()';
4558 throw new chai.AssertionError(message, {
4559 actual: actual
4560 , expected: expected
4561 , operator: operator
4562 }, assert.fail);
4563 };
4564
4565 /**
4566 * ### .isOk(object, [message])
4567 *
4568 * Asserts that `object` is truthy.
4569 *
4570 * assert.isOk('everything', 'everything is ok');
4571 * assert.isOk(false, 'this will fail');
4572 *
4573 * @name isOk
4574 * @alias ok
4575 * @param {Mixed} object to test
4576 * @param {String} message
4577 * @namespace Assert
4578 * @api public
4579 */
4580
4581 assert.isOk = function (val, msg) {
4582 new Assertion(val, msg, assert.isOk, true).is.ok;
4583 };
4584
4585 /**
4586 * ### .isNotOk(object, [message])
4587 *
4588 * Asserts that `object` is falsy.
4589 *
4590 * assert.isNotOk('everything', 'this will fail');
4591 * assert.isNotOk(false, 'this will pass');
4592 *
4593 * @name isNotOk
4594 * @alias notOk
4595 * @param {Mixed} object to test
4596 * @param {String} message
4597 * @namespace Assert
4598 * @api public
4599 */
4600
4601 assert.isNotOk = function (val, msg) {
4602 new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
4603 };
4604
4605 /**
4606 * ### .equal(actual, expected, [message])
4607 *
4608 * Asserts non-strict equality (`==`) of `actual` and `expected`.
4609 *
4610 * assert.equal(3, '3', '== coerces values to strings');
4611 *
4612 * @name equal
4613 * @param {Mixed} actual
4614 * @param {Mixed} expected
4615 * @param {String} message
4616 * @namespace Assert
4617 * @api public
4618 */
4619
4620 assert.equal = function (act, exp, msg) {
4621 var test = new Assertion(act, msg, assert.equal, true);
4622
4623 test.assert(
4624 exp == flag(test, 'object')
4625 , 'expected #{this} to equal #{exp}'
4626 , 'expected #{this} to not equal #{act}'
4627 , exp
4628 , act
4629 , true
4630 );
4631 };
4632
4633 /**
4634 * ### .notEqual(actual, expected, [message])
4635 *
4636 * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
4637 *
4638 * assert.notEqual(3, 4, 'these numbers are not equal');
4639 *
4640 * @name notEqual
4641 * @param {Mixed} actual
4642 * @param {Mixed} expected
4643 * @param {String} message
4644 * @namespace Assert
4645 * @api public
4646 */
4647
4648 assert.notEqual = function (act, exp, msg) {
4649 var test = new Assertion(act, msg, assert.notEqual, true);
4650
4651 test.assert(
4652 exp != flag(test, 'object')
4653 , 'expected #{this} to not equal #{exp}'
4654 , 'expected #{this} to equal #{act}'
4655 , exp
4656 , act
4657 , true
4658 );
4659 };
4660
4661 /**
4662 * ### .strictEqual(actual, expected, [message])
4663 *
4664 * Asserts strict equality (`===`) of `actual` and `expected`.
4665 *
4666 * assert.strictEqual(true, true, 'these booleans are strictly equal');
4667 *
4668 * @name strictEqual
4669 * @param {Mixed} actual
4670 * @param {Mixed} expected
4671 * @param {String} message
4672 * @namespace Assert
4673 * @api public
4674 */
4675
4676 assert.strictEqual = function (act, exp, msg) {
4677 new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
4678 };
4679
4680 /**
4681 * ### .notStrictEqual(actual, expected, [message])
4682 *
4683 * Asserts strict inequality (`!==`) of `actual` and `expected`.
4684 *
4685 * assert.notStrictEqual(3, '3', 'no coercion for strict equality');
4686 *
4687 * @name notStrictEqual
4688 * @param {Mixed} actual
4689 * @param {Mixed} expected
4690 * @param {String} message
4691 * @namespace Assert
4692 * @api public
4693 */
4694
4695 assert.notStrictEqual = function (act, exp, msg) {
4696 new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
4697 };
4698
4699 /**
4700 * ### .deepEqual(actual, expected, [message])
4701 *
4702 * Asserts that `actual` is deeply equal to `expected`.
4703 *
4704 * assert.deepEqual({ tea: 'green' }, { tea: 'green' });
4705 *
4706 * @name deepEqual
4707 * @param {Mixed} actual
4708 * @param {Mixed} expected
4709 * @param {String} message
4710 * @alias deepStrictEqual
4711 * @namespace Assert
4712 * @api public
4713 */
4714
4715 assert.deepEqual = assert.deepStrictEqual = function (act, exp, msg) {
4716 new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
4717 };
4718
4719 /**
4720 * ### .notDeepEqual(actual, expected, [message])
4721 *
4722 * Assert that `actual` is not deeply equal to `expected`.
4723 *
4724 * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
4725 *
4726 * @name notDeepEqual
4727 * @param {Mixed} actual
4728 * @param {Mixed} expected
4729 * @param {String} message
4730 * @namespace Assert
4731 * @api public
4732 */
4733
4734 assert.notDeepEqual = function (act, exp, msg) {
4735 new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
4736 };
4737
4738 /**
4739 * ### .isAbove(valueToCheck, valueToBeAbove, [message])
4740 *
4741 * Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove`.
4742 *
4743 * assert.isAbove(5, 2, '5 is strictly greater than 2');
4744 *
4745 * @name isAbove
4746 * @param {Mixed} valueToCheck
4747 * @param {Mixed} valueToBeAbove
4748 * @param {String} message
4749 * @namespace Assert
4750 * @api public
4751 */
4752
4753 assert.isAbove = function (val, abv, msg) {
4754 new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
4755 };
4756
4757 /**
4758 * ### .isAtLeast(valueToCheck, valueToBeAtLeast, [message])
4759 *
4760 * Asserts `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast`.
4761 *
4762 * assert.isAtLeast(5, 2, '5 is greater or equal to 2');
4763 * assert.isAtLeast(3, 3, '3 is greater or equal to 3');
4764 *
4765 * @name isAtLeast
4766 * @param {Mixed} valueToCheck
4767 * @param {Mixed} valueToBeAtLeast
4768 * @param {String} message
4769 * @namespace Assert
4770 * @api public
4771 */
4772
4773 assert.isAtLeast = function (val, atlst, msg) {
4774 new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
4775 };
4776
4777 /**
4778 * ### .isBelow(valueToCheck, valueToBeBelow, [message])
4779 *
4780 * Asserts `valueToCheck` is strictly less than (<) `valueToBeBelow`.
4781 *
4782 * assert.isBelow(3, 6, '3 is strictly less than 6');
4783 *
4784 * @name isBelow
4785 * @param {Mixed} valueToCheck
4786 * @param {Mixed} valueToBeBelow
4787 * @param {String} message
4788 * @namespace Assert
4789 * @api public
4790 */
4791
4792 assert.isBelow = function (val, blw, msg) {
4793 new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
4794 };
4795
4796 /**
4797 * ### .isAtMost(valueToCheck, valueToBeAtMost, [message])
4798 *
4799 * Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost`.
4800 *
4801 * assert.isAtMost(3, 6, '3 is less than or equal to 6');
4802 * assert.isAtMost(4, 4, '4 is less than or equal to 4');
4803 *
4804 * @name isAtMost
4805 * @param {Mixed} valueToCheck
4806 * @param {Mixed} valueToBeAtMost
4807 * @param {String} message
4808 * @namespace Assert
4809 * @api public
4810 */
4811
4812 assert.isAtMost = function (val, atmst, msg) {
4813 new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
4814 };
4815
4816 /**
4817 * ### .isTrue(value, [message])
4818 *
4819 * Asserts that `value` is true.
4820 *
4821 * var teaServed = true;
4822 * assert.isTrue(teaServed, 'the tea has been served');
4823 *
4824 * @name isTrue
4825 * @param {Mixed} value
4826 * @param {String} message
4827 * @namespace Assert
4828 * @api public
4829 */
4830
4831 assert.isTrue = function (val, msg) {
4832 new Assertion(val, msg, assert.isTrue, true).is['true'];
4833 };
4834
4835 /**
4836 * ### .isNotTrue(value, [message])
4837 *
4838 * Asserts that `value` is not true.
4839 *
4840 * var tea = 'tasty chai';
4841 * assert.isNotTrue(tea, 'great, time for tea!');
4842 *
4843 * @name isNotTrue
4844 * @param {Mixed} value
4845 * @param {String} message
4846 * @namespace Assert
4847 * @api public
4848 */
4849
4850 assert.isNotTrue = function (val, msg) {
4851 new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
4852 };
4853
4854 /**
4855 * ### .isFalse(value, [message])
4856 *
4857 * Asserts that `value` is false.
4858 *
4859 * var teaServed = false;
4860 * assert.isFalse(teaServed, 'no tea yet? hmm...');
4861 *
4862 * @name isFalse
4863 * @param {Mixed} value
4864 * @param {String} message
4865 * @namespace Assert
4866 * @api public
4867 */
4868
4869 assert.isFalse = function (val, msg) {
4870 new Assertion(val, msg, assert.isFalse, true).is['false'];
4871 };
4872
4873 /**
4874 * ### .isNotFalse(value, [message])
4875 *
4876 * Asserts that `value` is not false.
4877 *
4878 * var tea = 'tasty chai';
4879 * assert.isNotFalse(tea, 'great, time for tea!');
4880 *
4881 * @name isNotFalse
4882 * @param {Mixed} value
4883 * @param {String} message
4884 * @namespace Assert
4885 * @api public
4886 */
4887
4888 assert.isNotFalse = function (val, msg) {
4889 new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
4890 };
4891
4892 /**
4893 * ### .isNull(value, [message])
4894 *
4895 * Asserts that `value` is null.
4896 *
4897 * assert.isNull(err, 'there was no error');
4898 *
4899 * @name isNull
4900 * @param {Mixed} value
4901 * @param {String} message
4902 * @namespace Assert
4903 * @api public
4904 */
4905
4906 assert.isNull = function (val, msg) {
4907 new Assertion(val, msg, assert.isNull, true).to.equal(null);
4908 };
4909
4910 /**
4911 * ### .isNotNull(value, [message])
4912 *
4913 * Asserts that `value` is not null.
4914 *
4915 * var tea = 'tasty chai';
4916 * assert.isNotNull(tea, 'great, time for tea!');
4917 *
4918 * @name isNotNull
4919 * @param {Mixed} value
4920 * @param {String} message
4921 * @namespace Assert
4922 * @api public
4923 */
4924
4925 assert.isNotNull = function (val, msg) {
4926 new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
4927 };
4928
4929 /**
4930 * ### .isNaN
4931 *
4932 * Asserts that value is NaN.
4933 *
4934 * assert.isNaN(NaN, 'NaN is NaN');
4935 *
4936 * @name isNaN
4937 * @param {Mixed} value
4938 * @param {String} message
4939 * @namespace Assert
4940 * @api public
4941 */
4942
4943 assert.isNaN = function (val, msg) {
4944 new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
4945 };
4946
4947 /**
4948 * ### .isNotNaN
4949 *
4950 * Asserts that value is not NaN.
4951 *
4952 * assert.isNotNaN(4, '4 is not NaN');
4953 *
4954 * @name isNotNaN
4955 * @param {Mixed} value
4956 * @param {String} message
4957 * @namespace Assert
4958 * @api public
4959 */
4960 assert.isNotNaN = function (val, msg) {
4961 new Assertion(val, msg, assert.isNotNaN, true).not.to.be.NaN;
4962 };
4963
4964 /**
4965 * ### .exists
4966 *
4967 * Asserts that the target is neither `null` nor `undefined`.
4968 *
4969 * var foo = 'hi';
4970 *
4971 * assert.exists(foo, 'foo is neither `null` nor `undefined`');
4972 *
4973 * @name exists
4974 * @param {Mixed} value
4975 * @param {String} message
4976 * @namespace Assert
4977 * @api public
4978 */
4979
4980 assert.exists = function (val, msg) {
4981 new Assertion(val, msg, assert.exists, true).to.exist;
4982 };
4983
4984 /**
4985 * ### .notExists
4986 *
4987 * Asserts that the target is either `null` or `undefined`.
4988 *
4989 * var bar = null
4990 * , baz;
4991 *
4992 * assert.notExists(bar);
4993 * assert.notExists(baz, 'baz is either null or undefined');
4994 *
4995 * @name notExists
4996 * @param {Mixed} value
4997 * @param {String} message
4998 * @namespace Assert
4999 * @api public
5000 */
5001
5002 assert.notExists = function (val, msg) {
5003 new Assertion(val, msg, assert.notExists, true).to.not.exist;
5004 };
5005
5006 /**
5007 * ### .isUndefined(value, [message])
5008 *
5009 * Asserts that `value` is `undefined`.
5010 *
5011 * var tea;
5012 * assert.isUndefined(tea, 'no tea defined');
5013 *
5014 * @name isUndefined
5015 * @param {Mixed} value
5016 * @param {String} message
5017 * @namespace Assert
5018 * @api public
5019 */
5020
5021 assert.isUndefined = function (val, msg) {
5022 new Assertion(val, msg, assert.isUndefined, true).to.equal(undefined);
5023 };
5024
5025 /**
5026 * ### .isDefined(value, [message])
5027 *
5028 * Asserts that `value` is not `undefined`.
5029 *
5030 * var tea = 'cup of chai';
5031 * assert.isDefined(tea, 'tea has been defined');
5032 *
5033 * @name isDefined
5034 * @param {Mixed} value
5035 * @param {String} message
5036 * @namespace Assert
5037 * @api public
5038 */
5039
5040 assert.isDefined = function (val, msg) {
5041 new Assertion(val, msg, assert.isDefined, true).to.not.equal(undefined);
5042 };
5043
5044 /**
5045 * ### .isFunction(value, [message])
5046 *
5047 * Asserts that `value` is a function.
5048 *
5049 * function serveTea() { return 'cup of tea'; };
5050 * assert.isFunction(serveTea, 'great, we can have tea now');
5051 *
5052 * @name isFunction
5053 * @param {Mixed} value
5054 * @param {String} message
5055 * @namespace Assert
5056 * @api public
5057 */
5058
5059 assert.isFunction = function (val, msg) {
5060 new Assertion(val, msg, assert.isFunction, true).to.be.a('function');
5061 };
5062
5063 /**
5064 * ### .isNotFunction(value, [message])
5065 *
5066 * Asserts that `value` is _not_ a function.
5067 *
5068 * var serveTea = [ 'heat', 'pour', 'sip' ];
5069 * assert.isNotFunction(serveTea, 'great, we have listed the steps');
5070 *
5071 * @name isNotFunction
5072 * @param {Mixed} value
5073 * @param {String} message
5074 * @namespace Assert
5075 * @api public
5076 */
5077
5078 assert.isNotFunction = function (val, msg) {
5079 new Assertion(val, msg, assert.isNotFunction, true).to.not.be.a('function');
5080 };
5081
5082 /**
5083 * ### .isObject(value, [message])
5084 *
5085 * Asserts that `value` is an object of type 'Object' (as revealed by `Object.prototype.toString`).
5086 * _The assertion does not match subclassed objects._
5087 *
5088 * var selection = { name: 'Chai', serve: 'with spices' };
5089 * assert.isObject(selection, 'tea selection is an object');
5090 *
5091 * @name isObject
5092 * @param {Mixed} value
5093 * @param {String} message
5094 * @namespace Assert
5095 * @api public
5096 */
5097
5098 assert.isObject = function (val, msg) {
5099 new Assertion(val, msg, assert.isObject, true).to.be.a('object');
5100 };
5101
5102 /**
5103 * ### .isNotObject(value, [message])
5104 *
5105 * Asserts that `value` is _not_ an object of type 'Object' (as revealed by `Object.prototype.toString`).
5106 *
5107 * var selection = 'chai'
5108 * assert.isNotObject(selection, 'tea selection is not an object');
5109 * assert.isNotObject(null, 'null is not an object');
5110 *
5111 * @name isNotObject
5112 * @param {Mixed} value
5113 * @param {String} message
5114 * @namespace Assert
5115 * @api public
5116 */
5117
5118 assert.isNotObject = function (val, msg) {
5119 new Assertion(val, msg, assert.isNotObject, true).to.not.be.a('object');
5120 };
5121
5122 /**
5123 * ### .isArray(value, [message])
5124 *
5125 * Asserts that `value` is an array.
5126 *
5127 * var menu = [ 'green', 'chai', 'oolong' ];
5128 * assert.isArray(menu, 'what kind of tea do we want?');
5129 *
5130 * @name isArray
5131 * @param {Mixed} value
5132 * @param {String} message
5133 * @namespace Assert
5134 * @api public
5135 */
5136
5137 assert.isArray = function (val, msg) {
5138 new Assertion(val, msg, assert.isArray, true).to.be.an('array');
5139 };
5140
5141 /**
5142 * ### .isNotArray(value, [message])
5143 *
5144 * Asserts that `value` is _not_ an array.
5145 *
5146 * var menu = 'green|chai|oolong';
5147 * assert.isNotArray(menu, 'what kind of tea do we want?');
5148 *
5149 * @name isNotArray
5150 * @param {Mixed} value
5151 * @param {String} message
5152 * @namespace Assert
5153 * @api public
5154 */
5155
5156 assert.isNotArray = function (val, msg) {
5157 new Assertion(val, msg, assert.isNotArray, true).to.not.be.an('array');
5158 };
5159
5160 /**
5161 * ### .isString(value, [message])
5162 *
5163 * Asserts that `value` is a string.
5164 *
5165 * var teaOrder = 'chai';
5166 * assert.isString(teaOrder, 'order placed');
5167 *
5168 * @name isString
5169 * @param {Mixed} value
5170 * @param {String} message
5171 * @namespace Assert
5172 * @api public
5173 */
5174
5175 assert.isString = function (val, msg) {
5176 new Assertion(val, msg, assert.isString, true).to.be.a('string');
5177 };
5178
5179 /**
5180 * ### .isNotString(value, [message])
5181 *
5182 * Asserts that `value` is _not_ a string.
5183 *
5184 * var teaOrder = 4;
5185 * assert.isNotString(teaOrder, 'order placed');
5186 *
5187 * @name isNotString
5188 * @param {Mixed} value
5189 * @param {String} message
5190 * @namespace Assert
5191 * @api public
5192 */
5193
5194 assert.isNotString = function (val, msg) {
5195 new Assertion(val, msg, assert.isNotString, true).to.not.be.a('string');
5196 };
5197
5198 /**
5199 * ### .isNumber(value, [message])
5200 *
5201 * Asserts that `value` is a number.
5202 *
5203 * var cups = 2;
5204 * assert.isNumber(cups, 'how many cups');
5205 *
5206 * @name isNumber
5207 * @param {Number} value
5208 * @param {String} message
5209 * @namespace Assert
5210 * @api public
5211 */
5212
5213 assert.isNumber = function (val, msg) {
5214 new Assertion(val, msg, assert.isNumber, true).to.be.a('number');
5215 };
5216
5217 /**
5218 * ### .isNotNumber(value, [message])
5219 *
5220 * Asserts that `value` is _not_ a number.
5221 *
5222 * var cups = '2 cups please';
5223 * assert.isNotNumber(cups, 'how many cups');
5224 *
5225 * @name isNotNumber
5226 * @param {Mixed} value
5227 * @param {String} message
5228 * @namespace Assert
5229 * @api public
5230 */
5231
5232 assert.isNotNumber = function (val, msg) {
5233 new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a('number');
5234 };
5235
5236 /**
5237 * ### .isFinite(value, [message])
5238 *
5239 * Asserts that `value` is a finite number. Unlike `.isNumber`, this will fail for `NaN` and `Infinity`.
5240 *
5241 * var cups = 2;
5242 * assert.isFinite(cups, 'how many cups');
5243 *
5244 * assert.isFinite(NaN); // throws
5245 *
5246 * @name isFinite
5247 * @param {Number} value
5248 * @param {String} message
5249 * @namespace Assert
5250 * @api public
5251 */
5252
5253 assert.isFinite = function (val, msg) {
5254 new Assertion(val, msg, assert.isFinite, true).to.be.finite;
5255 };
5256
5257 /**
5258 * ### .isBoolean(value, [message])
5259 *
5260 * Asserts that `value` is a boolean.
5261 *
5262 * var teaReady = true
5263 * , teaServed = false;
5264 *
5265 * assert.isBoolean(teaReady, 'is the tea ready');
5266 * assert.isBoolean(teaServed, 'has tea been served');
5267 *
5268 * @name isBoolean
5269 * @param {Mixed} value
5270 * @param {String} message
5271 * @namespace Assert
5272 * @api public
5273 */
5274
5275 assert.isBoolean = function (val, msg) {
5276 new Assertion(val, msg, assert.isBoolean, true).to.be.a('boolean');
5277 };
5278
5279 /**
5280 * ### .isNotBoolean(value, [message])
5281 *
5282 * Asserts that `value` is _not_ a boolean.
5283 *
5284 * var teaReady = 'yep'
5285 * , teaServed = 'nope';
5286 *
5287 * assert.isNotBoolean(teaReady, 'is the tea ready');
5288 * assert.isNotBoolean(teaServed, 'has tea been served');
5289 *
5290 * @name isNotBoolean
5291 * @param {Mixed} value
5292 * @param {String} message
5293 * @namespace Assert
5294 * @api public
5295 */
5296
5297 assert.isNotBoolean = function (val, msg) {
5298 new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a('boolean');
5299 };
5300
5301 /**
5302 * ### .typeOf(value, name, [message])
5303 *
5304 * Asserts that `value`'s type is `name`, as determined by
5305 * `Object.prototype.toString`.
5306 *
5307 * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');
5308 * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');
5309 * assert.typeOf('tea', 'string', 'we have a string');
5310 * assert.typeOf(/tea/, 'regexp', 'we have a regular expression');
5311 * assert.typeOf(null, 'null', 'we have a null');
5312 * assert.typeOf(undefined, 'undefined', 'we have an undefined');
5313 *
5314 * @name typeOf
5315 * @param {Mixed} value
5316 * @param {String} name
5317 * @param {String} message
5318 * @namespace Assert
5319 * @api public
5320 */
5321
5322 assert.typeOf = function (val, type, msg) {
5323 new Assertion(val, msg, assert.typeOf, true).to.be.a(type);
5324 };
5325
5326 /**
5327 * ### .notTypeOf(value, name, [message])
5328 *
5329 * Asserts that `value`'s type is _not_ `name`, as determined by
5330 * `Object.prototype.toString`.
5331 *
5332 * assert.notTypeOf('tea', 'number', 'strings are not numbers');
5333 *
5334 * @name notTypeOf
5335 * @param {Mixed} value
5336 * @param {String} typeof name
5337 * @param {String} message
5338 * @namespace Assert
5339 * @api public
5340 */
5341
5342 assert.notTypeOf = function (val, type, msg) {
5343 new Assertion(val, msg, assert.notTypeOf, true).to.not.be.a(type);
5344 };
5345
5346 /**
5347 * ### .instanceOf(object, constructor, [message])
5348 *
5349 * Asserts that `value` is an instance of `constructor`.
5350 *
5351 * var Tea = function (name) { this.name = name; }
5352 * , chai = new Tea('chai');
5353 *
5354 * assert.instanceOf(chai, Tea, 'chai is an instance of tea');
5355 *
5356 * @name instanceOf
5357 * @param {Object} object
5358 * @param {Constructor} constructor
5359 * @param {String} message
5360 * @namespace Assert
5361 * @api public
5362 */
5363
5364 assert.instanceOf = function (val, type, msg) {
5365 new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type);
5366 };
5367
5368 /**
5369 * ### .notInstanceOf(object, constructor, [message])
5370 *
5371 * Asserts `value` is not an instance of `constructor`.
5372 *
5373 * var Tea = function (name) { this.name = name; }
5374 * , chai = new String('chai');
5375 *
5376 * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');
5377 *
5378 * @name notInstanceOf
5379 * @param {Object} object
5380 * @param {Constructor} constructor
5381 * @param {String} message
5382 * @namespace Assert
5383 * @api public
5384 */
5385
5386 assert.notInstanceOf = function (val, type, msg) {
5387 new Assertion(val, msg, assert.notInstanceOf, true)
5388 .to.not.be.instanceOf(type);
5389 };
5390
5391 /**
5392 * ### .include(haystack, needle, [message])
5393 *
5394 * Asserts that `haystack` includes `needle`. Can be used to assert the
5395 * inclusion of a value in an array, a substring in a string, or a subset of
5396 * properties in an object.
5397 *
5398 * assert.include([1,2,3], 2, 'array contains value');
5399 * assert.include('foobar', 'foo', 'string contains substring');
5400 * assert.include({ foo: 'bar', hello: 'universe' }, { foo: 'bar' }, 'object contains property');
5401 *
5402 * Strict equality (===) is used. When asserting the inclusion of a value in
5403 * an array, the array is searched for an element that's strictly equal to the
5404 * given value. When asserting a subset of properties in an object, the object
5405 * is searched for the given property keys, checking that each one is present
5406 * and strictly equal to the given property value. For instance:
5407 *
5408 * var obj1 = {a: 1}
5409 * , obj2 = {b: 2};
5410 * assert.include([obj1, obj2], obj1);
5411 * assert.include({foo: obj1, bar: obj2}, {foo: obj1});
5412 * assert.include({foo: obj1, bar: obj2}, {foo: obj1, bar: obj2});
5413 *
5414 * @name include
5415 * @param {Array|String} haystack
5416 * @param {Mixed} needle
5417 * @param {String} message
5418 * @namespace Assert
5419 * @api public
5420 */
5421
5422 assert.include = function (exp, inc, msg) {
5423 new Assertion(exp, msg, assert.include, true).include(inc);
5424 };
5425
5426 /**
5427 * ### .notInclude(haystack, needle, [message])
5428 *
5429 * Asserts that `haystack` does not include `needle`. Can be used to assert
5430 * the absence of a value in an array, a substring in a string, or a subset of
5431 * properties in an object.
5432 *
5433 * assert.notInclude([1,2,3], 4, "array doesn't contain value");
5434 * assert.notInclude('foobar', 'baz', "string doesn't contain substring");
5435 * assert.notInclude({ foo: 'bar', hello: 'universe' }, { foo: 'baz' }, 'object doesn't contain property');
5436 *
5437 * Strict equality (===) is used. When asserting the absence of a value in an
5438 * array, the array is searched to confirm the absence of an element that's
5439 * strictly equal to the given value. When asserting a subset of properties in
5440 * an object, the object is searched to confirm that at least one of the given
5441 * property keys is either not present or not strictly equal to the given
5442 * property value. For instance:
5443 *
5444 * var obj1 = {a: 1}
5445 * , obj2 = {b: 2};
5446 * assert.notInclude([obj1, obj2], {a: 1});
5447 * assert.notInclude({foo: obj1, bar: obj2}, {foo: {a: 1}});
5448 * assert.notInclude({foo: obj1, bar: obj2}, {foo: obj1, bar: {b: 2}});
5449 *
5450 * @name notInclude
5451 * @param {Array|String} haystack
5452 * @param {Mixed} needle
5453 * @param {String} message
5454 * @namespace Assert
5455 * @api public
5456 */
5457
5458 assert.notInclude = function (exp, inc, msg) {
5459 new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
5460 };
5461
5462 /**
5463 * ### .deepInclude(haystack, needle, [message])
5464 *
5465 * Asserts that `haystack` includes `needle`. Can be used to assert the
5466 * inclusion of a value in an array or a subset of properties in an object.
5467 * Deep equality is used.
5468 *
5469 * var obj1 = {a: 1}
5470 * , obj2 = {b: 2};
5471 * assert.deepInclude([obj1, obj2], {a: 1});
5472 * assert.deepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}});
5473 * assert.deepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 2}});
5474 *
5475 * @name deepInclude
5476 * @param {Array|String} haystack
5477 * @param {Mixed} needle
5478 * @param {String} message
5479 * @namespace Assert
5480 * @api public
5481 */
5482
5483 assert.deepInclude = function (exp, inc, msg) {
5484 new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
5485 };
5486
5487 /**
5488 * ### .notDeepInclude(haystack, needle, [message])
5489 *
5490 * Asserts that `haystack` does not include `needle`. Can be used to assert
5491 * the absence of a value in an array or a subset of properties in an object.
5492 * Deep equality is used.
5493 *
5494 * var obj1 = {a: 1}
5495 * , obj2 = {b: 2};
5496 * assert.notDeepInclude([obj1, obj2], {a: 9});
5497 * assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 9}});
5498 * assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 9}});
5499 *
5500 * @name notDeepInclude
5501 * @param {Array|String} haystack
5502 * @param {Mixed} needle
5503 * @param {String} message
5504 * @namespace Assert
5505 * @api public
5506 */
5507
5508 assert.notDeepInclude = function (exp, inc, msg) {
5509 new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
5510 };
5511
5512 /**
5513 * ### .nestedInclude(haystack, needle, [message])
5514 *
5515 * Asserts that 'haystack' includes 'needle'.
5516 * Can be used to assert the inclusion of a subset of properties in an
5517 * object.
5518 * Enables the use of dot- and bracket-notation for referencing nested
5519 * properties.
5520 * '[]' and '.' in property names can be escaped using double backslashes.
5521 *
5522 * assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'});
5523 * assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'});
5524 *
5525 * @name nestedInclude
5526 * @param {Object} haystack
5527 * @param {Object} needle
5528 * @param {String} message
5529 * @namespace Assert
5530 * @api public
5531 */
5532
5533 assert.nestedInclude = function (exp, inc, msg) {
5534 new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
5535 };
5536
5537 /**
5538 * ### .notNestedInclude(haystack, needle, [message])
5539 *
5540 * Asserts that 'haystack' does not include 'needle'.
5541 * Can be used to assert the absence of a subset of properties in an
5542 * object.
5543 * Enables the use of dot- and bracket-notation for referencing nested
5544 * properties.
5545 * '[]' and '.' in property names can be escaped using double backslashes.
5546 *
5547 * assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'});
5548 * assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'});
5549 *
5550 * @name notNestedInclude
5551 * @param {Object} haystack
5552 * @param {Object} needle
5553 * @param {String} message
5554 * @namespace Assert
5555 * @api public
5556 */
5557
5558 assert.notNestedInclude = function (exp, inc, msg) {
5559 new Assertion(exp, msg, assert.notNestedInclude, true)
5560 .not.nested.include(inc);
5561 };
5562
5563 /**
5564 * ### .deepNestedInclude(haystack, needle, [message])
5565 *
5566 * Asserts that 'haystack' includes 'needle'.
5567 * Can be used to assert the inclusion of a subset of properties in an
5568 * object while checking for deep equality.
5569 * Enables the use of dot- and bracket-notation for referencing nested
5570 * properties.
5571 * '[]' and '.' in property names can be escaped using double backslashes.
5572 *
5573 * assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}});
5574 * assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}});
5575 *
5576 * @name deepNestedInclude
5577 * @param {Object} haystack
5578 * @param {Object} needle
5579 * @param {String} message
5580 * @namespace Assert
5581 * @api public
5582 */
5583
5584 assert.deepNestedInclude = function(exp, inc, msg) {
5585 new Assertion(exp, msg, assert.deepNestedInclude, true)
5586 .deep.nested.include(inc);
5587 };
5588
5589 /**
5590 * ### .notDeepNestedInclude(haystack, needle, [message])
5591 *
5592 * Asserts that 'haystack' does not include 'needle'.
5593 * Can be used to assert the absence of a subset of properties in an
5594 * object while checking for deep equality.
5595 * Enables the use of dot- and bracket-notation for referencing nested
5596 * properties.
5597 * '[]' and '.' in property names can be escaped using double backslashes.
5598 *
5599 * assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}})
5600 * assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}});
5601 *
5602 * @name notDeepNestedInclude
5603 * @param {Object} haystack
5604 * @param {Object} needle
5605 * @param {String} message
5606 * @namespace Assert
5607 * @api public
5608 */
5609
5610 assert.notDeepNestedInclude = function(exp, inc, msg) {
5611 new Assertion(exp, msg, assert.notDeepNestedInclude, true)
5612 .not.deep.nested.include(inc);
5613 };
5614
5615 /**
5616 * ### .ownInclude(haystack, needle, [message])
5617 *
5618 * Asserts that 'haystack' includes 'needle'.
5619 * Can be used to assert the inclusion of a subset of properties in an
5620 * object while ignoring inherited properties.
5621 *
5622 * assert.ownInclude({ a: 1 }, { a: 1 });
5623 *
5624 * @name ownInclude
5625 * @param {Object} haystack
5626 * @param {Object} needle
5627 * @param {String} message
5628 * @namespace Assert
5629 * @api public
5630 */
5631
5632 assert.ownInclude = function(exp, inc, msg) {
5633 new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
5634 };
5635
5636 /**
5637 * ### .notOwnInclude(haystack, needle, [message])
5638 *
5639 * Asserts that 'haystack' includes 'needle'.
5640 * Can be used to assert the absence of a subset of properties in an
5641 * object while ignoring inherited properties.
5642 *
5643 * Object.prototype.b = 2;
5644 *
5645 * assert.notOwnInclude({ a: 1 }, { b: 2 });
5646 *
5647 * @name notOwnInclude
5648 * @param {Object} haystack
5649 * @param {Object} needle
5650 * @param {String} message
5651 * @namespace Assert
5652 * @api public
5653 */
5654
5655 assert.notOwnInclude = function(exp, inc, msg) {
5656 new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
5657 };
5658
5659 /**
5660 * ### .deepOwnInclude(haystack, needle, [message])
5661 *
5662 * Asserts that 'haystack' includes 'needle'.
5663 * Can be used to assert the inclusion of a subset of properties in an
5664 * object while ignoring inherited properties and checking for deep equality.
5665 *
5666 * assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}});
5667 *
5668 * @name deepOwnInclude
5669 * @param {Object} haystack
5670 * @param {Object} needle
5671 * @param {String} message
5672 * @namespace Assert
5673 * @api public
5674 */
5675
5676 assert.deepOwnInclude = function(exp, inc, msg) {
5677 new Assertion(exp, msg, assert.deepOwnInclude, true)
5678 .deep.own.include(inc);
5679 };
5680
5681 /**
5682 * ### .notDeepOwnInclude(haystack, needle, [message])
5683 *
5684 * Asserts that 'haystack' includes 'needle'.
5685 * Can be used to assert the absence of a subset of properties in an
5686 * object while ignoring inherited properties and checking for deep equality.
5687 *
5688 * assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}});
5689 *
5690 * @name notDeepOwnInclude
5691 * @param {Object} haystack
5692 * @param {Object} needle
5693 * @param {String} message
5694 * @namespace Assert
5695 * @api public
5696 */
5697
5698 assert.notDeepOwnInclude = function(exp, inc, msg) {
5699 new Assertion(exp, msg, assert.notDeepOwnInclude, true)
5700 .not.deep.own.include(inc);
5701 };
5702
5703 /**
5704 * ### .match(value, regexp, [message])
5705 *
5706 * Asserts that `value` matches the regular expression `regexp`.
5707 *
5708 * assert.match('foobar', /^foo/, 'regexp matches');
5709 *
5710 * @name match
5711 * @param {Mixed} value
5712 * @param {RegExp} regexp
5713 * @param {String} message
5714 * @namespace Assert
5715 * @api public
5716 */
5717
5718 assert.match = function (exp, re, msg) {
5719 new Assertion(exp, msg, assert.match, true).to.match(re);
5720 };
5721
5722 /**
5723 * ### .notMatch(value, regexp, [message])
5724 *
5725 * Asserts that `value` does not match the regular expression `regexp`.
5726 *
5727 * assert.notMatch('foobar', /^foo/, 'regexp does not match');
5728 *
5729 * @name notMatch
5730 * @param {Mixed} value
5731 * @param {RegExp} regexp
5732 * @param {String} message
5733 * @namespace Assert
5734 * @api public
5735 */
5736
5737 assert.notMatch = function (exp, re, msg) {
5738 new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
5739 };
5740
5741 /**
5742 * ### .property(object, property, [message])
5743 *
5744 * Asserts that `object` has a direct or inherited property named by
5745 * `property`.
5746 *
5747 * assert.property({ tea: { green: 'matcha' }}, 'tea');
5748 * assert.property({ tea: { green: 'matcha' }}, 'toString');
5749 *
5750 * @name property
5751 * @param {Object} object
5752 * @param {String} property
5753 * @param {String} message
5754 * @namespace Assert
5755 * @api public
5756 */
5757
5758 assert.property = function (obj, prop, msg) {
5759 new Assertion(obj, msg, assert.property, true).to.have.property(prop);
5760 };
5761
5762 /**
5763 * ### .notProperty(object, property, [message])
5764 *
5765 * Asserts that `object` does _not_ have a direct or inherited property named
5766 * by `property`.
5767 *
5768 * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');
5769 *
5770 * @name notProperty
5771 * @param {Object} object
5772 * @param {String} property
5773 * @param {String} message
5774 * @namespace Assert
5775 * @api public
5776 */
5777
5778 assert.notProperty = function (obj, prop, msg) {
5779 new Assertion(obj, msg, assert.notProperty, true)
5780 .to.not.have.property(prop);
5781 };
5782
5783 /**
5784 * ### .propertyVal(object, property, value, [message])
5785 *
5786 * Asserts that `object` has a direct or inherited property named by
5787 * `property` with a value given by `value`. Uses a strict equality check
5788 * (===).
5789 *
5790 * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');
5791 *
5792 * @name propertyVal
5793 * @param {Object} object
5794 * @param {String} property
5795 * @param {Mixed} value
5796 * @param {String} message
5797 * @namespace Assert
5798 * @api public
5799 */
5800
5801 assert.propertyVal = function (obj, prop, val, msg) {
5802 new Assertion(obj, msg, assert.propertyVal, true)
5803 .to.have.property(prop, val);
5804 };
5805
5806 /**
5807 * ### .notPropertyVal(object, property, value, [message])
5808 *
5809 * Asserts that `object` does _not_ have a direct or inherited property named
5810 * by `property` with value given by `value`. Uses a strict equality check
5811 * (===).
5812 *
5813 * assert.notPropertyVal({ tea: 'is good' }, 'tea', 'is bad');
5814 * assert.notPropertyVal({ tea: 'is good' }, 'coffee', 'is good');
5815 *
5816 * @name notPropertyVal
5817 * @param {Object} object
5818 * @param {String} property
5819 * @param {Mixed} value
5820 * @param {String} message
5821 * @namespace Assert
5822 * @api public
5823 */
5824
5825 assert.notPropertyVal = function (obj, prop, val, msg) {
5826 new Assertion(obj, msg, assert.notPropertyVal, true)
5827 .to.not.have.property(prop, val);
5828 };
5829
5830 /**
5831 * ### .deepPropertyVal(object, property, value, [message])
5832 *
5833 * Asserts that `object` has a direct or inherited property named by
5834 * `property` with a value given by `value`. Uses a deep equality check.
5835 *
5836 * assert.deepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'matcha' });
5837 *
5838 * @name deepPropertyVal
5839 * @param {Object} object
5840 * @param {String} property
5841 * @param {Mixed} value
5842 * @param {String} message
5843 * @namespace Assert
5844 * @api public
5845 */
5846
5847 assert.deepPropertyVal = function (obj, prop, val, msg) {
5848 new Assertion(obj, msg, assert.deepPropertyVal, true)
5849 .to.have.deep.property(prop, val);
5850 };
5851
5852 /**
5853 * ### .notDeepPropertyVal(object, property, value, [message])
5854 *
5855 * Asserts that `object` does _not_ have a direct or inherited property named
5856 * by `property` with value given by `value`. Uses a deep equality check.
5857 *
5858 * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { black: 'matcha' });
5859 * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'oolong' });
5860 * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'coffee', { green: 'matcha' });
5861 *
5862 * @name notDeepPropertyVal
5863 * @param {Object} object
5864 * @param {String} property
5865 * @param {Mixed} value
5866 * @param {String} message
5867 * @namespace Assert
5868 * @api public
5869 */
5870
5871 assert.notDeepPropertyVal = function (obj, prop, val, msg) {
5872 new Assertion(obj, msg, assert.notDeepPropertyVal, true)
5873 .to.not.have.deep.property(prop, val);
5874 };
5875
5876 /**
5877 * ### .ownProperty(object, property, [message])
5878 *
5879 * Asserts that `object` has a direct property named by `property`. Inherited
5880 * properties aren't checked.
5881 *
5882 * assert.ownProperty({ tea: { green: 'matcha' }}, 'tea');
5883 *
5884 * @name ownProperty
5885 * @param {Object} object
5886 * @param {String} property
5887 * @param {String} message
5888 * @api public
5889 */
5890
5891 assert.ownProperty = function (obj, prop, msg) {
5892 new Assertion(obj, msg, assert.ownProperty, true)
5893 .to.have.own.property(prop);
5894 };
5895
5896 /**
5897 * ### .notOwnProperty(object, property, [message])
5898 *
5899 * Asserts that `object` does _not_ have a direct property named by
5900 * `property`. Inherited properties aren't checked.
5901 *
5902 * assert.notOwnProperty({ tea: { green: 'matcha' }}, 'coffee');
5903 * assert.notOwnProperty({}, 'toString');
5904 *
5905 * @name notOwnProperty
5906 * @param {Object} object
5907 * @param {String} property
5908 * @param {String} message
5909 * @api public
5910 */
5911
5912 assert.notOwnProperty = function (obj, prop, msg) {
5913 new Assertion(obj, msg, assert.notOwnProperty, true)
5914 .to.not.have.own.property(prop);
5915 };
5916
5917 /**
5918 * ### .ownPropertyVal(object, property, value, [message])
5919 *
5920 * Asserts that `object` has a direct property named by `property` and a value
5921 * equal to the provided `value`. Uses a strict equality check (===).
5922 * Inherited properties aren't checked.
5923 *
5924 * assert.ownPropertyVal({ coffee: 'is good'}, 'coffee', 'is good');
5925 *
5926 * @name ownPropertyVal
5927 * @param {Object} object
5928 * @param {String} property
5929 * @param {Mixed} value
5930 * @param {String} message
5931 * @api public
5932 */
5933
5934 assert.ownPropertyVal = function (obj, prop, value, msg) {
5935 new Assertion(obj, msg, assert.ownPropertyVal, true)
5936 .to.have.own.property(prop, value);
5937 };
5938
5939 /**
5940 * ### .notOwnPropertyVal(object, property, value, [message])
5941 *
5942 * Asserts that `object` does _not_ have a direct property named by `property`
5943 * with a value equal to the provided `value`. Uses a strict equality check
5944 * (===). Inherited properties aren't checked.
5945 *
5946 * assert.notOwnPropertyVal({ tea: 'is better'}, 'tea', 'is worse');
5947 * assert.notOwnPropertyVal({}, 'toString', Object.prototype.toString);
5948 *
5949 * @name notOwnPropertyVal
5950 * @param {Object} object
5951 * @param {String} property
5952 * @param {Mixed} value
5953 * @param {String} message
5954 * @api public
5955 */
5956
5957 assert.notOwnPropertyVal = function (obj, prop, value, msg) {
5958 new Assertion(obj, msg, assert.notOwnPropertyVal, true)
5959 .to.not.have.own.property(prop, value);
5960 };
5961
5962 /**
5963 * ### .deepOwnPropertyVal(object, property, value, [message])
5964 *
5965 * Asserts that `object` has a direct property named by `property` and a value
5966 * equal to the provided `value`. Uses a deep equality check. Inherited
5967 * properties aren't checked.
5968 *
5969 * assert.deepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'matcha' });
5970 *
5971 * @name deepOwnPropertyVal
5972 * @param {Object} object
5973 * @param {String} property
5974 * @param {Mixed} value
5975 * @param {String} message
5976 * @api public
5977 */
5978
5979 assert.deepOwnPropertyVal = function (obj, prop, value, msg) {
5980 new Assertion(obj, msg, assert.deepOwnPropertyVal, true)
5981 .to.have.deep.own.property(prop, value);
5982 };
5983
5984 /**
5985 * ### .notDeepOwnPropertyVal(object, property, value, [message])
5986 *
5987 * Asserts that `object` does _not_ have a direct property named by `property`
5988 * with a value equal to the provided `value`. Uses a deep equality check.
5989 * Inherited properties aren't checked.
5990 *
5991 * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { black: 'matcha' });
5992 * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'oolong' });
5993 * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'coffee', { green: 'matcha' });
5994 * assert.notDeepOwnPropertyVal({}, 'toString', Object.prototype.toString);
5995 *
5996 * @name notDeepOwnPropertyVal
5997 * @param {Object} object
5998 * @param {String} property
5999 * @param {Mixed} value
6000 * @param {String} message
6001 * @api public
6002 */
6003
6004 assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) {
6005 new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true)
6006 .to.not.have.deep.own.property(prop, value);
6007 };
6008
6009 /**
6010 * ### .nestedProperty(object, property, [message])
6011 *
6012 * Asserts that `object` has a direct or inherited property named by
6013 * `property`, which can be a string using dot- and bracket-notation for
6014 * nested reference.
6015 *
6016 * assert.nestedProperty({ tea: { green: 'matcha' }}, 'tea.green');
6017 *
6018 * @name nestedProperty
6019 * @param {Object} object
6020 * @param {String} property
6021 * @param {String} message
6022 * @namespace Assert
6023 * @api public
6024 */
6025
6026 assert.nestedProperty = function (obj, prop, msg) {
6027 new Assertion(obj, msg, assert.nestedProperty, true)
6028 .to.have.nested.property(prop);
6029 };
6030
6031 /**
6032 * ### .notNestedProperty(object, property, [message])
6033 *
6034 * Asserts that `object` does _not_ have a property named by `property`, which
6035 * can be a string using dot- and bracket-notation for nested reference. The
6036 * property cannot exist on the object nor anywhere in its prototype chain.
6037 *
6038 * assert.notNestedProperty({ tea: { green: 'matcha' }}, 'tea.oolong');
6039 *
6040 * @name notNestedProperty
6041 * @param {Object} object
6042 * @param {String} property
6043 * @param {String} message
6044 * @namespace Assert
6045 * @api public
6046 */
6047
6048 assert.notNestedProperty = function (obj, prop, msg) {
6049 new Assertion(obj, msg, assert.notNestedProperty, true)
6050 .to.not.have.nested.property(prop);
6051 };
6052
6053 /**
6054 * ### .nestedPropertyVal(object, property, value, [message])
6055 *
6056 * Asserts that `object` has a property named by `property` with value given
6057 * by `value`. `property` can use dot- and bracket-notation for nested
6058 * reference. Uses a strict equality check (===).
6059 *
6060 * assert.nestedPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');
6061 *
6062 * @name nestedPropertyVal
6063 * @param {Object} object
6064 * @param {String} property
6065 * @param {Mixed} value
6066 * @param {String} message
6067 * @namespace Assert
6068 * @api public
6069 */
6070
6071 assert.nestedPropertyVal = function (obj, prop, val, msg) {
6072 new Assertion(obj, msg, assert.nestedPropertyVal, true)
6073 .to.have.nested.property(prop, val);
6074 };
6075
6076 /**
6077 * ### .notNestedPropertyVal(object, property, value, [message])
6078 *
6079 * Asserts that `object` does _not_ have a property named by `property` with
6080 * value given by `value`. `property` can use dot- and bracket-notation for
6081 * nested reference. Uses a strict equality check (===).
6082 *
6083 * assert.notNestedPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');
6084 * assert.notNestedPropertyVal({ tea: { green: 'matcha' }}, 'coffee.green', 'matcha');
6085 *
6086 * @name notNestedPropertyVal
6087 * @param {Object} object
6088 * @param {String} property
6089 * @param {Mixed} value
6090 * @param {String} message
6091 * @namespace Assert
6092 * @api public
6093 */
6094
6095 assert.notNestedPropertyVal = function (obj, prop, val, msg) {
6096 new Assertion(obj, msg, assert.notNestedPropertyVal, true)
6097 .to.not.have.nested.property(prop, val);
6098 };
6099
6100 /**
6101 * ### .deepNestedPropertyVal(object, property, value, [message])
6102 *
6103 * Asserts that `object` has a property named by `property` with a value given
6104 * by `value`. `property` can use dot- and bracket-notation for nested
6105 * reference. Uses a deep equality check.
6106 *
6107 * assert.deepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { matcha: 'yum' });
6108 *
6109 * @name deepNestedPropertyVal
6110 * @param {Object} object
6111 * @param {String} property
6112 * @param {Mixed} value
6113 * @param {String} message
6114 * @namespace Assert
6115 * @api public
6116 */
6117
6118 assert.deepNestedPropertyVal = function (obj, prop, val, msg) {
6119 new Assertion(obj, msg, assert.deepNestedPropertyVal, true)
6120 .to.have.deep.nested.property(prop, val);
6121 };
6122
6123 /**
6124 * ### .notDeepNestedPropertyVal(object, property, value, [message])
6125 *
6126 * Asserts that `object` does _not_ have a property named by `property` with
6127 * value given by `value`. `property` can use dot- and bracket-notation for
6128 * nested reference. Uses a deep equality check.
6129 *
6130 * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { oolong: 'yum' });
6131 * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { matcha: 'yuck' });
6132 * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.black', { matcha: 'yum' });
6133 *
6134 * @name notDeepNestedPropertyVal
6135 * @param {Object} object
6136 * @param {String} property
6137 * @param {Mixed} value
6138 * @param {String} message
6139 * @namespace Assert
6140 * @api public
6141 */
6142
6143 assert.notDeepNestedPropertyVal = function (obj, prop, val, msg) {
6144 new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true)
6145 .to.not.have.deep.nested.property(prop, val);
6146 }
6147
6148 /**
6149 * ### .lengthOf(object, length, [message])
6150 *
6151 * Asserts that `object` has a `length` or `size` with the expected value.
6152 *
6153 * assert.lengthOf([1,2,3], 3, 'array has length of 3');
6154 * assert.lengthOf('foobar', 6, 'string has length of 6');
6155 * assert.lengthOf(new Set([1,2,3]), 3, 'set has size of 3');
6156 * assert.lengthOf(new Map([['a',1],['b',2],['c',3]]), 3, 'map has size of 3');
6157 *
6158 * @name lengthOf
6159 * @param {Mixed} object
6160 * @param {Number} length
6161 * @param {String} message
6162 * @namespace Assert
6163 * @api public
6164 */
6165
6166 assert.lengthOf = function (exp, len, msg) {
6167 new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
6168 };
6169
6170 /**
6171 * ### .hasAnyKeys(object, [keys], [message])
6172 *
6173 * Asserts that `object` has at least one of the `keys` provided.
6174 * You can also provide a single object instead of a `keys` array and its keys
6175 * will be used as the expected set of keys.
6176 *
6177 * assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'iDontExist', 'baz']);
6178 * assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, iDontExist: 99, baz: 1337});
6179 * assert.hasAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']);
6180 * assert.hasAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']);
6181 *
6182 * @name hasAnyKeys
6183 * @param {Mixed} object
6184 * @param {Array|Object} keys
6185 * @param {String} message
6186 * @namespace Assert
6187 * @api public
6188 */
6189
6190 assert.hasAnyKeys = function (obj, keys, msg) {
6191 new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
6192 }
6193
6194 /**
6195 * ### .hasAllKeys(object, [keys], [message])
6196 *
6197 * Asserts that `object` has all and only all of the `keys` provided.
6198 * You can also provide a single object instead of a `keys` array and its keys
6199 * will be used as the expected set of keys.
6200 *
6201 * assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']);
6202 * assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337]);
6203 * assert.hasAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']);
6204 * assert.hasAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']);
6205 *
6206 * @name hasAllKeys
6207 * @param {Mixed} object
6208 * @param {String[]} keys
6209 * @param {String} message
6210 * @namespace Assert
6211 * @api public
6212 */
6213
6214 assert.hasAllKeys = function (obj, keys, msg) {
6215 new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
6216 }
6217
6218 /**
6219 * ### .containsAllKeys(object, [keys], [message])
6220 *
6221 * Asserts that `object` has all of the `keys` provided but may have more keys not listed.
6222 * You can also provide a single object instead of a `keys` array and its keys
6223 * will be used as the expected set of keys.
6224 *
6225 * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'baz']);
6226 * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']);
6227 * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, baz: 1337});
6228 * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337});
6229 * assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}]);
6230 * assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']);
6231 * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}]);
6232 * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']);
6233 *
6234 * @name containsAllKeys
6235 * @param {Mixed} object
6236 * @param {String[]} keys
6237 * @param {String} message
6238 * @namespace Assert
6239 * @api public
6240 */
6241
6242 assert.containsAllKeys = function (obj, keys, msg) {
6243 new Assertion(obj, msg, assert.containsAllKeys, true)
6244 .to.contain.all.keys(keys);
6245 }
6246
6247 /**
6248 * ### .doesNotHaveAnyKeys(object, [keys], [message])
6249 *
6250 * Asserts that `object` has none of the `keys` provided.
6251 * You can also provide a single object instead of a `keys` array and its keys
6252 * will be used as the expected set of keys.
6253 *
6254 * assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']);
6255 * assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'});
6256 * assert.doesNotHaveAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']);
6257 * assert.doesNotHaveAnyKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']);
6258 *
6259 * @name doesNotHaveAnyKeys
6260 * @param {Mixed} object
6261 * @param {String[]} keys
6262 * @param {String} message
6263 * @namespace Assert
6264 * @api public
6265 */
6266
6267 assert.doesNotHaveAnyKeys = function (obj, keys, msg) {
6268 new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true)
6269 .to.not.have.any.keys(keys);
6270 }
6271
6272 /**
6273 * ### .doesNotHaveAllKeys(object, [keys], [message])
6274 *
6275 * Asserts that `object` does not have at least one of the `keys` provided.
6276 * You can also provide a single object instead of a `keys` array and its keys
6277 * will be used as the expected set of keys.
6278 *
6279 * assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']);
6280 * assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'});
6281 * assert.doesNotHaveAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']);
6282 * assert.doesNotHaveAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']);
6283 *
6284 * @name doesNotHaveAllKeys
6285 * @param {Mixed} object
6286 * @param {String[]} keys
6287 * @param {String} message
6288 * @namespace Assert
6289 * @api public
6290 */
6291
6292 assert.doesNotHaveAllKeys = function (obj, keys, msg) {
6293 new Assertion(obj, msg, assert.doesNotHaveAllKeys, true)
6294 .to.not.have.all.keys(keys);
6295 }
6296
6297 /**
6298 * ### .hasAnyDeepKeys(object, [keys], [message])
6299 *
6300 * Asserts that `object` has at least one of the `keys` provided.
6301 * Since Sets and Maps can have objects as keys you can use this assertion to perform
6302 * a deep comparison.
6303 * You can also provide a single object instead of a `keys` array and its keys
6304 * will be used as the expected set of keys.
6305 *
6306 * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'});
6307 * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), [{one: 'one'}, {two: 'two'}]);
6308 * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]);
6309 * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'});
6310 * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]);
6311 * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
6312 *
6313 * @name hasAnyDeepKeys
6314 * @param {Mixed} object
6315 * @param {Array|Object} keys
6316 * @param {String} message
6317 * @namespace Assert
6318 * @api public
6319 */
6320
6321 assert.hasAnyDeepKeys = function (obj, keys, msg) {
6322 new Assertion(obj, msg, assert.hasAnyDeepKeys, true)
6323 .to.have.any.deep.keys(keys);
6324 }
6325
6326 /**
6327 * ### .hasAllDeepKeys(object, [keys], [message])
6328 *
6329 * Asserts that `object` has all and only all of the `keys` provided.
6330 * Since Sets and Maps can have objects as keys you can use this assertion to perform
6331 * a deep comparison.
6332 * You can also provide a single object instead of a `keys` array and its keys
6333 * will be used as the expected set of keys.
6334 *
6335 * assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne']]), {one: 'one'});
6336 * assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]);
6337 * assert.hasAllDeepKeys(new Set([{one: 'one'}]), {one: 'one'});
6338 * assert.hasAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
6339 *
6340 * @name hasAllDeepKeys
6341 * @param {Mixed} object
6342 * @param {Array|Object} keys
6343 * @param {String} message
6344 * @namespace Assert
6345 * @api public
6346 */
6347
6348 assert.hasAllDeepKeys = function (obj, keys, msg) {
6349 new Assertion(obj, msg, assert.hasAllDeepKeys, true)
6350 .to.have.all.deep.keys(keys);
6351 }
6352
6353 /**
6354 * ### .containsAllDeepKeys(object, [keys], [message])
6355 *
6356 * Asserts that `object` contains all of the `keys` provided.
6357 * Since Sets and Maps can have objects as keys you can use this assertion to perform
6358 * a deep comparison.
6359 * You can also provide a single object instead of a `keys` array and its keys
6360 * will be used as the expected set of keys.
6361 *
6362 * assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'});
6363 * assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]);
6364 * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'});
6365 * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
6366 *
6367 * @name containsAllDeepKeys
6368 * @param {Mixed} object
6369 * @param {Array|Object} keys
6370 * @param {String} message
6371 * @namespace Assert
6372 * @api public
6373 */
6374
6375 assert.containsAllDeepKeys = function (obj, keys, msg) {
6376 new Assertion(obj, msg, assert.containsAllDeepKeys, true)
6377 .to.contain.all.deep.keys(keys);
6378 }
6379
6380 /**
6381 * ### .doesNotHaveAnyDeepKeys(object, [keys], [message])
6382 *
6383 * Asserts that `object` has none of the `keys` provided.
6384 * Since Sets and Maps can have objects as keys you can use this assertion to perform
6385 * a deep comparison.
6386 * You can also provide a single object instead of a `keys` array and its keys
6387 * will be used as the expected set of keys.
6388 *
6389 * assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'});
6390 * assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {fifty: 'fifty'}]);
6391 * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'});
6392 * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{twenty: 'twenty'}, {fifty: 'fifty'}]);
6393 *
6394 * @name doesNotHaveAnyDeepKeys
6395 * @param {Mixed} object
6396 * @param {Array|Object} keys
6397 * @param {String} message
6398 * @namespace Assert
6399 * @api public
6400 */
6401
6402 assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) {
6403 new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true)
6404 .to.not.have.any.deep.keys(keys);
6405 }
6406
6407 /**
6408 * ### .doesNotHaveAllDeepKeys(object, [keys], [message])
6409 *
6410 * Asserts that `object` does not have at least one of the `keys` provided.
6411 * Since Sets and Maps can have objects as keys you can use this assertion to perform
6412 * a deep comparison.
6413 * You can also provide a single object instead of a `keys` array and its keys
6414 * will be used as the expected set of keys.
6415 *
6416 * assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'});
6417 * assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {one: 'one'}]);
6418 * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'});
6419 * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {fifty: 'fifty'}]);
6420 *
6421 * @name doesNotHaveAllDeepKeys
6422 * @param {Mixed} object
6423 * @param {Array|Object} keys
6424 * @param {String} message
6425 * @namespace Assert
6426 * @api public
6427 */
6428
6429 assert.doesNotHaveAllDeepKeys = function (obj, keys, msg) {
6430 new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true)
6431 .to.not.have.all.deep.keys(keys);
6432 }
6433
6434 /**
6435 * ### .throws(fn, [errorLike/string/regexp], [string/regexp], [message])
6436 *
6437 * If `errorLike` is an `Error` constructor, asserts that `fn` will throw an error that is an
6438 * instance of `errorLike`.
6439 * If `errorLike` is an `Error` instance, asserts that the error thrown is the same
6440 * instance as `errorLike`.
6441 * If `errMsgMatcher` is provided, it also asserts that the error thrown will have a
6442 * message matching `errMsgMatcher`.
6443 *
6444 * assert.throws(fn, 'Error thrown must have this msg');
6445 * assert.throws(fn, /Error thrown must have a msg that matches this/);
6446 * assert.throws(fn, ReferenceError);
6447 * assert.throws(fn, errorInstance);
6448 * assert.throws(fn, ReferenceError, 'Error thrown must be a ReferenceError and have this msg');
6449 * assert.throws(fn, errorInstance, 'Error thrown must be the same errorInstance and have this msg');
6450 * assert.throws(fn, ReferenceError, /Error thrown must be a ReferenceError and match this/);
6451 * assert.throws(fn, errorInstance, /Error thrown must be the same errorInstance and match this/);
6452 *
6453 * @name throws
6454 * @alias throw
6455 * @alias Throw
6456 * @param {Function} fn
6457 * @param {ErrorConstructor|Error} errorLike
6458 * @param {RegExp|String} errMsgMatcher
6459 * @param {String} message
6460 * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
6461 * @namespace Assert
6462 * @api public
6463 */
6464
6465 assert.throws = function (fn, errorLike, errMsgMatcher, msg) {
6466 if ('string' === typeof errorLike || errorLike instanceof RegExp) {
6467 errMsgMatcher = errorLike;
6468 errorLike = null;
6469 }
6470
6471 var assertErr = new Assertion(fn, msg, assert.throws, true)
6472 .to.throw(errorLike, errMsgMatcher);
6473 return flag(assertErr, 'object');
6474 };
6475
6476 /**
6477 * ### .doesNotThrow(fn, [errorLike/string/regexp], [string/regexp], [message])
6478 *
6479 * If `errorLike` is an `Error` constructor, asserts that `fn` will _not_ throw an error that is an
6480 * instance of `errorLike`.
6481 * If `errorLike` is an `Error` instance, asserts that the error thrown is _not_ the same
6482 * instance as `errorLike`.
6483 * If `errMsgMatcher` is provided, it also asserts that the error thrown will _not_ have a
6484 * message matching `errMsgMatcher`.
6485 *
6486 * assert.doesNotThrow(fn, 'Any Error thrown must not have this message');
6487 * assert.doesNotThrow(fn, /Any Error thrown must not match this/);
6488 * assert.doesNotThrow(fn, Error);
6489 * assert.doesNotThrow(fn, errorInstance);
6490 * assert.doesNotThrow(fn, Error, 'Error must not have this message');
6491 * assert.doesNotThrow(fn, errorInstance, 'Error must not have this message');
6492 * assert.doesNotThrow(fn, Error, /Error must not match this/);
6493 * assert.doesNotThrow(fn, errorInstance, /Error must not match this/);
6494 *
6495 * @name doesNotThrow
6496 * @param {Function} fn
6497 * @param {ErrorConstructor} errorLike
6498 * @param {RegExp|String} errMsgMatcher
6499 * @param {String} message
6500 * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
6501 * @namespace Assert
6502 * @api public
6503 */
6504
6505 assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, msg) {
6506 if ('string' === typeof errorLike || errorLike instanceof RegExp) {
6507 errMsgMatcher = errorLike;
6508 errorLike = null;
6509 }
6510
6511 new Assertion(fn, msg, assert.doesNotThrow, true)
6512 .to.not.throw(errorLike, errMsgMatcher);
6513 };
6514
6515 /**
6516 * ### .operator(val1, operator, val2, [message])
6517 *
6518 * Compares two values using `operator`.
6519 *
6520 * assert.operator(1, '<', 2, 'everything is ok');
6521 * assert.operator(1, '>', 2, 'this will fail');
6522 *
6523 * @name operator
6524 * @param {Mixed} val1
6525 * @param {String} operator
6526 * @param {Mixed} val2
6527 * @param {String} message
6528 * @namespace Assert
6529 * @api public
6530 */
6531
6532 assert.operator = function (val, operator, val2, msg) {
6533 var ok;
6534 switch(operator) {
6535 case '==':
6536 ok = val == val2;
6537 break;
6538 case '===':
6539 ok = val === val2;
6540 break;
6541 case '>':
6542 ok = val > val2;
6543 break;
6544 case '>=':
6545 ok = val >= val2;
6546 break;
6547 case '<':
6548 ok = val < val2;
6549 break;
6550 case '<=':
6551 ok = val <= val2;
6552 break;
6553 case '!=':
6554 ok = val != val2;
6555 break;
6556 case '!==':
6557 ok = val !== val2;
6558 break;
6559 default:
6560 msg = msg ? msg + ': ' : msg;
6561 throw new chai.AssertionError(
6562 msg + 'Invalid operator "' + operator + '"',
6563 undefined,
6564 assert.operator
6565 );
6566 }
6567 var test = new Assertion(ok, msg, assert.operator, true);
6568 test.assert(
6569 true === flag(test, 'object')
6570 , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)
6571 , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );
6572 };
6573
6574 /**
6575 * ### .closeTo(actual, expected, delta, [message])
6576 *
6577 * Asserts that the target is equal `expected`, to within a +/- `delta` range.
6578 *
6579 * assert.closeTo(1.5, 1, 0.5, 'numbers are close');
6580 *
6581 * @name closeTo
6582 * @param {Number} actual
6583 * @param {Number} expected
6584 * @param {Number} delta
6585 * @param {String} message
6586 * @namespace Assert
6587 * @api public
6588 */
6589
6590 assert.closeTo = function (act, exp, delta, msg) {
6591 new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
6592 };
6593
6594 /**
6595 * ### .approximately(actual, expected, delta, [message])
6596 *
6597 * Asserts that the target is equal `expected`, to within a +/- `delta` range.
6598 *
6599 * assert.approximately(1.5, 1, 0.5, 'numbers are close');
6600 *
6601 * @name approximately
6602 * @param {Number} actual
6603 * @param {Number} expected
6604 * @param {Number} delta
6605 * @param {String} message
6606 * @namespace Assert
6607 * @api public
6608 */
6609
6610 assert.approximately = function (act, exp, delta, msg) {
6611 new Assertion(act, msg, assert.approximately, true)
6612 .to.be.approximately(exp, delta);
6613 };
6614
6615 /**
6616 * ### .sameMembers(set1, set2, [message])
6617 *
6618 * Asserts that `set1` and `set2` have the same members in any order. Uses a
6619 * strict equality check (===).
6620 *
6621 * assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
6622 *
6623 * @name sameMembers
6624 * @param {Array} set1
6625 * @param {Array} set2
6626 * @param {String} message
6627 * @namespace Assert
6628 * @api public
6629 */
6630
6631 assert.sameMembers = function (set1, set2, msg) {
6632 new Assertion(set1, msg, assert.sameMembers, true)
6633 .to.have.same.members(set2);
6634 }
6635
6636 /**
6637 * ### .notSameMembers(set1, set2, [message])
6638 *
6639 * Asserts that `set1` and `set2` don't have the same members in any order.
6640 * Uses a strict equality check (===).
6641 *
6642 * assert.notSameMembers([ 1, 2, 3 ], [ 5, 1, 3 ], 'not same members');
6643 *
6644 * @name notSameMembers
6645 * @param {Array} set1
6646 * @param {Array} set2
6647 * @param {String} message
6648 * @namespace Assert
6649 * @api public
6650 */
6651
6652 assert.notSameMembers = function (set1, set2, msg) {
6653 new Assertion(set1, msg, assert.notSameMembers, true)
6654 .to.not.have.same.members(set2);
6655 }
6656
6657 /**
6658 * ### .sameDeepMembers(set1, set2, [message])
6659 *
6660 * Asserts that `set1` and `set2` have the same members in any order. Uses a
6661 * deep equality check.
6662 *
6663 * assert.sameDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [{ b: 2 }, { a: 1 }, { c: 3 }], 'same deep members');
6664 *
6665 * @name sameDeepMembers
6666 * @param {Array} set1
6667 * @param {Array} set2
6668 * @param {String} message
6669 * @namespace Assert
6670 * @api public
6671 */
6672
6673 assert.sameDeepMembers = function (set1, set2, msg) {
6674 new Assertion(set1, msg, assert.sameDeepMembers, true)
6675 .to.have.same.deep.members(set2);
6676 }
6677
6678 /**
6679 * ### .notSameDeepMembers(set1, set2, [message])
6680 *
6681 * Asserts that `set1` and `set2` don't have the same members in any order.
6682 * Uses a deep equality check.
6683 *
6684 * assert.notSameDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [{ b: 2 }, { a: 1 }, { f: 5 }], 'not same deep members');
6685 *
6686 * @name notSameDeepMembers
6687 * @param {Array} set1
6688 * @param {Array} set2
6689 * @param {String} message
6690 * @namespace Assert
6691 * @api public
6692 */
6693
6694 assert.notSameDeepMembers = function (set1, set2, msg) {
6695 new Assertion(set1, msg, assert.notSameDeepMembers, true)
6696 .to.not.have.same.deep.members(set2);
6697 }
6698
6699 /**
6700 * ### .sameOrderedMembers(set1, set2, [message])
6701 *
6702 * Asserts that `set1` and `set2` have the same members in the same order.
6703 * Uses a strict equality check (===).
6704 *
6705 * assert.sameOrderedMembers([ 1, 2, 3 ], [ 1, 2, 3 ], 'same ordered members');
6706 *
6707 * @name sameOrderedMembers
6708 * @param {Array} set1
6709 * @param {Array} set2
6710 * @param {String} message
6711 * @namespace Assert
6712 * @api public
6713 */
6714
6715 assert.sameOrderedMembers = function (set1, set2, msg) {
6716 new Assertion(set1, msg, assert.sameOrderedMembers, true)
6717 .to.have.same.ordered.members(set2);
6718 }
6719
6720 /**
6721 * ### .notSameOrderedMembers(set1, set2, [message])
6722 *
6723 * Asserts that `set1` and `set2` don't have the same members in the same
6724 * order. Uses a strict equality check (===).
6725 *
6726 * assert.notSameOrderedMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'not same ordered members');
6727 *
6728 * @name notSameOrderedMembers
6729 * @param {Array} set1
6730 * @param {Array} set2
6731 * @param {String} message
6732 * @namespace Assert
6733 * @api public
6734 */
6735
6736 assert.notSameOrderedMembers = function (set1, set2, msg) {
6737 new Assertion(set1, msg, assert.notSameOrderedMembers, true)
6738 .to.not.have.same.ordered.members(set2);
6739 }
6740
6741 /**
6742 * ### .sameDeepOrderedMembers(set1, set2, [message])
6743 *
6744 * Asserts that `set1` and `set2` have the same members in the same order.
6745 * Uses a deep equality check.
6746 *
6747 * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
6748 *
6749 * @name sameDeepOrderedMembers
6750 * @param {Array} set1
6751 * @param {Array} set2
6752 * @param {String} message
6753 * @namespace Assert
6754 * @api public
6755 */
6756
6757 assert.sameDeepOrderedMembers = function (set1, set2, msg) {
6758 new Assertion(set1, msg, assert.sameDeepOrderedMembers, true)
6759 .to.have.same.deep.ordered.members(set2);
6760 }
6761
6762 /**
6763 * ### .notSameDeepOrderedMembers(set1, set2, [message])
6764 *
6765 * Asserts that `set1` and `set2` don't have the same members in the same
6766 * order. Uses a deep equality check.
6767 *
6768 * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
6769 * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
6770 *
6771 * @name notSameDeepOrderedMembers
6772 * @param {Array} set1
6773 * @param {Array} set2
6774 * @param {String} message
6775 * @namespace Assert
6776 * @api public
6777 */
6778
6779 assert.notSameDeepOrderedMembers = function (set1, set2, msg) {
6780 new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true)
6781 .to.not.have.same.deep.ordered.members(set2);
6782 }
6783
6784 /**
6785 * ### .includeMembers(superset, subset, [message])
6786 *
6787 * Asserts that `subset` is included in `superset` in any order. Uses a
6788 * strict equality check (===). Duplicates are ignored.
6789 *
6790 * assert.includeMembers([ 1, 2, 3 ], [ 2, 1, 2 ], 'include members');
6791 *
6792 * @name includeMembers
6793 * @param {Array} superset
6794 * @param {Array} subset
6795 * @param {String} message
6796 * @namespace Assert
6797 * @api public
6798 */
6799
6800 assert.includeMembers = function (superset, subset, msg) {
6801 new Assertion(superset, msg, assert.includeMembers, true)
6802 .to.include.members(subset);
6803 }
6804
6805 /**
6806 * ### .notIncludeMembers(superset, subset, [message])
6807 *
6808 * Asserts that `subset` isn't included in `superset` in any order. Uses a
6809 * strict equality check (===). Duplicates are ignored.
6810 *
6811 * assert.notIncludeMembers([ 1, 2, 3 ], [ 5, 1 ], 'not include members');
6812 *
6813 * @name notIncludeMembers
6814 * @param {Array} superset
6815 * @param {Array} subset
6816 * @param {String} message
6817 * @namespace Assert
6818 * @api public
6819 */
6820
6821 assert.notIncludeMembers = function (superset, subset, msg) {
6822 new Assertion(superset, msg, assert.notIncludeMembers, true)
6823 .to.not.include.members(subset);
6824 }
6825
6826 /**
6827 * ### .includeDeepMembers(superset, subset, [message])
6828 *
6829 * Asserts that `subset` is included in `superset` in any order. Uses a deep
6830 * equality check. Duplicates are ignored.
6831 *
6832 * assert.includeDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { b: 2 } ], 'include deep members');
6833 *
6834 * @name includeDeepMembers
6835 * @param {Array} superset
6836 * @param {Array} subset
6837 * @param {String} message
6838 * @namespace Assert
6839 * @api public
6840 */
6841
6842 assert.includeDeepMembers = function (superset, subset, msg) {
6843 new Assertion(superset, msg, assert.includeDeepMembers, true)
6844 .to.include.deep.members(subset);
6845 }
6846
6847 /**
6848 * ### .notIncludeDeepMembers(superset, subset, [message])
6849 *
6850 * Asserts that `subset` isn't included in `superset` in any order. Uses a
6851 * deep equality check. Duplicates are ignored.
6852 *
6853 * assert.notIncludeDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { f: 5 } ], 'not include deep members');
6854 *
6855 * @name notIncludeDeepMembers
6856 * @param {Array} superset
6857 * @param {Array} subset
6858 * @param {String} message
6859 * @namespace Assert
6860 * @api public
6861 */
6862
6863 assert.notIncludeDeepMembers = function (superset, subset, msg) {
6864 new Assertion(superset, msg, assert.notIncludeDeepMembers, true)
6865 .to.not.include.deep.members(subset);
6866 }
6867
6868 /**
6869 * ### .includeOrderedMembers(superset, subset, [message])
6870 *
6871 * Asserts that `subset` is included in `superset` in the same order
6872 * beginning with the first element in `superset`. Uses a strict equality
6873 * check (===).
6874 *
6875 * assert.includeOrderedMembers([ 1, 2, 3 ], [ 1, 2 ], 'include ordered members');
6876 *
6877 * @name includeOrderedMembers
6878 * @param {Array} superset
6879 * @param {Array} subset
6880 * @param {String} message
6881 * @namespace Assert
6882 * @api public
6883 */
6884
6885 assert.includeOrderedMembers = function (superset, subset, msg) {
6886 new Assertion(superset, msg, assert.includeOrderedMembers, true)
6887 .to.include.ordered.members(subset);
6888 }
6889
6890 /**
6891 * ### .notIncludeOrderedMembers(superset, subset, [message])
6892 *
6893 * Asserts that `subset` isn't included in `superset` in the same order
6894 * beginning with the first element in `superset`. Uses a strict equality
6895 * check (===).
6896 *
6897 * assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 1 ], 'not include ordered members');
6898 * assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 3 ], 'not include ordered members');
6899 *
6900 * @name notIncludeOrderedMembers
6901 * @param {Array} superset
6902 * @param {Array} subset
6903 * @param {String} message
6904 * @namespace Assert
6905 * @api public
6906 */
6907
6908 assert.notIncludeOrderedMembers = function (superset, subset, msg) {
6909 new Assertion(superset, msg, assert.notIncludeOrderedMembers, true)
6910 .to.not.include.ordered.members(subset);
6911 }
6912
6913 /**
6914 * ### .includeDeepOrderedMembers(superset, subset, [message])
6915 *
6916 * Asserts that `subset` is included in `superset` in the same order
6917 * beginning with the first element in `superset`. Uses a deep equality
6918 * check.
6919 *
6920 * assert.includeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 } ], 'include deep ordered members');
6921 *
6922 * @name includeDeepOrderedMembers
6923 * @param {Array} superset
6924 * @param {Array} subset
6925 * @param {String} message
6926 * @namespace Assert
6927 * @api public
6928 */
6929
6930 assert.includeDeepOrderedMembers = function (superset, subset, msg) {
6931 new Assertion(superset, msg, assert.includeDeepOrderedMembers, true)
6932 .to.include.deep.ordered.members(subset);
6933 }
6934
6935 /**
6936 * ### .notIncludeDeepOrderedMembers(superset, subset, [message])
6937 *
6938 * Asserts that `subset` isn't included in `superset` in the same order
6939 * beginning with the first element in `superset`. Uses a deep equality
6940 * check.
6941 *
6942 * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { f: 5 } ], 'not include deep ordered members');
6943 * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 } ], 'not include deep ordered members');
6944 * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { c: 3 } ], 'not include deep ordered members');
6945 *
6946 * @name notIncludeDeepOrderedMembers
6947 * @param {Array} superset
6948 * @param {Array} subset
6949 * @param {String} message
6950 * @namespace Assert
6951 * @api public
6952 */
6953
6954 assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) {
6955 new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true)
6956 .to.not.include.deep.ordered.members(subset);
6957 }
6958
6959 /**
6960 * ### .oneOf(inList, list, [message])
6961 *
6962 * Asserts that non-object, non-array value `inList` appears in the flat array `list`.
6963 *
6964 * assert.oneOf(1, [ 2, 1 ], 'Not found in list');
6965 *
6966 * @name oneOf
6967 * @param {*} inList
6968 * @param {Array<*>} list
6969 * @param {String} message
6970 * @namespace Assert
6971 * @api public
6972 */
6973
6974 assert.oneOf = function (inList, list, msg) {
6975 new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
6976 }
6977
6978 /**
6979 * ### .changes(function, object, property, [message])
6980 *
6981 * Asserts that a function changes the value of a property.
6982 *
6983 * var obj = { val: 10 };
6984 * var fn = function() { obj.val = 22 };
6985 * assert.changes(fn, obj, 'val');
6986 *
6987 * @name changes
6988 * @param {Function} modifier function
6989 * @param {Object} object or getter function
6990 * @param {String} property name _optional_
6991 * @param {String} message _optional_
6992 * @namespace Assert
6993 * @api public
6994 */
6995
6996 assert.changes = function (fn, obj, prop, msg) {
6997 if (arguments.length === 3 && typeof obj === 'function') {
6998 msg = prop;
6999 prop = null;
7000 }
7001
7002 new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
7003 }
7004
7005 /**
7006 * ### .changesBy(function, object, property, delta, [message])
7007 *
7008 * Asserts that a function changes the value of a property by an amount (delta).
7009 *
7010 * var obj = { val: 10 };
7011 * var fn = function() { obj.val += 2 };
7012 * assert.changesBy(fn, obj, 'val', 2);
7013 *
7014 * @name changesBy
7015 * @param {Function} modifier function
7016 * @param {Object} object or getter function
7017 * @param {String} property name _optional_
7018 * @param {Number} change amount (delta)
7019 * @param {String} message _optional_
7020 * @namespace Assert
7021 * @api public
7022 */
7023
7024 assert.changesBy = function (fn, obj, prop, delta, msg) {
7025 if (arguments.length === 4 && typeof obj === 'function') {
7026 var tmpMsg = delta;
7027 delta = prop;
7028 msg = tmpMsg;
7029 } else if (arguments.length === 3) {
7030 delta = prop;
7031 prop = null;
7032 }
7033
7034 new Assertion(fn, msg, assert.changesBy, true)
7035 .to.change(obj, prop).by(delta);
7036 }
7037
7038 /**
7039 * ### .doesNotChange(function, object, property, [message])
7040 *
7041 * Asserts that a function does not change the value of a property.
7042 *
7043 * var obj = { val: 10 };
7044 * var fn = function() { console.log('foo'); };
7045 * assert.doesNotChange(fn, obj, 'val');
7046 *
7047 * @name doesNotChange
7048 * @param {Function} modifier function
7049 * @param {Object} object or getter function
7050 * @param {String} property name _optional_
7051 * @param {String} message _optional_
7052 * @namespace Assert
7053 * @api public
7054 */
7055
7056 assert.doesNotChange = function (fn, obj, prop, msg) {
7057 if (arguments.length === 3 && typeof obj === 'function') {
7058 msg = prop;
7059 prop = null;
7060 }
7061
7062 return new Assertion(fn, msg, assert.doesNotChange, true)
7063 .to.not.change(obj, prop);
7064 }
7065
7066 /**
7067 * ### .changesButNotBy(function, object, property, delta, [message])
7068 *
7069 * Asserts that a function does not change the value of a property or of a function's return value by an amount (delta)
7070 *
7071 * var obj = { val: 10 };
7072 * var fn = function() { obj.val += 10 };
7073 * assert.changesButNotBy(fn, obj, 'val', 5);
7074 *
7075 * @name changesButNotBy
7076 * @param {Function} modifier function
7077 * @param {Object} object or getter function
7078 * @param {String} property name _optional_
7079 * @param {Number} change amount (delta)
7080 * @param {String} message _optional_
7081 * @namespace Assert
7082 * @api public
7083 */
7084
7085 assert.changesButNotBy = function (fn, obj, prop, delta, msg) {
7086 if (arguments.length === 4 && typeof obj === 'function') {
7087 var tmpMsg = delta;
7088 delta = prop;
7089 msg = tmpMsg;
7090 } else if (arguments.length === 3) {
7091 delta = prop;
7092 prop = null;
7093 }
7094
7095 new Assertion(fn, msg, assert.changesButNotBy, true)
7096 .to.change(obj, prop).but.not.by(delta);
7097 }
7098
7099 /**
7100 * ### .increases(function, object, property, [message])
7101 *
7102 * Asserts that a function increases a numeric object property.
7103 *
7104 * var obj = { val: 10 };
7105 * var fn = function() { obj.val = 13 };
7106 * assert.increases(fn, obj, 'val');
7107 *
7108 * @name increases
7109 * @param {Function} modifier function
7110 * @param {Object} object or getter function
7111 * @param {String} property name _optional_
7112 * @param {String} message _optional_
7113 * @namespace Assert
7114 * @api public
7115 */
7116
7117 assert.increases = function (fn, obj, prop, msg) {
7118 if (arguments.length === 3 && typeof obj === 'function') {
7119 msg = prop;
7120 prop = null;
7121 }
7122
7123 return new Assertion(fn, msg, assert.increases, true)
7124 .to.increase(obj, prop);
7125 }
7126
7127 /**
7128 * ### .increasesBy(function, object, property, delta, [message])
7129 *
7130 * Asserts that a function increases a numeric object property or a function's return value by an amount (delta).
7131 *
7132 * var obj = { val: 10 };
7133 * var fn = function() { obj.val += 10 };
7134 * assert.increasesBy(fn, obj, 'val', 10);
7135 *
7136 * @name increasesBy
7137 * @param {Function} modifier function
7138 * @param {Object} object or getter function
7139 * @param {String} property name _optional_
7140 * @param {Number} change amount (delta)
7141 * @param {String} message _optional_
7142 * @namespace Assert
7143 * @api public
7144 */
7145
7146 assert.increasesBy = function (fn, obj, prop, delta, msg) {
7147 if (arguments.length === 4 && typeof obj === 'function') {
7148 var tmpMsg = delta;
7149 delta = prop;
7150 msg = tmpMsg;
7151 } else if (arguments.length === 3) {
7152 delta = prop;
7153 prop = null;
7154 }
7155
7156 new Assertion(fn, msg, assert.increasesBy, true)
7157 .to.increase(obj, prop).by(delta);
7158 }
7159
7160 /**
7161 * ### .doesNotIncrease(function, object, property, [message])
7162 *
7163 * Asserts that a function does not increase a numeric object property.
7164 *
7165 * var obj = { val: 10 };
7166 * var fn = function() { obj.val = 8 };
7167 * assert.doesNotIncrease(fn, obj, 'val');
7168 *
7169 * @name doesNotIncrease
7170 * @param {Function} modifier function
7171 * @param {Object} object or getter function
7172 * @param {String} property name _optional_
7173 * @param {String} message _optional_
7174 * @namespace Assert
7175 * @api public
7176 */
7177
7178 assert.doesNotIncrease = function (fn, obj, prop, msg) {
7179 if (arguments.length === 3 && typeof obj === 'function') {
7180 msg = prop;
7181 prop = null;
7182 }
7183
7184 return new Assertion(fn, msg, assert.doesNotIncrease, true)
7185 .to.not.increase(obj, prop);
7186 }
7187
7188 /**
7189 * ### .increasesButNotBy(function, object, property, delta, [message])
7190 *
7191 * Asserts that a function does not increase a numeric object property or function's return value by an amount (delta).
7192 *
7193 * var obj = { val: 10 };
7194 * var fn = function() { obj.val = 15 };
7195 * assert.increasesButNotBy(fn, obj, 'val', 10);
7196 *
7197 * @name increasesButNotBy
7198 * @param {Function} modifier function
7199 * @param {Object} object or getter function
7200 * @param {String} property name _optional_
7201 * @param {Number} change amount (delta)
7202 * @param {String} message _optional_
7203 * @namespace Assert
7204 * @api public
7205 */
7206
7207 assert.increasesButNotBy = function (fn, obj, prop, delta, msg) {
7208 if (arguments.length === 4 && typeof obj === 'function') {
7209 var tmpMsg = delta;
7210 delta = prop;
7211 msg = tmpMsg;
7212 } else if (arguments.length === 3) {
7213 delta = prop;
7214 prop = null;
7215 }
7216
7217 new Assertion(fn, msg, assert.increasesButNotBy, true)
7218 .to.increase(obj, prop).but.not.by(delta);
7219 }
7220
7221 /**
7222 * ### .decreases(function, object, property, [message])
7223 *
7224 * Asserts that a function decreases a numeric object property.
7225 *
7226 * var obj = { val: 10 };
7227 * var fn = function() { obj.val = 5 };
7228 * assert.decreases(fn, obj, 'val');
7229 *
7230 * @name decreases
7231 * @param {Function} modifier function
7232 * @param {Object} object or getter function
7233 * @param {String} property name _optional_
7234 * @param {String} message _optional_
7235 * @namespace Assert
7236 * @api public
7237 */
7238
7239 assert.decreases = function (fn, obj, prop, msg) {
7240 if (arguments.length === 3 && typeof obj === 'function') {
7241 msg = prop;
7242 prop = null;
7243 }
7244
7245 return new Assertion(fn, msg, assert.decreases, true)
7246 .to.decrease(obj, prop);
7247 }
7248
7249 /**
7250 * ### .decreasesBy(function, object, property, delta, [message])
7251 *
7252 * Asserts that a function decreases a numeric object property or a function's return value by an amount (delta)
7253 *
7254 * var obj = { val: 10 };
7255 * var fn = function() { obj.val -= 5 };
7256 * assert.decreasesBy(fn, obj, 'val', 5);
7257 *
7258 * @name decreasesBy
7259 * @param {Function} modifier function
7260 * @param {Object} object or getter function
7261 * @param {String} property name _optional_
7262 * @param {Number} change amount (delta)
7263 * @param {String} message _optional_
7264 * @namespace Assert
7265 * @api public
7266 */
7267
7268 assert.decreasesBy = function (fn, obj, prop, delta, msg) {
7269 if (arguments.length === 4 && typeof obj === 'function') {
7270 var tmpMsg = delta;
7271 delta = prop;
7272 msg = tmpMsg;
7273 } else if (arguments.length === 3) {
7274 delta = prop;
7275 prop = null;
7276 }
7277
7278 new Assertion(fn, msg, assert.decreasesBy, true)
7279 .to.decrease(obj, prop).by(delta);
7280 }
7281
7282 /**
7283 * ### .doesNotDecrease(function, object, property, [message])
7284 *
7285 * Asserts that a function does not decreases a numeric object property.
7286 *
7287 * var obj = { val: 10 };
7288 * var fn = function() { obj.val = 15 };
7289 * assert.doesNotDecrease(fn, obj, 'val');
7290 *
7291 * @name doesNotDecrease
7292 * @param {Function} modifier function
7293 * @param {Object} object or getter function
7294 * @param {String} property name _optional_
7295 * @param {String} message _optional_
7296 * @namespace Assert
7297 * @api public
7298 */
7299
7300 assert.doesNotDecrease = function (fn, obj, prop, msg) {
7301 if (arguments.length === 3 && typeof obj === 'function') {
7302 msg = prop;
7303 prop = null;
7304 }
7305
7306 return new Assertion(fn, msg, assert.doesNotDecrease, true)
7307 .to.not.decrease(obj, prop);
7308 }
7309
7310 /**
7311 * ### .doesNotDecreaseBy(function, object, property, delta, [message])
7312 *
7313 * Asserts that a function does not decreases a numeric object property or a function's return value by an amount (delta)
7314 *
7315 * var obj = { val: 10 };
7316 * var fn = function() { obj.val = 5 };
7317 * assert.doesNotDecreaseBy(fn, obj, 'val', 1);
7318 *
7319 * @name doesNotDecreaseBy
7320 * @param {Function} modifier function
7321 * @param {Object} object or getter function
7322 * @param {String} property name _optional_
7323 * @param {Number} change amount (delta)
7324 * @param {String} message _optional_
7325 * @namespace Assert
7326 * @api public
7327 */
7328
7329 assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) {
7330 if (arguments.length === 4 && typeof obj === 'function') {
7331 var tmpMsg = delta;
7332 delta = prop;
7333 msg = tmpMsg;
7334 } else if (arguments.length === 3) {
7335 delta = prop;
7336 prop = null;
7337 }
7338
7339 return new Assertion(fn, msg, assert.doesNotDecreaseBy, true)
7340 .to.not.decrease(obj, prop).by(delta);
7341 }
7342
7343 /**
7344 * ### .decreasesButNotBy(function, object, property, delta, [message])
7345 *
7346 * Asserts that a function does not decreases a numeric object property or a function's return value by an amount (delta)
7347 *
7348 * var obj = { val: 10 };
7349 * var fn = function() { obj.val = 5 };
7350 * assert.decreasesButNotBy(fn, obj, 'val', 1);
7351 *
7352 * @name decreasesButNotBy
7353 * @param {Function} modifier function
7354 * @param {Object} object or getter function
7355 * @param {String} property name _optional_
7356 * @param {Number} change amount (delta)
7357 * @param {String} message _optional_
7358 * @namespace Assert
7359 * @api public
7360 */
7361
7362 assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
7363 if (arguments.length === 4 && typeof obj === 'function') {
7364 var tmpMsg = delta;
7365 delta = prop;
7366 msg = tmpMsg;
7367 } else if (arguments.length === 3) {
7368 delta = prop;
7369 prop = null;
7370 }
7371
7372 new Assertion(fn, msg, assert.decreasesButNotBy, true)
7373 .to.decrease(obj, prop).but.not.by(delta);
7374 }
7375
7376 /*!
7377 * ### .ifError(object)
7378 *
7379 * Asserts if value is not a false value, and throws if it is a true value.
7380 * This is added to allow for chai to be a drop-in replacement for Node's
7381 * assert class.
7382 *
7383 * var err = new Error('I am a custom error');
7384 * assert.ifError(err); // Rethrows err!
7385 *
7386 * @name ifError
7387 * @param {Object} object
7388 * @namespace Assert
7389 * @api public
7390 */
7391
7392 assert.ifError = function (val) {
7393 if (val) {
7394 throw(val);
7395 }
7396 };
7397
7398 /**
7399 * ### .isExtensible(object)
7400 *
7401 * Asserts that `object` is extensible (can have new properties added to it).
7402 *
7403 * assert.isExtensible({});
7404 *
7405 * @name isExtensible
7406 * @alias extensible
7407 * @param {Object} object
7408 * @param {String} message _optional_
7409 * @namespace Assert
7410 * @api public
7411 */
7412
7413 assert.isExtensible = function (obj, msg) {
7414 new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
7415 };
7416
7417 /**
7418 * ### .isNotExtensible(object)
7419 *
7420 * Asserts that `object` is _not_ extensible.
7421 *
7422 * var nonExtensibleObject = Object.preventExtensions({});
7423 * var sealedObject = Object.seal({});
7424 * var frozenObject = Object.freeze({});
7425 *
7426 * assert.isNotExtensible(nonExtensibleObject);
7427 * assert.isNotExtensible(sealedObject);
7428 * assert.isNotExtensible(frozenObject);
7429 *
7430 * @name isNotExtensible
7431 * @alias notExtensible
7432 * @param {Object} object
7433 * @param {String} message _optional_
7434 * @namespace Assert
7435 * @api public
7436 */
7437
7438 assert.isNotExtensible = function (obj, msg) {
7439 new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
7440 };
7441
7442 /**
7443 * ### .isSealed(object)
7444 *
7445 * Asserts that `object` is sealed (cannot have new properties added to it
7446 * and its existing properties cannot be removed).
7447 *
7448 * var sealedObject = Object.seal({});
7449 * var frozenObject = Object.seal({});
7450 *
7451 * assert.isSealed(sealedObject);
7452 * assert.isSealed(frozenObject);
7453 *
7454 * @name isSealed
7455 * @alias sealed
7456 * @param {Object} object
7457 * @param {String} message _optional_
7458 * @namespace Assert
7459 * @api public
7460 */
7461
7462 assert.isSealed = function (obj, msg) {
7463 new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
7464 };
7465
7466 /**
7467 * ### .isNotSealed(object)
7468 *
7469 * Asserts that `object` is _not_ sealed.
7470 *
7471 * assert.isNotSealed({});
7472 *
7473 * @name isNotSealed
7474 * @alias notSealed
7475 * @param {Object} object
7476 * @param {String} message _optional_
7477 * @namespace Assert
7478 * @api public
7479 */
7480
7481 assert.isNotSealed = function (obj, msg) {
7482 new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
7483 };
7484
7485 /**
7486 * ### .isFrozen(object)
7487 *
7488 * Asserts that `object` is frozen (cannot have new properties added to it
7489 * and its existing properties cannot be modified).
7490 *
7491 * var frozenObject = Object.freeze({});
7492 * assert.frozen(frozenObject);
7493 *
7494 * @name isFrozen
7495 * @alias frozen
7496 * @param {Object} object
7497 * @param {String} message _optional_
7498 * @namespace Assert
7499 * @api public
7500 */
7501
7502 assert.isFrozen = function (obj, msg) {
7503 new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
7504 };
7505
7506 /**
7507 * ### .isNotFrozen(object)
7508 *
7509 * Asserts that `object` is _not_ frozen.
7510 *
7511 * assert.isNotFrozen({});
7512 *
7513 * @name isNotFrozen
7514 * @alias notFrozen
7515 * @param {Object} object
7516 * @param {String} message _optional_
7517 * @namespace Assert
7518 * @api public
7519 */
7520
7521 assert.isNotFrozen = function (obj, msg) {
7522 new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
7523 };
7524
7525 /**
7526 * ### .isEmpty(target)
7527 *
7528 * Asserts that the target does not contain any values.
7529 * For arrays and strings, it checks the `length` property.
7530 * For `Map` and `Set` instances, it checks the `size` property.
7531 * For non-function objects, it gets the count of own
7532 * enumerable string keys.
7533 *
7534 * assert.isEmpty([]);
7535 * assert.isEmpty('');
7536 * assert.isEmpty(new Map);
7537 * assert.isEmpty({});
7538 *
7539 * @name isEmpty
7540 * @alias empty
7541 * @param {Object|Array|String|Map|Set} target
7542 * @param {String} message _optional_
7543 * @namespace Assert
7544 * @api public
7545 */
7546
7547 assert.isEmpty = function(val, msg) {
7548 new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
7549 };
7550
7551 /**
7552 * ### .isNotEmpty(target)
7553 *
7554 * Asserts that the target contains values.
7555 * For arrays and strings, it checks the `length` property.
7556 * For `Map` and `Set` instances, it checks the `size` property.
7557 * For non-function objects, it gets the count of own
7558 * enumerable string keys.
7559 *
7560 * assert.isNotEmpty([1, 2]);
7561 * assert.isNotEmpty('34');
7562 * assert.isNotEmpty(new Set([5, 6]));
7563 * assert.isNotEmpty({ key: 7 });
7564 *
7565 * @name isNotEmpty
7566 * @alias notEmpty
7567 * @param {Object|Array|String|Map|Set} target
7568 * @param {String} message _optional_
7569 * @namespace Assert
7570 * @api public
7571 */
7572
7573 assert.isNotEmpty = function(val, msg) {
7574 new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
7575 };
7576
7577 /*!
7578 * Aliases.
7579 */
7580
7581 (function alias(name, as){
7582 assert[as] = assert[name];
7583 return alias;
7584 })
7585 ('isOk', 'ok')
7586 ('isNotOk', 'notOk')
7587 ('throws', 'throw')
7588 ('throws', 'Throw')
7589 ('isExtensible', 'extensible')
7590 ('isNotExtensible', 'notExtensible')
7591 ('isSealed', 'sealed')
7592 ('isNotSealed', 'notSealed')
7593 ('isFrozen', 'frozen')
7594 ('isNotFrozen', 'notFrozen')
7595 ('isEmpty', 'empty')
7596 ('isNotEmpty', 'notEmpty');
7597};
7598
7599
7600/***/ }),
7601
7602/***/ "./node_modules/chai/lib/chai/interface/expect.js":
7603/*!********************************************************!*\
7604 !*** ./node_modules/chai/lib/chai/interface/expect.js ***!
7605 \********************************************************/
7606/***/ ((module) => {
7607
7608/*!
7609 * chai
7610 * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
7611 * MIT Licensed
7612 */
7613
7614module.exports = function (chai, util) {
7615 chai.expect = function (val, message) {
7616 return new chai.Assertion(val, message);
7617 };
7618
7619 /**
7620 * ### .fail([message])
7621 * ### .fail(actual, expected, [message], [operator])
7622 *
7623 * Throw a failure.
7624 *
7625 * expect.fail();
7626 * expect.fail("custom error message");
7627 * expect.fail(1, 2);
7628 * expect.fail(1, 2, "custom error message");
7629 * expect.fail(1, 2, "custom error message", ">");
7630 * expect.fail(1, 2, undefined, ">");
7631 *
7632 * @name fail
7633 * @param {Mixed} actual
7634 * @param {Mixed} expected
7635 * @param {String} message
7636 * @param {String} operator
7637 * @namespace BDD
7638 * @api public
7639 */
7640
7641 chai.expect.fail = function (actual, expected, message, operator) {
7642 if (arguments.length < 2) {
7643 message = actual;
7644 actual = undefined;
7645 }
7646
7647 message = message || 'expect.fail()';
7648 throw new chai.AssertionError(message, {
7649 actual: actual
7650 , expected: expected
7651 , operator: operator
7652 }, chai.expect.fail);
7653 };
7654};
7655
7656
7657/***/ }),
7658
7659/***/ "./node_modules/chai/lib/chai/interface/should.js":
7660/*!********************************************************!*\
7661 !*** ./node_modules/chai/lib/chai/interface/should.js ***!
7662 \********************************************************/
7663/***/ ((module) => {
7664
7665/*!
7666 * chai
7667 * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
7668 * MIT Licensed
7669 */
7670
7671module.exports = function (chai, util) {
7672 var Assertion = chai.Assertion;
7673
7674 function loadShould () {
7675 // explicitly define this method as function as to have it's name to include as `ssfi`
7676 function shouldGetter() {
7677 if (this instanceof String
7678 || this instanceof Number
7679 || this instanceof Boolean
7680 || typeof Symbol === 'function' && this instanceof Symbol
7681 || typeof BigInt === 'function' && this instanceof BigInt) {
7682 return new Assertion(this.valueOf(), null, shouldGetter);
7683 }
7684 return new Assertion(this, null, shouldGetter);
7685 }
7686 function shouldSetter(value) {
7687 // See https://github.com/chaijs/chai/issues/86: this makes
7688 // `whatever.should = someValue` actually set `someValue`, which is
7689 // especially useful for `global.should = require('chai').should()`.
7690 //
7691 // Note that we have to use [[DefineProperty]] instead of [[Put]]
7692 // since otherwise we would trigger this very setter!
7693 Object.defineProperty(this, 'should', {
7694 value: value,
7695 enumerable: true,
7696 configurable: true,
7697 writable: true
7698 });
7699 }
7700 // modify Object.prototype to have `should`
7701 Object.defineProperty(Object.prototype, 'should', {
7702 set: shouldSetter
7703 , get: shouldGetter
7704 , configurable: true
7705 });
7706
7707 var should = {};
7708
7709 /**
7710 * ### .fail([message])
7711 * ### .fail(actual, expected, [message], [operator])
7712 *
7713 * Throw a failure.
7714 *
7715 * should.fail();
7716 * should.fail("custom error message");
7717 * should.fail(1, 2);
7718 * should.fail(1, 2, "custom error message");
7719 * should.fail(1, 2, "custom error message", ">");
7720 * should.fail(1, 2, undefined, ">");
7721 *
7722 *
7723 * @name fail
7724 * @param {Mixed} actual
7725 * @param {Mixed} expected
7726 * @param {String} message
7727 * @param {String} operator
7728 * @namespace BDD
7729 * @api public
7730 */
7731
7732 should.fail = function (actual, expected, message, operator) {
7733 if (arguments.length < 2) {
7734 message = actual;
7735 actual = undefined;
7736 }
7737
7738 message = message || 'should.fail()';
7739 throw new chai.AssertionError(message, {
7740 actual: actual
7741 , expected: expected
7742 , operator: operator
7743 }, should.fail);
7744 };
7745
7746 /**
7747 * ### .equal(actual, expected, [message])
7748 *
7749 * Asserts non-strict equality (`==`) of `actual` and `expected`.
7750 *
7751 * should.equal(3, '3', '== coerces values to strings');
7752 *
7753 * @name equal
7754 * @param {Mixed} actual
7755 * @param {Mixed} expected
7756 * @param {String} message
7757 * @namespace Should
7758 * @api public
7759 */
7760
7761 should.equal = function (val1, val2, msg) {
7762 new Assertion(val1, msg).to.equal(val2);
7763 };
7764
7765 /**
7766 * ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
7767 *
7768 * Asserts that `function` will throw an error that is an instance of
7769 * `constructor`, or alternately that it will throw an error with message
7770 * matching `regexp`.
7771 *
7772 * should.throw(fn, 'function throws a reference error');
7773 * should.throw(fn, /function throws a reference error/);
7774 * should.throw(fn, ReferenceError);
7775 * should.throw(fn, ReferenceError, 'function throws a reference error');
7776 * should.throw(fn, ReferenceError, /function throws a reference error/);
7777 *
7778 * @name throw
7779 * @alias Throw
7780 * @param {Function} function
7781 * @param {ErrorConstructor} constructor
7782 * @param {RegExp} regexp
7783 * @param {String} message
7784 * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
7785 * @namespace Should
7786 * @api public
7787 */
7788
7789 should.Throw = function (fn, errt, errs, msg) {
7790 new Assertion(fn, msg).to.Throw(errt, errs);
7791 };
7792
7793 /**
7794 * ### .exist
7795 *
7796 * Asserts that the target is neither `null` nor `undefined`.
7797 *
7798 * var foo = 'hi';
7799 *
7800 * should.exist(foo, 'foo exists');
7801 *
7802 * @name exist
7803 * @namespace Should
7804 * @api public
7805 */
7806
7807 should.exist = function (val, msg) {
7808 new Assertion(val, msg).to.exist;
7809 }
7810
7811 // negation
7812 should.not = {}
7813
7814 /**
7815 * ### .not.equal(actual, expected, [message])
7816 *
7817 * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
7818 *
7819 * should.not.equal(3, 4, 'these numbers are not equal');
7820 *
7821 * @name not.equal
7822 * @param {Mixed} actual
7823 * @param {Mixed} expected
7824 * @param {String} message
7825 * @namespace Should
7826 * @api public
7827 */
7828
7829 should.not.equal = function (val1, val2, msg) {
7830 new Assertion(val1, msg).to.not.equal(val2);
7831 };
7832
7833 /**
7834 * ### .throw(function, [constructor/regexp], [message])
7835 *
7836 * Asserts that `function` will _not_ throw an error that is an instance of
7837 * `constructor`, or alternately that it will not throw an error with message
7838 * matching `regexp`.
7839 *
7840 * should.not.throw(fn, Error, 'function does not throw');
7841 *
7842 * @name not.throw
7843 * @alias not.Throw
7844 * @param {Function} function
7845 * @param {ErrorConstructor} constructor
7846 * @param {RegExp} regexp
7847 * @param {String} message
7848 * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
7849 * @namespace Should
7850 * @api public
7851 */
7852
7853 should.not.Throw = function (fn, errt, errs, msg) {
7854 new Assertion(fn, msg).to.not.Throw(errt, errs);
7855 };
7856
7857 /**
7858 * ### .not.exist
7859 *
7860 * Asserts that the target is neither `null` nor `undefined`.
7861 *
7862 * var bar = null;
7863 *
7864 * should.not.exist(bar, 'bar does not exist');
7865 *
7866 * @name not.exist
7867 * @namespace Should
7868 * @api public
7869 */
7870
7871 should.not.exist = function (val, msg) {
7872 new Assertion(val, msg).to.not.exist;
7873 }
7874
7875 should['throw'] = should['Throw'];
7876 should.not['throw'] = should.not['Throw'];
7877
7878 return should;
7879 };
7880
7881 chai.should = loadShould;
7882 chai.Should = loadShould;
7883};
7884
7885
7886/***/ }),
7887
7888/***/ "./node_modules/chai/lib/chai/utils/addChainableMethod.js":
7889/*!****************************************************************!*\
7890 !*** ./node_modules/chai/lib/chai/utils/addChainableMethod.js ***!
7891 \****************************************************************/
7892/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7893
7894/*!
7895 * Chai - addChainingMethod utility
7896 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
7897 * MIT Licensed
7898 */
7899
7900/*!
7901 * Module dependencies
7902 */
7903
7904var addLengthGuard = __webpack_require__(/*! ./addLengthGuard */ "./node_modules/chai/lib/chai/utils/addLengthGuard.js");
7905var chai = __webpack_require__(/*! ../../chai */ "./node_modules/chai/lib/chai.js");
7906var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
7907var proxify = __webpack_require__(/*! ./proxify */ "./node_modules/chai/lib/chai/utils/proxify.js");
7908var transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
7909
7910/*!
7911 * Module variables
7912 */
7913
7914// Check whether `Object.setPrototypeOf` is supported
7915var canSetPrototype = typeof Object.setPrototypeOf === 'function';
7916
7917// Without `Object.setPrototypeOf` support, this module will need to add properties to a function.
7918// However, some of functions' own props are not configurable and should be skipped.
7919var testFn = function() {};
7920var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
7921 var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
7922
7923 // Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties,
7924 // but then returns `undefined` as the property descriptor for `callee`. As a
7925 // workaround, we perform an otherwise unnecessary type-check for `propDesc`,
7926 // and then filter it out if it's not an object as it should be.
7927 if (typeof propDesc !== 'object')
7928 return true;
7929
7930 return !propDesc.configurable;
7931});
7932
7933// Cache `Function` properties
7934var call = Function.prototype.call,
7935 apply = Function.prototype.apply;
7936
7937/**
7938 * ### .addChainableMethod(ctx, name, method, chainingBehavior)
7939 *
7940 * Adds a method to an object, such that the method can also be chained.
7941 *
7942 * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
7943 * var obj = utils.flag(this, 'object');
7944 * new chai.Assertion(obj).to.be.equal(str);
7945 * });
7946 *
7947 * Can also be accessed directly from `chai.Assertion`.
7948 *
7949 * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
7950 *
7951 * The result can then be used as both a method assertion, executing both `method` and
7952 * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
7953 *
7954 * expect(fooStr).to.be.foo('bar');
7955 * expect(fooStr).to.be.foo.equal('foo');
7956 *
7957 * @param {Object} ctx object to which the method is added
7958 * @param {String} name of method to add
7959 * @param {Function} method function to be used for `name`, when called
7960 * @param {Function} chainingBehavior function to be called every time the property is accessed
7961 * @namespace Utils
7962 * @name addChainableMethod
7963 * @api public
7964 */
7965
7966module.exports = function addChainableMethod(ctx, name, method, chainingBehavior) {
7967 if (typeof chainingBehavior !== 'function') {
7968 chainingBehavior = function () { };
7969 }
7970
7971 var chainableBehavior = {
7972 method: method
7973 , chainingBehavior: chainingBehavior
7974 };
7975
7976 // save the methods so we can overwrite them later, if we need to.
7977 if (!ctx.__methods) {
7978 ctx.__methods = {};
7979 }
7980 ctx.__methods[name] = chainableBehavior;
7981
7982 Object.defineProperty(ctx, name,
7983 { get: function chainableMethodGetter() {
7984 chainableBehavior.chainingBehavior.call(this);
7985
7986 var chainableMethodWrapper = function () {
7987 // Setting the `ssfi` flag to `chainableMethodWrapper` causes this
7988 // function to be the starting point for removing implementation
7989 // frames from the stack trace of a failed assertion.
7990 //
7991 // However, we only want to use this function as the starting point if
7992 // the `lockSsfi` flag isn't set.
7993 //
7994 // If the `lockSsfi` flag is set, then this assertion is being
7995 // invoked from inside of another assertion. In this case, the `ssfi`
7996 // flag has already been set by the outer assertion.
7997 //
7998 // Note that overwriting a chainable method merely replaces the saved
7999 // methods in `ctx.__methods` instead of completely replacing the
8000 // overwritten assertion. Therefore, an overwriting assertion won't
8001 // set the `ssfi` or `lockSsfi` flags.
8002 if (!flag(this, 'lockSsfi')) {
8003 flag(this, 'ssfi', chainableMethodWrapper);
8004 }
8005
8006 var result = chainableBehavior.method.apply(this, arguments);
8007 if (result !== undefined) {
8008 return result;
8009 }
8010
8011 var newAssertion = new chai.Assertion();
8012 transferFlags(this, newAssertion);
8013 return newAssertion;
8014 };
8015
8016 addLengthGuard(chainableMethodWrapper, name, true);
8017
8018 // Use `Object.setPrototypeOf` if available
8019 if (canSetPrototype) {
8020 // Inherit all properties from the object by replacing the `Function` prototype
8021 var prototype = Object.create(this);
8022 // Restore the `call` and `apply` methods from `Function`
8023 prototype.call = call;
8024 prototype.apply = apply;
8025 Object.setPrototypeOf(chainableMethodWrapper, prototype);
8026 }
8027 // Otherwise, redefine all properties (slow!)
8028 else {
8029 var asserterNames = Object.getOwnPropertyNames(ctx);
8030 asserterNames.forEach(function (asserterName) {
8031 if (excludeNames.indexOf(asserterName) !== -1) {
8032 return;
8033 }
8034
8035 var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
8036 Object.defineProperty(chainableMethodWrapper, asserterName, pd);
8037 });
8038 }
8039
8040 transferFlags(this, chainableMethodWrapper);
8041 return proxify(chainableMethodWrapper);
8042 }
8043 , configurable: true
8044 });
8045};
8046
8047
8048/***/ }),
8049
8050/***/ "./node_modules/chai/lib/chai/utils/addLengthGuard.js":
8051/*!************************************************************!*\
8052 !*** ./node_modules/chai/lib/chai/utils/addLengthGuard.js ***!
8053 \************************************************************/
8054/***/ ((module) => {
8055
8056var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
8057
8058/*!
8059 * Chai - addLengthGuard utility
8060 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8061 * MIT Licensed
8062 */
8063
8064/**
8065 * ### .addLengthGuard(fn, assertionName, isChainable)
8066 *
8067 * Define `length` as a getter on the given uninvoked method assertion. The
8068 * getter acts as a guard against chaining `length` directly off of an uninvoked
8069 * method assertion, which is a problem because it references `function`'s
8070 * built-in `length` property instead of Chai's `length` assertion. When the
8071 * getter catches the user making this mistake, it throws an error with a
8072 * helpful message.
8073 *
8074 * There are two ways in which this mistake can be made. The first way is by
8075 * chaining the `length` assertion directly off of an uninvoked chainable
8076 * method. In this case, Chai suggests that the user use `lengthOf` instead. The
8077 * second way is by chaining the `length` assertion directly off of an uninvoked
8078 * non-chainable method. Non-chainable methods must be invoked prior to
8079 * chaining. In this case, Chai suggests that the user consult the docs for the
8080 * given assertion.
8081 *
8082 * If the `length` property of functions is unconfigurable, then return `fn`
8083 * without modification.
8084 *
8085 * Note that in ES6, the function's `length` property is configurable, so once
8086 * support for legacy environments is dropped, Chai's `length` property can
8087 * replace the built-in function's `length` property, and this length guard will
8088 * no longer be necessary. In the mean time, maintaining consistency across all
8089 * environments is the priority.
8090 *
8091 * @param {Function} fn
8092 * @param {String} assertionName
8093 * @param {Boolean} isChainable
8094 * @namespace Utils
8095 * @name addLengthGuard
8096 */
8097
8098module.exports = function addLengthGuard (fn, assertionName, isChainable) {
8099 if (!fnLengthDesc.configurable) return fn;
8100
8101 Object.defineProperty(fn, 'length', {
8102 get: function () {
8103 if (isChainable) {
8104 throw Error('Invalid Chai property: ' + assertionName + '.length. Due' +
8105 ' to a compatibility issue, "length" cannot directly follow "' +
8106 assertionName + '". Use "' + assertionName + '.lengthOf" instead.');
8107 }
8108
8109 throw Error('Invalid Chai property: ' + assertionName + '.length. See' +
8110 ' docs for proper usage of "' + assertionName + '".');
8111 }
8112 });
8113
8114 return fn;
8115};
8116
8117
8118/***/ }),
8119
8120/***/ "./node_modules/chai/lib/chai/utils/addMethod.js":
8121/*!*******************************************************!*\
8122 !*** ./node_modules/chai/lib/chai/utils/addMethod.js ***!
8123 \*******************************************************/
8124/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8125
8126/*!
8127 * Chai - addMethod utility
8128 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8129 * MIT Licensed
8130 */
8131
8132var addLengthGuard = __webpack_require__(/*! ./addLengthGuard */ "./node_modules/chai/lib/chai/utils/addLengthGuard.js");
8133var chai = __webpack_require__(/*! ../../chai */ "./node_modules/chai/lib/chai.js");
8134var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
8135var proxify = __webpack_require__(/*! ./proxify */ "./node_modules/chai/lib/chai/utils/proxify.js");
8136var transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
8137
8138/**
8139 * ### .addMethod(ctx, name, method)
8140 *
8141 * Adds a method to the prototype of an object.
8142 *
8143 * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
8144 * var obj = utils.flag(this, 'object');
8145 * new chai.Assertion(obj).to.be.equal(str);
8146 * });
8147 *
8148 * Can also be accessed directly from `chai.Assertion`.
8149 *
8150 * chai.Assertion.addMethod('foo', fn);
8151 *
8152 * Then can be used as any other assertion.
8153 *
8154 * expect(fooStr).to.be.foo('bar');
8155 *
8156 * @param {Object} ctx object to which the method is added
8157 * @param {String} name of method to add
8158 * @param {Function} method function to be used for name
8159 * @namespace Utils
8160 * @name addMethod
8161 * @api public
8162 */
8163
8164module.exports = function addMethod(ctx, name, method) {
8165 var methodWrapper = function () {
8166 // Setting the `ssfi` flag to `methodWrapper` causes this function to be the
8167 // starting point for removing implementation frames from the stack trace of
8168 // a failed assertion.
8169 //
8170 // However, we only want to use this function as the starting point if the
8171 // `lockSsfi` flag isn't set.
8172 //
8173 // If the `lockSsfi` flag is set, then either this assertion has been
8174 // overwritten by another assertion, or this assertion is being invoked from
8175 // inside of another assertion. In the first case, the `ssfi` flag has
8176 // already been set by the overwriting assertion. In the second case, the
8177 // `ssfi` flag has already been set by the outer assertion.
8178 if (!flag(this, 'lockSsfi')) {
8179 flag(this, 'ssfi', methodWrapper);
8180 }
8181
8182 var result = method.apply(this, arguments);
8183 if (result !== undefined)
8184 return result;
8185
8186 var newAssertion = new chai.Assertion();
8187 transferFlags(this, newAssertion);
8188 return newAssertion;
8189 };
8190
8191 addLengthGuard(methodWrapper, name, false);
8192 ctx[name] = proxify(methodWrapper, name);
8193};
8194
8195
8196/***/ }),
8197
8198/***/ "./node_modules/chai/lib/chai/utils/addProperty.js":
8199/*!*********************************************************!*\
8200 !*** ./node_modules/chai/lib/chai/utils/addProperty.js ***!
8201 \*********************************************************/
8202/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8203
8204/*!
8205 * Chai - addProperty utility
8206 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8207 * MIT Licensed
8208 */
8209
8210var chai = __webpack_require__(/*! ../../chai */ "./node_modules/chai/lib/chai.js");
8211var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
8212var isProxyEnabled = __webpack_require__(/*! ./isProxyEnabled */ "./node_modules/chai/lib/chai/utils/isProxyEnabled.js");
8213var transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
8214
8215/**
8216 * ### .addProperty(ctx, name, getter)
8217 *
8218 * Adds a property to the prototype of an object.
8219 *
8220 * utils.addProperty(chai.Assertion.prototype, 'foo', function () {
8221 * var obj = utils.flag(this, 'object');
8222 * new chai.Assertion(obj).to.be.instanceof(Foo);
8223 * });
8224 *
8225 * Can also be accessed directly from `chai.Assertion`.
8226 *
8227 * chai.Assertion.addProperty('foo', fn);
8228 *
8229 * Then can be used as any other assertion.
8230 *
8231 * expect(myFoo).to.be.foo;
8232 *
8233 * @param {Object} ctx object to which the property is added
8234 * @param {String} name of property to add
8235 * @param {Function} getter function to be used for name
8236 * @namespace Utils
8237 * @name addProperty
8238 * @api public
8239 */
8240
8241module.exports = function addProperty(ctx, name, getter) {
8242 getter = getter === undefined ? function () {} : getter;
8243
8244 Object.defineProperty(ctx, name,
8245 { get: function propertyGetter() {
8246 // Setting the `ssfi` flag to `propertyGetter` causes this function to
8247 // be the starting point for removing implementation frames from the
8248 // stack trace of a failed assertion.
8249 //
8250 // However, we only want to use this function as the starting point if
8251 // the `lockSsfi` flag isn't set and proxy protection is disabled.
8252 //
8253 // If the `lockSsfi` flag is set, then either this assertion has been
8254 // overwritten by another assertion, or this assertion is being invoked
8255 // from inside of another assertion. In the first case, the `ssfi` flag
8256 // has already been set by the overwriting assertion. In the second
8257 // case, the `ssfi` flag has already been set by the outer assertion.
8258 //
8259 // If proxy protection is enabled, then the `ssfi` flag has already been
8260 // set by the proxy getter.
8261 if (!isProxyEnabled() && !flag(this, 'lockSsfi')) {
8262 flag(this, 'ssfi', propertyGetter);
8263 }
8264
8265 var result = getter.call(this);
8266 if (result !== undefined)
8267 return result;
8268
8269 var newAssertion = new chai.Assertion();
8270 transferFlags(this, newAssertion);
8271 return newAssertion;
8272 }
8273 , configurable: true
8274 });
8275};
8276
8277
8278/***/ }),
8279
8280/***/ "./node_modules/chai/lib/chai/utils/compareByInspect.js":
8281/*!**************************************************************!*\
8282 !*** ./node_modules/chai/lib/chai/utils/compareByInspect.js ***!
8283 \**************************************************************/
8284/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8285
8286/*!
8287 * Chai - compareByInspect utility
8288 * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
8289 * MIT Licensed
8290 */
8291
8292/*!
8293 * Module dependencies
8294 */
8295
8296var inspect = __webpack_require__(/*! ./inspect */ "./node_modules/chai/lib/chai/utils/inspect.js");
8297
8298/**
8299 * ### .compareByInspect(mixed, mixed)
8300 *
8301 * To be used as a compareFunction with Array.prototype.sort. Compares elements
8302 * using inspect instead of default behavior of using toString so that Symbols
8303 * and objects with irregular/missing toString can still be sorted without a
8304 * TypeError.
8305 *
8306 * @param {Mixed} first element to compare
8307 * @param {Mixed} second element to compare
8308 * @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
8309 * @name compareByInspect
8310 * @namespace Utils
8311 * @api public
8312 */
8313
8314module.exports = function compareByInspect(a, b) {
8315 return inspect(a) < inspect(b) ? -1 : 1;
8316};
8317
8318
8319/***/ }),
8320
8321/***/ "./node_modules/chai/lib/chai/utils/expectTypes.js":
8322/*!*********************************************************!*\
8323 !*** ./node_modules/chai/lib/chai/utils/expectTypes.js ***!
8324 \*********************************************************/
8325/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8326
8327/*!
8328 * Chai - expectTypes utility
8329 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8330 * MIT Licensed
8331 */
8332
8333/**
8334 * ### .expectTypes(obj, types)
8335 *
8336 * Ensures that the object being tested against is of a valid type.
8337 *
8338 * utils.expectTypes(this, ['array', 'object', 'string']);
8339 *
8340 * @param {Mixed} obj constructed Assertion
8341 * @param {Array} type A list of allowed types for this assertion
8342 * @namespace Utils
8343 * @name expectTypes
8344 * @api public
8345 */
8346
8347var AssertionError = __webpack_require__(/*! assertion-error */ "./node_modules/assertion-error/index.js");
8348var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
8349var type = __webpack_require__(/*! type-detect */ "./node_modules/type-detect/type-detect.js");
8350
8351module.exports = function expectTypes(obj, types) {
8352 var flagMsg = flag(obj, 'message');
8353 var ssfi = flag(obj, 'ssfi');
8354
8355 flagMsg = flagMsg ? flagMsg + ': ' : '';
8356
8357 obj = flag(obj, 'object');
8358 types = types.map(function (t) { return t.toLowerCase(); });
8359 types.sort();
8360
8361 // Transforms ['lorem', 'ipsum'] into 'a lorem, or an ipsum'
8362 var str = types.map(function (t, index) {
8363 var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a';
8364 var or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
8365 return or + art + ' ' + t;
8366 }).join(', ');
8367
8368 var objType = type(obj).toLowerCase();
8369
8370 if (!types.some(function (expected) { return objType === expected; })) {
8371 throw new AssertionError(
8372 flagMsg + 'object tested must be ' + str + ', but ' + objType + ' given',
8373 undefined,
8374 ssfi
8375 );
8376 }
8377};
8378
8379
8380/***/ }),
8381
8382/***/ "./node_modules/chai/lib/chai/utils/flag.js":
8383/*!**************************************************!*\
8384 !*** ./node_modules/chai/lib/chai/utils/flag.js ***!
8385 \**************************************************/
8386/***/ ((module) => {
8387
8388/*!
8389 * Chai - flag utility
8390 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8391 * MIT Licensed
8392 */
8393
8394/**
8395 * ### .flag(object, key, [value])
8396 *
8397 * Get or set a flag value on an object. If a
8398 * value is provided it will be set, else it will
8399 * return the currently set value or `undefined` if
8400 * the value is not set.
8401 *
8402 * utils.flag(this, 'foo', 'bar'); // setter
8403 * utils.flag(this, 'foo'); // getter, returns `bar`
8404 *
8405 * @param {Object} object constructed Assertion
8406 * @param {String} key
8407 * @param {Mixed} value (optional)
8408 * @namespace Utils
8409 * @name flag
8410 * @api private
8411 */
8412
8413module.exports = function flag(obj, key, value) {
8414 var flags = obj.__flags || (obj.__flags = Object.create(null));
8415 if (arguments.length === 3) {
8416 flags[key] = value;
8417 } else {
8418 return flags[key];
8419 }
8420};
8421
8422
8423/***/ }),
8424
8425/***/ "./node_modules/chai/lib/chai/utils/getActual.js":
8426/*!*******************************************************!*\
8427 !*** ./node_modules/chai/lib/chai/utils/getActual.js ***!
8428 \*******************************************************/
8429/***/ ((module) => {
8430
8431/*!
8432 * Chai - getActual utility
8433 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8434 * MIT Licensed
8435 */
8436
8437/**
8438 * ### .getActual(object, [actual])
8439 *
8440 * Returns the `actual` value for an Assertion.
8441 *
8442 * @param {Object} object (constructed Assertion)
8443 * @param {Arguments} chai.Assertion.prototype.assert arguments
8444 * @namespace Utils
8445 * @name getActual
8446 */
8447
8448module.exports = function getActual(obj, args) {
8449 return args.length > 4 ? args[4] : obj._obj;
8450};
8451
8452
8453/***/ }),
8454
8455/***/ "./node_modules/chai/lib/chai/utils/getMessage.js":
8456/*!********************************************************!*\
8457 !*** ./node_modules/chai/lib/chai/utils/getMessage.js ***!
8458 \********************************************************/
8459/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8460
8461/*!
8462 * Chai - message composition utility
8463 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8464 * MIT Licensed
8465 */
8466
8467/*!
8468 * Module dependencies
8469 */
8470
8471var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js")
8472 , getActual = __webpack_require__(/*! ./getActual */ "./node_modules/chai/lib/chai/utils/getActual.js")
8473 , objDisplay = __webpack_require__(/*! ./objDisplay */ "./node_modules/chai/lib/chai/utils/objDisplay.js");
8474
8475/**
8476 * ### .getMessage(object, message, negateMessage)
8477 *
8478 * Construct the error message based on flags
8479 * and template tags. Template tags will return
8480 * a stringified inspection of the object referenced.
8481 *
8482 * Message template tags:
8483 * - `#{this}` current asserted object
8484 * - `#{act}` actual value
8485 * - `#{exp}` expected value
8486 *
8487 * @param {Object} object (constructed Assertion)
8488 * @param {Arguments} chai.Assertion.prototype.assert arguments
8489 * @namespace Utils
8490 * @name getMessage
8491 * @api public
8492 */
8493
8494module.exports = function getMessage(obj, args) {
8495 var negate = flag(obj, 'negate')
8496 , val = flag(obj, 'object')
8497 , expected = args[3]
8498 , actual = getActual(obj, args)
8499 , msg = negate ? args[2] : args[1]
8500 , flagMsg = flag(obj, 'message');
8501
8502 if(typeof msg === "function") msg = msg();
8503 msg = msg || '';
8504 msg = msg
8505 .replace(/#\{this\}/g, function () { return objDisplay(val); })
8506 .replace(/#\{act\}/g, function () { return objDisplay(actual); })
8507 .replace(/#\{exp\}/g, function () { return objDisplay(expected); });
8508
8509 return flagMsg ? flagMsg + ': ' + msg : msg;
8510};
8511
8512
8513/***/ }),
8514
8515/***/ "./node_modules/chai/lib/chai/utils/getOperator.js":
8516/*!*********************************************************!*\
8517 !*** ./node_modules/chai/lib/chai/utils/getOperator.js ***!
8518 \*********************************************************/
8519/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8520
8521var type = __webpack_require__(/*! type-detect */ "./node_modules/type-detect/type-detect.js");
8522
8523var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
8524
8525function isObjectType(obj) {
8526 var objectType = type(obj);
8527 var objectTypes = ['Array', 'Object', 'function'];
8528
8529 return objectTypes.indexOf(objectType) !== -1;
8530}
8531
8532/**
8533 * ### .getOperator(message)
8534 *
8535 * Extract the operator from error message.
8536 * Operator defined is based on below link
8537 * https://nodejs.org/api/assert.html#assert_assert.
8538 *
8539 * Returns the `operator` or `undefined` value for an Assertion.
8540 *
8541 * @param {Object} object (constructed Assertion)
8542 * @param {Arguments} chai.Assertion.prototype.assert arguments
8543 * @namespace Utils
8544 * @name getOperator
8545 * @api public
8546 */
8547
8548module.exports = function getOperator(obj, args) {
8549 var operator = flag(obj, 'operator');
8550 var negate = flag(obj, 'negate');
8551 var expected = args[3];
8552 var msg = negate ? args[2] : args[1];
8553
8554 if (operator) {
8555 return operator;
8556 }
8557
8558 if (typeof msg === 'function') msg = msg();
8559
8560 msg = msg || '';
8561 if (!msg) {
8562 return undefined;
8563 }
8564
8565 if (/\shave\s/.test(msg)) {
8566 return undefined;
8567 }
8568
8569 var isObject = isObjectType(expected);
8570 if (/\snot\s/.test(msg)) {
8571 return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
8572 }
8573
8574 return isObject ? 'deepStrictEqual' : 'strictEqual';
8575};
8576
8577
8578/***/ }),
8579
8580/***/ "./node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js":
8581/*!************************************************************************!*\
8582 !*** ./node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js ***!
8583 \************************************************************************/
8584/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8585
8586/*!
8587 * Chai - getOwnEnumerableProperties utility
8588 * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
8589 * MIT Licensed
8590 */
8591
8592/*!
8593 * Module dependencies
8594 */
8595
8596var getOwnEnumerablePropertySymbols = __webpack_require__(/*! ./getOwnEnumerablePropertySymbols */ "./node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js");
8597
8598/**
8599 * ### .getOwnEnumerableProperties(object)
8600 *
8601 * This allows the retrieval of directly-owned enumerable property names and
8602 * symbols of an object. This function is necessary because Object.keys only
8603 * returns enumerable property names, not enumerable property symbols.
8604 *
8605 * @param {Object} object
8606 * @returns {Array}
8607 * @namespace Utils
8608 * @name getOwnEnumerableProperties
8609 * @api public
8610 */
8611
8612module.exports = function getOwnEnumerableProperties(obj) {
8613 return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
8614};
8615
8616
8617/***/ }),
8618
8619/***/ "./node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js":
8620/*!*****************************************************************************!*\
8621 !*** ./node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js ***!
8622 \*****************************************************************************/
8623/***/ ((module) => {
8624
8625/*!
8626 * Chai - getOwnEnumerablePropertySymbols utility
8627 * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
8628 * MIT Licensed
8629 */
8630
8631/**
8632 * ### .getOwnEnumerablePropertySymbols(object)
8633 *
8634 * This allows the retrieval of directly-owned enumerable property symbols of an
8635 * object. This function is necessary because Object.getOwnPropertySymbols
8636 * returns both enumerable and non-enumerable property symbols.
8637 *
8638 * @param {Object} object
8639 * @returns {Array}
8640 * @namespace Utils
8641 * @name getOwnEnumerablePropertySymbols
8642 * @api public
8643 */
8644
8645module.exports = function getOwnEnumerablePropertySymbols(obj) {
8646 if (typeof Object.getOwnPropertySymbols !== 'function') return [];
8647
8648 return Object.getOwnPropertySymbols(obj).filter(function (sym) {
8649 return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
8650 });
8651};
8652
8653
8654/***/ }),
8655
8656/***/ "./node_modules/chai/lib/chai/utils/getProperties.js":
8657/*!***********************************************************!*\
8658 !*** ./node_modules/chai/lib/chai/utils/getProperties.js ***!
8659 \***********************************************************/
8660/***/ ((module) => {
8661
8662/*!
8663 * Chai - getProperties utility
8664 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8665 * MIT Licensed
8666 */
8667
8668/**
8669 * ### .getProperties(object)
8670 *
8671 * This allows the retrieval of property names of an object, enumerable or not,
8672 * inherited or not.
8673 *
8674 * @param {Object} object
8675 * @returns {Array}
8676 * @namespace Utils
8677 * @name getProperties
8678 * @api public
8679 */
8680
8681module.exports = function getProperties(object) {
8682 var result = Object.getOwnPropertyNames(object);
8683
8684 function addProperty(property) {
8685 if (result.indexOf(property) === -1) {
8686 result.push(property);
8687 }
8688 }
8689
8690 var proto = Object.getPrototypeOf(object);
8691 while (proto !== null) {
8692 Object.getOwnPropertyNames(proto).forEach(addProperty);
8693 proto = Object.getPrototypeOf(proto);
8694 }
8695
8696 return result;
8697};
8698
8699
8700/***/ }),
8701
8702/***/ "./node_modules/chai/lib/chai/utils/index.js":
8703/*!***************************************************!*\
8704 !*** ./node_modules/chai/lib/chai/utils/index.js ***!
8705 \***************************************************/
8706/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8707
8708/*!
8709 * chai
8710 * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
8711 * MIT Licensed
8712 */
8713
8714/*!
8715 * Dependencies that are used for multiple exports are required here only once
8716 */
8717
8718var pathval = __webpack_require__(/*! pathval */ "./node_modules/pathval/index.js");
8719
8720/*!
8721 * test utility
8722 */
8723
8724exports.test = __webpack_require__(/*! ./test */ "./node_modules/chai/lib/chai/utils/test.js");
8725
8726/*!
8727 * type utility
8728 */
8729
8730exports.type = __webpack_require__(/*! type-detect */ "./node_modules/type-detect/type-detect.js");
8731
8732/*!
8733 * expectTypes utility
8734 */
8735exports.expectTypes = __webpack_require__(/*! ./expectTypes */ "./node_modules/chai/lib/chai/utils/expectTypes.js");
8736
8737/*!
8738 * message utility
8739 */
8740
8741exports.getMessage = __webpack_require__(/*! ./getMessage */ "./node_modules/chai/lib/chai/utils/getMessage.js");
8742
8743/*!
8744 * actual utility
8745 */
8746
8747exports.getActual = __webpack_require__(/*! ./getActual */ "./node_modules/chai/lib/chai/utils/getActual.js");
8748
8749/*!
8750 * Inspect util
8751 */
8752
8753exports.inspect = __webpack_require__(/*! ./inspect */ "./node_modules/chai/lib/chai/utils/inspect.js");
8754
8755/*!
8756 * Object Display util
8757 */
8758
8759exports.objDisplay = __webpack_require__(/*! ./objDisplay */ "./node_modules/chai/lib/chai/utils/objDisplay.js");
8760
8761/*!
8762 * Flag utility
8763 */
8764
8765exports.flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
8766
8767/*!
8768 * Flag transferring utility
8769 */
8770
8771exports.transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
8772
8773/*!
8774 * Deep equal utility
8775 */
8776
8777exports.eql = __webpack_require__(/*! deep-eql */ "./node_modules/deep-eql/index.js");
8778
8779/*!
8780 * Deep path info
8781 */
8782
8783exports.getPathInfo = pathval.getPathInfo;
8784
8785/*!
8786 * Check if a property exists
8787 */
8788
8789exports.hasProperty = pathval.hasProperty;
8790
8791/*!
8792 * Function name
8793 */
8794
8795exports.getName = __webpack_require__(/*! get-func-name */ "./node_modules/get-func-name/index.js");
8796
8797/*!
8798 * add Property
8799 */
8800
8801exports.addProperty = __webpack_require__(/*! ./addProperty */ "./node_modules/chai/lib/chai/utils/addProperty.js");
8802
8803/*!
8804 * add Method
8805 */
8806
8807exports.addMethod = __webpack_require__(/*! ./addMethod */ "./node_modules/chai/lib/chai/utils/addMethod.js");
8808
8809/*!
8810 * overwrite Property
8811 */
8812
8813exports.overwriteProperty = __webpack_require__(/*! ./overwriteProperty */ "./node_modules/chai/lib/chai/utils/overwriteProperty.js");
8814
8815/*!
8816 * overwrite Method
8817 */
8818
8819exports.overwriteMethod = __webpack_require__(/*! ./overwriteMethod */ "./node_modules/chai/lib/chai/utils/overwriteMethod.js");
8820
8821/*!
8822 * Add a chainable method
8823 */
8824
8825exports.addChainableMethod = __webpack_require__(/*! ./addChainableMethod */ "./node_modules/chai/lib/chai/utils/addChainableMethod.js");
8826
8827/*!
8828 * Overwrite chainable method
8829 */
8830
8831exports.overwriteChainableMethod = __webpack_require__(/*! ./overwriteChainableMethod */ "./node_modules/chai/lib/chai/utils/overwriteChainableMethod.js");
8832
8833/*!
8834 * Compare by inspect method
8835 */
8836
8837exports.compareByInspect = __webpack_require__(/*! ./compareByInspect */ "./node_modules/chai/lib/chai/utils/compareByInspect.js");
8838
8839/*!
8840 * Get own enumerable property symbols method
8841 */
8842
8843exports.getOwnEnumerablePropertySymbols = __webpack_require__(/*! ./getOwnEnumerablePropertySymbols */ "./node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js");
8844
8845/*!
8846 * Get own enumerable properties method
8847 */
8848
8849exports.getOwnEnumerableProperties = __webpack_require__(/*! ./getOwnEnumerableProperties */ "./node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js");
8850
8851/*!
8852 * Checks error against a given set of criteria
8853 */
8854
8855exports.checkError = __webpack_require__(/*! check-error */ "./node_modules/check-error/index.js");
8856
8857/*!
8858 * Proxify util
8859 */
8860
8861exports.proxify = __webpack_require__(/*! ./proxify */ "./node_modules/chai/lib/chai/utils/proxify.js");
8862
8863/*!
8864 * addLengthGuard util
8865 */
8866
8867exports.addLengthGuard = __webpack_require__(/*! ./addLengthGuard */ "./node_modules/chai/lib/chai/utils/addLengthGuard.js");
8868
8869/*!
8870 * isProxyEnabled helper
8871 */
8872
8873exports.isProxyEnabled = __webpack_require__(/*! ./isProxyEnabled */ "./node_modules/chai/lib/chai/utils/isProxyEnabled.js");
8874
8875/*!
8876 * isNaN method
8877 */
8878
8879exports.isNaN = __webpack_require__(/*! ./isNaN */ "./node_modules/chai/lib/chai/utils/isNaN.js");
8880
8881/*!
8882 * getOperator method
8883 */
8884
8885exports.getOperator = __webpack_require__(/*! ./getOperator */ "./node_modules/chai/lib/chai/utils/getOperator.js");
8886
8887/***/ }),
8888
8889/***/ "./node_modules/chai/lib/chai/utils/inspect.js":
8890/*!*****************************************************!*\
8891 !*** ./node_modules/chai/lib/chai/utils/inspect.js ***!
8892 \*****************************************************/
8893/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8894
8895// This is (almost) directly from Node.js utils
8896// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
8897
8898var getName = __webpack_require__(/*! get-func-name */ "./node_modules/get-func-name/index.js");
8899var loupe = __webpack_require__(/*! loupe */ "./node_modules/loupe/loupe.js");
8900var config = __webpack_require__(/*! ../config */ "./node_modules/chai/lib/chai/config.js");
8901
8902module.exports = inspect;
8903
8904/**
8905 * ### .inspect(obj, [showHidden], [depth], [colors])
8906 *
8907 * Echoes the value of a value. Tries to print the value out
8908 * in the best way possible given the different types.
8909 *
8910 * @param {Object} obj The object to print out.
8911 * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
8912 * properties of objects. Default is false.
8913 * @param {Number} depth Depth in which to descend in object. Default is 2.
8914 * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
8915 * output. Default is false (no coloring).
8916 * @namespace Utils
8917 * @name inspect
8918 */
8919function inspect(obj, showHidden, depth, colors) {
8920 var options = {
8921 colors: colors,
8922 depth: (typeof depth === 'undefined' ? 2 : depth),
8923 showHidden: showHidden,
8924 truncate: config.truncateThreshold ? config.truncateThreshold : Infinity,
8925 };
8926 return loupe.inspect(obj, options);
8927}
8928
8929
8930/***/ }),
8931
8932/***/ "./node_modules/chai/lib/chai/utils/isNaN.js":
8933/*!***************************************************!*\
8934 !*** ./node_modules/chai/lib/chai/utils/isNaN.js ***!
8935 \***************************************************/
8936/***/ ((module) => {
8937
8938/*!
8939 * Chai - isNaN utility
8940 * Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
8941 * MIT Licensed
8942 */
8943
8944/**
8945 * ### .isNaN(value)
8946 *
8947 * Checks if the given value is NaN or not.
8948 *
8949 * utils.isNaN(NaN); // true
8950 *
8951 * @param {Value} The value which has to be checked if it is NaN
8952 * @name isNaN
8953 * @api private
8954 */
8955
8956function isNaN(value) {
8957 // Refer http://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number
8958 // section's NOTE.
8959 return value !== value;
8960}
8961
8962// If ECMAScript 6's Number.isNaN is present, prefer that.
8963module.exports = Number.isNaN || isNaN;
8964
8965
8966/***/ }),
8967
8968/***/ "./node_modules/chai/lib/chai/utils/isProxyEnabled.js":
8969/*!************************************************************!*\
8970 !*** ./node_modules/chai/lib/chai/utils/isProxyEnabled.js ***!
8971 \************************************************************/
8972/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8973
8974var config = __webpack_require__(/*! ../config */ "./node_modules/chai/lib/chai/config.js");
8975
8976/*!
8977 * Chai - isProxyEnabled helper
8978 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
8979 * MIT Licensed
8980 */
8981
8982/**
8983 * ### .isProxyEnabled()
8984 *
8985 * Helper function to check if Chai's proxy protection feature is enabled. If
8986 * proxies are unsupported or disabled via the user's Chai config, then return
8987 * false. Otherwise, return true.
8988 *
8989 * @namespace Utils
8990 * @name isProxyEnabled
8991 */
8992
8993module.exports = function isProxyEnabled() {
8994 return config.useProxy &&
8995 typeof Proxy !== 'undefined' &&
8996 typeof Reflect !== 'undefined';
8997};
8998
8999
9000/***/ }),
9001
9002/***/ "./node_modules/chai/lib/chai/utils/objDisplay.js":
9003/*!********************************************************!*\
9004 !*** ./node_modules/chai/lib/chai/utils/objDisplay.js ***!
9005 \********************************************************/
9006/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9007
9008/*!
9009 * Chai - flag utility
9010 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9011 * MIT Licensed
9012 */
9013
9014/*!
9015 * Module dependencies
9016 */
9017
9018var inspect = __webpack_require__(/*! ./inspect */ "./node_modules/chai/lib/chai/utils/inspect.js");
9019var config = __webpack_require__(/*! ../config */ "./node_modules/chai/lib/chai/config.js");
9020
9021/**
9022 * ### .objDisplay(object)
9023 *
9024 * Determines if an object or an array matches
9025 * criteria to be inspected in-line for error
9026 * messages or should be truncated.
9027 *
9028 * @param {Mixed} javascript object to inspect
9029 * @name objDisplay
9030 * @namespace Utils
9031 * @api public
9032 */
9033
9034module.exports = function objDisplay(obj) {
9035 var str = inspect(obj)
9036 , type = Object.prototype.toString.call(obj);
9037
9038 if (config.truncateThreshold && str.length >= config.truncateThreshold) {
9039 if (type === '[object Function]') {
9040 return !obj.name || obj.name === ''
9041 ? '[Function]'
9042 : '[Function: ' + obj.name + ']';
9043 } else if (type === '[object Array]') {
9044 return '[ Array(' + obj.length + ') ]';
9045 } else if (type === '[object Object]') {
9046 var keys = Object.keys(obj)
9047 , kstr = keys.length > 2
9048 ? keys.splice(0, 2).join(', ') + ', ...'
9049 : keys.join(', ');
9050 return '{ Object (' + kstr + ') }';
9051 } else {
9052 return str;
9053 }
9054 } else {
9055 return str;
9056 }
9057};
9058
9059
9060/***/ }),
9061
9062/***/ "./node_modules/chai/lib/chai/utils/overwriteChainableMethod.js":
9063/*!**********************************************************************!*\
9064 !*** ./node_modules/chai/lib/chai/utils/overwriteChainableMethod.js ***!
9065 \**********************************************************************/
9066/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9067
9068/*!
9069 * Chai - overwriteChainableMethod utility
9070 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9071 * MIT Licensed
9072 */
9073
9074var chai = __webpack_require__(/*! ../../chai */ "./node_modules/chai/lib/chai.js");
9075var transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
9076
9077/**
9078 * ### .overwriteChainableMethod(ctx, name, method, chainingBehavior)
9079 *
9080 * Overwrites an already existing chainable method
9081 * and provides access to the previous function or
9082 * property. Must return functions to be used for
9083 * name.
9084 *
9085 * utils.overwriteChainableMethod(chai.Assertion.prototype, 'lengthOf',
9086 * function (_super) {
9087 * }
9088 * , function (_super) {
9089 * }
9090 * );
9091 *
9092 * Can also be accessed directly from `chai.Assertion`.
9093 *
9094 * chai.Assertion.overwriteChainableMethod('foo', fn, fn);
9095 *
9096 * Then can be used as any other assertion.
9097 *
9098 * expect(myFoo).to.have.lengthOf(3);
9099 * expect(myFoo).to.have.lengthOf.above(3);
9100 *
9101 * @param {Object} ctx object whose method / property is to be overwritten
9102 * @param {String} name of method / property to overwrite
9103 * @param {Function} method function that returns a function to be used for name
9104 * @param {Function} chainingBehavior function that returns a function to be used for property
9105 * @namespace Utils
9106 * @name overwriteChainableMethod
9107 * @api public
9108 */
9109
9110module.exports = function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
9111 var chainableBehavior = ctx.__methods[name];
9112
9113 var _chainingBehavior = chainableBehavior.chainingBehavior;
9114 chainableBehavior.chainingBehavior = function overwritingChainableMethodGetter() {
9115 var result = chainingBehavior(_chainingBehavior).call(this);
9116 if (result !== undefined) {
9117 return result;
9118 }
9119
9120 var newAssertion = new chai.Assertion();
9121 transferFlags(this, newAssertion);
9122 return newAssertion;
9123 };
9124
9125 var _method = chainableBehavior.method;
9126 chainableBehavior.method = function overwritingChainableMethodWrapper() {
9127 var result = method(_method).apply(this, arguments);
9128 if (result !== undefined) {
9129 return result;
9130 }
9131
9132 var newAssertion = new chai.Assertion();
9133 transferFlags(this, newAssertion);
9134 return newAssertion;
9135 };
9136};
9137
9138
9139/***/ }),
9140
9141/***/ "./node_modules/chai/lib/chai/utils/overwriteMethod.js":
9142/*!*************************************************************!*\
9143 !*** ./node_modules/chai/lib/chai/utils/overwriteMethod.js ***!
9144 \*************************************************************/
9145/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9146
9147/*!
9148 * Chai - overwriteMethod utility
9149 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9150 * MIT Licensed
9151 */
9152
9153var addLengthGuard = __webpack_require__(/*! ./addLengthGuard */ "./node_modules/chai/lib/chai/utils/addLengthGuard.js");
9154var chai = __webpack_require__(/*! ../../chai */ "./node_modules/chai/lib/chai.js");
9155var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
9156var proxify = __webpack_require__(/*! ./proxify */ "./node_modules/chai/lib/chai/utils/proxify.js");
9157var transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
9158
9159/**
9160 * ### .overwriteMethod(ctx, name, fn)
9161 *
9162 * Overwrites an already existing method and provides
9163 * access to previous function. Must return function
9164 * to be used for name.
9165 *
9166 * utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
9167 * return function (str) {
9168 * var obj = utils.flag(this, 'object');
9169 * if (obj instanceof Foo) {
9170 * new chai.Assertion(obj.value).to.equal(str);
9171 * } else {
9172 * _super.apply(this, arguments);
9173 * }
9174 * }
9175 * });
9176 *
9177 * Can also be accessed directly from `chai.Assertion`.
9178 *
9179 * chai.Assertion.overwriteMethod('foo', fn);
9180 *
9181 * Then can be used as any other assertion.
9182 *
9183 * expect(myFoo).to.equal('bar');
9184 *
9185 * @param {Object} ctx object whose method is to be overwritten
9186 * @param {String} name of method to overwrite
9187 * @param {Function} method function that returns a function to be used for name
9188 * @namespace Utils
9189 * @name overwriteMethod
9190 * @api public
9191 */
9192
9193module.exports = function overwriteMethod(ctx, name, method) {
9194 var _method = ctx[name]
9195 , _super = function () {
9196 throw new Error(name + ' is not a function');
9197 };
9198
9199 if (_method && 'function' === typeof _method)
9200 _super = _method;
9201
9202 var overwritingMethodWrapper = function () {
9203 // Setting the `ssfi` flag to `overwritingMethodWrapper` causes this
9204 // function to be the starting point for removing implementation frames from
9205 // the stack trace of a failed assertion.
9206 //
9207 // However, we only want to use this function as the starting point if the
9208 // `lockSsfi` flag isn't set.
9209 //
9210 // If the `lockSsfi` flag is set, then either this assertion has been
9211 // overwritten by another assertion, or this assertion is being invoked from
9212 // inside of another assertion. In the first case, the `ssfi` flag has
9213 // already been set by the overwriting assertion. In the second case, the
9214 // `ssfi` flag has already been set by the outer assertion.
9215 if (!flag(this, 'lockSsfi')) {
9216 flag(this, 'ssfi', overwritingMethodWrapper);
9217 }
9218
9219 // Setting the `lockSsfi` flag to `true` prevents the overwritten assertion
9220 // from changing the `ssfi` flag. By this point, the `ssfi` flag is already
9221 // set to the correct starting point for this assertion.
9222 var origLockSsfi = flag(this, 'lockSsfi');
9223 flag(this, 'lockSsfi', true);
9224 var result = method(_super).apply(this, arguments);
9225 flag(this, 'lockSsfi', origLockSsfi);
9226
9227 if (result !== undefined) {
9228 return result;
9229 }
9230
9231 var newAssertion = new chai.Assertion();
9232 transferFlags(this, newAssertion);
9233 return newAssertion;
9234 }
9235
9236 addLengthGuard(overwritingMethodWrapper, name, false);
9237 ctx[name] = proxify(overwritingMethodWrapper, name);
9238};
9239
9240
9241/***/ }),
9242
9243/***/ "./node_modules/chai/lib/chai/utils/overwriteProperty.js":
9244/*!***************************************************************!*\
9245 !*** ./node_modules/chai/lib/chai/utils/overwriteProperty.js ***!
9246 \***************************************************************/
9247/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9248
9249/*!
9250 * Chai - overwriteProperty utility
9251 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9252 * MIT Licensed
9253 */
9254
9255var chai = __webpack_require__(/*! ../../chai */ "./node_modules/chai/lib/chai.js");
9256var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
9257var isProxyEnabled = __webpack_require__(/*! ./isProxyEnabled */ "./node_modules/chai/lib/chai/utils/isProxyEnabled.js");
9258var transferFlags = __webpack_require__(/*! ./transferFlags */ "./node_modules/chai/lib/chai/utils/transferFlags.js");
9259
9260/**
9261 * ### .overwriteProperty(ctx, name, fn)
9262 *
9263 * Overwrites an already existing property getter and provides
9264 * access to previous value. Must return function to use as getter.
9265 *
9266 * utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
9267 * return function () {
9268 * var obj = utils.flag(this, 'object');
9269 * if (obj instanceof Foo) {
9270 * new chai.Assertion(obj.name).to.equal('bar');
9271 * } else {
9272 * _super.call(this);
9273 * }
9274 * }
9275 * });
9276 *
9277 *
9278 * Can also be accessed directly from `chai.Assertion`.
9279 *
9280 * chai.Assertion.overwriteProperty('foo', fn);
9281 *
9282 * Then can be used as any other assertion.
9283 *
9284 * expect(myFoo).to.be.ok;
9285 *
9286 * @param {Object} ctx object whose property is to be overwritten
9287 * @param {String} name of property to overwrite
9288 * @param {Function} getter function that returns a getter function to be used for name
9289 * @namespace Utils
9290 * @name overwriteProperty
9291 * @api public
9292 */
9293
9294module.exports = function overwriteProperty(ctx, name, getter) {
9295 var _get = Object.getOwnPropertyDescriptor(ctx, name)
9296 , _super = function () {};
9297
9298 if (_get && 'function' === typeof _get.get)
9299 _super = _get.get
9300
9301 Object.defineProperty(ctx, name,
9302 { get: function overwritingPropertyGetter() {
9303 // Setting the `ssfi` flag to `overwritingPropertyGetter` causes this
9304 // function to be the starting point for removing implementation frames
9305 // from the stack trace of a failed assertion.
9306 //
9307 // However, we only want to use this function as the starting point if
9308 // the `lockSsfi` flag isn't set and proxy protection is disabled.
9309 //
9310 // If the `lockSsfi` flag is set, then either this assertion has been
9311 // overwritten by another assertion, or this assertion is being invoked
9312 // from inside of another assertion. In the first case, the `ssfi` flag
9313 // has already been set by the overwriting assertion. In the second
9314 // case, the `ssfi` flag has already been set by the outer assertion.
9315 //
9316 // If proxy protection is enabled, then the `ssfi` flag has already been
9317 // set by the proxy getter.
9318 if (!isProxyEnabled() && !flag(this, 'lockSsfi')) {
9319 flag(this, 'ssfi', overwritingPropertyGetter);
9320 }
9321
9322 // Setting the `lockSsfi` flag to `true` prevents the overwritten
9323 // assertion from changing the `ssfi` flag. By this point, the `ssfi`
9324 // flag is already set to the correct starting point for this assertion.
9325 var origLockSsfi = flag(this, 'lockSsfi');
9326 flag(this, 'lockSsfi', true);
9327 var result = getter(_super).call(this);
9328 flag(this, 'lockSsfi', origLockSsfi);
9329
9330 if (result !== undefined) {
9331 return result;
9332 }
9333
9334 var newAssertion = new chai.Assertion();
9335 transferFlags(this, newAssertion);
9336 return newAssertion;
9337 }
9338 , configurable: true
9339 });
9340};
9341
9342
9343/***/ }),
9344
9345/***/ "./node_modules/chai/lib/chai/utils/proxify.js":
9346/*!*****************************************************!*\
9347 !*** ./node_modules/chai/lib/chai/utils/proxify.js ***!
9348 \*****************************************************/
9349/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9350
9351var config = __webpack_require__(/*! ../config */ "./node_modules/chai/lib/chai/config.js");
9352var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
9353var getProperties = __webpack_require__(/*! ./getProperties */ "./node_modules/chai/lib/chai/utils/getProperties.js");
9354var isProxyEnabled = __webpack_require__(/*! ./isProxyEnabled */ "./node_modules/chai/lib/chai/utils/isProxyEnabled.js");
9355
9356/*!
9357 * Chai - proxify utility
9358 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9359 * MIT Licensed
9360 */
9361
9362/**
9363 * ### .proxify(object)
9364 *
9365 * Return a proxy of given object that throws an error when a non-existent
9366 * property is read. By default, the root cause is assumed to be a misspelled
9367 * property, and thus an attempt is made to offer a reasonable suggestion from
9368 * the list of existing properties. However, if a nonChainableMethodName is
9369 * provided, then the root cause is instead a failure to invoke a non-chainable
9370 * method prior to reading the non-existent property.
9371 *
9372 * If proxies are unsupported or disabled via the user's Chai config, then
9373 * return object without modification.
9374 *
9375 * @param {Object} obj
9376 * @param {String} nonChainableMethodName
9377 * @namespace Utils
9378 * @name proxify
9379 */
9380
9381var builtins = ['__flags', '__methods', '_obj', 'assert'];
9382
9383module.exports = function proxify(obj, nonChainableMethodName) {
9384 if (!isProxyEnabled()) return obj;
9385
9386 return new Proxy(obj, {
9387 get: function proxyGetter(target, property) {
9388 // This check is here because we should not throw errors on Symbol properties
9389 // such as `Symbol.toStringTag`.
9390 // The values for which an error should be thrown can be configured using
9391 // the `config.proxyExcludedKeys` setting.
9392 if (typeof property === 'string' &&
9393 config.proxyExcludedKeys.indexOf(property) === -1 &&
9394 !Reflect.has(target, property)) {
9395 // Special message for invalid property access of non-chainable methods.
9396 if (nonChainableMethodName) {
9397 throw Error('Invalid Chai property: ' + nonChainableMethodName + '.' +
9398 property + '. See docs for proper usage of "' +
9399 nonChainableMethodName + '".');
9400 }
9401
9402 // If the property is reasonably close to an existing Chai property,
9403 // suggest that property to the user. Only suggest properties with a
9404 // distance less than 4.
9405 var suggestion = null;
9406 var suggestionDistance = 4;
9407 getProperties(target).forEach(function(prop) {
9408 if (
9409 !Object.prototype.hasOwnProperty(prop) &&
9410 builtins.indexOf(prop) === -1
9411 ) {
9412 var dist = stringDistanceCapped(
9413 property,
9414 prop,
9415 suggestionDistance
9416 );
9417 if (dist < suggestionDistance) {
9418 suggestion = prop;
9419 suggestionDistance = dist;
9420 }
9421 }
9422 });
9423
9424 if (suggestion !== null) {
9425 throw Error('Invalid Chai property: ' + property +
9426 '. Did you mean "' + suggestion + '"?');
9427 } else {
9428 throw Error('Invalid Chai property: ' + property);
9429 }
9430 }
9431
9432 // Use this proxy getter as the starting point for removing implementation
9433 // frames from the stack trace of a failed assertion. For property
9434 // assertions, this prevents the proxy getter from showing up in the stack
9435 // trace since it's invoked before the property getter. For method and
9436 // chainable method assertions, this flag will end up getting changed to
9437 // the method wrapper, which is good since this frame will no longer be in
9438 // the stack once the method is invoked. Note that Chai builtin assertion
9439 // properties such as `__flags` are skipped since this is only meant to
9440 // capture the starting point of an assertion. This step is also skipped
9441 // if the `lockSsfi` flag is set, thus indicating that this assertion is
9442 // being called from within another assertion. In that case, the `ssfi`
9443 // flag is already set to the outer assertion's starting point.
9444 if (builtins.indexOf(property) === -1 && !flag(target, 'lockSsfi')) {
9445 flag(target, 'ssfi', proxyGetter);
9446 }
9447
9448 return Reflect.get(target, property);
9449 }
9450 });
9451};
9452
9453/**
9454 * # stringDistanceCapped(strA, strB, cap)
9455 * Return the Levenshtein distance between two strings, but no more than cap.
9456 * @param {string} strA
9457 * @param {string} strB
9458 * @param {number} number
9459 * @return {number} min(string distance between strA and strB, cap)
9460 * @api private
9461 */
9462
9463function stringDistanceCapped(strA, strB, cap) {
9464 if (Math.abs(strA.length - strB.length) >= cap) {
9465 return cap;
9466 }
9467
9468 var memo = [];
9469 // `memo` is a two-dimensional array containing distances.
9470 // memo[i][j] is the distance between strA.slice(0, i) and
9471 // strB.slice(0, j).
9472 for (var i = 0; i <= strA.length; i++) {
9473 memo[i] = Array(strB.length + 1).fill(0);
9474 memo[i][0] = i;
9475 }
9476 for (var j = 0; j < strB.length; j++) {
9477 memo[0][j] = j;
9478 }
9479
9480 for (var i = 1; i <= strA.length; i++) {
9481 var ch = strA.charCodeAt(i - 1);
9482 for (var j = 1; j <= strB.length; j++) {
9483 if (Math.abs(i - j) >= cap) {
9484 memo[i][j] = cap;
9485 continue;
9486 }
9487 memo[i][j] = Math.min(
9488 memo[i - 1][j] + 1,
9489 memo[i][j - 1] + 1,
9490 memo[i - 1][j - 1] +
9491 (ch === strB.charCodeAt(j - 1) ? 0 : 1)
9492 );
9493 }
9494 }
9495
9496 return memo[strA.length][strB.length];
9497}
9498
9499
9500/***/ }),
9501
9502/***/ "./node_modules/chai/lib/chai/utils/test.js":
9503/*!**************************************************!*\
9504 !*** ./node_modules/chai/lib/chai/utils/test.js ***!
9505 \**************************************************/
9506/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9507
9508/*!
9509 * Chai - test utility
9510 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9511 * MIT Licensed
9512 */
9513
9514/*!
9515 * Module dependencies
9516 */
9517
9518var flag = __webpack_require__(/*! ./flag */ "./node_modules/chai/lib/chai/utils/flag.js");
9519
9520/**
9521 * ### .test(object, expression)
9522 *
9523 * Test and object for expression.
9524 *
9525 * @param {Object} object (constructed Assertion)
9526 * @param {Arguments} chai.Assertion.prototype.assert arguments
9527 * @namespace Utils
9528 * @name test
9529 */
9530
9531module.exports = function test(obj, args) {
9532 var negate = flag(obj, 'negate')
9533 , expr = args[0];
9534 return negate ? !expr : expr;
9535};
9536
9537
9538/***/ }),
9539
9540/***/ "./node_modules/chai/lib/chai/utils/transferFlags.js":
9541/*!***********************************************************!*\
9542 !*** ./node_modules/chai/lib/chai/utils/transferFlags.js ***!
9543 \***********************************************************/
9544/***/ ((module) => {
9545
9546/*!
9547 * Chai - transferFlags utility
9548 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
9549 * MIT Licensed
9550 */
9551
9552/**
9553 * ### .transferFlags(assertion, object, includeAll = true)
9554 *
9555 * Transfer all the flags for `assertion` to `object`. If
9556 * `includeAll` is set to `false`, then the base Chai
9557 * assertion flags (namely `object`, `ssfi`, `lockSsfi`,
9558 * and `message`) will not be transferred.
9559 *
9560 *
9561 * var newAssertion = new Assertion();
9562 * utils.transferFlags(assertion, newAssertion);
9563 *
9564 * var anotherAssertion = new Assertion(myObj);
9565 * utils.transferFlags(assertion, anotherAssertion, false);
9566 *
9567 * @param {Assertion} assertion the assertion to transfer the flags from
9568 * @param {Object} object the object to transfer the flags to; usually a new assertion
9569 * @param {Boolean} includeAll
9570 * @namespace Utils
9571 * @name transferFlags
9572 * @api private
9573 */
9574
9575module.exports = function transferFlags(assertion, object, includeAll) {
9576 var flags = assertion.__flags || (assertion.__flags = Object.create(null));
9577
9578 if (!object.__flags) {
9579 object.__flags = Object.create(null);
9580 }
9581
9582 includeAll = arguments.length === 3 ? includeAll : true;
9583
9584 for (var flag in flags) {
9585 if (includeAll ||
9586 (flag !== 'object' && flag !== 'ssfi' && flag !== 'lockSsfi' && flag != 'message')) {
9587 object.__flags[flag] = flags[flag];
9588 }
9589 }
9590};
9591
9592
9593/***/ }),
9594
9595/***/ "./node_modules/check-error/index.js":
9596/*!*******************************************!*\
9597 !*** ./node_modules/check-error/index.js ***!
9598 \*******************************************/
9599/***/ ((module) => {
9600
9601"use strict";
9602
9603
9604/* !
9605 * Chai - checkError utility
9606 * Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
9607 * MIT Licensed
9608 */
9609
9610/**
9611 * ### .checkError
9612 *
9613 * Checks that an error conforms to a given set of criteria and/or retrieves information about it.
9614 *
9615 * @api public
9616 */
9617
9618/**
9619 * ### .compatibleInstance(thrown, errorLike)
9620 *
9621 * Checks if two instances are compatible (strict equal).
9622 * Returns false if errorLike is not an instance of Error, because instances
9623 * can only be compatible if they're both error instances.
9624 *
9625 * @name compatibleInstance
9626 * @param {Error} thrown error
9627 * @param {Error|ErrorConstructor} errorLike object to compare against
9628 * @namespace Utils
9629 * @api public
9630 */
9631
9632function compatibleInstance(thrown, errorLike) {
9633 return errorLike instanceof Error && thrown === errorLike;
9634}
9635
9636/**
9637 * ### .compatibleConstructor(thrown, errorLike)
9638 *
9639 * Checks if two constructors are compatible.
9640 * This function can receive either an error constructor or
9641 * an error instance as the `errorLike` argument.
9642 * Constructors are compatible if they're the same or if one is
9643 * an instance of another.
9644 *
9645 * @name compatibleConstructor
9646 * @param {Error} thrown error
9647 * @param {Error|ErrorConstructor} errorLike object to compare against
9648 * @namespace Utils
9649 * @api public
9650 */
9651
9652function compatibleConstructor(thrown, errorLike) {
9653 if (errorLike instanceof Error) {
9654 // If `errorLike` is an instance of any error we compare their constructors
9655 return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
9656 } else if (errorLike.prototype instanceof Error || errorLike === Error) {
9657 // If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly
9658 return thrown.constructor === errorLike || thrown instanceof errorLike;
9659 }
9660
9661 return false;
9662}
9663
9664/**
9665 * ### .compatibleMessage(thrown, errMatcher)
9666 *
9667 * Checks if an error's message is compatible with a matcher (String or RegExp).
9668 * If the message contains the String or passes the RegExp test,
9669 * it is considered compatible.
9670 *
9671 * @name compatibleMessage
9672 * @param {Error} thrown error
9673 * @param {String|RegExp} errMatcher to look for into the message
9674 * @namespace Utils
9675 * @api public
9676 */
9677
9678function compatibleMessage(thrown, errMatcher) {
9679 var comparisonString = typeof thrown === 'string' ? thrown : thrown.message;
9680 if (errMatcher instanceof RegExp) {
9681 return errMatcher.test(comparisonString);
9682 } else if (typeof errMatcher === 'string') {
9683 return comparisonString.indexOf(errMatcher) !== -1; // eslint-disable-line no-magic-numbers
9684 }
9685
9686 return false;
9687}
9688
9689/**
9690 * ### .getFunctionName(constructorFn)
9691 *
9692 * Returns the name of a function.
9693 * This also includes a polyfill function if `constructorFn.name` is not defined.
9694 *
9695 * @name getFunctionName
9696 * @param {Function} constructorFn
9697 * @namespace Utils
9698 * @api private
9699 */
9700
9701var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/;
9702function getFunctionName(constructorFn) {
9703 var name = '';
9704 if (typeof constructorFn.name === 'undefined') {
9705 // Here we run a polyfill if constructorFn.name is not defined
9706 var match = String(constructorFn).match(functionNameMatch);
9707 if (match) {
9708 name = match[1];
9709 }
9710 } else {
9711 name = constructorFn.name;
9712 }
9713
9714 return name;
9715}
9716
9717/**
9718 * ### .getConstructorName(errorLike)
9719 *
9720 * Gets the constructor name for an Error instance or constructor itself.
9721 *
9722 * @name getConstructorName
9723 * @param {Error|ErrorConstructor} errorLike
9724 * @namespace Utils
9725 * @api public
9726 */
9727
9728function getConstructorName(errorLike) {
9729 var constructorName = errorLike;
9730 if (errorLike instanceof Error) {
9731 constructorName = getFunctionName(errorLike.constructor);
9732 } else if (typeof errorLike === 'function') {
9733 // If `err` is not an instance of Error it is an error constructor itself or another function.
9734 // If we've got a common function we get its name, otherwise we may need to create a new instance
9735 // of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more.
9736 constructorName = getFunctionName(errorLike).trim() ||
9737 getFunctionName(new errorLike()); // eslint-disable-line new-cap
9738 }
9739
9740 return constructorName;
9741}
9742
9743/**
9744 * ### .getMessage(errorLike)
9745 *
9746 * Gets the error message from an error.
9747 * If `err` is a String itself, we return it.
9748 * If the error has no message, we return an empty string.
9749 *
9750 * @name getMessage
9751 * @param {Error|String} errorLike
9752 * @namespace Utils
9753 * @api public
9754 */
9755
9756function getMessage(errorLike) {
9757 var msg = '';
9758 if (errorLike && errorLike.message) {
9759 msg = errorLike.message;
9760 } else if (typeof errorLike === 'string') {
9761 msg = errorLike;
9762 }
9763
9764 return msg;
9765}
9766
9767module.exports = {
9768 compatibleInstance: compatibleInstance,
9769 compatibleConstructor: compatibleConstructor,
9770 compatibleMessage: compatibleMessage,
9771 getMessage: getMessage,
9772 getConstructorName: getConstructorName,
9773};
9774
9775
9776/***/ }),
9777
9778/***/ "./node_modules/deep-eql/index.js":
9779/*!****************************************!*\
9780 !*** ./node_modules/deep-eql/index.js ***!
9781 \****************************************/
9782/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9783
9784"use strict";
9785
9786/* globals Symbol: false, Uint8Array: false, WeakMap: false */
9787/*!
9788 * deep-eql
9789 * Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
9790 * MIT Licensed
9791 */
9792
9793var type = __webpack_require__(/*! type-detect */ "./node_modules/type-detect/type-detect.js");
9794function FakeMap() {
9795 this._key = 'chai/deep-eql__' + Math.random() + Date.now();
9796}
9797
9798FakeMap.prototype = {
9799 get: function getMap(key) {
9800 return key[this._key];
9801 },
9802 set: function setMap(key, value) {
9803 if (Object.isExtensible(key)) {
9804 Object.defineProperty(key, this._key, {
9805 value: value,
9806 configurable: true,
9807 });
9808 }
9809 },
9810};
9811
9812var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap;
9813/*!
9814 * Check to see if the MemoizeMap has recorded a result of the two operands
9815 *
9816 * @param {Mixed} leftHandOperand
9817 * @param {Mixed} rightHandOperand
9818 * @param {MemoizeMap} memoizeMap
9819 * @returns {Boolean|null} result
9820*/
9821function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
9822 // Technically, WeakMap keys can *only* be objects, not primitives.
9823 if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
9824 return null;
9825 }
9826 var leftHandMap = memoizeMap.get(leftHandOperand);
9827 if (leftHandMap) {
9828 var result = leftHandMap.get(rightHandOperand);
9829 if (typeof result === 'boolean') {
9830 return result;
9831 }
9832 }
9833 return null;
9834}
9835
9836/*!
9837 * Set the result of the equality into the MemoizeMap
9838 *
9839 * @param {Mixed} leftHandOperand
9840 * @param {Mixed} rightHandOperand
9841 * @param {MemoizeMap} memoizeMap
9842 * @param {Boolean} result
9843*/
9844function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
9845 // Technically, WeakMap keys can *only* be objects, not primitives.
9846 if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
9847 return;
9848 }
9849 var leftHandMap = memoizeMap.get(leftHandOperand);
9850 if (leftHandMap) {
9851 leftHandMap.set(rightHandOperand, result);
9852 } else {
9853 leftHandMap = new MemoizeMap();
9854 leftHandMap.set(rightHandOperand, result);
9855 memoizeMap.set(leftHandOperand, leftHandMap);
9856 }
9857}
9858
9859/*!
9860 * Primary Export
9861 */
9862
9863module.exports = deepEqual;
9864module.exports.MemoizeMap = MemoizeMap;
9865
9866/**
9867 * Assert deeply nested sameValue equality between two objects of any type.
9868 *
9869 * @param {Mixed} leftHandOperand
9870 * @param {Mixed} rightHandOperand
9871 * @param {Object} [options] (optional) Additional options
9872 * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
9873 * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
9874 complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
9875 references to blow the stack.
9876 * @return {Boolean} equal match
9877 */
9878function deepEqual(leftHandOperand, rightHandOperand, options) {
9879 // If we have a comparator, we can't assume anything; so bail to its check first.
9880 if (options && options.comparator) {
9881 return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
9882 }
9883
9884 var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
9885 if (simpleResult !== null) {
9886 return simpleResult;
9887 }
9888
9889 // Deeper comparisons are pushed through to a larger function
9890 return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
9891}
9892
9893/**
9894 * Many comparisons can be canceled out early via simple equality or primitive checks.
9895 * @param {Mixed} leftHandOperand
9896 * @param {Mixed} rightHandOperand
9897 * @return {Boolean|null} equal match
9898 */
9899function simpleEqual(leftHandOperand, rightHandOperand) {
9900 // Equal references (except for Numbers) can be returned early
9901 if (leftHandOperand === rightHandOperand) {
9902 // Handle +-0 cases
9903 return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
9904 }
9905
9906 // handle NaN cases
9907 if (
9908 leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare
9909 rightHandOperand !== rightHandOperand // eslint-disable-line no-self-compare
9910 ) {
9911 return true;
9912 }
9913
9914 // Anything that is not an 'object', i.e. symbols, functions, booleans, numbers,
9915 // strings, and undefined, can be compared by reference.
9916 if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
9917 // Easy out b/c it would have passed the first equality check
9918 return false;
9919 }
9920 return null;
9921}
9922
9923/*!
9924 * The main logic of the `deepEqual` function.
9925 *
9926 * @param {Mixed} leftHandOperand
9927 * @param {Mixed} rightHandOperand
9928 * @param {Object} [options] (optional) Additional options
9929 * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
9930 * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
9931 complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
9932 references to blow the stack.
9933 * @return {Boolean} equal match
9934*/
9935function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
9936 options = options || {};
9937 options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
9938 var comparator = options && options.comparator;
9939
9940 // Check if a memoized result exists.
9941 var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
9942 if (memoizeResultLeft !== null) {
9943 return memoizeResultLeft;
9944 }
9945 var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
9946 if (memoizeResultRight !== null) {
9947 return memoizeResultRight;
9948 }
9949
9950 // If a comparator is present, use it.
9951 if (comparator) {
9952 var comparatorResult = comparator(leftHandOperand, rightHandOperand);
9953 // Comparators may return null, in which case we want to go back to default behavior.
9954 if (comparatorResult === false || comparatorResult === true) {
9955 memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
9956 return comparatorResult;
9957 }
9958 // To allow comparators to override *any* behavior, we ran them first. Since it didn't decide
9959 // what to do, we need to make sure to return the basic tests first before we move on.
9960 var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
9961 if (simpleResult !== null) {
9962 // Don't memoize this, it takes longer to set/retrieve than to just compare.
9963 return simpleResult;
9964 }
9965 }
9966
9967 var leftHandType = type(leftHandOperand);
9968 if (leftHandType !== type(rightHandOperand)) {
9969 memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
9970 return false;
9971 }
9972
9973 // Temporarily set the operands in the memoize object to prevent blowing the stack
9974 memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
9975
9976 var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
9977 memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
9978 return result;
9979}
9980
9981function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
9982 switch (leftHandType) {
9983 case 'String':
9984 case 'Number':
9985 case 'Boolean':
9986 case 'Date':
9987 // If these types are their instance types (e.g. `new Number`) then re-deepEqual against their values
9988 return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
9989 case 'Promise':
9990 case 'Symbol':
9991 case 'function':
9992 case 'WeakMap':
9993 case 'WeakSet':
9994 case 'Error':
9995 return leftHandOperand === rightHandOperand;
9996 case 'Arguments':
9997 case 'Int8Array':
9998 case 'Uint8Array':
9999 case 'Uint8ClampedArray':
10000 case 'Int16Array':
10001 case 'Uint16Array':
10002 case 'Int32Array':
10003 case 'Uint32Array':
10004 case 'Float32Array':
10005 case 'Float64Array':
10006 case 'Array':
10007 return iterableEqual(leftHandOperand, rightHandOperand, options);
10008 case 'RegExp':
10009 return regexpEqual(leftHandOperand, rightHandOperand);
10010 case 'Generator':
10011 return generatorEqual(leftHandOperand, rightHandOperand, options);
10012 case 'DataView':
10013 return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
10014 case 'ArrayBuffer':
10015 return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
10016 case 'Set':
10017 return entriesEqual(leftHandOperand, rightHandOperand, options);
10018 case 'Map':
10019 return entriesEqual(leftHandOperand, rightHandOperand, options);
10020 default:
10021 return objectEqual(leftHandOperand, rightHandOperand, options);
10022 }
10023}
10024
10025/*!
10026 * Compare two Regular Expressions for equality.
10027 *
10028 * @param {RegExp} leftHandOperand
10029 * @param {RegExp} rightHandOperand
10030 * @return {Boolean} result
10031 */
10032
10033function regexpEqual(leftHandOperand, rightHandOperand) {
10034 return leftHandOperand.toString() === rightHandOperand.toString();
10035}
10036
10037/*!
10038 * Compare two Sets/Maps for equality. Faster than other equality functions.
10039 *
10040 * @param {Set} leftHandOperand
10041 * @param {Set} rightHandOperand
10042 * @param {Object} [options] (Optional)
10043 * @return {Boolean} result
10044 */
10045
10046function entriesEqual(leftHandOperand, rightHandOperand, options) {
10047 // IE11 doesn't support Set#entries or Set#@@iterator, so we need manually populate using Set#forEach
10048 if (leftHandOperand.size !== rightHandOperand.size) {
10049 return false;
10050 }
10051 if (leftHandOperand.size === 0) {
10052 return true;
10053 }
10054 var leftHandItems = [];
10055 var rightHandItems = [];
10056 leftHandOperand.forEach(function gatherEntries(key, value) {
10057 leftHandItems.push([ key, value ]);
10058 });
10059 rightHandOperand.forEach(function gatherEntries(key, value) {
10060 rightHandItems.push([ key, value ]);
10061 });
10062 return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
10063}
10064
10065/*!
10066 * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
10067 *
10068 * @param {Iterable} leftHandOperand
10069 * @param {Iterable} rightHandOperand
10070 * @param {Object} [options] (Optional)
10071 * @return {Boolean} result
10072 */
10073
10074function iterableEqual(leftHandOperand, rightHandOperand, options) {
10075 var length = leftHandOperand.length;
10076 if (length !== rightHandOperand.length) {
10077 return false;
10078 }
10079 if (length === 0) {
10080 return true;
10081 }
10082 var index = -1;
10083 while (++index < length) {
10084 if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
10085 return false;
10086 }
10087 }
10088 return true;
10089}
10090
10091/*!
10092 * Simple equality for generator objects such as those returned by generator functions.
10093 *
10094 * @param {Iterable} leftHandOperand
10095 * @param {Iterable} rightHandOperand
10096 * @param {Object} [options] (Optional)
10097 * @return {Boolean} result
10098 */
10099
10100function generatorEqual(leftHandOperand, rightHandOperand, options) {
10101 return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
10102}
10103
10104/*!
10105 * Determine if the given object has an @@iterator function.
10106 *
10107 * @param {Object} target
10108 * @return {Boolean} `true` if the object has an @@iterator function.
10109 */
10110function hasIteratorFunction(target) {
10111 return typeof Symbol !== 'undefined' &&
10112 typeof target === 'object' &&
10113 typeof Symbol.iterator !== 'undefined' &&
10114 typeof target[Symbol.iterator] === 'function';
10115}
10116
10117/*!
10118 * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
10119 * This will consume the iterator - which could have side effects depending on the @@iterator implementation.
10120 *
10121 * @param {Object} target
10122 * @returns {Array} an array of entries from the @@iterator function
10123 */
10124function getIteratorEntries(target) {
10125 if (hasIteratorFunction(target)) {
10126 try {
10127 return getGeneratorEntries(target[Symbol.iterator]());
10128 } catch (iteratorError) {
10129 return [];
10130 }
10131 }
10132 return [];
10133}
10134
10135/*!
10136 * Gets all entries from a Generator. This will consume the generator - which could have side effects.
10137 *
10138 * @param {Generator} target
10139 * @returns {Array} an array of entries from the Generator.
10140 */
10141function getGeneratorEntries(generator) {
10142 var generatorResult = generator.next();
10143 var accumulator = [ generatorResult.value ];
10144 while (generatorResult.done === false) {
10145 generatorResult = generator.next();
10146 accumulator.push(generatorResult.value);
10147 }
10148 return accumulator;
10149}
10150
10151/*!
10152 * Gets all own and inherited enumerable keys from a target.
10153 *
10154 * @param {Object} target
10155 * @returns {Array} an array of own and inherited enumerable keys from the target.
10156 */
10157function getEnumerableKeys(target) {
10158 var keys = [];
10159 for (var key in target) {
10160 keys.push(key);
10161 }
10162 return keys;
10163}
10164
10165/*!
10166 * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
10167 * each key. If any value of the given key is not equal, the function will return false (early).
10168 *
10169 * @param {Mixed} leftHandOperand
10170 * @param {Mixed} rightHandOperand
10171 * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
10172 * @param {Object} [options] (Optional)
10173 * @return {Boolean} result
10174 */
10175function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
10176 var length = keys.length;
10177 if (length === 0) {
10178 return true;
10179 }
10180 for (var i = 0; i < length; i += 1) {
10181 if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
10182 return false;
10183 }
10184 }
10185 return true;
10186}
10187
10188/*!
10189 * Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
10190 * for each enumerable key in the object.
10191 *
10192 * @param {Mixed} leftHandOperand
10193 * @param {Mixed} rightHandOperand
10194 * @param {Object} [options] (Optional)
10195 * @return {Boolean} result
10196 */
10197
10198function objectEqual(leftHandOperand, rightHandOperand, options) {
10199 var leftHandKeys = getEnumerableKeys(leftHandOperand);
10200 var rightHandKeys = getEnumerableKeys(rightHandOperand);
10201 if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
10202 leftHandKeys.sort();
10203 rightHandKeys.sort();
10204 if (iterableEqual(leftHandKeys, rightHandKeys) === false) {
10205 return false;
10206 }
10207 return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
10208 }
10209
10210 var leftHandEntries = getIteratorEntries(leftHandOperand);
10211 var rightHandEntries = getIteratorEntries(rightHandOperand);
10212 if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
10213 leftHandEntries.sort();
10214 rightHandEntries.sort();
10215 return iterableEqual(leftHandEntries, rightHandEntries, options);
10216 }
10217
10218 if (leftHandKeys.length === 0 &&
10219 leftHandEntries.length === 0 &&
10220 rightHandKeys.length === 0 &&
10221 rightHandEntries.length === 0) {
10222 return true;
10223 }
10224
10225 return false;
10226}
10227
10228/*!
10229 * Returns true if the argument is a primitive.
10230 *
10231 * This intentionally returns true for all objects that can be compared by reference,
10232 * including functions and symbols.
10233 *
10234 * @param {Mixed} value
10235 * @return {Boolean} result
10236 */
10237function isPrimitive(value) {
10238 return value === null || typeof value !== 'object';
10239}
10240
10241
10242/***/ }),
10243
10244/***/ "./node_modules/foreach/index.js":
10245/*!***************************************!*\
10246 !*** ./node_modules/foreach/index.js ***!
10247 \***************************************/
10248/***/ ((module) => {
10249
10250
10251var hasOwn = Object.prototype.hasOwnProperty;
10252var toString = Object.prototype.toString;
10253
10254module.exports = function forEach (obj, fn, ctx) {
10255 if (toString.call(fn) !== '[object Function]') {
10256 throw new TypeError('iterator must be a function');
10257 }
10258 var l = obj.length;
10259 if (l === +l) {
10260 for (var i = 0; i < l; i++) {
10261 fn.call(ctx, obj[i], i, obj);
10262 }
10263 } else {
10264 for (var k in obj) {
10265 if (hasOwn.call(obj, k)) {
10266 fn.call(ctx, obj[k], k, obj);
10267 }
10268 }
10269 }
10270};
10271
10272
10273
10274/***/ }),
10275
10276/***/ "./node_modules/function-bind/implementation.js":
10277/*!******************************************************!*\
10278 !*** ./node_modules/function-bind/implementation.js ***!
10279 \******************************************************/
10280/***/ ((module) => {
10281
10282"use strict";
10283
10284
10285/* eslint no-invalid-this: 1 */
10286
10287var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
10288var slice = Array.prototype.slice;
10289var toStr = Object.prototype.toString;
10290var funcType = '[object Function]';
10291
10292module.exports = function bind(that) {
10293 var target = this;
10294 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
10295 throw new TypeError(ERROR_MESSAGE + target);
10296 }
10297 var args = slice.call(arguments, 1);
10298
10299 var bound;
10300 var binder = function () {
10301 if (this instanceof bound) {
10302 var result = target.apply(
10303 this,
10304 args.concat(slice.call(arguments))
10305 );
10306 if (Object(result) === result) {
10307 return result;
10308 }
10309 return this;
10310 } else {
10311 return target.apply(
10312 that,
10313 args.concat(slice.call(arguments))
10314 );
10315 }
10316 };
10317
10318 var boundLength = Math.max(0, target.length - args.length);
10319 var boundArgs = [];
10320 for (var i = 0; i < boundLength; i++) {
10321 boundArgs.push('$' + i);
10322 }
10323
10324 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
10325
10326 if (target.prototype) {
10327 var Empty = function Empty() {};
10328 Empty.prototype = target.prototype;
10329 bound.prototype = new Empty();
10330 Empty.prototype = null;
10331 }
10332
10333 return bound;
10334};
10335
10336
10337/***/ }),
10338
10339/***/ "./node_modules/function-bind/index.js":
10340/*!*********************************************!*\
10341 !*** ./node_modules/function-bind/index.js ***!
10342 \*********************************************/
10343/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10344
10345"use strict";
10346
10347
10348var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/function-bind/implementation.js");
10349
10350module.exports = Function.prototype.bind || implementation;
10351
10352
10353/***/ }),
10354
10355/***/ "./node_modules/get-func-name/index.js":
10356/*!*********************************************!*\
10357 !*** ./node_modules/get-func-name/index.js ***!
10358 \*********************************************/
10359/***/ ((module) => {
10360
10361"use strict";
10362
10363
10364/* !
10365 * Chai - getFuncName utility
10366 * Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
10367 * MIT Licensed
10368 */
10369
10370/**
10371 * ### .getFuncName(constructorFn)
10372 *
10373 * Returns the name of a function.
10374 * When a non-function instance is passed, returns `null`.
10375 * This also includes a polyfill function if `aFunc.name` is not defined.
10376 *
10377 * @name getFuncName
10378 * @param {Function} funct
10379 * @namespace Utils
10380 * @api public
10381 */
10382
10383var toString = Function.prototype.toString;
10384var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
10385function getFuncName(aFunc) {
10386 if (typeof aFunc !== 'function') {
10387 return null;
10388 }
10389
10390 var name = '';
10391 if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') {
10392 // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined
10393 var match = toString.call(aFunc).match(functionNameMatch);
10394 if (match) {
10395 name = match[1];
10396 }
10397 } else {
10398 // If we've got a `name` property we just use it
10399 name = aFunc.name;
10400 }
10401
10402 return name;
10403}
10404
10405module.exports = getFuncName;
10406
10407
10408/***/ }),
10409
10410/***/ "./node_modules/get-intrinsic/index.js":
10411/*!*********************************************!*\
10412 !*** ./node_modules/get-intrinsic/index.js ***!
10413 \*********************************************/
10414/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10415
10416"use strict";
10417
10418
10419var undefined;
10420
10421var $SyntaxError = SyntaxError;
10422var $Function = Function;
10423var $TypeError = TypeError;
10424
10425// eslint-disable-next-line consistent-return
10426var getEvalledConstructor = function (expressionSyntax) {
10427 try {
10428 return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
10429 } catch (e) {}
10430};
10431
10432var $gOPD = Object.getOwnPropertyDescriptor;
10433if ($gOPD) {
10434 try {
10435 $gOPD({}, '');
10436 } catch (e) {
10437 $gOPD = null; // this is IE 8, which has a broken gOPD
10438 }
10439}
10440
10441var throwTypeError = function () {
10442 throw new $TypeError();
10443};
10444var ThrowTypeError = $gOPD
10445 ? (function () {
10446 try {
10447 // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
10448 arguments.callee; // IE 8 does not throw here
10449 return throwTypeError;
10450 } catch (calleeThrows) {
10451 try {
10452 // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
10453 return $gOPD(arguments, 'callee').get;
10454 } catch (gOPDthrows) {
10455 return throwTypeError;
10456 }
10457 }
10458 }())
10459 : throwTypeError;
10460
10461var hasSymbols = __webpack_require__(/*! has-symbols */ "./node_modules/has-symbols/index.js")();
10462
10463var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
10464
10465var needsEval = {};
10466
10467var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
10468
10469var INTRINSICS = {
10470 '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
10471 '%Array%': Array,
10472 '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
10473 '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
10474 '%AsyncFromSyncIteratorPrototype%': undefined,
10475 '%AsyncFunction%': needsEval,
10476 '%AsyncGenerator%': needsEval,
10477 '%AsyncGeneratorFunction%': needsEval,
10478 '%AsyncIteratorPrototype%': needsEval,
10479 '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
10480 '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
10481 '%Boolean%': Boolean,
10482 '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
10483 '%Date%': Date,
10484 '%decodeURI%': decodeURI,
10485 '%decodeURIComponent%': decodeURIComponent,
10486 '%encodeURI%': encodeURI,
10487 '%encodeURIComponent%': encodeURIComponent,
10488 '%Error%': Error,
10489 '%eval%': eval, // eslint-disable-line no-eval
10490 '%EvalError%': EvalError,
10491 '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
10492 '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
10493 '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
10494 '%Function%': $Function,
10495 '%GeneratorFunction%': needsEval,
10496 '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
10497 '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
10498 '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
10499 '%isFinite%': isFinite,
10500 '%isNaN%': isNaN,
10501 '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
10502 '%JSON%': typeof JSON === 'object' ? JSON : undefined,
10503 '%Map%': typeof Map === 'undefined' ? undefined : Map,
10504 '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
10505 '%Math%': Math,
10506 '%Number%': Number,
10507 '%Object%': Object,
10508 '%parseFloat%': parseFloat,
10509 '%parseInt%': parseInt,
10510 '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
10511 '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
10512 '%RangeError%': RangeError,
10513 '%ReferenceError%': ReferenceError,
10514 '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
10515 '%RegExp%': RegExp,
10516 '%Set%': typeof Set === 'undefined' ? undefined : Set,
10517 '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
10518 '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
10519 '%String%': String,
10520 '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
10521 '%Symbol%': hasSymbols ? Symbol : undefined,
10522 '%SyntaxError%': $SyntaxError,
10523 '%ThrowTypeError%': ThrowTypeError,
10524 '%TypedArray%': TypedArray,
10525 '%TypeError%': $TypeError,
10526 '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
10527 '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
10528 '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
10529 '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
10530 '%URIError%': URIError,
10531 '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
10532 '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
10533 '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
10534};
10535
10536var doEval = function doEval(name) {
10537 var value;
10538 if (name === '%AsyncFunction%') {
10539 value = getEvalledConstructor('async function () {}');
10540 } else if (name === '%GeneratorFunction%') {
10541 value = getEvalledConstructor('function* () {}');
10542 } else if (name === '%AsyncGeneratorFunction%') {
10543 value = getEvalledConstructor('async function* () {}');
10544 } else if (name === '%AsyncGenerator%') {
10545 var fn = doEval('%AsyncGeneratorFunction%');
10546 if (fn) {
10547 value = fn.prototype;
10548 }
10549 } else if (name === '%AsyncIteratorPrototype%') {
10550 var gen = doEval('%AsyncGenerator%');
10551 if (gen) {
10552 value = getProto(gen.prototype);
10553 }
10554 }
10555
10556 INTRINSICS[name] = value;
10557
10558 return value;
10559};
10560
10561var LEGACY_ALIASES = {
10562 '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
10563 '%ArrayPrototype%': ['Array', 'prototype'],
10564 '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
10565 '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
10566 '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
10567 '%ArrayProto_values%': ['Array', 'prototype', 'values'],
10568 '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
10569 '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
10570 '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
10571 '%BooleanPrototype%': ['Boolean', 'prototype'],
10572 '%DataViewPrototype%': ['DataView', 'prototype'],
10573 '%DatePrototype%': ['Date', 'prototype'],
10574 '%ErrorPrototype%': ['Error', 'prototype'],
10575 '%EvalErrorPrototype%': ['EvalError', 'prototype'],
10576 '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
10577 '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
10578 '%FunctionPrototype%': ['Function', 'prototype'],
10579 '%Generator%': ['GeneratorFunction', 'prototype'],
10580 '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
10581 '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
10582 '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
10583 '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
10584 '%JSONParse%': ['JSON', 'parse'],
10585 '%JSONStringify%': ['JSON', 'stringify'],
10586 '%MapPrototype%': ['Map', 'prototype'],
10587 '%NumberPrototype%': ['Number', 'prototype'],
10588 '%ObjectPrototype%': ['Object', 'prototype'],
10589 '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
10590 '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
10591 '%PromisePrototype%': ['Promise', 'prototype'],
10592 '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
10593 '%Promise_all%': ['Promise', 'all'],
10594 '%Promise_reject%': ['Promise', 'reject'],
10595 '%Promise_resolve%': ['Promise', 'resolve'],
10596 '%RangeErrorPrototype%': ['RangeError', 'prototype'],
10597 '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
10598 '%RegExpPrototype%': ['RegExp', 'prototype'],
10599 '%SetPrototype%': ['Set', 'prototype'],
10600 '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
10601 '%StringPrototype%': ['String', 'prototype'],
10602 '%SymbolPrototype%': ['Symbol', 'prototype'],
10603 '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
10604 '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
10605 '%TypeErrorPrototype%': ['TypeError', 'prototype'],
10606 '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
10607 '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
10608 '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
10609 '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
10610 '%URIErrorPrototype%': ['URIError', 'prototype'],
10611 '%WeakMapPrototype%': ['WeakMap', 'prototype'],
10612 '%WeakSetPrototype%': ['WeakSet', 'prototype']
10613};
10614
10615var bind = __webpack_require__(/*! function-bind */ "./node_modules/function-bind/index.js");
10616var hasOwn = __webpack_require__(/*! has */ "./node_modules/has/src/index.js");
10617var $concat = bind.call(Function.call, Array.prototype.concat);
10618var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
10619var $replace = bind.call(Function.call, String.prototype.replace);
10620var $strSlice = bind.call(Function.call, String.prototype.slice);
10621
10622/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
10623var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
10624var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
10625var stringToPath = function stringToPath(string) {
10626 var first = $strSlice(string, 0, 1);
10627 var last = $strSlice(string, -1);
10628 if (first === '%' && last !== '%') {
10629 throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
10630 } else if (last === '%' && first !== '%') {
10631 throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
10632 }
10633 var result = [];
10634 $replace(string, rePropName, function (match, number, quote, subString) {
10635 result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
10636 });
10637 return result;
10638};
10639/* end adaptation */
10640
10641var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
10642 var intrinsicName = name;
10643 var alias;
10644 if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
10645 alias = LEGACY_ALIASES[intrinsicName];
10646 intrinsicName = '%' + alias[0] + '%';
10647 }
10648
10649 if (hasOwn(INTRINSICS, intrinsicName)) {
10650 var value = INTRINSICS[intrinsicName];
10651 if (value === needsEval) {
10652 value = doEval(intrinsicName);
10653 }
10654 if (typeof value === 'undefined' && !allowMissing) {
10655 throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
10656 }
10657
10658 return {
10659 alias: alias,
10660 name: intrinsicName,
10661 value: value
10662 };
10663 }
10664
10665 throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
10666};
10667
10668module.exports = function GetIntrinsic(name, allowMissing) {
10669 if (typeof name !== 'string' || name.length === 0) {
10670 throw new $TypeError('intrinsic name must be a non-empty string');
10671 }
10672 if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
10673 throw new $TypeError('"allowMissing" argument must be a boolean');
10674 }
10675
10676 var parts = stringToPath(name);
10677 var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
10678
10679 var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
10680 var intrinsicRealName = intrinsic.name;
10681 var value = intrinsic.value;
10682 var skipFurtherCaching = false;
10683
10684 var alias = intrinsic.alias;
10685 if (alias) {
10686 intrinsicBaseName = alias[0];
10687 $spliceApply(parts, $concat([0, 1], alias));
10688 }
10689
10690 for (var i = 1, isOwn = true; i < parts.length; i += 1) {
10691 var part = parts[i];
10692 var first = $strSlice(part, 0, 1);
10693 var last = $strSlice(part, -1);
10694 if (
10695 (
10696 (first === '"' || first === "'" || first === '`')
10697 || (last === '"' || last === "'" || last === '`')
10698 )
10699 && first !== last
10700 ) {
10701 throw new $SyntaxError('property names with quotes must have matching quotes');
10702 }
10703 if (part === 'constructor' || !isOwn) {
10704 skipFurtherCaching = true;
10705 }
10706
10707 intrinsicBaseName += '.' + part;
10708 intrinsicRealName = '%' + intrinsicBaseName + '%';
10709
10710 if (hasOwn(INTRINSICS, intrinsicRealName)) {
10711 value = INTRINSICS[intrinsicRealName];
10712 } else if (value != null) {
10713 if (!(part in value)) {
10714 if (!allowMissing) {
10715 throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
10716 }
10717 return void undefined;
10718 }
10719 if ($gOPD && (i + 1) >= parts.length) {
10720 var desc = $gOPD(value, part);
10721 isOwn = !!desc;
10722
10723 // By convention, when a data property is converted to an accessor
10724 // property to emulate a data property that does not suffer from
10725 // the override mistake, that accessor's getter is marked with
10726 // an `originalValue` property. Here, when we detect this, we
10727 // uphold the illusion by pretending to see that original data
10728 // property, i.e., returning the value rather than the getter
10729 // itself.
10730 if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
10731 value = desc.get;
10732 } else {
10733 value = value[part];
10734 }
10735 } else {
10736 isOwn = hasOwn(value, part);
10737 value = value[part];
10738 }
10739
10740 if (isOwn && !skipFurtherCaching) {
10741 INTRINSICS[intrinsicRealName] = value;
10742 }
10743 }
10744 }
10745 return value;
10746};
10747
10748
10749/***/ }),
10750
10751/***/ "./node_modules/has-symbols/index.js":
10752/*!*******************************************!*\
10753 !*** ./node_modules/has-symbols/index.js ***!
10754 \*******************************************/
10755/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10756
10757"use strict";
10758
10759
10760var origSymbol = typeof Symbol !== 'undefined' && Symbol;
10761var hasSymbolSham = __webpack_require__(/*! ./shams */ "./node_modules/has-symbols/shams.js");
10762
10763module.exports = function hasNativeSymbols() {
10764 if (typeof origSymbol !== 'function') { return false; }
10765 if (typeof Symbol !== 'function') { return false; }
10766 if (typeof origSymbol('foo') !== 'symbol') { return false; }
10767 if (typeof Symbol('bar') !== 'symbol') { return false; }
10768
10769 return hasSymbolSham();
10770};
10771
10772
10773/***/ }),
10774
10775/***/ "./node_modules/has-symbols/shams.js":
10776/*!*******************************************!*\
10777 !*** ./node_modules/has-symbols/shams.js ***!
10778 \*******************************************/
10779/***/ ((module) => {
10780
10781"use strict";
10782
10783
10784/* eslint complexity: [2, 18], max-statements: [2, 33] */
10785module.exports = function hasSymbols() {
10786 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
10787 if (typeof Symbol.iterator === 'symbol') { return true; }
10788
10789 var obj = {};
10790 var sym = Symbol('test');
10791 var symObj = Object(sym);
10792 if (typeof sym === 'string') { return false; }
10793
10794 if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
10795 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
10796
10797 // temp disabled per https://github.com/ljharb/object.assign/issues/17
10798 // if (sym instanceof Symbol) { return false; }
10799 // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
10800 // if (!(symObj instanceof Symbol)) { return false; }
10801
10802 // if (typeof Symbol.prototype.toString !== 'function') { return false; }
10803 // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
10804
10805 var symVal = 42;
10806 obj[sym] = symVal;
10807 for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
10808 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
10809
10810 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
10811
10812 var syms = Object.getOwnPropertySymbols(obj);
10813 if (syms.length !== 1 || syms[0] !== sym) { return false; }
10814
10815 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
10816
10817 if (typeof Object.getOwnPropertyDescriptor === 'function') {
10818 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
10819 if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
10820 }
10821
10822 return true;
10823};
10824
10825
10826/***/ }),
10827
10828/***/ "./node_modules/has-tostringtag/shams.js":
10829/*!***********************************************!*\
10830 !*** ./node_modules/has-tostringtag/shams.js ***!
10831 \***********************************************/
10832/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10833
10834"use strict";
10835
10836
10837var hasSymbols = __webpack_require__(/*! has-symbols/shams */ "./node_modules/has-symbols/shams.js");
10838
10839module.exports = function hasToStringTagShams() {
10840 return hasSymbols() && !!Symbol.toStringTag;
10841};
10842
10843
10844/***/ }),
10845
10846/***/ "./node_modules/has/src/index.js":
10847/*!***************************************!*\
10848 !*** ./node_modules/has/src/index.js ***!
10849 \***************************************/
10850/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10851
10852"use strict";
10853
10854
10855var bind = __webpack_require__(/*! function-bind */ "./node_modules/function-bind/index.js");
10856
10857module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
10858
10859
10860/***/ }),
10861
10862/***/ "./node_modules/inherits/inherits_browser.js":
10863/*!***************************************************!*\
10864 !*** ./node_modules/inherits/inherits_browser.js ***!
10865 \***************************************************/
10866/***/ ((module) => {
10867
10868if (typeof Object.create === 'function') {
10869 // implementation from standard node.js 'util' module
10870 module.exports = function inherits(ctor, superCtor) {
10871 if (superCtor) {
10872 ctor.super_ = superCtor
10873 ctor.prototype = Object.create(superCtor.prototype, {
10874 constructor: {
10875 value: ctor,
10876 enumerable: false,
10877 writable: true,
10878 configurable: true
10879 }
10880 })
10881 }
10882 };
10883} else {
10884 // old school shim for old browsers
10885 module.exports = function inherits(ctor, superCtor) {
10886 if (superCtor) {
10887 ctor.super_ = superCtor
10888 var TempCtor = function () {}
10889 TempCtor.prototype = superCtor.prototype
10890 ctor.prototype = new TempCtor()
10891 ctor.prototype.constructor = ctor
10892 }
10893 }
10894}
10895
10896
10897/***/ }),
10898
10899/***/ "./node_modules/is-arguments/index.js":
10900/*!********************************************!*\
10901 !*** ./node_modules/is-arguments/index.js ***!
10902 \********************************************/
10903/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10904
10905"use strict";
10906
10907
10908var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
10909var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
10910
10911var $toString = callBound('Object.prototype.toString');
10912
10913var isStandardArguments = function isArguments(value) {
10914 if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
10915 return false;
10916 }
10917 return $toString(value) === '[object Arguments]';
10918};
10919
10920var isLegacyArguments = function isArguments(value) {
10921 if (isStandardArguments(value)) {
10922 return true;
10923 }
10924 return value !== null &&
10925 typeof value === 'object' &&
10926 typeof value.length === 'number' &&
10927 value.length >= 0 &&
10928 $toString(value) !== '[object Array]' &&
10929 $toString(value.callee) === '[object Function]';
10930};
10931
10932var supportsStandardArguments = (function () {
10933 return isStandardArguments(arguments);
10934}());
10935
10936isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
10937
10938module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
10939
10940
10941/***/ }),
10942
10943/***/ "./node_modules/is-generator-function/index.js":
10944/*!*****************************************************!*\
10945 !*** ./node_modules/is-generator-function/index.js ***!
10946 \*****************************************************/
10947/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10948
10949"use strict";
10950
10951
10952var toStr = Object.prototype.toString;
10953var fnToStr = Function.prototype.toString;
10954var isFnRegex = /^\s*(?:function)?\*/;
10955var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
10956var getProto = Object.getPrototypeOf;
10957var getGeneratorFunc = function () { // eslint-disable-line consistent-return
10958 if (!hasToStringTag) {
10959 return false;
10960 }
10961 try {
10962 return Function('return function*() {}')();
10963 } catch (e) {
10964 }
10965};
10966var GeneratorFunction;
10967
10968module.exports = function isGeneratorFunction(fn) {
10969 if (typeof fn !== 'function') {
10970 return false;
10971 }
10972 if (isFnRegex.test(fnToStr.call(fn))) {
10973 return true;
10974 }
10975 if (!hasToStringTag) {
10976 var str = toStr.call(fn);
10977 return str === '[object GeneratorFunction]';
10978 }
10979 if (!getProto) {
10980 return false;
10981 }
10982 if (typeof GeneratorFunction === 'undefined') {
10983 var generatorFunc = getGeneratorFunc();
10984 GeneratorFunction = generatorFunc ? getProto(generatorFunc) : false;
10985 }
10986 return getProto(fn) === GeneratorFunction;
10987};
10988
10989
10990/***/ }),
10991
10992/***/ "./node_modules/is-typed-array/index.js":
10993/*!**********************************************!*\
10994 !*** ./node_modules/is-typed-array/index.js ***!
10995 \**********************************************/
10996/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10997
10998"use strict";
10999
11000
11001var forEach = __webpack_require__(/*! foreach */ "./node_modules/foreach/index.js");
11002var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
11003var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
11004
11005var $toString = callBound('Object.prototype.toString');
11006var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
11007
11008var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
11009var typedArrays = availableTypedArrays();
11010
11011var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
11012 for (var i = 0; i < array.length; i += 1) {
11013 if (array[i] === value) {
11014 return i;
11015 }
11016 }
11017 return -1;
11018};
11019var $slice = callBound('String.prototype.slice');
11020var toStrTags = {};
11021var gOPD = __webpack_require__(/*! es-abstract/helpers/getOwnPropertyDescriptor */ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js");
11022var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
11023if (hasToStringTag && gOPD && getPrototypeOf) {
11024 forEach(typedArrays, function (typedArray) {
11025 var arr = new g[typedArray]();
11026 if (Symbol.toStringTag in arr) {
11027 var proto = getPrototypeOf(arr);
11028 var descriptor = gOPD(proto, Symbol.toStringTag);
11029 if (!descriptor) {
11030 var superProto = getPrototypeOf(proto);
11031 descriptor = gOPD(superProto, Symbol.toStringTag);
11032 }
11033 toStrTags[typedArray] = descriptor.get;
11034 }
11035 });
11036}
11037
11038var tryTypedArrays = function tryAllTypedArrays(value) {
11039 var anyTrue = false;
11040 forEach(toStrTags, function (getter, typedArray) {
11041 if (!anyTrue) {
11042 try {
11043 anyTrue = getter.call(value) === typedArray;
11044 } catch (e) { /**/ }
11045 }
11046 });
11047 return anyTrue;
11048};
11049
11050module.exports = function isTypedArray(value) {
11051 if (!value || typeof value !== 'object') { return false; }
11052 if (!hasToStringTag || !(Symbol.toStringTag in value)) {
11053 var tag = $slice($toString(value), 8, -1);
11054 return $indexOf(typedArrays, tag) > -1;
11055 }
11056 if (!gOPD) { return false; }
11057 return tryTypedArrays(value);
11058};
11059
11060
11061/***/ }),
11062
11063/***/ "./node_modules/loupe/loupe.js":
11064/*!*************************************!*\
11065 !*** ./node_modules/loupe/loupe.js ***!
11066 \*************************************/
11067/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
11068
11069(function (global, factory) {
11070 true ? factory(exports) :
11071 0;
11072}(this, (function (exports) { 'use strict';
11073
11074 function _typeof(obj) {
11075 "@babel/helpers - typeof";
11076
11077 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
11078 _typeof = function (obj) {
11079 return typeof obj;
11080 };
11081 } else {
11082 _typeof = function (obj) {
11083 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11084 };
11085 }
11086
11087 return _typeof(obj);
11088 }
11089
11090 function _slicedToArray(arr, i) {
11091 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
11092 }
11093
11094 function _arrayWithHoles(arr) {
11095 if (Array.isArray(arr)) return arr;
11096 }
11097
11098 function _iterableToArrayLimit(arr, i) {
11099 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
11100 var _arr = [];
11101 var _n = true;
11102 var _d = false;
11103 var _e = undefined;
11104
11105 try {
11106 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
11107 _arr.push(_s.value);
11108
11109 if (i && _arr.length === i) break;
11110 }
11111 } catch (err) {
11112 _d = true;
11113 _e = err;
11114 } finally {
11115 try {
11116 if (!_n && _i["return"] != null) _i["return"]();
11117 } finally {
11118 if (_d) throw _e;
11119 }
11120 }
11121
11122 return _arr;
11123 }
11124
11125 function _unsupportedIterableToArray(o, minLen) {
11126 if (!o) return;
11127 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
11128 var n = Object.prototype.toString.call(o).slice(8, -1);
11129 if (n === "Object" && o.constructor) n = o.constructor.name;
11130 if (n === "Map" || n === "Set") return Array.from(o);
11131 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
11132 }
11133
11134 function _arrayLikeToArray(arr, len) {
11135 if (len == null || len > arr.length) len = arr.length;
11136
11137 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
11138
11139 return arr2;
11140 }
11141
11142 function _nonIterableRest() {
11143 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
11144 }
11145
11146 var ansiColors = {
11147 bold: ['1', '22'],
11148 dim: ['2', '22'],
11149 italic: ['3', '23'],
11150 underline: ['4', '24'],
11151 // 5 & 6 are blinking
11152 inverse: ['7', '27'],
11153 hidden: ['8', '28'],
11154 strike: ['9', '29'],
11155 // 10-20 are fonts
11156 // 21-29 are resets for 1-9
11157 black: ['30', '39'],
11158 red: ['31', '39'],
11159 green: ['32', '39'],
11160 yellow: ['33', '39'],
11161 blue: ['34', '39'],
11162 magenta: ['35', '39'],
11163 cyan: ['36', '39'],
11164 white: ['37', '39'],
11165 brightblack: ['30;1', '39'],
11166 brightred: ['31;1', '39'],
11167 brightgreen: ['32;1', '39'],
11168 brightyellow: ['33;1', '39'],
11169 brightblue: ['34;1', '39'],
11170 brightmagenta: ['35;1', '39'],
11171 brightcyan: ['36;1', '39'],
11172 brightwhite: ['37;1', '39'],
11173 grey: ['90', '39']
11174 };
11175 var styles = {
11176 special: 'cyan',
11177 number: 'yellow',
11178 bigint: 'yellow',
11179 boolean: 'yellow',
11180 undefined: 'grey',
11181 null: 'bold',
11182 string: 'green',
11183 symbol: 'green',
11184 date: 'magenta',
11185 regexp: 'red'
11186 };
11187 var truncator = '…';
11188
11189 function colorise(value, styleType) {
11190 var color = ansiColors[styles[styleType]] || ansiColors[styleType];
11191
11192 if (!color) {
11193 return String(value);
11194 }
11195
11196 return "\x1B[".concat(color[0], "m").concat(String(value), "\x1B[").concat(color[1], "m");
11197 }
11198
11199 function normaliseOptions() {
11200 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
11201 _ref$showHidden = _ref.showHidden,
11202 showHidden = _ref$showHidden === void 0 ? false : _ref$showHidden,
11203 _ref$depth = _ref.depth,
11204 depth = _ref$depth === void 0 ? 2 : _ref$depth,
11205 _ref$colors = _ref.colors,
11206 colors = _ref$colors === void 0 ? false : _ref$colors,
11207 _ref$customInspect = _ref.customInspect,
11208 customInspect = _ref$customInspect === void 0 ? true : _ref$customInspect,
11209 _ref$showProxy = _ref.showProxy,
11210 showProxy = _ref$showProxy === void 0 ? false : _ref$showProxy,
11211 _ref$maxArrayLength = _ref.maxArrayLength,
11212 maxArrayLength = _ref$maxArrayLength === void 0 ? Infinity : _ref$maxArrayLength,
11213 _ref$breakLength = _ref.breakLength,
11214 breakLength = _ref$breakLength === void 0 ? Infinity : _ref$breakLength,
11215 _ref$seen = _ref.seen,
11216 seen = _ref$seen === void 0 ? [] : _ref$seen,
11217 _ref$truncate = _ref.truncate,
11218 truncate = _ref$truncate === void 0 ? Infinity : _ref$truncate,
11219 _ref$stylize = _ref.stylize,
11220 stylize = _ref$stylize === void 0 ? String : _ref$stylize;
11221
11222 var options = {
11223 showHidden: Boolean(showHidden),
11224 depth: Number(depth),
11225 colors: Boolean(colors),
11226 customInspect: Boolean(customInspect),
11227 showProxy: Boolean(showProxy),
11228 maxArrayLength: Number(maxArrayLength),
11229 breakLength: Number(breakLength),
11230 truncate: Number(truncate),
11231 seen: seen,
11232 stylize: stylize
11233 };
11234
11235 if (options.colors) {
11236 options.stylize = colorise;
11237 }
11238
11239 return options;
11240 }
11241 function truncate(string, length) {
11242 var tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : truncator;
11243 string = String(string);
11244 var tailLength = tail.length;
11245 var stringLength = string.length;
11246
11247 if (tailLength > length && stringLength > tailLength) {
11248 return tail;
11249 }
11250
11251 if (stringLength > length && stringLength > tailLength) {
11252 return "".concat(string.slice(0, length - tailLength)).concat(tail);
11253 }
11254
11255 return string;
11256 } // eslint-disable-next-line complexity
11257
11258 function inspectList(list, options, inspectItem) {
11259 var separator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
11260 inspectItem = inspectItem || options.inspect;
11261 var size = list.length;
11262 if (size === 0) return '';
11263 var originalLength = options.truncate;
11264 var output = '';
11265 var peek = '';
11266 var truncated = '';
11267
11268 for (var i = 0; i < size; i += 1) {
11269 var last = i + 1 === list.length;
11270 var secondToLast = i + 2 === list.length;
11271 truncated = "".concat(truncator, "(").concat(list.length - i, ")");
11272 var value = list[i]; // If there is more than one remaining we need to account for a separator of `, `
11273
11274 options.truncate = originalLength - output.length - (last ? 0 : separator.length);
11275 var string = peek || inspectItem(value, options) + (last ? '' : separator);
11276 var nextLength = output.length + string.length;
11277 var truncatedLength = nextLength + truncated.length; // If this is the last element, and adding it would
11278 // take us over length, but adding the truncator wouldn't - then break now
11279
11280 if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
11281 break;
11282 } // If this isn't the last or second to last element to scan,
11283 // but the string is already over length then break here
11284
11285
11286 if (!last && !secondToLast && truncatedLength > originalLength) {
11287 break;
11288 } // Peek at the next string to determine if we should
11289 // break early before adding this item to the output
11290
11291
11292 peek = last ? '' : inspectItem(list[i + 1], options) + (secondToLast ? '' : separator); // If we have one element left, but this element and
11293 // the next takes over length, the break early
11294
11295 if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
11296 break;
11297 }
11298
11299 output += string; // If the next element takes us to length -
11300 // but there are more after that, then we should truncate now
11301
11302 if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
11303 truncated = "".concat(truncator, "(").concat(list.length - i - 1, ")");
11304 break;
11305 }
11306
11307 truncated = '';
11308 }
11309
11310 return "".concat(output).concat(truncated);
11311 }
11312
11313 function quoteComplexKey(key) {
11314 if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
11315 return key;
11316 }
11317
11318 return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
11319 }
11320
11321 function inspectProperty(_ref2, options) {
11322 var _ref3 = _slicedToArray(_ref2, 2),
11323 key = _ref3[0],
11324 value = _ref3[1];
11325
11326 options.truncate -= 2;
11327
11328 if (typeof key === 'string') {
11329 key = quoteComplexKey(key);
11330 } else if (typeof key !== 'number') {
11331 key = "[".concat(options.inspect(key, options), "]");
11332 }
11333
11334 options.truncate -= key.length;
11335 value = options.inspect(value, options);
11336 return "".concat(key, ": ").concat(value);
11337 }
11338
11339 function inspectArray(array, options) {
11340 // Object.keys will always output the Array indices first, so we can slice by
11341 // `array.length` to get non-index properties
11342 var nonIndexProperties = Object.keys(array).slice(array.length);
11343 if (!array.length && !nonIndexProperties.length) return '[]';
11344 options.truncate -= 4;
11345 var listContents = inspectList(array, options);
11346 options.truncate -= listContents.length;
11347 var propertyContents = '';
11348
11349 if (nonIndexProperties.length) {
11350 propertyContents = inspectList(nonIndexProperties.map(function (key) {
11351 return [key, array[key]];
11352 }), options, inspectProperty);
11353 }
11354
11355 return "[ ".concat(listContents).concat(propertyContents ? ", ".concat(propertyContents) : '', " ]");
11356 }
11357
11358 /* !
11359 * Chai - getFuncName utility
11360 * Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
11361 * MIT Licensed
11362 */
11363
11364 /**
11365 * ### .getFuncName(constructorFn)
11366 *
11367 * Returns the name of a function.
11368 * When a non-function instance is passed, returns `null`.
11369 * This also includes a polyfill function if `aFunc.name` is not defined.
11370 *
11371 * @name getFuncName
11372 * @param {Function} funct
11373 * @namespace Utils
11374 * @api public
11375 */
11376
11377 var toString = Function.prototype.toString;
11378 var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
11379 function getFuncName(aFunc) {
11380 if (typeof aFunc !== 'function') {
11381 return null;
11382 }
11383
11384 var name = '';
11385 if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') {
11386 // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined
11387 var match = toString.call(aFunc).match(functionNameMatch);
11388 if (match) {
11389 name = match[1];
11390 }
11391 } else {
11392 // If we've got a `name` property we just use it
11393 name = aFunc.name;
11394 }
11395
11396 return name;
11397 }
11398
11399 var getFuncName_1 = getFuncName;
11400
11401 var getArrayName = function getArrayName(array) {
11402 // We need to special case Node.js' Buffers, which report to be Uint8Array
11403 if (typeof Buffer === 'function' && array instanceof Buffer) {
11404 return 'Buffer';
11405 }
11406
11407 if (array[Symbol.toStringTag]) {
11408 return array[Symbol.toStringTag];
11409 }
11410
11411 return getFuncName_1(array.constructor);
11412 };
11413
11414 function inspectTypedArray(array, options) {
11415 var name = getArrayName(array);
11416 options.truncate -= name.length + 4; // Object.keys will always output the Array indices first, so we can slice by
11417 // `array.length` to get non-index properties
11418
11419 var nonIndexProperties = Object.keys(array).slice(array.length);
11420 if (!array.length && !nonIndexProperties.length) return "".concat(name, "[]"); // As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply
11421 // stylise the toString() value of them
11422
11423 var output = '';
11424
11425 for (var i = 0; i < array.length; i++) {
11426 var string = "".concat(options.stylize(truncate(array[i], options.truncate), 'number')).concat(i === array.length - 1 ? '' : ', ');
11427 options.truncate -= string.length;
11428
11429 if (array[i] !== array.length && options.truncate <= 3) {
11430 output += "".concat(truncator, "(").concat(array.length - array[i] + 1, ")");
11431 break;
11432 }
11433
11434 output += string;
11435 }
11436
11437 var propertyContents = '';
11438
11439 if (nonIndexProperties.length) {
11440 propertyContents = inspectList(nonIndexProperties.map(function (key) {
11441 return [key, array[key]];
11442 }), options, inspectProperty);
11443 }
11444
11445 return "".concat(name, "[ ").concat(output).concat(propertyContents ? ", ".concat(propertyContents) : '', " ]");
11446 }
11447
11448 function inspectDate(dateObject, options) {
11449 // If we need to - truncate the time portion, but never the date
11450 var split = dateObject.toJSON().split('T');
11451 var date = split[0];
11452 return options.stylize("".concat(date, "T").concat(truncate(split[1], options.truncate - date.length - 1)), 'date');
11453 }
11454
11455 function inspectFunction(func, options) {
11456 var name = getFuncName_1(func);
11457
11458 if (!name) {
11459 return options.stylize('[Function]', 'special');
11460 }
11461
11462 return options.stylize("[Function ".concat(truncate(name, options.truncate - 11), "]"), 'special');
11463 }
11464
11465 function inspectMapEntry(_ref, options) {
11466 var _ref2 = _slicedToArray(_ref, 2),
11467 key = _ref2[0],
11468 value = _ref2[1];
11469
11470 options.truncate -= 4;
11471 key = options.inspect(key, options);
11472 options.truncate -= key.length;
11473 value = options.inspect(value, options);
11474 return "".concat(key, " => ").concat(value);
11475 } // IE11 doesn't support `map.entries()`
11476
11477
11478 function mapToEntries(map) {
11479 var entries = [];
11480 map.forEach(function (value, key) {
11481 entries.push([key, value]);
11482 });
11483 return entries;
11484 }
11485
11486 function inspectMap(map, options) {
11487 var size = map.size - 1;
11488
11489 if (size <= 0) {
11490 return 'Map{}';
11491 }
11492
11493 options.truncate -= 7;
11494 return "Map{ ".concat(inspectList(mapToEntries(map), options, inspectMapEntry), " }");
11495 }
11496
11497 var isNaN = Number.isNaN || function (i) {
11498 return i !== i;
11499 }; // eslint-disable-line no-self-compare
11500
11501
11502 function inspectNumber(number, options) {
11503 if (isNaN(number)) {
11504 return options.stylize('NaN', 'number');
11505 }
11506
11507 if (number === Infinity) {
11508 return options.stylize('Infinity', 'number');
11509 }
11510
11511 if (number === -Infinity) {
11512 return options.stylize('-Infinity', 'number');
11513 }
11514
11515 if (number === 0) {
11516 return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number');
11517 }
11518
11519 return options.stylize(truncate(number, options.truncate), 'number');
11520 }
11521
11522 function inspectBigInt(number, options) {
11523 var nums = truncate(number.toString(), options.truncate - 1);
11524 if (nums !== truncator) nums += 'n';
11525 return options.stylize(nums, 'bigint');
11526 }
11527
11528 function inspectRegExp(value, options) {
11529 var flags = value.toString().split('/')[2];
11530 var sourceLength = options.truncate - (2 + flags.length);
11531 var source = value.source;
11532 return options.stylize("/".concat(truncate(source, sourceLength), "/").concat(flags), 'regexp');
11533 }
11534
11535 function arrayFromSet(set) {
11536 var values = [];
11537 set.forEach(function (value) {
11538 values.push(value);
11539 });
11540 return values;
11541 }
11542
11543 function inspectSet(set, options) {
11544 if (set.size === 0) return 'Set{}';
11545 options.truncate -= 7;
11546 return "Set{ ".concat(inspectList(arrayFromSet(set), options), " }");
11547 }
11548
11549 var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5" + "\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", 'g');
11550 var escapeCharacters = {
11551 '\b': '\\b',
11552 '\t': '\\t',
11553 '\n': '\\n',
11554 '\f': '\\f',
11555 '\r': '\\r',
11556 "'": "\\'",
11557 '\\': '\\\\'
11558 };
11559 var hex = 16;
11560 var unicodeLength = 4;
11561
11562 function escape(char) {
11563 return escapeCharacters[char] || "\\u".concat("0000".concat(char.charCodeAt(0).toString(hex)).slice(-unicodeLength));
11564 }
11565
11566 function inspectString(string, options) {
11567 if (stringEscapeChars.test(string)) {
11568 string = string.replace(stringEscapeChars, escape);
11569 }
11570
11571 return options.stylize("'".concat(truncate(string, options.truncate - 2), "'"), 'string');
11572 }
11573
11574 function inspectSymbol(value) {
11575 if ('description' in Symbol.prototype) {
11576 return value.description ? "Symbol(".concat(value.description, ")") : 'Symbol()';
11577 }
11578
11579 return value.toString();
11580 }
11581
11582 var getPromiseValue = function getPromiseValue() {
11583 return 'Promise{…}';
11584 };
11585
11586 try {
11587 var _process$binding = process.binding('util'),
11588 getPromiseDetails = _process$binding.getPromiseDetails,
11589 kPending = _process$binding.kPending,
11590 kRejected = _process$binding.kRejected;
11591
11592 if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
11593 getPromiseValue = function getPromiseValue(value, options) {
11594 var _getPromiseDetails = getPromiseDetails(value),
11595 _getPromiseDetails2 = _slicedToArray(_getPromiseDetails, 2),
11596 state = _getPromiseDetails2[0],
11597 innerValue = _getPromiseDetails2[1];
11598
11599 if (state === kPending) {
11600 return 'Promise{<pending>}';
11601 }
11602
11603 return "Promise".concat(state === kRejected ? '!' : '', "{").concat(options.inspect(innerValue, options), "}");
11604 };
11605 }
11606 } catch (notNode) {
11607 /* ignore */
11608 }
11609
11610 var inspectPromise = getPromiseValue;
11611
11612 function inspectObject(object, options) {
11613 var properties = Object.getOwnPropertyNames(object);
11614 var symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
11615
11616 if (properties.length === 0 && symbols.length === 0) {
11617 return '{}';
11618 }
11619
11620 options.truncate -= 4;
11621 options.seen = options.seen || [];
11622
11623 if (options.seen.indexOf(object) >= 0) {
11624 return '[Circular]';
11625 }
11626
11627 options.seen.push(object);
11628 var propertyContents = inspectList(properties.map(function (key) {
11629 return [key, object[key]];
11630 }), options, inspectProperty);
11631 var symbolContents = inspectList(symbols.map(function (key) {
11632 return [key, object[key]];
11633 }), options, inspectProperty);
11634 options.seen.pop();
11635 var sep = '';
11636
11637 if (propertyContents && symbolContents) {
11638 sep = ', ';
11639 }
11640
11641 return "{ ".concat(propertyContents).concat(sep).concat(symbolContents, " }");
11642 }
11643
11644 var toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false;
11645 function inspectClass(value, options) {
11646 var name = '';
11647
11648 if (toStringTag && toStringTag in value) {
11649 name = value[toStringTag];
11650 }
11651
11652 name = name || getFuncName_1(value.constructor); // Babel transforms anonymous classes to the name `_class`
11653
11654 if (!name || name === '_class') {
11655 name = '<Anonymous Class>';
11656 }
11657
11658 options.truncate -= name.length;
11659 return "".concat(name).concat(inspectObject(value, options));
11660 }
11661
11662 function inspectArguments(args, options) {
11663 if (args.length === 0) return 'Arguments[]';
11664 options.truncate -= 13;
11665 return "Arguments[ ".concat(inspectList(args, options), " ]");
11666 }
11667
11668 var errorKeys = ['stack', 'line', 'column', 'name', 'message', 'fileName', 'lineNumber', 'columnNumber', 'number', 'description'];
11669 function inspectObject$1(error, options) {
11670 var properties = Object.getOwnPropertyNames(error).filter(function (key) {
11671 return errorKeys.indexOf(key) === -1;
11672 });
11673 var name = error.name;
11674 options.truncate -= name.length;
11675 var message = '';
11676
11677 if (typeof error.message === 'string') {
11678 message = truncate(error.message, options.truncate);
11679 } else {
11680 properties.unshift('message');
11681 }
11682
11683 message = message ? ": ".concat(message) : '';
11684 options.truncate -= message.length + 5;
11685 var propertyContents = inspectList(properties.map(function (key) {
11686 return [key, error[key]];
11687 }), options, inspectProperty);
11688 return "".concat(name).concat(message).concat(propertyContents ? " { ".concat(propertyContents, " }") : '');
11689 }
11690
11691 function inspectAttribute(_ref, options) {
11692 var _ref2 = _slicedToArray(_ref, 2),
11693 key = _ref2[0],
11694 value = _ref2[1];
11695
11696 options.truncate -= 3;
11697
11698 if (!value) {
11699 return "".concat(options.stylize(key, 'yellow'));
11700 }
11701
11702 return "".concat(options.stylize(key, 'yellow'), "=").concat(options.stylize("\"".concat(value, "\""), 'string'));
11703 }
11704 function inspectHTMLCollection(collection, options) {
11705 // eslint-disable-next-line no-use-before-define
11706 return inspectList(collection, options, inspectHTML, '\n');
11707 }
11708 function inspectHTML(element, options) {
11709 var properties = element.getAttributeNames();
11710 var name = element.tagName.toLowerCase();
11711 var head = options.stylize("<".concat(name), 'special');
11712 var headClose = options.stylize(">", 'special');
11713 var tail = options.stylize("</".concat(name, ">"), 'special');
11714 options.truncate -= name.length * 2 + 5;
11715 var propertyContents = '';
11716
11717 if (properties.length > 0) {
11718 propertyContents += ' ';
11719 propertyContents += inspectList(properties.map(function (key) {
11720 return [key, element.getAttribute(key)];
11721 }), options, inspectAttribute, ' ');
11722 }
11723
11724 options.truncate -= propertyContents.length;
11725 var truncate = options.truncate;
11726 var children = inspectHTMLCollection(element.children, options);
11727
11728 if (children && children.length > truncate) {
11729 children = "".concat(truncator, "(").concat(element.children.length, ")");
11730 }
11731
11732 return "".concat(head).concat(propertyContents).concat(headClose).concat(children).concat(tail);
11733 }
11734
11735 var symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function';
11736 var chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect';
11737 var nodeInspect = false;
11738
11739 try {
11740 // eslint-disable-next-line global-require
11741 var nodeUtil = __webpack_require__(/*! util */ "./node_modules/util/util.js");
11742
11743 nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
11744 } catch (noNodeInspect) {
11745 nodeInspect = false;
11746 }
11747
11748 var constructorMap = new WeakMap();
11749 var stringTagMap = {};
11750 var baseTypesMap = {
11751 undefined: function undefined$1(value, options) {
11752 return options.stylize('undefined', 'undefined');
11753 },
11754 null: function _null(value, options) {
11755 return options.stylize(null, 'null');
11756 },
11757 boolean: function boolean(value, options) {
11758 return options.stylize(value, 'boolean');
11759 },
11760 Boolean: function Boolean(value, options) {
11761 return options.stylize(value, 'boolean');
11762 },
11763 number: inspectNumber,
11764 Number: inspectNumber,
11765 bigint: inspectBigInt,
11766 BigInt: inspectBigInt,
11767 string: inspectString,
11768 String: inspectString,
11769 function: inspectFunction,
11770 Function: inspectFunction,
11771 symbol: inspectSymbol,
11772 // A Symbol polyfill will return `Symbol` not `symbol` from typedetect
11773 Symbol: inspectSymbol,
11774 Array: inspectArray,
11775 Date: inspectDate,
11776 Map: inspectMap,
11777 Set: inspectSet,
11778 RegExp: inspectRegExp,
11779 Promise: inspectPromise,
11780 // WeakSet, WeakMap are totally opaque to us
11781 WeakSet: function WeakSet(value, options) {
11782 return options.stylize('WeakSet{…}', 'special');
11783 },
11784 WeakMap: function WeakMap(value, options) {
11785 return options.stylize('WeakMap{…}', 'special');
11786 },
11787 Arguments: inspectArguments,
11788 Int8Array: inspectTypedArray,
11789 Uint8Array: inspectTypedArray,
11790 Uint8ClampedArray: inspectTypedArray,
11791 Int16Array: inspectTypedArray,
11792 Uint16Array: inspectTypedArray,
11793 Int32Array: inspectTypedArray,
11794 Uint32Array: inspectTypedArray,
11795 Float32Array: inspectTypedArray,
11796 Float64Array: inspectTypedArray,
11797 Generator: function Generator() {
11798 return '';
11799 },
11800 DataView: function DataView() {
11801 return '';
11802 },
11803 ArrayBuffer: function ArrayBuffer() {
11804 return '';
11805 },
11806 Error: inspectObject$1,
11807 HTMLCollection: inspectHTMLCollection,
11808 NodeList: inspectHTMLCollection
11809 }; // eslint-disable-next-line complexity
11810
11811 var inspectCustom = function inspectCustom(value, options, type) {
11812 if (chaiInspect in value && typeof value[chaiInspect] === 'function') {
11813 return value[chaiInspect](options);
11814 }
11815
11816 if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === 'function') {
11817 return value[nodeInspect](options.depth, options);
11818 }
11819
11820 if ('inspect' in value && typeof value.inspect === 'function') {
11821 return value.inspect(options.depth, options);
11822 }
11823
11824 if ('constructor' in value && constructorMap.has(value.constructor)) {
11825 return constructorMap.get(value.constructor)(value, options);
11826 }
11827
11828 if (stringTagMap[type]) {
11829 return stringTagMap[type](value, options);
11830 }
11831
11832 return '';
11833 };
11834
11835 var toString$1 = Object.prototype.toString; // eslint-disable-next-line complexity
11836
11837 function inspect(value, options) {
11838 options = normaliseOptions(options);
11839 options.inspect = inspect;
11840 var _options = options,
11841 customInspect = _options.customInspect;
11842 var type = value === null ? 'null' : _typeof(value);
11843
11844 if (type === 'object') {
11845 type = toString$1.call(value).slice(8, -1);
11846 } // If it is a base value that we already support, then use Loupe's inspector
11847
11848
11849 if (baseTypesMap[type]) {
11850 return baseTypesMap[type](value, options);
11851 } // If `options.customInspect` is set to true then try to use the custom inspector
11852
11853
11854 if (customInspect && value) {
11855 var output = inspectCustom(value, options, type);
11856
11857 if (output) {
11858 if (typeof output === 'string') return output;
11859 return inspect(output, options);
11860 }
11861 }
11862
11863 var proto = value ? Object.getPrototypeOf(value) : false; // If it's a plain Object then use Loupe's inspector
11864
11865 if (proto === Object.prototype || proto === null) {
11866 return inspectObject(value, options);
11867 } // Specifically account for HTMLElements
11868 // eslint-disable-next-line no-undef
11869
11870
11871 if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) {
11872 return inspectHTML(value, options);
11873 }
11874
11875 if ('constructor' in value) {
11876 // If it is a class, inspect it like an object but add the constructor name
11877 if (value.constructor !== Object) {
11878 return inspectClass(value, options);
11879 } // If it is an object with an anonymous prototype, display it as an object.
11880
11881
11882 return inspectObject(value, options);
11883 } // We have run out of options! Just stringify the value
11884
11885
11886 return options.stylize(String(value), type);
11887 }
11888 function registerConstructor(constructor, inspector) {
11889 if (constructorMap.has(constructor)) {
11890 return false;
11891 }
11892
11893 constructorMap.add(constructor, inspector);
11894 return true;
11895 }
11896 function registerStringTag(stringTag, inspector) {
11897 if (stringTag in stringTagMap) {
11898 return false;
11899 }
11900
11901 stringTagMap[stringTag] = inspector;
11902 return true;
11903 }
11904 var custom = chaiInspect;
11905
11906 exports.custom = custom;
11907 exports.default = inspect;
11908 exports.inspect = inspect;
11909 exports.registerConstructor = registerConstructor;
11910 exports.registerStringTag = registerStringTag;
11911
11912 Object.defineProperty(exports, '__esModule', { value: true });
11913
11914})));
11915
11916
11917/***/ }),
11918
11919/***/ "./node_modules/pathval/index.js":
11920/*!***************************************!*\
11921 !*** ./node_modules/pathval/index.js ***!
11922 \***************************************/
11923/***/ ((module) => {
11924
11925"use strict";
11926
11927
11928/* !
11929 * Chai - pathval utility
11930 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
11931 * @see https://github.com/logicalparadox/filtr
11932 * MIT Licensed
11933 */
11934
11935/**
11936 * ### .hasProperty(object, name)
11937 *
11938 * This allows checking whether an object has own
11939 * or inherited from prototype chain named property.
11940 *
11941 * Basically does the same thing as the `in`
11942 * operator but works properly with null/undefined values
11943 * and other primitives.
11944 *
11945 * var obj = {
11946 * arr: ['a', 'b', 'c']
11947 * , str: 'Hello'
11948 * }
11949 *
11950 * The following would be the results.
11951 *
11952 * hasProperty(obj, 'str'); // true
11953 * hasProperty(obj, 'constructor'); // true
11954 * hasProperty(obj, 'bar'); // false
11955 *
11956 * hasProperty(obj.str, 'length'); // true
11957 * hasProperty(obj.str, 1); // true
11958 * hasProperty(obj.str, 5); // false
11959 *
11960 * hasProperty(obj.arr, 'length'); // true
11961 * hasProperty(obj.arr, 2); // true
11962 * hasProperty(obj.arr, 3); // false
11963 *
11964 * @param {Object} object
11965 * @param {String|Symbol} name
11966 * @returns {Boolean} whether it exists
11967 * @namespace Utils
11968 * @name hasProperty
11969 * @api public
11970 */
11971
11972function hasProperty(obj, name) {
11973 if (typeof obj === 'undefined' || obj === null) {
11974 return false;
11975 }
11976
11977 // The `in` operator does not work with primitives.
11978 return name in Object(obj);
11979}
11980
11981/* !
11982 * ## parsePath(path)
11983 *
11984 * Helper function used to parse string object
11985 * paths. Use in conjunction with `internalGetPathValue`.
11986 *
11987 * var parsed = parsePath('myobject.property.subprop');
11988 *
11989 * ### Paths:
11990 *
11991 * * Can be infinitely deep and nested.
11992 * * Arrays are also valid using the formal `myobject.document[3].property`.
11993 * * Literal dots and brackets (not delimiter) must be backslash-escaped.
11994 *
11995 * @param {String} path
11996 * @returns {Object} parsed
11997 * @api private
11998 */
11999
12000function parsePath(path) {
12001 var str = path.replace(/([^\\])\[/g, '$1.[');
12002 var parts = str.match(/(\\\.|[^.]+?)+/g);
12003 return parts.map(function mapMatches(value) {
12004 if (
12005 value === 'constructor' ||
12006 value === '__proto__' ||
12007 value === 'prototype'
12008 ) {
12009 return {};
12010 }
12011 var regexp = /^\[(\d+)\]$/;
12012 var mArr = regexp.exec(value);
12013 var parsed = null;
12014 if (mArr) {
12015 parsed = { i: parseFloat(mArr[1]) };
12016 } else {
12017 parsed = { p: value.replace(/\\([.[\]])/g, '$1') };
12018 }
12019
12020 return parsed;
12021 });
12022}
12023
12024/* !
12025 * ## internalGetPathValue(obj, parsed[, pathDepth])
12026 *
12027 * Helper companion function for `.parsePath` that returns
12028 * the value located at the parsed address.
12029 *
12030 * var value = getPathValue(obj, parsed);
12031 *
12032 * @param {Object} object to search against
12033 * @param {Object} parsed definition from `parsePath`.
12034 * @param {Number} depth (nesting level) of the property we want to retrieve
12035 * @returns {Object|Undefined} value
12036 * @api private
12037 */
12038
12039function internalGetPathValue(obj, parsed, pathDepth) {
12040 var temporaryValue = obj;
12041 var res = null;
12042 pathDepth = typeof pathDepth === 'undefined' ? parsed.length : pathDepth;
12043
12044 for (var i = 0; i < pathDepth; i++) {
12045 var part = parsed[i];
12046 if (temporaryValue) {
12047 if (typeof part.p === 'undefined') {
12048 temporaryValue = temporaryValue[part.i];
12049 } else {
12050 temporaryValue = temporaryValue[part.p];
12051 }
12052
12053 if (i === pathDepth - 1) {
12054 res = temporaryValue;
12055 }
12056 }
12057 }
12058
12059 return res;
12060}
12061
12062/* !
12063 * ## internalSetPathValue(obj, value, parsed)
12064 *
12065 * Companion function for `parsePath` that sets
12066 * the value located at a parsed address.
12067 *
12068 * internalSetPathValue(obj, 'value', parsed);
12069 *
12070 * @param {Object} object to search and define on
12071 * @param {*} value to use upon set
12072 * @param {Object} parsed definition from `parsePath`
12073 * @api private
12074 */
12075
12076function internalSetPathValue(obj, val, parsed) {
12077 var tempObj = obj;
12078 var pathDepth = parsed.length;
12079 var part = null;
12080 // Here we iterate through every part of the path
12081 for (var i = 0; i < pathDepth; i++) {
12082 var propName = null;
12083 var propVal = null;
12084 part = parsed[i];
12085
12086 // If it's the last part of the path, we set the 'propName' value with the property name
12087 if (i === pathDepth - 1) {
12088 propName = typeof part.p === 'undefined' ? part.i : part.p;
12089 // Now we set the property with the name held by 'propName' on object with the desired val
12090 tempObj[propName] = val;
12091 } else if (typeof part.p !== 'undefined' && tempObj[part.p]) {
12092 tempObj = tempObj[part.p];
12093 } else if (typeof part.i !== 'undefined' && tempObj[part.i]) {
12094 tempObj = tempObj[part.i];
12095 } else {
12096 // If the obj doesn't have the property we create one with that name to define it
12097 var next = parsed[i + 1];
12098 // Here we set the name of the property which will be defined
12099 propName = typeof part.p === 'undefined' ? part.i : part.p;
12100 // Here we decide if this property will be an array or a new object
12101 propVal = typeof next.p === 'undefined' ? [] : {};
12102 tempObj[propName] = propVal;
12103 tempObj = tempObj[propName];
12104 }
12105 }
12106}
12107
12108/**
12109 * ### .getPathInfo(object, path)
12110 *
12111 * This allows the retrieval of property info in an
12112 * object given a string path.
12113 *
12114 * The path info consists of an object with the
12115 * following properties:
12116 *
12117 * * parent - The parent object of the property referenced by `path`
12118 * * name - The name of the final property, a number if it was an array indexer
12119 * * value - The value of the property, if it exists, otherwise `undefined`
12120 * * exists - Whether the property exists or not
12121 *
12122 * @param {Object} object
12123 * @param {String} path
12124 * @returns {Object} info
12125 * @namespace Utils
12126 * @name getPathInfo
12127 * @api public
12128 */
12129
12130function getPathInfo(obj, path) {
12131 var parsed = parsePath(path);
12132 var last = parsed[parsed.length - 1];
12133 var info = {
12134 parent:
12135 parsed.length > 1 ?
12136 internalGetPathValue(obj, parsed, parsed.length - 1) :
12137 obj,
12138 name: last.p || last.i,
12139 value: internalGetPathValue(obj, parsed),
12140 };
12141 info.exists = hasProperty(info.parent, info.name);
12142
12143 return info;
12144}
12145
12146/**
12147 * ### .getPathValue(object, path)
12148 *
12149 * This allows the retrieval of values in an
12150 * object given a string path.
12151 *
12152 * var obj = {
12153 * prop1: {
12154 * arr: ['a', 'b', 'c']
12155 * , str: 'Hello'
12156 * }
12157 * , prop2: {
12158 * arr: [ { nested: 'Universe' } ]
12159 * , str: 'Hello again!'
12160 * }
12161 * }
12162 *
12163 * The following would be the results.
12164 *
12165 * getPathValue(obj, 'prop1.str'); // Hello
12166 * getPathValue(obj, 'prop1.att[2]'); // b
12167 * getPathValue(obj, 'prop2.arr[0].nested'); // Universe
12168 *
12169 * @param {Object} object
12170 * @param {String} path
12171 * @returns {Object} value or `undefined`
12172 * @namespace Utils
12173 * @name getPathValue
12174 * @api public
12175 */
12176
12177function getPathValue(obj, path) {
12178 var info = getPathInfo(obj, path);
12179 return info.value;
12180}
12181
12182/**
12183 * ### .setPathValue(object, path, value)
12184 *
12185 * Define the value in an object at a given string path.
12186 *
12187 * ```js
12188 * var obj = {
12189 * prop1: {
12190 * arr: ['a', 'b', 'c']
12191 * , str: 'Hello'
12192 * }
12193 * , prop2: {
12194 * arr: [ { nested: 'Universe' } ]
12195 * , str: 'Hello again!'
12196 * }
12197 * };
12198 * ```
12199 *
12200 * The following would be acceptable.
12201 *
12202 * ```js
12203 * var properties = require('tea-properties');
12204 * properties.set(obj, 'prop1.str', 'Hello Universe!');
12205 * properties.set(obj, 'prop1.arr[2]', 'B');
12206 * properties.set(obj, 'prop2.arr[0].nested.value', { hello: 'universe' });
12207 * ```
12208 *
12209 * @param {Object} object
12210 * @param {String} path
12211 * @param {Mixed} value
12212 * @api private
12213 */
12214
12215function setPathValue(obj, path, val) {
12216 var parsed = parsePath(path);
12217 internalSetPathValue(obj, val, parsed);
12218 return obj;
12219}
12220
12221module.exports = {
12222 hasProperty: hasProperty,
12223 getPathInfo: getPathInfo,
12224 getPathValue: getPathValue,
12225 setPathValue: setPathValue,
12226};
12227
12228
12229/***/ }),
12230
12231/***/ "./src/__tests__/pointer.spec.ts":
12232/*!***************************************!*\
12233 !*** ./src/__tests__/pointer.spec.ts ***!
12234 \***************************************/
12235/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12236
12237"use strict";
12238__webpack_require__.r(__webpack_exports__);
12239/* harmony import */ var chai__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! chai */ "./node_modules/chai/index.mjs");
12240/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! util */ "./node_modules/util/util.js");
12241/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_1__);
12242/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! .. */ "./src/index.ts");
12243/**
12244 * @hidden
12245 * @packageDocumentation
12246 */
12247
12248
12249
12250var rand = function (min, max) {
12251 return Math.random() * (max - min) + min;
12252};
12253describe('JsonPointer', function () {
12254 var data0 = {
12255 has: 'data',
12256 arr: ['data', { nested: 'object with data' }, null],
12257 nested: { even: { further: 'hello' } },
12258 };
12259 // list paths in order so the .set method can work in reverse order
12260 var tests0 = [
12261 ['', data0],
12262 ['/has', data0.has],
12263 ['/arr', data0.arr],
12264 ['/arr/0', data0.arr[0]],
12265 ['/arr/1', data0.arr[1]],
12266 ['/arr/1/nested', data0.arr[1].nested],
12267 ['/arr/2', data0.arr[2]],
12268 ['/nested', data0.nested],
12269 ['/nested/even', data0.nested.even],
12270 ['/nested/even/further', data0.nested.even.further],
12271 ['/hasnot', undefined],
12272 ];
12273 var data1 = {
12274 foo: 'bar',
12275 baz: [
12276 'qux',
12277 'quux',
12278 {
12279 garply: { waldo: ['fred', 'plugh'] },
12280 },
12281 ],
12282 };
12283 var tests1 = [
12284 ['', data1],
12285 ['/foo', data1.foo],
12286 ['/baz', data1.baz],
12287 ['/baz/0', data1.baz[0]],
12288 ['/baz/1', data1.baz[1]],
12289 ['/baz/2', data1.baz[2]],
12290 ['/baz/2/garply', data1.baz[2].garply],
12291 [
12292 '/baz/2/garply/waldo',
12293 data1.baz[2].garply
12294 .waldo,
12295 ],
12296 [
12297 '/baz/2/garply/waldo/0',
12298 data1.baz[2].garply
12299 .waldo[0],
12300 ],
12301 [
12302 '/baz/2/garply/waldo/1',
12303 data1.baz[2].garply
12304 .waldo[1],
12305 ],
12306 ];
12307 var tests1f = [
12308 ['#', data1],
12309 ['#/foo', data1.foo],
12310 ['#/baz', data1.baz],
12311 ['#/baz/0', data1.baz[0]],
12312 ['#/baz/1', data1.baz[1]],
12313 ['#/baz/2', data1.baz[2]],
12314 ['#/baz/2/garply', data1.baz[2].garply],
12315 [
12316 '#/baz/2/garply/waldo',
12317 data1.baz[2].garply
12318 .waldo,
12319 ],
12320 [
12321 '#/baz/2/garply/waldo/0',
12322 data1.baz[2].garply
12323 .waldo[0],
12324 ],
12325 [
12326 '#/baz/2/garply/waldo/1',
12327 data1.baz[2].garply
12328 .waldo[1],
12329 ],
12330 ];
12331 describe('static .create()', function () {
12332 it('throws on undefined', function () {
12333 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.create(undefined); }).to.throw('Invalid type: JSON Pointers are represented as strings.');
12334 });
12335 it('succeeds when pointer is string', function () {
12336 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.create('')).to.be.a('object');
12337 });
12338 it('succeeds when pointer is PathSegment', function () {
12339 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.create([])).to.be.a('object');
12340 });
12341 });
12342 describe('.ctor()', function () {
12343 it('throws on undefined', function () {
12344 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(undefined); }).to.throw('Invalid type: JSON Pointers are represented as strings.');
12345 });
12346 it('succeeds when pointer is string', function () {
12347 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('')).to.be.a('object');
12348 });
12349 it('succeeds when pointer is PathSegment', function () {
12350 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer([])).to.be.a('object');
12351 });
12352 });
12353 describe('static .has()', function () {
12354 var _loop_1 = function (p, expected) {
12355 it("static .has(data, '".concat(p, "') = ").concat(expected !== undefined), function () {
12356 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.has(data0, p)).to.be.eql(expected !== undefined);
12357 });
12358 it("static .has(data, '".concat(JSON.stringify(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p)), "') = ").concat(expected !== undefined), function () {
12359 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.has(data0, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p))).to.be.eql(expected !== undefined);
12360 });
12361 it("static .has(data, p'".concat(p, "') = ").concat(expected !== undefined), function () {
12362 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.has(data0, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p))).to.be.eql(expected !== undefined);
12363 });
12364 };
12365 for (var _i = 0, tests0_1 = tests0; _i < tests0_1.length; _i++) {
12366 var _a = tests0_1[_i], p = _a[0], expected = _a[1];
12367 _loop_1(p, expected);
12368 }
12369 });
12370 describe('.has()', function () {
12371 var _loop_2 = function (p, expected) {
12372 it(".has('".concat(p, "') = ").concat(expected !== undefined), function () {
12373 var ptr = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p);
12374 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(ptr.has(data0)).to.be.eql(expected !== undefined);
12375 });
12376 };
12377 for (var _i = 0, tests0_2 = tests0; _i < tests0_2.length; _i++) {
12378 var _a = tests0_2[_i], p = _a[0], expected = _a[1];
12379 _loop_2(p, expected);
12380 }
12381 });
12382 describe('static .get()', function () {
12383 var _loop_3 = function (p, expected) {
12384 it("static .get(data, '".concat(p, "') = ").concat(JSON.stringify(expected)), function () {
12385 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(data0, p)).to.be.eql(expected);
12386 });
12387 it("static .get(data, '".concat(JSON.stringify(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p)), "') = ").concat(JSON.stringify(expected)), function () {
12388 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(data0, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p))).to.be.eql(expected);
12389 });
12390 it("static .get(data, p'".concat(p, "') = ").concat(JSON.stringify(expected)), function () {
12391 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(data0, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p))).to.be.eql(expected);
12392 });
12393 };
12394 for (var _i = 0, tests0_3 = tests0; _i < tests0_3.length; _i++) {
12395 var _a = tests0_3[_i], p = _a[0], expected = _a[1];
12396 _loop_3(p, expected);
12397 }
12398 });
12399 describe('static .set() unforced', function () {
12400 var dataCopy0 = JSON.parse(JSON.stringify(data0));
12401 var dataCopy1 = JSON.parse(JSON.stringify(data0));
12402 var dataCopy2 = JSON.parse(JSON.stringify(data0));
12403 var _loop_4 = function (p, expected) {
12404 var r = rand(1, 99999);
12405 it("static .set(data, '".concat(p, "', ").concat(r, ")"), function () {
12406 if (p === '') {
12407 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(dataCopy0, p, r); }).to.throw('Cannot set the root object; assign it directly.');
12408 return;
12409 }
12410 ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(dataCopy0, p, r);
12411 if (expected === undefined) {
12412 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy0, p)).to.be.eql(expected);
12413 }
12414 else {
12415 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy0, p)).to.be.eql(r);
12416 }
12417 });
12418 it("static .set(data, ".concat(JSON.stringify(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p)), ", ").concat(r, ")"), function () {
12419 if (p.length === 0) {
12420 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
12421 return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p), r);
12422 }).to.throw('Cannot set the root object; assign it directly.');
12423 return;
12424 }
12425 ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p), r);
12426 if (expected === undefined) {
12427 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p))).to.be.eql(expected);
12428 }
12429 else {
12430 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p))).to.be.eql(r);
12431 }
12432 });
12433 it("static .set(data, p'".concat(p, "', ").concat(r, ")"), function () {
12434 if (p === '') {
12435 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
12436 return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(dataCopy2, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p), r);
12437 }).to.throw('Cannot set the root object; assign it directly.');
12438 return;
12439 }
12440 ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(dataCopy2, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p), r);
12441 if (expected === undefined) {
12442 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy2, p)).to.be.eql(expected);
12443 }
12444 else {
12445 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy2, p)).to.be.eql(r);
12446 }
12447 });
12448 };
12449 for (var _i = 0, _a = tests0.reverse(); _i < _a.length; _i++) {
12450 var _b = _a[_i], p = _b[0], expected = _b[1];
12451 _loop_4(p, expected);
12452 }
12453 it('throws on attempted prototype pollution', function () {
12454 var subject = { my: 'subject' };
12455 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
12456 return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.set(subject, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/__proto__/polluted'), "Yes! It's polluted");
12457 }).to.throw('Attempted prototype pollution disallowed.');
12458 });
12459 });
12460 describe('static .unset()', function () {
12461 var dataCopy0 = JSON.parse(JSON.stringify(data0));
12462 var dataCopy1 = JSON.parse(JSON.stringify(data0));
12463 var dataCopy2 = JSON.parse(JSON.stringify(data0));
12464 var _loop_5 = function (p) {
12465 it("static .unset(data, '".concat(p, "')"), function () {
12466 if (p === '') {
12467 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.unset(dataCopy0, p); }).to.throw('Cannot unset the root object; assign it directly.');
12468 return;
12469 }
12470 // values are changing! get it so we know what to expect
12471 var updatedExpected = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy0, p);
12472 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.unset(dataCopy0, p)).to.be.eql(updatedExpected);
12473 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy0, p)).to.be.undefined;
12474 });
12475 it("static .unset(data, ".concat(JSON.stringify(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p)), ")"), function () {
12476 if (p.length === 0) {
12477 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
12478 return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.unset(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p));
12479 }).to.throw('Cannot unset the root object; assign it directly.');
12480 return;
12481 }
12482 // values are changing! get it so we know what to expect
12483 var updatedExpected = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy1, p);
12484 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.unset(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p))).to.be.eql(updatedExpected);
12485 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy1, ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p))).to.be
12486 .undefined;
12487 });
12488 it("static .unset(data, p'".concat(p, "')"), function () {
12489 if (p === '') {
12490 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
12491 return ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.unset(dataCopy2, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p));
12492 }).to.throw('Cannot unset the root object; assign it directly.');
12493 return;
12494 }
12495 // values are changing! get it so we know what to expect
12496 var updatedExpected = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy2, p);
12497 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.unset(dataCopy2, new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer(p))).to.be.eql(updatedExpected);
12498 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.get(dataCopy2, p)).to.be.undefined;
12499 });
12500 };
12501 for (var _i = 0, _a = tests0.reverse(); _i < _a.length; _i++) {
12502 var p = _a[_i][0];
12503 _loop_5(p);
12504 }
12505 });
12506 describe('static .visit()', function () {
12507 it("static .visit(data)", function () {
12508 var sequence = [];
12509 ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.visit(data1, function (p, v) {
12510 var path = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p);
12511 if (path.length) {
12512 sequence.push(path[path.length - 1]);
12513 if (typeof v === 'string') {
12514 sequence.push(v);
12515 }
12516 }
12517 });
12518 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(sequence).to.eql([
12519 'foo',
12520 'bar',
12521 'baz',
12522 '0',
12523 'qux',
12524 '1',
12525 'quux',
12526 '2',
12527 'garply',
12528 'waldo',
12529 '0',
12530 'fred',
12531 '1',
12532 'plugh',
12533 ]);
12534 });
12535 it("static .visit(data) fragments", function () {
12536 var sequence = [];
12537 ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.visit(data1, function (p, v) {
12538 var path = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p);
12539 if (path.length) {
12540 sequence.push(path[path.length - 1]);
12541 if (typeof v === 'string') {
12542 sequence.push(v);
12543 }
12544 }
12545 }, true);
12546 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(sequence).to.eql([
12547 'foo',
12548 'bar',
12549 'baz',
12550 '0',
12551 'qux',
12552 '1',
12553 'quux',
12554 '2',
12555 'garply',
12556 'waldo',
12557 '0',
12558 'fred',
12559 '1',
12560 'plugh',
12561 ]);
12562 });
12563 var obj = { my: { obj: 'with nested data' } };
12564 var objWithReferences = {
12565 your: { obj: { refers_to: obj } },
12566 my: obj,
12567 };
12568 objWithReferences.self = {
12569 nested: [objWithReferences, obj],
12570 };
12571 it('handles references', function () {
12572 var pointers = {};
12573 ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.visit(objWithReferences, function (p, v) {
12574 pointers[p] = v;
12575 });
12576 console.log((0,util__WEBPACK_IMPORTED_MODULE_1__.inspect)(pointers, false, 9));
12577 });
12578 });
12579 describe('static .flatten()', function () {
12580 var data = {
12581 foo: 'bar',
12582 baz: [
12583 'qux',
12584 'quux',
12585 {
12586 garply: { waldo: ['fred', 'plugh'] },
12587 },
12588 ],
12589 };
12590 var obj = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.flatten(data);
12591 var objf = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.flatten(data, true);
12592 it('obj to # of items', function () {
12593 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(Object.keys(obj).length).to.eql(tests1.length);
12594 });
12595 var _loop_6 = function (p, expected) {
12596 it("obj['".concat(p, "'] === ").concat(JSON.stringify(expected)), function () {
12597 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(obj[p]).to.eql(expected);
12598 });
12599 };
12600 for (var _i = 0, tests1_1 = tests1; _i < tests1_1.length; _i++) {
12601 var _a = tests1_1[_i], p = _a[0], expected = _a[1];
12602 _loop_6(p, expected);
12603 }
12604 var _loop_7 = function (p, expected) {
12605 it("obj['".concat(p, "'] === ").concat(JSON.stringify(expected)), function () {
12606 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(objf[p]).to.eql(expected);
12607 });
12608 };
12609 for (var _b = 0, tests1f_1 = tests1f; _b < tests1f_1.length; _b++) {
12610 var _c = tests1f_1[_b], p = _c[0], expected = _c[1];
12611 _loop_7(p, expected);
12612 }
12613 });
12614 describe('static .map()', function () {
12615 var data = {
12616 foo: 'bar',
12617 baz: [
12618 'qux',
12619 'quux',
12620 {
12621 garply: { waldo: ['fred', 'plugh'] },
12622 },
12623 ],
12624 };
12625 var map = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.map(data);
12626 var mapf = ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.map(data, true);
12627 it('map to # of items', function () {
12628 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(Array.from(map.keys()).length).to.eql(tests1.length);
12629 });
12630 var _loop_8 = function (p, expected) {
12631 it("map.get('".concat(p, "') === ").concat(JSON.stringify(expected)), function () {
12632 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(map.get(p)).to.eql(expected);
12633 });
12634 };
12635 for (var _i = 0, tests1_2 = tests1; _i < tests1_2.length; _i++) {
12636 var _a = tests1_2[_i], p = _a[0], expected = _a[1];
12637 _loop_8(p, expected);
12638 }
12639 var _loop_9 = function (p, expected) {
12640 it("map.get('".concat(p, "') === ").concat(JSON.stringify(expected)), function () {
12641 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(mapf.get(p)).to.eql(expected);
12642 });
12643 };
12644 for (var _b = 0, tests1f_2 = tests1f; _b < tests1f_2.length; _b++) {
12645 var _c = tests1f_2[_b], p = _c[0], expected = _c[1];
12646 _loop_9(p, expected);
12647 }
12648 });
12649 describe('static .decode()', function () {
12650 var tests = [
12651 ['', []],
12652 ['/foo', ['foo']],
12653 ['/foo/0', ['foo', '0']],
12654 ['/', ['']],
12655 ['/a~1b', ['a/b']],
12656 ['/c%d', ['c%d']],
12657 ['/e^f', ['e^f']],
12658 ['/g|h', ['g|h']],
12659 ['/i\\j', ['i\\j']],
12660 ['/k"l', ['k"l']],
12661 ['/ ', [' ']],
12662 ['/m~0n', ['m~n']],
12663 ['/foo/bar/baz', ['foo', 'bar', 'baz']],
12664 ['#/foo/bar/baz', ['foo', 'bar', 'baz']],
12665 ];
12666 var _loop_10 = function (p, expected) {
12667 it(".decode('".concat(p, "') = ").concat(JSON.stringify(expected)), function () {
12668 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_2__.JsonPointer.decode(p)).to.be.eql(expected);
12669 });
12670 };
12671 for (var _i = 0, tests_1 = tests; _i < tests_1.length; _i++) {
12672 var _a = tests_1[_i], p = _a[0], expected = _a[1];
12673 _loop_10(p, expected);
12674 }
12675 });
12676 describe('.pointer property', function () {
12677 it('encodes pointer', function () {
12678 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/foo');
12679 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.pointer).to.eql('/foo');
12680 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.pointer).to.eql(p.pointer);
12681 });
12682 it('encodes fragment', function () {
12683 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('#/foo');
12684 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.pointer).to.eql('/foo');
12685 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.pointer).to.eql(p.pointer);
12686 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.uriFragmentIdentifier).to.eql('#/foo');
12687 });
12688 });
12689 describe('.relative method', function () {
12690 var doc = {
12691 foo: ['bar', 'baz'],
12692 highly: {
12693 nested: {
12694 objects: true,
12695 },
12696 },
12697 };
12698 it('throws when relative pointer unspecified', function () {
12699 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12700 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.rel(doc, undefined); }).to.throw('Invalid type: Relative JSON Pointers are represented as strings.');
12701 });
12702 it('throws when relative pointer empty', function () {
12703 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12704 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.rel(doc, ''); }).to.throw('Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.');
12705 });
12706 it('throws when relative pointer invalid [0](NaN)', function () {
12707 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12708 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.rel(doc, 'b/z'); }).to.throw('Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.');
12709 });
12710 it('throws when relative pointer invalid 1#/z', function () {
12711 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12712 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.rel(doc, '1#/z'); }).to.throw('Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.');
12713 });
12714 it('Spec examples 1', function () {
12715 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/foo/1');
12716 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '0')).to.eql('baz');
12717 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '1/0')).to.eql('bar');
12718 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '2/highly/nested/objects')).to.eql(true);
12719 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '0#')).to.eql(1);
12720 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '1#')).to.eql('foo');
12721 });
12722 it('Spec examples 2', function () {
12723 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested');
12724 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '0/objects')).to.eql(true);
12725 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '1/nested/objects')).to.eql(true);
12726 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '2/foo/0')).to.eql('bar');
12727 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '0#')).to.eql('nested');
12728 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '1#')).to.eql('highly');
12729 });
12730 it('returns undefined when relative location cannot exist', function () {
12731 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12732 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(p.rel(doc, '5/not-here')).to.be.undefined;
12733 });
12734 });
12735 describe('.rel method', function () {
12736 var doc = {
12737 foo: ['bar', 'baz'],
12738 highly: {
12739 nested: {
12740 objects: true,
12741 },
12742 },
12743 };
12744 it('throws when relative pointer unspecified', function () {
12745 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12746 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.relative(undefined); }).to.throw('Invalid type: Relative JSON Pointers are represented as strings.');
12747 });
12748 it('throws when relative pointer empty', function () {
12749 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12750 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.relative(''); }).to.throw('Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.');
12751 });
12752 it('throws when relative pointer invalid [0](NaN)', function () {
12753 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12754 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.relative('b/z'); }).to.throw('Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.');
12755 });
12756 it('throws when relative pointer invalid 1#/z', function () {
12757 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12758 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.relative('1#/z'); }).to.throw('Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.');
12759 });
12760 it('throws when relative pointer to name (#)', function () {
12761 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12762 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.relative('1#'); }).to.throw("We won't compile a pointer that will always return 'nested'. Use JsonPointer.rel(target, ptr) instead.");
12763 });
12764 it('throws when relative location cannot exist', function () {
12765 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested/objects');
12766 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return p.relative('5/not-here'); }).to.throw('Relative location does not exist.');
12767 });
12768 it('Spec example from 1', function () {
12769 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/foo/1');
12770 var q = p.relative('2/highly/nested/objects');
12771 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(q.get(doc)).to.eql(true);
12772 });
12773 it('Spec example from 2', function () {
12774 var p = new ___WEBPACK_IMPORTED_MODULE_2__.JsonPointer('/highly/nested');
12775 var q = p.relative('2/foo/0');
12776 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(q.get(doc)).to.eql('bar');
12777 });
12778 });
12779});
12780
12781
12782/***/ }),
12783
12784/***/ "./src/__tests__/ptr.spec.ts":
12785/*!***********************************!*\
12786 !*** ./src/__tests__/ptr.spec.ts ***!
12787 \***********************************/
12788/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12789
12790"use strict";
12791__webpack_require__.r(__webpack_exports__);
12792/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! .. */ "./src/index.ts");
12793/* harmony import */ var chai__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! chai */ "./node_modules/chai/index.mjs");
12794/**
12795 * @hidden
12796 * @packageDocumentation
12797 */
12798
12799
12800var create = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.create;
12801describe('JsonPointer', function () {
12802 describe('when working with the example data from the rfc', function () {
12803 var data = {
12804 foo: ['bar', 'baz'],
12805 '': 0,
12806 'a/b': 1,
12807 'c%d': 2,
12808 'e^f': 3,
12809 'g|h': 4,
12810 'i\\j': 5,
12811 'k"l': 6,
12812 ' ': 7,
12813 'm~n': 8,
12814 };
12815 describe('with a JSON pointer to the root ``', function () {
12816 var p = create('');
12817 it('#get should resolve to the object itself', function () {
12818 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data);
12819 });
12820 it('#set should throw', function () {
12821 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(function () {
12822 p.set(data, {
12823 this: 'should cause an exception',
12824 });
12825 }).to.throw();
12826 });
12827 it('#unset should throw', function () {
12828 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(function () {
12829 p.unset(data);
12830 }).to.throw('Cannot unset the root object; assign it directly.');
12831 });
12832 it('should have an empty path', function () {
12833 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.have.length(0);
12834 });
12835 it('should have a pointer that is empty', function () {
12836 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('');
12837 });
12838 it('should have a URI fragment identifier that is empty', function () {
12839 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#');
12840 });
12841 });
12842 describe('a URI fragment identifier to the root #', function () {
12843 var p = create('#');
12844 it('#get should resolve to the object itself', function () {
12845 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data);
12846 });
12847 it('#set should throw', function () {
12848 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(function () {
12849 p.set(data, {
12850 this: 'should cause an exception',
12851 });
12852 }).to.throw();
12853 });
12854 it('should have an empty path', function () {
12855 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.have.length(0);
12856 });
12857 it('should have a pointer that is empty', function () {
12858 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('');
12859 });
12860 it('should have a URI fragment identifier that is empty', function () {
12861 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#');
12862 });
12863 });
12864 describe('with a JSON pointer of `/foo`', function () {
12865 var p = create('/foo');
12866 it('#get should resolve to data["foo"]', function () {
12867 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data.foo);
12868 });
12869 it('#set should succeed changing the referenced value', function () {
12870 var capture = p.get(data);
12871 var updated = {
12872 this: 'should succeed',
12873 };
12874 p.set(data, updated);
12875 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
12876 p.set(data, capture);
12877 });
12878 it('should have a path of [ "foo" ]', function () {
12879 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['foo']);
12880 });
12881 it('should have the pointer `/foo`', function () {
12882 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/foo');
12883 });
12884 it('should have the URI fragment identifier `#/foo`', function () {
12885 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/foo');
12886 });
12887 });
12888 describe('a URI fragment identifier of `#/foo`', function () {
12889 var p = create('#/foo');
12890 it('#get should resolve to data["foo"]', function () {
12891 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data.foo);
12892 });
12893 it('#set should succeed changing the referenced value', function () {
12894 var capture = p.get(data);
12895 var updated = {
12896 this: 'should succeed',
12897 };
12898 p.set(data, updated);
12899 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
12900 p.set(data, capture);
12901 });
12902 it('should have a path of [ "foo" ]', function () {
12903 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['foo']);
12904 });
12905 it('should have the pointer `/foo`', function () {
12906 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/foo');
12907 });
12908 it('should have the URI fragment identifier `#/foo`', function () {
12909 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/foo');
12910 });
12911 });
12912 describe('with a JSON pointer of `/foo/0`', function () {
12913 var p = create('/foo/0');
12914 it('#get should resolve to data.foo[0]', function () {
12915 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data.foo[0]);
12916 });
12917 it('#set should succeed changing the referenced value', function () {
12918 var capture = p.get(data);
12919 var updated = {
12920 this: 'should succeed',
12921 };
12922 p.set(data, updated);
12923 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
12924 p.set(data, capture);
12925 });
12926 it('should have a path of [ "foo", "0" ]', function () {
12927 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['foo', '0']);
12928 });
12929 it('should have the pointer `/foo/0`', function () {
12930 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/foo/0');
12931 });
12932 it('should have the URI fragment identifier `#/foo/0`', function () {
12933 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/foo/0');
12934 });
12935 });
12936 describe('a URI fragment identifier of `#/foo/0`', function () {
12937 var p = create('#/foo/0');
12938 it('#get should resolve to data.foo[0]', function () {
12939 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data.foo[0]);
12940 });
12941 it('#set should succeed changing the referenced value', function () {
12942 var capture = p.get(data);
12943 var updated = {
12944 this: 'should succeed',
12945 };
12946 p.set(data, updated);
12947 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
12948 p.set(data, capture);
12949 });
12950 it('should have a path of [ "foo", "0" ]', function () {
12951 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['foo', '0']);
12952 });
12953 it('should have the pointer `/foo/0`', function () {
12954 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/foo/0');
12955 });
12956 it('should have the URI fragment identifier `#/foo/0`', function () {
12957 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/foo/0');
12958 });
12959 });
12960 describe('a URI fragment identifier of `#/newArray/0`', function () {
12961 var p = create('#/newArray/0');
12962 it('#get should resolve to undefined', function () {
12963 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(undefined);
12964 });
12965 it('#set with force should succeed creating an array and setting the referenced value', function () {
12966 var blank = {};
12967 var capture = p.get(data);
12968 var updated = {
12969 this: 'should succeed',
12970 };
12971 p.set(blank, updated, true);
12972 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(Array.isArray(blank.newArray)).to.eql(true);
12973 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(blank)).to.eql(updated);
12974 p.set(blank, capture);
12975 });
12976 it('should have a path of [ "newArray", "0" ]', function () {
12977 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['newArray', '0']);
12978 });
12979 it('should have the pointer `/newArray/0`', function () {
12980 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/newArray/0');
12981 });
12982 it('should have the URI fragment identifier `#/newArray/0`', function () {
12983 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/newArray/0');
12984 });
12985 });
12986 describe('with a JSON pointer of `/`', function () {
12987 var p = create('/');
12988 it('#get should resolve to data[""]', function () {
12989 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['']);
12990 });
12991 it('#set should succeed changing the referenced value', function () {
12992 var capture = p.get(data);
12993 var updated = {
12994 this: 'should succeed',
12995 };
12996 p.set(data, updated);
12997 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
12998 p.set(data, capture);
12999 });
13000 it('should have a path of [ "" ]', function () {
13001 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['']);
13002 });
13003 it('should have the pointer `/`', function () {
13004 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/');
13005 });
13006 it('should have the URI fragment identifier `#/`', function () {
13007 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/');
13008 });
13009 });
13010 describe('a URI fragment identifier of `#/`', function () {
13011 var p = create('#/');
13012 it('#get should resolve to data[""]', function () {
13013 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['']);
13014 });
13015 it('#set should succeed changing the referenced value', function () {
13016 var capture = p.get(data);
13017 var updated = {
13018 this: 'should succeed',
13019 };
13020 p.set(data, updated);
13021 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13022 p.set(data, capture);
13023 });
13024 it('should have a path of [ "" ]', function () {
13025 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['']);
13026 });
13027 it('should have the pointer `/`', function () {
13028 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/');
13029 });
13030 it('should have the URI fragment identifier `#/`', function () {
13031 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/');
13032 });
13033 });
13034 describe('with a JSON pointer of `/a~1b`', function () {
13035 var p = create('/a~1b');
13036 it('#get should resolve to data["a/b"]', function () {
13037 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['a/b']);
13038 });
13039 it('#set should succeed changing the referenced value', function () {
13040 var capture = p.get(data);
13041 var updated = {
13042 this: 'should succeed',
13043 };
13044 p.set(data, updated);
13045 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13046 p.set(data, capture);
13047 });
13048 it('should have a path of [ "a/b" ]', function () {
13049 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['a/b']);
13050 });
13051 it('should have the pointer `/a~1b`', function () {
13052 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/a~1b');
13053 });
13054 it('should have the URI fragment identifier `#/a~1b`', function () {
13055 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/a~1b');
13056 });
13057 });
13058 describe('a URI fragment identifier of `#/a~1b`', function () {
13059 var p = create('#/a~1b');
13060 it('#get should resolve to data["a/b"]', function () {
13061 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['a/b']);
13062 });
13063 it('#set should succeed changing the referenced value', function () {
13064 var capture = p.get(data);
13065 var updated = {
13066 this: 'should succeed',
13067 };
13068 p.set(data, updated);
13069 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13070 p.set(data, capture);
13071 });
13072 it('should have a path of [ "a/b" ]', function () {
13073 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['a/b']);
13074 });
13075 it('should have the pointer `/a~1b`', function () {
13076 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/a~1b');
13077 });
13078 it('should have the URI fragment identifier `#/a~1b`', function () {
13079 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/a~1b');
13080 });
13081 });
13082 describe('with a JSON pointer of `/c%d`', function () {
13083 var p = create('/c%d');
13084 it('#get should resolve to data["c%d"]', function () {
13085 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['c%d']);
13086 });
13087 it('#set should succeed changing the referenced value', function () {
13088 var capture = p.get(data);
13089 var updated = {
13090 this: 'should succeed',
13091 };
13092 p.set(data, updated);
13093 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13094 p.set(data, capture);
13095 });
13096 it('should have a path of [ "c%d" ]', function () {
13097 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['c%d']);
13098 });
13099 it('should have the pointer `/c%d`', function () {
13100 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/c%d');
13101 });
13102 it('should have the URI fragment identifier `#/c%25d`', function () {
13103 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/c%25d');
13104 });
13105 });
13106 describe('a URI fragment identifier of `#/c%25d`', function () {
13107 var p = create('#/c%25d');
13108 it('#get should resolve to data["c%d"]', function () {
13109 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['c%d']);
13110 });
13111 it('#set should succeed changing the referenced value', function () {
13112 var capture = p.get(data);
13113 var updated = {
13114 this: 'should succeed',
13115 };
13116 p.set(data, updated);
13117 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13118 p.set(data, capture);
13119 });
13120 it('should have a path of [ "c%d" ]', function () {
13121 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['c%d']);
13122 });
13123 it('should have the pointer `/c%d`', function () {
13124 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/c%d');
13125 });
13126 it('should have the URI fragment identifier `#/c%25d`', function () {
13127 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/c%25d');
13128 });
13129 });
13130 describe('with a JSON pointer of `/e^f`', function () {
13131 var p = create('/e^f');
13132 it('#get should resolve to data["e^f"]', function () {
13133 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['e^f']);
13134 });
13135 it('#set should succeed changing the referenced value', function () {
13136 var capture = p.get(data);
13137 var updated = {
13138 this: 'should succeed',
13139 };
13140 p.set(data, updated);
13141 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13142 p.set(data, capture);
13143 });
13144 it('should have a path of [ "e^f" ]', function () {
13145 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['e^f']);
13146 });
13147 it('should have the pointer `/e^f`', function () {
13148 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/e^f');
13149 });
13150 it('should have the URI fragment identifier `#/e%5Ef`', function () {
13151 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/e%5Ef');
13152 });
13153 });
13154 describe('a URI fragment identifier of `#/e%5Ef`', function () {
13155 var p = create('#/e%5Ef');
13156 it('#get should resolve to data["e^f"]', function () {
13157 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['e^f']);
13158 });
13159 it('#set should succeed changing the referenced value', function () {
13160 var capture = p.get(data);
13161 var updated = {
13162 this: 'should succeed',
13163 };
13164 p.set(data, updated);
13165 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13166 p.set(data, capture);
13167 });
13168 it('should have a path of [ "e^f" ]', function () {
13169 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['e^f']);
13170 });
13171 it('should have the pointer `/e^f`', function () {
13172 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/e^f');
13173 });
13174 it('should have the URI fragment identifier `#/e%5Ef`', function () {
13175 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/e%5Ef');
13176 });
13177 });
13178 describe('with a JSON pointer of `/g|h`', function () {
13179 var p = create('/g|h');
13180 it('#get should resolve to data["g|h"]', function () {
13181 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['g|h']);
13182 });
13183 it('#set should succeed changing the referenced value', function () {
13184 var capture = p.get(data);
13185 var updated = {
13186 this: 'should succeed',
13187 };
13188 p.set(data, updated);
13189 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13190 p.set(data, capture);
13191 });
13192 it('should have a path of [ "g|h" ]', function () {
13193 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['g|h']);
13194 });
13195 it('should have the pointer `/g|h`', function () {
13196 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/g|h');
13197 });
13198 it('should have the URI fragment identifier `#/g%7Ch`', function () {
13199 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/g%7Ch');
13200 });
13201 });
13202 describe('a URI fragment identifier of `#/g%7Ch`', function () {
13203 var p = create('#/g%7Ch');
13204 it('#get should resolve to data["g|h"]', function () {
13205 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['g|h']);
13206 });
13207 it('#set should succeed changing the referenced value', function () {
13208 var capture = p.get(data);
13209 var updated = {
13210 this: 'should succeed',
13211 };
13212 p.set(data, updated);
13213 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13214 p.set(data, capture);
13215 });
13216 it('should have a path of [ "g|h" ]', function () {
13217 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['g|h']);
13218 });
13219 it('should have the pointer `/g|h`', function () {
13220 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/g|h');
13221 });
13222 it('should have the URI fragment identifier `#/g%7Ch`', function () {
13223 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/g%7Ch');
13224 });
13225 });
13226 describe('with a JSON pointer of "/i\\j"', function () {
13227 var p = create('/i\\j');
13228 it('#get should resolve to data["i\\j"]', function () {
13229 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['i\\j']);
13230 });
13231 it('#set should succeed changing the referenced value', function () {
13232 var capture = p.get(data);
13233 var updated = {
13234 this: 'should succeed',
13235 };
13236 p.set(data, updated);
13237 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13238 p.set(data, capture);
13239 });
13240 it('should have a path of [ "i\\j" ]', function () {
13241 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['i\\j']);
13242 });
13243 it('should have the pointer `/i\\j`', function () {
13244 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/i\\j');
13245 });
13246 it('should have the URI fragment identifier `#/i%5Cj`', function () {
13247 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/i%5Cj');
13248 });
13249 });
13250 describe('a URI fragment identifier of `#/i%5Cj`', function () {
13251 var p = create('#/i%5Cj');
13252 it('#get should resolve to data["i\\j"]', function () {
13253 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['i\\j']);
13254 });
13255 it('#set should succeed changing the referenced value', function () {
13256 var capture = p.get(data);
13257 var updated = {
13258 this: 'should succeed',
13259 };
13260 p.set(data, updated);
13261 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13262 p.set(data, capture);
13263 });
13264 it('should have a path of [ "i\\j" ]', function () {
13265 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['i\\j']);
13266 });
13267 it('should have the pointer `/i\\j`', function () {
13268 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/i\\j');
13269 });
13270 it('should have the URI fragment identifier `#/i%5Cj`', function () {
13271 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/i%5Cj');
13272 });
13273 });
13274 describe("with a JSON pointer of '/k\\\"l'", function () {
13275 // eslint-disable-next-line no-useless-escape
13276 var p = create('/k"l');
13277 // eslint-disable-next-line no-useless-escape
13278 it('#get should resolve to data["k"l"]', function () {
13279 // eslint-disable-next-line no-useless-escape
13280 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['k"l']);
13281 });
13282 it('#set should succeed changing the referenced value', function () {
13283 var capture = p.get(data);
13284 var updated = {
13285 this: 'should succeed',
13286 };
13287 p.set(data, updated);
13288 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13289 p.set(data, capture);
13290 });
13291 // eslint-disable-next-line no-useless-escape
13292 it('should have a path of [ "k"l" ]', function () {
13293 // eslint-disable-next-line no-useless-escape
13294 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['k"l']);
13295 });
13296 // eslint-disable-next-line no-useless-escape
13297 it('should have the pointer `/k"l`', function () {
13298 // eslint-disable-next-line no-useless-escape
13299 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/k"l');
13300 });
13301 it('should have the URI fragment identifier `#/k%22l`', function () {
13302 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/k%22l');
13303 });
13304 });
13305 describe('a URI fragment identifier of `#/k%22l`', function () {
13306 var p = create('#/k%22l');
13307 // eslint-disable-next-line no-useless-escape
13308 it('#get should resolve to data["k"l"]', function () {
13309 // eslint-disable-next-line no-useless-escape
13310 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['k"l']);
13311 });
13312 it('#set should succeed changing the referenced value', function () {
13313 var capture = p.get(data);
13314 var updated = {
13315 this: 'should succeed',
13316 };
13317 p.set(data, updated);
13318 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13319 p.set(data, capture);
13320 });
13321 // eslint-disable-next-line no-useless-escape
13322 it('should have a path of [ "k"l" ]', function () {
13323 // eslint-disable-next-line no-useless-escape
13324 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['k"l']);
13325 });
13326 // eslint-disable-next-line no-useless-escape
13327 it('should have the pointer `/k"l`', function () {
13328 // eslint-disable-next-line no-useless-escape
13329 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/k"l');
13330 });
13331 it('should have the URI fragment identifier `#/k%22l`', function () {
13332 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/k%22l');
13333 });
13334 });
13335 describe('with a JSON pointer of `/ `', function () {
13336 var p = create('/ ');
13337 it('#get should resolve to data[" "]', function () {
13338 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data[' ']);
13339 });
13340 it('#set should succeed changing the referenced value', function () {
13341 var capture = p.get(data);
13342 var updated = {
13343 this: 'should succeed',
13344 };
13345 p.set(data, updated);
13346 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13347 p.set(data, capture);
13348 });
13349 it('should have a path of [ " " ]', function () {
13350 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql([' ']);
13351 });
13352 it('should have the pointer `/ `', function () {
13353 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/ ');
13354 });
13355 it('should have the URI fragment identifier `#/%20`', function () {
13356 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/%20');
13357 });
13358 });
13359 describe('a URI fragment identifier of `#/%20`', function () {
13360 var p = create('#/%20');
13361 it('#get should resolve to data[" "]', function () {
13362 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data[' ']);
13363 });
13364 it('#set should succeed changing the referenced value', function () {
13365 var capture = p.get(data);
13366 var updated = {
13367 this: 'should succeed',
13368 };
13369 p.set(data, updated);
13370 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13371 p.set(data, capture);
13372 });
13373 it('should have a path of [ " " ]', function () {
13374 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql([' ']);
13375 });
13376 it('should have the pointer `/ `', function () {
13377 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/ ');
13378 });
13379 it('should have the URI fragment identifier `#/%20`', function () {
13380 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/%20');
13381 });
13382 });
13383 describe('with a JSON pointer of `/m~0n`', function () {
13384 var p = create('/m~0n');
13385 it('#get should resolve to data["m~n"]', function () {
13386 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['m~n']);
13387 });
13388 it('#set should succeed changing the referenced value', function () {
13389 var capture = p.get(data);
13390 var updated = {
13391 this: 'should succeed',
13392 };
13393 p.set(data, updated);
13394 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13395 p.set(data, capture);
13396 });
13397 it('should have a path of [ "m~n" ]', function () {
13398 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['m~n']);
13399 });
13400 it('should have the pointer `/m~0n`', function () {
13401 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/m~0n');
13402 });
13403 it('should have the URI fragment identifier `#/m~0n`', function () {
13404 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/m~0n');
13405 });
13406 });
13407 describe('a URI fragment identifier of `#/m~0n`', function () {
13408 var p = create('#/m~0n');
13409 it('#get should resolve to data["m~n"]', function () {
13410 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(data['m~n']);
13411 });
13412 it('#set should succeed changing the referenced value', function () {
13413 var capture = p.get(data);
13414 var updated = {
13415 this: 'should succeed',
13416 };
13417 p.set(data, updated);
13418 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(updated);
13419 p.set(data, capture);
13420 });
13421 it('should have a path of [ "m~n" ]', function () {
13422 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.path).to.eql(['m~n']);
13423 });
13424 it('should have the pointer `/m~0n`', function () {
13425 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.pointer).to.eql('/m~0n');
13426 });
13427 it('should have the URI fragment identifier `#/m~0n`', function () {
13428 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.uriFragmentIdentifier).to.eql('#/m~0n');
13429 });
13430 });
13431 describe('a special array pointer from draft-ietf-appsawg-json-pointer-08 `/foo/-`', function () {
13432 var p = create('/foo/-');
13433 it('should not resolve via #get', function () {
13434 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.be.undefined;
13435 });
13436 it('should set the next element of the array, repeatedly...', function () {
13437 p.set(data, 'qux');
13438 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(data.foo[2]).to.eql('qux');
13439 });
13440 it('...3', function () {
13441 p.set(data, 'quux');
13442 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(data.foo[3]).to.eql('quux');
13443 });
13444 it('...4', function () {
13445 p.set(data, 'corge');
13446 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(data.foo[4]).to.eql('corge');
13447 });
13448 it('...5', function () {
13449 p.set(data, 'grault');
13450 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(data.foo[5]).to.eql('grault');
13451 });
13452 });
13453 describe('an invalid pointer', function () {
13454 it('should fail to parse', function () {
13455 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(function () {
13456 create('a/');
13457 }).to.throw();
13458 });
13459 });
13460 describe('an invalid URI fragment identifier', function () {
13461 it('should fail to parse', function () {
13462 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(function () {
13463 create('#a');
13464 }).to.throw();
13465 });
13466 });
13467 });
13468 describe('when working with complex data', function () {
13469 var data = {
13470 a: 1,
13471 b: {
13472 c: 2,
13473 },
13474 d: {
13475 e: [
13476 {
13477 a: 3,
13478 },
13479 {
13480 b: 4,
13481 },
13482 {
13483 c: 5,
13484 },
13485 ],
13486 },
13487 f: null,
13488 'http://schema.org/name': 'Phillip',
13489 };
13490 it('#get should return `undefined` when the requested element is undefined (#/g/h)', function () {
13491 var unk = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(data, '#/g/h');
13492 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(unk).to.be.undefined;
13493 });
13494 it('#get should return null when the requested element has a null value (#/f)', function () {
13495 var unk = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(data, '#/f');
13496 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(unk).to.be.null;
13497 });
13498 it('#get should return the value of a prop named with multiple slahes (#/http:~1~1schema.org~1name)', function () {
13499 var unk = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(data, '#/http:~1~1schema.org~1name');
13500 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(unk).to.eql('Phillip');
13501 });
13502 it('#get should return the value of a prop named with multiple slahes (/http:~1~1schema.org~1name)', function () {
13503 var unk = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(data, '/http:~1~1schema.org~1name');
13504 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(unk).to.eql('Phillip');
13505 });
13506 it('#set should set the value of a prop named with multiple slahes (#/http:~1~1schema.org~1name)', function () {
13507 ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.set(data, '#/http:~1~1schema.org~1name', 'Phil');
13508 var unk = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(data, '/http:~1~1schema.org~1name');
13509 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(unk).to.eql('Phil');
13510 });
13511 it('#set should set the value of a prop named with multiple slahes (/http:~1~1schema.org~1name)', function () {
13512 ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.set(data, '/http:~1~1schema.org~1name', 'Phil');
13513 var unk = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(data, '/http:~1~1schema.org~1name');
13514 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(unk).to.eql('Phil');
13515 });
13516 });
13517 describe('given an sequence of property names ["d", "e~f", "2"]', function () {
13518 var path = ['d', 'e~f', '2'];
13519 it('#encodePointer should produce a pointer (/d/e~0f/2)', function () {
13520 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)((0,___WEBPACK_IMPORTED_MODULE_0__.encodePointer)(path)).to.eql('/d/e~0f/2');
13521 });
13522 it('#encodeUriFragmentIdentifier should produce a pointer (#/d/e~0f/2)', function () {
13523 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)((0,___WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier)(path)).to.eql('#/d/e~0f/2');
13524 });
13525 });
13526 describe('#list...', function () {
13527 var data = {
13528 a: 1,
13529 b: { c: 2 },
13530 d: { e: [{ a: 3 }, { b: 4 }, { c: 5 }] },
13531 f: null,
13532 };
13533 var pointerList = [
13534 ['', data],
13535 ['/a', data.a],
13536 ['/b', data.b],
13537 ['/d', data.d],
13538 ['/f', data.f],
13539 ['/b/c', data.b.c],
13540 ['/d/e', data.d.e],
13541 ['/d/e/0', data.d.e[0]],
13542 ['/d/e/1', data.d.e[1]],
13543 ['/d/e/2', data.d.e[2]],
13544 ['/d/e/0/a', data.d.e[0].a],
13545 ['/d/e/1/b', data.d.e[1].b],
13546 ['/d/e/2/c', data.d.e[2].c],
13547 ];
13548 var fragmentList = [
13549 ['#', data],
13550 ['#/a', data.a],
13551 ['#/b', data.b],
13552 ['#/d', data.d],
13553 ['#/f', data.f],
13554 ['#/b/c', data.b.c],
13555 ['#/d/e', data.d.e],
13556 ['#/d/e/0', data.d.e[0]],
13557 ['#/d/e/1', data.d.e[1]],
13558 ['#/d/e/2', data.d.e[2]],
13559 ['#/d/e/0/a', data.d.e[0].a],
13560 ['#/d/e/1/b', data.d.e[1].b],
13561 ['#/d/e/2/c', data.d.e[2].c],
13562 ];
13563 describe('listPointers(target)', function () {
13564 var items = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.listPointers(data);
13565 pointerList.forEach(function (tt, n) {
13566 it("item ".concat(n, " has pointer ").concat(tt[0]), function () {
13567 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(items[n].pointer).to.eql(tt[0]);
13568 });
13569 it("item ".concat(n, " has value ").concat(tt[1]), function () {
13570 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(items[n].value).to.eql(tt[1]);
13571 });
13572 });
13573 });
13574 describe('listFragmentIds(target)', function () {
13575 var items = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.listFragmentIds(data);
13576 fragmentList.forEach(function (tt, n) {
13577 it("item ".concat(n, " has fragmentId ").concat(tt[0]), function () {
13578 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(items[n].fragmentId).to.eql(tt[0]);
13579 });
13580 it("item ".concat(n, " has value ").concat(tt[1]), function () {
13581 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(items[n].value).to.eql(tt[1]);
13582 });
13583 });
13584 });
13585 });
13586});
13587describe('when data contains an array early in the path', function () {
13588 var data = {
13589 foo: [],
13590 };
13591 it('#set(o, val, true) should create the path through the array #/foo/0/wilbur/idiocies', function () {
13592 var p = create('#/foo/0/wilbur/idiocies');
13593 p.set(data, 5, true);
13594 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(p.get(data)).to.eql(5);
13595 });
13596});
13597describe('concat pointers', function () {
13598 var ptr1 = create('/a/b');
13599 var ptr2 = create('/c/d');
13600 var result = '/a/b/c/d';
13601 it('#concat JsonPointer("/a/b") with array ["a", "b"] should produce ' +
13602 result, function () {
13603 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(ptr1.concat(Array.from(ptr2.path)).pointer).to.eql(result);
13604 });
13605 it('#concat JsonPointer("/a/b") with JsonPointer("/b/c") should produce ' +
13606 result, function () {
13607 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(ptr1.concat(ptr2).pointer).to.eql(result);
13608 });
13609 it('#concat JsonPointer("/a/b") with string "/b/c" should produce ' + result, function () {
13610 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(ptr1.concat(ptr2.pointer).pointer).to.eql(result);
13611 });
13612 it('#concat JsonPointer("/a/b") with string "#/b/c" should produce ' + result, function () {
13613 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(ptr1.concat(ptr2.uriFragmentIdentifier).toString()).to.eql(result);
13614 });
13615});
13616describe('path segments containing single quote', function () {
13617 it('issue 28 proof of fix', function () {
13618 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get({}, "/it's bad")).to.eql(undefined);
13619 });
13620 it('issue 30 proof of fix', function () {
13621 ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get({}, "/aaa'])) !== 'undefined') {return it;}; Number.hacked = true; if(((['a");
13622 var result = Number;
13623 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(result.hacked).to.eql(undefined);
13624 });
13625});
13626describe('unreachable path across a null object in the graph', function () {
13627 it('issue 36 proof of fix', function () {
13628 var o = {
13629 id: 1234,
13630 employee: null,
13631 created_on: '2021-05-11',
13632 };
13633 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.get(o, '/employee/st_price')).to.eql(undefined);
13634 });
13635});
13636describe('.set() ops, single char segment interpreted as number', function () {
13637 it('issue 48 proof of fix', function () {
13638 var _a;
13639 var obj = {};
13640 var ptr = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.create('/hi/e');
13641 ptr.set(obj, 'hello', true);
13642 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)((_a = obj.hi) === null || _a === void 0 ? void 0 : _a.e).to.eql('hello');
13643 });
13644 it('issue 48 does not apply when path is an integer', function () {
13645 var obj = {};
13646 var ptr = ___WEBPACK_IMPORTED_MODULE_0__.JsonPointer.create('/arr/0');
13647 ptr.set(obj, 'hello', true);
13648 if (obj.arr) {
13649 (0,chai__WEBPACK_IMPORTED_MODULE_1__.expect)(obj.arr[0]).to.eql('hello');
13650 }
13651 else {
13652 chai__WEBPACK_IMPORTED_MODULE_1__.expect.fail('well hell, the array should have been created.');
13653 }
13654 });
13655});
13656
13657
13658/***/ }),
13659
13660/***/ "./src/__tests__/reference.spec.ts":
13661/*!*****************************************!*\
13662 !*** ./src/__tests__/reference.spec.ts ***!
13663 \*****************************************/
13664/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
13665
13666"use strict";
13667__webpack_require__.r(__webpack_exports__);
13668/* harmony import */ var chai__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! chai */ "./node_modules/chai/index.mjs");
13669/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! .. */ "./src/index.ts");
13670/**
13671 * @hidden
13672 * @packageDocumentation
13673 */
13674
13675
13676describe('JsonReference', function () {
13677 describe('.ctor()', function () {
13678 it('throws when pointer unspecified', function () {
13679 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference(undefined); }).to.throw('Invalid type: JSON Pointers are represented as strings.');
13680 });
13681 it('succeeds when pointer specified as string', function () {
13682 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference('');
13683 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(ref.pointer().path).to.eql([]);
13684 });
13685 it('succeeds when pointer specified as PathSegments', function () {
13686 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference([]);
13687 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(ref.pointer().path).to.eql([]);
13688 });
13689 it('succeeds when pointer specified as JsonPointer', function () {
13690 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference(new ___WEBPACK_IMPORTED_MODULE_1__.JsonPointer('/foo'));
13691 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(ref.pointer().path).to.eql(['foo']);
13692 });
13693 });
13694 describe('static .isReference()', function () {
13695 it('returns false when reference unspecified', function () {
13696 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_1__.JsonReference.isReference(undefined)).to.be.false;
13697 });
13698 it('returns false when reference specified as null', function () {
13699 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_1__.JsonReference.isReference(null)).to.be.false;
13700 });
13701 it('returns false when reference specified is not a reference', function () {
13702 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_1__.JsonReference.isReference(new Date())).to.be.false;
13703 });
13704 it('returns true when reference specified', function () {
13705 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(___WEBPACK_IMPORTED_MODULE_1__.JsonReference.isReference(new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference(''))).to.be.true;
13706 });
13707 });
13708 describe('.resolve()', function () {
13709 var data = { foo: { bar: 'baz' } };
13710 it('resolves to referenced property', function () {
13711 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference('/foo/bar');
13712 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(ref.resolve(data)).to.eql(data.foo.bar);
13713 });
13714 it('resolves to undefined when no such property', function () {
13715 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference('/foo/baz');
13716 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(ref.resolve(data)).to.be.undefined;
13717 });
13718 });
13719 describe('.toString()', function () {
13720 it('is interpolated', function () {
13721 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference('/foo/bar');
13722 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)("".concat(ref)).to.eql('#/foo/bar');
13723 });
13724 it('is coerced', function () {
13725 var ref = new ___WEBPACK_IMPORTED_MODULE_1__.JsonReference('/foo/bar');
13726 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)('' + ref).to.eql('#/foo/bar');
13727 });
13728 });
13729});
13730
13731
13732/***/ }),
13733
13734/***/ "./src/__tests__/utils.spec.ts":
13735/*!*************************************!*\
13736 !*** ./src/__tests__/utils.spec.ts ***!
13737 \*************************************/
13738/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
13739
13740"use strict";
13741__webpack_require__.r(__webpack_exports__);
13742/* harmony import */ var chai__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! chai */ "./node_modules/chai/index.mjs");
13743/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! .. */ "./src/index.ts");
13744/**
13745 * @hidden
13746 * @packageDocumentation
13747 */
13748
13749
13750describe('Utils', function () {
13751 var fragments = [
13752 [[], [], '#'],
13753 [[''], [''], '#/'],
13754 [['foo bar'], ['foo%20bar'], '#/foo%20bar'],
13755 [['foo bar', 0], ['foo%20bar', 0], '#/foo%20bar/0'],
13756 ];
13757 var pointers = [
13758 [[], [], ''],
13759 [[''], [''], '/'],
13760 [['foo bar'], ['foo bar'], '/foo bar'],
13761 [['foo bar', 0], ['foo bar', 0], '/foo bar/0'],
13762 ];
13763 describe('encodeFragmentSegments()', function () {
13764 var _loop_1 = function (decoded, encoded) {
13765 it("".concat(JSON.stringify(decoded), " encodes to ").concat(JSON.stringify(encoded)), function () {
13766 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.encodeFragmentSegments)(decoded)).to.eql(encoded);
13767 });
13768 };
13769 for (var _i = 0, fragments_1 = fragments; _i < fragments_1.length; _i++) {
13770 var _a = fragments_1[_i], decoded = _a[0], encoded = _a[1];
13771 _loop_1(decoded, encoded);
13772 }
13773 });
13774 describe('decodeFragmentSegments()', function () {
13775 var _loop_2 = function (decoded, encoded) {
13776 it("".concat(JSON.stringify(encoded), " encodes to ").concat(JSON.stringify(decoded)), function () {
13777 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.decodeFragmentSegments)(encoded)).to.eql(decoded);
13778 });
13779 };
13780 for (var _i = 0, fragments_2 = fragments; _i < fragments_2.length; _i++) {
13781 var _a = fragments_2[_i], decoded = _a[0], encoded = _a[1];
13782 _loop_2(decoded, encoded);
13783 }
13784 });
13785 describe('encodePointerSegments()', function () {
13786 var _loop_3 = function (decoded, encoded) {
13787 it("".concat(JSON.stringify(decoded), " encodes to ").concat(JSON.stringify(encoded)), function () {
13788 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.encodePointerSegments)(decoded)).to.eql(encoded);
13789 });
13790 };
13791 for (var _i = 0, pointers_1 = pointers; _i < pointers_1.length; _i++) {
13792 var _a = pointers_1[_i], decoded = _a[0], encoded = _a[1];
13793 _loop_3(decoded, encoded);
13794 }
13795 });
13796 describe('decodePointerSegments()', function () {
13797 var _loop_4 = function (decoded, encoded) {
13798 it("".concat(JSON.stringify(encoded), " encodes to ").concat(JSON.stringify(decoded)), function () {
13799 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.decodePointerSegments)(encoded)).to.eql(decoded);
13800 });
13801 };
13802 for (var _i = 0, pointers_2 = pointers; _i < pointers_2.length; _i++) {
13803 var _a = pointers_2[_i], decoded = _a[0], encoded = _a[1];
13804 _loop_4(decoded, encoded);
13805 }
13806 });
13807 describe('encodePointer()', function () {
13808 it('throws when segments unspecified', function () {
13809 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13810 return (0,___WEBPACK_IMPORTED_MODULE_1__.encodePointer)(undefined);
13811 }).to.throw('Invalid type: path must be an array of segments.');
13812 });
13813 it('throws when segments specified wrong type', function () {
13814 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return (0,___WEBPACK_IMPORTED_MODULE_1__.encodePointer)({}); }).to.throw('Invalid type: path must be an array of segments.');
13815 });
13816 var _loop_5 = function (encoded, p) {
13817 it("".concat(JSON.stringify(encoded), " = '").concat(p, "'"), function () {
13818 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.encodePointer)(encoded)).to.eql(p);
13819 });
13820 };
13821 for (var _i = 0, pointers_3 = pointers; _i < pointers_3.length; _i++) {
13822 var _a = pointers_3[_i], encoded = _a[1], p = _a[2];
13823 _loop_5(encoded, p);
13824 }
13825 });
13826 describe('encodeUriFragmentIdentifier()', function () {
13827 it('throws when segments unspecified', function () {
13828 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13829 return (0,___WEBPACK_IMPORTED_MODULE_1__.encodeUriFragmentIdentifier)(undefined);
13830 }).to.throw('Invalid type: path must be an array of segments.');
13831 });
13832 it('throws when segments specified wrong type', function () {
13833 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13834 return (0,___WEBPACK_IMPORTED_MODULE_1__.encodeUriFragmentIdentifier)({});
13835 }).to.throw('Invalid type: path must be an array of segments.');
13836 });
13837 var _loop_6 = function (decoded, p) {
13838 it("".concat(JSON.stringify(decoded), " = '").concat(p, "'"), function () {
13839 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.encodeUriFragmentIdentifier)(decoded)).to.eql(p);
13840 });
13841 };
13842 for (var _i = 0, fragments_3 = fragments; _i < fragments_3.length; _i++) {
13843 var _a = fragments_3[_i], decoded = _a[0], p = _a[2];
13844 _loop_6(decoded, p);
13845 }
13846 });
13847 describe('decodeUriFragmentIdentifier()', function () {
13848 it('throws when ptr unspecified', function () {
13849 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13850 return (0,___WEBPACK_IMPORTED_MODULE_1__.decodeUriFragmentIdentifier)(undefined);
13851 }).to.throw('Invalid type: JSON Pointers are represented as strings.');
13852 });
13853 it('throws when ptr specified wrong type', function () {
13854 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13855 return (0,___WEBPACK_IMPORTED_MODULE_1__.decodeUriFragmentIdentifier)({});
13856 }).to.throw('Invalid type: JSON Pointers are represented as strings.');
13857 });
13858 it('throws when invalid ptr specified', function () {
13859 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return (0,___WEBPACK_IMPORTED_MODULE_1__.decodeUriFragmentIdentifier)(''); }).to.throw('Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.');
13860 });
13861 var _loop_7 = function (decoded, p) {
13862 var d = decoded.map(function (v) { return v + ''; });
13863 it("'".concat(p, "' === ").concat(JSON.stringify(d)), function () {
13864 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.decodeUriFragmentIdentifier)(p)).to.eql(d);
13865 });
13866 };
13867 for (var _i = 0, fragments_4 = fragments; _i < fragments_4.length; _i++) {
13868 var _a = fragments_4[_i], decoded = _a[0], p = _a[2];
13869 _loop_7(decoded, p);
13870 }
13871 });
13872 describe('toArrayIndexReference()', function () {
13873 it('returns idx when specified as number', function () {
13874 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference)([], 1000)).to.eql(1000);
13875 });
13876 it("returns 0 when array falsy and idx === '-'", function () {
13877 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference)(undefined, '-')).to.eql(0);
13878 });
13879 it("returns length when idx === '-'", function () {
13880 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference)(['one'], '-')).to.eql(1);
13881 });
13882 it('returns -1 when idx NAN', function () {
13883 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference)([], 'NaN')).to.eql(-1);
13884 });
13885 it('returns -1 when idx empty', function () {
13886 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference)([], '')).to.eql(-1);
13887 });
13888 it('returns -1 when idx large numeric string but NaN', function () {
13889 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference)([], '999s9')).to.eql(-1);
13890 });
13891 });
13892 describe('setValueAtPath()', function () {
13893 it('throws when target undefined', function () {
13894 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return (0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)(undefined, 0, ['foo']); }).to.throw('Cannot set values on undefined');
13895 });
13896 var data = { one: ['two', { three: 'four' }] };
13897 it('does not set at end of array if not forced', function () {
13898 var expected = data.one.length;
13899 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)(data, 'VV', ['one', 2])).to.be.undefined;
13900 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(data.one.length).to.eql(expected);
13901 });
13902 it('will set at end of array if forced', function () {
13903 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)(data, 'VV', ['one', 2], true)).to.be.undefined;
13904 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(data.one[2]).to.eql('VV');
13905 });
13906 it('does not set beyond end of array if not forced', function () {
13907 var expected = data.one.length;
13908 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)(data, 'VV', ['one', 5])).to.be.undefined;
13909 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(data.one.length).to.eql(expected);
13910 });
13911 it('will set beyond end of array if forced', function () {
13912 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)(data, 'VV', ['one', 5], true)).to.be.undefined;
13913 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(data.one[5]).to.eql('VV');
13914 });
13915 it('will prevent __proto__ from being polluted', function () {
13916 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13917 (0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)({}, 'yes', ['__proto__', 'polluted'], true);
13918 }).to.throw('Attempted prototype pollution disallowed.');
13919 var prototyped = {};
13920 if (!prototyped.__proto__)
13921 return;
13922 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(prototyped.__proto__.polluted).to.not.eql('yes');
13923 });
13924 it('will prevent .constructor from being polluted', function () {
13925 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13926 (0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)({}, 'yes', ['constructor', 'polluted'], true);
13927 }).to.throw('Attempted prototype pollution disallowed.');
13928 var prototyped = {};
13929 if (!prototyped.constructor)
13930 return;
13931 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(prototyped.constructor.polluted).to.not.eql('yes');
13932 });
13933 it('will prevent .prototype from being polluted', function () {
13934 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13935 (0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)({}, 'yes', ['prototype', 'polluted'], true);
13936 }).to.throw('Attempted prototype pollution disallowed.');
13937 var prototyped = {};
13938 if (!prototyped.prototype)
13939 return;
13940 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(prototyped.prototype.polluted).to.not.eql('yes');
13941 });
13942 it('will prevent __proto__ from being polluted by javascript', function () {
13943 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13944 (0,___WEBPACK_IMPORTED_MODULE_1__.setValueAtPath)({}, 'yes',
13945 // not allowed in TS depending on tsconfig, but hackable in JS:
13946 [['__proto__'], 'polluted'], true);
13947 var prototyped = {};
13948 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(prototyped.__proto__).to.be.undefined;
13949 }).to.throw('PathSegments must be a string or a number.');
13950 });
13951 });
13952 describe('unsetValueAtPath()', function () {
13953 it('throws when target undefined', function () {
13954 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () { return (0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)(undefined, ['foo']); }).to.throw('Cannot unset values on undefined');
13955 });
13956 var data = {
13957 a: ['one', { two: 'three' }, 'four', { five: { six: 'seven' } }],
13958 };
13959 it('can unset array elements', function () {
13960 var expected = data.a[0];
13961 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)(data, (0,___WEBPACK_IMPORTED_MODULE_1__.decodePointer)('/a/0'))).to.eql(expected);
13962 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(data.a[0]).to.be.undefined;
13963 });
13964 it('returns undefined if reference beyond array length', function () {
13965 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)(data, (0,___WEBPACK_IMPORTED_MODULE_1__.decodePointer)('/a/7'))).to.undefined;
13966 });
13967 it('succeeds when path through array', function () {
13968 var expected = data.a[3].six;
13969 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)((0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)(data, (0,___WEBPACK_IMPORTED_MODULE_1__.decodePointer)('/a/3/six'))).to.eql(expected);
13970 });
13971 it('will prevent __proto__ from being polluted', function () {
13972 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13973 (0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)({}, ['__proto__', 'polluted']);
13974 }).to.throw('Attempted prototype pollution disallowed.');
13975 });
13976 it('will prevent .constructor from being polluted', function () {
13977 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13978 (0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)({}, ['constructor', 'polluted']);
13979 }).to.throw('Attempted prototype pollution disallowed.');
13980 });
13981 it('will prevent .prototype from being polluted', function () {
13982 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13983 (0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)({}, ['prototype', 'polluted']);
13984 }).to.throw('Attempted prototype pollution disallowed.');
13985 });
13986 it('will prevent __proto__ from being polluted by javascript', function () {
13987 (0,chai__WEBPACK_IMPORTED_MODULE_0__.expect)(function () {
13988 (0,___WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath)({},
13989 // not allowed in TS depending on tsconfig, but hackable in JS:
13990 [['__proto__'], 'polluted']);
13991 }).to.throw('PathSegments must be a string or a number.');
13992 });
13993 });
13994});
13995
13996
13997/***/ }),
13998
13999/***/ "./src/index.ts":
14000/*!**********************!*\
14001 !*** ./src/index.ts ***!
14002 \**********************/
14003/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14004
14005"use strict";
14006__webpack_require__.r(__webpack_exports__);
14007/* harmony export */ __webpack_require__.d(__webpack_exports__, {
14008/* harmony export */ "compilePointerDereference": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.compilePointerDereference),
14009/* harmony export */ "decodeFragmentSegments": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.decodeFragmentSegments),
14010/* harmony export */ "decodePointer": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.decodePointer),
14011/* harmony export */ "decodePointerSegments": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.decodePointerSegments),
14012/* harmony export */ "decodePtrInit": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.decodePtrInit),
14013/* harmony export */ "decodeRelativePointer": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.decodeRelativePointer),
14014/* harmony export */ "decodeUriFragmentIdentifier": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.decodeUriFragmentIdentifier),
14015/* harmony export */ "encodeFragmentSegments": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.encodeFragmentSegments),
14016/* harmony export */ "encodePointer": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.encodePointer),
14017/* harmony export */ "encodePointerSegments": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.encodePointerSegments),
14018/* harmony export */ "encodeUriFragmentIdentifier": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.encodeUriFragmentIdentifier),
14019/* harmony export */ "looksLikeFragment": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.looksLikeFragment),
14020/* harmony export */ "pickDecoder": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.pickDecoder),
14021/* harmony export */ "replace": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.replace),
14022/* harmony export */ "setValueAtPath": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.setValueAtPath),
14023/* harmony export */ "toArrayIndexReference": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.toArrayIndexReference),
14024/* harmony export */ "unsetValueAtPath": () => (/* reexport safe */ _util__WEBPACK_IMPORTED_MODULE_1__.unsetValueAtPath),
14025/* harmony export */ "JsonPointer": () => (/* reexport safe */ _pointer__WEBPACK_IMPORTED_MODULE_2__.JsonPointer),
14026/* harmony export */ "JsonReference": () => (/* reexport safe */ _pointer__WEBPACK_IMPORTED_MODULE_2__.JsonReference)
14027/* harmony export */ });
14028/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./src/types.ts");
14029/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util */ "./src/util.ts");
14030/* harmony import */ var _pointer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pointer */ "./src/pointer.ts");
14031/**
14032 * @packageDocumentation
14033 */
14034
14035
14036
14037
14038
14039/***/ }),
14040
14041/***/ "./src/pointer.ts":
14042/*!************************!*\
14043 !*** ./src/pointer.ts ***!
14044 \************************/
14045/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14046
14047"use strict";
14048__webpack_require__.r(__webpack_exports__);
14049/* harmony export */ __webpack_require__.d(__webpack_exports__, {
14050/* harmony export */ "JsonPointer": () => (/* binding */ JsonPointer),
14051/* harmony export */ "JsonReference": () => (/* binding */ JsonReference)
14052/* harmony export */ });
14053/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ "./src/util.ts");
14054
14055/**
14056 * Determines if the value is an object (not null)
14057 * @param value the value
14058 * @returns true if the value is a non-null object; otherwise false.
14059 *
14060 * @hidden
14061 */
14062function isObject(value) {
14063 return typeof value === 'object' && value !== null;
14064}
14065/** @hidden */
14066function shouldDescend(obj) {
14067 return isObject(obj) && !JsonReference.isReference(obj);
14068}
14069/** @hidden */
14070function descendingVisit(target, visitor, encoder) {
14071 var distinctObjects = new Map();
14072 var q = [{ obj: target, path: [] }];
14073 while (q.length) {
14074 var _a = q.shift(), obj = _a.obj, path = _a.path;
14075 visitor(encoder(path), obj);
14076 if (shouldDescend(obj)) {
14077 distinctObjects.set(obj, new JsonPointer((0,_util__WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier)(path)));
14078 if (!Array.isArray(obj)) {
14079 var keys = Object.keys(obj);
14080 var len = keys.length;
14081 var i = -1;
14082 while (++i < len) {
14083 var it_1 = obj[keys[i]];
14084 if (isObject(it_1) && distinctObjects.has(it_1)) {
14085 q.push({
14086 obj: new JsonReference(distinctObjects.get(it_1)),
14087 path: path.concat(keys[i]),
14088 });
14089 }
14090 else {
14091 q.push({
14092 obj: it_1,
14093 path: path.concat(keys[i]),
14094 });
14095 }
14096 }
14097 }
14098 else {
14099 // handleArray
14100 var j = -1;
14101 var len = obj.length;
14102 while (++j < len) {
14103 var it_2 = obj[j];
14104 if (isObject(it_2) && distinctObjects.has(it_2)) {
14105 q.push({
14106 obj: new JsonReference(distinctObjects.get(it_2)),
14107 path: path.concat([j + '']),
14108 });
14109 }
14110 else {
14111 q.push({
14112 obj: it_2,
14113 path: path.concat([j + '']),
14114 });
14115 }
14116 }
14117 }
14118 }
14119 }
14120}
14121/** @hidden */
14122var $ptr = Symbol('pointer');
14123/** @hidden */
14124var $frg = Symbol('fragmentId');
14125/** @hidden */
14126var $get = Symbol('getter');
14127/**
14128 * Represents a JSON Pointer, capable of getting and setting the value on target
14129 * objects at the pointer's location.
14130 *
14131 * While there are static variants for most operations, our recommendation is
14132 * to use the instance level methods, which enables you avoid repeated
14133 * compiling/emitting transient accessors. Take a look at the speed comparisons
14134 * for our justification.
14135 *
14136 * In most cases, you should create and reuse instances of JsonPointer within
14137 * scope that makes sense for your app. We often create constants for frequently
14138 * used pointers, but your use case may vary.
14139 *
14140 * The following is a contrived example showing a function that uses pointers to
14141 * deal with changes in the structure of data (a version independent function):
14142 *
14143 * ```ts
14144 * import { JsonPointer } from 'json-ptr';
14145 *
14146 * export type SupportedVersion = '1.0' | '1.1';
14147 *
14148 * interface PrimaryGuestNamePointers {
14149 * name: JsonPointer;
14150 * surname: JsonPointer;
14151 * honorific: JsonPointer;
14152 * }
14153 * const versions: Record<SupportedVersion, PrimaryGuestNamePointers> = {
14154 * '1.0': {
14155 * name: JsonPointer.create('/guests/0/name'),
14156 * surname: JsonPointer.create('/guests/0/surname'),
14157 * honorific: JsonPointer.create('/guests/0/honorific'),
14158 * },
14159 * '1.1': {
14160 * name: JsonPointer.create('/primary/primaryGuest/name'),
14161 * surname: JsonPointer.create('/primary/primaryGuest/surname'),
14162 * honorific: JsonPointer.create('/primary/primaryGuest/honorific'),
14163 * }
14164 * };
14165 *
14166 * interface Reservation extends Record<string, unknown> {
14167 * version?: SupportedVersion;
14168 * }
14169 *
14170 * function primaryGuestName(reservation: Reservation): string {
14171 * const pointers = versions[reservation.version || '1.0'];
14172 * const name = pointers.name.get(reservation) as string;
14173 * const surname = pointers.surname.get(reservation) as string;
14174 * const honorific = pointers.honorific.get(reservation) as string;
14175 * const names: string[] = [];
14176 * if (honorific) names.push(honorific);
14177 * if (name) names.push(name);
14178 * if (surname) names.push(surname);
14179 * return names.join(' ');
14180 * }
14181 *
14182 * // The original layout of a reservation (only the parts relevant to our example)
14183 * const reservationV1: Reservation = {
14184 * guests: [{
14185 * name: 'Wilbur',
14186 * surname: 'Finkle',
14187 * honorific: 'Mr.'
14188 * }, {
14189 * name: 'Wanda',
14190 * surname: 'Finkle',
14191 * honorific: 'Mrs.'
14192 * }, {
14193 * name: 'Wilma',
14194 * surname: 'Finkle',
14195 * honorific: 'Miss',
14196 * child: true,
14197 * age: 12
14198 * }]
14199 * // ...
14200 * };
14201 *
14202 * // The new layout of a reservation (only the parts relevant to our example)
14203 * const reservationV1_1: Reservation = {
14204 * version: '1.1',
14205 * primary: {
14206 * primaryGuest: {
14207 * name: 'Wilbur',
14208 * surname: 'Finkle',
14209 * honorific: 'Mr.'
14210 * },
14211 * additionalGuests: [{
14212 * name: 'Wanda',
14213 * surname: 'Finkle',
14214 * honorific: 'Mrs.'
14215 * }, {
14216 * name: 'Wilma',
14217 * surname: 'Finkle',
14218 * honorific: 'Miss',
14219 * child: true,
14220 * age: 12
14221 * }]
14222 * // ...
14223 * }
14224 * // ...
14225 * };
14226 *
14227 * console.log(primaryGuestName(reservationV1));
14228 * console.log(primaryGuestName(reservationV1_1));
14229 *
14230 * ```
14231 *
14232 * There are many uses for pointers.
14233 */
14234var JsonPointer = /** @class */ (function () {
14235 /**
14236 * Creates a new instance.
14237 * @param ptr a string representation of a JSON Pointer, or a decoded array of path segments.
14238 */
14239 function JsonPointer(ptr) {
14240 this.path = (0,_util__WEBPACK_IMPORTED_MODULE_0__.decodePtrInit)(ptr);
14241 }
14242 /**
14243 * Factory function that creates a JsonPointer instance.
14244 *
14245 * ```ts
14246 * const ptr = JsonPointer.create('/deeply/nested/data/0/here');
14247 * ```
14248 * _or_
14249 * ```ts
14250 * const ptr = JsonPointer.create(['deeply', 'nested', 'data', 0, 'here']);
14251 * ```
14252 * @param pointer the pointer or path.
14253 */
14254 JsonPointer.create = function (pointer) {
14255 return new JsonPointer(pointer);
14256 };
14257 /**
14258 * Determines if the specified `target`'s object graph has a value at the `pointer`'s location.
14259 *
14260 * ```ts
14261 * const target = {
14262 * first: 'second',
14263 * third: ['fourth', 'fifth', { sixth: 'seventh' }],
14264 * eighth: 'ninth'
14265 * };
14266 *
14267 * console.log(JsonPointer.has(target, '/third/0'));
14268 * // true
14269 * console.log(JsonPointer.has(target, '/tenth'));
14270 * // false
14271 * ```
14272 *
14273 * @param target the target of the operation
14274 * @param pointer the pointer or path
14275 */
14276 JsonPointer.has = function (target, pointer) {
14277 if (typeof pointer === 'string' || Array.isArray(pointer)) {
14278 pointer = new JsonPointer(pointer);
14279 }
14280 return pointer.has(target);
14281 };
14282 /**
14283 * Gets the `target` object's value at the `pointer`'s location.
14284 *
14285 * ```ts
14286 * const target = {
14287 * first: 'second',
14288 * third: ['fourth', 'fifth', { sixth: 'seventh' }],
14289 * eighth: 'ninth'
14290 * };
14291 *
14292 * console.log(JsonPointer.get(target, '/third/2/sixth'));
14293 * // seventh
14294 * console.log(JsonPointer.get(target, '/tenth'));
14295 * // undefined
14296 * ```
14297 *
14298 * @param target the target of the operation
14299 * @param pointer the pointer or path.
14300 */
14301 JsonPointer.get = function (target, pointer) {
14302 if (typeof pointer === 'string' || Array.isArray(pointer)) {
14303 pointer = new JsonPointer(pointer);
14304 }
14305 return pointer.get(target);
14306 };
14307 /**
14308 * Sets the `target` object's value, as specified, at the `pointer`'s location.
14309 *
14310 * ```ts
14311 * const target = {
14312 * first: 'second',
14313 * third: ['fourth', 'fifth', { sixth: 'seventh' }],
14314 * eighth: 'ninth'
14315 * };
14316 *
14317 * console.log(JsonPointer.set(target, '/third/2/sixth', 'tenth'));
14318 * // seventh
14319 * console.log(JsonPointer.set(target, '/tenth', 'eleventh', true));
14320 * // undefined
14321 * console.log(JSON.stringify(target, null, ' '));
14322 * // {
14323 * // "first": "second",
14324 * // "third": [
14325 * // "fourth",
14326 * // "fifth",
14327 * // {
14328 * // "sixth": "tenth"
14329 * // }
14330 * // ],
14331 * // "eighth": "ninth",
14332 * // "tenth": "eleventh"
14333 * // }
14334 * ```
14335 *
14336 * @param target the target of the operation
14337 * @param pointer the pointer or path
14338 * @param val a value to write into the object graph at the specified pointer location
14339 * @param force indications whether the operation should force the pointer's location into existence in the object graph.
14340 *
14341 * @returns the prior value at the pointer's location in the object graph.
14342 */
14343 JsonPointer.set = function (target, pointer, val, force) {
14344 if (force === void 0) { force = false; }
14345 if (typeof pointer === 'string' || Array.isArray(pointer)) {
14346 pointer = new JsonPointer(pointer);
14347 }
14348 return pointer.set(target, val, force);
14349 };
14350 /**
14351 * Removes the `target` object's value at the `pointer`'s location.
14352 *
14353 * ```ts
14354 * const target = {
14355 * first: 'second',
14356 * third: ['fourth', 'fifth', { sixth: 'seventh' }],
14357 * eighth: 'ninth'
14358 * };
14359 *
14360 * console.log(JsonPointer.unset(target, '/third/2/sixth'));
14361 * // seventh
14362 * console.log(JsonPointer.unset(target, '/tenth'));
14363 * // undefined
14364 * console.log(JSON.stringify(target, null, ' '));
14365 * // {
14366 * // "first": "second",
14367 * // "third": [
14368 * // "fourth",
14369 * // "fifth",
14370 * // {}
14371 * // ],
14372 * // "eighth": "ninth",
14373 * // }
14374 * ```
14375 * @param target the target of the operation
14376 * @param pointer the pointer or path
14377 *
14378 * @returns the value that was removed from the object graph.
14379 */
14380 JsonPointer.unset = function (target, pointer) {
14381 if (typeof pointer === 'string' || Array.isArray(pointer)) {
14382 pointer = new JsonPointer(pointer);
14383 }
14384 return pointer.unset(target);
14385 };
14386 /**
14387 * Decodes the specified pointer into path segments.
14388 * @param pointer a string representation of a JSON Pointer
14389 */
14390 JsonPointer.decode = function (pointer) {
14391 return (0,_util__WEBPACK_IMPORTED_MODULE_0__.pickDecoder)(pointer)(pointer);
14392 };
14393 /**
14394 * Evaluates the target's object graph, calling the specified visitor for every unique pointer location discovered while walking the graph.
14395 * @param target the target of the operation
14396 * @param visitor a callback function invoked for each unique pointer location in the object graph
14397 * @param fragmentId indicates whether the visitor should receive fragment identifiers or regular pointers
14398 */
14399 JsonPointer.visit = function (target, visitor, fragmentId) {
14400 if (fragmentId === void 0) { fragmentId = false; }
14401 descendingVisit(target, visitor, fragmentId ? _util__WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier : _util__WEBPACK_IMPORTED_MODULE_0__.encodePointer);
14402 };
14403 /**
14404 * Evaluates the target's object graph, returning a [[JsonStringPointerListItem]] for each location in the graph.
14405 * @param target the target of the operation
14406 */
14407 JsonPointer.listPointers = function (target) {
14408 var res = [];
14409 descendingVisit(target, function (pointer, value) {
14410 res.push({ pointer: pointer, value: value });
14411 }, _util__WEBPACK_IMPORTED_MODULE_0__.encodePointer);
14412 return res;
14413 };
14414 /**
14415 * Evaluates the target's object graph, returning a [[UriFragmentIdentifierPointerListItem]] for each location in the graph.
14416 * @param target the target of the operation
14417 */
14418 JsonPointer.listFragmentIds = function (target) {
14419 var res = [];
14420 descendingVisit(target, function (fragmentId, value) {
14421 res.push({ fragmentId: fragmentId, value: value });
14422 }, _util__WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier);
14423 return res;
14424 };
14425 /**
14426 * Evaluates the target's object graph, returning a Record&lt;Pointer, unknown> populated with pointers and the corresponding values from the graph.
14427 * @param target the target of the operation
14428 * @param fragmentId indicates whether the results are populated with fragment identifiers rather than regular pointers
14429 */
14430 JsonPointer.flatten = function (target, fragmentId) {
14431 if (fragmentId === void 0) { fragmentId = false; }
14432 var res = {};
14433 descendingVisit(target, function (p, v) {
14434 res[p] = v;
14435 }, fragmentId ? _util__WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier : _util__WEBPACK_IMPORTED_MODULE_0__.encodePointer);
14436 return res;
14437 };
14438 /**
14439 * Evaluates the target's object graph, returning a Map&lt;Pointer,unknown> populated with pointers and the corresponding values form the graph.
14440 * @param target the target of the operation
14441 * @param fragmentId indicates whether the results are populated with fragment identifiers rather than regular pointers
14442 */
14443 JsonPointer.map = function (target, fragmentId) {
14444 if (fragmentId === void 0) { fragmentId = false; }
14445 var res = new Map();
14446 descendingVisit(target, res.set.bind(res), fragmentId ? _util__WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier : _util__WEBPACK_IMPORTED_MODULE_0__.encodePointer);
14447 return res;
14448 };
14449 /**
14450 * Gets the target object's value at the pointer's location.
14451 * @param target the target of the operation
14452 */
14453 JsonPointer.prototype.get = function (target) {
14454 if (!this[$get]) {
14455 this[$get] = (0,_util__WEBPACK_IMPORTED_MODULE_0__.compilePointerDereference)(this.path);
14456 }
14457 return this[$get](target);
14458 };
14459 /**
14460 * Sets the target object's value, as specified, at the pointer's location.
14461 *
14462 * If any part of the pointer's path does not exist, the operation aborts
14463 * without modification, unless the caller indicates that pointer's location
14464 * should be created.
14465 *
14466 * @param target the target of the operation
14467 * @param value the value to set
14468 * @param force indicates whether the pointer's location should be created if it doesn't already exist.
14469 */
14470 JsonPointer.prototype.set = function (target, value, force) {
14471 if (force === void 0) { force = false; }
14472 return (0,_util__WEBPACK_IMPORTED_MODULE_0__.setValueAtPath)(target, value, this.path, force);
14473 };
14474 /**
14475 * Removes the target object's value at the pointer's location.
14476 * @param target the target of the operation
14477 *
14478 * @returns the value that was removed from the object graph.
14479 */
14480 JsonPointer.prototype.unset = function (target) {
14481 return (0,_util__WEBPACK_IMPORTED_MODULE_0__.unsetValueAtPath)(target, this.path);
14482 };
14483 /**
14484 * Determines if the specified target's object graph has a value at the pointer's location.
14485 * @param target the target of the operation
14486 */
14487 JsonPointer.prototype.has = function (target) {
14488 return typeof this.get(target) !== 'undefined';
14489 };
14490 /**
14491 * Gets the value in the object graph that is the parent of the pointer location.
14492 * @param target the target of the operation
14493 */
14494 JsonPointer.prototype.parent = function (target) {
14495 var p = this.path;
14496 if (p.length == 1)
14497 return undefined;
14498 var parent = new JsonPointer(p.slice(0, p.length - 1));
14499 return parent.get(target);
14500 };
14501 /**
14502 * Creates a new JsonPointer instance, pointing to the specified relative location in the object graph.
14503 * @param ptr the relative pointer (relative to this)
14504 * @returns A new instance that points to the relative location.
14505 */
14506 JsonPointer.prototype.relative = function (ptr) {
14507 var p = this.path;
14508 var decoded = (0,_util__WEBPACK_IMPORTED_MODULE_0__.decodeRelativePointer)(ptr);
14509 var n = parseInt(decoded[0]);
14510 if (n > p.length)
14511 throw new Error('Relative location does not exist.');
14512 var r = p.slice(0, p.length - n).concat(decoded.slice(1));
14513 if (decoded[0][decoded[0].length - 1] == '#') {
14514 // It references the path segment/name, not the value
14515 var name_1 = r[r.length - 1];
14516 throw new Error("We won't compile a pointer that will always return '".concat(name_1, "'. Use JsonPointer.rel(target, ptr) instead."));
14517 }
14518 return new JsonPointer(r);
14519 };
14520 /**
14521 * Resolves the specified relative pointer path against the specified target object, and gets the target object's value at the relative pointer's location.
14522 * @param target the target of the operation
14523 * @param ptr the relative pointer (relative to this)
14524 * @returns the value at the relative pointer's resolved path; otherwise undefined.
14525 */
14526 JsonPointer.prototype.rel = function (target, ptr) {
14527 var p = this.path;
14528 var decoded = (0,_util__WEBPACK_IMPORTED_MODULE_0__.decodeRelativePointer)(ptr);
14529 var n = parseInt(decoded[0]);
14530 if (n > p.length) {
14531 // out of bounds
14532 return undefined;
14533 }
14534 var r = p.slice(0, p.length - n).concat(decoded.slice(1));
14535 var other = new JsonPointer(r);
14536 if (decoded[0][decoded[0].length - 1] == '#') {
14537 // It references the path segment/name, not the value
14538 var name_2 = r[r.length - 1];
14539 var parent_1 = other.parent(target);
14540 return Array.isArray(parent_1) ? parseInt(name_2, 10) : name_2;
14541 }
14542 return other.get(target);
14543 };
14544 /**
14545 * Creates a new instance by concatenating the specified pointer's path onto this pointer's path.
14546 * @param ptr the string representation of a pointer, it's decoded path, or an instance of JsonPointer indicating the additional path to concatenate onto the pointer.
14547 */
14548 JsonPointer.prototype.concat = function (ptr) {
14549 return new JsonPointer(this.path.concat(ptr instanceof JsonPointer ? ptr.path : (0,_util__WEBPACK_IMPORTED_MODULE_0__.decodePtrInit)(ptr)));
14550 };
14551 Object.defineProperty(JsonPointer.prototype, "pointer", {
14552 /**
14553 * This pointer's JSON Pointer encoded string representation.
14554 */
14555 get: function () {
14556 if (this[$ptr] === undefined) {
14557 this[$ptr] = (0,_util__WEBPACK_IMPORTED_MODULE_0__.encodePointer)(this.path);
14558 }
14559 return this[$ptr];
14560 },
14561 enumerable: false,
14562 configurable: true
14563 });
14564 Object.defineProperty(JsonPointer.prototype, "uriFragmentIdentifier", {
14565 /**
14566 * This pointer's URI fragment identifier encoded string representation.
14567 */
14568 get: function () {
14569 if (!this[$frg]) {
14570 this[$frg] = (0,_util__WEBPACK_IMPORTED_MODULE_0__.encodeUriFragmentIdentifier)(this.path);
14571 }
14572 return this[$frg];
14573 },
14574 enumerable: false,
14575 configurable: true
14576 });
14577 /**
14578 * Emits the JSON Pointer encoded string representation.
14579 */
14580 JsonPointer.prototype.toString = function () {
14581 return this.pointer;
14582 };
14583 return JsonPointer;
14584}());
14585
14586/** @hidden */
14587var $pointer = Symbol('pointer');
14588/**
14589 * A reference to a location in an object graph.
14590 *
14591 * This type is used by this module to break cycles in an object graph and to
14592 * reference locations that have already been visited when enumerating pointers.
14593 */
14594var JsonReference = /** @class */ (function () {
14595 /**
14596 * Creates a new instance.
14597 * @param pointer a JSON Pointer for the reference.
14598 */
14599 function JsonReference(pointer) {
14600 this[$pointer] =
14601 pointer instanceof JsonPointer ? pointer : new JsonPointer(pointer);
14602 this.$ref = this[$pointer].uriFragmentIdentifier;
14603 }
14604 /**
14605 * Determines if the specified `candidate` is a JsonReference.
14606 * @param candidate the candidate
14607 */
14608 JsonReference.isReference = function (candidate) {
14609 if (!candidate)
14610 return false;
14611 var ref = candidate;
14612 return typeof ref.$ref === 'string' && typeof ref.resolve === 'function';
14613 };
14614 /**
14615 * Resolves the reference against the `target` object, returning the value at
14616 * the referenced pointer's location.
14617 * @param target the target object
14618 */
14619 JsonReference.prototype.resolve = function (target) {
14620 return this[$pointer].get(target);
14621 };
14622 /**
14623 * Gets the reference's pointer.
14624 */
14625 JsonReference.prototype.pointer = function () {
14626 return this[$pointer];
14627 };
14628 /**
14629 * Gets the reference pointer's string representation (a URI fragment identifier).
14630 */
14631 JsonReference.prototype.toString = function () {
14632 return this.$ref;
14633 };
14634 return JsonReference;
14635}());
14636
14637
14638
14639/***/ }),
14640
14641/***/ "./src/types.ts":
14642/*!**********************!*\
14643 !*** ./src/types.ts ***!
14644 \**********************/
14645/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14646
14647"use strict";
14648__webpack_require__.r(__webpack_exports__);
14649
14650
14651
14652/***/ }),
14653
14654/***/ "./src/util.ts":
14655/*!*********************!*\
14656 !*** ./src/util.ts ***!
14657 \*********************/
14658/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14659
14660"use strict";
14661__webpack_require__.r(__webpack_exports__);
14662/* harmony export */ __webpack_require__.d(__webpack_exports__, {
14663/* harmony export */ "replace": () => (/* binding */ replace),
14664/* harmony export */ "decodeFragmentSegments": () => (/* binding */ decodeFragmentSegments),
14665/* harmony export */ "encodeFragmentSegments": () => (/* binding */ encodeFragmentSegments),
14666/* harmony export */ "decodePointerSegments": () => (/* binding */ decodePointerSegments),
14667/* harmony export */ "encodePointerSegments": () => (/* binding */ encodePointerSegments),
14668/* harmony export */ "decodePointer": () => (/* binding */ decodePointer),
14669/* harmony export */ "encodePointer": () => (/* binding */ encodePointer),
14670/* harmony export */ "decodeUriFragmentIdentifier": () => (/* binding */ decodeUriFragmentIdentifier),
14671/* harmony export */ "encodeUriFragmentIdentifier": () => (/* binding */ encodeUriFragmentIdentifier),
14672/* harmony export */ "decodeRelativePointer": () => (/* binding */ decodeRelativePointer),
14673/* harmony export */ "toArrayIndexReference": () => (/* binding */ toArrayIndexReference),
14674/* harmony export */ "compilePointerDereference": () => (/* binding */ compilePointerDereference),
14675/* harmony export */ "setValueAtPath": () => (/* binding */ setValueAtPath),
14676/* harmony export */ "unsetValueAtPath": () => (/* binding */ unsetValueAtPath),
14677/* harmony export */ "looksLikeFragment": () => (/* binding */ looksLikeFragment),
14678/* harmony export */ "pickDecoder": () => (/* binding */ pickDecoder),
14679/* harmony export */ "decodePtrInit": () => (/* binding */ decodePtrInit)
14680/* harmony export */ });
14681function replace(source, find, repl) {
14682 var res = '';
14683 var rem = source;
14684 var beg = 0;
14685 var end = -1;
14686 while ((end = rem.indexOf(find)) > -1) {
14687 res += source.substring(beg, beg + end) + repl;
14688 rem = rem.substring(end + find.length, rem.length);
14689 beg += end + find.length;
14690 }
14691 if (rem.length > 0) {
14692 res += source.substring(source.length - rem.length, source.length);
14693 }
14694 return res;
14695}
14696function decodeFragmentSegments(segments) {
14697 var i = -1;
14698 var len = segments.length;
14699 var res = new Array(len);
14700 while (++i < len) {
14701 if (typeof segments[i] === 'string') {
14702 res[i] = replace(replace(decodeURIComponent(segments[i]), '~1', '/'), '~0', '~');
14703 }
14704 else {
14705 res[i] = segments[i];
14706 }
14707 }
14708 return res;
14709}
14710function encodeFragmentSegments(segments) {
14711 var i = -1;
14712 var len = segments.length;
14713 var res = new Array(len);
14714 while (++i < len) {
14715 if (typeof segments[i] === 'string') {
14716 res[i] = encodeURIComponent(replace(replace(segments[i], '~', '~0'), '/', '~1'));
14717 }
14718 else {
14719 res[i] = segments[i];
14720 }
14721 }
14722 return res;
14723}
14724function decodePointerSegments(segments) {
14725 var i = -1;
14726 var len = segments.length;
14727 var res = new Array(len);
14728 while (++i < len) {
14729 if (typeof segments[i] === 'string') {
14730 res[i] = replace(replace(segments[i], '~1', '/'), '~0', '~');
14731 }
14732 else {
14733 res[i] = segments[i];
14734 }
14735 }
14736 return res;
14737}
14738function encodePointerSegments(segments) {
14739 var i = -1;
14740 var len = segments.length;
14741 var res = new Array(len);
14742 while (++i < len) {
14743 if (typeof segments[i] === 'string') {
14744 res[i] = replace(replace(segments[i], '~', '~0'), '/', '~1');
14745 }
14746 else {
14747 res[i] = segments[i];
14748 }
14749 }
14750 return res;
14751}
14752function decodePointer(ptr) {
14753 if (typeof ptr !== 'string') {
14754 throw new TypeError('Invalid type: JSON Pointers are represented as strings.');
14755 }
14756 if (ptr.length === 0) {
14757 return [];
14758 }
14759 if (ptr[0] !== '/') {
14760 throw new ReferenceError('Invalid JSON Pointer syntax. Non-empty pointer must begin with a solidus `/`.');
14761 }
14762 return decodePointerSegments(ptr.substring(1).split('/'));
14763}
14764function encodePointer(path) {
14765 if (!path || (path && !Array.isArray(path))) {
14766 throw new TypeError('Invalid type: path must be an array of segments.');
14767 }
14768 if (path.length === 0) {
14769 return '';
14770 }
14771 return '/'.concat(encodePointerSegments(path).join('/'));
14772}
14773function decodeUriFragmentIdentifier(ptr) {
14774 if (typeof ptr !== 'string') {
14775 throw new TypeError('Invalid type: JSON Pointers are represented as strings.');
14776 }
14777 if (ptr.length === 0 || ptr[0] !== '#') {
14778 throw new ReferenceError('Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.');
14779 }
14780 if (ptr.length === 1) {
14781 return [];
14782 }
14783 if (ptr[1] !== '/') {
14784 throw new ReferenceError('Invalid JSON Pointer syntax.');
14785 }
14786 return decodeFragmentSegments(ptr.substring(2).split('/'));
14787}
14788function encodeUriFragmentIdentifier(path) {
14789 if (!path || (path && !Array.isArray(path))) {
14790 throw new TypeError('Invalid type: path must be an array of segments.');
14791 }
14792 if (path.length === 0) {
14793 return '#';
14794 }
14795 return '#/'.concat(encodeFragmentSegments(path).join('/'));
14796}
14797var InvalidRelativePointerError = 'Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.';
14798function decodeRelativePointer(ptr) {
14799 if (typeof ptr !== 'string') {
14800 throw new TypeError('Invalid type: Relative JSON Pointers are represented as strings.');
14801 }
14802 if (ptr.length === 0) {
14803 // https://tools.ietf.org/id/draft-handrews-relative-json-pointer-00.html#rfc.section.3
14804 throw new ReferenceError(InvalidRelativePointerError);
14805 }
14806 var segments = ptr.split('/');
14807 var first = segments[0];
14808 // It is a name reference; strip the hash.
14809 if (first[first.length - 1] == '#') {
14810 if (segments.length > 1) {
14811 throw new ReferenceError(InvalidRelativePointerError);
14812 }
14813 first = first.substr(0, first.length - 1);
14814 }
14815 var i = -1;
14816 var len = first.length;
14817 while (++i < len) {
14818 if (first[i] < '0' || first[i] > '9') {
14819 throw new ReferenceError(InvalidRelativePointerError);
14820 }
14821 }
14822 var path = decodePointerSegments(segments.slice(1));
14823 path.unshift(segments[0]);
14824 return path;
14825}
14826function toArrayIndexReference(arr, idx) {
14827 if (typeof idx === 'number')
14828 return idx;
14829 var len = idx.length;
14830 if (!len)
14831 return -1;
14832 var cursor = 0;
14833 if (len === 1 && idx[0] === '-') {
14834 if (!Array.isArray(arr)) {
14835 return 0;
14836 }
14837 return arr.length;
14838 }
14839 while (++cursor < len) {
14840 if (idx[cursor] < '0' || idx[cursor] > '9') {
14841 return -1;
14842 }
14843 }
14844 return parseInt(idx, 10);
14845}
14846function compilePointerDereference(path) {
14847 var body = "if (typeof(it) !== 'undefined'";
14848 if (path.length === 0) {
14849 return function (it) { return it; };
14850 }
14851 body = path.reduce(function (body, _, i) {
14852 return (body +
14853 "\n\t&& it !== null && typeof((it = it['" +
14854 replace(replace(path[i] + '', '\\', '\\\\'), "'", "\\'") +
14855 "'])) !== 'undefined'");
14856 }, "if (typeof(it) !== 'undefined'");
14857 body = body + ') {\n\treturn it;\n }';
14858 // eslint-disable-next-line no-new-func
14859 return new Function('it', body);
14860}
14861function setValueAtPath(target, val, path, force) {
14862 if (force === void 0) { force = false; }
14863 if (path.length === 0) {
14864 throw new Error('Cannot set the root object; assign it directly.');
14865 }
14866 if (typeof target === 'undefined') {
14867 throw new TypeError('Cannot set values on undefined');
14868 }
14869 // eslint-disable-next-line @typescript-eslint/no-explicit-any
14870 var it = target;
14871 var len = path.length;
14872 var end = path.length - 1;
14873 var step;
14874 var cursor = -1;
14875 var rem;
14876 var p;
14877 while (++cursor < len) {
14878 step = path[cursor];
14879 if (typeof step !== 'string' && typeof step !== 'number') {
14880 throw new TypeError('PathSegments must be a string or a number.');
14881 }
14882 if (
14883 // Reconsider this strategy. It disallows legitimate structures on
14884 // non - objects, or more precisely, on objects not derived from a class
14885 // or constructor function.
14886 step === '__proto__' ||
14887 step === 'constructor' ||
14888 step === 'prototype') {
14889 throw new Error('Attempted prototype pollution disallowed.');
14890 }
14891 if (Array.isArray(it)) {
14892 if (step === '-' && cursor === end) {
14893 it.push(val);
14894 return undefined;
14895 }
14896 p = toArrayIndexReference(it, step);
14897 if (it.length > p) {
14898 if (cursor === end) {
14899 rem = it[p];
14900 it[p] = val;
14901 break;
14902 }
14903 it = it[p];
14904 }
14905 else if (cursor === end && p === it.length) {
14906 if (force) {
14907 it.push(val);
14908 return undefined;
14909 }
14910 }
14911 else if (force) {
14912 it = it[p] = cursor === end ? val : {};
14913 }
14914 }
14915 else {
14916 if (typeof it[step] === 'undefined') {
14917 if (force) {
14918 if (cursor === end) {
14919 it[step] = val;
14920 return undefined;
14921 }
14922 // if the next step is an array index, this step should be an array.
14923 var n = Number(path[cursor + 1]);
14924 if (Number.isInteger(n) &&
14925 toArrayIndexReference(it[step], n) !== -1) {
14926 it = it[step] = [];
14927 continue;
14928 }
14929 it = it[step] = {};
14930 continue;
14931 }
14932 return undefined;
14933 }
14934 if (cursor === end) {
14935 rem = it[step];
14936 it[step] = val;
14937 break;
14938 }
14939 it = it[step];
14940 }
14941 }
14942 return rem;
14943}
14944function unsetValueAtPath(target, path) {
14945 if (path.length === 0) {
14946 throw new Error('Cannot unset the root object; assign it directly.');
14947 }
14948 if (typeof target === 'undefined') {
14949 throw new TypeError('Cannot unset values on undefined');
14950 }
14951 // eslint-disable-next-line @typescript-eslint/no-explicit-any
14952 var it = target;
14953 var len = path.length;
14954 var end = path.length - 1;
14955 var step;
14956 var cursor = -1;
14957 var rem;
14958 var p;
14959 while (++cursor < len) {
14960 step = path[cursor];
14961 if (typeof step !== 'string' && typeof step !== 'number') {
14962 throw new TypeError('PathSegments must be a string or a number.');
14963 }
14964 if (step === '__proto__' ||
14965 step === 'constructor' ||
14966 step === 'prototype') {
14967 throw new Error('Attempted prototype pollution disallowed.');
14968 }
14969 if (Array.isArray(it)) {
14970 p = toArrayIndexReference(it, step);
14971 if (p >= it.length)
14972 return undefined;
14973 if (cursor === end) {
14974 rem = it[p];
14975 delete it[p];
14976 break;
14977 }
14978 it = it[p];
14979 }
14980 else {
14981 if (typeof it[step] === 'undefined') {
14982 return undefined;
14983 }
14984 if (cursor === end) {
14985 rem = it[step];
14986 delete it[step];
14987 break;
14988 }
14989 it = it[step];
14990 }
14991 }
14992 return rem;
14993}
14994function looksLikeFragment(ptr) {
14995 return typeof ptr === 'string' && ptr.length > 0 && ptr[0] === '#';
14996}
14997function pickDecoder(ptr) {
14998 return looksLikeFragment(ptr) ? decodeUriFragmentIdentifier : decodePointer;
14999}
15000function decodePtrInit(ptr) {
15001 return Array.isArray(ptr)
15002 ? ptr.slice(0)
15003 : pickDecoder(ptr)(ptr);
15004}
15005
15006
15007/***/ }),
15008
15009/***/ "./node_modules/type-detect/type-detect.js":
15010/*!*************************************************!*\
15011 !*** ./node_modules/type-detect/type-detect.js ***!
15012 \*************************************************/
15013/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15014
15015(function (global, factory) {
15016 true ? module.exports = factory() :
15017 0;
15018}(this, (function () { 'use strict';
15019
15020/* !
15021 * type-detect
15022 * Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
15023 * MIT Licensed
15024 */
15025var promiseExists = typeof Promise === 'function';
15026
15027/* eslint-disable no-undef */
15028var globalObject = typeof self === 'object' ? self : __webpack_require__.g; // eslint-disable-line id-blacklist
15029
15030var symbolExists = typeof Symbol !== 'undefined';
15031var mapExists = typeof Map !== 'undefined';
15032var setExists = typeof Set !== 'undefined';
15033var weakMapExists = typeof WeakMap !== 'undefined';
15034var weakSetExists = typeof WeakSet !== 'undefined';
15035var dataViewExists = typeof DataView !== 'undefined';
15036var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
15037var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
15038var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
15039var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
15040var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
15041var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
15042var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
15043var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
15044var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
15045var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
15046var toStringLeftSliceLength = 8;
15047var toStringRightSliceLength = -1;
15048/**
15049 * ### typeOf (obj)
15050 *
15051 * Uses `Object.prototype.toString` to determine the type of an object,
15052 * normalising behaviour across engine versions & well optimised.
15053 *
15054 * @param {Mixed} object
15055 * @return {String} object type
15056 * @api public
15057 */
15058function typeDetect(obj) {
15059 /* ! Speed optimisation
15060 * Pre:
15061 * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
15062 * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
15063 * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
15064 * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
15065 * function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
15066 * Post:
15067 * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
15068 * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
15069 * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
15070 * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
15071 * function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
15072 */
15073 var typeofObj = typeof obj;
15074 if (typeofObj !== 'object') {
15075 return typeofObj;
15076 }
15077
15078 /* ! Speed optimisation
15079 * Pre:
15080 * null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
15081 * Post:
15082 * null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
15083 */
15084 if (obj === null) {
15085 return 'null';
15086 }
15087
15088 /* ! Spec Conformance
15089 * Test: `Object.prototype.toString.call(window)``
15090 * - Node === "[object global]"
15091 * - Chrome === "[object global]"
15092 * - Firefox === "[object Window]"
15093 * - PhantomJS === "[object Window]"
15094 * - Safari === "[object Window]"
15095 * - IE 11 === "[object Window]"
15096 * - IE Edge === "[object Window]"
15097 * Test: `Object.prototype.toString.call(this)``
15098 * - Chrome Worker === "[object global]"
15099 * - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
15100 * - Safari Worker === "[object DedicatedWorkerGlobalScope]"
15101 * - IE 11 Worker === "[object WorkerGlobalScope]"
15102 * - IE Edge Worker === "[object WorkerGlobalScope]"
15103 */
15104 if (obj === globalObject) {
15105 return 'global';
15106 }
15107
15108 /* ! Speed optimisation
15109 * Pre:
15110 * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
15111 * Post:
15112 * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
15113 */
15114 if (
15115 Array.isArray(obj) &&
15116 (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
15117 ) {
15118 return 'Array';
15119 }
15120
15121 // Not caching existence of `window` and related properties due to potential
15122 // for `window` to be unset before tests in quasi-browser environments.
15123 if (typeof window === 'object' && window !== null) {
15124 /* ! Spec Conformance
15125 * (https://html.spec.whatwg.org/multipage/browsers.html#location)
15126 * WhatWG HTML$7.7.3 - The `Location` interface
15127 * Test: `Object.prototype.toString.call(window.location)``
15128 * - IE <=11 === "[object Object]"
15129 * - IE Edge <=13 === "[object Object]"
15130 */
15131 if (typeof window.location === 'object' && obj === window.location) {
15132 return 'Location';
15133 }
15134
15135 /* ! Spec Conformance
15136 * (https://html.spec.whatwg.org/#document)
15137 * WhatWG HTML$3.1.1 - The `Document` object
15138 * Note: Most browsers currently adher to the W3C DOM Level 2 spec
15139 * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
15140 * which suggests that browsers should use HTMLTableCellElement for
15141 * both TD and TH elements. WhatWG separates these.
15142 * WhatWG HTML states:
15143 * > For historical reasons, Window objects must also have a
15144 * > writable, configurable, non-enumerable property named
15145 * > HTMLDocument whose value is the Document interface object.
15146 * Test: `Object.prototype.toString.call(document)``
15147 * - Chrome === "[object HTMLDocument]"
15148 * - Firefox === "[object HTMLDocument]"
15149 * - Safari === "[object HTMLDocument]"
15150 * - IE <=10 === "[object Document]"
15151 * - IE 11 === "[object HTMLDocument]"
15152 * - IE Edge <=13 === "[object HTMLDocument]"
15153 */
15154 if (typeof window.document === 'object' && obj === window.document) {
15155 return 'Document';
15156 }
15157
15158 if (typeof window.navigator === 'object') {
15159 /* ! Spec Conformance
15160 * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
15161 * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
15162 * Test: `Object.prototype.toString.call(navigator.mimeTypes)``
15163 * - IE <=10 === "[object MSMimeTypesCollection]"
15164 */
15165 if (typeof window.navigator.mimeTypes === 'object' &&
15166 obj === window.navigator.mimeTypes) {
15167 return 'MimeTypeArray';
15168 }
15169
15170 /* ! Spec Conformance
15171 * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
15172 * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
15173 * Test: `Object.prototype.toString.call(navigator.plugins)``
15174 * - IE <=10 === "[object MSPluginsCollection]"
15175 */
15176 if (typeof window.navigator.plugins === 'object' &&
15177 obj === window.navigator.plugins) {
15178 return 'PluginArray';
15179 }
15180 }
15181
15182 if ((typeof window.HTMLElement === 'function' ||
15183 typeof window.HTMLElement === 'object') &&
15184 obj instanceof window.HTMLElement) {
15185 /* ! Spec Conformance
15186 * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
15187 * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
15188 * Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
15189 * - IE <=10 === "[object HTMLBlockElement]"
15190 */
15191 if (obj.tagName === 'BLOCKQUOTE') {
15192 return 'HTMLQuoteElement';
15193 }
15194
15195 /* ! Spec Conformance
15196 * (https://html.spec.whatwg.org/#htmltabledatacellelement)
15197 * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
15198 * Note: Most browsers currently adher to the W3C DOM Level 2 spec
15199 * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
15200 * which suggests that browsers should use HTMLTableCellElement for
15201 * both TD and TH elements. WhatWG separates these.
15202 * Test: Object.prototype.toString.call(document.createElement('td'))
15203 * - Chrome === "[object HTMLTableCellElement]"
15204 * - Firefox === "[object HTMLTableCellElement]"
15205 * - Safari === "[object HTMLTableCellElement]"
15206 */
15207 if (obj.tagName === 'TD') {
15208 return 'HTMLTableDataCellElement';
15209 }
15210
15211 /* ! Spec Conformance
15212 * (https://html.spec.whatwg.org/#htmltableheadercellelement)
15213 * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
15214 * Note: Most browsers currently adher to the W3C DOM Level 2 spec
15215 * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
15216 * which suggests that browsers should use HTMLTableCellElement for
15217 * both TD and TH elements. WhatWG separates these.
15218 * Test: Object.prototype.toString.call(document.createElement('th'))
15219 * - Chrome === "[object HTMLTableCellElement]"
15220 * - Firefox === "[object HTMLTableCellElement]"
15221 * - Safari === "[object HTMLTableCellElement]"
15222 */
15223 if (obj.tagName === 'TH') {
15224 return 'HTMLTableHeaderCellElement';
15225 }
15226 }
15227 }
15228
15229 /* ! Speed optimisation
15230 * Pre:
15231 * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
15232 * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
15233 * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
15234 * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
15235 * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
15236 * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
15237 * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
15238 * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
15239 * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
15240 * Post:
15241 * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
15242 * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
15243 * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
15244 * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
15245 * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
15246 * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
15247 * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
15248 * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
15249 * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
15250 */
15251 var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
15252 if (typeof stringTag === 'string') {
15253 return stringTag;
15254 }
15255
15256 var objPrototype = Object.getPrototypeOf(obj);
15257 /* ! Speed optimisation
15258 * Pre:
15259 * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
15260 * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
15261 * Post:
15262 * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
15263 * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
15264 */
15265 if (objPrototype === RegExp.prototype) {
15266 return 'RegExp';
15267 }
15268
15269 /* ! Speed optimisation
15270 * Pre:
15271 * date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
15272 * Post:
15273 * date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
15274 */
15275 if (objPrototype === Date.prototype) {
15276 return 'Date';
15277 }
15278
15279 /* ! Spec Conformance
15280 * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
15281 * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
15282 * Test: `Object.prototype.toString.call(Promise.resolve())``
15283 * - Chrome <=47 === "[object Object]"
15284 * - Edge <=20 === "[object Object]"
15285 * - Firefox 29-Latest === "[object Promise]"
15286 * - Safari 7.1-Latest === "[object Promise]"
15287 */
15288 if (promiseExists && objPrototype === Promise.prototype) {
15289 return 'Promise';
15290 }
15291
15292 /* ! Speed optimisation
15293 * Pre:
15294 * set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
15295 * Post:
15296 * set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
15297 */
15298 if (setExists && objPrototype === Set.prototype) {
15299 return 'Set';
15300 }
15301
15302 /* ! Speed optimisation
15303 * Pre:
15304 * map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
15305 * Post:
15306 * map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
15307 */
15308 if (mapExists && objPrototype === Map.prototype) {
15309 return 'Map';
15310 }
15311
15312 /* ! Speed optimisation
15313 * Pre:
15314 * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
15315 * Post:
15316 * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
15317 */
15318 if (weakSetExists && objPrototype === WeakSet.prototype) {
15319 return 'WeakSet';
15320 }
15321
15322 /* ! Speed optimisation
15323 * Pre:
15324 * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
15325 * Post:
15326 * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
15327 */
15328 if (weakMapExists && objPrototype === WeakMap.prototype) {
15329 return 'WeakMap';
15330 }
15331
15332 /* ! Spec Conformance
15333 * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
15334 * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
15335 * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
15336 * - Edge <=13 === "[object Object]"
15337 */
15338 if (dataViewExists && objPrototype === DataView.prototype) {
15339 return 'DataView';
15340 }
15341
15342 /* ! Spec Conformance
15343 * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
15344 * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
15345 * Test: `Object.prototype.toString.call(new Map().entries())``
15346 * - Edge <=13 === "[object Object]"
15347 */
15348 if (mapExists && objPrototype === mapIteratorPrototype) {
15349 return 'Map Iterator';
15350 }
15351
15352 /* ! Spec Conformance
15353 * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
15354 * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
15355 * Test: `Object.prototype.toString.call(new Set().entries())``
15356 * - Edge <=13 === "[object Object]"
15357 */
15358 if (setExists && objPrototype === setIteratorPrototype) {
15359 return 'Set Iterator';
15360 }
15361
15362 /* ! Spec Conformance
15363 * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
15364 * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
15365 * Test: `Object.prototype.toString.call([][Symbol.iterator]())``
15366 * - Edge <=13 === "[object Object]"
15367 */
15368 if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
15369 return 'Array Iterator';
15370 }
15371
15372 /* ! Spec Conformance
15373 * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
15374 * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
15375 * Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
15376 * - Edge <=13 === "[object Object]"
15377 */
15378 if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
15379 return 'String Iterator';
15380 }
15381
15382 /* ! Speed optimisation
15383 * Pre:
15384 * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
15385 * Post:
15386 * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
15387 */
15388 if (objPrototype === null) {
15389 return 'Object';
15390 }
15391
15392 return Object
15393 .prototype
15394 .toString
15395 .call(obj)
15396 .slice(toStringLeftSliceLength, toStringRightSliceLength);
15397}
15398
15399return typeDetect;
15400
15401})));
15402
15403
15404/***/ }),
15405
15406/***/ "./node_modules/util/support/isBufferBrowser.js":
15407/*!******************************************************!*\
15408 !*** ./node_modules/util/support/isBufferBrowser.js ***!
15409 \******************************************************/
15410/***/ ((module) => {
15411
15412module.exports = function isBuffer(arg) {
15413 return arg && typeof arg === 'object'
15414 && typeof arg.copy === 'function'
15415 && typeof arg.fill === 'function'
15416 && typeof arg.readUInt8 === 'function';
15417}
15418
15419/***/ }),
15420
15421/***/ "./node_modules/util/support/types.js":
15422/*!********************************************!*\
15423 !*** ./node_modules/util/support/types.js ***!
15424 \********************************************/
15425/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
15426
15427"use strict";
15428// Currently in sync with Node.js lib/internal/util/types.js
15429// https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9
15430
15431
15432
15433var isArgumentsObject = __webpack_require__(/*! is-arguments */ "./node_modules/is-arguments/index.js");
15434var isGeneratorFunction = __webpack_require__(/*! is-generator-function */ "./node_modules/is-generator-function/index.js");
15435var whichTypedArray = __webpack_require__(/*! which-typed-array */ "./node_modules/which-typed-array/index.js");
15436var isTypedArray = __webpack_require__(/*! is-typed-array */ "./node_modules/is-typed-array/index.js");
15437
15438function uncurryThis(f) {
15439 return f.call.bind(f);
15440}
15441
15442var BigIntSupported = typeof BigInt !== 'undefined';
15443var SymbolSupported = typeof Symbol !== 'undefined';
15444
15445var ObjectToString = uncurryThis(Object.prototype.toString);
15446
15447var numberValue = uncurryThis(Number.prototype.valueOf);
15448var stringValue = uncurryThis(String.prototype.valueOf);
15449var booleanValue = uncurryThis(Boolean.prototype.valueOf);
15450
15451if (BigIntSupported) {
15452 var bigIntValue = uncurryThis(BigInt.prototype.valueOf);
15453}
15454
15455if (SymbolSupported) {
15456 var symbolValue = uncurryThis(Symbol.prototype.valueOf);
15457}
15458
15459function checkBoxedPrimitive(value, prototypeValueOf) {
15460 if (typeof value !== 'object') {
15461 return false;
15462 }
15463 try {
15464 prototypeValueOf(value);
15465 return true;
15466 } catch(e) {
15467 return false;
15468 }
15469}
15470
15471exports.isArgumentsObject = isArgumentsObject;
15472exports.isGeneratorFunction = isGeneratorFunction;
15473exports.isTypedArray = isTypedArray;
15474
15475// Taken from here and modified for better browser support
15476// https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js
15477function isPromise(input) {
15478 return (
15479 (
15480 typeof Promise !== 'undefined' &&
15481 input instanceof Promise
15482 ) ||
15483 (
15484 input !== null &&
15485 typeof input === 'object' &&
15486 typeof input.then === 'function' &&
15487 typeof input.catch === 'function'
15488 )
15489 );
15490}
15491exports.isPromise = isPromise;
15492
15493function isArrayBufferView(value) {
15494 if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
15495 return ArrayBuffer.isView(value);
15496 }
15497
15498 return (
15499 isTypedArray(value) ||
15500 isDataView(value)
15501 );
15502}
15503exports.isArrayBufferView = isArrayBufferView;
15504
15505
15506function isUint8Array(value) {
15507 return whichTypedArray(value) === 'Uint8Array';
15508}
15509exports.isUint8Array = isUint8Array;
15510
15511function isUint8ClampedArray(value) {
15512 return whichTypedArray(value) === 'Uint8ClampedArray';
15513}
15514exports.isUint8ClampedArray = isUint8ClampedArray;
15515
15516function isUint16Array(value) {
15517 return whichTypedArray(value) === 'Uint16Array';
15518}
15519exports.isUint16Array = isUint16Array;
15520
15521function isUint32Array(value) {
15522 return whichTypedArray(value) === 'Uint32Array';
15523}
15524exports.isUint32Array = isUint32Array;
15525
15526function isInt8Array(value) {
15527 return whichTypedArray(value) === 'Int8Array';
15528}
15529exports.isInt8Array = isInt8Array;
15530
15531function isInt16Array(value) {
15532 return whichTypedArray(value) === 'Int16Array';
15533}
15534exports.isInt16Array = isInt16Array;
15535
15536function isInt32Array(value) {
15537 return whichTypedArray(value) === 'Int32Array';
15538}
15539exports.isInt32Array = isInt32Array;
15540
15541function isFloat32Array(value) {
15542 return whichTypedArray(value) === 'Float32Array';
15543}
15544exports.isFloat32Array = isFloat32Array;
15545
15546function isFloat64Array(value) {
15547 return whichTypedArray(value) === 'Float64Array';
15548}
15549exports.isFloat64Array = isFloat64Array;
15550
15551function isBigInt64Array(value) {
15552 return whichTypedArray(value) === 'BigInt64Array';
15553}
15554exports.isBigInt64Array = isBigInt64Array;
15555
15556function isBigUint64Array(value) {
15557 return whichTypedArray(value) === 'BigUint64Array';
15558}
15559exports.isBigUint64Array = isBigUint64Array;
15560
15561function isMapToString(value) {
15562 return ObjectToString(value) === '[object Map]';
15563}
15564isMapToString.working = (
15565 typeof Map !== 'undefined' &&
15566 isMapToString(new Map())
15567);
15568
15569function isMap(value) {
15570 if (typeof Map === 'undefined') {
15571 return false;
15572 }
15573
15574 return isMapToString.working
15575 ? isMapToString(value)
15576 : value instanceof Map;
15577}
15578exports.isMap = isMap;
15579
15580function isSetToString(value) {
15581 return ObjectToString(value) === '[object Set]';
15582}
15583isSetToString.working = (
15584 typeof Set !== 'undefined' &&
15585 isSetToString(new Set())
15586);
15587function isSet(value) {
15588 if (typeof Set === 'undefined') {
15589 return false;
15590 }
15591
15592 return isSetToString.working
15593 ? isSetToString(value)
15594 : value instanceof Set;
15595}
15596exports.isSet = isSet;
15597
15598function isWeakMapToString(value) {
15599 return ObjectToString(value) === '[object WeakMap]';
15600}
15601isWeakMapToString.working = (
15602 typeof WeakMap !== 'undefined' &&
15603 isWeakMapToString(new WeakMap())
15604);
15605function isWeakMap(value) {
15606 if (typeof WeakMap === 'undefined') {
15607 return false;
15608 }
15609
15610 return isWeakMapToString.working
15611 ? isWeakMapToString(value)
15612 : value instanceof WeakMap;
15613}
15614exports.isWeakMap = isWeakMap;
15615
15616function isWeakSetToString(value) {
15617 return ObjectToString(value) === '[object WeakSet]';
15618}
15619isWeakSetToString.working = (
15620 typeof WeakSet !== 'undefined' &&
15621 isWeakSetToString(new WeakSet())
15622);
15623function isWeakSet(value) {
15624 return isWeakSetToString(value);
15625}
15626exports.isWeakSet = isWeakSet;
15627
15628function isArrayBufferToString(value) {
15629 return ObjectToString(value) === '[object ArrayBuffer]';
15630}
15631isArrayBufferToString.working = (
15632 typeof ArrayBuffer !== 'undefined' &&
15633 isArrayBufferToString(new ArrayBuffer())
15634);
15635function isArrayBuffer(value) {
15636 if (typeof ArrayBuffer === 'undefined') {
15637 return false;
15638 }
15639
15640 return isArrayBufferToString.working
15641 ? isArrayBufferToString(value)
15642 : value instanceof ArrayBuffer;
15643}
15644exports.isArrayBuffer = isArrayBuffer;
15645
15646function isDataViewToString(value) {
15647 return ObjectToString(value) === '[object DataView]';
15648}
15649isDataViewToString.working = (
15650 typeof ArrayBuffer !== 'undefined' &&
15651 typeof DataView !== 'undefined' &&
15652 isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1))
15653);
15654function isDataView(value) {
15655 if (typeof DataView === 'undefined') {
15656 return false;
15657 }
15658
15659 return isDataViewToString.working
15660 ? isDataViewToString(value)
15661 : value instanceof DataView;
15662}
15663exports.isDataView = isDataView;
15664
15665// Store a copy of SharedArrayBuffer in case it's deleted elsewhere
15666var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined;
15667function isSharedArrayBufferToString(value) {
15668 return ObjectToString(value) === '[object SharedArrayBuffer]';
15669}
15670function isSharedArrayBuffer(value) {
15671 if (typeof SharedArrayBufferCopy === 'undefined') {
15672 return false;
15673 }
15674
15675 if (typeof isSharedArrayBufferToString.working === 'undefined') {
15676 isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy());
15677 }
15678
15679 return isSharedArrayBufferToString.working
15680 ? isSharedArrayBufferToString(value)
15681 : value instanceof SharedArrayBufferCopy;
15682}
15683exports.isSharedArrayBuffer = isSharedArrayBuffer;
15684
15685function isAsyncFunction(value) {
15686 return ObjectToString(value) === '[object AsyncFunction]';
15687}
15688exports.isAsyncFunction = isAsyncFunction;
15689
15690function isMapIterator(value) {
15691 return ObjectToString(value) === '[object Map Iterator]';
15692}
15693exports.isMapIterator = isMapIterator;
15694
15695function isSetIterator(value) {
15696 return ObjectToString(value) === '[object Set Iterator]';
15697}
15698exports.isSetIterator = isSetIterator;
15699
15700function isGeneratorObject(value) {
15701 return ObjectToString(value) === '[object Generator]';
15702}
15703exports.isGeneratorObject = isGeneratorObject;
15704
15705function isWebAssemblyCompiledModule(value) {
15706 return ObjectToString(value) === '[object WebAssembly.Module]';
15707}
15708exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule;
15709
15710function isNumberObject(value) {
15711 return checkBoxedPrimitive(value, numberValue);
15712}
15713exports.isNumberObject = isNumberObject;
15714
15715function isStringObject(value) {
15716 return checkBoxedPrimitive(value, stringValue);
15717}
15718exports.isStringObject = isStringObject;
15719
15720function isBooleanObject(value) {
15721 return checkBoxedPrimitive(value, booleanValue);
15722}
15723exports.isBooleanObject = isBooleanObject;
15724
15725function isBigIntObject(value) {
15726 return BigIntSupported && checkBoxedPrimitive(value, bigIntValue);
15727}
15728exports.isBigIntObject = isBigIntObject;
15729
15730function isSymbolObject(value) {
15731 return SymbolSupported && checkBoxedPrimitive(value, symbolValue);
15732}
15733exports.isSymbolObject = isSymbolObject;
15734
15735function isBoxedPrimitive(value) {
15736 return (
15737 isNumberObject(value) ||
15738 isStringObject(value) ||
15739 isBooleanObject(value) ||
15740 isBigIntObject(value) ||
15741 isSymbolObject(value)
15742 );
15743}
15744exports.isBoxedPrimitive = isBoxedPrimitive;
15745
15746function isAnyArrayBuffer(value) {
15747 return typeof Uint8Array !== 'undefined' && (
15748 isArrayBuffer(value) ||
15749 isSharedArrayBuffer(value)
15750 );
15751}
15752exports.isAnyArrayBuffer = isAnyArrayBuffer;
15753
15754['isProxy', 'isExternal', 'isModuleNamespaceObject'].forEach(function(method) {
15755 Object.defineProperty(exports, method, {
15756 enumerable: false,
15757 value: function() {
15758 throw new Error(method + ' is not supported in userland');
15759 }
15760 });
15761});
15762
15763
15764/***/ }),
15765
15766/***/ "./node_modules/util/util.js":
15767/*!***********************************!*\
15768 !*** ./node_modules/util/util.js ***!
15769 \***********************************/
15770/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
15771
15772// Copyright Joyent, Inc. and other Node contributors.
15773//
15774// Permission is hereby granted, free of charge, to any person obtaining a
15775// copy of this software and associated documentation files (the
15776// "Software"), to deal in the Software without restriction, including
15777// without limitation the rights to use, copy, modify, merge, publish,
15778// distribute, sublicense, and/or sell copies of the Software, and to permit
15779// persons to whom the Software is furnished to do so, subject to the
15780// following conditions:
15781//
15782// The above copyright notice and this permission notice shall be included
15783// in all copies or substantial portions of the Software.
15784//
15785// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15786// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15787// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15788// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15789// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15790// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15791// USE OR OTHER DEALINGS IN THE SOFTWARE.
15792
15793var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
15794 function getOwnPropertyDescriptors(obj) {
15795 var keys = Object.keys(obj);
15796 var descriptors = {};
15797 for (var i = 0; i < keys.length; i++) {
15798 descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
15799 }
15800 return descriptors;
15801 };
15802
15803var formatRegExp = /%[sdj%]/g;
15804exports.format = function(f) {
15805 if (!isString(f)) {
15806 var objects = [];
15807 for (var i = 0; i < arguments.length; i++) {
15808 objects.push(inspect(arguments[i]));
15809 }
15810 return objects.join(' ');
15811 }
15812
15813 var i = 1;
15814 var args = arguments;
15815 var len = args.length;
15816 var str = String(f).replace(formatRegExp, function(x) {
15817 if (x === '%%') return '%';
15818 if (i >= len) return x;
15819 switch (x) {
15820 case '%s': return String(args[i++]);
15821 case '%d': return Number(args[i++]);
15822 case '%j':
15823 try {
15824 return JSON.stringify(args[i++]);
15825 } catch (_) {
15826 return '[Circular]';
15827 }
15828 default:
15829 return x;
15830 }
15831 });
15832 for (var x = args[i]; i < len; x = args[++i]) {
15833 if (isNull(x) || !isObject(x)) {
15834 str += ' ' + x;
15835 } else {
15836 str += ' ' + inspect(x);
15837 }
15838 }
15839 return str;
15840};
15841
15842
15843// Mark that a method should not be used.
15844// Returns a modified function which warns once by default.
15845// If --no-deprecation is set, then it is a no-op.
15846exports.deprecate = function(fn, msg) {
15847 if (typeof process !== 'undefined' && process.noDeprecation === true) {
15848 return fn;
15849 }
15850
15851 // Allow for deprecating things in the process of starting up.
15852 if (typeof process === 'undefined') {
15853 return function() {
15854 return exports.deprecate(fn, msg).apply(this, arguments);
15855 };
15856 }
15857
15858 var warned = false;
15859 function deprecated() {
15860 if (!warned) {
15861 if (process.throwDeprecation) {
15862 throw new Error(msg);
15863 } else if (process.traceDeprecation) {
15864 console.trace(msg);
15865 } else {
15866 console.error(msg);
15867 }
15868 warned = true;
15869 }
15870 return fn.apply(this, arguments);
15871 }
15872
15873 return deprecated;
15874};
15875
15876
15877var debugs = {};
15878var debugEnvRegex = /^$/;
15879
15880if (process.env.NODE_DEBUG) {
15881 var debugEnv = process.env.NODE_DEBUG;
15882 debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
15883 .replace(/\*/g, '.*')
15884 .replace(/,/g, '$|^')
15885 .toUpperCase();
15886 debugEnvRegex = new RegExp('^' + debugEnv + '$', 'i');
15887}
15888exports.debuglog = function(set) {
15889 set = set.toUpperCase();
15890 if (!debugs[set]) {
15891 if (debugEnvRegex.test(set)) {
15892 var pid = process.pid;
15893 debugs[set] = function() {
15894 var msg = exports.format.apply(exports, arguments);
15895 console.error('%s %d: %s', set, pid, msg);
15896 };
15897 } else {
15898 debugs[set] = function() {};
15899 }
15900 }
15901 return debugs[set];
15902};
15903
15904
15905/**
15906 * Echos the value of a value. Trys to print the value out
15907 * in the best way possible given the different types.
15908 *
15909 * @param {Object} obj The object to print out.
15910 * @param {Object} opts Optional options object that alters the output.
15911 */
15912/* legacy: obj, showHidden, depth, colors*/
15913function inspect(obj, opts) {
15914 // default options
15915 var ctx = {
15916 seen: [],
15917 stylize: stylizeNoColor
15918 };
15919 // legacy...
15920 if (arguments.length >= 3) ctx.depth = arguments[2];
15921 if (arguments.length >= 4) ctx.colors = arguments[3];
15922 if (isBoolean(opts)) {
15923 // legacy...
15924 ctx.showHidden = opts;
15925 } else if (opts) {
15926 // got an "options" object
15927 exports._extend(ctx, opts);
15928 }
15929 // set default options
15930 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
15931 if (isUndefined(ctx.depth)) ctx.depth = 2;
15932 if (isUndefined(ctx.colors)) ctx.colors = false;
15933 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
15934 if (ctx.colors) ctx.stylize = stylizeWithColor;
15935 return formatValue(ctx, obj, ctx.depth);
15936}
15937exports.inspect = inspect;
15938
15939
15940// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
15941inspect.colors = {
15942 'bold' : [1, 22],
15943 'italic' : [3, 23],
15944 'underline' : [4, 24],
15945 'inverse' : [7, 27],
15946 'white' : [37, 39],
15947 'grey' : [90, 39],
15948 'black' : [30, 39],
15949 'blue' : [34, 39],
15950 'cyan' : [36, 39],
15951 'green' : [32, 39],
15952 'magenta' : [35, 39],
15953 'red' : [31, 39],
15954 'yellow' : [33, 39]
15955};
15956
15957// Don't use 'blue' not visible on cmd.exe
15958inspect.styles = {
15959 'special': 'cyan',
15960 'number': 'yellow',
15961 'boolean': 'yellow',
15962 'undefined': 'grey',
15963 'null': 'bold',
15964 'string': 'green',
15965 'date': 'magenta',
15966 // "name": intentionally not styling
15967 'regexp': 'red'
15968};
15969
15970
15971function stylizeWithColor(str, styleType) {
15972 var style = inspect.styles[styleType];
15973
15974 if (style) {
15975 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
15976 '\u001b[' + inspect.colors[style][1] + 'm';
15977 } else {
15978 return str;
15979 }
15980}
15981
15982
15983function stylizeNoColor(str, styleType) {
15984 return str;
15985}
15986
15987
15988function arrayToHash(array) {
15989 var hash = {};
15990
15991 array.forEach(function(val, idx) {
15992 hash[val] = true;
15993 });
15994
15995 return hash;
15996}
15997
15998
15999function formatValue(ctx, value, recurseTimes) {
16000 // Provide a hook for user-specified inspect functions.
16001 // Check that value is an object with an inspect function on it
16002 if (ctx.customInspect &&
16003 value &&
16004 isFunction(value.inspect) &&
16005 // Filter out the util module, it's inspect function is special
16006 value.inspect !== exports.inspect &&
16007 // Also filter out any prototype objects using the circular check.
16008 !(value.constructor && value.constructor.prototype === value)) {
16009 var ret = value.inspect(recurseTimes, ctx);
16010 if (!isString(ret)) {
16011 ret = formatValue(ctx, ret, recurseTimes);
16012 }
16013 return ret;
16014 }
16015
16016 // Primitive types cannot have properties
16017 var primitive = formatPrimitive(ctx, value);
16018 if (primitive) {
16019 return primitive;
16020 }
16021
16022 // Look up the keys of the object.
16023 var keys = Object.keys(value);
16024 var visibleKeys = arrayToHash(keys);
16025
16026 if (ctx.showHidden) {
16027 keys = Object.getOwnPropertyNames(value);
16028 }
16029
16030 // IE doesn't make error fields non-enumerable
16031 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
16032 if (isError(value)
16033 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
16034 return formatError(value);
16035 }
16036
16037 // Some type of object without properties can be shortcutted.
16038 if (keys.length === 0) {
16039 if (isFunction(value)) {
16040 var name = value.name ? ': ' + value.name : '';
16041 return ctx.stylize('[Function' + name + ']', 'special');
16042 }
16043 if (isRegExp(value)) {
16044 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
16045 }
16046 if (isDate(value)) {
16047 return ctx.stylize(Date.prototype.toString.call(value), 'date');
16048 }
16049 if (isError(value)) {
16050 return formatError(value);
16051 }
16052 }
16053
16054 var base = '', array = false, braces = ['{', '}'];
16055
16056 // Make Array say that they are Array
16057 if (isArray(value)) {
16058 array = true;
16059 braces = ['[', ']'];
16060 }
16061
16062 // Make functions say that they are functions
16063 if (isFunction(value)) {
16064 var n = value.name ? ': ' + value.name : '';
16065 base = ' [Function' + n + ']';
16066 }
16067
16068 // Make RegExps say that they are RegExps
16069 if (isRegExp(value)) {
16070 base = ' ' + RegExp.prototype.toString.call(value);
16071 }
16072
16073 // Make dates with properties first say the date
16074 if (isDate(value)) {
16075 base = ' ' + Date.prototype.toUTCString.call(value);
16076 }
16077
16078 // Make error with message first say the error
16079 if (isError(value)) {
16080 base = ' ' + formatError(value);
16081 }
16082
16083 if (keys.length === 0 && (!array || value.length == 0)) {
16084 return braces[0] + base + braces[1];
16085 }
16086
16087 if (recurseTimes < 0) {
16088 if (isRegExp(value)) {
16089 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
16090 } else {
16091 return ctx.stylize('[Object]', 'special');
16092 }
16093 }
16094
16095 ctx.seen.push(value);
16096
16097 var output;
16098 if (array) {
16099 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
16100 } else {
16101 output = keys.map(function(key) {
16102 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
16103 });
16104 }
16105
16106 ctx.seen.pop();
16107
16108 return reduceToSingleString(output, base, braces);
16109}
16110
16111
16112function formatPrimitive(ctx, value) {
16113 if (isUndefined(value))
16114 return ctx.stylize('undefined', 'undefined');
16115 if (isString(value)) {
16116 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
16117 .replace(/'/g, "\\'")
16118 .replace(/\\"/g, '"') + '\'';
16119 return ctx.stylize(simple, 'string');
16120 }
16121 if (isNumber(value))
16122 return ctx.stylize('' + value, 'number');
16123 if (isBoolean(value))
16124 return ctx.stylize('' + value, 'boolean');
16125 // For some reason typeof null is "object", so special case here.
16126 if (isNull(value))
16127 return ctx.stylize('null', 'null');
16128}
16129
16130
16131function formatError(value) {
16132 return '[' + Error.prototype.toString.call(value) + ']';
16133}
16134
16135
16136function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
16137 var output = [];
16138 for (var i = 0, l = value.length; i < l; ++i) {
16139 if (hasOwnProperty(value, String(i))) {
16140 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
16141 String(i), true));
16142 } else {
16143 output.push('');
16144 }
16145 }
16146 keys.forEach(function(key) {
16147 if (!key.match(/^\d+$/)) {
16148 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
16149 key, true));
16150 }
16151 });
16152 return output;
16153}
16154
16155
16156function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
16157 var name, str, desc;
16158 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
16159 if (desc.get) {
16160 if (desc.set) {
16161 str = ctx.stylize('[Getter/Setter]', 'special');
16162 } else {
16163 str = ctx.stylize('[Getter]', 'special');
16164 }
16165 } else {
16166 if (desc.set) {
16167 str = ctx.stylize('[Setter]', 'special');
16168 }
16169 }
16170 if (!hasOwnProperty(visibleKeys, key)) {
16171 name = '[' + key + ']';
16172 }
16173 if (!str) {
16174 if (ctx.seen.indexOf(desc.value) < 0) {
16175 if (isNull(recurseTimes)) {
16176 str = formatValue(ctx, desc.value, null);
16177 } else {
16178 str = formatValue(ctx, desc.value, recurseTimes - 1);
16179 }
16180 if (str.indexOf('\n') > -1) {
16181 if (array) {
16182 str = str.split('\n').map(function(line) {
16183 return ' ' + line;
16184 }).join('\n').substr(2);
16185 } else {
16186 str = '\n' + str.split('\n').map(function(line) {
16187 return ' ' + line;
16188 }).join('\n');
16189 }
16190 }
16191 } else {
16192 str = ctx.stylize('[Circular]', 'special');
16193 }
16194 }
16195 if (isUndefined(name)) {
16196 if (array && key.match(/^\d+$/)) {
16197 return str;
16198 }
16199 name = JSON.stringify('' + key);
16200 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
16201 name = name.substr(1, name.length - 2);
16202 name = ctx.stylize(name, 'name');
16203 } else {
16204 name = name.replace(/'/g, "\\'")
16205 .replace(/\\"/g, '"')
16206 .replace(/(^"|"$)/g, "'");
16207 name = ctx.stylize(name, 'string');
16208 }
16209 }
16210
16211 return name + ': ' + str;
16212}
16213
16214
16215function reduceToSingleString(output, base, braces) {
16216 var numLinesEst = 0;
16217 var length = output.reduce(function(prev, cur) {
16218 numLinesEst++;
16219 if (cur.indexOf('\n') >= 0) numLinesEst++;
16220 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
16221 }, 0);
16222
16223 if (length > 60) {
16224 return braces[0] +
16225 (base === '' ? '' : base + '\n ') +
16226 ' ' +
16227 output.join(',\n ') +
16228 ' ' +
16229 braces[1];
16230 }
16231
16232 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
16233}
16234
16235
16236// NOTE: These type checking functions intentionally don't use `instanceof`
16237// because it is fragile and can be easily faked with `Object.create()`.
16238exports.types = __webpack_require__(/*! ./support/types */ "./node_modules/util/support/types.js");
16239
16240function isArray(ar) {
16241 return Array.isArray(ar);
16242}
16243exports.isArray = isArray;
16244
16245function isBoolean(arg) {
16246 return typeof arg === 'boolean';
16247}
16248exports.isBoolean = isBoolean;
16249
16250function isNull(arg) {
16251 return arg === null;
16252}
16253exports.isNull = isNull;
16254
16255function isNullOrUndefined(arg) {
16256 return arg == null;
16257}
16258exports.isNullOrUndefined = isNullOrUndefined;
16259
16260function isNumber(arg) {
16261 return typeof arg === 'number';
16262}
16263exports.isNumber = isNumber;
16264
16265function isString(arg) {
16266 return typeof arg === 'string';
16267}
16268exports.isString = isString;
16269
16270function isSymbol(arg) {
16271 return typeof arg === 'symbol';
16272}
16273exports.isSymbol = isSymbol;
16274
16275function isUndefined(arg) {
16276 return arg === void 0;
16277}
16278exports.isUndefined = isUndefined;
16279
16280function isRegExp(re) {
16281 return isObject(re) && objectToString(re) === '[object RegExp]';
16282}
16283exports.isRegExp = isRegExp;
16284exports.types.isRegExp = isRegExp;
16285
16286function isObject(arg) {
16287 return typeof arg === 'object' && arg !== null;
16288}
16289exports.isObject = isObject;
16290
16291function isDate(d) {
16292 return isObject(d) && objectToString(d) === '[object Date]';
16293}
16294exports.isDate = isDate;
16295exports.types.isDate = isDate;
16296
16297function isError(e) {
16298 return isObject(e) &&
16299 (objectToString(e) === '[object Error]' || e instanceof Error);
16300}
16301exports.isError = isError;
16302exports.types.isNativeError = isError;
16303
16304function isFunction(arg) {
16305 return typeof arg === 'function';
16306}
16307exports.isFunction = isFunction;
16308
16309function isPrimitive(arg) {
16310 return arg === null ||
16311 typeof arg === 'boolean' ||
16312 typeof arg === 'number' ||
16313 typeof arg === 'string' ||
16314 typeof arg === 'symbol' || // ES6 symbol
16315 typeof arg === 'undefined';
16316}
16317exports.isPrimitive = isPrimitive;
16318
16319exports.isBuffer = __webpack_require__(/*! ./support/isBuffer */ "./node_modules/util/support/isBufferBrowser.js");
16320
16321function objectToString(o) {
16322 return Object.prototype.toString.call(o);
16323}
16324
16325
16326function pad(n) {
16327 return n < 10 ? '0' + n.toString(10) : n.toString(10);
16328}
16329
16330
16331var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
16332 'Oct', 'Nov', 'Dec'];
16333
16334// 26 Feb 16:19:34
16335function timestamp() {
16336 var d = new Date();
16337 var time = [pad(d.getHours()),
16338 pad(d.getMinutes()),
16339 pad(d.getSeconds())].join(':');
16340 return [d.getDate(), months[d.getMonth()], time].join(' ');
16341}
16342
16343
16344// log is just a thin wrapper to console.log that prepends a timestamp
16345exports.log = function() {
16346 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
16347};
16348
16349
16350/**
16351 * Inherit the prototype methods from one constructor into another.
16352 *
16353 * The Function.prototype.inherits from lang.js rewritten as a standalone
16354 * function (not on Function.prototype). NOTE: If this file is to be loaded
16355 * during bootstrapping this function needs to be rewritten using some native
16356 * functions as prototype setup using normal JavaScript does not work as
16357 * expected during bootstrapping (see mirror.js in r114903).
16358 *
16359 * @param {function} ctor Constructor function which needs to inherit the
16360 * prototype.
16361 * @param {function} superCtor Constructor function to inherit prototype from.
16362 */
16363exports.inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
16364
16365exports._extend = function(origin, add) {
16366 // Don't do anything if add isn't an object
16367 if (!add || !isObject(add)) return origin;
16368
16369 var keys = Object.keys(add);
16370 var i = keys.length;
16371 while (i--) {
16372 origin[keys[i]] = add[keys[i]];
16373 }
16374 return origin;
16375};
16376
16377function hasOwnProperty(obj, prop) {
16378 return Object.prototype.hasOwnProperty.call(obj, prop);
16379}
16380
16381var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
16382
16383exports.promisify = function promisify(original) {
16384 if (typeof original !== 'function')
16385 throw new TypeError('The "original" argument must be of type Function');
16386
16387 if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
16388 var fn = original[kCustomPromisifiedSymbol];
16389 if (typeof fn !== 'function') {
16390 throw new TypeError('The "util.promisify.custom" argument must be of type Function');
16391 }
16392 Object.defineProperty(fn, kCustomPromisifiedSymbol, {
16393 value: fn, enumerable: false, writable: false, configurable: true
16394 });
16395 return fn;
16396 }
16397
16398 function fn() {
16399 var promiseResolve, promiseReject;
16400 var promise = new Promise(function (resolve, reject) {
16401 promiseResolve = resolve;
16402 promiseReject = reject;
16403 });
16404
16405 var args = [];
16406 for (var i = 0; i < arguments.length; i++) {
16407 args.push(arguments[i]);
16408 }
16409 args.push(function (err, value) {
16410 if (err) {
16411 promiseReject(err);
16412 } else {
16413 promiseResolve(value);
16414 }
16415 });
16416
16417 try {
16418 original.apply(this, args);
16419 } catch (err) {
16420 promiseReject(err);
16421 }
16422
16423 return promise;
16424 }
16425
16426 Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
16427
16428 if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
16429 value: fn, enumerable: false, writable: false, configurable: true
16430 });
16431 return Object.defineProperties(
16432 fn,
16433 getOwnPropertyDescriptors(original)
16434 );
16435}
16436
16437exports.promisify.custom = kCustomPromisifiedSymbol
16438
16439function callbackifyOnRejected(reason, cb) {
16440 // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
16441 // Because `null` is a special error value in callbacks which means "no error
16442 // occurred", we error-wrap so the callback consumer can distinguish between
16443 // "the promise rejected with null" or "the promise fulfilled with undefined".
16444 if (!reason) {
16445 var newReason = new Error('Promise was rejected with a falsy value');
16446 newReason.reason = reason;
16447 reason = newReason;
16448 }
16449 return cb(reason);
16450}
16451
16452function callbackify(original) {
16453 if (typeof original !== 'function') {
16454 throw new TypeError('The "original" argument must be of type Function');
16455 }
16456
16457 // We DO NOT return the promise as it gives the user a false sense that
16458 // the promise is actually somehow related to the callback's execution
16459 // and that the callback throwing will reject the promise.
16460 function callbackified() {
16461 var args = [];
16462 for (var i = 0; i < arguments.length; i++) {
16463 args.push(arguments[i]);
16464 }
16465
16466 var maybeCb = args.pop();
16467 if (typeof maybeCb !== 'function') {
16468 throw new TypeError('The last argument must be of type Function');
16469 }
16470 var self = this;
16471 var cb = function() {
16472 return maybeCb.apply(self, arguments);
16473 };
16474 // In true node style we process the callback on `nextTick` with all the
16475 // implications (stack, `uncaughtException`, `async_hooks`)
16476 original.apply(this, args)
16477 .then(function(ret) { process.nextTick(cb.bind(null, null, ret)) },
16478 function(rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)) });
16479 }
16480
16481 Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
16482 Object.defineProperties(callbackified,
16483 getOwnPropertyDescriptors(original));
16484 return callbackified;
16485}
16486exports.callbackify = callbackify;
16487
16488
16489/***/ }),
16490
16491/***/ "./node_modules/which-typed-array/index.js":
16492/*!*************************************************!*\
16493 !*** ./node_modules/which-typed-array/index.js ***!
16494 \*************************************************/
16495/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16496
16497"use strict";
16498
16499
16500var forEach = __webpack_require__(/*! foreach */ "./node_modules/foreach/index.js");
16501var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
16502var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
16503
16504var $toString = callBound('Object.prototype.toString');
16505var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
16506
16507var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
16508var typedArrays = availableTypedArrays();
16509
16510var $slice = callBound('String.prototype.slice');
16511var toStrTags = {};
16512var gOPD = __webpack_require__(/*! es-abstract/helpers/getOwnPropertyDescriptor */ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js");
16513var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
16514if (hasToStringTag && gOPD && getPrototypeOf) {
16515 forEach(typedArrays, function (typedArray) {
16516 if (typeof g[typedArray] === 'function') {
16517 var arr = new g[typedArray]();
16518 if (Symbol.toStringTag in arr) {
16519 var proto = getPrototypeOf(arr);
16520 var descriptor = gOPD(proto, Symbol.toStringTag);
16521 if (!descriptor) {
16522 var superProto = getPrototypeOf(proto);
16523 descriptor = gOPD(superProto, Symbol.toStringTag);
16524 }
16525 toStrTags[typedArray] = descriptor.get;
16526 }
16527 }
16528 });
16529}
16530
16531var tryTypedArrays = function tryAllTypedArrays(value) {
16532 var foundName = false;
16533 forEach(toStrTags, function (getter, typedArray) {
16534 if (!foundName) {
16535 try {
16536 var name = getter.call(value);
16537 if (name === typedArray) {
16538 foundName = name;
16539 }
16540 } catch (e) {}
16541 }
16542 });
16543 return foundName;
16544};
16545
16546var isTypedArray = __webpack_require__(/*! is-typed-array */ "./node_modules/is-typed-array/index.js");
16547
16548module.exports = function whichTypedArray(value) {
16549 if (!isTypedArray(value)) { return false; }
16550 if (!hasToStringTag || !(Symbol.toStringTag in value)) { return $slice($toString(value), 8, -1); }
16551 return tryTypedArrays(value);
16552};
16553
16554
16555/***/ }),
16556
16557/***/ "./node_modules/available-typed-arrays/index.js":
16558/*!******************************************************!*\
16559 !*** ./node_modules/available-typed-arrays/index.js ***!
16560 \******************************************************/
16561/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16562
16563"use strict";
16564
16565
16566var possibleNames = [
16567 'BigInt64Array',
16568 'BigUint64Array',
16569 'Float32Array',
16570 'Float64Array',
16571 'Int16Array',
16572 'Int32Array',
16573 'Int8Array',
16574 'Uint16Array',
16575 'Uint32Array',
16576 'Uint8Array',
16577 'Uint8ClampedArray'
16578];
16579
16580var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
16581
16582module.exports = function availableTypedArrays() {
16583 var out = [];
16584 for (var i = 0; i < possibleNames.length; i++) {
16585 if (typeof g[possibleNames[i]] === 'function') {
16586 out[out.length] = possibleNames[i];
16587 }
16588 }
16589 return out;
16590};
16591
16592
16593/***/ }),
16594
16595/***/ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js":
16596/*!**********************************************************************!*\
16597 !*** ./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js ***!
16598 \**********************************************************************/
16599/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16600
16601"use strict";
16602
16603
16604var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "./node_modules/get-intrinsic/index.js");
16605
16606var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
16607if ($gOPD) {
16608 try {
16609 $gOPD([], 'length');
16610 } catch (e) {
16611 // IE 8 has a broken gOPD
16612 $gOPD = null;
16613 }
16614}
16615
16616module.exports = $gOPD;
16617
16618
16619/***/ }),
16620
16621/***/ "./node_modules/chai/index.mjs":
16622/*!*************************************!*\
16623 !*** ./node_modules/chai/index.mjs ***!
16624 \*************************************/
16625/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
16626
16627"use strict";
16628__webpack_require__.r(__webpack_exports__);
16629/* harmony export */ __webpack_require__.d(__webpack_exports__, {
16630/* harmony export */ "expect": () => (/* binding */ expect),
16631/* harmony export */ "version": () => (/* binding */ version),
16632/* harmony export */ "Assertion": () => (/* binding */ Assertion),
16633/* harmony export */ "AssertionError": () => (/* binding */ AssertionError),
16634/* harmony export */ "util": () => (/* binding */ util),
16635/* harmony export */ "config": () => (/* binding */ config),
16636/* harmony export */ "use": () => (/* binding */ use),
16637/* harmony export */ "should": () => (/* binding */ should),
16638/* harmony export */ "assert": () => (/* binding */ assert),
16639/* harmony export */ "core": () => (/* binding */ core),
16640/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
16641/* harmony export */ });
16642/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index.js */ "./node_modules/chai/index.js");
16643
16644
16645const expect = _index_js__WEBPACK_IMPORTED_MODULE_0__.expect;
16646const version = _index_js__WEBPACK_IMPORTED_MODULE_0__.version;
16647const Assertion = _index_js__WEBPACK_IMPORTED_MODULE_0__.Assertion;
16648const AssertionError = _index_js__WEBPACK_IMPORTED_MODULE_0__.AssertionError;
16649const util = _index_js__WEBPACK_IMPORTED_MODULE_0__.util;
16650const config = _index_js__WEBPACK_IMPORTED_MODULE_0__.config;
16651const use = _index_js__WEBPACK_IMPORTED_MODULE_0__.use;
16652const should = _index_js__WEBPACK_IMPORTED_MODULE_0__.should;
16653const assert = _index_js__WEBPACK_IMPORTED_MODULE_0__.assert;
16654const core = _index_js__WEBPACK_IMPORTED_MODULE_0__.core;
16655
16656/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_index_js__WEBPACK_IMPORTED_MODULE_0__);
16657
16658
16659/***/ })
16660
16661/******/ });
16662/************************************************************************/
16663/******/ // The module cache
16664/******/ var __webpack_module_cache__ = {};
16665/******/
16666/******/ // The require function
16667/******/ function __webpack_require__(moduleId) {
16668/******/ // Check if module is in cache
16669/******/ var cachedModule = __webpack_module_cache__[moduleId];
16670/******/ if (cachedModule !== undefined) {
16671/******/ return cachedModule.exports;
16672/******/ }
16673/******/ // Create a new module (and put it into the cache)
16674/******/ var module = __webpack_module_cache__[moduleId] = {
16675/******/ // no module.id needed
16676/******/ // no module.loaded needed
16677/******/ exports: {}
16678/******/ };
16679/******/
16680/******/ // Execute the module function
16681/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
16682/******/
16683/******/ // Return the exports of the module
16684/******/ return module.exports;
16685/******/ }
16686/******/
16687/************************************************************************/
16688/******/ /* webpack/runtime/compat get default export */
16689/******/ (() => {
16690/******/ // getDefaultExport function for compatibility with non-harmony modules
16691/******/ __webpack_require__.n = (module) => {
16692/******/ var getter = module && module.__esModule ?
16693/******/ () => (module['default']) :
16694/******/ () => (module);
16695/******/ __webpack_require__.d(getter, { a: getter });
16696/******/ return getter;
16697/******/ };
16698/******/ })();
16699/******/
16700/******/ /* webpack/runtime/define property getters */
16701/******/ (() => {
16702/******/ // define getter functions for harmony exports
16703/******/ __webpack_require__.d = (exports, definition) => {
16704/******/ for(var key in definition) {
16705/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
16706/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
16707/******/ }
16708/******/ }
16709/******/ };
16710/******/ })();
16711/******/
16712/******/ /* webpack/runtime/global */
16713/******/ (() => {
16714/******/ __webpack_require__.g = (function() {
16715/******/ if (typeof globalThis === 'object') return globalThis;
16716/******/ try {
16717/******/ return this || new Function('return this')();
16718/******/ } catch (e) {
16719/******/ if (typeof window === 'object') return window;
16720/******/ }
16721/******/ })();
16722/******/ })();
16723/******/
16724/******/ /* webpack/runtime/hasOwnProperty shorthand */
16725/******/ (() => {
16726/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
16727/******/ })();
16728/******/
16729/******/ /* webpack/runtime/make namespace object */
16730/******/ (() => {
16731/******/ // define __esModule on exports
16732/******/ __webpack_require__.r = (exports) => {
16733/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
16734/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16735/******/ }
16736/******/ Object.defineProperty(exports, '__esModule', { value: true });
16737/******/ };
16738/******/ })();
16739/******/
16740/************************************************************************/
16741var __webpack_exports__ = {};
16742// This entry need to be wrapped in an IIFE because it need to be in strict mode.
16743(() => {
16744"use strict";
16745/*!********************************!*\
16746 !*** ./src/__tests__/index.ts ***!
16747 \********************************/
16748__webpack_require__.r(__webpack_exports__);
16749/* harmony import */ var _pointer_spec__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointer.spec */ "./src/__tests__/pointer.spec.ts");
16750/* harmony import */ var _ptr_spec__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ptr.spec */ "./src/__tests__/ptr.spec.ts");
16751/* harmony import */ var _reference_spec__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./reference.spec */ "./src/__tests__/reference.spec.ts");
16752/* harmony import */ var _utils_spec__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.spec */ "./src/__tests__/utils.spec.ts");
16753
16754
16755
16756
16757
16758})();
16759
16760/******/ })()
16761;
16762//# sourceMappingURL=json-ptr.tests.js.map
\No newline at end of file