chai 4.3.10 → 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.
Files changed (51) hide show
  1. package/CONTRIBUTING.md +7 -1
  2. package/README.md +13 -71
  3. package/chai.js +3616 -11088
  4. package/eslint.config.js +12 -0
  5. package/index.js +1 -1
  6. package/lib/chai/assertion.js +152 -163
  7. package/lib/chai/config.js +35 -15
  8. package/lib/chai/core/assertions.js +3737 -3656
  9. package/lib/chai/interface/assert.js +2984 -3046
  10. package/lib/chai/interface/expect.js +45 -37
  11. package/lib/chai/interface/should.js +203 -201
  12. package/lib/chai/utils/addChainableMethod.js +14 -19
  13. package/lib/chai/utils/addLengthGuard.js +6 -6
  14. package/lib/chai/utils/addMethod.js +13 -14
  15. package/lib/chai/utils/addProperty.js +12 -13
  16. package/lib/chai/utils/compareByInspect.js +7 -12
  17. package/lib/chai/utils/expectTypes.js +9 -10
  18. package/lib/chai/utils/flag.js +7 -7
  19. package/lib/chai/utils/getActual.js +5 -5
  20. package/lib/chai/utils/getEnumerableProperties.js +2 -3
  21. package/lib/chai/utils/getMessage.js +9 -13
  22. package/lib/chai/utils/getOperator.js +13 -10
  23. package/lib/chai/utils/getOwnEnumerableProperties.js +5 -10
  24. package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +4 -5
  25. package/lib/chai/utils/getProperties.js +7 -5
  26. package/lib/chai/utils/index.js +74 -140
  27. package/lib/chai/utils/inspect.js +9 -11
  28. package/lib/chai/utils/isNaN.js +5 -5
  29. package/lib/chai/utils/isProxyEnabled.js +4 -4
  30. package/lib/chai/utils/objDisplay.js +6 -11
  31. package/lib/chai/utils/overwriteChainableMethod.js +13 -14
  32. package/lib/chai/utils/overwriteMethod.js +18 -19
  33. package/lib/chai/utils/overwriteProperty.js +17 -19
  34. package/lib/chai/utils/proxify.js +15 -15
  35. package/lib/chai/utils/test.js +6 -10
  36. package/lib/chai/utils/transferFlags.js +6 -8
  37. package/lib/chai/utils/type-detect.js +20 -0
  38. package/lib/chai.js +35 -62
  39. package/package.json +25 -27
  40. package/register-assert.cjs +3 -0
  41. package/register-assert.js +3 -1
  42. package/register-expect.cjs +3 -0
  43. package/register-expect.js +3 -1
  44. package/register-should.cjs +3 -0
  45. package/register-should.js +3 -1
  46. package/web-test-runner.config.js +20 -0
  47. package/bower.json +0 -26
  48. package/index.mjs +0 -14
  49. package/karma.conf.js +0 -34
  50. package/karma.sauce.js +0 -41
  51. package/sauce.browsers.js +0 -106
@@ -4,44 +4,52 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- module.exports = function (chai, util) {
8
- chai.expect = function (val, message) {
9
- return new chai.Assertion(val, message);
10
- };
7
+ import * as chai from '../../../index.js';
8
+ import {Assertion} from '../assertion.js';
9
+ import {AssertionError} from 'assertion-error';
11
10
 
12
- /**
13
- * ### .fail([message])
14
- * ### .fail(actual, expected, [message], [operator])
15
- *
16
- * Throw a failure.
17
- *
18
- * expect.fail();
19
- * expect.fail("custom error message");
20
- * expect.fail(1, 2);
21
- * expect.fail(1, 2, "custom error message");
22
- * expect.fail(1, 2, "custom error message", ">");
23
- * expect.fail(1, 2, undefined, ">");
24
- *
25
- * @name fail
26
- * @param {Mixed} actual
27
- * @param {Mixed} expected
28
- * @param {String} message
29
- * @param {String} operator
30
- * @namespace BDD
31
- * @api public
32
- */
11
+ /**
12
+ * @param {unknown} val
13
+ * @param {string} message
14
+ * @returns {Assertion}
15
+ */
16
+ function expect(val, message) {
17
+ return new Assertion(val, message);
18
+ }
19
+
20
+ export {expect};
33
21
 
34
- chai.expect.fail = function (actual, expected, message, operator) {
35
- if (arguments.length < 2) {
36
- message = actual;
37
- actual = undefined;
38
- }
22
+ /**
23
+ * ### .fail([message])
24
+ * ### .fail(actual, expected, [message], [operator])
25
+ *
26
+ * Throw a failure.
27
+ *
28
+ * expect.fail();
29
+ * expect.fail("custom error message");
30
+ * expect.fail(1, 2);
31
+ * expect.fail(1, 2, "custom error message");
32
+ * expect.fail(1, 2, "custom error message", ">");
33
+ * expect.fail(1, 2, undefined, ">");
34
+ *
35
+ * @name fail
36
+ * @param {unknown} actual
37
+ * @param {unknown} expected
38
+ * @param {string} message
39
+ * @param {string} operator
40
+ * @namespace expect
41
+ * @public
42
+ */
43
+ expect.fail = function (actual, expected, message, operator) {
44
+ if (arguments.length < 2) {
45
+ message = actual;
46
+ actual = undefined;
47
+ }
39
48
 
40
- message = message || 'expect.fail()';
41
- throw new chai.AssertionError(message, {
42
- actual: actual
43
- , expected: expected
44
- , operator: operator
45
- }, chai.expect.fail);
46
- };
49
+ message = message || 'expect.fail()';
50
+ throw new AssertionError(message, {
51
+ actual: actual
52
+ , expected: expected
53
+ , operator: operator
54
+ }, chai.expect.fail);
47
55
  };
@@ -4,216 +4,218 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- module.exports = function (chai, util) {
8
- var Assertion = chai.Assertion;
7
+ import {Assertion} from '../assertion.js';
8
+ import {AssertionError} from 'assertion-error';
9
9
 
10
- function loadShould () {
11
- // explicitly define this method as function as to have it's name to include as `ssfi`
12
- function shouldGetter() {
13
- if (this instanceof String
14
- || this instanceof Number
15
- || this instanceof Boolean
16
- || typeof Symbol === 'function' && this instanceof Symbol
17
- || typeof BigInt === 'function' && this instanceof BigInt) {
18
- return new Assertion(this.valueOf(), null, shouldGetter);
19
- }
20
- return new Assertion(this, null, shouldGetter);
21
- }
22
- function shouldSetter(value) {
23
- // See https://github.com/chaijs/chai/issues/86: this makes
24
- // `whatever.should = someValue` actually set `someValue`, which is
25
- // especially useful for `global.should = require('chai').should()`.
26
- //
27
- // Note that we have to use [[DefineProperty]] instead of [[Put]]
28
- // since otherwise we would trigger this very setter!
29
- Object.defineProperty(this, 'should', {
30
- value: value,
31
- enumerable: true,
32
- configurable: true,
33
- writable: true
34
- });
10
+ /**
11
+ * @returns {void}
12
+ */
13
+ function loadShould () {
14
+ // explicitly define this method as function as to have it's name to include as `ssfi`
15
+ /**
16
+ * @returns {Assertion}
17
+ */
18
+ function shouldGetter() {
19
+ if (this instanceof String
20
+ || this instanceof Number
21
+ || this instanceof Boolean
22
+ || typeof Symbol === 'function' && this instanceof Symbol
23
+ || typeof BigInt === 'function' && this instanceof BigInt) {
24
+ return new Assertion(this.valueOf(), null, shouldGetter);
35
25
  }
36
- // modify Object.prototype to have `should`
37
- Object.defineProperty(Object.prototype, 'should', {
38
- set: shouldSetter
39
- , get: shouldGetter
40
- , configurable: true
26
+ return new Assertion(this, null, shouldGetter);
27
+ }
28
+ /**
29
+ * @param {unknown} value
30
+ */
31
+ function shouldSetter(value) {
32
+ // See https://github.com/chaijs/chai/issues/86: this makes
33
+ // `whatever.should = someValue` actually set `someValue`, which is
34
+ // especially useful for `global.should = require('chai').should()`.
35
+ //
36
+ // Note that we have to use [[DefineProperty]] instead of [[Put]]
37
+ // since otherwise we would trigger this very setter!
38
+ Object.defineProperty(this, 'should', {
39
+ value: value,
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true
41
43
  });
42
-
43
- var should = {};
44
-
45
- /**
46
- * ### .fail([message])
47
- * ### .fail(actual, expected, [message], [operator])
48
- *
49
- * Throw a failure.
50
- *
51
- * should.fail();
52
- * should.fail("custom error message");
53
- * should.fail(1, 2);
54
- * should.fail(1, 2, "custom error message");
55
- * should.fail(1, 2, "custom error message", ">");
56
- * should.fail(1, 2, undefined, ">");
57
- *
58
- *
59
- * @name fail
60
- * @param {Mixed} actual
61
- * @param {Mixed} expected
62
- * @param {String} message
63
- * @param {String} operator
64
- * @namespace BDD
65
- * @api public
66
- */
67
-
68
- should.fail = function (actual, expected, message, operator) {
69
- if (arguments.length < 2) {
70
- message = actual;
71
- actual = undefined;
72
- }
73
-
74
- message = message || 'should.fail()';
75
- throw new chai.AssertionError(message, {
76
- actual: actual
77
- , expected: expected
78
- , operator: operator
79
- }, should.fail);
80
- };
81
-
82
- /**
83
- * ### .equal(actual, expected, [message])
84
- *
85
- * Asserts non-strict equality (`==`) of `actual` and `expected`.
86
- *
87
- * should.equal(3, '3', '== coerces values to strings');
88
- *
89
- * @name equal
90
- * @param {Mixed} actual
91
- * @param {Mixed} expected
92
- * @param {String} message
93
- * @namespace Should
94
- * @api public
95
- */
96
-
97
- should.equal = function (val1, val2, msg) {
98
- new Assertion(val1, msg).to.equal(val2);
99
- };
100
-
101
- /**
102
- * ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
103
- *
104
- * Asserts that `function` will throw an error that is an instance of
105
- * `constructor`, or alternately that it will throw an error with message
106
- * matching `regexp`.
107
- *
108
- * should.throw(fn, 'function throws a reference error');
109
- * should.throw(fn, /function throws a reference error/);
110
- * should.throw(fn, ReferenceError);
111
- * should.throw(fn, ReferenceError, 'function throws a reference error');
112
- * should.throw(fn, ReferenceError, /function throws a reference error/);
113
- *
114
- * @name throw
115
- * @alias Throw
116
- * @param {Function} function
117
- * @param {ErrorConstructor} constructor
118
- * @param {RegExp} regexp
119
- * @param {String} message
120
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
121
- * @namespace Should
122
- * @api public
123
- */
124
-
125
- should.Throw = function (fn, errt, errs, msg) {
126
- new Assertion(fn, msg).to.Throw(errt, errs);
127
- };
128
-
129
- /**
130
- * ### .exist
131
- *
132
- * Asserts that the target is neither `null` nor `undefined`.
133
- *
134
- * var foo = 'hi';
135
- *
136
- * should.exist(foo, 'foo exists');
137
- *
138
- * @name exist
139
- * @namespace Should
140
- * @api public
141
- */
142
-
143
- should.exist = function (val, msg) {
144
- new Assertion(val, msg).to.exist;
44
+ }
45
+ // modify Object.prototype to have `should`
46
+ Object.defineProperty(Object.prototype, 'should', {
47
+ set: shouldSetter
48
+ , get: shouldGetter
49
+ , configurable: true
50
+ });
51
+
52
+ var should = {};
53
+
54
+ /**
55
+ * ### .fail([message])
56
+ * ### .fail(actual, expected, [message], [operator])
57
+ *
58
+ * Throw a failure.
59
+ *
60
+ * should.fail();
61
+ * should.fail("custom error message");
62
+ * should.fail(1, 2);
63
+ * should.fail(1, 2, "custom error message");
64
+ * should.fail(1, 2, "custom error message", ">");
65
+ * should.fail(1, 2, undefined, ">");
66
+ *
67
+ * @name fail
68
+ * @param {unknown} actual
69
+ * @param {unknown} expected
70
+ * @param {string} message
71
+ * @param {string} operator
72
+ * @namespace BDD
73
+ * @public
74
+ */
75
+ should.fail = function (actual, expected, message, operator) {
76
+ if (arguments.length < 2) {
77
+ message = actual;
78
+ actual = undefined;
145
79
  }
146
80
 
147
- // negation
148
- should.not = {}
149
-
150
- /**
151
- * ### .not.equal(actual, expected, [message])
152
- *
153
- * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
154
- *
155
- * should.not.equal(3, 4, 'these numbers are not equal');
156
- *
157
- * @name not.equal
158
- * @param {Mixed} actual
159
- * @param {Mixed} expected
160
- * @param {String} message
161
- * @namespace Should
162
- * @api public
163
- */
164
-
165
- should.not.equal = function (val1, val2, msg) {
166
- new Assertion(val1, msg).to.not.equal(val2);
167
- };
168
-
169
- /**
170
- * ### .throw(function, [constructor/regexp], [message])
171
- *
172
- * Asserts that `function` will _not_ throw an error that is an instance of
173
- * `constructor`, or alternately that it will not throw an error with message
174
- * matching `regexp`.
175
- *
176
- * should.not.throw(fn, Error, 'function does not throw');
177
- *
178
- * @name not.throw
179
- * @alias not.Throw
180
- * @param {Function} function
181
- * @param {ErrorConstructor} constructor
182
- * @param {RegExp} regexp
183
- * @param {String} message
184
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
185
- * @namespace Should
186
- * @api public
187
- */
188
-
189
- should.not.Throw = function (fn, errt, errs, msg) {
190
- new Assertion(fn, msg).to.not.Throw(errt, errs);
191
- };
81
+ message = message || 'should.fail()';
82
+ throw new AssertionError(message, {
83
+ actual: actual
84
+ , expected: expected
85
+ , operator: operator
86
+ }, should.fail);
87
+ };
192
88
 
193
- /**
194
- * ### .not.exist
195
- *
196
- * Asserts that the target is neither `null` nor `undefined`.
197
- *
198
- * var bar = null;
199
- *
200
- * should.not.exist(bar, 'bar does not exist');
201
- *
202
- * @name not.exist
203
- * @namespace Should
204
- * @api public
205
- */
89
+ /**
90
+ * ### .equal(actual, expected, [message])
91
+ *
92
+ * Asserts non-strict equality (`==`) of `actual` and `expected`.
93
+ *
94
+ * should.equal(3, '3', '== coerces values to strings');
95
+ *
96
+ * @name equal
97
+ * @param {unknown} actual
98
+ * @param {unknown} expected
99
+ * @param {string} message
100
+ * @namespace Should
101
+ * @public
102
+ */
103
+ should.equal = function (actual, expected, message) {
104
+ new Assertion(actual, message).to.equal(expected);
105
+ };
206
106
 
207
- should.not.exist = function (val, msg) {
208
- new Assertion(val, msg).to.not.exist;
209
- }
107
+ /**
108
+ * ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
109
+ *
110
+ * Asserts that `function` will throw an error that is an instance of
111
+ * `constructor`, or alternately that it will throw an error with message
112
+ * matching `regexp`.
113
+ *
114
+ * should.throw(fn, 'function throws a reference error');
115
+ * should.throw(fn, /function throws a reference error/);
116
+ * should.throw(fn, ReferenceError);
117
+ * should.throw(fn, ReferenceError, 'function throws a reference error');
118
+ * should.throw(fn, ReferenceError, /function throws a reference error/);
119
+ *
120
+ * @name throw
121
+ * @alias Throw
122
+ * @param {Function} fn
123
+ * @param {Error} errt
124
+ * @param {RegExp} errs
125
+ * @param {string} msg
126
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
127
+ * @namespace Should
128
+ * @public
129
+ */
130
+ should.Throw = function (fn, errt, errs, msg) {
131
+ new Assertion(fn, msg).to.Throw(errt, errs);
132
+ };
210
133
 
211
- should['throw'] = should['Throw'];
212
- should.not['throw'] = should.not['Throw'];
134
+ /**
135
+ * ### .exist
136
+ *
137
+ * Asserts that the target is neither `null` nor `undefined`.
138
+ *
139
+ * var foo = 'hi';
140
+ * should.exist(foo, 'foo exists');
141
+ *
142
+ * @param {unknown} val
143
+ * @param {string} msg
144
+ * @name exist
145
+ * @namespace Should
146
+ * @public
147
+ */
148
+ should.exist = function (val, msg) {
149
+ new Assertion(val, msg).to.exist;
150
+ }
151
+
152
+ // negation
153
+ should.not = {}
154
+
155
+ /**
156
+ * ### .not.equal(actual, expected, [message])
157
+ *
158
+ * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
159
+ *
160
+ * should.not.equal(3, 4, 'these numbers are not equal');
161
+ *
162
+ * @name not.equal
163
+ * @param {unknown} actual
164
+ * @param {unknown} expected
165
+ * @param {string} msg
166
+ * @namespace Should
167
+ * @public
168
+ */
169
+ should.not.equal = function (actual, expected, msg) {
170
+ new Assertion(actual, msg).to.not.equal(expected);
171
+ };
213
172
 
214
- return should;
173
+ /**
174
+ * ### .throw(function, [constructor/regexp], [message])
175
+ *
176
+ * Asserts that `function` will _not_ throw an error that is an instance of
177
+ * `constructor`, or alternately that it will not throw an error with message
178
+ * matching `regexp`.
179
+ *
180
+ * should.not.throw(fn, Error, 'function does not throw');
181
+ *
182
+ * @name not.throw
183
+ * @alias not.Throw
184
+ * @param {Function} fn
185
+ * @param {Error} errt
186
+ * @param {RegExp} errs
187
+ * @param {string} msg
188
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
189
+ * @namespace Should
190
+ * @public
191
+ */
192
+ should.not.Throw = function (fn, errt, errs, msg) {
193
+ new Assertion(fn, msg).to.not.Throw(errt, errs);
215
194
  };
216
195
 
217
- chai.should = loadShould;
218
- chai.Should = loadShould;
196
+ /**
197
+ * ### .not.exist
198
+ *
199
+ * Asserts that the target is neither `null` nor `undefined`.
200
+ *
201
+ * var bar = null;
202
+ * should.not.exist(bar, 'bar does not exist');
203
+ *
204
+ * @namespace Should
205
+ * @name not.exist
206
+ * @param {unknown} val
207
+ * @param {string} msg
208
+ * @public
209
+ */
210
+ should.not.exist = function (val, msg) {
211
+ new Assertion(val, msg).to.not.exist;
212
+ }
213
+
214
+ should['throw'] = should['Throw'];
215
+ should.not['throw'] = should.not['Throw'];
216
+
217
+ return should;
219
218
  };
219
+
220
+ export const should = loadShould;
221
+ export const Should = loadShould;
@@ -4,17 +4,13 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- /*!
8
- * Module dependencies
9
- */
10
-
11
- var addLengthGuard = require('./addLengthGuard');
12
- var chai = require('../../chai');
13
- var flag = require('./flag');
14
- var proxify = require('./proxify');
15
- var transferFlags = require('./transferFlags');
7
+ import {Assertion} from '../assertion.js';
8
+ import {addLengthGuard} from './addLengthGuard.js';
9
+ import {flag} from './flag.js';
10
+ import {proxify} from './proxify.js';
11
+ import {transferFlags} from './transferFlags.js';
16
12
 
17
- /*!
13
+ /**
18
14
  * Module variables
19
15
  */
20
16
 
@@ -47,8 +43,8 @@ var call = Function.prototype.call,
47
43
  * Adds a method to an object, such that the method can also be chained.
48
44
  *
49
45
  * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
50
- * var obj = utils.flag(this, 'object');
51
- * new chai.Assertion(obj).to.be.equal(str);
46
+ * var obj = utils.flag(this, 'object');
47
+ * new chai.Assertion(obj).to.be.equal(str);
52
48
  * });
53
49
  *
54
50
  * Can also be accessed directly from `chai.Assertion`.
@@ -61,16 +57,15 @@ var call = Function.prototype.call,
61
57
  * expect(fooStr).to.be.foo('bar');
62
58
  * expect(fooStr).to.be.foo.equal('foo');
63
59
  *
64
- * @param {Object} ctx object to which the method is added
65
- * @param {String} name of method to add
60
+ * @param {object} ctx object to which the method is added
61
+ * @param {string} name of method to add
66
62
  * @param {Function} method function to be used for `name`, when called
67
63
  * @param {Function} chainingBehavior function to be called every time the property is accessed
68
64
  * @namespace Utils
69
65
  * @name addChainableMethod
70
- * @api public
66
+ * @public
71
67
  */
72
-
73
- module.exports = function addChainableMethod(ctx, name, method, chainingBehavior) {
68
+ export function addChainableMethod(ctx, name, method, chainingBehavior) {
74
69
  if (typeof chainingBehavior !== 'function') {
75
70
  chainingBehavior = function () { };
76
71
  }
@@ -115,7 +110,7 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
115
110
  return result;
116
111
  }
117
112
 
118
- var newAssertion = new chai.Assertion();
113
+ var newAssertion = new Assertion();
119
114
  transferFlags(this, newAssertion);
120
115
  return newAssertion;
121
116
  };
@@ -149,4 +144,4 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
149
144
  }
150
145
  , configurable: true
151
146
  });
152
- };
147
+ }
@@ -1,4 +1,4 @@
1
- var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
1
+ const fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
2
2
 
3
3
  /*!
4
4
  * Chai - addLengthGuard utility
@@ -34,13 +34,13 @@ var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
34
34
  * environments is the priority.
35
35
  *
36
36
  * @param {Function} fn
37
- * @param {String} assertionName
38
- * @param {Boolean} isChainable
37
+ * @param {string} assertionName
38
+ * @param {boolean} isChainable
39
+ * @returns {unknown}
39
40
  * @namespace Utils
40
41
  * @name addLengthGuard
41
42
  */
42
-
43
- module.exports = function addLengthGuard (fn, assertionName, isChainable) {
43
+ export function addLengthGuard(fn, assertionName, isChainable) {
44
44
  if (!fnLengthDesc.configurable) return fn;
45
45
 
46
46
  Object.defineProperty(fn, 'length', {
@@ -57,4 +57,4 @@ module.exports = function addLengthGuard (fn, assertionName, isChainable) {
57
57
  });
58
58
 
59
59
  return fn;
60
- };
60
+ }
@@ -4,11 +4,11 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- var addLengthGuard = require('./addLengthGuard');
8
- var chai = require('../../chai');
9
- var flag = require('./flag');
10
- var proxify = require('./proxify');
11
- var transferFlags = require('./transferFlags');
7
+ import {addLengthGuard} from './addLengthGuard.js';
8
+ import {flag} from './flag.js';
9
+ import {proxify} from './proxify.js';
10
+ import {transferFlags} from './transferFlags.js';
11
+ import {Assertion} from '../assertion.js';
12
12
 
13
13
  /**
14
14
  * ### .addMethod(ctx, name, method)
@@ -16,8 +16,8 @@ var transferFlags = require('./transferFlags');
16
16
  * Adds a method to the prototype of an object.
17
17
  *
18
18
  * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
19
- * var obj = utils.flag(this, 'object');
20
- * new chai.Assertion(obj).to.be.equal(str);
19
+ * var obj = utils.flag(this, 'object');
20
+ * new chai.Assertion(obj).to.be.equal(str);
21
21
  * });
22
22
  *
23
23
  * Can also be accessed directly from `chai.Assertion`.
@@ -28,15 +28,14 @@ var transferFlags = require('./transferFlags');
28
28
  *
29
29
  * expect(fooStr).to.be.foo('bar');
30
30
  *
31
- * @param {Object} ctx object to which the method is added
32
- * @param {String} name of method to add
31
+ * @param {object} ctx object to which the method is added
32
+ * @param {string} name of method to add
33
33
  * @param {Function} method function to be used for name
34
34
  * @namespace Utils
35
35
  * @name addMethod
36
- * @api public
36
+ * @public
37
37
  */
38
-
39
- module.exports = function addMethod(ctx, name, method) {
38
+ export function addMethod(ctx, name, method) {
40
39
  var methodWrapper = function () {
41
40
  // Setting the `ssfi` flag to `methodWrapper` causes this function to be the
42
41
  // starting point for removing implementation frames from the stack trace of
@@ -58,11 +57,11 @@ module.exports = function addMethod(ctx, name, method) {
58
57
  if (result !== undefined)
59
58
  return result;
60
59
 
61
- var newAssertion = new chai.Assertion();
60
+ var newAssertion = new Assertion();
62
61
  transferFlags(this, newAssertion);
63
62
  return newAssertion;
64
63
  };
65
64
 
66
65
  addLengthGuard(methodWrapper, name, false);
67
66
  ctx[name] = proxify(methodWrapper, name);
68
- };
67
+ }