chai 5.2.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -328,7 +328,7 @@ const functionTypes = {
328
328
  function an(type, msg) {
329
329
  if (msg) flag(this, 'message', msg);
330
330
  type = type.toLowerCase();
331
- var obj = flag(this, 'object'),
331
+ let obj = flag(this, 'object'),
332
332
  article = ~['a', 'e', 'i', 'o', 'u'].indexOf(type.charAt(0)) ? 'an ' : 'a ';
333
333
 
334
334
  const detectedType = _.type(obj).toLowerCase();
@@ -352,7 +352,6 @@ Assertion.addChainableMethod('an', an);
352
352
  Assertion.addChainableMethod('a', an);
353
353
 
354
354
  /**
355
- *
356
355
  * @param {unknown} a
357
356
  * @param {unknown} b
358
357
  * @returns {boolean}
@@ -361,9 +360,7 @@ function SameValueZero(a, b) {
361
360
  return (_.isNaN(a) && _.isNaN(b)) || a === b;
362
361
  }
363
362
 
364
- /**
365
- *
366
- */
363
+ /** */
367
364
  function includeChainingBehavior() {
368
365
  flag(this, 'contains', true);
369
366
  }
@@ -517,7 +514,7 @@ function includeChainingBehavior() {
517
514
  function include(val, msg) {
518
515
  if (msg) flag(this, 'message', msg);
519
516
 
520
- var obj = flag(this, 'object'),
517
+ let obj = flag(this, 'object'),
521
518
  objType = _.type(obj).toLowerCase(),
522
519
  flagMsg = flag(this, 'message'),
523
520
  negate = flag(this, 'negate'),
@@ -528,7 +525,7 @@ function include(val, msg) {
528
525
 
529
526
  flagMsg = flagMsg ? flagMsg + ': ' : '';
530
527
 
531
- var included = false;
528
+ let included = false;
532
529
 
533
530
  switch (objType) {
534
531
  case 'string':
@@ -573,7 +570,7 @@ function include(val, msg) {
573
570
  }
574
571
  break;
575
572
 
576
- default:
573
+ default: {
577
574
  // This block is for asserting a subset of properties in an object.
578
575
  // `_.expectTypes` isn't used here because `.include` should work with
579
576
  // objects with a custom `@@toStringTag`.
@@ -594,12 +591,12 @@ function include(val, msg) {
594
591
  );
595
592
  }
596
593
 
597
- var props = Object.keys(val),
598
- firstErr = null,
599
- numErrs = 0;
594
+ let props = Object.keys(val);
595
+ let firstErr = null;
596
+ let numErrs = 0;
600
597
 
601
598
  props.forEach(function (prop) {
602
- var propAssertion = new Assertion(obj);
599
+ let propAssertion = new Assertion(obj);
603
600
  _.transferFlags(this, propAssertion, true);
604
601
  flag(propAssertion, 'lockSsfi', true);
605
602
 
@@ -627,6 +624,7 @@ function include(val, msg) {
627
624
  throw firstErr;
628
625
  }
629
626
  return;
627
+ }
630
628
  }
631
629
 
632
630
  // Assert inclusion in collection or substring in a string.
@@ -925,7 +923,7 @@ Assertion.addProperty('NaN', function () {
925
923
  * @public
926
924
  */
927
925
  function assertExist() {
928
- var val = flag(this, 'object');
926
+ let val = flag(this, 'object');
929
927
  this.assert(
930
928
  val !== null && val !== undefined,
931
929
  'expected #{this} to exist',
@@ -985,7 +983,7 @@ Assertion.addProperty('exists', assertExist);
985
983
  * @public
986
984
  */
987
985
  Assertion.addProperty('empty', function () {
988
- var val = flag(this, 'object'),
986
+ let val = flag(this, 'object'),
989
987
  ssfi = flag(this, 'ssfi'),
990
988
  flagMsg = flag(this, 'message'),
991
989
  itemsCount;
@@ -1008,9 +1006,10 @@ Assertion.addProperty('empty', function () {
1008
1006
  undefined,
1009
1007
  ssfi
1010
1008
  );
1011
- case 'function':
1012
- var msg = flagMsg + '.empty was passed a function ' + _.getName(val);
1009
+ case 'function': {
1010
+ const msg = flagMsg + '.empty was passed a function ' + _.getName(val);
1013
1011
  throw new AssertionError(msg.trim(), undefined, ssfi);
1012
+ }
1014
1013
  default:
1015
1014
  if (val !== Object(val)) {
1016
1015
  throw new AssertionError(
@@ -1059,7 +1058,7 @@ Assertion.addProperty('empty', function () {
1059
1058
  * @public
1060
1059
  */
1061
1060
  function checkArguments() {
1062
- var obj = flag(this, 'object'),
1061
+ let obj = flag(this, 'object'),
1063
1062
  type = _.type(obj);
1064
1063
  this.assert(
1065
1064
  'Arguments' === type,
@@ -1117,9 +1116,9 @@ Assertion.addProperty('Arguments', checkArguments);
1117
1116
  */
1118
1117
  function assertEqual(val, msg) {
1119
1118
  if (msg) flag(this, 'message', msg);
1120
- var obj = flag(this, 'object');
1119
+ let obj = flag(this, 'object');
1121
1120
  if (flag(this, 'deep')) {
1122
- var prevLockSsfi = flag(this, 'lockSsfi');
1121
+ let prevLockSsfi = flag(this, 'lockSsfi');
1123
1122
  flag(this, 'lockSsfi', true);
1124
1123
  this.eql(val);
1125
1124
  flag(this, 'lockSsfi', prevLockSsfi);
@@ -1181,7 +1180,7 @@ Assertion.addMethod('eq', assertEqual);
1181
1180
  */
1182
1181
  function assertEql(obj, msg) {
1183
1182
  if (msg) flag(this, 'message', msg);
1184
- var eql = flag(this, 'eql');
1183
+ let eql = flag(this, 'eql');
1185
1184
  this.assert(
1186
1185
  eql(obj, flag(this, 'object')),
1187
1186
  'expected #{this} to deeply equal #{exp}',
@@ -1239,7 +1238,7 @@ Assertion.addMethod('eqls', assertEql);
1239
1238
  */
1240
1239
  function assertAbove(n, msg) {
1241
1240
  if (msg) flag(this, 'message', msg);
1242
- var obj = flag(this, 'object'),
1241
+ let obj = flag(this, 'object'),
1243
1242
  doLength = flag(this, 'doLength'),
1244
1243
  flagMsg = flag(this, 'message'),
1245
1244
  msgPrefix = flagMsg ? flagMsg + ': ' : '',
@@ -1264,7 +1263,7 @@ function assertAbove(n, msg) {
1264
1263
  ssfi
1265
1264
  );
1266
1265
  } else if (!doLength && objType !== 'date' && !_.isNumeric(obj)) {
1267
- var printObj = objType === 'string' ? "'" + obj + "'" : obj;
1266
+ let printObj = objType === 'string' ? "'" + obj + "'" : obj;
1268
1267
  throw new AssertionError(
1269
1268
  msgPrefix + 'expected ' + printObj + ' to be a number or a date',
1270
1269
  undefined,
@@ -1273,7 +1272,7 @@ function assertAbove(n, msg) {
1273
1272
  }
1274
1273
 
1275
1274
  if (doLength) {
1276
- var descriptor = 'length',
1275
+ let descriptor = 'length',
1277
1276
  itemsCount;
1278
1277
  if (objType === 'map' || objType === 'set') {
1279
1278
  descriptor = 'size';
@@ -1349,7 +1348,7 @@ Assertion.addMethod('greaterThan', assertAbove);
1349
1348
  */
1350
1349
  function assertLeast(n, msg) {
1351
1350
  if (msg) flag(this, 'message', msg);
1352
- var obj = flag(this, 'object'),
1351
+ let obj = flag(this, 'object'),
1353
1352
  doLength = flag(this, 'doLength'),
1354
1353
  flagMsg = flag(this, 'message'),
1355
1354
  msgPrefix = flagMsg ? flagMsg + ': ' : '',
@@ -1368,7 +1367,7 @@ function assertLeast(n, msg) {
1368
1367
  } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1369
1368
  errorMessage = msgPrefix + 'the argument to least must be a number';
1370
1369
  } else if (!doLength && objType !== 'date' && !_.isNumeric(obj)) {
1371
- var printObj = objType === 'string' ? "'" + obj + "'" : obj;
1370
+ let printObj = objType === 'string' ? "'" + obj + "'" : obj;
1372
1371
  errorMessage =
1373
1372
  msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1374
1373
  } else {
@@ -1380,7 +1379,7 @@ function assertLeast(n, msg) {
1380
1379
  }
1381
1380
 
1382
1381
  if (doLength) {
1383
- var descriptor = 'length',
1382
+ let descriptor = 'length',
1384
1383
  itemsCount;
1385
1384
  if (objType === 'map' || objType === 'set') {
1386
1385
  descriptor = 'size';
@@ -1455,7 +1454,7 @@ Assertion.addMethod('greaterThanOrEqual', assertLeast);
1455
1454
  */
1456
1455
  function assertBelow(n, msg) {
1457
1456
  if (msg) flag(this, 'message', msg);
1458
- var obj = flag(this, 'object'),
1457
+ let obj = flag(this, 'object'),
1459
1458
  doLength = flag(this, 'doLength'),
1460
1459
  flagMsg = flag(this, 'message'),
1461
1460
  msgPrefix = flagMsg ? flagMsg + ': ' : '',
@@ -1474,7 +1473,7 @@ function assertBelow(n, msg) {
1474
1473
  } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1475
1474
  errorMessage = msgPrefix + 'the argument to below must be a number';
1476
1475
  } else if (!doLength && objType !== 'date' && !_.isNumeric(obj)) {
1477
- var printObj = objType === 'string' ? "'" + obj + "'" : obj;
1476
+ let printObj = objType === 'string' ? "'" + obj + "'" : obj;
1478
1477
  errorMessage =
1479
1478
  msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1480
1479
  } else {
@@ -1486,7 +1485,7 @@ function assertBelow(n, msg) {
1486
1485
  }
1487
1486
 
1488
1487
  if (doLength) {
1489
- var descriptor = 'length',
1488
+ let descriptor = 'length',
1490
1489
  itemsCount;
1491
1490
  if (objType === 'map' || objType === 'set') {
1492
1491
  descriptor = 'size';
@@ -1562,7 +1561,7 @@ Assertion.addMethod('lessThan', assertBelow);
1562
1561
  */
1563
1562
  function assertMost(n, msg) {
1564
1563
  if (msg) flag(this, 'message', msg);
1565
- var obj = flag(this, 'object'),
1564
+ let obj = flag(this, 'object'),
1566
1565
  doLength = flag(this, 'doLength'),
1567
1566
  flagMsg = flag(this, 'message'),
1568
1567
  msgPrefix = flagMsg ? flagMsg + ': ' : '',
@@ -1581,7 +1580,7 @@ function assertMost(n, msg) {
1581
1580
  } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1582
1581
  errorMessage = msgPrefix + 'the argument to most must be a number';
1583
1582
  } else if (!doLength && objType !== 'date' && !_.isNumeric(obj)) {
1584
- var printObj = objType === 'string' ? "'" + obj + "'" : obj;
1583
+ let printObj = objType === 'string' ? "'" + obj + "'" : obj;
1585
1584
  errorMessage =
1586
1585
  msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1587
1586
  } else {
@@ -1593,7 +1592,7 @@ function assertMost(n, msg) {
1593
1592
  }
1594
1593
 
1595
1594
  if (doLength) {
1596
- var descriptor = 'length',
1595
+ let descriptor = 'length',
1597
1596
  itemsCount;
1598
1597
  if (objType === 'map' || objType === 'set') {
1599
1598
  descriptor = 'size';
@@ -1668,7 +1667,7 @@ Assertion.addMethod('lessThanOrEqual', assertMost);
1668
1667
  */
1669
1668
  Assertion.addMethod('within', function (start, finish, msg) {
1670
1669
  if (msg) flag(this, 'message', msg);
1671
- var obj = flag(this, 'object'),
1670
+ let obj = flag(this, 'object'),
1672
1671
  doLength = flag(this, 'doLength'),
1673
1672
  flagMsg = flag(this, 'message'),
1674
1673
  msgPrefix = flagMsg ? flagMsg + ': ' : '',
@@ -1699,7 +1698,7 @@ Assertion.addMethod('within', function (start, finish, msg) {
1699
1698
  ) {
1700
1699
  errorMessage = msgPrefix + 'the arguments to within must be numbers';
1701
1700
  } else if (!doLength && objType !== 'date' && !_.isNumeric(obj)) {
1702
- var printObj = objType === 'string' ? "'" + obj + "'" : obj;
1701
+ let printObj = objType === 'string' ? "'" + obj + "'" : obj;
1703
1702
  errorMessage =
1704
1703
  msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1705
1704
  } else {
@@ -1711,7 +1710,7 @@ Assertion.addMethod('within', function (start, finish, msg) {
1711
1710
  }
1712
1711
 
1713
1712
  if (doLength) {
1714
- var descriptor = 'length',
1713
+ let descriptor = 'length',
1715
1714
  itemsCount;
1716
1715
  if (objType === 'map' || objType === 'set') {
1717
1716
  descriptor = 'size';
@@ -1774,12 +1773,13 @@ Assertion.addMethod('within', function (start, finish, msg) {
1774
1773
  function assertInstanceOf(constructor, msg) {
1775
1774
  if (msg) flag(this, 'message', msg);
1776
1775
 
1777
- var target = flag(this, 'object');
1778
- var ssfi = flag(this, 'ssfi');
1779
- var flagMsg = flag(this, 'message');
1776
+ let target = flag(this, 'object');
1777
+ let ssfi = flag(this, 'ssfi');
1778
+ let flagMsg = flag(this, 'message');
1779
+ let isInstanceOf;
1780
1780
 
1781
1781
  try {
1782
- var isInstanceOf = target instanceof constructor;
1782
+ isInstanceOf = target instanceof constructor;
1783
1783
  } catch (err) {
1784
1784
  if (err instanceof TypeError) {
1785
1785
  flagMsg = flagMsg ? flagMsg + ': ' : '';
@@ -1795,7 +1795,7 @@ function assertInstanceOf(constructor, msg) {
1795
1795
  throw err;
1796
1796
  }
1797
1797
 
1798
- var name = _.getName(constructor);
1798
+ let name = _.getName(constructor);
1799
1799
  if (name == null) {
1800
1800
  name = 'an unnamed constructor';
1801
1801
  }
@@ -1923,7 +1923,7 @@ Assertion.addMethod('instanceOf', assertInstanceOf);
1923
1923
  function assertProperty(name, val, msg) {
1924
1924
  if (msg) flag(this, 'message', msg);
1925
1925
 
1926
- var isNested = flag(this, 'nested'),
1926
+ let isNested = flag(this, 'nested'),
1927
1927
  isOwn = flag(this, 'own'),
1928
1928
  flagMsg = flag(this, 'message'),
1929
1929
  obj = flag(this, 'object'),
@@ -1972,19 +1972,19 @@ function assertProperty(name, val, msg) {
1972
1972
  );
1973
1973
  }
1974
1974
 
1975
- var isDeep = flag(this, 'deep'),
1975
+ let isDeep = flag(this, 'deep'),
1976
1976
  negate = flag(this, 'negate'),
1977
1977
  pathInfo = isNested ? _.getPathInfo(obj, name) : null,
1978
1978
  value = isNested ? pathInfo.value : obj[name],
1979
1979
  isEql = isDeep ? flag(this, 'eql') : (val1, val2) => val1 === val2;
1980
1980
 
1981
- var descriptor = '';
1981
+ let descriptor = '';
1982
1982
  if (isDeep) descriptor += 'deep ';
1983
1983
  if (isOwn) descriptor += 'own ';
1984
1984
  if (isNested) descriptor += 'nested ';
1985
1985
  descriptor += 'property ';
1986
1986
 
1987
- var hasProperty;
1987
+ let hasProperty;
1988
1988
  if (isOwn) hasProperty = Object.prototype.hasOwnProperty.call(obj, name);
1989
1989
  else if (isNested) hasProperty = pathInfo.exists;
1990
1990
  else hasProperty = _.hasProperty(obj, name);
@@ -2024,7 +2024,6 @@ function assertProperty(name, val, msg) {
2024
2024
  Assertion.addMethod('property', assertProperty);
2025
2025
 
2026
2026
  /**
2027
- *
2028
2027
  * @param {unknown} _name
2029
2028
  * @param {unknown} _value
2030
2029
  * @param {string} _msg
@@ -2161,9 +2160,9 @@ function assertOwnPropertyDescriptor(name, descriptor, msg) {
2161
2160
  descriptor = null;
2162
2161
  }
2163
2162
  if (msg) flag(this, 'message', msg);
2164
- var obj = flag(this, 'object');
2165
- var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
2166
- var eql = flag(this, 'eql');
2163
+ let obj = flag(this, 'object');
2164
+ let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
2165
+ let eql = flag(this, 'eql');
2167
2166
  if (actualDescriptor && descriptor) {
2168
2167
  this.assert(
2169
2168
  eql(descriptor, actualDescriptor),
@@ -2196,9 +2195,7 @@ function assertOwnPropertyDescriptor(name, descriptor, msg) {
2196
2195
  Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
2197
2196
  Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);
2198
2197
 
2199
- /**
2200
- *
2201
- */
2198
+ /** */
2202
2199
  function assertLengthChain() {
2203
2200
  flag(this, 'doLength', true);
2204
2201
  }
@@ -2262,7 +2259,7 @@ function assertLengthChain() {
2262
2259
  */
2263
2260
  function assertLength(n, msg) {
2264
2261
  if (msg) flag(this, 'message', msg);
2265
- var obj = flag(this, 'object'),
2262
+ let obj = flag(this, 'object'),
2266
2263
  objType = _.type(obj).toLowerCase(),
2267
2264
  flagMsg = flag(this, 'message'),
2268
2265
  ssfi = flag(this, 'ssfi'),
@@ -2321,7 +2318,7 @@ Assertion.addChainableMethod('lengthOf', assertLength, assertLengthChain);
2321
2318
  */
2322
2319
  function assertMatch(re, msg) {
2323
2320
  if (msg) flag(this, 'message', msg);
2324
- var obj = flag(this, 'object');
2321
+ let obj = flag(this, 'object');
2325
2322
  this.assert(
2326
2323
  re.exec(obj),
2327
2324
  'expected #{this} to match ' + re,
@@ -2358,7 +2355,7 @@ Assertion.addMethod('matches', assertMatch);
2358
2355
  */
2359
2356
  Assertion.addMethod('string', function (str, msg) {
2360
2357
  if (msg) flag(this, 'message', msg);
2361
- var obj = flag(this, 'object'),
2358
+ let obj = flag(this, 'object'),
2362
2359
  flagMsg = flag(this, 'message'),
2363
2360
  ssfi = flag(this, 'ssfi');
2364
2361
  new Assertion(obj, flagMsg, ssfi, true).is.a('string');
@@ -2474,7 +2471,7 @@ Assertion.addMethod('string', function (str, msg) {
2474
2471
  * @public
2475
2472
  */
2476
2473
  function assertKeys(keys) {
2477
- var obj = flag(this, 'object'),
2474
+ let obj = flag(this, 'object'),
2478
2475
  objType = _.type(obj),
2479
2476
  keysType = _.type(keys),
2480
2477
  ssfi = flag(this, 'ssfi'),
@@ -2486,7 +2483,7 @@ function assertKeys(keys) {
2486
2483
  flagMsg = flag(this, 'message');
2487
2484
 
2488
2485
  flagMsg = flagMsg ? flagMsg + ': ' : '';
2489
- var mixedArgsMsg =
2486
+ let mixedArgsMsg =
2490
2487
  flagMsg +
2491
2488
  'when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments';
2492
2489
 
@@ -2531,7 +2528,7 @@ function assertKeys(keys) {
2531
2528
  throw new AssertionError(flagMsg + 'keys required', undefined, ssfi);
2532
2529
  }
2533
2530
 
2534
- var len = keys.length,
2531
+ let len = keys.length,
2535
2532
  any = flag(this, 'any'),
2536
2533
  all = flag(this, 'all'),
2537
2534
  expected = keys,
@@ -2568,7 +2565,7 @@ function assertKeys(keys) {
2568
2565
  keys = keys.map(function (key) {
2569
2566
  return _.inspect(key);
2570
2567
  });
2571
- var last = keys.pop();
2568
+ let last = keys.pop();
2572
2569
  if (all) {
2573
2570
  str = keys.join(', ') + ', and ' + last;
2574
2571
  }
@@ -2760,7 +2757,7 @@ Assertion.addMethod('key', assertKeys);
2760
2757
  */
2761
2758
  function assertThrows(errorLike, errMsgMatcher, msg) {
2762
2759
  if (msg) flag(this, 'message', msg);
2763
- var obj = flag(this, 'object'),
2760
+ let obj = flag(this, 'object'),
2764
2761
  ssfi = flag(this, 'ssfi'),
2765
2762
  flagMsg = flag(this, 'message'),
2766
2763
  negate = flag(this, 'negate') || false;
@@ -2782,19 +2779,19 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2782
2779
 
2783
2780
  // If we have the negate flag enabled and at least one valid argument it means we do expect an error
2784
2781
  // but we want it to match a given set of criteria
2785
- var everyArgIsUndefined =
2782
+ let everyArgIsUndefined =
2786
2783
  errorLike === undefined && errMsgMatcher === undefined;
2787
2784
 
2788
2785
  // If we've got the negate flag enabled and both args, we should only fail if both aren't compatible
2789
2786
  // See Issue #551 and PR #683@GitHub
2790
- var everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
2791
- var errorLikeFail = false;
2792
- var errMsgMatcherFail = false;
2787
+ let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
2788
+ let errorLikeFail = false;
2789
+ let errMsgMatcherFail = false;
2793
2790
 
2794
2791
  // Checking if error was thrown
2795
2792
  if (everyArgIsUndefined || (!everyArgIsUndefined && !negate)) {
2796
2793
  // We need this to display results correctly according to their types
2797
- var errorLikeString = 'an error';
2794
+ let errorLikeString = 'an error';
2798
2795
  if (errorLike instanceof Error) {
2799
2796
  errorLikeString = '#{exp}';
2800
2797
  } else if (errorLike) {
@@ -2830,7 +2827,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2830
2827
  if (errorLike && caughtErr) {
2831
2828
  // We should compare instances only if `errorLike` is an instance of `Error`
2832
2829
  if (errorLike instanceof Error) {
2833
- var isCompatibleInstance = _.checkError.compatibleInstance(
2830
+ let isCompatibleInstance = _.checkError.compatibleInstance(
2834
2831
  caughtErr,
2835
2832
  errorLike
2836
2833
  );
@@ -2853,7 +2850,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2853
2850
  }
2854
2851
  }
2855
2852
 
2856
- var isCompatibleConstructor = _.checkError.compatibleConstructor(
2853
+ let isCompatibleConstructor = _.checkError.compatibleConstructor(
2857
2854
  caughtErr,
2858
2855
  errorLike
2859
2856
  );
@@ -2879,12 +2876,12 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2879
2876
 
2880
2877
  if (caughtErr && errMsgMatcher !== undefined && errMsgMatcher !== null) {
2881
2878
  // Here we check compatible messages
2882
- var placeholder = 'including';
2879
+ let placeholder = 'including';
2883
2880
  if (_.isRegExp(errMsgMatcher)) {
2884
2881
  placeholder = 'matching';
2885
2882
  }
2886
2883
 
2887
- var isCompatibleMessage = _.checkError.compatibleMessage(
2884
+ let isCompatibleMessage = _.checkError.compatibleMessage(
2888
2885
  caughtErr,
2889
2886
  errMsgMatcher
2890
2887
  );
@@ -2994,7 +2991,7 @@ Assertion.addMethod('Throw', assertThrows);
2994
2991
  */
2995
2992
  function respondTo(method, msg) {
2996
2993
  if (msg) flag(this, 'message', msg);
2997
- var obj = flag(this, 'object'),
2994
+ let obj = flag(this, 'object'),
2998
2995
  itself = flag(this, 'itself'),
2999
2996
  context =
3000
2997
  'function' === typeof obj && !itself
@@ -3073,8 +3070,8 @@ Assertion.addProperty('itself', function () {
3073
3070
  */
3074
3071
  function satisfy(matcher, msg) {
3075
3072
  if (msg) flag(this, 'message', msg);
3076
- var obj = flag(this, 'object');
3077
- var result = matcher(obj);
3073
+ let obj = flag(this, 'object');
3074
+ let result = matcher(obj);
3078
3075
  this.assert(
3079
3076
  result,
3080
3077
  'expected #{this} to satisfy ' + _.objDisplay(matcher),
@@ -3126,26 +3123,28 @@ Assertion.addMethod('satisfies', satisfy);
3126
3123
  */
3127
3124
  function closeTo(expected, delta, msg) {
3128
3125
  if (msg) flag(this, 'message', msg);
3129
- var obj = flag(this, 'object'),
3126
+ let obj = flag(this, 'object'),
3130
3127
  flagMsg = flag(this, 'message'),
3131
3128
  ssfi = flag(this, 'ssfi');
3132
3129
 
3133
3130
  new Assertion(obj, flagMsg, ssfi, true).is.numeric;
3134
3131
  let message = 'A `delta` value is required for `closeTo`';
3135
- if (delta == undefined)
3132
+ if (delta == undefined) {
3136
3133
  throw new AssertionError(
3137
3134
  flagMsg ? `${flagMsg}: ${message}` : message,
3138
3135
  undefined,
3139
3136
  ssfi
3140
3137
  );
3138
+ }
3141
3139
  new Assertion(delta, flagMsg, ssfi, true).is.numeric;
3142
3140
  message = 'A `expected` value is required for `closeTo`';
3143
- if (expected == undefined)
3141
+ if (expected == undefined) {
3144
3142
  throw new AssertionError(
3145
3143
  flagMsg ? `${flagMsg}: ${message}` : message,
3146
3144
  undefined,
3147
3145
  ssfi
3148
3146
  );
3147
+ }
3149
3148
  new Assertion(expected, flagMsg, ssfi, true).is.numeric;
3150
3149
 
3151
3150
  const abs = (x) => (x < 0n ? -x : x);
@@ -3184,7 +3183,7 @@ function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
3184
3183
  if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
3185
3184
 
3186
3185
  if (!cmp) {
3187
- var matchIdx = superset.indexOf(elem);
3186
+ let matchIdx = superset.indexOf(elem);
3188
3187
  if (matchIdx === -1) return false;
3189
3188
 
3190
3189
  // Remove match from superset so not counted twice if duplicate in subset.
@@ -3272,17 +3271,17 @@ function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
3272
3271
  */
3273
3272
  Assertion.addMethod('members', function (subset, msg) {
3274
3273
  if (msg) flag(this, 'message', msg);
3275
- var obj = flag(this, 'object'),
3274
+ let obj = flag(this, 'object'),
3276
3275
  flagMsg = flag(this, 'message'),
3277
3276
  ssfi = flag(this, 'ssfi');
3278
3277
 
3279
3278
  new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
3280
3279
  new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
3281
3280
 
3282
- var contains = flag(this, 'contains');
3283
- var ordered = flag(this, 'ordered');
3281
+ let contains = flag(this, 'contains');
3282
+ let ordered = flag(this, 'ordered');
3284
3283
 
3285
- var subject, failMsg, failNegateMsg;
3284
+ let subject, failMsg, failNegateMsg;
3286
3285
 
3287
3286
  if (contains) {
3288
3287
  subject = ordered ? 'an ordered superset' : 'a superset';
@@ -3295,7 +3294,7 @@ Assertion.addMethod('members', function (subset, msg) {
3295
3294
  'expected #{this} to not have the same ' + subject + ' as #{exp}';
3296
3295
  }
3297
3296
 
3298
- var cmp = flag(this, 'deep') ? flag(this, 'eql') : undefined;
3297
+ let cmp = flag(this, 'deep') ? flag(this, 'eql') : undefined;
3299
3298
 
3300
3299
  this.assert(
3301
3300
  isSubsetOf(subset, obj, cmp, contains, ordered),
@@ -3330,7 +3329,7 @@ Assertion.addMethod('members', function (subset, msg) {
3330
3329
  */
3331
3330
  Assertion.addProperty('iterable', function (msg) {
3332
3331
  if (msg) flag(this, 'message', msg);
3333
- var obj = flag(this, 'object');
3332
+ let obj = flag(this, 'object');
3334
3333
 
3335
3334
  this.assert(
3336
3335
  obj != undefined && obj[Symbol.iterator],
@@ -3379,7 +3378,7 @@ Assertion.addProperty('iterable', function (msg) {
3379
3378
  */
3380
3379
  function oneOf(list, msg) {
3381
3380
  if (msg) flag(this, 'message', msg);
3382
- var expected = flag(this, 'object'),
3381
+ let expected = flag(this, 'object'),
3383
3382
  flagMsg = flag(this, 'message'),
3384
3383
  ssfi = flag(this, 'ssfi'),
3385
3384
  contains = flag(this, 'contains'),
@@ -3518,12 +3517,12 @@ Assertion.addMethod('oneOf', oneOf);
3518
3517
  */
3519
3518
  function assertChanges(subject, prop, msg) {
3520
3519
  if (msg) flag(this, 'message', msg);
3521
- var fn = flag(this, 'object'),
3520
+ let fn = flag(this, 'object'),
3522
3521
  flagMsg = flag(this, 'message'),
3523
3522
  ssfi = flag(this, 'ssfi');
3524
3523
  new Assertion(fn, flagMsg, ssfi, true).is.a('function');
3525
3524
 
3526
- var initial;
3525
+ let initial;
3527
3526
  if (!prop) {
3528
3527
  new Assertion(subject, flagMsg, ssfi, true).is.a('function');
3529
3528
  initial = subject();
@@ -3534,8 +3533,8 @@ function assertChanges(subject, prop, msg) {
3534
3533
 
3535
3534
  fn();
3536
3535
 
3537
- var final = prop === undefined || prop === null ? subject() : subject[prop];
3538
- var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3536
+ let final = prop === undefined || prop === null ? subject() : subject[prop];
3537
+ let msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3539
3538
 
3540
3539
  // This gets flagged because of the .by(delta) assertion
3541
3540
  flag(this, 'deltaMsgObj', msgObj);
@@ -3634,12 +3633,12 @@ Assertion.addMethod('changes', assertChanges);
3634
3633
  */
3635
3634
  function assertIncreases(subject, prop, msg) {
3636
3635
  if (msg) flag(this, 'message', msg);
3637
- var fn = flag(this, 'object'),
3636
+ let fn = flag(this, 'object'),
3638
3637
  flagMsg = flag(this, 'message'),
3639
3638
  ssfi = flag(this, 'ssfi');
3640
3639
  new Assertion(fn, flagMsg, ssfi, true).is.a('function');
3641
3640
 
3642
- var initial;
3641
+ let initial;
3643
3642
  if (!prop) {
3644
3643
  new Assertion(subject, flagMsg, ssfi, true).is.a('function');
3645
3644
  initial = subject();
@@ -3653,8 +3652,8 @@ function assertIncreases(subject, prop, msg) {
3653
3652
 
3654
3653
  fn();
3655
3654
 
3656
- var final = prop === undefined || prop === null ? subject() : subject[prop];
3657
- var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3655
+ let final = prop === undefined || prop === null ? subject() : subject[prop];
3656
+ let msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3658
3657
 
3659
3658
  flag(this, 'deltaMsgObj', msgObj);
3660
3659
  flag(this, 'initialDeltaValue', initial);
@@ -3752,12 +3751,12 @@ Assertion.addMethod('increases', assertIncreases);
3752
3751
  */
3753
3752
  function assertDecreases(subject, prop, msg) {
3754
3753
  if (msg) flag(this, 'message', msg);
3755
- var fn = flag(this, 'object'),
3754
+ let fn = flag(this, 'object'),
3756
3755
  flagMsg = flag(this, 'message'),
3757
3756
  ssfi = flag(this, 'ssfi');
3758
3757
  new Assertion(fn, flagMsg, ssfi, true).is.a('function');
3759
3758
 
3760
- var initial;
3759
+ let initial;
3761
3760
  if (!prop) {
3762
3761
  new Assertion(subject, flagMsg, ssfi, true).is.a('function');
3763
3762
  initial = subject();
@@ -3771,8 +3770,8 @@ function assertDecreases(subject, prop, msg) {
3771
3770
 
3772
3771
  fn();
3773
3772
 
3774
- var final = prop === undefined || prop === null ? subject() : subject[prop];
3775
- var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3773
+ let final = prop === undefined || prop === null ? subject() : subject[prop];
3774
+ let msgObj = prop === undefined || prop === null ? initial : '.' + prop;
3776
3775
 
3777
3776
  flag(this, 'deltaMsgObj', msgObj);
3778
3777
  flag(this, 'initialDeltaValue', initial);
@@ -3858,13 +3857,13 @@ Assertion.addMethod('decreases', assertDecreases);
3858
3857
  function assertDelta(delta, msg) {
3859
3858
  if (msg) flag(this, 'message', msg);
3860
3859
 
3861
- var msgObj = flag(this, 'deltaMsgObj');
3862
- var initial = flag(this, 'initialDeltaValue');
3863
- var final = flag(this, 'finalDeltaValue');
3864
- var behavior = flag(this, 'deltaBehavior');
3865
- var realDelta = flag(this, 'realDelta');
3860
+ let msgObj = flag(this, 'deltaMsgObj');
3861
+ let initial = flag(this, 'initialDeltaValue');
3862
+ let final = flag(this, 'finalDeltaValue');
3863
+ let behavior = flag(this, 'deltaBehavior');
3864
+ let realDelta = flag(this, 'realDelta');
3866
3865
 
3867
- var expression;
3866
+ let expression;
3868
3867
  if (behavior === 'change') {
3869
3868
  expression = Math.abs(final - initial) === Math.abs(delta);
3870
3869
  } else {
@@ -3908,14 +3907,14 @@ Assertion.addMethod('by', assertDelta);
3908
3907
  * @public
3909
3908
  */
3910
3909
  Assertion.addProperty('extensible', function () {
3911
- var obj = flag(this, 'object');
3910
+ let obj = flag(this, 'object');
3912
3911
 
3913
3912
  // In ES5, if the argument to this method is a primitive, then it will cause a TypeError.
3914
3913
  // In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false.
3915
3914
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible
3916
3915
  // The following provides ES6 behavior for ES5 environments.
3917
3916
 
3918
- var isExtensible = obj === Object(obj) && Object.isExtensible(obj);
3917
+ let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
3919
3918
 
3920
3919
  this.assert(
3921
3920
  isExtensible,
@@ -3952,14 +3951,14 @@ Assertion.addProperty('extensible', function () {
3952
3951
  * @public
3953
3952
  */
3954
3953
  Assertion.addProperty('sealed', function () {
3955
- var obj = flag(this, 'object');
3954
+ let obj = flag(this, 'object');
3956
3955
 
3957
3956
  // In ES5, if the argument to this method is a primitive, then it will cause a TypeError.
3958
3957
  // In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true.
3959
3958
  // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed
3960
3959
  // The following provides ES6 behavior for ES5 environments.
3961
3960
 
3962
- var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
3961
+ let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
3963
3962
 
3964
3963
  this.assert(
3965
3964
  isSealed,
@@ -3993,14 +3992,14 @@ Assertion.addProperty('sealed', function () {
3993
3992
  * @public
3994
3993
  */
3995
3994
  Assertion.addProperty('frozen', function () {
3996
- var obj = flag(this, 'object');
3995
+ let obj = flag(this, 'object');
3997
3996
 
3998
3997
  // In ES5, if the argument to this method is a primitive, then it will cause a TypeError.
3999
3998
  // In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true.
4000
3999
  // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen
4001
4000
  // The following provides ES6 behavior for ES5 environments.
4002
4001
 
4003
- var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
4002
+ let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
4004
4003
 
4005
4004
  this.assert(
4006
4005
  isFrozen,
@@ -4058,7 +4057,7 @@ Assertion.addProperty('frozen', function () {
4058
4057
  * @public
4059
4058
  */
4060
4059
  Assertion.addProperty('finite', function (_msg) {
4061
- var obj = flag(this, 'object');
4060
+ let obj = flag(this, 'object');
4062
4061
 
4063
4062
  this.assert(
4064
4063
  typeof obj === 'number' && isFinite(obj),
@@ -4108,8 +4107,8 @@ function compareSubset(expected, actual) {
4108
4107
  }
4109
4108
 
4110
4109
  return Object.keys(expected).every(function (key) {
4111
- var expectedValue = expected[key];
4112
- var actualValue = actual[key];
4110
+ let expectedValue = expected[key];
4111
+ let actualValue = actual[key];
4113
4112
  if (
4114
4113
  typeof expectedValue === 'object' &&
4115
4114
  expectedValue !== null &&