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.
- package/CONTRIBUTING.md +7 -1
- package/README.md +13 -71
- package/chai.js +3616 -11088
- package/eslint.config.js +12 -0
- package/index.js +1 -1
- package/lib/chai/assertion.js +152 -163
- package/lib/chai/config.js +35 -15
- package/lib/chai/core/assertions.js +3737 -3656
- package/lib/chai/interface/assert.js +2984 -3046
- package/lib/chai/interface/expect.js +45 -37
- package/lib/chai/interface/should.js +203 -201
- package/lib/chai/utils/addChainableMethod.js +14 -19
- package/lib/chai/utils/addLengthGuard.js +6 -6
- package/lib/chai/utils/addMethod.js +13 -14
- package/lib/chai/utils/addProperty.js +12 -13
- package/lib/chai/utils/compareByInspect.js +7 -12
- package/lib/chai/utils/expectTypes.js +9 -10
- package/lib/chai/utils/flag.js +7 -7
- package/lib/chai/utils/getActual.js +5 -5
- package/lib/chai/utils/getEnumerableProperties.js +2 -3
- package/lib/chai/utils/getMessage.js +9 -13
- package/lib/chai/utils/getOperator.js +13 -10
- package/lib/chai/utils/getOwnEnumerableProperties.js +5 -10
- package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +4 -5
- package/lib/chai/utils/getProperties.js +7 -5
- package/lib/chai/utils/index.js +74 -140
- package/lib/chai/utils/inspect.js +9 -11
- package/lib/chai/utils/isNaN.js +5 -5
- package/lib/chai/utils/isProxyEnabled.js +4 -4
- package/lib/chai/utils/objDisplay.js +6 -11
- package/lib/chai/utils/overwriteChainableMethod.js +13 -14
- package/lib/chai/utils/overwriteMethod.js +18 -19
- package/lib/chai/utils/overwriteProperty.js +17 -19
- package/lib/chai/utils/proxify.js +15 -15
- package/lib/chai/utils/test.js +6 -10
- package/lib/chai/utils/transferFlags.js +6 -8
- package/lib/chai/utils/type-detect.js +20 -0
- package/lib/chai.js +35 -62
- package/package.json +25 -27
- package/register-assert.cjs +3 -0
- package/register-assert.js +3 -1
- package/register-expect.cjs +3 -0
- package/register-expect.js +3 -1
- package/register-should.cjs +3 -0
- package/register-should.js +3 -1
- package/web-test-runner.config.js +20 -0
- package/bower.json +0 -26
- package/index.mjs +0 -14
- package/karma.conf.js +0 -34
- package/karma.sauce.js +0 -41
- package/sauce.browsers.js +0 -106
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {Assertion} from '../assertion.js';
|
|
8
|
+
import {flag} from './flag.js';
|
|
9
|
+
import {isProxyEnabled} from './isProxyEnabled.js';
|
|
10
|
+
import {transferFlags} from './transferFlags.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* ### .addProperty(ctx, name, getter)
|
|
@@ -15,8 +15,8 @@ var transferFlags = require('./transferFlags');
|
|
|
15
15
|
* Adds a property to the prototype of an object.
|
|
16
16
|
*
|
|
17
17
|
* utils.addProperty(chai.Assertion.prototype, 'foo', function () {
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* var obj = utils.flag(this, 'object');
|
|
19
|
+
* new chai.Assertion(obj).to.be.instanceof(Foo);
|
|
20
20
|
* });
|
|
21
21
|
*
|
|
22
22
|
* Can also be accessed directly from `chai.Assertion`.
|
|
@@ -27,15 +27,14 @@ var transferFlags = require('./transferFlags');
|
|
|
27
27
|
*
|
|
28
28
|
* expect(myFoo).to.be.foo;
|
|
29
29
|
*
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
30
|
+
* @param {object} ctx object to which the property is added
|
|
31
|
+
* @param {string} name of property to add
|
|
32
32
|
* @param {Function} getter function to be used for name
|
|
33
33
|
* @namespace Utils
|
|
34
34
|
* @name addProperty
|
|
35
|
-
* @
|
|
35
|
+
* @public
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
module.exports = function addProperty(ctx, name, getter) {
|
|
37
|
+
export function addProperty(ctx, name, getter) {
|
|
39
38
|
getter = getter === undefined ? function () {} : getter;
|
|
40
39
|
|
|
41
40
|
Object.defineProperty(ctx, name,
|
|
@@ -63,10 +62,10 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
63
62
|
if (result !== undefined)
|
|
64
63
|
return result;
|
|
65
64
|
|
|
66
|
-
var newAssertion = new
|
|
65
|
+
var newAssertion = new Assertion();
|
|
67
66
|
transferFlags(this, newAssertion);
|
|
68
67
|
return newAssertion;
|
|
69
68
|
}
|
|
70
69
|
, configurable: true
|
|
71
70
|
});
|
|
72
|
-
}
|
|
71
|
+
}
|
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var inspect = require('./inspect');
|
|
7
|
+
import {inspect} from './inspect.js';
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* ### .compareByInspect(mixed, mixed)
|
|
@@ -18,14 +14,13 @@ var inspect = require('./inspect');
|
|
|
18
14
|
* and objects with irregular/missing toString can still be sorted without a
|
|
19
15
|
* TypeError.
|
|
20
16
|
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @returns {
|
|
17
|
+
* @param {unknown} a first element to compare
|
|
18
|
+
* @param {unknown} b second element to compare
|
|
19
|
+
* @returns {number} -1 if 'a' should come before 'b'; otherwise 1
|
|
24
20
|
* @name compareByInspect
|
|
25
21
|
* @namespace Utils
|
|
26
|
-
* @
|
|
22
|
+
* @public
|
|
27
23
|
*/
|
|
28
|
-
|
|
29
|
-
module.exports = function compareByInspect(a, b) {
|
|
24
|
+
export function compareByInspect(a, b) {
|
|
30
25
|
return inspect(a) < inspect(b) ? -1 : 1;
|
|
31
|
-
}
|
|
26
|
+
}
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import {AssertionError} from 'assertion-error';
|
|
8
|
+
import {flag} from './flag.js';
|
|
9
|
+
import {type} from './type-detect.js';
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* ### .expectTypes(obj, types)
|
|
9
13
|
*
|
|
@@ -11,18 +15,13 @@
|
|
|
11
15
|
*
|
|
12
16
|
* utils.expectTypes(this, ['array', 'object', 'string']);
|
|
13
17
|
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Array}
|
|
18
|
+
* @param {unknown} obj constructed Assertion
|
|
19
|
+
* @param {Array} types A list of allowed types for this assertion
|
|
16
20
|
* @namespace Utils
|
|
17
21
|
* @name expectTypes
|
|
18
|
-
* @
|
|
22
|
+
* @public
|
|
19
23
|
*/
|
|
20
|
-
|
|
21
|
-
var AssertionError = require('assertion-error');
|
|
22
|
-
var flag = require('./flag');
|
|
23
|
-
var type = require('type-detect');
|
|
24
|
-
|
|
25
|
-
module.exports = function expectTypes(obj, types) {
|
|
24
|
+
export function expectTypes(obj, types) {
|
|
26
25
|
var flagMsg = flag(obj, 'message');
|
|
27
26
|
var ssfi = flag(obj, 'ssfi');
|
|
28
27
|
|
|
@@ -48,4 +47,4 @@ module.exports = function expectTypes(obj, types) {
|
|
|
48
47
|
ssfi
|
|
49
48
|
);
|
|
50
49
|
}
|
|
51
|
-
}
|
|
50
|
+
}
|
package/lib/chai/utils/flag.js
CHANGED
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
* utils.flag(this, 'foo', 'bar'); // setter
|
|
16
16
|
* utils.flag(this, 'foo'); // getter, returns `bar`
|
|
17
17
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
18
|
+
* @param {object} obj object constructed Assertion
|
|
19
|
+
* @param {string} key
|
|
20
|
+
* @param {unknown} value (optional)
|
|
21
21
|
* @namespace Utils
|
|
22
22
|
* @name flag
|
|
23
|
-
* @
|
|
23
|
+
* @returns {unknown | undefined}
|
|
24
|
+
* @private
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
module.exports = function flag(obj, key, value) {
|
|
26
|
+
export function flag(obj, key, value) {
|
|
27
27
|
var flags = obj.__flags || (obj.__flags = Object.create(null));
|
|
28
28
|
if (arguments.length === 3) {
|
|
29
29
|
flags[key] = value;
|
|
30
30
|
} else {
|
|
31
31
|
return flags[key];
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Returns the `actual` value for an Assertion.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {object} obj object (constructed Assertion)
|
|
13
|
+
* @param {unknown} args chai.Assertion.prototype.assert arguments
|
|
14
|
+
* @returns {unknown}
|
|
14
15
|
* @namespace Utils
|
|
15
16
|
* @name getActual
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
module.exports = function getActual(obj, args) {
|
|
18
|
+
export function getActual(obj, args) {
|
|
19
19
|
return args.length > 4 ? args[4] : obj._obj;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
* This allows the retrieval of enumerable property names of an object,
|
|
11
11
|
* inherited or not.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {object} object
|
|
14
14
|
* @returns {Array}
|
|
15
15
|
* @namespace Utils
|
|
16
16
|
* @name getEnumerableProperties
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
module.exports = function getEnumerableProperties(object) {
|
|
21
20
|
var result = [];
|
|
22
21
|
for (var name in object) {
|
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var flag = require('./flag')
|
|
12
|
-
, getActual = require('./getActual')
|
|
13
|
-
, objDisplay = require('./objDisplay');
|
|
7
|
+
import {flag} from './flag.js';
|
|
8
|
+
import {getActual} from './getActual.js';
|
|
9
|
+
import {objDisplay} from './objDisplay.js';
|
|
14
10
|
|
|
15
11
|
/**
|
|
16
12
|
* ### .getMessage(object, message, negateMessage)
|
|
@@ -24,14 +20,14 @@ var flag = require('./flag')
|
|
|
24
20
|
* - `#{act}` actual value
|
|
25
21
|
* - `#{exp}` expected value
|
|
26
22
|
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
23
|
+
* @param {object} obj object (constructed Assertion)
|
|
24
|
+
* @param {unknown} args chai.Assertion.prototype.assert arguments
|
|
25
|
+
* @returns {unknown}
|
|
29
26
|
* @namespace Utils
|
|
30
27
|
* @name getMessage
|
|
31
|
-
* @
|
|
28
|
+
* @public
|
|
32
29
|
*/
|
|
33
|
-
|
|
34
|
-
module.exports = function getMessage(obj, args) {
|
|
30
|
+
export function getMessage(obj, args) {
|
|
35
31
|
var negate = flag(obj, 'negate')
|
|
36
32
|
, val = flag(obj, 'object')
|
|
37
33
|
, expected = args[3]
|
|
@@ -47,4 +43,4 @@ module.exports = function getMessage(obj, args) {
|
|
|
47
43
|
.replace(/#\{exp\}/g, function () { return objDisplay(expected); });
|
|
48
44
|
|
|
49
45
|
return flagMsg ? flagMsg + ': ' + msg : msg;
|
|
50
|
-
}
|
|
46
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var flag = require('./flag');
|
|
1
|
+
import {flag} from './flag.js';
|
|
2
|
+
import {type} from './type-detect.js';
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @param {unknown} obj
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
5
8
|
function isObjectType(obj) {
|
|
6
9
|
var objectType = type(obj);
|
|
7
|
-
var objectTypes = ['Array', 'Object', '
|
|
10
|
+
var objectTypes = ['Array', 'Object', 'Function'];
|
|
8
11
|
|
|
9
12
|
return objectTypes.indexOf(objectType) !== -1;
|
|
10
13
|
}
|
|
@@ -18,14 +21,14 @@ function isObjectType(obj) {
|
|
|
18
21
|
*
|
|
19
22
|
* Returns the `operator` or `undefined` value for an Assertion.
|
|
20
23
|
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
24
|
+
* @param {object} obj object (constructed Assertion)
|
|
25
|
+
* @param {unknown} args chai.Assertion.prototype.assert arguments
|
|
26
|
+
* @returns {unknown}
|
|
23
27
|
* @namespace Utils
|
|
24
28
|
* @name getOperator
|
|
25
|
-
* @
|
|
29
|
+
* @public
|
|
26
30
|
*/
|
|
27
|
-
|
|
28
|
-
module.exports = function getOperator(obj, args) {
|
|
31
|
+
export function getOperator(obj, args) {
|
|
29
32
|
var operator = flag(obj, 'operator');
|
|
30
33
|
var negate = flag(obj, 'negate');
|
|
31
34
|
var expected = args[3];
|
|
@@ -52,4 +55,4 @@ module.exports = function getOperator(obj, args) {
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
|
55
|
-
}
|
|
58
|
+
}
|
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
|
|
7
|
+
import {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols.js';
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* ### .getOwnEnumerableProperties(object)
|
|
@@ -17,13 +13,12 @@ var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols
|
|
|
17
13
|
* symbols of an object. This function is necessary because Object.keys only
|
|
18
14
|
* returns enumerable property names, not enumerable property symbols.
|
|
19
15
|
*
|
|
20
|
-
* @param {
|
|
16
|
+
* @param {object} obj
|
|
21
17
|
* @returns {Array}
|
|
22
18
|
* @namespace Utils
|
|
23
19
|
* @name getOwnEnumerableProperties
|
|
24
|
-
* @
|
|
20
|
+
* @public
|
|
25
21
|
*/
|
|
26
|
-
|
|
27
|
-
module.exports = function getOwnEnumerableProperties(obj) {
|
|
22
|
+
export function getOwnEnumerableProperties(obj) {
|
|
28
23
|
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
29
|
-
}
|
|
24
|
+
}
|
|
@@ -11,17 +11,16 @@
|
|
|
11
11
|
* object. This function is necessary because Object.getOwnPropertySymbols
|
|
12
12
|
* returns both enumerable and non-enumerable property symbols.
|
|
13
13
|
*
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {object} obj
|
|
15
15
|
* @returns {Array}
|
|
16
16
|
* @namespace Utils
|
|
17
17
|
* @name getOwnEnumerablePropertySymbols
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
module.exports = function getOwnEnumerablePropertySymbols(obj) {
|
|
20
|
+
export function getOwnEnumerablePropertySymbols(obj) {
|
|
22
21
|
if (typeof Object.getOwnPropertySymbols !== 'function') return [];
|
|
23
22
|
|
|
24
23
|
return Object.getOwnPropertySymbols(obj).filter(function (sym) {
|
|
25
24
|
return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
|
|
26
25
|
});
|
|
27
|
-
}
|
|
26
|
+
}
|
|
@@ -10,16 +10,18 @@
|
|
|
10
10
|
* This allows the retrieval of property names of an object, enumerable or not,
|
|
11
11
|
* inherited or not.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {object} object
|
|
14
14
|
* @returns {Array}
|
|
15
15
|
* @namespace Utils
|
|
16
16
|
* @name getProperties
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
module.exports = function getProperties(object) {
|
|
19
|
+
export function getProperties(object) {
|
|
21
20
|
var result = Object.getOwnPropertyNames(object);
|
|
22
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @param {unknown} property
|
|
24
|
+
*/
|
|
23
25
|
function addProperty(property) {
|
|
24
26
|
if (result.indexOf(property) === -1) {
|
|
25
27
|
result.push(property);
|
|
@@ -33,4 +35,4 @@ module.exports = function getProperties(object) {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
return result;
|
|
36
|
-
}
|
|
38
|
+
}
|
package/lib/chai/utils/index.js
CHANGED
|
@@ -4,175 +4,109 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var pathval = require('pathval');
|
|
12
|
-
|
|
13
|
-
/*!
|
|
14
|
-
* test utility
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
exports.test = require('./test');
|
|
18
|
-
|
|
19
|
-
/*!
|
|
20
|
-
* type utility
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
exports.type = require('type-detect');
|
|
24
|
-
|
|
25
|
-
/*!
|
|
26
|
-
* expectTypes utility
|
|
27
|
-
*/
|
|
28
|
-
exports.expectTypes = require('./expectTypes');
|
|
29
|
-
|
|
30
|
-
/*!
|
|
31
|
-
* message utility
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
exports.getMessage = require('./getMessage');
|
|
35
|
-
|
|
36
|
-
/*!
|
|
37
|
-
* actual utility
|
|
38
|
-
*/
|
|
7
|
+
// Dependencies that are used for multiple exports are required here only once
|
|
8
|
+
import * as checkError from 'check-error';
|
|
39
9
|
|
|
40
|
-
|
|
10
|
+
// test utility
|
|
11
|
+
export {test} from './test.js';
|
|
41
12
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
13
|
+
// type utility
|
|
14
|
+
import {type} from './type-detect.js';
|
|
15
|
+
export {type};
|
|
45
16
|
|
|
46
|
-
|
|
17
|
+
// expectTypes utility
|
|
18
|
+
export {expectTypes} from './expectTypes.js';
|
|
47
19
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*/
|
|
20
|
+
// message utility
|
|
21
|
+
export {getMessage} from './getMessage.js';
|
|
51
22
|
|
|
52
|
-
|
|
23
|
+
// actual utility
|
|
24
|
+
export {getActual} from './getActual.js';
|
|
53
25
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*/
|
|
26
|
+
// Inspect util
|
|
27
|
+
export {inspect} from './inspect.js';
|
|
57
28
|
|
|
58
|
-
|
|
29
|
+
// Object Display util
|
|
30
|
+
export {objDisplay} from './objDisplay.js';
|
|
59
31
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
32
|
+
// Flag utility
|
|
33
|
+
export {flag} from './flag.js';
|
|
63
34
|
|
|
64
|
-
|
|
35
|
+
// Flag transferring utility
|
|
36
|
+
export {transferFlags} from './transferFlags.js';
|
|
65
37
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*/
|
|
38
|
+
// Deep equal utility
|
|
39
|
+
export {default as eql} from 'deep-eql';
|
|
69
40
|
|
|
70
|
-
|
|
41
|
+
// Deep path info
|
|
42
|
+
export {getPathInfo, hasProperty} from 'pathval';
|
|
71
43
|
|
|
72
|
-
|
|
73
|
-
* Deep path info
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
exports.getPathInfo = pathval.getPathInfo;
|
|
77
|
-
|
|
78
|
-
/*!
|
|
79
|
-
* Check if a property exists
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
exports.hasProperty = pathval.hasProperty;
|
|
83
|
-
|
|
84
|
-
/*!
|
|
44
|
+
/**
|
|
85
45
|
* Function name
|
|
46
|
+
*
|
|
47
|
+
* @param {Function} fn
|
|
48
|
+
* @returns {string}
|
|
86
49
|
*/
|
|
50
|
+
export function getName(fn) {
|
|
51
|
+
return fn.name
|
|
52
|
+
}
|
|
87
53
|
|
|
88
|
-
|
|
54
|
+
// add Property
|
|
55
|
+
export {addProperty} from './addProperty.js';
|
|
89
56
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*/
|
|
57
|
+
// add Method
|
|
58
|
+
export {addMethod} from './addMethod.js';
|
|
93
59
|
|
|
94
|
-
|
|
60
|
+
// overwrite Property
|
|
61
|
+
export {overwriteProperty} from './overwriteProperty.js';
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
63
|
+
// overwrite Method
|
|
64
|
+
export {overwriteMethod} from './overwriteMethod.js';
|
|
99
65
|
|
|
100
|
-
|
|
66
|
+
// Add a chainable method
|
|
67
|
+
export {addChainableMethod} from './addChainableMethod.js';
|
|
101
68
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
69
|
+
// Overwrite chainable method
|
|
70
|
+
export {overwriteChainableMethod} from './overwriteChainableMethod.js';
|
|
105
71
|
|
|
106
|
-
|
|
72
|
+
// Compare by inspect method
|
|
73
|
+
export {compareByInspect} from './compareByInspect.js';
|
|
107
74
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*/
|
|
75
|
+
// Get own enumerable property symbols method
|
|
76
|
+
export {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols.js';
|
|
111
77
|
|
|
112
|
-
|
|
78
|
+
// Get own enumerable properties method
|
|
79
|
+
export {getOwnEnumerableProperties} from './getOwnEnumerableProperties.js';
|
|
113
80
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*/
|
|
81
|
+
// Checks error against a given set of criteria
|
|
82
|
+
export {checkError};
|
|
117
83
|
|
|
118
|
-
|
|
84
|
+
// Proxify util
|
|
85
|
+
export {proxify} from './proxify.js';
|
|
119
86
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*/
|
|
87
|
+
// addLengthGuard util
|
|
88
|
+
export {addLengthGuard} from './addLengthGuard.js';
|
|
123
89
|
|
|
124
|
-
|
|
90
|
+
// isProxyEnabled helper
|
|
91
|
+
export {isProxyEnabled} from './isProxyEnabled.js';
|
|
125
92
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
exports.compareByInspect = require('./compareByInspect');
|
|
131
|
-
|
|
132
|
-
/*!
|
|
133
|
-
* Get own enumerable property symbols method
|
|
134
|
-
*/
|
|
93
|
+
// isNaN method
|
|
94
|
+
export {isNaN} from './isNaN.js';
|
|
135
95
|
|
|
136
|
-
|
|
96
|
+
// getOperator method
|
|
97
|
+
export {getOperator} from './getOperator.js';
|
|
137
98
|
|
|
138
|
-
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
/*!
|
|
145
|
-
* Checks error against a given set of criteria
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
exports.checkError = require('check-error');
|
|
149
|
-
|
|
150
|
-
/*!
|
|
151
|
-
* Proxify util
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
exports.proxify = require('./proxify');
|
|
155
|
-
|
|
156
|
-
/*!
|
|
157
|
-
* addLengthGuard util
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
exports.addLengthGuard = require('./addLengthGuard');
|
|
161
|
-
|
|
162
|
-
/*!
|
|
163
|
-
* isProxyEnabled helper
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
exports.isProxyEnabled = require('./isProxyEnabled');
|
|
167
|
-
|
|
168
|
-
/*!
|
|
169
|
-
* isNaN method
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
exports.isNaN = require('./isNaN');
|
|
173
|
-
|
|
174
|
-
/*!
|
|
175
|
-
* getOperator method
|
|
99
|
+
/**
|
|
100
|
+
* Determines if an object is a `RegExp`
|
|
101
|
+
* This is used since `instanceof` will not work in virtual contexts
|
|
102
|
+
*
|
|
103
|
+
* @param {*} obj Object to test
|
|
104
|
+
* @returns {boolean}
|
|
176
105
|
*/
|
|
106
|
+
export function isRegExp(obj) {
|
|
107
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
108
|
+
}
|
|
177
109
|
|
|
178
|
-
|
|
110
|
+
export function isNumeric(obj) {
|
|
111
|
+
return ['Number', 'BigInt'].includes(type(obj))
|
|
112
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// This is (almost) directly from Node.js utils
|
|
2
2
|
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var config = require('../config');
|
|
7
|
-
|
|
8
|
-
module.exports = inspect;
|
|
4
|
+
import {inspect as _inspect} from 'loupe';
|
|
5
|
+
import {config} from '../config.js';
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* ### .inspect(obj, [showHidden], [depth], [colors])
|
|
@@ -13,21 +10,22 @@ module.exports = inspect;
|
|
|
13
10
|
* Echoes the value of a value. Tries to print the value out
|
|
14
11
|
* in the best way possible given the different types.
|
|
15
12
|
*
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
13
|
+
* @param {object} obj The object to print out.
|
|
14
|
+
* @param {boolean} showHidden Flag that shows hidden (not enumerable)
|
|
18
15
|
* properties of objects. Default is false.
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
16
|
+
* @param {number} depth Depth in which to descend in object. Default is 2.
|
|
17
|
+
* @param {boolean} colors Flag to turn on ANSI escape codes to color the
|
|
21
18
|
* output. Default is false (no coloring).
|
|
19
|
+
* @returns {string}
|
|
22
20
|
* @namespace Utils
|
|
23
21
|
* @name inspect
|
|
24
22
|
*/
|
|
25
|
-
function inspect(obj, showHidden, depth, colors) {
|
|
23
|
+
export function inspect(obj, showHidden, depth, colors) {
|
|
26
24
|
var options = {
|
|
27
25
|
colors: colors,
|
|
28
26
|
depth: (typeof depth === 'undefined' ? 2 : depth),
|
|
29
27
|
showHidden: showHidden,
|
|
30
28
|
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity,
|
|
31
29
|
};
|
|
32
|
-
return
|
|
30
|
+
return _inspect(obj, options);
|
|
33
31
|
}
|