@fluixi/utils 1.0.0-alpha.83 → 1.0.0-alpha.84
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/dist/index.cjs +2858 -1
- package/dist/index.mjs +2838 -1
- package/dist/lib/array/advanced.cjs +2227 -1
- package/dist/lib/array/advanced.mjs +2204 -1
- package/dist/lib/array/array.cjs +57 -1
- package/dist/lib/array/array.mjs +36 -1
- package/dist/lib/array/index.cjs +2344 -1
- package/dist/lib/array/index.mjs +2322 -1
- package/dist/lib/array/utils.cjs +103 -1
- package/dist/lib/array/utils.mjs +82 -1
- package/dist/lib/color/color.cjs +2190 -1
- package/dist/lib/color/color.mjs +2167 -1
- package/dist/lib/color/constants.cjs +380 -1
- package/dist/lib/color/constants.mjs +359 -1
- package/dist/lib/color/conversions.cjs +629 -1
- package/dist/lib/color/conversions.mjs +608 -1
- package/dist/lib/color/helpers.cjs +2534 -1
- package/dist/lib/color/helpers.mjs +2511 -1
- package/dist/lib/color/index.cjs +2641 -1
- package/dist/lib/color/index.mjs +2619 -1
- package/dist/lib/color/types.cjs +18 -1
- package/dist/lib/color/utils.cjs +962 -1
- package/dist/lib/color/utils.mjs +939 -1
- package/dist/lib/compare/comparators.cjs +171 -1
- package/dist/lib/compare/comparators.mjs +150 -1
- package/dist/lib/compare/index.cjs +172 -1
- package/dist/lib/compare/index.mjs +152 -1
- package/dist/lib/crypto/hash.cjs +83 -1
- package/dist/lib/crypto/hash.mjs +62 -1
- package/dist/lib/crypto/index.cjs +85 -1
- package/dist/lib/crypto/index.mjs +62 -1
- package/dist/lib/dom/events.cjs +40 -1
- package/dist/lib/dom/events.mjs +19 -1
- package/dist/lib/dom/index.cjs +78 -1
- package/dist/lib/dom/index.mjs +56 -1
- package/dist/lib/dom/utils.cjs +57 -1
- package/dist/lib/dom/utils.mjs +36 -1
- package/dist/lib/functions/functions.cjs +366 -1
- package/dist/lib/functions/functions.mjs +345 -1
- package/dist/lib/functions/index.cjs +369 -1
- package/dist/lib/functions/index.mjs +347 -1
- package/dist/lib/functions/types.cjs +18 -1
- package/dist/lib/helpers.cjs +78 -1
- package/dist/lib/helpers.mjs +59 -1
- package/dist/lib/index.cjs +2857 -1
- package/dist/lib/index.mjs +2836 -1
- package/dist/lib/maths/constants.cjs +70 -1
- package/dist/lib/maths/constants.mjs +50 -1
- package/dist/lib/maths/fn/advanced.cjs +231 -1
- package/dist/lib/maths/fn/advanced.mjs +208 -1
- package/dist/lib/maths/fn/basic.cjs +212 -1
- package/dist/lib/maths/fn/basic.mjs +191 -1
- package/dist/lib/maths/fn/complex.cjs +268 -1
- package/dist/lib/maths/fn/complex.mjs +247 -1
- package/dist/lib/maths/fn/index.cjs +877 -1
- package/dist/lib/maths/fn/index.mjs +855 -1
- package/dist/lib/maths/fn/trigo.cjs +179 -1
- package/dist/lib/maths/fn/trigo.mjs +156 -1
- package/dist/lib/maths/fn/vector.cjs +728 -1
- package/dist/lib/maths/fn/vector.mjs +707 -1
- package/dist/lib/maths/formatter.cjs +61 -1
- package/dist/lib/maths/formatter.mjs +40 -1
- package/dist/lib/maths/guards.cjs +164 -1
- package/dist/lib/maths/guards.mjs +144 -1
- package/dist/lib/maths/index.cjs +1152 -1
- package/dist/lib/maths/index.mjs +1130 -1
- package/dist/lib/maths/parser.cjs +75 -1
- package/dist/lib/maths/parser.mjs +54 -1
- package/dist/lib/maths/random.cjs +49 -1
- package/dist/lib/maths/random.mjs +28 -1
- package/dist/lib/maths/types/advanced.cjs +18 -1
- package/dist/lib/maths/types/basic.cjs +18 -1
- package/dist/lib/maths/types/index.cjs +19 -1
- package/dist/lib/maths/types/index.mjs +1 -0
- package/dist/lib/maths/types/negative.cjs +18 -1
- package/dist/lib/maths/types/operations.cjs +18 -1
- package/dist/lib/object/clone.cjs +88 -1
- package/dist/lib/object/clone.mjs +65 -1
- package/dist/lib/object/diff.cjs +573 -1
- package/dist/lib/object/diff.mjs +550 -1
- package/dist/lib/object/getter-setter.cjs +2351 -1
- package/dist/lib/object/getter-setter.mjs +2330 -1
- package/dist/lib/object/index.cjs +3956 -6
- package/dist/lib/object/index.mjs +3936 -6
- package/dist/lib/object/merge.cjs +1029 -1
- package/dist/lib/object/merge.mjs +1006 -1
- package/dist/lib/object/object.cjs +280 -1
- package/dist/lib/object/object.mjs +257 -1
- package/dist/lib/object/omit.cjs +2022 -1
- package/dist/lib/object/omit.mjs +1999 -1
- package/dist/lib/object/reconcile.cjs +126 -1
- package/dist/lib/object/reconcile.mjs +105 -1
- package/dist/lib/object/selector.cjs +303 -1
- package/dist/lib/object/selector.mjs +282 -1
- package/dist/lib/object/sort.cjs +209 -1
- package/dist/lib/object/sort.mjs +186 -1
- package/dist/lib/object/transform.cjs +2211 -1
- package/dist/lib/object/transform.mjs +2190 -1
- package/dist/lib/object/types.cjs +18 -1
- package/dist/lib/object/utils.cjs +326 -6
- package/dist/lib/object/utils.mjs +305 -6
- package/dist/lib/primitive/boolean/boolean.cjs +407 -1
- package/dist/lib/primitive/boolean/boolean.mjs +386 -1
- package/dist/lib/primitive/boolean/index.cjs +382 -1
- package/dist/lib/primitive/boolean/index.mjs +359 -1
- package/dist/lib/primitive/boolean/types.cjs +18 -1
- package/dist/lib/primitive/date/date.cjs +1126 -1
- package/dist/lib/primitive/date/date.mjs +1105 -1
- package/dist/lib/primitive/date/index.cjs +1128 -1
- package/dist/lib/primitive/date/index.mjs +1105 -1
- package/dist/lib/primitive/date/types.cjs +18 -1
- package/dist/lib/primitive/index.cjs +2338 -5
- package/dist/lib/primitive/index.mjs +2316 -5
- package/dist/lib/primitive/string/index.cjs +875 -5
- package/dist/lib/primitive/string/index.mjs +852 -5
- package/dist/lib/primitive/string/parser-2.cjs +543 -8
- package/dist/lib/primitive/string/parser-2.mjs +522 -8
- package/dist/lib/primitive/string/parser.cjs +236 -3
- package/dist/lib/primitive/string/parser.mjs +215 -3
- package/dist/lib/primitive/string/string.cjs +926 -5
- package/dist/lib/primitive/string/string.mjs +903 -5
- package/dist/lib/primitive/string/types.cjs +18 -1
- package/dist/lib/primitive/types.cjs +18 -1
- package/dist/lib/url/index.cjs +327 -1
- package/dist/lib/url/index.mjs +304 -1
- package/dist/lib/url/parser.cjs +325 -1
- package/dist/lib/url/parser.mjs +304 -1
- package/dist/lib/url/types.cjs +18 -1
- package/package.json +5 -5
|
@@ -1 +1,171 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/compare/comparators.ts
|
|
21
|
+
var comparators_exports = {};
|
|
22
|
+
__export(comparators_exports, {
|
|
23
|
+
deepEqual: () => deepEqual,
|
|
24
|
+
hasLength: () => hasLength,
|
|
25
|
+
isDeepEqual: () => isDeepEqual,
|
|
26
|
+
isEqual: () => isEqual
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(comparators_exports);
|
|
29
|
+
|
|
30
|
+
// src/lib/helpers.ts
|
|
31
|
+
var import_primitive = require("@fluixi/utils/primitive");
|
|
32
|
+
var import_object = require("@fluixi/utils/object");
|
|
33
|
+
var import_array = require("@fluixi/utils/array");
|
|
34
|
+
var import_functions = require("@fluixi/utils/functions");
|
|
35
|
+
var isUndefinedOrNull = (element) => {
|
|
36
|
+
if (typeof element === "undefined" || element === null) return true;
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
function isPrimitive(v) {
|
|
40
|
+
const type = typeof v;
|
|
41
|
+
return v === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "bigint" || type === "undefined" || (0, import_primitive.isDate)(v);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/lib/compare/comparators.ts
|
|
45
|
+
var import_object2 = require("@fluixi/utils/object");
|
|
46
|
+
var hasLength = (data) => {
|
|
47
|
+
const type = typeof data;
|
|
48
|
+
let hasValue = false;
|
|
49
|
+
if (isUndefinedOrNull(data)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
switch (type) {
|
|
53
|
+
case "string":
|
|
54
|
+
hasValue = data.length > 0;
|
|
55
|
+
break;
|
|
56
|
+
case "number":
|
|
57
|
+
hasValue = true;
|
|
58
|
+
break;
|
|
59
|
+
case "object":
|
|
60
|
+
if (Array.isArray(data)) {
|
|
61
|
+
hasValue = data.length > 0;
|
|
62
|
+
} else {
|
|
63
|
+
hasValue = Object.keys(data).length > 0;
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case "boolean":
|
|
67
|
+
hasValue = data;
|
|
68
|
+
}
|
|
69
|
+
return hasValue;
|
|
70
|
+
};
|
|
71
|
+
var isDeepEqual = (compare1, compare2, keys) => {
|
|
72
|
+
if (compare1 === void 0 || compare2 === void 0) return false;
|
|
73
|
+
if (compare1 === null || compare2 === null) return compare1 === compare2;
|
|
74
|
+
if (Array.isArray(compare1) && Array.isArray(compare2)) {
|
|
75
|
+
if (compare1.length !== compare2.length) return false;
|
|
76
|
+
return compare1.every((v, i) => isDeepEqual(v, compare2[i]));
|
|
77
|
+
}
|
|
78
|
+
if (keys && keys.length > 0) {
|
|
79
|
+
if (isPrimitive(compare1) && isPrimitive(compare2))
|
|
80
|
+
return compare1 === compare2;
|
|
81
|
+
if ((0, import_object2.isObject)(compare1) && (0, import_object2.isObject)(compare2))
|
|
82
|
+
return keys.every(
|
|
83
|
+
(k) => isDeepEqual(compare1[k], compare2[k])
|
|
84
|
+
);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if ((0, import_object2.isObject)(compare1) && (0, import_object2.isObject)(compare2)) {
|
|
88
|
+
const obj1Keys = Object.keys(compare1).sort();
|
|
89
|
+
const obj2Keys = Object.keys(compare2).sort();
|
|
90
|
+
if (obj1Keys.length !== obj2Keys.length) return false;
|
|
91
|
+
return obj1Keys.every(
|
|
92
|
+
(key) => isDeepEqual(compare1[key], compare2[key])
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return compare1 === compare2;
|
|
96
|
+
};
|
|
97
|
+
function unorderedArrayEqual(a, b, opts) {
|
|
98
|
+
const used = new Uint8Array(b.length);
|
|
99
|
+
outer: for (let i = 0; i < a.length; i++) {
|
|
100
|
+
for (let j = 0; j < b.length; j++) {
|
|
101
|
+
if (!used[j] && deepEqual(a[i], b[j], opts)) {
|
|
102
|
+
used[j] = 1;
|
|
103
|
+
continue outer;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
var deepEqual = (obj1, obj2, options = {}) => {
|
|
111
|
+
if (obj1 === obj2) return true;
|
|
112
|
+
if (obj1 == null || obj2 == null) return false;
|
|
113
|
+
if (typeof obj1 !== typeof obj2) return false;
|
|
114
|
+
const isArr1 = Array.isArray(obj1);
|
|
115
|
+
const isArr2 = Array.isArray(obj2);
|
|
116
|
+
if (isArr1 !== isArr2) return false;
|
|
117
|
+
if (isArr1 && isArr2) {
|
|
118
|
+
if (obj1.length !== obj2.length) return false;
|
|
119
|
+
return options.unordered ? unorderedArrayEqual(obj1, obj2, options) : obj1.every((item, i) => deepEqual(item, obj2[i], options));
|
|
120
|
+
}
|
|
121
|
+
if (typeof obj1 !== "object") return obj1 === obj2;
|
|
122
|
+
const isDate1 = obj1 instanceof Date;
|
|
123
|
+
const isDate2 = obj2 instanceof Date;
|
|
124
|
+
if (isDate1 !== isDate2) return false;
|
|
125
|
+
if (isDate1) return obj1.getTime() === obj2.getTime();
|
|
126
|
+
const isRE1 = obj1 instanceof RegExp;
|
|
127
|
+
const isRE2 = obj2 instanceof RegExp;
|
|
128
|
+
if (isRE1 !== isRE2) return false;
|
|
129
|
+
if (isRE1) return obj1.toString() === obj2.toString();
|
|
130
|
+
const isMap1 = obj1 instanceof Map;
|
|
131
|
+
const isMap2 = obj2 instanceof Map;
|
|
132
|
+
if (isMap1 !== isMap2) return false;
|
|
133
|
+
if (isMap1) {
|
|
134
|
+
if (obj1.size !== obj2.size) return false;
|
|
135
|
+
for (const [k, v] of obj1) {
|
|
136
|
+
if (!obj2.has(k)) return false;
|
|
137
|
+
if (!deepEqual(v, obj2.get(k), options)) return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
const isSet1 = obj1 instanceof Set;
|
|
142
|
+
const isSet2 = obj2 instanceof Set;
|
|
143
|
+
if (isSet1 !== isSet2) return false;
|
|
144
|
+
if (isSet1) {
|
|
145
|
+
if (obj1.size !== obj2.size) return false;
|
|
146
|
+
const bArr = [...obj2];
|
|
147
|
+
const used = new Uint8Array(bArr.length);
|
|
148
|
+
outer: for (const v of obj1) {
|
|
149
|
+
for (let j = 0; j < bArr.length; j++) {
|
|
150
|
+
if (!used[j] && deepEqual(v, bArr[j], options)) {
|
|
151
|
+
used[j] = 1;
|
|
152
|
+
continue outer;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (!(0, import_object2.isObject)(obj1) || !(0, import_object2.isObject)(obj2)) return false;
|
|
160
|
+
const keys1 = Object.keys(obj1);
|
|
161
|
+
const keys2 = Object.keys(obj2);
|
|
162
|
+
if (keys1.length !== keys2.length) return false;
|
|
163
|
+
for (const key of keys1) {
|
|
164
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key)) return false;
|
|
165
|
+
if (!deepEqual(obj1[key], obj2[key], options)) return false;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
};
|
|
169
|
+
function isEqual(a, b) {
|
|
170
|
+
return Object.is(a, b);
|
|
171
|
+
}
|
|
@@ -1 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/helpers.ts
|
|
2
|
+
import {
|
|
3
|
+
isDate
|
|
4
|
+
} from "@fluixi/utils/primitive";
|
|
5
|
+
import { isClass, isObject } from "@fluixi/utils/object";
|
|
6
|
+
import { isArray } from "@fluixi/utils/array";
|
|
7
|
+
import { isFunction } from "@fluixi/utils/functions";
|
|
8
|
+
var isUndefinedOrNull = (element) => {
|
|
9
|
+
if (typeof element === "undefined" || element === null) return true;
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
12
|
+
function isPrimitive(v) {
|
|
13
|
+
const type = typeof v;
|
|
14
|
+
return v === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "bigint" || type === "undefined" || isDate(v);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/lib/compare/comparators.ts
|
|
18
|
+
import { isObject as isObject2 } from "@fluixi/utils/object";
|
|
19
|
+
var hasLength = (data) => {
|
|
20
|
+
const type = typeof data;
|
|
21
|
+
let hasValue = false;
|
|
22
|
+
if (isUndefinedOrNull(data)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
switch (type) {
|
|
26
|
+
case "string":
|
|
27
|
+
hasValue = data.length > 0;
|
|
28
|
+
break;
|
|
29
|
+
case "number":
|
|
30
|
+
hasValue = true;
|
|
31
|
+
break;
|
|
32
|
+
case "object":
|
|
33
|
+
if (Array.isArray(data)) {
|
|
34
|
+
hasValue = data.length > 0;
|
|
35
|
+
} else {
|
|
36
|
+
hasValue = Object.keys(data).length > 0;
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case "boolean":
|
|
40
|
+
hasValue = data;
|
|
41
|
+
}
|
|
42
|
+
return hasValue;
|
|
43
|
+
};
|
|
44
|
+
var isDeepEqual = (compare1, compare2, keys) => {
|
|
45
|
+
if (compare1 === void 0 || compare2 === void 0) return false;
|
|
46
|
+
if (compare1 === null || compare2 === null) return compare1 === compare2;
|
|
47
|
+
if (Array.isArray(compare1) && Array.isArray(compare2)) {
|
|
48
|
+
if (compare1.length !== compare2.length) return false;
|
|
49
|
+
return compare1.every((v, i) => isDeepEqual(v, compare2[i]));
|
|
50
|
+
}
|
|
51
|
+
if (keys && keys.length > 0) {
|
|
52
|
+
if (isPrimitive(compare1) && isPrimitive(compare2))
|
|
53
|
+
return compare1 === compare2;
|
|
54
|
+
if (isObject2(compare1) && isObject2(compare2))
|
|
55
|
+
return keys.every(
|
|
56
|
+
(k) => isDeepEqual(compare1[k], compare2[k])
|
|
57
|
+
);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (isObject2(compare1) && isObject2(compare2)) {
|
|
61
|
+
const obj1Keys = Object.keys(compare1).sort();
|
|
62
|
+
const obj2Keys = Object.keys(compare2).sort();
|
|
63
|
+
if (obj1Keys.length !== obj2Keys.length) return false;
|
|
64
|
+
return obj1Keys.every(
|
|
65
|
+
(key) => isDeepEqual(compare1[key], compare2[key])
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return compare1 === compare2;
|
|
69
|
+
};
|
|
70
|
+
function unorderedArrayEqual(a, b, opts) {
|
|
71
|
+
const used = new Uint8Array(b.length);
|
|
72
|
+
outer: for (let i = 0; i < a.length; i++) {
|
|
73
|
+
for (let j = 0; j < b.length; j++) {
|
|
74
|
+
if (!used[j] && deepEqual(a[i], b[j], opts)) {
|
|
75
|
+
used[j] = 1;
|
|
76
|
+
continue outer;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
var deepEqual = (obj1, obj2, options = {}) => {
|
|
84
|
+
if (obj1 === obj2) return true;
|
|
85
|
+
if (obj1 == null || obj2 == null) return false;
|
|
86
|
+
if (typeof obj1 !== typeof obj2) return false;
|
|
87
|
+
const isArr1 = Array.isArray(obj1);
|
|
88
|
+
const isArr2 = Array.isArray(obj2);
|
|
89
|
+
if (isArr1 !== isArr2) return false;
|
|
90
|
+
if (isArr1 && isArr2) {
|
|
91
|
+
if (obj1.length !== obj2.length) return false;
|
|
92
|
+
return options.unordered ? unorderedArrayEqual(obj1, obj2, options) : obj1.every((item, i) => deepEqual(item, obj2[i], options));
|
|
93
|
+
}
|
|
94
|
+
if (typeof obj1 !== "object") return obj1 === obj2;
|
|
95
|
+
const isDate1 = obj1 instanceof Date;
|
|
96
|
+
const isDate2 = obj2 instanceof Date;
|
|
97
|
+
if (isDate1 !== isDate2) return false;
|
|
98
|
+
if (isDate1) return obj1.getTime() === obj2.getTime();
|
|
99
|
+
const isRE1 = obj1 instanceof RegExp;
|
|
100
|
+
const isRE2 = obj2 instanceof RegExp;
|
|
101
|
+
if (isRE1 !== isRE2) return false;
|
|
102
|
+
if (isRE1) return obj1.toString() === obj2.toString();
|
|
103
|
+
const isMap1 = obj1 instanceof Map;
|
|
104
|
+
const isMap2 = obj2 instanceof Map;
|
|
105
|
+
if (isMap1 !== isMap2) return false;
|
|
106
|
+
if (isMap1) {
|
|
107
|
+
if (obj1.size !== obj2.size) return false;
|
|
108
|
+
for (const [k, v] of obj1) {
|
|
109
|
+
if (!obj2.has(k)) return false;
|
|
110
|
+
if (!deepEqual(v, obj2.get(k), options)) return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const isSet1 = obj1 instanceof Set;
|
|
115
|
+
const isSet2 = obj2 instanceof Set;
|
|
116
|
+
if (isSet1 !== isSet2) return false;
|
|
117
|
+
if (isSet1) {
|
|
118
|
+
if (obj1.size !== obj2.size) return false;
|
|
119
|
+
const bArr = [...obj2];
|
|
120
|
+
const used = new Uint8Array(bArr.length);
|
|
121
|
+
outer: for (const v of obj1) {
|
|
122
|
+
for (let j = 0; j < bArr.length; j++) {
|
|
123
|
+
if (!used[j] && deepEqual(v, bArr[j], options)) {
|
|
124
|
+
used[j] = 1;
|
|
125
|
+
continue outer;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
if (!isObject2(obj1) || !isObject2(obj2)) return false;
|
|
133
|
+
const keys1 = Object.keys(obj1);
|
|
134
|
+
const keys2 = Object.keys(obj2);
|
|
135
|
+
if (keys1.length !== keys2.length) return false;
|
|
136
|
+
for (const key of keys1) {
|
|
137
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key)) return false;
|
|
138
|
+
if (!deepEqual(obj1[key], obj2[key], options)) return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
};
|
|
142
|
+
function isEqual(a, b) {
|
|
143
|
+
return Object.is(a, b);
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
deepEqual,
|
|
147
|
+
hasLength,
|
|
148
|
+
isDeepEqual,
|
|
149
|
+
isEqual
|
|
150
|
+
};
|
|
@@ -1 +1,172 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/utils v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/lib/compare/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
deepEqual: () => deepEqual,
|
|
25
|
+
hasLength: () => hasLength,
|
|
26
|
+
isDeepEqual: () => isDeepEqual,
|
|
27
|
+
isEqual: () => isEqual
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/lib/helpers.ts
|
|
32
|
+
var import_primitive = require("@fluixi/utils/primitive");
|
|
33
|
+
var import_object = require("@fluixi/utils/object");
|
|
34
|
+
var import_array = require("@fluixi/utils/array");
|
|
35
|
+
var import_functions = require("@fluixi/utils/functions");
|
|
36
|
+
var isUndefinedOrNull = (element) => {
|
|
37
|
+
if (typeof element === "undefined" || element === null) return true;
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
function isPrimitive(v) {
|
|
41
|
+
const type = typeof v;
|
|
42
|
+
return v === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "bigint" || type === "undefined" || (0, import_primitive.isDate)(v);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/lib/compare/comparators.ts
|
|
46
|
+
var import_object2 = require("@fluixi/utils/object");
|
|
47
|
+
var hasLength = (data) => {
|
|
48
|
+
const type = typeof data;
|
|
49
|
+
let hasValue = false;
|
|
50
|
+
if (isUndefinedOrNull(data)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
switch (type) {
|
|
54
|
+
case "string":
|
|
55
|
+
hasValue = data.length > 0;
|
|
56
|
+
break;
|
|
57
|
+
case "number":
|
|
58
|
+
hasValue = true;
|
|
59
|
+
break;
|
|
60
|
+
case "object":
|
|
61
|
+
if (Array.isArray(data)) {
|
|
62
|
+
hasValue = data.length > 0;
|
|
63
|
+
} else {
|
|
64
|
+
hasValue = Object.keys(data).length > 0;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case "boolean":
|
|
68
|
+
hasValue = data;
|
|
69
|
+
}
|
|
70
|
+
return hasValue;
|
|
71
|
+
};
|
|
72
|
+
var isDeepEqual = (compare1, compare2, keys) => {
|
|
73
|
+
if (compare1 === void 0 || compare2 === void 0) return false;
|
|
74
|
+
if (compare1 === null || compare2 === null) return compare1 === compare2;
|
|
75
|
+
if (Array.isArray(compare1) && Array.isArray(compare2)) {
|
|
76
|
+
if (compare1.length !== compare2.length) return false;
|
|
77
|
+
return compare1.every((v, i) => isDeepEqual(v, compare2[i]));
|
|
78
|
+
}
|
|
79
|
+
if (keys && keys.length > 0) {
|
|
80
|
+
if (isPrimitive(compare1) && isPrimitive(compare2))
|
|
81
|
+
return compare1 === compare2;
|
|
82
|
+
if ((0, import_object2.isObject)(compare1) && (0, import_object2.isObject)(compare2))
|
|
83
|
+
return keys.every(
|
|
84
|
+
(k) => isDeepEqual(compare1[k], compare2[k])
|
|
85
|
+
);
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if ((0, import_object2.isObject)(compare1) && (0, import_object2.isObject)(compare2)) {
|
|
89
|
+
const obj1Keys = Object.keys(compare1).sort();
|
|
90
|
+
const obj2Keys = Object.keys(compare2).sort();
|
|
91
|
+
if (obj1Keys.length !== obj2Keys.length) return false;
|
|
92
|
+
return obj1Keys.every(
|
|
93
|
+
(key) => isDeepEqual(compare1[key], compare2[key])
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return compare1 === compare2;
|
|
97
|
+
};
|
|
98
|
+
function unorderedArrayEqual(a, b, opts) {
|
|
99
|
+
const used = new Uint8Array(b.length);
|
|
100
|
+
outer: for (let i = 0; i < a.length; i++) {
|
|
101
|
+
for (let j = 0; j < b.length; j++) {
|
|
102
|
+
if (!used[j] && deepEqual(a[i], b[j], opts)) {
|
|
103
|
+
used[j] = 1;
|
|
104
|
+
continue outer;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
var deepEqual = (obj1, obj2, options = {}) => {
|
|
112
|
+
if (obj1 === obj2) return true;
|
|
113
|
+
if (obj1 == null || obj2 == null) return false;
|
|
114
|
+
if (typeof obj1 !== typeof obj2) return false;
|
|
115
|
+
const isArr1 = Array.isArray(obj1);
|
|
116
|
+
const isArr2 = Array.isArray(obj2);
|
|
117
|
+
if (isArr1 !== isArr2) return false;
|
|
118
|
+
if (isArr1 && isArr2) {
|
|
119
|
+
if (obj1.length !== obj2.length) return false;
|
|
120
|
+
return options.unordered ? unorderedArrayEqual(obj1, obj2, options) : obj1.every((item, i) => deepEqual(item, obj2[i], options));
|
|
121
|
+
}
|
|
122
|
+
if (typeof obj1 !== "object") return obj1 === obj2;
|
|
123
|
+
const isDate1 = obj1 instanceof Date;
|
|
124
|
+
const isDate2 = obj2 instanceof Date;
|
|
125
|
+
if (isDate1 !== isDate2) return false;
|
|
126
|
+
if (isDate1) return obj1.getTime() === obj2.getTime();
|
|
127
|
+
const isRE1 = obj1 instanceof RegExp;
|
|
128
|
+
const isRE2 = obj2 instanceof RegExp;
|
|
129
|
+
if (isRE1 !== isRE2) return false;
|
|
130
|
+
if (isRE1) return obj1.toString() === obj2.toString();
|
|
131
|
+
const isMap1 = obj1 instanceof Map;
|
|
132
|
+
const isMap2 = obj2 instanceof Map;
|
|
133
|
+
if (isMap1 !== isMap2) return false;
|
|
134
|
+
if (isMap1) {
|
|
135
|
+
if (obj1.size !== obj2.size) return false;
|
|
136
|
+
for (const [k, v] of obj1) {
|
|
137
|
+
if (!obj2.has(k)) return false;
|
|
138
|
+
if (!deepEqual(v, obj2.get(k), options)) return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
const isSet1 = obj1 instanceof Set;
|
|
143
|
+
const isSet2 = obj2 instanceof Set;
|
|
144
|
+
if (isSet1 !== isSet2) return false;
|
|
145
|
+
if (isSet1) {
|
|
146
|
+
if (obj1.size !== obj2.size) return false;
|
|
147
|
+
const bArr = [...obj2];
|
|
148
|
+
const used = new Uint8Array(bArr.length);
|
|
149
|
+
outer: for (const v of obj1) {
|
|
150
|
+
for (let j = 0; j < bArr.length; j++) {
|
|
151
|
+
if (!used[j] && deepEqual(v, bArr[j], options)) {
|
|
152
|
+
used[j] = 1;
|
|
153
|
+
continue outer;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (!(0, import_object2.isObject)(obj1) || !(0, import_object2.isObject)(obj2)) return false;
|
|
161
|
+
const keys1 = Object.keys(obj1);
|
|
162
|
+
const keys2 = Object.keys(obj2);
|
|
163
|
+
if (keys1.length !== keys2.length) return false;
|
|
164
|
+
for (const key of keys1) {
|
|
165
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key)) return false;
|
|
166
|
+
if (!deepEqual(obj1[key], obj2[key], options)) return false;
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
};
|
|
170
|
+
function isEqual(a, b) {
|
|
171
|
+
return Object.is(a, b);
|
|
172
|
+
}
|
|
@@ -1 +1,152 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/utils v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/lib/helpers.ts
|
|
4
|
+
import {
|
|
5
|
+
isDate
|
|
6
|
+
} from "@fluixi/utils/primitive";
|
|
7
|
+
import { isClass, isObject } from "@fluixi/utils/object";
|
|
8
|
+
import { isArray } from "@fluixi/utils/array";
|
|
9
|
+
import { isFunction } from "@fluixi/utils/functions";
|
|
10
|
+
var isUndefinedOrNull = (element) => {
|
|
11
|
+
if (typeof element === "undefined" || element === null) return true;
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
14
|
+
function isPrimitive(v) {
|
|
15
|
+
const type = typeof v;
|
|
16
|
+
return v === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "bigint" || type === "undefined" || isDate(v);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/lib/compare/comparators.ts
|
|
20
|
+
import { isObject as isObject2 } from "@fluixi/utils/object";
|
|
21
|
+
var hasLength = (data) => {
|
|
22
|
+
const type = typeof data;
|
|
23
|
+
let hasValue = false;
|
|
24
|
+
if (isUndefinedOrNull(data)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
switch (type) {
|
|
28
|
+
case "string":
|
|
29
|
+
hasValue = data.length > 0;
|
|
30
|
+
break;
|
|
31
|
+
case "number":
|
|
32
|
+
hasValue = true;
|
|
33
|
+
break;
|
|
34
|
+
case "object":
|
|
35
|
+
if (Array.isArray(data)) {
|
|
36
|
+
hasValue = data.length > 0;
|
|
37
|
+
} else {
|
|
38
|
+
hasValue = Object.keys(data).length > 0;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case "boolean":
|
|
42
|
+
hasValue = data;
|
|
43
|
+
}
|
|
44
|
+
return hasValue;
|
|
45
|
+
};
|
|
46
|
+
var isDeepEqual = (compare1, compare2, keys) => {
|
|
47
|
+
if (compare1 === void 0 || compare2 === void 0) return false;
|
|
48
|
+
if (compare1 === null || compare2 === null) return compare1 === compare2;
|
|
49
|
+
if (Array.isArray(compare1) && Array.isArray(compare2)) {
|
|
50
|
+
if (compare1.length !== compare2.length) return false;
|
|
51
|
+
return compare1.every((v, i) => isDeepEqual(v, compare2[i]));
|
|
52
|
+
}
|
|
53
|
+
if (keys && keys.length > 0) {
|
|
54
|
+
if (isPrimitive(compare1) && isPrimitive(compare2))
|
|
55
|
+
return compare1 === compare2;
|
|
56
|
+
if (isObject2(compare1) && isObject2(compare2))
|
|
57
|
+
return keys.every(
|
|
58
|
+
(k) => isDeepEqual(compare1[k], compare2[k])
|
|
59
|
+
);
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (isObject2(compare1) && isObject2(compare2)) {
|
|
63
|
+
const obj1Keys = Object.keys(compare1).sort();
|
|
64
|
+
const obj2Keys = Object.keys(compare2).sort();
|
|
65
|
+
if (obj1Keys.length !== obj2Keys.length) return false;
|
|
66
|
+
return obj1Keys.every(
|
|
67
|
+
(key) => isDeepEqual(compare1[key], compare2[key])
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return compare1 === compare2;
|
|
71
|
+
};
|
|
72
|
+
function unorderedArrayEqual(a, b, opts) {
|
|
73
|
+
const used = new Uint8Array(b.length);
|
|
74
|
+
outer: for (let i = 0; i < a.length; i++) {
|
|
75
|
+
for (let j = 0; j < b.length; j++) {
|
|
76
|
+
if (!used[j] && deepEqual(a[i], b[j], opts)) {
|
|
77
|
+
used[j] = 1;
|
|
78
|
+
continue outer;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
var deepEqual = (obj1, obj2, options = {}) => {
|
|
86
|
+
if (obj1 === obj2) return true;
|
|
87
|
+
if (obj1 == null || obj2 == null) return false;
|
|
88
|
+
if (typeof obj1 !== typeof obj2) return false;
|
|
89
|
+
const isArr1 = Array.isArray(obj1);
|
|
90
|
+
const isArr2 = Array.isArray(obj2);
|
|
91
|
+
if (isArr1 !== isArr2) return false;
|
|
92
|
+
if (isArr1 && isArr2) {
|
|
93
|
+
if (obj1.length !== obj2.length) return false;
|
|
94
|
+
return options.unordered ? unorderedArrayEqual(obj1, obj2, options) : obj1.every((item, i) => deepEqual(item, obj2[i], options));
|
|
95
|
+
}
|
|
96
|
+
if (typeof obj1 !== "object") return obj1 === obj2;
|
|
97
|
+
const isDate1 = obj1 instanceof Date;
|
|
98
|
+
const isDate2 = obj2 instanceof Date;
|
|
99
|
+
if (isDate1 !== isDate2) return false;
|
|
100
|
+
if (isDate1) return obj1.getTime() === obj2.getTime();
|
|
101
|
+
const isRE1 = obj1 instanceof RegExp;
|
|
102
|
+
const isRE2 = obj2 instanceof RegExp;
|
|
103
|
+
if (isRE1 !== isRE2) return false;
|
|
104
|
+
if (isRE1) return obj1.toString() === obj2.toString();
|
|
105
|
+
const isMap1 = obj1 instanceof Map;
|
|
106
|
+
const isMap2 = obj2 instanceof Map;
|
|
107
|
+
if (isMap1 !== isMap2) return false;
|
|
108
|
+
if (isMap1) {
|
|
109
|
+
if (obj1.size !== obj2.size) return false;
|
|
110
|
+
for (const [k, v] of obj1) {
|
|
111
|
+
if (!obj2.has(k)) return false;
|
|
112
|
+
if (!deepEqual(v, obj2.get(k), options)) return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const isSet1 = obj1 instanceof Set;
|
|
117
|
+
const isSet2 = obj2 instanceof Set;
|
|
118
|
+
if (isSet1 !== isSet2) return false;
|
|
119
|
+
if (isSet1) {
|
|
120
|
+
if (obj1.size !== obj2.size) return false;
|
|
121
|
+
const bArr = [...obj2];
|
|
122
|
+
const used = new Uint8Array(bArr.length);
|
|
123
|
+
outer: for (const v of obj1) {
|
|
124
|
+
for (let j = 0; j < bArr.length; j++) {
|
|
125
|
+
if (!used[j] && deepEqual(v, bArr[j], options)) {
|
|
126
|
+
used[j] = 1;
|
|
127
|
+
continue outer;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
if (!isObject2(obj1) || !isObject2(obj2)) return false;
|
|
135
|
+
const keys1 = Object.keys(obj1);
|
|
136
|
+
const keys2 = Object.keys(obj2);
|
|
137
|
+
if (keys1.length !== keys2.length) return false;
|
|
138
|
+
for (const key of keys1) {
|
|
139
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key)) return false;
|
|
140
|
+
if (!deepEqual(obj1[key], obj2[key], options)) return false;
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
};
|
|
144
|
+
function isEqual(a, b) {
|
|
145
|
+
return Object.is(a, b);
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
deepEqual,
|
|
149
|
+
hasLength,
|
|
150
|
+
isDeepEqual,
|
|
151
|
+
isEqual
|
|
152
|
+
};
|