@magic/types 0.1.27 → 0.1.28
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 +13 -1
- package/package.json +2 -2
- package/src/deep/equal.js +12 -4
package/README.md
CHANGED
|
@@ -176,6 +176,12 @@ isDeepEqual([1, 2, 3], [1, 2, 3]) // true
|
|
|
176
176
|
isDeepDifferent([1, 2, 3], [1, 2, 3]) // false
|
|
177
177
|
// alias is.deep.diff, is.deep.different
|
|
178
178
|
|
|
179
|
+
isDeepEqual([1, 2, 3], [3, 2, 1]) // true
|
|
180
|
+
isDeepEqual([1, 2, 3], [3, 2, 1], { strict: true }) // false
|
|
181
|
+
|
|
182
|
+
isDeepEqual({a: 1, b: 2, c: 3 }, { c: 3, b: 2, a: 1 }) // true
|
|
183
|
+
isDeepEqual({a: 1, b: 2, c: 3 }, { c: 3, b: 2, a: 1 }, { strict: true }) // false
|
|
184
|
+
|
|
179
185
|
isEvery([1, 2, 3], 'number') // true
|
|
180
186
|
isEvery([1, 2, 3], is.number) // true
|
|
181
187
|
// alias is.every, is.all
|
|
@@ -210,6 +216,7 @@ isModule(mod) // true
|
|
|
210
216
|
|
|
211
217
|
isOwnProp({ test: undefined }, 'test') // true
|
|
212
218
|
// alias isOwnProperty, is.ownProperty, is.ownProp, is.prop
|
|
219
|
+
|
|
213
220
|
```
|
|
214
221
|
|
|
215
222
|
#### Changelog
|
|
@@ -348,6 +355,11 @@ update dependencies
|
|
|
348
355
|
- @types/node is a dependency, not devDependency
|
|
349
356
|
- update dependencies
|
|
350
357
|
|
|
351
|
-
##### 0.1.28
|
|
358
|
+
##### 0.1.28
|
|
359
|
+
|
|
360
|
+
- options.strict makes the tests include sort order of objects and array, [1, 2] is [2, 1] if options.strict = true
|
|
361
|
+
- update dependencies
|
|
362
|
+
|
|
363
|
+
##### 0.1.29 - unreleased
|
|
352
364
|
|
|
353
365
|
...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"author": "Wizards & Witches",
|
|
5
5
|
"homepage": "https://github.com/magic/types",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
}
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@types/node": "24.
|
|
64
|
+
"@types/node": "24.7.1"
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/deep/equal.js
CHANGED
|
@@ -16,9 +16,11 @@ import is from '../lib.js'
|
|
|
16
16
|
/**
|
|
17
17
|
* @param {unknown} a
|
|
18
18
|
* @param {unknown} [b]
|
|
19
|
+
* @param {object} [options]
|
|
20
|
+
* @param {boolean} [options.strict=false]
|
|
19
21
|
* @returns {boolean | ((c: unknown) => boolean)}
|
|
20
22
|
*/
|
|
21
|
-
export const equal = (a, b) => {
|
|
23
|
+
export const equal = (a, b, options = { strict: false }) => {
|
|
22
24
|
// curry
|
|
23
25
|
if (is.undefined(b)) {
|
|
24
26
|
if (is.undefined(a)) {
|
|
@@ -46,7 +48,6 @@ export const equal = (a, b) => {
|
|
|
46
48
|
// return is.length.eq(a, b)
|
|
47
49
|
// }
|
|
48
50
|
|
|
49
|
-
// Check if both are objects before accessing prototype
|
|
50
51
|
if (!is.object(a) || !is.object(b)) {
|
|
51
52
|
return a === b
|
|
52
53
|
}
|
|
@@ -100,6 +101,11 @@ export const equal = (a, b) => {
|
|
|
100
101
|
return false
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
if (!options.strict) {
|
|
105
|
+
a.sort()
|
|
106
|
+
b.sort()
|
|
107
|
+
}
|
|
108
|
+
|
|
103
109
|
return !a.some((v, i) => v !== b[i])
|
|
104
110
|
}
|
|
105
111
|
|
|
@@ -118,8 +124,10 @@ export const equal = (a, b) => {
|
|
|
118
124
|
return false
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
if (!options.strict) {
|
|
128
|
+
ka.sort()
|
|
129
|
+
kb.sort()
|
|
130
|
+
}
|
|
123
131
|
|
|
124
132
|
// ~~~cheap key test
|
|
125
133
|
for (let i = 0; i < ka.length; i++) {
|