@ls-stack/utils 3.43.0 → 3.44.0
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 +37 -0
- package/dist/partialEqual.d.cts +22 -1
- package/dist/partialEqual.d.ts +22 -1
- package/dist/partialEqual.js +37 -0
- package/package.json +1 -1
package/dist/partialEqual.cjs
CHANGED
|
@@ -98,6 +98,15 @@ var Comparisons = class {
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
var match = {
|
|
101
|
+
hasType: {
|
|
102
|
+
string: new Comparisons(["hasType", "string"]),
|
|
103
|
+
number: new Comparisons(["hasType", "number"]),
|
|
104
|
+
boolean: new Comparisons(["hasType", "boolean"]),
|
|
105
|
+
object: new Comparisons(["hasType", "object"]),
|
|
106
|
+
array: new Comparisons(["hasType", "array"]),
|
|
107
|
+
function: new Comparisons(["hasType", "function"])
|
|
108
|
+
},
|
|
109
|
+
isInstanceOf: (constructor) => new Comparisons(["isInstanceOf", constructor]),
|
|
101
110
|
str: {
|
|
102
111
|
contains: (substring) => new Comparisons(["strContains", substring]),
|
|
103
112
|
startsWith: (substring) => new Comparisons(["strStartsWith", substring]),
|
|
@@ -118,6 +127,15 @@ var match = {
|
|
|
118
127
|
partialEqual: (value) => new Comparisons(["partialEqual", value]),
|
|
119
128
|
custom: (isEqual) => new Comparisons(["custom", isEqual]),
|
|
120
129
|
not: {
|
|
130
|
+
hasType: {
|
|
131
|
+
string: new Comparisons(["not", ["hasType", "string"]]),
|
|
132
|
+
number: new Comparisons(["not", ["hasType", "number"]]),
|
|
133
|
+
boolean: new Comparisons(["not", ["hasType", "boolean"]]),
|
|
134
|
+
object: new Comparisons(["not", ["hasType", "object"]]),
|
|
135
|
+
array: new Comparisons(["not", ["hasType", "array"]]),
|
|
136
|
+
function: new Comparisons(["not", ["hasType", "function"]])
|
|
137
|
+
},
|
|
138
|
+
isInstanceOf: (constructor) => new Comparisons(["not", ["isInstanceOf", constructor]]),
|
|
121
139
|
str: {
|
|
122
140
|
contains: (substring) => new Comparisons(["not", ["strContains", substring]]),
|
|
123
141
|
startsWith: (substring) => new Comparisons(["not", ["strStartsWith", substring]]),
|
|
@@ -147,6 +165,25 @@ function find2(iter, tar) {
|
|
|
147
165
|
function executeComparison(target, comparison) {
|
|
148
166
|
const [type, value] = comparison;
|
|
149
167
|
switch (type) {
|
|
168
|
+
case "hasType":
|
|
169
|
+
switch (value) {
|
|
170
|
+
case "string":
|
|
171
|
+
return typeof target === "string";
|
|
172
|
+
case "number":
|
|
173
|
+
return typeof target === "number";
|
|
174
|
+
case "boolean":
|
|
175
|
+
return typeof target === "boolean";
|
|
176
|
+
case "function":
|
|
177
|
+
return typeof target === "function";
|
|
178
|
+
case "array":
|
|
179
|
+
return Array.isArray(target);
|
|
180
|
+
case "object":
|
|
181
|
+
return typeof target === "object" && target !== null && !Array.isArray(target);
|
|
182
|
+
default:
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
case "isInstanceOf":
|
|
186
|
+
return target instanceof value;
|
|
150
187
|
case "strStartsWith":
|
|
151
188
|
return typeof target === "string" && target.startsWith(value);
|
|
152
189
|
case "strEndsWith":
|
package/dist/partialEqual.d.cts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsWith', value: string] | [
|
|
1
|
+
type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsWith', value: string] | [
|
|
2
|
+
type: 'hasType',
|
|
3
|
+
value: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function'
|
|
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];
|
|
2
5
|
declare class Comparisons {
|
|
3
6
|
type: ComparisonsType;
|
|
4
7
|
constructor(type: ComparisonsType);
|
|
5
8
|
}
|
|
6
9
|
declare const match: {
|
|
10
|
+
hasType: {
|
|
11
|
+
string: Comparisons;
|
|
12
|
+
number: Comparisons;
|
|
13
|
+
boolean: Comparisons;
|
|
14
|
+
object: Comparisons;
|
|
15
|
+
array: Comparisons;
|
|
16
|
+
function: Comparisons;
|
|
17
|
+
};
|
|
18
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparisons;
|
|
7
19
|
str: {
|
|
8
20
|
contains: (substring: string) => Comparisons;
|
|
9
21
|
startsWith: (substring: string) => Comparisons;
|
|
@@ -24,6 +36,15 @@ declare const match: {
|
|
|
24
36
|
partialEqual: (value: any) => Comparisons;
|
|
25
37
|
custom: (isEqual: (value: unknown) => boolean) => Comparisons;
|
|
26
38
|
not: {
|
|
39
|
+
hasType: {
|
|
40
|
+
string: Comparisons;
|
|
41
|
+
number: Comparisons;
|
|
42
|
+
boolean: Comparisons;
|
|
43
|
+
object: Comparisons;
|
|
44
|
+
array: Comparisons;
|
|
45
|
+
function: Comparisons;
|
|
46
|
+
};
|
|
47
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparisons;
|
|
27
48
|
str: {
|
|
28
49
|
contains: (substring: string) => Comparisons;
|
|
29
50
|
startsWith: (substring: string) => Comparisons;
|
package/dist/partialEqual.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsWith', value: string] | [
|
|
1
|
+
type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsWith', value: string] | [
|
|
2
|
+
type: 'hasType',
|
|
3
|
+
value: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function'
|
|
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];
|
|
2
5
|
declare class Comparisons {
|
|
3
6
|
type: ComparisonsType;
|
|
4
7
|
constructor(type: ComparisonsType);
|
|
5
8
|
}
|
|
6
9
|
declare const match: {
|
|
10
|
+
hasType: {
|
|
11
|
+
string: Comparisons;
|
|
12
|
+
number: Comparisons;
|
|
13
|
+
boolean: Comparisons;
|
|
14
|
+
object: Comparisons;
|
|
15
|
+
array: Comparisons;
|
|
16
|
+
function: Comparisons;
|
|
17
|
+
};
|
|
18
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparisons;
|
|
7
19
|
str: {
|
|
8
20
|
contains: (substring: string) => Comparisons;
|
|
9
21
|
startsWith: (substring: string) => Comparisons;
|
|
@@ -24,6 +36,15 @@ declare const match: {
|
|
|
24
36
|
partialEqual: (value: any) => Comparisons;
|
|
25
37
|
custom: (isEqual: (value: unknown) => boolean) => Comparisons;
|
|
26
38
|
not: {
|
|
39
|
+
hasType: {
|
|
40
|
+
string: Comparisons;
|
|
41
|
+
number: Comparisons;
|
|
42
|
+
boolean: Comparisons;
|
|
43
|
+
object: Comparisons;
|
|
44
|
+
array: Comparisons;
|
|
45
|
+
function: Comparisons;
|
|
46
|
+
};
|
|
47
|
+
isInstanceOf: (constructor: new (...args: any[]) => any) => Comparisons;
|
|
27
48
|
str: {
|
|
28
49
|
contains: (substring: string) => Comparisons;
|
|
29
50
|
startsWith: (substring: string) => Comparisons;
|
package/dist/partialEqual.js
CHANGED
|
@@ -11,6 +11,15 @@ var Comparisons = class {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
var match = {
|
|
14
|
+
hasType: {
|
|
15
|
+
string: new Comparisons(["hasType", "string"]),
|
|
16
|
+
number: new Comparisons(["hasType", "number"]),
|
|
17
|
+
boolean: new Comparisons(["hasType", "boolean"]),
|
|
18
|
+
object: new Comparisons(["hasType", "object"]),
|
|
19
|
+
array: new Comparisons(["hasType", "array"]),
|
|
20
|
+
function: new Comparisons(["hasType", "function"])
|
|
21
|
+
},
|
|
22
|
+
isInstanceOf: (constructor) => new Comparisons(["isInstanceOf", constructor]),
|
|
14
23
|
str: {
|
|
15
24
|
contains: (substring) => new Comparisons(["strContains", substring]),
|
|
16
25
|
startsWith: (substring) => new Comparisons(["strStartsWith", substring]),
|
|
@@ -31,6 +40,15 @@ var match = {
|
|
|
31
40
|
partialEqual: (value) => new Comparisons(["partialEqual", value]),
|
|
32
41
|
custom: (isEqual) => new Comparisons(["custom", isEqual]),
|
|
33
42
|
not: {
|
|
43
|
+
hasType: {
|
|
44
|
+
string: new Comparisons(["not", ["hasType", "string"]]),
|
|
45
|
+
number: new Comparisons(["not", ["hasType", "number"]]),
|
|
46
|
+
boolean: new Comparisons(["not", ["hasType", "boolean"]]),
|
|
47
|
+
object: new Comparisons(["not", ["hasType", "object"]]),
|
|
48
|
+
array: new Comparisons(["not", ["hasType", "array"]]),
|
|
49
|
+
function: new Comparisons(["not", ["hasType", "function"]])
|
|
50
|
+
},
|
|
51
|
+
isInstanceOf: (constructor) => new Comparisons(["not", ["isInstanceOf", constructor]]),
|
|
34
52
|
str: {
|
|
35
53
|
contains: (substring) => new Comparisons(["not", ["strContains", substring]]),
|
|
36
54
|
startsWith: (substring) => new Comparisons(["not", ["strStartsWith", substring]]),
|
|
@@ -60,6 +78,25 @@ function find(iter, tar) {
|
|
|
60
78
|
function executeComparison(target, comparison) {
|
|
61
79
|
const [type, value] = comparison;
|
|
62
80
|
switch (type) {
|
|
81
|
+
case "hasType":
|
|
82
|
+
switch (value) {
|
|
83
|
+
case "string":
|
|
84
|
+
return typeof target === "string";
|
|
85
|
+
case "number":
|
|
86
|
+
return typeof target === "number";
|
|
87
|
+
case "boolean":
|
|
88
|
+
return typeof target === "boolean";
|
|
89
|
+
case "function":
|
|
90
|
+
return typeof target === "function";
|
|
91
|
+
case "array":
|
|
92
|
+
return Array.isArray(target);
|
|
93
|
+
case "object":
|
|
94
|
+
return typeof target === "object" && target !== null && !Array.isArray(target);
|
|
95
|
+
default:
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
case "isInstanceOf":
|
|
99
|
+
return target instanceof value;
|
|
63
100
|
case "strStartsWith":
|
|
64
101
|
return typeof target === "string" && target.startsWith(value);
|
|
65
102
|
case "strEndsWith":
|