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.
@@ -24,7 +24,7 @@ import {AssertionError} from 'assertion-error';
24
24
  * @public
25
25
  */
26
26
  export function assert(express, errmsg) {
27
- var test = new Assertion(null, null, chai.assert, true);
27
+ let test = new Assertion(null, null, chai.assert, true);
28
28
  test.assert(express, errmsg, '[ negation message unavailable ]');
29
29
  }
30
30
 
@@ -122,7 +122,7 @@ assert.isNotOk = function (val, msg) {
122
122
  * @public
123
123
  */
124
124
  assert.equal = function (act, exp, msg) {
125
- var test = new Assertion(act, msg, assert.equal, true);
125
+ let test = new Assertion(act, msg, assert.equal, true);
126
126
 
127
127
  test.assert(
128
128
  exp == flag(test, 'object'),
@@ -149,7 +149,7 @@ assert.equal = function (act, exp, msg) {
149
149
  * @public
150
150
  */
151
151
  assert.notEqual = function (act, exp, msg) {
152
- var test = new Assertion(act, msg, assert.notEqual, true);
152
+ let test = new Assertion(act, msg, assert.notEqual, true);
153
153
 
154
154
  test.assert(
155
155
  exp != flag(test, 'object'),
@@ -1993,7 +1993,7 @@ assert.throws = function (fn, errorLike, errMsgMatcher, msg) {
1993
1993
  errorLike = null;
1994
1994
  }
1995
1995
 
1996
- var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
1996
+ let assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
1997
1997
  errorLike,
1998
1998
  errMsgMatcher
1999
1999
  );
@@ -2057,7 +2057,7 @@ assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, message) {
2057
2057
  * @public
2058
2058
  */
2059
2059
  assert.operator = function (val, operator, val2, msg) {
2060
- var ok;
2060
+ let ok;
2061
2061
  switch (operator) {
2062
2062
  case '==':
2063
2063
  ok = val == val2;
@@ -2091,7 +2091,7 @@ assert.operator = function (val, operator, val2, msg) {
2091
2091
  assert.operator
2092
2092
  );
2093
2093
  }
2094
- var test = new Assertion(ok, msg, assert.operator, true);
2094
+ let test = new Assertion(ok, msg, assert.operator, true);
2095
2095
  test.assert(
2096
2096
  true === flag(test, 'object'),
2097
2097
  'expected ' + inspect(val) + ' to be ' + operator + ' ' + inspect(val2),
@@ -2611,7 +2611,7 @@ assert.changes = function (fn, obj, prop, msg) {
2611
2611
  */
2612
2612
  assert.changesBy = function (fn, obj, prop, delta, msg) {
2613
2613
  if (arguments.length === 4 && typeof obj === 'function') {
2614
- var tmpMsg = delta;
2614
+ let tmpMsg = delta;
2615
2615
  delta = prop;
2616
2616
  msg = tmpMsg;
2617
2617
  } else if (arguments.length === 3) {
@@ -2672,7 +2672,7 @@ assert.doesNotChange = function (fn, obj, prop, msg) {
2672
2672
  */
2673
2673
  assert.changesButNotBy = function (fn, obj, prop, delta, msg) {
2674
2674
  if (arguments.length === 4 && typeof obj === 'function') {
2675
- var tmpMsg = delta;
2675
+ let tmpMsg = delta;
2676
2676
  delta = prop;
2677
2677
  msg = tmpMsg;
2678
2678
  } else if (arguments.length === 3) {
@@ -2732,7 +2732,7 @@ assert.increases = function (fn, obj, prop, msg) {
2732
2732
  */
2733
2733
  assert.increasesBy = function (fn, obj, prop, delta, msg) {
2734
2734
  if (arguments.length === 4 && typeof obj === 'function') {
2735
- var tmpMsg = delta;
2735
+ let tmpMsg = delta;
2736
2736
  delta = prop;
2737
2737
  msg = tmpMsg;
2738
2738
  } else if (arguments.length === 3) {
@@ -2795,7 +2795,7 @@ assert.doesNotIncrease = function (fn, obj, prop, msg) {
2795
2795
  */
2796
2796
  assert.increasesButNotBy = function (fn, obj, prop, delta, msg) {
2797
2797
  if (arguments.length === 4 && typeof obj === 'function') {
2798
- var tmpMsg = delta;
2798
+ let tmpMsg = delta;
2799
2799
  delta = prop;
2800
2800
  msg = tmpMsg;
2801
2801
  } else if (arguments.length === 3) {
@@ -2855,7 +2855,7 @@ assert.decreases = function (fn, obj, prop, msg) {
2855
2855
  */
2856
2856
  assert.decreasesBy = function (fn, obj, prop, delta, msg) {
2857
2857
  if (arguments.length === 4 && typeof obj === 'function') {
2858
- var tmpMsg = delta;
2858
+ let tmpMsg = delta;
2859
2859
  delta = prop;
2860
2860
  msg = tmpMsg;
2861
2861
  } else if (arguments.length === 3) {
@@ -2919,7 +2919,7 @@ assert.doesNotDecrease = function (fn, obj, prop, msg) {
2919
2919
  */
2920
2920
  assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) {
2921
2921
  if (arguments.length === 4 && typeof obj === 'function') {
2922
- var tmpMsg = delta;
2922
+ let tmpMsg = delta;
2923
2923
  delta = prop;
2924
2924
  msg = tmpMsg;
2925
2925
  } else if (arguments.length === 3) {
@@ -2952,7 +2952,7 @@ assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) {
2952
2952
  */
2953
2953
  assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
2954
2954
  if (arguments.length === 4 && typeof obj === 'function') {
2955
- var tmpMsg = delta;
2955
+ let tmpMsg = delta;
2956
2956
  delta = prop;
2957
2957
  msg = tmpMsg;
2958
2958
  } else if (arguments.length === 3) {
@@ -51,7 +51,7 @@ function loadShould() {
51
51
  configurable: true
52
52
  });
53
53
 
54
- var should = {};
54
+ let should = {};
55
55
 
56
56
  /**
57
57
  * ### .fail([message])
@@ -15,13 +15,13 @@ import {transferFlags} from './transferFlags.js';
15
15
  */
16
16
 
17
17
  // Check whether `Object.setPrototypeOf` is supported
18
- var canSetPrototype = typeof Object.setPrototypeOf === 'function';
18
+ let canSetPrototype = typeof Object.setPrototypeOf === 'function';
19
19
 
20
20
  // Without `Object.setPrototypeOf` support, this module will need to add properties to a function.
21
21
  // However, some of functions' own props are not configurable and should be skipped.
22
- var testFn = function () {};
23
- var excludeNames = Object.getOwnPropertyNames(testFn).filter(function (name) {
24
- var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
22
+ let testFn = function () {};
23
+ let excludeNames = Object.getOwnPropertyNames(testFn).filter(function (name) {
24
+ let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
25
25
 
26
26
  // Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties,
27
27
  // but then returns `undefined` as the property descriptor for `callee`. As a
@@ -33,7 +33,7 @@ var excludeNames = Object.getOwnPropertyNames(testFn).filter(function (name) {
33
33
  });
34
34
 
35
35
  // Cache `Function` properties
36
- var call = Function.prototype.call,
36
+ let call = Function.prototype.call,
37
37
  apply = Function.prototype.apply;
38
38
 
39
39
  /**
@@ -69,7 +69,7 @@ export function addChainableMethod(ctx, name, method, chainingBehavior) {
69
69
  chainingBehavior = function () {};
70
70
  }
71
71
 
72
- var chainableBehavior = {
72
+ let chainableBehavior = {
73
73
  method: method,
74
74
  chainingBehavior: chainingBehavior
75
75
  };
@@ -84,7 +84,7 @@ export function addChainableMethod(ctx, name, method, chainingBehavior) {
84
84
  get: function chainableMethodGetter() {
85
85
  chainableBehavior.chainingBehavior.call(this);
86
86
 
87
- var chainableMethodWrapper = function () {
87
+ let chainableMethodWrapper = function () {
88
88
  // Setting the `ssfi` flag to `chainableMethodWrapper` causes this
89
89
  // function to be the starting point for removing implementation
90
90
  // frames from the stack trace of a failed assertion.
@@ -104,12 +104,12 @@ export function addChainableMethod(ctx, name, method, chainingBehavior) {
104
104
  flag(this, 'ssfi', chainableMethodWrapper);
105
105
  }
106
106
 
107
- var result = chainableBehavior.method.apply(this, arguments);
107
+ let result = chainableBehavior.method.apply(this, arguments);
108
108
  if (result !== undefined) {
109
109
  return result;
110
110
  }
111
111
 
112
- var newAssertion = new Assertion();
112
+ let newAssertion = new Assertion();
113
113
  transferFlags(this, newAssertion);
114
114
  return newAssertion;
115
115
  };
@@ -119,7 +119,7 @@ export function addChainableMethod(ctx, name, method, chainingBehavior) {
119
119
  // Use `Object.setPrototypeOf` if available
120
120
  if (canSetPrototype) {
121
121
  // Inherit all properties from the object by replacing the `Function` prototype
122
- var prototype = Object.create(this);
122
+ let prototype = Object.create(this);
123
123
  // Restore the `call` and `apply` methods from `Function`
124
124
  prototype.call = call;
125
125
  prototype.apply = apply;
@@ -127,13 +127,13 @@ export function addChainableMethod(ctx, name, method, chainingBehavior) {
127
127
  }
128
128
  // Otherwise, redefine all properties (slow!)
129
129
  else {
130
- var asserterNames = Object.getOwnPropertyNames(ctx);
130
+ let asserterNames = Object.getOwnPropertyNames(ctx);
131
131
  asserterNames.forEach(function (asserterName) {
132
132
  if (excludeNames.indexOf(asserterName) !== -1) {
133
133
  return;
134
134
  }
135
135
 
136
- var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
136
+ let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
137
137
  Object.defineProperty(chainableMethodWrapper, asserterName, pd);
138
138
  });
139
139
  }
@@ -36,7 +36,7 @@ import {Assertion} from '../assertion.js';
36
36
  * @public
37
37
  */
38
38
  export function addMethod(ctx, name, method) {
39
- var methodWrapper = function () {
39
+ let methodWrapper = function () {
40
40
  // Setting the `ssfi` flag to `methodWrapper` causes this function to be the
41
41
  // starting point for removing implementation frames from the stack trace of
42
42
  // a failed assertion.
@@ -53,10 +53,10 @@ export function addMethod(ctx, name, method) {
53
53
  flag(this, 'ssfi', methodWrapper);
54
54
  }
55
55
 
56
- var result = method.apply(this, arguments);
56
+ let result = method.apply(this, arguments);
57
57
  if (result !== undefined) return result;
58
58
 
59
- var newAssertion = new Assertion();
59
+ let newAssertion = new Assertion();
60
60
  transferFlags(this, newAssertion);
61
61
  return newAssertion;
62
62
  };
@@ -58,10 +58,10 @@ export function addProperty(ctx, name, getter) {
58
58
  flag(this, 'ssfi', propertyGetter);
59
59
  }
60
60
 
61
- var result = getter.call(this);
61
+ let result = getter.call(this);
62
62
  if (result !== undefined) return result;
63
63
 
64
- var newAssertion = new Assertion();
64
+ let newAssertion = new Assertion();
65
65
  transferFlags(this, newAssertion);
66
66
  return newAssertion;
67
67
  },
@@ -22,8 +22,8 @@ import {type} from './type-detect.js';
22
22
  * @public
23
23
  */
24
24
  export function expectTypes(obj, types) {
25
- var flagMsg = flag(obj, 'message');
26
- var ssfi = flag(obj, 'ssfi');
25
+ let flagMsg = flag(obj, 'message');
26
+ let ssfi = flag(obj, 'ssfi');
27
27
 
28
28
  flagMsg = flagMsg ? flagMsg + ': ' : '';
29
29
 
@@ -34,15 +34,15 @@ export function expectTypes(obj, types) {
34
34
  types.sort();
35
35
 
36
36
  // Transforms ['lorem', 'ipsum'] into 'a lorem, or an ipsum'
37
- var str = types
37
+ let str = types
38
38
  .map(function (t, index) {
39
- var art = ~['a', 'e', 'i', 'o', 'u'].indexOf(t.charAt(0)) ? 'an' : 'a';
40
- var or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
39
+ let art = ~['a', 'e', 'i', 'o', 'u'].indexOf(t.charAt(0)) ? 'an' : 'a';
40
+ let or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
41
41
  return or + art + ' ' + t;
42
42
  })
43
43
  .join(', ');
44
44
 
45
- var objType = type(obj).toLowerCase();
45
+ let objType = type(obj).toLowerCase();
46
46
 
47
47
  if (
48
48
  !types.some(function (expected) {
@@ -15,16 +15,17 @@
15
15
  * utils.flag(this, 'foo', 'bar'); // setter
16
16
  * utils.flag(this, 'foo'); // getter, returns `bar`
17
17
  *
18
- * @param {object} obj object constructed Assertion
18
+ * @template {{__flags?: {[key: PropertyKey]: unknown}}} T
19
+ * @param {T} obj object constructed Assertion
19
20
  * @param {string} key
20
- * @param {unknown} value (optional)
21
+ * @param {unknown} [value]
21
22
  * @namespace Utils
22
23
  * @name flag
23
24
  * @returns {unknown | undefined}
24
25
  * @private
25
26
  */
26
27
  export function flag(obj, key, value) {
27
- var flags = obj.__flags || (obj.__flags = Object.create(null));
28
+ let flags = obj.__flags || (obj.__flags = Object.create(null));
28
29
  if (arguments.length === 3) {
29
30
  flags[key] = value;
30
31
  } else {
@@ -21,19 +21,19 @@ import {objDisplay} from './objDisplay.js';
21
21
  * - `#{exp}` expected value
22
22
  *
23
23
  * @param {object} obj object (constructed Assertion)
24
- * @param {unknown} args chai.Assertion.prototype.assert arguments
25
- * @returns {unknown}
24
+ * @param {IArguments} args chai.Assertion.prototype.assert arguments
25
+ * @returns {string}
26
26
  * @namespace Utils
27
27
  * @name getMessage
28
28
  * @public
29
29
  */
30
30
  export function getMessage(obj, args) {
31
- var negate = flag(obj, 'negate'),
32
- val = flag(obj, 'object'),
33
- expected = args[3],
34
- actual = getActual(obj, args),
35
- msg = negate ? args[2] : args[1],
36
- flagMsg = flag(obj, 'message');
31
+ let negate = flag(obj, 'negate');
32
+ let val = flag(obj, 'object');
33
+ let expected = args[3];
34
+ let actual = getActual(obj, args);
35
+ let msg = negate ? args[2] : args[1];
36
+ let flagMsg = flag(obj, 'message');
37
37
 
38
38
  if (typeof msg === 'function') msg = msg();
39
39
  msg = msg || '';
@@ -6,8 +6,8 @@ import {type} from './type-detect.js';
6
6
  * @returns {boolean}
7
7
  */
8
8
  function isObjectType(obj) {
9
- var objectType = type(obj);
10
- var objectTypes = ['Array', 'Object', 'Function'];
9
+ let objectType = type(obj);
10
+ let objectTypes = ['Array', 'Object', 'Function'];
11
11
 
12
12
  return objectTypes.indexOf(objectType) !== -1;
13
13
  }
@@ -29,10 +29,10 @@ function isObjectType(obj) {
29
29
  * @public
30
30
  */
31
31
  export function getOperator(obj, args) {
32
- var operator = flag(obj, 'operator');
33
- var negate = flag(obj, 'negate');
34
- var expected = args[3];
35
- var msg = negate ? args[2] : args[1];
32
+ let operator = flag(obj, 'operator');
33
+ let negate = flag(obj, 'negate');
34
+ let expected = args[3];
35
+ let msg = negate ? args[2] : args[1];
36
36
 
37
37
  if (operator) {
38
38
  return operator;
@@ -49,7 +49,7 @@ export function getOperator(obj, args) {
49
49
  return undefined;
50
50
  }
51
51
 
52
- var isObject = isObjectType(expected);
52
+ let isObject = isObjectType(expected);
53
53
  if (/\snot\s/.test(msg)) {
54
54
  return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
55
55
  }
@@ -17,7 +17,7 @@
17
17
  * @public
18
18
  */
19
19
  export function getProperties(object) {
20
- var result = Object.getOwnPropertyNames(object);
20
+ let result = Object.getOwnPropertyNames(object);
21
21
 
22
22
  /**
23
23
  * @param {unknown} property
@@ -28,7 +28,7 @@ export function getProperties(object) {
28
28
  }
29
29
  }
30
30
 
31
- var proto = Object.getPrototypeOf(object);
31
+ let proto = Object.getPrototypeOf(object);
32
32
  while (proto !== null) {
33
33
  Object.getOwnPropertyNames(proto).forEach(addProperty);
34
34
  proto = Object.getPrototypeOf(proto);
@@ -21,7 +21,7 @@ import {config} from '../config.js';
21
21
  * @name inspect
22
22
  */
23
23
  export function inspect(obj, showHidden, depth, colors) {
24
- var options = {
24
+ let options = {
25
25
  colors: colors,
26
26
  depth: typeof depth === 'undefined' ? 2 : depth,
27
27
  showHidden: showHidden,
@@ -21,7 +21,7 @@ import {config} from '../config.js';
21
21
  * @public
22
22
  */
23
23
  export function objDisplay(obj) {
24
- var str = inspect(obj),
24
+ let str = inspect(obj),
25
25
  type = Object.prototype.toString.call(obj);
26
26
 
27
27
  if (config.truncateThreshold && str.length >= config.truncateThreshold) {
@@ -32,7 +32,7 @@ export function objDisplay(obj) {
32
32
  } else if (type === '[object Array]') {
33
33
  return '[ Array(' + obj.length + ') ]';
34
34
  } else if (type === '[object Object]') {
35
- var keys = Object.keys(obj),
35
+ let keys = Object.keys(obj),
36
36
  kstr =
37
37
  keys.length > 2
38
38
  ? keys.splice(0, 2).join(', ') + ', ...'
@@ -40,29 +40,29 @@ import {transferFlags} from './transferFlags.js';
40
40
  * @public
41
41
  */
42
42
  export function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
43
- var chainableBehavior = ctx.__methods[name];
43
+ let chainableBehavior = ctx.__methods[name];
44
44
 
45
- var _chainingBehavior = chainableBehavior.chainingBehavior;
45
+ let _chainingBehavior = chainableBehavior.chainingBehavior;
46
46
  chainableBehavior.chainingBehavior =
47
47
  function overwritingChainableMethodGetter() {
48
- var result = chainingBehavior(_chainingBehavior).call(this);
48
+ let result = chainingBehavior(_chainingBehavior).call(this);
49
49
  if (result !== undefined) {
50
50
  return result;
51
51
  }
52
52
 
53
- var newAssertion = new Assertion();
53
+ let newAssertion = new Assertion();
54
54
  transferFlags(this, newAssertion);
55
55
  return newAssertion;
56
56
  };
57
57
 
58
- var _method = chainableBehavior.method;
58
+ let _method = chainableBehavior.method;
59
59
  chainableBehavior.method = function overwritingChainableMethodWrapper() {
60
- var result = method(_method).apply(this, arguments);
60
+ let result = method(_method).apply(this, arguments);
61
61
  if (result !== undefined) {
62
62
  return result;
63
63
  }
64
64
 
65
- var newAssertion = new Assertion();
65
+ let newAssertion = new Assertion();
66
66
  transferFlags(this, newAssertion);
67
67
  return newAssertion;
68
68
  };
@@ -44,14 +44,14 @@ import {transferFlags} from './transferFlags.js';
44
44
  * @public
45
45
  */
46
46
  export function overwriteMethod(ctx, name, method) {
47
- var _method = ctx[name],
47
+ let _method = ctx[name],
48
48
  _super = function () {
49
49
  throw new Error(name + ' is not a function');
50
50
  };
51
51
 
52
52
  if (_method && 'function' === typeof _method) _super = _method;
53
53
 
54
- var overwritingMethodWrapper = function () {
54
+ let overwritingMethodWrapper = function () {
55
55
  // Setting the `ssfi` flag to `overwritingMethodWrapper` causes this
56
56
  // function to be the starting point for removing implementation frames from
57
57
  // the stack trace of a failed assertion.
@@ -71,16 +71,16 @@ export function overwriteMethod(ctx, name, method) {
71
71
  // Setting the `lockSsfi` flag to `true` prevents the overwritten assertion
72
72
  // from changing the `ssfi` flag. By this point, the `ssfi` flag is already
73
73
  // set to the correct starting point for this assertion.
74
- var origLockSsfi = flag(this, 'lockSsfi');
74
+ let origLockSsfi = flag(this, 'lockSsfi');
75
75
  flag(this, 'lockSsfi', true);
76
- var result = method(_super).apply(this, arguments);
76
+ let result = method(_super).apply(this, arguments);
77
77
  flag(this, 'lockSsfi', origLockSsfi);
78
78
 
79
79
  if (result !== undefined) {
80
80
  return result;
81
81
  }
82
82
 
83
- var newAssertion = new Assertion();
83
+ let newAssertion = new Assertion();
84
84
  transferFlags(this, newAssertion);
85
85
  return newAssertion;
86
86
  };
@@ -42,7 +42,7 @@ import {transferFlags} from './transferFlags.js';
42
42
  * @public
43
43
  */
44
44
  export function overwriteProperty(ctx, name, getter) {
45
- var _get = Object.getOwnPropertyDescriptor(ctx, name),
45
+ let _get = Object.getOwnPropertyDescriptor(ctx, name),
46
46
  _super = function () {};
47
47
 
48
48
  if (_get && 'function' === typeof _get.get) _super = _get.get;
@@ -71,16 +71,16 @@ export function overwriteProperty(ctx, name, getter) {
71
71
  // Setting the `lockSsfi` flag to `true` prevents the overwritten
72
72
  // assertion from changing the `ssfi` flag. By this point, the `ssfi`
73
73
  // flag is already set to the correct starting point for this assertion.
74
- var origLockSsfi = flag(this, 'lockSsfi');
74
+ let origLockSsfi = flag(this, 'lockSsfi');
75
75
  flag(this, 'lockSsfi', true);
76
- var result = getter(_super).call(this);
76
+ let result = getter(_super).call(this);
77
77
  flag(this, 'lockSsfi', origLockSsfi);
78
78
 
79
79
  if (result !== undefined) {
80
80
  return result;
81
81
  }
82
82
 
83
- var newAssertion = new Assertion();
83
+ let newAssertion = new Assertion();
84
84
  transferFlags(this, newAssertion);
85
85
  return newAssertion;
86
86
  },
@@ -9,6 +9,7 @@ import {isProxyEnabled} from './isProxyEnabled.js';
9
9
  * MIT Licensed
10
10
  */
11
11
 
12
+ /** @type {PropertyKey[]} */
12
13
  const builtins = ['__flags', '__methods', '_obj', 'assert'];
13
14
 
14
15
  /**
@@ -24,11 +25,11 @@ const builtins = ['__flags', '__methods', '_obj', 'assert'];
24
25
  * If proxies are unsupported or disabled via the user's Chai config, then
25
26
  * return object without modification.
26
27
  *
27
- * @param {object} obj
28
- * @param {string} nonChainableMethodName
29
- * @returns {unknown}
30
28
  * @namespace Utils
31
- * @name proxify
29
+ * @template {object} T
30
+ * @param {T} obj
31
+ * @param {string} [nonChainableMethodName]
32
+ * @returns {T}
32
33
  */
33
34
  export function proxify(obj, nonChainableMethodName) {
34
35
  if (!isProxyEnabled()) return obj;
@@ -60,8 +61,8 @@ export function proxify(obj, nonChainableMethodName) {
60
61
  // If the property is reasonably close to an existing Chai property,
61
62
  // suggest that property to the user. Only suggest properties with a
62
63
  // distance less than 4.
63
- var suggestion = null;
64
- var suggestionDistance = 4;
64
+ let suggestion = null;
65
+ let suggestionDistance = 4;
65
66
  getProperties(target).forEach(function (prop) {
66
67
  if (
67
68
  // we actually mean to check `Object.prototype` here
@@ -69,7 +70,7 @@ export function proxify(obj, nonChainableMethodName) {
69
70
  !Object.prototype.hasOwnProperty(prop) &&
70
71
  builtins.indexOf(prop) === -1
71
72
  ) {
72
- var dist = stringDistanceCapped(property, prop, suggestionDistance);
73
+ let dist = stringDistanceCapped(property, prop, suggestionDistance);
73
74
  if (dist < suggestionDistance) {
74
75
  suggestion = prop;
75
76
  suggestionDistance = dist;
@@ -126,7 +127,7 @@ function stringDistanceCapped(strA, strB, cap) {
126
127
  return cap;
127
128
  }
128
129
 
129
- var memo = [];
130
+ let memo = [];
130
131
  // `memo` is a two-dimensional array containing distances.
131
132
  // memo[i][j] is the distance between strA.slice(0, i) and
132
133
  // strB.slice(0, j).
@@ -139,7 +140,7 @@ function stringDistanceCapped(strA, strB, cap) {
139
140
  }
140
141
 
141
142
  for (let i = 1; i <= strA.length; i++) {
142
- var ch = strA.charCodeAt(i - 1);
143
+ let ch = strA.charCodeAt(i - 1);
143
144
  for (let j = 1; j <= strB.length; j++) {
144
145
  if (Math.abs(i - j) >= cap) {
145
146
  memo[i][j] = cap;
@@ -18,7 +18,7 @@ import {flag} from './flag.js';
18
18
  * @name test
19
19
  */
20
20
  export function test(obj, args) {
21
- var negate = flag(obj, 'negate'),
21
+ let negate = flag(obj, 'negate'),
22
22
  expr = args[0];
23
23
  return negate ? !expr : expr;
24
24
  }
@@ -26,7 +26,7 @@
26
26
  * @private
27
27
  */
28
28
  export function transferFlags(assertion, object, includeAll) {
29
- var flags = assertion.__flags || (assertion.__flags = Object.create(null));
29
+ let flags = assertion.__flags || (assertion.__flags = Object.create(null));
30
30
 
31
31
  if (!object.__flags) {
32
32
  object.__flags = Object.create(null);
@@ -34,7 +34,7 @@ export function transferFlags(assertion, object, includeAll) {
34
34
 
35
35
  includeAll = arguments.length === 3 ? includeAll : true;
36
36
 
37
- for (var flag in flags) {
37
+ for (let flag in flags) {
38
38
  if (
39
39
  includeAll ||
40
40
  (flag !== 'object' &&
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.2.0",
21
+ "version": "5.2.1",
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "https://github.com/chaijs/chai"
@@ -39,10 +39,11 @@
39
39
  "lint": "npm run lint:js && npm run lint:format",
40
40
  "lint:js": "eslint lib/",
41
41
  "lint:format": "prettier --check lib",
42
+ "lint:types": "tsc",
42
43
  "clean": "rm -rf chai.js coverage/"
43
44
  },
44
45
  "engines": {
45
- "node": ">=12"
46
+ "node": ">=18"
46
47
  },
47
48
  "dependencies": {
48
49
  "assertion-error": "^2.0.1",
@@ -58,10 +59,11 @@
58
59
  "@web/test-runner": "^0.18.0",
59
60
  "@web/test-runner-playwright": "^0.11.0",
60
61
  "c8": "^10.1.3",
61
- "esbuild": "^0.19.10",
62
+ "esbuild": "^0.25.0",
62
63
  "eslint": "^8.56.0",
63
64
  "eslint-plugin-jsdoc": "^48.0.4",
64
65
  "mocha": "^10.2.0",
65
- "prettier": "^3.4.2"
66
+ "prettier": "^3.4.2",
67
+ "typescript": "~5.7.3"
66
68
  }
67
69
  }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
6
+ "types": [],
7
+ "checkJs": true,
8
+ "noEmit": true,
9
+ "isolatedModules": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "strict": true,
12
+ "noUnusedLocals": true,
13
+ "noUnusedParameters": true
14
+ },
15
+ "include": [
16
+ "lib/**/*.js"
17
+ ]
18
+ }