@magic/types 0.1.37 → 0.1.38
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/README.md +6 -1
- package/package.json +15 -5
- package/src/deep/different.js +3 -3
- package/src/deep/equal.js +19 -10
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"author": "Wizards & Witches",
|
|
5
5
|
"homepage": "https://github.com/magic/types",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
"main": "src/index.js",
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
10
|
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./src/index.js",
|
|
14
|
+
"types": "./types/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
"scripts": {
|
|
12
18
|
"start": "t",
|
|
13
19
|
"build": "tsc && npm run format",
|
|
@@ -44,9 +50,9 @@
|
|
|
44
50
|
"@magic-modules/no-spy": "0.0.9",
|
|
45
51
|
"@magic-modules/pre": "0.0.12",
|
|
46
52
|
"@magic-themes/docs": "0.0.15",
|
|
47
|
-
"@magic/core": "0.0.
|
|
48
|
-
"@magic/format": "0.0.
|
|
49
|
-
"@magic/test": "0.3.
|
|
53
|
+
"@magic/core": "0.0.159",
|
|
54
|
+
"@magic/format": "0.0.74",
|
|
55
|
+
"@magic/test": "0.3.21",
|
|
50
56
|
"typescript": "6.0.3"
|
|
51
57
|
},
|
|
52
58
|
"keywords": [
|
|
@@ -61,6 +67,10 @@
|
|
|
61
67
|
}
|
|
62
68
|
],
|
|
63
69
|
"dependencies": {
|
|
64
|
-
"@types/node": "
|
|
70
|
+
"@types/node": "26.0.1"
|
|
71
|
+
},
|
|
72
|
+
"allowScripts": {
|
|
73
|
+
"@swc/core@1.3.41": true,
|
|
74
|
+
"canvas@3.2.3": true
|
|
65
75
|
}
|
|
66
76
|
}
|
package/src/deep/different.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isUndefined } from '../fns.js'
|
|
2
2
|
|
|
3
3
|
import equal from './equal.js'
|
|
4
4
|
|
|
@@ -19,8 +19,8 @@ import equal from './equal.js'
|
|
|
19
19
|
* @returns {boolean | ((c: unknown) => boolean)}
|
|
20
20
|
*/
|
|
21
21
|
export const different = (a, b) => {
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
22
|
+
if (isUndefined(b)) {
|
|
23
|
+
if (isUndefined(a)) {
|
|
24
24
|
return false
|
|
25
25
|
}
|
|
26
26
|
|
package/src/deep/equal.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
// Written by Substack <3
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
isArray,
|
|
5
|
+
isBuffer,
|
|
6
|
+
isDate,
|
|
7
|
+
isFunction,
|
|
8
|
+
isNull,
|
|
9
|
+
isObject,
|
|
10
|
+
isObjectNative,
|
|
11
|
+
isUndefined,
|
|
12
|
+
} from '../fns.js'
|
|
4
13
|
|
|
5
14
|
/**
|
|
6
15
|
* @overload
|
|
@@ -25,15 +34,15 @@ export const equal = (a, b, options = {}) => {
|
|
|
25
34
|
const { strict = false, arrayOrderStrict = false } = options
|
|
26
35
|
|
|
27
36
|
// curry
|
|
28
|
-
if (
|
|
29
|
-
if (
|
|
37
|
+
if (isUndefined(b)) {
|
|
38
|
+
if (isUndefined(a)) {
|
|
30
39
|
return true
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
return c => equal(a, c)
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
if (
|
|
45
|
+
if (isNull(b)) {
|
|
37
46
|
return a === b
|
|
38
47
|
}
|
|
39
48
|
|
|
@@ -43,11 +52,11 @@ export const equal = (a, b, options = {}) => {
|
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
/* functions are handled by their toString value */
|
|
46
|
-
if (
|
|
55
|
+
if (isFunction(a) && isFunction(b)) {
|
|
47
56
|
return a.toString() === b.toString()
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
if (!
|
|
59
|
+
if (!isObject(a) || !isObject(b)) {
|
|
51
60
|
return a === b
|
|
52
61
|
}
|
|
53
62
|
|
|
@@ -62,12 +71,12 @@ export const equal = (a, b, options = {}) => {
|
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
// dates
|
|
65
|
-
if (
|
|
74
|
+
if (isDate(a)) {
|
|
66
75
|
return a.toString() === b.toString()
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
// buffers
|
|
70
|
-
if (
|
|
79
|
+
if (isBuffer(a) && isBuffer(b)) {
|
|
71
80
|
if (a.length !== b.length) {
|
|
72
81
|
return false
|
|
73
82
|
}
|
|
@@ -81,7 +90,7 @@ export const equal = (a, b, options = {}) => {
|
|
|
81
90
|
return true
|
|
82
91
|
}
|
|
83
92
|
|
|
84
|
-
if (
|
|
93
|
+
if (isArray(a) && isArray(b)) {
|
|
85
94
|
if (!strict && !arrayOrderStrict) {
|
|
86
95
|
a.sort()
|
|
87
96
|
b.sort()
|
|
@@ -91,7 +100,7 @@ export const equal = (a, b, options = {}) => {
|
|
|
91
100
|
return allEqual
|
|
92
101
|
}
|
|
93
102
|
|
|
94
|
-
if (
|
|
103
|
+
if (isObjectNative(a) && isObjectNative(b)) {
|
|
95
104
|
const aObj = a
|
|
96
105
|
const bObj = b
|
|
97
106
|
|