@gkucmierz/utils 1.1.6 → 1.1.7
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/package-lock.json +2 -2
- package/package.json +1 -1
- package/spec/get-type.spec.mjs +61 -2
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gkucmierz/utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@gkucmierz/utils",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"husky": "^8.0.1",
|
package/package.json
CHANGED
package/spec/get-type.spec.mjs
CHANGED
|
@@ -2,15 +2,74 @@
|
|
|
2
2
|
import { getType } from '../src/get-type.mjs';
|
|
3
3
|
|
|
4
4
|
describe('get-type', () => {
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
it('should undefined', () => {
|
|
6
7
|
expect(getType(undefined)).toEqual('undefined');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should null', () => {
|
|
7
11
|
expect(getType(null)).toEqual('null');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should boolean', () => {
|
|
8
15
|
expect(getType(true)).toEqual('boolean');
|
|
16
|
+
expect(getType(false)).toEqual('boolean');
|
|
17
|
+
expect(getType(new Boolean)).toEqual('boolean');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should number', () => {
|
|
9
21
|
expect(getType(1)).toEqual('number');
|
|
22
|
+
expect(getType(1e3)).toEqual('number');
|
|
23
|
+
expect(getType(1_000)).toEqual('number');
|
|
24
|
+
expect(getType(NaN)).toEqual('number');
|
|
25
|
+
expect(getType(Infinity)).toEqual('number');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should bigint', () => {
|
|
10
29
|
expect(getType(1n)).toEqual('bigint');
|
|
11
|
-
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should string', () => {
|
|
33
|
+
expect(getType('hello')).toEqual('string');
|
|
34
|
+
expect(getType(new String)).toEqual('string');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should Symbol', () => {
|
|
12
38
|
expect(getType(Symbol())).toEqual('symbol');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should function', () => {
|
|
13
42
|
expect(getType(() => 0)).toEqual('function');
|
|
43
|
+
expect(getType(function() { })).toEqual('function');
|
|
44
|
+
expect(getType(new Function)).toEqual('function');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should generatorfunction', () => {
|
|
48
|
+
expect(getType(function*() { })).toEqual('generatorfunction');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should date', () => {
|
|
52
|
+
expect(getType(new Date)).toEqual('date');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should array', () => {
|
|
56
|
+
expect(getType([])).toEqual('array');
|
|
57
|
+
expect(getType(new Array)).toEqual('array');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should object', () => {
|
|
14
61
|
expect(getType({})).toEqual('object');
|
|
62
|
+
expect(getType(new Object)).toEqual('object');
|
|
63
|
+
expect(getType(new Proxy({}, {}))).toEqual('object');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should map', () => {
|
|
67
|
+
expect(getType(new Map)).toEqual('map');
|
|
68
|
+
expect(getType(new WeakMap)).toEqual('weakmap');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should set', () => {
|
|
72
|
+
expect(getType(new Set)).toEqual('set');
|
|
73
|
+
expect(getType(new WeakSet)).toEqual('weakset');
|
|
15
74
|
});
|
|
16
75
|
});
|