chai 4.3.10 → 5.0.0

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 (46) hide show
  1. package/CONTRIBUTING.md +7 -1
  2. package/README.md +3 -43
  3. package/chai.js +3802 -11206
  4. package/index.js +1 -1
  5. package/{karma.conf.js → karma.conf.cjs} +4 -3
  6. package/lib/chai/assertion.js +153 -163
  7. package/lib/chai/config.js +28 -2
  8. package/lib/chai/core/assertions.js +3631 -3634
  9. package/lib/chai/interface/assert.js +3036 -3042
  10. package/lib/chai/interface/expect.js +40 -37
  11. package/lib/chai/interface/should.js +203 -204
  12. package/lib/chai/utils/addChainableMethod.js +8 -8
  13. package/lib/chai/utils/addLengthGuard.js +3 -3
  14. package/lib/chai/utils/addMethod.js +8 -8
  15. package/lib/chai/utils/addProperty.js +7 -7
  16. package/lib/chai/utils/compareByInspect.js +3 -3
  17. package/lib/chai/utils/expectTypes.js +5 -5
  18. package/lib/chai/utils/flag.js +2 -2
  19. package/lib/chai/utils/getActual.js +2 -2
  20. package/lib/chai/utils/getMessage.js +5 -5
  21. package/lib/chai/utils/getOperator.js +5 -6
  22. package/lib/chai/utils/getOwnEnumerableProperties.js +3 -3
  23. package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -2
  24. package/lib/chai/utils/getProperties.js +2 -2
  25. package/lib/chai/utils/index.js +30 -34
  26. package/lib/chai/utils/inspect.js +4 -7
  27. package/lib/chai/utils/isNaN.js +2 -2
  28. package/lib/chai/utils/isProxyEnabled.js +3 -3
  29. package/lib/chai/utils/objDisplay.js +4 -4
  30. package/lib/chai/utils/overwriteChainableMethod.js +6 -6
  31. package/lib/chai/utils/overwriteMethod.js +8 -8
  32. package/lib/chai/utils/overwriteProperty.js +7 -7
  33. package/lib/chai/utils/proxify.js +7 -7
  34. package/lib/chai/utils/test.js +3 -3
  35. package/lib/chai/utils/transferFlags.js +2 -2
  36. package/lib/chai/utils/type-detect.js +16 -0
  37. package/lib/chai.js +27 -32
  38. package/package.json +24 -28
  39. package/register-assert.cjs +3 -0
  40. package/register-assert.js +3 -1
  41. package/register-expect.cjs +3 -0
  42. package/register-expect.js +3 -1
  43. package/register-should.cjs +3 -0
  44. package/register-should.js +3 -1
  45. package/web-test-runner.config.js +17 -0
  46. package/index.mjs +0 -14
@@ -18,11 +18,11 @@
18
18
  * @api public
19
19
  */
20
20
 
21
- var AssertionError = require('assertion-error');
22
- var flag = require('./flag');
23
- var type = require('type-detect');
21
+ import {AssertionError} from 'assertion-error';
22
+ import {flag} from './flag.js';
23
+ import {type} from './type-detect.js';
24
24
 
25
- module.exports = function expectTypes(obj, types) {
25
+ export function expectTypes(obj, types) {
26
26
  var flagMsg = flag(obj, 'message');
27
27
  var ssfi = flag(obj, 'ssfi');
28
28
 
@@ -48,4 +48,4 @@ module.exports = function expectTypes(obj, types) {
48
48
  ssfi
49
49
  );
50
50
  }
51
- };
51
+ }
@@ -23,11 +23,11 @@
23
23
  * @api private
24
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
+ }
@@ -15,6 +15,6 @@
15
15
  * @name getActual
16
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
+ }
@@ -8,9 +8,9 @@
8
8
  * Module dependencies
9
9
  */
10
10
 
11
- var flag = require('./flag')
12
- , getActual = require('./getActual')
13
- , objDisplay = require('./objDisplay');
11
+ import {flag} from './flag.js';
12
+ import {getActual} from './getActual.js';
13
+ import {objDisplay} from './objDisplay.js';
14
14
 
15
15
  /**
16
16
  * ### .getMessage(object, message, negateMessage)
@@ -31,7 +31,7 @@ var flag = require('./flag')
31
31
  * @api public
32
32
  */
33
33
 
34
- module.exports = function getMessage(obj, args) {
34
+ export function getMessage(obj, args) {
35
35
  var negate = flag(obj, 'negate')
36
36
  , val = flag(obj, 'object')
37
37
  , expected = args[3]
@@ -47,4 +47,4 @@ module.exports = function getMessage(obj, args) {
47
47
  .replace(/#\{exp\}/g, function () { return objDisplay(expected); });
48
48
 
49
49
  return flagMsg ? flagMsg + ': ' + msg : msg;
50
- };
50
+ }
@@ -1,10 +1,9 @@
1
- var type = require('type-detect');
2
-
3
- var flag = require('./flag');
1
+ import {flag} from './flag.js';
2
+ import {type} from './type-detect.js';
4
3
 
5
4
  function isObjectType(obj) {
6
5
  var objectType = type(obj);
7
- var objectTypes = ['Array', 'Object', 'function'];
6
+ var objectTypes = ['Array', 'Object', 'Function'];
8
7
 
9
8
  return objectTypes.indexOf(objectType) !== -1;
10
9
  }
@@ -25,7 +24,7 @@ function isObjectType(obj) {
25
24
  * @api public
26
25
  */
27
26
 
28
- module.exports = function getOperator(obj, args) {
27
+ export function getOperator(obj, args) {
29
28
  var operator = flag(obj, 'operator');
30
29
  var negate = flag(obj, 'negate');
31
30
  var expected = args[3];
@@ -52,4 +51,4 @@ module.exports = function getOperator(obj, args) {
52
51
  }
53
52
 
54
53
  return isObject ? 'deepStrictEqual' : 'strictEqual';
55
- };
54
+ }
@@ -8,7 +8,7 @@
8
8
  * Module dependencies
9
9
  */
10
10
 
11
- var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
11
+ import {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols.js';
12
12
 
13
13
  /**
14
14
  * ### .getOwnEnumerableProperties(object)
@@ -24,6 +24,6 @@ var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols
24
24
  * @api public
25
25
  */
26
26
 
27
- module.exports = function getOwnEnumerableProperties(obj) {
27
+ export function getOwnEnumerableProperties(obj) {
28
28
  return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
29
- };
29
+ }
@@ -18,10 +18,10 @@
18
18
  * @api public
19
19
  */
20
20
 
21
- module.exports = function getOwnEnumerablePropertySymbols(obj) {
21
+ export function getOwnEnumerablePropertySymbols(obj) {
22
22
  if (typeof Object.getOwnPropertySymbols !== 'function') return [];
23
23
 
24
24
  return Object.getOwnPropertySymbols(obj).filter(function (sym) {
25
25
  return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
26
26
  });
27
- };
27
+ }
@@ -17,7 +17,7 @@
17
17
  * @api public
18
18
  */
19
19
 
20
- module.exports = function getProperties(object) {
20
+ export function getProperties(object) {
21
21
  var result = Object.getOwnPropertyNames(object);
22
22
 
23
23
  function addProperty(property) {
@@ -33,4 +33,4 @@ module.exports = function getProperties(object) {
33
33
  }
34
34
 
35
35
  return result;
36
- };
36
+ }
@@ -8,171 +8,167 @@
8
8
  * Dependencies that are used for multiple exports are required here only once
9
9
  */
10
10
 
11
- var pathval = require('pathval');
11
+ import * as checkError from 'check-error';
12
12
 
13
13
  /*!
14
14
  * test utility
15
15
  */
16
16
 
17
- exports.test = require('./test');
17
+ export {test} from './test.js';
18
18
 
19
19
  /*!
20
20
  * type utility
21
21
  */
22
22
 
23
- exports.type = require('type-detect');
23
+ export {type} from './type-detect.js';
24
24
 
25
25
  /*!
26
26
  * expectTypes utility
27
27
  */
28
- exports.expectTypes = require('./expectTypes');
28
+ export {expectTypes} from './expectTypes.js';
29
29
 
30
30
  /*!
31
31
  * message utility
32
32
  */
33
33
 
34
- exports.getMessage = require('./getMessage');
34
+ export {getMessage} from './getMessage.js';
35
35
 
36
36
  /*!
37
37
  * actual utility
38
38
  */
39
39
 
40
- exports.getActual = require('./getActual');
40
+ export {getActual} from './getActual.js';
41
41
 
42
42
  /*!
43
43
  * Inspect util
44
44
  */
45
45
 
46
- exports.inspect = require('./inspect');
46
+ export {inspect} from './inspect.js';
47
47
 
48
48
  /*!
49
49
  * Object Display util
50
50
  */
51
51
 
52
- exports.objDisplay = require('./objDisplay');
52
+ export {objDisplay} from './objDisplay.js';
53
53
 
54
54
  /*!
55
55
  * Flag utility
56
56
  */
57
57
 
58
- exports.flag = require('./flag');
58
+ export {flag} from './flag.js';
59
59
 
60
60
  /*!
61
61
  * Flag transferring utility
62
62
  */
63
63
 
64
- exports.transferFlags = require('./transferFlags');
64
+ export {transferFlags} from './transferFlags.js';
65
65
 
66
66
  /*!
67
67
  * Deep equal utility
68
68
  */
69
69
 
70
- exports.eql = require('deep-eql');
70
+ export {default as eql} from 'deep-eql';
71
71
 
72
72
  /*!
73
73
  * Deep path info
74
74
  */
75
75
 
76
- exports.getPathInfo = pathval.getPathInfo;
77
-
78
- /*!
79
- * Check if a property exists
80
- */
81
-
82
- exports.hasProperty = pathval.hasProperty;
76
+ export {getPathInfo, hasProperty} from 'pathval';
83
77
 
84
78
  /*!
85
79
  * Function name
86
80
  */
87
81
 
88
- exports.getName = require('get-func-name');
82
+ export function getName(fn) {
83
+ return fn.name
84
+ }
89
85
 
90
86
  /*!
91
87
  * add Property
92
88
  */
93
89
 
94
- exports.addProperty = require('./addProperty');
90
+ export {addProperty} from './addProperty.js';
95
91
 
96
92
  /*!
97
93
  * add Method
98
94
  */
99
95
 
100
- exports.addMethod = require('./addMethod');
96
+ export {addMethod} from './addMethod.js';
101
97
 
102
98
  /*!
103
99
  * overwrite Property
104
100
  */
105
101
 
106
- exports.overwriteProperty = require('./overwriteProperty');
102
+ export {overwriteProperty} from './overwriteProperty.js';
107
103
 
108
104
  /*!
109
105
  * overwrite Method
110
106
  */
111
107
 
112
- exports.overwriteMethod = require('./overwriteMethod');
108
+ export {overwriteMethod} from './overwriteMethod.js';
113
109
 
114
110
  /*!
115
111
  * Add a chainable method
116
112
  */
117
113
 
118
- exports.addChainableMethod = require('./addChainableMethod');
114
+ export {addChainableMethod} from './addChainableMethod.js';
119
115
 
120
116
  /*!
121
117
  * Overwrite chainable method
122
118
  */
123
119
 
124
- exports.overwriteChainableMethod = require('./overwriteChainableMethod');
120
+ export {overwriteChainableMethod} from './overwriteChainableMethod.js';
125
121
 
126
122
  /*!
127
123
  * Compare by inspect method
128
124
  */
129
125
 
130
- exports.compareByInspect = require('./compareByInspect');
126
+ export {compareByInspect} from './compareByInspect.js';
131
127
 
132
128
  /*!
133
129
  * Get own enumerable property symbols method
134
130
  */
135
131
 
136
- exports.getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
132
+ export {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols.js';
137
133
 
138
134
  /*!
139
135
  * Get own enumerable properties method
140
136
  */
141
137
 
142
- exports.getOwnEnumerableProperties = require('./getOwnEnumerableProperties');
138
+ export {getOwnEnumerableProperties} from './getOwnEnumerableProperties.js';
143
139
 
144
140
  /*!
145
141
  * Checks error against a given set of criteria
146
142
  */
147
143
 
148
- exports.checkError = require('check-error');
144
+ export {checkError};
149
145
 
150
146
  /*!
151
147
  * Proxify util
152
148
  */
153
149
 
154
- exports.proxify = require('./proxify');
150
+ export {proxify} from './proxify.js';
155
151
 
156
152
  /*!
157
153
  * addLengthGuard util
158
154
  */
159
155
 
160
- exports.addLengthGuard = require('./addLengthGuard');
156
+ export {addLengthGuard} from './addLengthGuard.js';
161
157
 
162
158
  /*!
163
159
  * isProxyEnabled helper
164
160
  */
165
161
 
166
- exports.isProxyEnabled = require('./isProxyEnabled');
162
+ export {isProxyEnabled} from './isProxyEnabled.js';
167
163
 
168
164
  /*!
169
165
  * isNaN method
170
166
  */
171
167
 
172
- exports.isNaN = require('./isNaN');
168
+ export {isNaN} from './isNaN.js';
173
169
 
174
170
  /*!
175
171
  * getOperator method
176
172
  */
177
173
 
178
- exports.getOperator = require('./getOperator');
174
+ export {getOperator} from './getOperator.js';
@@ -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
- var getName = require('get-func-name');
5
- var loupe = require('loupe');
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])
@@ -22,12 +19,12 @@ module.exports = inspect;
22
19
  * @namespace Utils
23
20
  * @name inspect
24
21
  */
25
- function inspect(obj, showHidden, depth, colors) {
22
+ export function inspect(obj, showHidden, depth, colors) {
26
23
  var options = {
27
24
  colors: colors,
28
25
  depth: (typeof depth === 'undefined' ? 2 : depth),
29
26
  showHidden: showHidden,
30
27
  truncate: config.truncateThreshold ? config.truncateThreshold : Infinity,
31
28
  };
32
- return loupe.inspect(obj, options);
29
+ return _inspect(obj, options);
33
30
  }
@@ -16,11 +16,11 @@
16
16
  * @api private
17
17
  */
18
18
 
19
- function isNaN(value) {
19
+ function _isNaN(value) {
20
20
  // Refer http://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number
21
21
  // section's NOTE.
22
22
  return value !== value;
23
23
  }
24
24
 
25
25
  // If ECMAScript 6's Number.isNaN is present, prefer that.
26
- module.exports = Number.isNaN || isNaN;
26
+ export const isNaN = Number.isNaN || _isNaN;
@@ -1,4 +1,4 @@
1
- var config = require('../config');
1
+ import {config} from '../config.js';
2
2
 
3
3
  /*!
4
4
  * Chai - isProxyEnabled helper
@@ -17,8 +17,8 @@ var config = require('../config');
17
17
  * @name isProxyEnabled
18
18
  */
19
19
 
20
- module.exports = function isProxyEnabled() {
20
+ export function isProxyEnabled() {
21
21
  return config.useProxy &&
22
22
  typeof Proxy !== 'undefined' &&
23
23
  typeof Reflect !== 'undefined';
24
- };
24
+ }
@@ -8,8 +8,8 @@
8
8
  * Module dependencies
9
9
  */
10
10
 
11
- var inspect = require('./inspect');
12
- var config = require('../config');
11
+ import {inspect} from './inspect.js';
12
+ import {config} from '../config.js';
13
13
 
14
14
  /**
15
15
  * ### .objDisplay(object)
@@ -25,7 +25,7 @@ var config = require('../config');
25
25
  * @api public
26
26
  */
27
27
 
28
- module.exports = function objDisplay(obj) {
28
+ export function objDisplay(obj) {
29
29
  var str = inspect(obj)
30
30
  , type = Object.prototype.toString.call(obj);
31
31
 
@@ -48,4 +48,4 @@ module.exports = function objDisplay(obj) {
48
48
  } else {
49
49
  return str;
50
50
  }
51
- };
51
+ }
@@ -4,8 +4,8 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- var chai = require('../../chai');
8
- var transferFlags = require('./transferFlags');
7
+ import {Assertion} from '../assertion.js';
8
+ import {transferFlags} from './transferFlags.js';
9
9
 
10
10
  /**
11
11
  * ### .overwriteChainableMethod(ctx, name, method, chainingBehavior)
@@ -40,7 +40,7 @@ var transferFlags = require('./transferFlags');
40
40
  * @api public
41
41
  */
42
42
 
43
- module.exports = function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
43
+ export function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
44
44
  var chainableBehavior = ctx.__methods[name];
45
45
 
46
46
  var _chainingBehavior = chainableBehavior.chainingBehavior;
@@ -50,7 +50,7 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
50
50
  return result;
51
51
  }
52
52
 
53
- var newAssertion = new chai.Assertion();
53
+ var newAssertion = new Assertion();
54
54
  transferFlags(this, newAssertion);
55
55
  return newAssertion;
56
56
  };
@@ -62,8 +62,8 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
62
62
  return result;
63
63
  }
64
64
 
65
- var newAssertion = new chai.Assertion();
65
+ var newAssertion = new Assertion();
66
66
  transferFlags(this, newAssertion);
67
67
  return newAssertion;
68
68
  };
69
- };
69
+ }
@@ -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 {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';
12
12
 
13
13
  /**
14
14
  * ### .overwriteMethod(ctx, name, fn)
@@ -44,7 +44,7 @@ var transferFlags = require('./transferFlags');
44
44
  * @api public
45
45
  */
46
46
 
47
- module.exports = function overwriteMethod(ctx, name, method) {
47
+ export function overwriteMethod(ctx, name, method) {
48
48
  var _method = ctx[name]
49
49
  , _super = function () {
50
50
  throw new Error(name + ' is not a function');
@@ -82,11 +82,11 @@ module.exports = function overwriteMethod(ctx, name, method) {
82
82
  return result;
83
83
  }
84
84
 
85
- var newAssertion = new chai.Assertion();
85
+ var newAssertion = new Assertion();
86
86
  transferFlags(this, newAssertion);
87
87
  return newAssertion;
88
88
  }
89
89
 
90
90
  addLengthGuard(overwritingMethodWrapper, name, false);
91
91
  ctx[name] = proxify(overwritingMethodWrapper, name);
92
- };
92
+ }
@@ -4,10 +4,10 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- var chai = require('../../chai');
8
- var flag = require('./flag');
9
- var isProxyEnabled = require('./isProxyEnabled');
10
- var transferFlags = require('./transferFlags');
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
  * ### .overwriteProperty(ctx, name, fn)
@@ -43,7 +43,7 @@ var transferFlags = require('./transferFlags');
43
43
  * @api public
44
44
  */
45
45
 
46
- module.exports = function overwriteProperty(ctx, name, getter) {
46
+ export function overwriteProperty(ctx, name, getter) {
47
47
  var _get = Object.getOwnPropertyDescriptor(ctx, name)
48
48
  , _super = function () {};
49
49
 
@@ -83,10 +83,10 @@ module.exports = function overwriteProperty(ctx, name, getter) {
83
83
  return result;
84
84
  }
85
85
 
86
- var newAssertion = new chai.Assertion();
86
+ var newAssertion = new Assertion();
87
87
  transferFlags(this, newAssertion);
88
88
  return newAssertion;
89
89
  }
90
90
  , configurable: true
91
91
  });
92
- };
92
+ }
@@ -1,7 +1,7 @@
1
- var config = require('../config');
2
- var flag = require('./flag');
3
- var getProperties = require('./getProperties');
4
- var isProxyEnabled = require('./isProxyEnabled');
1
+ import {config} from '../config.js';
2
+ import {flag} from './flag.js';
3
+ import {getProperties} from './getProperties.js';
4
+ import {isProxyEnabled} from './isProxyEnabled.js';
5
5
 
6
6
  /*!
7
7
  * Chai - proxify utility
@@ -28,9 +28,9 @@ var isProxyEnabled = require('./isProxyEnabled');
28
28
  * @name proxify
29
29
  */
30
30
 
31
- var builtins = ['__flags', '__methods', '_obj', 'assert'];
31
+ const builtins = ['__flags', '__methods', '_obj', 'assert'];
32
32
 
33
- module.exports = function proxify(obj, nonChainableMethodName) {
33
+ export function proxify(obj ,nonChainableMethodName) {
34
34
  if (!isProxyEnabled()) return obj;
35
35
 
36
36
  return new Proxy(obj, {
@@ -98,7 +98,7 @@ module.exports = function proxify(obj, nonChainableMethodName) {
98
98
  return Reflect.get(target, property);
99
99
  }
100
100
  });
101
- };
101
+ }
102
102
 
103
103
  /**
104
104
  * # stringDistanceCapped(strA, strB, cap)
@@ -8,7 +8,7 @@
8
8
  * Module dependencies
9
9
  */
10
10
 
11
- var flag = require('./flag');
11
+ import {flag} from './flag.js';
12
12
 
13
13
  /**
14
14
  * ### .test(object, expression)
@@ -21,8 +21,8 @@ var flag = require('./flag');
21
21
  * @name test
22
22
  */
23
23
 
24
- module.exports = function test(obj, args) {
24
+ export function test(obj, args) {
25
25
  var negate = flag(obj, 'negate')
26
26
  , expr = args[0];
27
27
  return negate ? !expr : expr;
28
- };
28
+ }
@@ -27,7 +27,7 @@
27
27
  * @api private
28
28
  */
29
29
 
30
- module.exports = function transferFlags(assertion, object, includeAll) {
30
+ export function transferFlags(assertion, object, includeAll) {
31
31
  var flags = assertion.__flags || (assertion.__flags = Object.create(null));
32
32
 
33
33
  if (!object.__flags) {
@@ -42,4 +42,4 @@ module.exports = function transferFlags(assertion, object, includeAll) {
42
42
  object.__flags[flag] = flags[flag];
43
43
  }
44
44
  }
45
- };
45
+ }
@@ -0,0 +1,16 @@
1
+ export function type(obj) {
2
+ if (typeof obj === 'undefined') {
3
+ return 'undefined';
4
+ }
5
+
6
+ if (obj === null) {
7
+ return 'null';
8
+ }
9
+
10
+ const stringTag = obj[Symbol.toStringTag];
11
+ if (typeof stringTag === 'string') {
12
+ return stringTag;
13
+ }
14
+ const type = Object.prototype.toString.call(obj).slice(8, -1);
15
+ return type;
16
+ }