chai 5.1.1 → 5.1.2

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.
package/chai.js CHANGED
@@ -37,6 +37,7 @@ __export(utils_exports, {
37
37
  hasProperty: () => hasProperty,
38
38
  inspect: () => inspect2,
39
39
  isNaN: () => isNaN2,
40
+ isNumeric: () => isNumeric,
40
41
  isProxyEnabled: () => isProxyEnabled,
41
42
  isRegExp: () => isRegExp2,
42
43
  objDisplay: () => objDisplay,
@@ -302,6 +303,10 @@ function normaliseOptions({
302
303
  return options;
303
304
  }
304
305
  __name(normaliseOptions, "normaliseOptions");
306
+ function isHighSurrogate(char) {
307
+ return char >= "\uD800" && char <= "\uDBFF";
308
+ }
309
+ __name(isHighSurrogate, "isHighSurrogate");
305
310
  function truncate(string, length, tail = truncator) {
306
311
  string = String(string);
307
312
  const tailLength = tail.length;
@@ -310,7 +315,11 @@ function truncate(string, length, tail = truncator) {
310
315
  return tail;
311
316
  }
312
317
  if (stringLength > length && stringLength > tailLength) {
313
- return `${string.slice(0, length - tailLength)}${tail}`;
318
+ let end = length - tailLength;
319
+ if (end > 0 && isHighSurrogate(string[end - 1])) {
320
+ end = end - 1;
321
+ }
322
+ return `${string.slice(0, end)}${tail}`;
314
323
  }
315
324
  return string;
316
325
  }
@@ -587,7 +596,7 @@ function inspectObject(object, options) {
587
596
  }
588
597
  options.truncate -= 4;
589
598
  options.seen = options.seen || [];
590
- if (options.seen.indexOf(object) >= 0) {
599
+ if (options.seen.includes(object)) {
591
600
  return "[Circular]";
592
601
  }
593
602
  options.seen.push(object);
@@ -638,7 +647,8 @@ var errorKeys = [
638
647
  "lineNumber",
639
648
  "columnNumber",
640
649
  "number",
641
- "description"
650
+ "description",
651
+ "cause"
642
652
  ];
643
653
  function inspectObject2(error, options) {
644
654
  const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
@@ -652,6 +662,11 @@ function inspectObject2(error, options) {
652
662
  }
653
663
  message = message ? `: ${message}` : "";
654
664
  options.truncate -= message.length + 5;
665
+ options.seen = options.seen || [];
666
+ if (options.seen.includes(error)) {
667
+ return "[Circular]";
668
+ }
669
+ options.seen.push(error);
655
670
  const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
656
671
  return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
657
672
  }
@@ -1161,12 +1176,16 @@ function regexpEqual(leftHandOperand, rightHandOperand) {
1161
1176
  }
1162
1177
  __name(regexpEqual, "regexpEqual");
1163
1178
  function entriesEqual(leftHandOperand, rightHandOperand, options) {
1164
- if (leftHandOperand.size !== rightHandOperand.size) {
1179
+ try {
1180
+ if (leftHandOperand.size !== rightHandOperand.size) {
1181
+ return false;
1182
+ }
1183
+ if (leftHandOperand.size === 0) {
1184
+ return true;
1185
+ }
1186
+ } catch (sizeError) {
1165
1187
  return false;
1166
1188
  }
1167
- if (leftHandOperand.size === 0) {
1168
- return true;
1169
- }
1170
1189
  var leftHandItems = [];
1171
1190
  var rightHandItems = [];
1172
1191
  leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
@@ -1822,6 +1841,10 @@ function isRegExp2(obj) {
1822
1841
  return Object.prototype.toString.call(obj) === "[object RegExp]";
1823
1842
  }
1824
1843
  __name(isRegExp2, "isRegExp");
1844
+ function isNumeric(obj) {
1845
+ return ["Number", "BigInt"].includes(type(obj));
1846
+ }
1847
+ __name(isNumeric, "isNumeric");
1825
1848
 
1826
1849
  // lib/chai/core/assertions.js
1827
1850
  var { flag: flag2 } = utils_exports;
@@ -2008,6 +2031,15 @@ Assertion.addProperty("true", function() {
2008
2031
  flag2(this, "negate") ? false : true
2009
2032
  );
2010
2033
  });
2034
+ Assertion.addProperty("numeric", function() {
2035
+ const object = flag2(this, "object");
2036
+ this.assert(
2037
+ ["Number", "BigInt"].includes(type(object)),
2038
+ "expected #{this} to be numeric",
2039
+ "expected #{this} to not be numeric",
2040
+ flag2(this, "negate") ? false : true
2041
+ );
2042
+ });
2011
2043
  Assertion.addProperty("callable", function() {
2012
2044
  const val = flag2(this, "object");
2013
2045
  const ssfi = flag2(this, "ssfi");
@@ -2156,22 +2188,17 @@ Assertion.addMethod("eqls", assertEql);
2156
2188
  function assertAbove(n, msg) {
2157
2189
  if (msg)
2158
2190
  flag2(this, "message", msg);
2159
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
2191
+ var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
2160
2192
  if (doLength && objType !== "map" && objType !== "set") {
2161
2193
  new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2162
2194
  }
2163
2195
  if (!doLength && (objType === "date" && nType !== "date")) {
2164
- errorMessage = msgPrefix + "the argument to above must be a date";
2165
- } else if (nType !== "number" && (doLength || objType === "number")) {
2166
- errorMessage = msgPrefix + "the argument to above must be a number";
2167
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2196
+ throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
2197
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2198
+ throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
2199
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2168
2200
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2169
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2170
- } else {
2171
- shouldThrow = false;
2172
- }
2173
- if (shouldThrow) {
2174
- throw new AssertionError(errorMessage, void 0, ssfi);
2201
+ throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", void 0, ssfi);
2175
2202
  }
2176
2203
  if (doLength) {
2177
2204
  var descriptor = "length", itemsCount;
@@ -2210,9 +2237,9 @@ function assertLeast(n, msg) {
2210
2237
  }
2211
2238
  if (!doLength && (objType === "date" && nType !== "date")) {
2212
2239
  errorMessage = msgPrefix + "the argument to least must be a date";
2213
- } else if (nType !== "number" && (doLength || objType === "number")) {
2240
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2214
2241
  errorMessage = msgPrefix + "the argument to least must be a number";
2215
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2242
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2216
2243
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2217
2244
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2218
2245
  } else {
@@ -2258,9 +2285,9 @@ function assertBelow(n, msg) {
2258
2285
  }
2259
2286
  if (!doLength && (objType === "date" && nType !== "date")) {
2260
2287
  errorMessage = msgPrefix + "the argument to below must be a date";
2261
- } else if (nType !== "number" && (doLength || objType === "number")) {
2288
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2262
2289
  errorMessage = msgPrefix + "the argument to below must be a number";
2263
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2290
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2264
2291
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2265
2292
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2266
2293
  } else {
@@ -2306,9 +2333,9 @@ function assertMost(n, msg) {
2306
2333
  }
2307
2334
  if (!doLength && (objType === "date" && nType !== "date")) {
2308
2335
  errorMessage = msgPrefix + "the argument to most must be a date";
2309
- } else if (nType !== "number" && (doLength || objType === "number")) {
2336
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2310
2337
  errorMessage = msgPrefix + "the argument to most must be a number";
2311
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2338
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2312
2339
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2313
2340
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2314
2341
  } else {
@@ -2354,9 +2381,9 @@ Assertion.addMethod("within", function(start, finish, msg) {
2354
2381
  }
2355
2382
  if (!doLength && (objType === "date" && (startType !== "date" || finishType !== "date"))) {
2356
2383
  errorMessage = msgPrefix + "the arguments to within must be dates";
2357
- } else if ((startType !== "number" || finishType !== "number") && (doLength || objType === "number")) {
2384
+ } else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
2358
2385
  errorMessage = msgPrefix + "the arguments to within must be numbers";
2359
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2386
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2360
2387
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2361
2388
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2362
2389
  } else {
@@ -2817,18 +2844,18 @@ function closeTo(expected, delta, msg) {
2817
2844
  if (msg)
2818
2845
  flag2(this, "message", msg);
2819
2846
  var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2820
- new Assertion(obj, flagMsg, ssfi, true).is.a("number");
2821
- if (typeof expected !== "number" || typeof delta !== "number") {
2822
- flagMsg = flagMsg ? flagMsg + ": " : "";
2823
- var deltaMessage = delta === void 0 ? ", and a delta is required" : "";
2824
- throw new AssertionError(
2825
- flagMsg + "the arguments to closeTo or approximately must be numbers" + deltaMessage,
2826
- void 0,
2827
- ssfi
2828
- );
2829
- }
2847
+ new Assertion(obj, flagMsg, ssfi, true).is.numeric;
2848
+ let message = "A `delta` value is required for `closeTo`";
2849
+ if (delta == void 0)
2850
+ throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
2851
+ new Assertion(delta, flagMsg, ssfi, true).is.numeric;
2852
+ message = "A `expected` value is required for `closeTo`";
2853
+ if (expected == void 0)
2854
+ throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
2855
+ new Assertion(expected, flagMsg, ssfi, true).is.numeric;
2856
+ const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
2830
2857
  this.assert(
2831
- Math.abs(obj - expected) <= delta,
2858
+ abs(obj - expected) <= delta,
2832
2859
  "expected #{this} to be close to " + expected + " +/- " + delta,
2833
2860
  "expected #{this} not to be close to " + expected + " +/- " + delta
2834
2861
  );
@@ -3319,6 +3346,12 @@ assert.isNumber = function(val, msg) {
3319
3346
  assert.isNotNumber = function(val, msg) {
3320
3347
  new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
3321
3348
  };
3349
+ assert.isNumeric = function(val, msg) {
3350
+ new Assertion(val, msg, assert.isNumeric, true).is.numeric;
3351
+ };
3352
+ assert.isNotNumeric = function(val, msg) {
3353
+ new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
3354
+ };
3322
3355
  assert.isFinite = function(val, msg) {
3323
3356
  new Assertion(val, msg, assert.isFinite, true).to.be.finite;
3324
3357
  };
@@ -233,7 +233,6 @@ Assertion.addProperty('any', function () {
233
233
  * @namespace BDD
234
234
  * @public
235
235
  */
236
-
237
236
  Assertion.addProperty('all', function () {
238
237
  flag(this, 'all', true);
239
238
  flag(this, 'any', false);
@@ -694,6 +693,17 @@ Assertion.addProperty('true', function () {
694
693
  );
695
694
  });
696
695
 
696
+ Assertion.addProperty('numeric', function () {
697
+ const object = flag(this, 'object');
698
+
699
+ this.assert(
700
+ ['Number', 'BigInt'].includes(_.type(object))
701
+ , 'expected #{this} to be numeric'
702
+ , 'expected #{this} to not be numeric'
703
+ , flag(this, 'negate') ? false : true
704
+ );
705
+ });
706
+
697
707
  /**
698
708
  * ### .callable
699
709
  *
@@ -1208,27 +1218,19 @@ function assertAbove (n, msg) {
1208
1218
  , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
1209
1219
  , ssfi = flag(this, 'ssfi')
1210
1220
  , objType = _.type(obj).toLowerCase()
1211
- , nType = _.type(n).toLowerCase()
1212
- , errorMessage
1213
- , shouldThrow = true;
1221
+ , nType = _.type(n).toLowerCase();
1214
1222
 
1215
1223
  if (doLength && objType !== 'map' && objType !== 'set') {
1216
1224
  new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
1217
1225
  }
1218
1226
 
1219
1227
  if (!doLength && (objType === 'date' && nType !== 'date')) {
1220
- errorMessage = msgPrefix + 'the argument to above must be a date';
1221
- } else if (nType !== 'number' && (doLength || objType === 'number')) {
1222
- errorMessage = msgPrefix + 'the argument to above must be a number';
1223
- } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1228
+ throw new AssertionError(msgPrefix + 'the argument to above must be a date', undefined, ssfi);
1229
+ } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1230
+ throw new AssertionError(msgPrefix + 'the argument to above must be a number', undefined, ssfi);
1231
+ } else if (!doLength && (objType !== 'date' && !_.isNumeric(obj))) {
1224
1232
  var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1225
- errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1226
- } else {
1227
- shouldThrow = false;
1228
- }
1229
-
1230
- if (shouldThrow) {
1231
- throw new AssertionError(errorMessage, undefined, ssfi);
1233
+ throw new AssertionError(msgPrefix + 'expected ' + printObj + ' to be a number or a date', undefined, ssfi);
1232
1234
  }
1233
1235
 
1234
1236
  if (doLength) {
@@ -1299,7 +1301,7 @@ Assertion.addMethod('greaterThan', assertAbove);
1299
1301
  * @name least
1300
1302
  * @alias gte
1301
1303
  * @alias greaterThanOrEqual
1302
- * @param {number} n
1304
+ * @param {unknown} n
1303
1305
  * @param {string} msg _optional_
1304
1306
  * @namespace BDD
1305
1307
  * @public
@@ -1322,9 +1324,9 @@ function assertLeast (n, msg) {
1322
1324
 
1323
1325
  if (!doLength && (objType === 'date' && nType !== 'date')) {
1324
1326
  errorMessage = msgPrefix + 'the argument to least must be a date';
1325
- } else if (nType !== 'number' && (doLength || objType === 'number')) {
1327
+ } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1326
1328
  errorMessage = msgPrefix + 'the argument to least must be a number';
1327
- } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1329
+ } else if (!doLength && (objType !== 'date' && !_.isNumeric(obj))) {
1328
1330
  var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1329
1331
  errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1330
1332
  } else {
@@ -1402,7 +1404,7 @@ Assertion.addMethod('greaterThanOrEqual', assertLeast);
1402
1404
  * @name below
1403
1405
  * @alias lt
1404
1406
  * @alias lessThan
1405
- * @param {number} n
1407
+ * @param {unknown} n
1406
1408
  * @param {string} msg _optional_
1407
1409
  * @namespace BDD
1408
1410
  * @public
@@ -1422,12 +1424,12 @@ function assertBelow (n, msg) {
1422
1424
  if (doLength && objType !== 'map' && objType !== 'set') {
1423
1425
  new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
1424
1426
  }
1425
-
1427
+
1426
1428
  if (!doLength && (objType === 'date' && nType !== 'date')) {
1427
1429
  errorMessage = msgPrefix + 'the argument to below must be a date';
1428
- } else if (nType !== 'number' && (doLength || objType === 'number')) {
1430
+ } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1429
1431
  errorMessage = msgPrefix + 'the argument to below must be a number';
1430
- } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1432
+ } else if (!doLength && (objType !== 'date' && !_.isNumeric(obj))) {
1431
1433
  var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1432
1434
  errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1433
1435
  } else {
@@ -1506,7 +1508,7 @@ Assertion.addMethod('lessThan', assertBelow);
1506
1508
  * @name most
1507
1509
  * @alias lte
1508
1510
  * @alias lessThanOrEqual
1509
- * @param {number} n
1511
+ * @param {unknown} n
1510
1512
  * @param {string} msg _optional_
1511
1513
  * @namespace BDD
1512
1514
  * @public
@@ -1529,9 +1531,9 @@ function assertMost (n, msg) {
1529
1531
 
1530
1532
  if (!doLength && (objType === 'date' && nType !== 'date')) {
1531
1533
  errorMessage = msgPrefix + 'the argument to most must be a date';
1532
- } else if (nType !== 'number' && (doLength || objType === 'number')) {
1534
+ } else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
1533
1535
  errorMessage = msgPrefix + 'the argument to most must be a number';
1534
- } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1536
+ } else if (!doLength && (objType !== 'date' && !_.isNumeric(obj))) {
1535
1537
  var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1536
1538
  errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1537
1539
  } else {
@@ -1608,8 +1610,8 @@ Assertion.addMethod('lessThanOrEqual', assertMost);
1608
1610
  * expect(4, 'nooo why fail??').to.be.within(1, 3);
1609
1611
  *
1610
1612
  * @name within
1611
- * @param {number} start lower bound inclusive
1612
- * @param {number} finish upper bound inclusive
1613
+ * @param {unknown} start lower bound inclusive
1614
+ * @param {unknown} finish upper bound inclusive
1613
1615
  * @param {string} msg _optional_
1614
1616
  * @namespace BDD
1615
1617
  * @public
@@ -1636,9 +1638,9 @@ Assertion.addMethod('within', function (start, finish, msg) {
1636
1638
 
1637
1639
  if (!doLength && (objType === 'date' && (startType !== 'date' || finishType !== 'date'))) {
1638
1640
  errorMessage = msgPrefix + 'the arguments to within must be dates';
1639
- } else if ((startType !== 'number' || finishType !== 'number') && (doLength || objType === 'number')) {
1641
+ } else if ((!_.isNumeric(start) || !_.isNumeric(finish)) && (doLength || _.isNumeric(obj))) {
1640
1642
  errorMessage = msgPrefix + 'the arguments to within must be numbers';
1641
- } else if (!doLength && (objType !== 'date' && objType !== 'number')) {
1643
+ } else if (!doLength && (objType !== 'date' && !_.isNumeric(obj))) {
1642
1644
  var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
1643
1645
  errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
1644
1646
  } else {
@@ -3013,19 +3015,18 @@ function closeTo(expected, delta, msg) {
3013
3015
  , flagMsg = flag(this, 'message')
3014
3016
  , ssfi = flag(this, 'ssfi');
3015
3017
 
3016
- new Assertion(obj, flagMsg, ssfi, true).is.a('number');
3017
- if (typeof expected !== 'number' || typeof delta !== 'number') {
3018
- flagMsg = flagMsg ? flagMsg + ': ' : '';
3019
- var deltaMessage = delta === undefined ? ", and a delta is required" : "";
3020
- throw new AssertionError(
3021
- flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
3022
- undefined,
3023
- ssfi
3024
- );
3025
- }
3018
+ new Assertion(obj, flagMsg, ssfi, true).is.numeric;
3019
+ let message = 'A `delta` value is required for `closeTo`';
3020
+ if (delta == undefined) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, undefined, ssfi);
3021
+ new Assertion(delta, flagMsg, ssfi, true).is.numeric;
3022
+ message = 'A `expected` value is required for `closeTo`';
3023
+ if (expected == undefined) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, undefined, ssfi);
3024
+ new Assertion(expected, flagMsg, ssfi, true).is.numeric;
3025
+
3026
+ const abs = (x) => x < 0n ? -x : x;
3026
3027
 
3027
3028
  this.assert(
3028
- Math.abs(obj - expected) <= delta
3029
+ abs(obj - expected) <= delta
3029
3030
  , 'expected #{this} to be close to ' + expected + ' +/- ' + delta
3030
3031
  , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta
3031
3032
  );
@@ -706,6 +706,45 @@ assert.isNotNumber = function (val, msg) {
706
706
  new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a('number');
707
707
  };
708
708
 
709
+ /**
710
+ * ### .isNumeric(value, [message])
711
+ *
712
+ * Asserts that `value` is a number or BigInt.
713
+ *
714
+ * var cups = 2;
715
+ * assert.isNumeric(cups, 'how many cups');
716
+ *
717
+ * var cups = 10n;
718
+ * assert.isNumeric(cups, 'how many cups');
719
+ *
720
+ * @name isNumeric
721
+ * @param {unknown} val
722
+ * @param {string} msg
723
+ * @namespace Assert
724
+ * @public
725
+ */
726
+ assert.isNumeric = function (val, msg) {
727
+ new Assertion(val, msg, assert.isNumeric, true).is.numeric;
728
+ };
729
+
730
+ /**
731
+ * ### .isNotNumeric(value, [message])
732
+ *
733
+ * Asserts that `value` is _not_ a number or BigInt.
734
+ *
735
+ * var cups = '2 cups please';
736
+ * assert.isNotNumeric(cups, 'how many cups');
737
+ *
738
+ * @name isNotNumeric
739
+ * @param {unknown} val
740
+ * @param {string} msg
741
+ * @namespace Assert
742
+ * @public
743
+ */
744
+ assert.isNotNumeric = function (val, msg) {
745
+ new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
746
+ };
747
+
709
748
  /**
710
749
  * ### .isFinite(value, [message])
711
750
  *
@@ -11,7 +11,8 @@ import * as checkError from 'check-error';
11
11
  export {test} from './test.js';
12
12
 
13
13
  // type utility
14
- export {type} from './type-detect.js';
14
+ import {type} from './type-detect.js';
15
+ export {type};
15
16
 
16
17
  // expectTypes utility
17
18
  export {expectTypes} from './expectTypes.js';
@@ -105,3 +106,7 @@ export {getOperator} from './getOperator.js';
105
106
  export function isRegExp(obj) {
106
107
  return Object.prototype.toString.call(obj) === '[object RegExp]';
107
108
  }
109
+
110
+ export function isNumeric(obj) {
111
+ return ['Number', 'BigInt'].includes(type(obj))
112
+ }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "Veselin Todorov <hi@vesln.com>",
19
19
  "John Firebaugh <john.firebaugh@gmail.com>"
20
20
  ],
21
- "version": "5.1.1",
21
+ "version": "5.1.2",
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "https://github.com/chaijs/chai"