@ls-stack/utils 3.44.0 → 3.44.1
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/partialEqual.cjs +47 -48
- package/dist/partialEqual.d.cts +43 -44
- package/dist/partialEqual.d.ts +43 -44
- package/dist/partialEqual.js +47 -48
- package/package.json +1 -1
package/dist/partialEqual.cjs
CHANGED
|
@@ -91,70 +91,69 @@ function deepEqual(foo, bar, maxDepth = 20) {
|
|
|
91
91
|
|
|
92
92
|
// src/partialEqual.ts
|
|
93
93
|
var has2 = Object.prototype.hasOwnProperty;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
94
|
+
function createComparison(type) {
|
|
95
|
+
return {
|
|
96
|
+
"~sc": type
|
|
97
|
+
};
|
|
98
|
+
}
|
|
100
99
|
var match = {
|
|
101
100
|
hasType: {
|
|
102
|
-
string:
|
|
103
|
-
number:
|
|
104
|
-
boolean:
|
|
105
|
-
object:
|
|
106
|
-
array:
|
|
107
|
-
function:
|
|
101
|
+
string: createComparison(["hasType", "string"]),
|
|
102
|
+
number: createComparison(["hasType", "number"]),
|
|
103
|
+
boolean: createComparison(["hasType", "boolean"]),
|
|
104
|
+
object: createComparison(["hasType", "object"]),
|
|
105
|
+
array: createComparison(["hasType", "array"]),
|
|
106
|
+
function: createComparison(["hasType", "function"])
|
|
108
107
|
},
|
|
109
|
-
isInstanceOf: (constructor) =>
|
|
108
|
+
isInstanceOf: (constructor) => createComparison(["isInstanceOf", constructor]),
|
|
110
109
|
str: {
|
|
111
|
-
contains: (substring) =>
|
|
112
|
-
startsWith: (substring) =>
|
|
113
|
-
endsWith: (substring) =>
|
|
114
|
-
matchesRegex: (regex) =>
|
|
110
|
+
contains: (substring) => createComparison(["strContains", substring]),
|
|
111
|
+
startsWith: (substring) => createComparison(["strStartsWith", substring]),
|
|
112
|
+
endsWith: (substring) => createComparison(["strEndsWith", substring]),
|
|
113
|
+
matchesRegex: (regex) => createComparison(["strMatchesRegex", regex])
|
|
115
114
|
},
|
|
116
115
|
num: {
|
|
117
|
-
isGreaterThan: (value) =>
|
|
118
|
-
isGreaterThanOrEqual: (value) =>
|
|
119
|
-
isLessThan: (value) =>
|
|
120
|
-
isLessThanOrEqual: (value) =>
|
|
121
|
-
isInRange: (value) =>
|
|
116
|
+
isGreaterThan: (value) => createComparison(["numIsGreaterThan", value]),
|
|
117
|
+
isGreaterThanOrEqual: (value) => createComparison(["numIsGreaterThanOrEqual", value]),
|
|
118
|
+
isLessThan: (value) => createComparison(["numIsLessThan", value]),
|
|
119
|
+
isLessThanOrEqual: (value) => createComparison(["numIsLessThanOrEqual", value]),
|
|
120
|
+
isInRange: (value) => createComparison(["numIsInRange", value])
|
|
122
121
|
},
|
|
123
122
|
jsonString: {
|
|
124
|
-
hasPartial: (value) =>
|
|
123
|
+
hasPartial: (value) => createComparison(["jsonStringHasPartial", value])
|
|
125
124
|
},
|
|
126
|
-
equal: (value) =>
|
|
127
|
-
partialEqual: (value) =>
|
|
128
|
-
custom: (isEqual) =>
|
|
125
|
+
equal: (value) => createComparison(["deepEqual", value]),
|
|
126
|
+
partialEqual: (value) => createComparison(["partialEqual", value]),
|
|
127
|
+
custom: (isEqual) => createComparison(["custom", isEqual]),
|
|
129
128
|
not: {
|
|
130
129
|
hasType: {
|
|
131
|
-
string:
|
|
132
|
-
number:
|
|
133
|
-
boolean:
|
|
134
|
-
object:
|
|
135
|
-
array:
|
|
136
|
-
function:
|
|
130
|
+
string: createComparison(["not", ["hasType", "string"]]),
|
|
131
|
+
number: createComparison(["not", ["hasType", "number"]]),
|
|
132
|
+
boolean: createComparison(["not", ["hasType", "boolean"]]),
|
|
133
|
+
object: createComparison(["not", ["hasType", "object"]]),
|
|
134
|
+
array: createComparison(["not", ["hasType", "array"]]),
|
|
135
|
+
function: createComparison(["not", ["hasType", "function"]])
|
|
137
136
|
},
|
|
138
|
-
isInstanceOf: (constructor) =>
|
|
137
|
+
isInstanceOf: (constructor) => createComparison(["not", ["isInstanceOf", constructor]]),
|
|
139
138
|
str: {
|
|
140
|
-
contains: (substring) =>
|
|
141
|
-
startsWith: (substring) =>
|
|
142
|
-
endsWith: (substring) =>
|
|
143
|
-
matchesRegex: (regex) =>
|
|
139
|
+
contains: (substring) => createComparison(["not", ["strContains", substring]]),
|
|
140
|
+
startsWith: (substring) => createComparison(["not", ["strStartsWith", substring]]),
|
|
141
|
+
endsWith: (substring) => createComparison(["not", ["strEndsWith", substring]]),
|
|
142
|
+
matchesRegex: (regex) => createComparison(["not", ["strMatchesRegex", regex]])
|
|
144
143
|
},
|
|
145
144
|
num: {
|
|
146
|
-
isGreaterThan: (value) =>
|
|
147
|
-
isGreaterThanOrEqual: (value) =>
|
|
148
|
-
isLessThan: (value) =>
|
|
149
|
-
isLessThanOrEqual: (value) =>
|
|
150
|
-
isInRange: (value) =>
|
|
145
|
+
isGreaterThan: (value) => createComparison(["not", ["numIsGreaterThan", value]]),
|
|
146
|
+
isGreaterThanOrEqual: (value) => createComparison(["not", ["numIsGreaterThanOrEqual", value]]),
|
|
147
|
+
isLessThan: (value) => createComparison(["not", ["numIsLessThan", value]]),
|
|
148
|
+
isLessThanOrEqual: (value) => createComparison(["not", ["numIsLessThanOrEqual", value]]),
|
|
149
|
+
isInRange: (value) => createComparison(["not", ["numIsInRange", value]])
|
|
151
150
|
},
|
|
152
151
|
jsonString: {
|
|
153
|
-
hasPartial: (value) =>
|
|
152
|
+
hasPartial: (value) => createComparison(["not", ["jsonStringHasPartial", value]])
|
|
154
153
|
},
|
|
155
|
-
equal: (value) =>
|
|
156
|
-
partialEqual: (value) =>
|
|
157
|
-
custom: (value) =>
|
|
154
|
+
equal: (value) => createComparison(["not", ["deepEqual", value]]),
|
|
155
|
+
partialEqual: (value) => createComparison(["not", ["partialEqual", value]]),
|
|
156
|
+
custom: (value) => createComparison(["not", ["custom", value]])
|
|
158
157
|
}
|
|
159
158
|
};
|
|
160
159
|
function find2(iter, tar) {
|
|
@@ -224,8 +223,8 @@ function executeComparison(target, comparison) {
|
|
|
224
223
|
}
|
|
225
224
|
function partialEqual(target, sub) {
|
|
226
225
|
if (sub === target) return true;
|
|
227
|
-
if (sub
|
|
228
|
-
return executeComparison(target, sub
|
|
226
|
+
if (sub && typeof sub === "object" && "~sc" in sub) {
|
|
227
|
+
return executeComparison(target, sub["~sc"]);
|
|
229
228
|
}
|
|
230
229
|
if (sub && target && sub.constructor === target.constructor) {
|
|
231
230
|
const ctor = sub.constructor;
|
package/dist/partialEqual.d.cts
CHANGED
|
@@ -2,68 +2,67 @@ type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsW
|
|
|
2
2
|
type: 'hasType',
|
|
3
3
|
value: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function'
|
|
4
4
|
] | [type: 'strContains', value: string] | [type: 'strMatchesRegex', value: RegExp] | [type: 'deepEqual', value: any] | [type: 'numIsGreaterThan', value: number] | [type: 'numIsGreaterThanOrEqual', value: number] | [type: 'numIsLessThan', value: number] | [type: 'numIsLessThanOrEqual', value: number] | [type: 'numIsInRange', value: [number, number]] | [type: 'jsonStringHasPartial', value: any] | [type: 'partialEqual', value: any] | [type: 'custom', value: (target: unknown) => boolean] | [type: 'isInstanceOf', value: new (...args: any[]) => any] | [type: 'not', value: ComparisonsType];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
type Comparison = {
|
|
6
|
+
'~sc': ComparisonsType;
|
|
7
|
+
};
|
|
9
8
|
declare const match: {
|
|
10
9
|
hasType: {
|
|
11
|
-
string:
|
|
12
|
-
number:
|
|
13
|
-
boolean:
|
|
14
|
-
object:
|
|
15
|
-
array:
|
|
16
|
-
function:
|
|
10
|
+
string: Comparison;
|
|
11
|
+
number: Comparison;
|
|
12
|
+
boolean: Comparison;
|
|
13
|
+
object: Comparison;
|
|
14
|
+
array: Comparison;
|
|
15
|
+
function: Comparison;
|
|
17
16
|
};
|
|
18
|
-
isInstanceOf: (constructor: new (...args: any[]) => any) =>
|
|
17
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
|
|
19
18
|
str: {
|
|
20
|
-
contains: (substring: string) =>
|
|
21
|
-
startsWith: (substring: string) =>
|
|
22
|
-
endsWith: (substring: string) =>
|
|
23
|
-
matchesRegex: (regex: RegExp) =>
|
|
19
|
+
contains: (substring: string) => Comparison;
|
|
20
|
+
startsWith: (substring: string) => Comparison;
|
|
21
|
+
endsWith: (substring: string) => Comparison;
|
|
22
|
+
matchesRegex: (regex: RegExp) => Comparison;
|
|
24
23
|
};
|
|
25
24
|
num: {
|
|
26
|
-
isGreaterThan: (value: number) =>
|
|
27
|
-
isGreaterThanOrEqual: (value: number) =>
|
|
28
|
-
isLessThan: (value: number) =>
|
|
29
|
-
isLessThanOrEqual: (value: number) =>
|
|
30
|
-
isInRange: (value: [number, number]) =>
|
|
25
|
+
isGreaterThan: (value: number) => Comparison;
|
|
26
|
+
isGreaterThanOrEqual: (value: number) => Comparison;
|
|
27
|
+
isLessThan: (value: number) => Comparison;
|
|
28
|
+
isLessThanOrEqual: (value: number) => Comparison;
|
|
29
|
+
isInRange: (value: [number, number]) => Comparison;
|
|
31
30
|
};
|
|
32
31
|
jsonString: {
|
|
33
|
-
hasPartial: (value: any) =>
|
|
32
|
+
hasPartial: (value: any) => Comparison;
|
|
34
33
|
};
|
|
35
|
-
equal: (value: any) =>
|
|
36
|
-
partialEqual: (value: any) =>
|
|
37
|
-
custom: (isEqual: (value: unknown) => boolean) =>
|
|
34
|
+
equal: (value: any) => Comparison;
|
|
35
|
+
partialEqual: (value: any) => Comparison;
|
|
36
|
+
custom: (isEqual: (value: unknown) => boolean) => Comparison;
|
|
38
37
|
not: {
|
|
39
38
|
hasType: {
|
|
40
|
-
string:
|
|
41
|
-
number:
|
|
42
|
-
boolean:
|
|
43
|
-
object:
|
|
44
|
-
array:
|
|
45
|
-
function:
|
|
39
|
+
string: Comparison;
|
|
40
|
+
number: Comparison;
|
|
41
|
+
boolean: Comparison;
|
|
42
|
+
object: Comparison;
|
|
43
|
+
array: Comparison;
|
|
44
|
+
function: Comparison;
|
|
46
45
|
};
|
|
47
|
-
isInstanceOf: (constructor: new (...args: any[]) => any) =>
|
|
46
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
|
|
48
47
|
str: {
|
|
49
|
-
contains: (substring: string) =>
|
|
50
|
-
startsWith: (substring: string) =>
|
|
51
|
-
endsWith: (substring: string) =>
|
|
52
|
-
matchesRegex: (regex: RegExp) =>
|
|
48
|
+
contains: (substring: string) => Comparison;
|
|
49
|
+
startsWith: (substring: string) => Comparison;
|
|
50
|
+
endsWith: (substring: string) => Comparison;
|
|
51
|
+
matchesRegex: (regex: RegExp) => Comparison;
|
|
53
52
|
};
|
|
54
53
|
num: {
|
|
55
|
-
isGreaterThan: (value: number) =>
|
|
56
|
-
isGreaterThanOrEqual: (value: number) =>
|
|
57
|
-
isLessThan: (value: number) =>
|
|
58
|
-
isLessThanOrEqual: (value: number) =>
|
|
59
|
-
isInRange: (value: [number, number]) =>
|
|
54
|
+
isGreaterThan: (value: number) => Comparison;
|
|
55
|
+
isGreaterThanOrEqual: (value: number) => Comparison;
|
|
56
|
+
isLessThan: (value: number) => Comparison;
|
|
57
|
+
isLessThanOrEqual: (value: number) => Comparison;
|
|
58
|
+
isInRange: (value: [number, number]) => Comparison;
|
|
60
59
|
};
|
|
61
60
|
jsonString: {
|
|
62
|
-
hasPartial: (value: any) =>
|
|
61
|
+
hasPartial: (value: any) => Comparison;
|
|
63
62
|
};
|
|
64
|
-
equal: (value: any) =>
|
|
65
|
-
partialEqual: (value: any) =>
|
|
66
|
-
custom: (value: (target: unknown) => boolean) =>
|
|
63
|
+
equal: (value: any) => Comparison;
|
|
64
|
+
partialEqual: (value: any) => Comparison;
|
|
65
|
+
custom: (value: (target: unknown) => boolean) => Comparison;
|
|
67
66
|
};
|
|
68
67
|
};
|
|
69
68
|
declare function partialEqual(target: any, sub: any): boolean;
|
package/dist/partialEqual.d.ts
CHANGED
|
@@ -2,68 +2,67 @@ type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsW
|
|
|
2
2
|
type: 'hasType',
|
|
3
3
|
value: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function'
|
|
4
4
|
] | [type: 'strContains', value: string] | [type: 'strMatchesRegex', value: RegExp] | [type: 'deepEqual', value: any] | [type: 'numIsGreaterThan', value: number] | [type: 'numIsGreaterThanOrEqual', value: number] | [type: 'numIsLessThan', value: number] | [type: 'numIsLessThanOrEqual', value: number] | [type: 'numIsInRange', value: [number, number]] | [type: 'jsonStringHasPartial', value: any] | [type: 'partialEqual', value: any] | [type: 'custom', value: (target: unknown) => boolean] | [type: 'isInstanceOf', value: new (...args: any[]) => any] | [type: 'not', value: ComparisonsType];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
type Comparison = {
|
|
6
|
+
'~sc': ComparisonsType;
|
|
7
|
+
};
|
|
9
8
|
declare const match: {
|
|
10
9
|
hasType: {
|
|
11
|
-
string:
|
|
12
|
-
number:
|
|
13
|
-
boolean:
|
|
14
|
-
object:
|
|
15
|
-
array:
|
|
16
|
-
function:
|
|
10
|
+
string: Comparison;
|
|
11
|
+
number: Comparison;
|
|
12
|
+
boolean: Comparison;
|
|
13
|
+
object: Comparison;
|
|
14
|
+
array: Comparison;
|
|
15
|
+
function: Comparison;
|
|
17
16
|
};
|
|
18
|
-
isInstanceOf: (constructor: new (...args: any[]) => any) =>
|
|
17
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
|
|
19
18
|
str: {
|
|
20
|
-
contains: (substring: string) =>
|
|
21
|
-
startsWith: (substring: string) =>
|
|
22
|
-
endsWith: (substring: string) =>
|
|
23
|
-
matchesRegex: (regex: RegExp) =>
|
|
19
|
+
contains: (substring: string) => Comparison;
|
|
20
|
+
startsWith: (substring: string) => Comparison;
|
|
21
|
+
endsWith: (substring: string) => Comparison;
|
|
22
|
+
matchesRegex: (regex: RegExp) => Comparison;
|
|
24
23
|
};
|
|
25
24
|
num: {
|
|
26
|
-
isGreaterThan: (value: number) =>
|
|
27
|
-
isGreaterThanOrEqual: (value: number) =>
|
|
28
|
-
isLessThan: (value: number) =>
|
|
29
|
-
isLessThanOrEqual: (value: number) =>
|
|
30
|
-
isInRange: (value: [number, number]) =>
|
|
25
|
+
isGreaterThan: (value: number) => Comparison;
|
|
26
|
+
isGreaterThanOrEqual: (value: number) => Comparison;
|
|
27
|
+
isLessThan: (value: number) => Comparison;
|
|
28
|
+
isLessThanOrEqual: (value: number) => Comparison;
|
|
29
|
+
isInRange: (value: [number, number]) => Comparison;
|
|
31
30
|
};
|
|
32
31
|
jsonString: {
|
|
33
|
-
hasPartial: (value: any) =>
|
|
32
|
+
hasPartial: (value: any) => Comparison;
|
|
34
33
|
};
|
|
35
|
-
equal: (value: any) =>
|
|
36
|
-
partialEqual: (value: any) =>
|
|
37
|
-
custom: (isEqual: (value: unknown) => boolean) =>
|
|
34
|
+
equal: (value: any) => Comparison;
|
|
35
|
+
partialEqual: (value: any) => Comparison;
|
|
36
|
+
custom: (isEqual: (value: unknown) => boolean) => Comparison;
|
|
38
37
|
not: {
|
|
39
38
|
hasType: {
|
|
40
|
-
string:
|
|
41
|
-
number:
|
|
42
|
-
boolean:
|
|
43
|
-
object:
|
|
44
|
-
array:
|
|
45
|
-
function:
|
|
39
|
+
string: Comparison;
|
|
40
|
+
number: Comparison;
|
|
41
|
+
boolean: Comparison;
|
|
42
|
+
object: Comparison;
|
|
43
|
+
array: Comparison;
|
|
44
|
+
function: Comparison;
|
|
46
45
|
};
|
|
47
|
-
isInstanceOf: (constructor: new (...args: any[]) => any) =>
|
|
46
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
|
|
48
47
|
str: {
|
|
49
|
-
contains: (substring: string) =>
|
|
50
|
-
startsWith: (substring: string) =>
|
|
51
|
-
endsWith: (substring: string) =>
|
|
52
|
-
matchesRegex: (regex: RegExp) =>
|
|
48
|
+
contains: (substring: string) => Comparison;
|
|
49
|
+
startsWith: (substring: string) => Comparison;
|
|
50
|
+
endsWith: (substring: string) => Comparison;
|
|
51
|
+
matchesRegex: (regex: RegExp) => Comparison;
|
|
53
52
|
};
|
|
54
53
|
num: {
|
|
55
|
-
isGreaterThan: (value: number) =>
|
|
56
|
-
isGreaterThanOrEqual: (value: number) =>
|
|
57
|
-
isLessThan: (value: number) =>
|
|
58
|
-
isLessThanOrEqual: (value: number) =>
|
|
59
|
-
isInRange: (value: [number, number]) =>
|
|
54
|
+
isGreaterThan: (value: number) => Comparison;
|
|
55
|
+
isGreaterThanOrEqual: (value: number) => Comparison;
|
|
56
|
+
isLessThan: (value: number) => Comparison;
|
|
57
|
+
isLessThanOrEqual: (value: number) => Comparison;
|
|
58
|
+
isInRange: (value: [number, number]) => Comparison;
|
|
60
59
|
};
|
|
61
60
|
jsonString: {
|
|
62
|
-
hasPartial: (value: any) =>
|
|
61
|
+
hasPartial: (value: any) => Comparison;
|
|
63
62
|
};
|
|
64
|
-
equal: (value: any) =>
|
|
65
|
-
partialEqual: (value: any) =>
|
|
66
|
-
custom: (value: (target: unknown) => boolean) =>
|
|
63
|
+
equal: (value: any) => Comparison;
|
|
64
|
+
partialEqual: (value: any) => Comparison;
|
|
65
|
+
custom: (value: (target: unknown) => boolean) => Comparison;
|
|
67
66
|
};
|
|
68
67
|
};
|
|
69
68
|
declare function partialEqual(target: any, sub: any): boolean;
|
package/dist/partialEqual.js
CHANGED
|
@@ -4,70 +4,69 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/partialEqual.ts
|
|
6
6
|
var has = Object.prototype.hasOwnProperty;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
7
|
+
function createComparison(type) {
|
|
8
|
+
return {
|
|
9
|
+
"~sc": type
|
|
10
|
+
};
|
|
11
|
+
}
|
|
13
12
|
var match = {
|
|
14
13
|
hasType: {
|
|
15
|
-
string:
|
|
16
|
-
number:
|
|
17
|
-
boolean:
|
|
18
|
-
object:
|
|
19
|
-
array:
|
|
20
|
-
function:
|
|
14
|
+
string: createComparison(["hasType", "string"]),
|
|
15
|
+
number: createComparison(["hasType", "number"]),
|
|
16
|
+
boolean: createComparison(["hasType", "boolean"]),
|
|
17
|
+
object: createComparison(["hasType", "object"]),
|
|
18
|
+
array: createComparison(["hasType", "array"]),
|
|
19
|
+
function: createComparison(["hasType", "function"])
|
|
21
20
|
},
|
|
22
|
-
isInstanceOf: (constructor) =>
|
|
21
|
+
isInstanceOf: (constructor) => createComparison(["isInstanceOf", constructor]),
|
|
23
22
|
str: {
|
|
24
|
-
contains: (substring) =>
|
|
25
|
-
startsWith: (substring) =>
|
|
26
|
-
endsWith: (substring) =>
|
|
27
|
-
matchesRegex: (regex) =>
|
|
23
|
+
contains: (substring) => createComparison(["strContains", substring]),
|
|
24
|
+
startsWith: (substring) => createComparison(["strStartsWith", substring]),
|
|
25
|
+
endsWith: (substring) => createComparison(["strEndsWith", substring]),
|
|
26
|
+
matchesRegex: (regex) => createComparison(["strMatchesRegex", regex])
|
|
28
27
|
},
|
|
29
28
|
num: {
|
|
30
|
-
isGreaterThan: (value) =>
|
|
31
|
-
isGreaterThanOrEqual: (value) =>
|
|
32
|
-
isLessThan: (value) =>
|
|
33
|
-
isLessThanOrEqual: (value) =>
|
|
34
|
-
isInRange: (value) =>
|
|
29
|
+
isGreaterThan: (value) => createComparison(["numIsGreaterThan", value]),
|
|
30
|
+
isGreaterThanOrEqual: (value) => createComparison(["numIsGreaterThanOrEqual", value]),
|
|
31
|
+
isLessThan: (value) => createComparison(["numIsLessThan", value]),
|
|
32
|
+
isLessThanOrEqual: (value) => createComparison(["numIsLessThanOrEqual", value]),
|
|
33
|
+
isInRange: (value) => createComparison(["numIsInRange", value])
|
|
35
34
|
},
|
|
36
35
|
jsonString: {
|
|
37
|
-
hasPartial: (value) =>
|
|
36
|
+
hasPartial: (value) => createComparison(["jsonStringHasPartial", value])
|
|
38
37
|
},
|
|
39
|
-
equal: (value) =>
|
|
40
|
-
partialEqual: (value) =>
|
|
41
|
-
custom: (isEqual) =>
|
|
38
|
+
equal: (value) => createComparison(["deepEqual", value]),
|
|
39
|
+
partialEqual: (value) => createComparison(["partialEqual", value]),
|
|
40
|
+
custom: (isEqual) => createComparison(["custom", isEqual]),
|
|
42
41
|
not: {
|
|
43
42
|
hasType: {
|
|
44
|
-
string:
|
|
45
|
-
number:
|
|
46
|
-
boolean:
|
|
47
|
-
object:
|
|
48
|
-
array:
|
|
49
|
-
function:
|
|
43
|
+
string: createComparison(["not", ["hasType", "string"]]),
|
|
44
|
+
number: createComparison(["not", ["hasType", "number"]]),
|
|
45
|
+
boolean: createComparison(["not", ["hasType", "boolean"]]),
|
|
46
|
+
object: createComparison(["not", ["hasType", "object"]]),
|
|
47
|
+
array: createComparison(["not", ["hasType", "array"]]),
|
|
48
|
+
function: createComparison(["not", ["hasType", "function"]])
|
|
50
49
|
},
|
|
51
|
-
isInstanceOf: (constructor) =>
|
|
50
|
+
isInstanceOf: (constructor) => createComparison(["not", ["isInstanceOf", constructor]]),
|
|
52
51
|
str: {
|
|
53
|
-
contains: (substring) =>
|
|
54
|
-
startsWith: (substring) =>
|
|
55
|
-
endsWith: (substring) =>
|
|
56
|
-
matchesRegex: (regex) =>
|
|
52
|
+
contains: (substring) => createComparison(["not", ["strContains", substring]]),
|
|
53
|
+
startsWith: (substring) => createComparison(["not", ["strStartsWith", substring]]),
|
|
54
|
+
endsWith: (substring) => createComparison(["not", ["strEndsWith", substring]]),
|
|
55
|
+
matchesRegex: (regex) => createComparison(["not", ["strMatchesRegex", regex]])
|
|
57
56
|
},
|
|
58
57
|
num: {
|
|
59
|
-
isGreaterThan: (value) =>
|
|
60
|
-
isGreaterThanOrEqual: (value) =>
|
|
61
|
-
isLessThan: (value) =>
|
|
62
|
-
isLessThanOrEqual: (value) =>
|
|
63
|
-
isInRange: (value) =>
|
|
58
|
+
isGreaterThan: (value) => createComparison(["not", ["numIsGreaterThan", value]]),
|
|
59
|
+
isGreaterThanOrEqual: (value) => createComparison(["not", ["numIsGreaterThanOrEqual", value]]),
|
|
60
|
+
isLessThan: (value) => createComparison(["not", ["numIsLessThan", value]]),
|
|
61
|
+
isLessThanOrEqual: (value) => createComparison(["not", ["numIsLessThanOrEqual", value]]),
|
|
62
|
+
isInRange: (value) => createComparison(["not", ["numIsInRange", value]])
|
|
64
63
|
},
|
|
65
64
|
jsonString: {
|
|
66
|
-
hasPartial: (value) =>
|
|
65
|
+
hasPartial: (value) => createComparison(["not", ["jsonStringHasPartial", value]])
|
|
67
66
|
},
|
|
68
|
-
equal: (value) =>
|
|
69
|
-
partialEqual: (value) =>
|
|
70
|
-
custom: (value) =>
|
|
67
|
+
equal: (value) => createComparison(["not", ["deepEqual", value]]),
|
|
68
|
+
partialEqual: (value) => createComparison(["not", ["partialEqual", value]]),
|
|
69
|
+
custom: (value) => createComparison(["not", ["custom", value]])
|
|
71
70
|
}
|
|
72
71
|
};
|
|
73
72
|
function find(iter, tar) {
|
|
@@ -137,8 +136,8 @@ function executeComparison(target, comparison) {
|
|
|
137
136
|
}
|
|
138
137
|
function partialEqual(target, sub) {
|
|
139
138
|
if (sub === target) return true;
|
|
140
|
-
if (sub
|
|
141
|
-
return executeComparison(target, sub
|
|
139
|
+
if (sub && typeof sub === "object" && "~sc" in sub) {
|
|
140
|
+
return executeComparison(target, sub["~sc"]);
|
|
142
141
|
}
|
|
143
142
|
if (sub && target && sub.constructor === target.constructor) {
|
|
144
143
|
const ctor = sub.constructor;
|