@tstdl/base 0.85.11 → 0.85.12
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.json +1 -1
- package/utils/equals.d.ts +1 -0
- package/utils/equals.js +5 -1
- package/utils/object/property-name.js +7 -3
package/package.json
CHANGED
package/utils/equals.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type ArrayEqualsOptions<A, B> = {
|
|
|
12
12
|
sort?: Comparator<A | B>;
|
|
13
13
|
comparator?: ArrayEqualsComparator<A, B>;
|
|
14
14
|
};
|
|
15
|
+
export declare function strictEquals(a: any, b: any): boolean;
|
|
15
16
|
export declare function arrayEquals<A, B>(a: readonly A[], b: readonly B[], options?: ArrayEqualsOptions<A, B>): boolean;
|
|
16
17
|
export type EqualsOptions = {
|
|
17
18
|
deep?: boolean;
|
package/utils/equals.js
CHANGED
|
@@ -21,7 +21,8 @@ __export(equals_exports, {
|
|
|
21
21
|
Equals: () => Equals,
|
|
22
22
|
arrayEquals: () => arrayEquals,
|
|
23
23
|
binaryEquals: () => binaryEquals,
|
|
24
|
-
equals: () => equals
|
|
24
|
+
equals: () => equals,
|
|
25
|
+
strictEquals: () => strictEquals
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(equals_exports);
|
|
27
28
|
var import_array = require("./array/array.js");
|
|
@@ -33,6 +34,9 @@ const equalsSymbol = Symbol("equals");
|
|
|
33
34
|
const Equals = {
|
|
34
35
|
symbol: equalsSymbol
|
|
35
36
|
};
|
|
37
|
+
function strictEquals(a, b) {
|
|
38
|
+
return a === b;
|
|
39
|
+
}
|
|
36
40
|
function arrayEquals(a, b, options) {
|
|
37
41
|
const _sort = options?.sort ?? false;
|
|
38
42
|
const comparator = options?.comparator ?? equals;
|
|
@@ -39,6 +39,7 @@ function isPropertyName(value) {
|
|
|
39
39
|
const propertyNameProxy = Symbol("PropertyNameProxy");
|
|
40
40
|
function getPropertyNameProxy(options = {}) {
|
|
41
41
|
const { deep = true, flat = false, prefix } = options;
|
|
42
|
+
const cache = /* @__PURE__ */ new Map();
|
|
42
43
|
const proxy = new Proxy({ [propertyNameProxy]: prefix }, {
|
|
43
44
|
get: (_target, property) => {
|
|
44
45
|
if (property == propertyName) {
|
|
@@ -55,10 +56,13 @@ function getPropertyNameProxy(options = {}) {
|
|
|
55
56
|
if (ignore) {
|
|
56
57
|
return proxy;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const cached = cache.get(property);
|
|
60
|
+
if ((0, import_type_guards.isDefined)(cached)) {
|
|
61
|
+
return cached;
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
const newProxy = getPropertyNameProxy({ deep, flat, prefix: deep ? (0, import_type_guards.isUndefined)(prefix) ? property : `${prefix}.${property}` : property });
|
|
64
|
+
cache.set(property, newProxy);
|
|
65
|
+
return newProxy;
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
return proxy;
|