@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.
@@ -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
- var Comparisons = class {
95
- type;
96
- constructor(type) {
97
- this.type = type;
98
- }
99
- };
94
+ function createComparison(type) {
95
+ return {
96
+ "~sc": type
97
+ };
98
+ }
100
99
  var match = {
101
100
  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"])
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) => new Comparisons(["isInstanceOf", constructor]),
108
+ isInstanceOf: (constructor) => createComparison(["isInstanceOf", constructor]),
110
109
  str: {
111
- contains: (substring) => new Comparisons(["strContains", substring]),
112
- startsWith: (substring) => new Comparisons(["strStartsWith", substring]),
113
- endsWith: (substring) => new Comparisons(["strEndsWith", substring]),
114
- matchesRegex: (regex) => new Comparisons(["strMatchesRegex", 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) => new Comparisons(["numIsGreaterThan", value]),
118
- isGreaterThanOrEqual: (value) => new Comparisons(["numIsGreaterThanOrEqual", value]),
119
- isLessThan: (value) => new Comparisons(["numIsLessThan", value]),
120
- isLessThanOrEqual: (value) => new Comparisons(["numIsLessThanOrEqual", value]),
121
- isInRange: (value) => new Comparisons(["numIsInRange", 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) => new Comparisons(["jsonStringHasPartial", value])
123
+ hasPartial: (value) => createComparison(["jsonStringHasPartial", value])
125
124
  },
126
- equal: (value) => new Comparisons(["deepEqual", value]),
127
- partialEqual: (value) => new Comparisons(["partialEqual", value]),
128
- custom: (isEqual) => new Comparisons(["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: 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"]])
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) => new Comparisons(["not", ["isInstanceOf", constructor]]),
137
+ isInstanceOf: (constructor) => createComparison(["not", ["isInstanceOf", constructor]]),
139
138
  str: {
140
- contains: (substring) => new Comparisons(["not", ["strContains", substring]]),
141
- startsWith: (substring) => new Comparisons(["not", ["strStartsWith", substring]]),
142
- endsWith: (substring) => new Comparisons(["not", ["strEndsWith", substring]]),
143
- matchesRegex: (regex) => new Comparisons(["not", ["strMatchesRegex", 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) => new Comparisons(["not", ["numIsGreaterThan", value]]),
147
- isGreaterThanOrEqual: (value) => new Comparisons(["not", ["numIsGreaterThanOrEqual", value]]),
148
- isLessThan: (value) => new Comparisons(["not", ["numIsLessThan", value]]),
149
- isLessThanOrEqual: (value) => new Comparisons(["not", ["numIsLessThanOrEqual", value]]),
150
- isInRange: (value) => new Comparisons(["not", ["numIsInRange", 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) => new Comparisons(["not", ["jsonStringHasPartial", value]])
152
+ hasPartial: (value) => createComparison(["not", ["jsonStringHasPartial", value]])
154
153
  },
155
- equal: (value) => new Comparisons(["not", ["deepEqual", value]]),
156
- partialEqual: (value) => new Comparisons(["not", ["partialEqual", value]]),
157
- custom: (value) => new Comparisons(["not", ["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 instanceof Comparisons) {
228
- return executeComparison(target, sub.type);
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;
@@ -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
- declare class Comparisons {
6
- type: ComparisonsType;
7
- constructor(type: ComparisonsType);
8
- }
5
+ type Comparison = {
6
+ '~sc': ComparisonsType;
7
+ };
9
8
  declare const match: {
10
9
  hasType: {
11
- string: Comparisons;
12
- number: Comparisons;
13
- boolean: Comparisons;
14
- object: Comparisons;
15
- array: Comparisons;
16
- function: Comparisons;
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) => Comparisons;
17
+ isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
19
18
  str: {
20
- contains: (substring: string) => Comparisons;
21
- startsWith: (substring: string) => Comparisons;
22
- endsWith: (substring: string) => Comparisons;
23
- matchesRegex: (regex: RegExp) => Comparisons;
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) => Comparisons;
27
- isGreaterThanOrEqual: (value: number) => Comparisons;
28
- isLessThan: (value: number) => Comparisons;
29
- isLessThanOrEqual: (value: number) => Comparisons;
30
- isInRange: (value: [number, number]) => Comparisons;
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) => Comparisons;
32
+ hasPartial: (value: any) => Comparison;
34
33
  };
35
- equal: (value: any) => Comparisons;
36
- partialEqual: (value: any) => Comparisons;
37
- custom: (isEqual: (value: unknown) => boolean) => Comparisons;
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: Comparisons;
41
- number: Comparisons;
42
- boolean: Comparisons;
43
- object: Comparisons;
44
- array: Comparisons;
45
- function: Comparisons;
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) => Comparisons;
46
+ isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
48
47
  str: {
49
- contains: (substring: string) => Comparisons;
50
- startsWith: (substring: string) => Comparisons;
51
- endsWith: (substring: string) => Comparisons;
52
- matchesRegex: (regex: RegExp) => Comparisons;
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) => Comparisons;
56
- isGreaterThanOrEqual: (value: number) => Comparisons;
57
- isLessThan: (value: number) => Comparisons;
58
- isLessThanOrEqual: (value: number) => Comparisons;
59
- isInRange: (value: [number, number]) => Comparisons;
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) => Comparisons;
61
+ hasPartial: (value: any) => Comparison;
63
62
  };
64
- equal: (value: any) => Comparisons;
65
- partialEqual: (value: any) => Comparisons;
66
- custom: (value: (target: unknown) => boolean) => Comparisons;
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;
@@ -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
- declare class Comparisons {
6
- type: ComparisonsType;
7
- constructor(type: ComparisonsType);
8
- }
5
+ type Comparison = {
6
+ '~sc': ComparisonsType;
7
+ };
9
8
  declare const match: {
10
9
  hasType: {
11
- string: Comparisons;
12
- number: Comparisons;
13
- boolean: Comparisons;
14
- object: Comparisons;
15
- array: Comparisons;
16
- function: Comparisons;
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) => Comparisons;
17
+ isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
19
18
  str: {
20
- contains: (substring: string) => Comparisons;
21
- startsWith: (substring: string) => Comparisons;
22
- endsWith: (substring: string) => Comparisons;
23
- matchesRegex: (regex: RegExp) => Comparisons;
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) => Comparisons;
27
- isGreaterThanOrEqual: (value: number) => Comparisons;
28
- isLessThan: (value: number) => Comparisons;
29
- isLessThanOrEqual: (value: number) => Comparisons;
30
- isInRange: (value: [number, number]) => Comparisons;
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) => Comparisons;
32
+ hasPartial: (value: any) => Comparison;
34
33
  };
35
- equal: (value: any) => Comparisons;
36
- partialEqual: (value: any) => Comparisons;
37
- custom: (isEqual: (value: unknown) => boolean) => Comparisons;
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: Comparisons;
41
- number: Comparisons;
42
- boolean: Comparisons;
43
- object: Comparisons;
44
- array: Comparisons;
45
- function: Comparisons;
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) => Comparisons;
46
+ isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison;
48
47
  str: {
49
- contains: (substring: string) => Comparisons;
50
- startsWith: (substring: string) => Comparisons;
51
- endsWith: (substring: string) => Comparisons;
52
- matchesRegex: (regex: RegExp) => Comparisons;
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) => Comparisons;
56
- isGreaterThanOrEqual: (value: number) => Comparisons;
57
- isLessThan: (value: number) => Comparisons;
58
- isLessThanOrEqual: (value: number) => Comparisons;
59
- isInRange: (value: [number, number]) => Comparisons;
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) => Comparisons;
61
+ hasPartial: (value: any) => Comparison;
63
62
  };
64
- equal: (value: any) => Comparisons;
65
- partialEqual: (value: any) => Comparisons;
66
- custom: (value: (target: unknown) => boolean) => Comparisons;
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;
@@ -4,70 +4,69 @@ import {
4
4
 
5
5
  // src/partialEqual.ts
6
6
  var has = Object.prototype.hasOwnProperty;
7
- var Comparisons = class {
8
- type;
9
- constructor(type) {
10
- this.type = type;
11
- }
12
- };
7
+ function createComparison(type) {
8
+ return {
9
+ "~sc": type
10
+ };
11
+ }
13
12
  var match = {
14
13
  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"])
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) => new Comparisons(["isInstanceOf", constructor]),
21
+ isInstanceOf: (constructor) => createComparison(["isInstanceOf", constructor]),
23
22
  str: {
24
- contains: (substring) => new Comparisons(["strContains", substring]),
25
- startsWith: (substring) => new Comparisons(["strStartsWith", substring]),
26
- endsWith: (substring) => new Comparisons(["strEndsWith", substring]),
27
- matchesRegex: (regex) => new Comparisons(["strMatchesRegex", 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) => new Comparisons(["numIsGreaterThan", value]),
31
- isGreaterThanOrEqual: (value) => new Comparisons(["numIsGreaterThanOrEqual", value]),
32
- isLessThan: (value) => new Comparisons(["numIsLessThan", value]),
33
- isLessThanOrEqual: (value) => new Comparisons(["numIsLessThanOrEqual", value]),
34
- isInRange: (value) => new Comparisons(["numIsInRange", 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) => new Comparisons(["jsonStringHasPartial", value])
36
+ hasPartial: (value) => createComparison(["jsonStringHasPartial", value])
38
37
  },
39
- equal: (value) => new Comparisons(["deepEqual", value]),
40
- partialEqual: (value) => new Comparisons(["partialEqual", value]),
41
- custom: (isEqual) => new Comparisons(["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: 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"]])
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) => new Comparisons(["not", ["isInstanceOf", constructor]]),
50
+ isInstanceOf: (constructor) => createComparison(["not", ["isInstanceOf", constructor]]),
52
51
  str: {
53
- contains: (substring) => new Comparisons(["not", ["strContains", substring]]),
54
- startsWith: (substring) => new Comparisons(["not", ["strStartsWith", substring]]),
55
- endsWith: (substring) => new Comparisons(["not", ["strEndsWith", substring]]),
56
- matchesRegex: (regex) => new Comparisons(["not", ["strMatchesRegex", 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) => new Comparisons(["not", ["numIsGreaterThan", value]]),
60
- isGreaterThanOrEqual: (value) => new Comparisons(["not", ["numIsGreaterThanOrEqual", value]]),
61
- isLessThan: (value) => new Comparisons(["not", ["numIsLessThan", value]]),
62
- isLessThanOrEqual: (value) => new Comparisons(["not", ["numIsLessThanOrEqual", value]]),
63
- isInRange: (value) => new Comparisons(["not", ["numIsInRange", 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) => new Comparisons(["not", ["jsonStringHasPartial", value]])
65
+ hasPartial: (value) => createComparison(["not", ["jsonStringHasPartial", value]])
67
66
  },
68
- equal: (value) => new Comparisons(["not", ["deepEqual", value]]),
69
- partialEqual: (value) => new Comparisons(["not", ["partialEqual", value]]),
70
- custom: (value) => new Comparisons(["not", ["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 instanceof Comparisons) {
141
- return executeComparison(target, sub.type);
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.44.0",
4
+ "version": "3.44.1",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist",