@sinclair/typebox 0.32.0-dev-27 → 0.32.0-dev-28
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/build/import/compiler/compiler.mjs +7 -0
- package/build/import/errors/errors.d.mts +16 -15
- package/build/import/errors/errors.mjs +24 -15
- package/build/import/errors/function.mjs +2 -0
- package/build/import/type/clone/value.mjs +6 -2
- package/build/import/type/extends/extends-check.mjs +137 -125
- package/build/import/type/guard/type.d.mts +3 -0
- package/build/import/type/guard/type.mjs +10 -0
- package/build/import/type/guard/value.d.mts +2 -0
- package/build/import/type/guard/value.mjs +4 -0
- package/build/import/type/record/record.d.mts +3 -1
- package/build/import/type/record/record.mjs +10 -5
- package/build/import/type/regexp/regexp.d.mts +11 -4
- package/build/import/type/regexp/regexp.mjs +3 -3
- package/build/import/type/schema/anyschema.d.mts +2 -1
- package/build/import/type/type/javascript.d.mts +2 -2
- package/build/import/type/type/javascript.mjs +1 -1
- package/build/import/value/cast/cast.d.mts +2 -15
- package/build/import/value/cast/cast.mjs +5 -28
- package/build/import/value/check/check.mjs +6 -1
- package/build/import/value/convert/convert.d.mts +0 -5
- package/build/import/value/convert/convert.mjs +0 -12
- package/build/import/value/create/create.d.mts +2 -23
- package/build/import/value/create/create.mjs +30 -53
- package/build/import/value/default/default.mjs +0 -2
- package/build/import/value/delta/delta.d.mts +4 -4
- package/build/import/value/delta/delta.mjs +12 -12
- package/build/import/value/index.d.mts +7 -7
- package/build/import/value/index.mjs +6 -6
- package/build/import/value/mutate/mutate.d.mts +2 -5
- package/build/import/value/mutate/mutate.mjs +5 -10
- package/build/require/compiler/compiler.js +7 -0
- package/build/require/errors/errors.d.ts +16 -15
- package/build/require/errors/errors.js +24 -15
- package/build/require/errors/function.js +2 -0
- package/build/require/type/clone/value.js +6 -2
- package/build/require/type/extends/extends-check.js +137 -125
- package/build/require/type/guard/type.d.ts +3 -0
- package/build/require/type/guard/type.js +12 -1
- package/build/require/type/guard/value.d.ts +2 -0
- package/build/require/type/guard/value.js +6 -1
- package/build/require/type/record/record.d.ts +3 -1
- package/build/require/type/record/record.js +9 -4
- package/build/require/type/regexp/regexp.d.ts +11 -4
- package/build/require/type/regexp/regexp.js +3 -3
- package/build/require/type/schema/anyschema.d.ts +2 -1
- package/build/require/type/type/javascript.d.ts +2 -2
- package/build/require/type/type/javascript.js +1 -1
- package/build/require/value/cast/cast.d.ts +2 -15
- package/build/require/value/cast/cast.js +7 -29
- package/build/require/value/check/check.js +6 -1
- package/build/require/value/convert/convert.d.ts +0 -5
- package/build/require/value/convert/convert.js +31 -43
- package/build/require/value/create/create.d.ts +2 -23
- package/build/require/value/create/create.js +32 -54
- package/build/require/value/default/default.js +0 -2
- package/build/require/value/delta/delta.d.ts +4 -4
- package/build/require/value/delta/delta.js +14 -14
- package/build/require/value/index.d.ts +7 -7
- package/build/require/value/index.js +8 -19
- package/build/require/value/mutate/mutate.d.ts +2 -5
- package/build/require/value/mutate/mutate.js +7 -13
- package/package.json +1 -1
- package/readme.md +8 -7
|
@@ -48,23 +48,23 @@ function IsStructuralRight(right) {
|
|
|
48
48
|
}
|
|
49
49
|
// prettier-ignore
|
|
50
50
|
function StructuralRight(left, right) {
|
|
51
|
-
return (index_10.TypeGuard.IsNever(right) ?
|
|
52
|
-
index_10.TypeGuard.IsIntersect(right) ?
|
|
53
|
-
index_10.TypeGuard.IsUnion(right) ?
|
|
54
|
-
index_10.TypeGuard.IsUnknown(right) ?
|
|
55
|
-
index_10.TypeGuard.IsAny(right) ?
|
|
51
|
+
return (index_10.TypeGuard.IsNever(right) ? FromNeverRight(left, right) :
|
|
52
|
+
index_10.TypeGuard.IsIntersect(right) ? FromIntersectRight(left, right) :
|
|
53
|
+
index_10.TypeGuard.IsUnion(right) ? FromUnionRight(left, right) :
|
|
54
|
+
index_10.TypeGuard.IsUnknown(right) ? FromUnknownRight(left, right) :
|
|
55
|
+
index_10.TypeGuard.IsAny(right) ? FromAnyRight(left, right) :
|
|
56
56
|
Throw('StructuralRight'));
|
|
57
57
|
}
|
|
58
58
|
// ------------------------------------------------------------------
|
|
59
59
|
// Any
|
|
60
60
|
// ------------------------------------------------------------------
|
|
61
61
|
// prettier-ignore
|
|
62
|
-
function
|
|
62
|
+
function FromAnyRight(left, right) {
|
|
63
63
|
return ExtendsResult.True;
|
|
64
64
|
}
|
|
65
65
|
// prettier-ignore
|
|
66
|
-
function
|
|
67
|
-
return (index_10.TypeGuard.IsIntersect(right) ?
|
|
66
|
+
function FromAny(left, right) {
|
|
67
|
+
return (index_10.TypeGuard.IsIntersect(right) ? FromIntersectRight(left, right) :
|
|
68
68
|
(index_10.TypeGuard.IsUnion(right) && right.anyOf.some((schema) => index_10.TypeGuard.IsAny(schema) || index_10.TypeGuard.IsUnknown(schema))) ? ExtendsResult.True :
|
|
69
69
|
index_10.TypeGuard.IsUnion(right) ? ExtendsResult.Union :
|
|
70
70
|
index_10.TypeGuard.IsUnknown(right) ? ExtendsResult.True :
|
|
@@ -75,14 +75,14 @@ function TAny(left, right) {
|
|
|
75
75
|
// Array
|
|
76
76
|
// ------------------------------------------------------------------
|
|
77
77
|
// prettier-ignore
|
|
78
|
-
function
|
|
78
|
+
function FromArrayRight(left, right) {
|
|
79
79
|
return (index_10.TypeGuard.IsUnknown(left) ? ExtendsResult.False :
|
|
80
80
|
index_10.TypeGuard.IsAny(left) ? ExtendsResult.Union :
|
|
81
81
|
index_10.TypeGuard.IsNever(left) ? ExtendsResult.True :
|
|
82
82
|
ExtendsResult.False);
|
|
83
83
|
}
|
|
84
84
|
// prettier-ignore
|
|
85
|
-
function
|
|
85
|
+
function FromArray(left, right) {
|
|
86
86
|
return (index_10.TypeGuard.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
|
|
87
87
|
IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
88
88
|
!index_10.TypeGuard.IsArray(right) ? ExtendsResult.False :
|
|
@@ -92,7 +92,7 @@ function TArray(left, right) {
|
|
|
92
92
|
// AsyncIterator
|
|
93
93
|
// ------------------------------------------------------------------
|
|
94
94
|
// prettier-ignore
|
|
95
|
-
function
|
|
95
|
+
function FromAsyncIterator(left, right) {
|
|
96
96
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
97
97
|
!index_10.TypeGuard.IsAsyncIterator(right) ? ExtendsResult.False :
|
|
98
98
|
IntoBooleanResult(Visit(left.items, right.items)));
|
|
@@ -101,10 +101,10 @@ function TAsyncIterator(left, right) {
|
|
|
101
101
|
// BigInt
|
|
102
102
|
// ------------------------------------------------------------------
|
|
103
103
|
// prettier-ignore
|
|
104
|
-
function
|
|
104
|
+
function FromBigInt(left, right) {
|
|
105
105
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
106
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
107
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
106
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
107
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
108
108
|
index_10.TypeGuard.IsBigInt(right) ? ExtendsResult.True :
|
|
109
109
|
ExtendsResult.False);
|
|
110
110
|
}
|
|
@@ -112,16 +112,16 @@ function TBigInt(left, right) {
|
|
|
112
112
|
// Boolean
|
|
113
113
|
// ------------------------------------------------------------------
|
|
114
114
|
// prettier-ignore
|
|
115
|
-
function
|
|
115
|
+
function FromBooleanRight(left, right) {
|
|
116
116
|
return (index_10.TypeGuard.IsLiteralBoolean(left) ? ExtendsResult.True :
|
|
117
117
|
index_10.TypeGuard.IsBoolean(left) ? ExtendsResult.True :
|
|
118
118
|
ExtendsResult.False);
|
|
119
119
|
}
|
|
120
120
|
// prettier-ignore
|
|
121
|
-
function
|
|
121
|
+
function FromBoolean(left, right) {
|
|
122
122
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
123
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
124
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
123
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
124
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
125
125
|
index_10.TypeGuard.IsBoolean(right) ? ExtendsResult.True :
|
|
126
126
|
ExtendsResult.False);
|
|
127
127
|
}
|
|
@@ -129,9 +129,9 @@ function TBoolean(left, right) {
|
|
|
129
129
|
// Constructor
|
|
130
130
|
// ------------------------------------------------------------------
|
|
131
131
|
// prettier-ignore
|
|
132
|
-
function
|
|
132
|
+
function FromConstructor(left, right) {
|
|
133
133
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
134
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
134
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
135
135
|
!index_10.TypeGuard.IsConstructor(right) ? ExtendsResult.False :
|
|
136
136
|
left.parameters.length > right.parameters.length ? ExtendsResult.False :
|
|
137
137
|
(!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True)) ? ExtendsResult.False :
|
|
@@ -141,10 +141,10 @@ function TConstructor(left, right) {
|
|
|
141
141
|
// Date
|
|
142
142
|
// ------------------------------------------------------------------
|
|
143
143
|
// prettier-ignore
|
|
144
|
-
function
|
|
144
|
+
function FromDate(left, right) {
|
|
145
145
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
146
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
147
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
146
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
147
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
148
148
|
index_10.TypeGuard.IsDate(right) ? ExtendsResult.True :
|
|
149
149
|
ExtendsResult.False);
|
|
150
150
|
}
|
|
@@ -152,9 +152,9 @@ function TDate(left, right) {
|
|
|
152
152
|
// Function
|
|
153
153
|
// ------------------------------------------------------------------
|
|
154
154
|
// prettier-ignore
|
|
155
|
-
function
|
|
155
|
+
function FromFunction(left, right) {
|
|
156
156
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
157
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
157
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
158
158
|
!index_10.TypeGuard.IsFunction(right) ? ExtendsResult.False :
|
|
159
159
|
left.parameters.length > right.parameters.length ? ExtendsResult.False :
|
|
160
160
|
(!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True)) ? ExtendsResult.False :
|
|
@@ -164,30 +164,30 @@ function TFunction(left, right) {
|
|
|
164
164
|
// Integer
|
|
165
165
|
// ------------------------------------------------------------------
|
|
166
166
|
// prettier-ignore
|
|
167
|
-
function
|
|
167
|
+
function FromIntegerRight(left, right) {
|
|
168
168
|
return (index_10.TypeGuard.IsLiteral(left) && index_10.ValueGuard.IsNumber(left.const) ? ExtendsResult.True :
|
|
169
169
|
index_10.TypeGuard.IsNumber(left) || index_10.TypeGuard.IsInteger(left) ? ExtendsResult.True :
|
|
170
170
|
ExtendsResult.False);
|
|
171
171
|
}
|
|
172
172
|
// prettier-ignore
|
|
173
|
-
function
|
|
173
|
+
function FromInteger(left, right) {
|
|
174
174
|
return (index_10.TypeGuard.IsInteger(right) || index_10.TypeGuard.IsNumber(right) ? ExtendsResult.True :
|
|
175
175
|
IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
176
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
177
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
176
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
177
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
178
178
|
ExtendsResult.False);
|
|
179
179
|
}
|
|
180
180
|
// ------------------------------------------------------------------
|
|
181
181
|
// Intersect
|
|
182
182
|
// ------------------------------------------------------------------
|
|
183
183
|
// prettier-ignore
|
|
184
|
-
function
|
|
184
|
+
function FromIntersectRight(left, right) {
|
|
185
185
|
return right.allOf.every((schema) => Visit(left, schema) === ExtendsResult.True)
|
|
186
186
|
? ExtendsResult.True
|
|
187
187
|
: ExtendsResult.False;
|
|
188
188
|
}
|
|
189
189
|
// prettier-ignore
|
|
190
|
-
function
|
|
190
|
+
function FromIntersect(left, right) {
|
|
191
191
|
return left.allOf.some((schema) => Visit(schema, right) === ExtendsResult.True)
|
|
192
192
|
? ExtendsResult.True
|
|
193
193
|
: ExtendsResult.False;
|
|
@@ -196,7 +196,7 @@ function TIntersect(left, right) {
|
|
|
196
196
|
// Iterator
|
|
197
197
|
// ------------------------------------------------------------------
|
|
198
198
|
// prettier-ignore
|
|
199
|
-
function
|
|
199
|
+
function FromIterator(left, right) {
|
|
200
200
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
201
201
|
!index_10.TypeGuard.IsIterator(right) ? ExtendsResult.False :
|
|
202
202
|
IntoBooleanResult(Visit(left.items, right.items)));
|
|
@@ -205,26 +205,26 @@ function TIterator(left, right) {
|
|
|
205
205
|
// Literal
|
|
206
206
|
// ------------------------------------------------------------------
|
|
207
207
|
// prettier-ignore
|
|
208
|
-
function
|
|
208
|
+
function FromLiteral(left, right) {
|
|
209
209
|
return (index_10.TypeGuard.IsLiteral(right) && right.const === left.const ? ExtendsResult.True :
|
|
210
210
|
IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
211
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
212
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
213
|
-
index_10.TypeGuard.IsString(right) ?
|
|
214
|
-
index_10.TypeGuard.IsNumber(right) ?
|
|
215
|
-
index_10.TypeGuard.IsInteger(right) ?
|
|
216
|
-
index_10.TypeGuard.IsBoolean(right) ?
|
|
211
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
212
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
213
|
+
index_10.TypeGuard.IsString(right) ? FromStringRight(left, right) :
|
|
214
|
+
index_10.TypeGuard.IsNumber(right) ? FromNumberRight(left, right) :
|
|
215
|
+
index_10.TypeGuard.IsInteger(right) ? FromIntegerRight(left, right) :
|
|
216
|
+
index_10.TypeGuard.IsBoolean(right) ? FromBooleanRight(left, right) :
|
|
217
217
|
ExtendsResult.False);
|
|
218
218
|
}
|
|
219
219
|
// ------------------------------------------------------------------
|
|
220
220
|
// Never
|
|
221
221
|
// ------------------------------------------------------------------
|
|
222
222
|
// prettier-ignore
|
|
223
|
-
function
|
|
223
|
+
function FromNeverRight(left, right) {
|
|
224
224
|
return ExtendsResult.False;
|
|
225
225
|
}
|
|
226
226
|
// prettier-ignore
|
|
227
|
-
function
|
|
227
|
+
function FromNever(left, right) {
|
|
228
228
|
return ExtendsResult.True;
|
|
229
229
|
}
|
|
230
230
|
// ------------------------------------------------------------------
|
|
@@ -242,7 +242,7 @@ function UnwrapTNot(schema) {
|
|
|
242
242
|
return depth % 2 === 0 ? current : (0, index_5.Unknown)();
|
|
243
243
|
}
|
|
244
244
|
// prettier-ignore
|
|
245
|
-
function
|
|
245
|
+
function FromNot(left, right) {
|
|
246
246
|
// TypeScript has no concept of negated types, and attempts to correctly check the negated
|
|
247
247
|
// type at runtime would put TypeBox at odds with TypeScripts ability to statically infer
|
|
248
248
|
// the type. Instead we unwrap to either unknown or T and continue evaluating.
|
|
@@ -255,10 +255,10 @@ function TNot(left, right) {
|
|
|
255
255
|
// Null
|
|
256
256
|
// ------------------------------------------------------------------
|
|
257
257
|
// prettier-ignore
|
|
258
|
-
function
|
|
258
|
+
function FromNull(left, right) {
|
|
259
259
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
260
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
261
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
260
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
261
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
262
262
|
index_10.TypeGuard.IsNull(right) ? ExtendsResult.True :
|
|
263
263
|
ExtendsResult.False);
|
|
264
264
|
}
|
|
@@ -266,16 +266,16 @@ function TNull(left, right) {
|
|
|
266
266
|
// Number
|
|
267
267
|
// ------------------------------------------------------------------
|
|
268
268
|
// prettier-ignore
|
|
269
|
-
function
|
|
269
|
+
function FromNumberRight(left, right) {
|
|
270
270
|
return (index_10.TypeGuard.IsLiteralNumber(left) ? ExtendsResult.True :
|
|
271
271
|
index_10.TypeGuard.IsNumber(left) || index_10.TypeGuard.IsInteger(left) ? ExtendsResult.True :
|
|
272
272
|
ExtendsResult.False);
|
|
273
273
|
}
|
|
274
274
|
// prettier-ignore
|
|
275
|
-
function
|
|
275
|
+
function FromNumber(left, right) {
|
|
276
276
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
277
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
278
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
277
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
278
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
279
279
|
index_10.TypeGuard.IsInteger(right) || index_10.TypeGuard.IsNumber(right) ? ExtendsResult.True :
|
|
280
280
|
ExtendsResult.False);
|
|
281
281
|
}
|
|
@@ -345,7 +345,7 @@ function Property(left, right) {
|
|
|
345
345
|
ExtendsResult.True);
|
|
346
346
|
}
|
|
347
347
|
// prettier-ignore
|
|
348
|
-
function
|
|
348
|
+
function FromObjectRight(left, right) {
|
|
349
349
|
return (index_10.TypeGuard.IsUnknown(left) ? ExtendsResult.False :
|
|
350
350
|
index_10.TypeGuard.IsAny(left) ? ExtendsResult.Union : (index_10.TypeGuard.IsNever(left) ||
|
|
351
351
|
(index_10.TypeGuard.IsLiteralString(left) && IsObjectStringLike(right)) ||
|
|
@@ -373,9 +373,9 @@ function TObjectRight(left, right) {
|
|
|
373
373
|
ExtendsResult.False);
|
|
374
374
|
}
|
|
375
375
|
// prettier-ignore
|
|
376
|
-
function
|
|
376
|
+
function FromObject(left, right) {
|
|
377
377
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
378
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
378
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
379
379
|
!index_10.TypeGuard.IsObject(right) ? ExtendsResult.False :
|
|
380
380
|
(() => {
|
|
381
381
|
for (const key of Object.getOwnPropertyNames(right.properties)) {
|
|
@@ -396,7 +396,7 @@ function TObject(left, right) {
|
|
|
396
396
|
// Promise
|
|
397
397
|
// ------------------------------------------------------------------
|
|
398
398
|
// prettier-ignore
|
|
399
|
-
function
|
|
399
|
+
function FromPromise(left, right) {
|
|
400
400
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
401
401
|
index_10.TypeGuard.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True :
|
|
402
402
|
!index_10.TypeGuard.IsPromise(right) ? ExtendsResult.False :
|
|
@@ -418,7 +418,7 @@ function RecordValue(schema) {
|
|
|
418
418
|
Throw('Unable to get record value schema'));
|
|
419
419
|
}
|
|
420
420
|
// prettier-ignore
|
|
421
|
-
function
|
|
421
|
+
function FromRecordRight(left, right) {
|
|
422
422
|
const [Key, Value] = [RecordKey(right), RecordValue(right)];
|
|
423
423
|
return ((index_10.TypeGuard.IsLiteralString(left) && index_10.TypeGuard.IsNumber(Key) && IntoBooleanResult(Visit(left, Value)) === ExtendsResult.True) ? ExtendsResult.True :
|
|
424
424
|
index_10.TypeGuard.IsUint8Array(left) && index_10.TypeGuard.IsNumber(Key) ? Visit(left, Value) :
|
|
@@ -435,26 +435,37 @@ function TRecordRight(left, right) {
|
|
|
435
435
|
ExtendsResult.False);
|
|
436
436
|
}
|
|
437
437
|
// prettier-ignore
|
|
438
|
-
function
|
|
438
|
+
function FromRecord(left, right) {
|
|
439
439
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
440
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
440
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
441
441
|
!index_10.TypeGuard.IsRecord(right) ? ExtendsResult.False :
|
|
442
442
|
Visit(RecordValue(left), RecordValue(right)));
|
|
443
443
|
}
|
|
444
444
|
// ------------------------------------------------------------------
|
|
445
|
+
// RegExp
|
|
446
|
+
// ------------------------------------------------------------------
|
|
447
|
+
// prettier-ignore
|
|
448
|
+
function FromRegExp(left, right) {
|
|
449
|
+
// Note: RegExp types evaluate as strings, not RegExp objects.
|
|
450
|
+
// Here we remap either into string and continue evaluating.
|
|
451
|
+
const L = index_10.TypeGuard.IsRegExp(left) ? (0, index_4.String)() : left;
|
|
452
|
+
const R = index_10.TypeGuard.IsRegExp(right) ? (0, index_4.String)() : right;
|
|
453
|
+
return Visit(L, R);
|
|
454
|
+
}
|
|
455
|
+
// ------------------------------------------------------------------
|
|
445
456
|
// String
|
|
446
457
|
// ------------------------------------------------------------------
|
|
447
458
|
// prettier-ignore
|
|
448
|
-
function
|
|
459
|
+
function FromStringRight(left, right) {
|
|
449
460
|
return (index_10.TypeGuard.IsLiteral(left) && index_10.ValueGuard.IsString(left.const) ? ExtendsResult.True :
|
|
450
461
|
index_10.TypeGuard.IsString(left) ? ExtendsResult.True :
|
|
451
462
|
ExtendsResult.False);
|
|
452
463
|
}
|
|
453
464
|
// prettier-ignore
|
|
454
|
-
function
|
|
465
|
+
function FromString(left, right) {
|
|
455
466
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
456
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
457
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
467
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
468
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
458
469
|
index_10.TypeGuard.IsString(right) ? ExtendsResult.True :
|
|
459
470
|
ExtendsResult.False);
|
|
460
471
|
}
|
|
@@ -462,10 +473,10 @@ function TString(left, right) {
|
|
|
462
473
|
// Symbol
|
|
463
474
|
// ------------------------------------------------------------------
|
|
464
475
|
// prettier-ignore
|
|
465
|
-
function
|
|
476
|
+
function FromSymbol(left, right) {
|
|
466
477
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
467
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
468
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
478
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
479
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
469
480
|
index_10.TypeGuard.IsSymbol(right) ? ExtendsResult.True :
|
|
470
481
|
ExtendsResult.False);
|
|
471
482
|
}
|
|
@@ -473,7 +484,7 @@ function TSymbol(left, right) {
|
|
|
473
484
|
// TemplateLiteral
|
|
474
485
|
// ------------------------------------------------------------------
|
|
475
486
|
// prettier-ignore
|
|
476
|
-
function
|
|
487
|
+
function FromTemplateLiteral(left, right) {
|
|
477
488
|
// TemplateLiteral types are resolved to either unions for finite expressions or string
|
|
478
489
|
// for infinite expressions. Here we call to TemplateLiteralResolver to resolve for
|
|
479
490
|
// either type and continue evaluating.
|
|
@@ -491,14 +502,14 @@ function IsArrayOfTuple(left, right) {
|
|
|
491
502
|
left.items.every((schema) => Visit(schema, right.items) === ExtendsResult.True));
|
|
492
503
|
}
|
|
493
504
|
// prettier-ignore
|
|
494
|
-
function
|
|
505
|
+
function FromTupleRight(left, right) {
|
|
495
506
|
return (index_10.TypeGuard.IsNever(left) ? ExtendsResult.True :
|
|
496
507
|
index_10.TypeGuard.IsUnknown(left) ? ExtendsResult.False :
|
|
497
508
|
index_10.TypeGuard.IsAny(left) ? ExtendsResult.Union :
|
|
498
509
|
ExtendsResult.False);
|
|
499
510
|
}
|
|
500
511
|
// prettier-ignore
|
|
501
|
-
function
|
|
512
|
+
function FromTuple(left, right) {
|
|
502
513
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
503
514
|
index_10.TypeGuard.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
|
|
504
515
|
index_10.TypeGuard.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True :
|
|
@@ -512,10 +523,10 @@ function TTuple(left, right) {
|
|
|
512
523
|
// Uint8Array
|
|
513
524
|
// ------------------------------------------------------------------
|
|
514
525
|
// prettier-ignore
|
|
515
|
-
function
|
|
526
|
+
function FromUint8Array(left, right) {
|
|
516
527
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
517
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
518
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
528
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
529
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
519
530
|
index_10.TypeGuard.IsUint8Array(right) ? ExtendsResult.True :
|
|
520
531
|
ExtendsResult.False);
|
|
521
532
|
}
|
|
@@ -523,11 +534,11 @@ function TUint8Array(left, right) {
|
|
|
523
534
|
// Undefined
|
|
524
535
|
// ------------------------------------------------------------------
|
|
525
536
|
// prettier-ignore
|
|
526
|
-
function
|
|
537
|
+
function FromUndefined(left, right) {
|
|
527
538
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
528
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
529
|
-
index_10.TypeGuard.IsRecord(right) ?
|
|
530
|
-
index_10.TypeGuard.IsVoid(right) ?
|
|
539
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
540
|
+
index_10.TypeGuard.IsRecord(right) ? FromRecordRight(left, right) :
|
|
541
|
+
index_10.TypeGuard.IsVoid(right) ? FromVoidRight(left, right) :
|
|
531
542
|
index_10.TypeGuard.IsUndefined(right) ? ExtendsResult.True :
|
|
532
543
|
ExtendsResult.False);
|
|
533
544
|
}
|
|
@@ -535,13 +546,13 @@ function TUndefined(left, right) {
|
|
|
535
546
|
// Union
|
|
536
547
|
// ------------------------------------------------------------------
|
|
537
548
|
// prettier-ignore
|
|
538
|
-
function
|
|
549
|
+
function FromUnionRight(left, right) {
|
|
539
550
|
return right.anyOf.some((schema) => Visit(left, schema) === ExtendsResult.True)
|
|
540
551
|
? ExtendsResult.True
|
|
541
552
|
: ExtendsResult.False;
|
|
542
553
|
}
|
|
543
554
|
// prettier-ignore
|
|
544
|
-
function
|
|
555
|
+
function FromUnion(left, right) {
|
|
545
556
|
return left.anyOf.every((schema) => Visit(schema, right) === ExtendsResult.True)
|
|
546
557
|
? ExtendsResult.True
|
|
547
558
|
: ExtendsResult.False;
|
|
@@ -550,22 +561,22 @@ function TUnion(left, right) {
|
|
|
550
561
|
// Unknown
|
|
551
562
|
// ------------------------------------------------------------------
|
|
552
563
|
// prettier-ignore
|
|
553
|
-
function
|
|
564
|
+
function FromUnknownRight(left, right) {
|
|
554
565
|
return ExtendsResult.True;
|
|
555
566
|
}
|
|
556
567
|
// prettier-ignore
|
|
557
|
-
function
|
|
558
|
-
return (index_10.TypeGuard.IsNever(right) ?
|
|
559
|
-
index_10.TypeGuard.IsIntersect(right) ?
|
|
560
|
-
index_10.TypeGuard.IsUnion(right) ?
|
|
561
|
-
index_10.TypeGuard.IsAny(right) ?
|
|
562
|
-
index_10.TypeGuard.IsString(right) ?
|
|
563
|
-
index_10.TypeGuard.IsNumber(right) ?
|
|
564
|
-
index_10.TypeGuard.IsInteger(right) ?
|
|
565
|
-
index_10.TypeGuard.IsBoolean(right) ?
|
|
566
|
-
index_10.TypeGuard.IsArray(right) ?
|
|
567
|
-
index_10.TypeGuard.IsTuple(right) ?
|
|
568
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
568
|
+
function FromUnknown(left, right) {
|
|
569
|
+
return (index_10.TypeGuard.IsNever(right) ? FromNeverRight(left, right) :
|
|
570
|
+
index_10.TypeGuard.IsIntersect(right) ? FromIntersectRight(left, right) :
|
|
571
|
+
index_10.TypeGuard.IsUnion(right) ? FromUnionRight(left, right) :
|
|
572
|
+
index_10.TypeGuard.IsAny(right) ? FromAnyRight(left, right) :
|
|
573
|
+
index_10.TypeGuard.IsString(right) ? FromStringRight(left, right) :
|
|
574
|
+
index_10.TypeGuard.IsNumber(right) ? FromNumberRight(left, right) :
|
|
575
|
+
index_10.TypeGuard.IsInteger(right) ? FromIntegerRight(left, right) :
|
|
576
|
+
index_10.TypeGuard.IsBoolean(right) ? FromBooleanRight(left, right) :
|
|
577
|
+
index_10.TypeGuard.IsArray(right) ? FromArrayRight(left, right) :
|
|
578
|
+
index_10.TypeGuard.IsTuple(right) ? FromTupleRight(left, right) :
|
|
579
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
569
580
|
index_10.TypeGuard.IsUnknown(right) ? ExtendsResult.True :
|
|
570
581
|
ExtendsResult.False);
|
|
571
582
|
}
|
|
@@ -573,18 +584,18 @@ function TUnknown(left, right) {
|
|
|
573
584
|
// Void
|
|
574
585
|
// ------------------------------------------------------------------
|
|
575
586
|
// prettier-ignore
|
|
576
|
-
function
|
|
587
|
+
function FromVoidRight(left, right) {
|
|
577
588
|
return (index_10.TypeGuard.IsUndefined(left) ? ExtendsResult.True :
|
|
578
589
|
index_10.TypeGuard.IsUndefined(left) ? ExtendsResult.True :
|
|
579
590
|
ExtendsResult.False);
|
|
580
591
|
}
|
|
581
592
|
// prettier-ignore
|
|
582
|
-
function
|
|
583
|
-
return (index_10.TypeGuard.IsIntersect(right) ?
|
|
584
|
-
index_10.TypeGuard.IsUnion(right) ?
|
|
585
|
-
index_10.TypeGuard.IsUnknown(right) ?
|
|
586
|
-
index_10.TypeGuard.IsAny(right) ?
|
|
587
|
-
index_10.TypeGuard.IsObject(right) ?
|
|
593
|
+
function FromVoid(left, right) {
|
|
594
|
+
return (index_10.TypeGuard.IsIntersect(right) ? FromIntersectRight(left, right) :
|
|
595
|
+
index_10.TypeGuard.IsUnion(right) ? FromUnionRight(left, right) :
|
|
596
|
+
index_10.TypeGuard.IsUnknown(right) ? FromUnknownRight(left, right) :
|
|
597
|
+
index_10.TypeGuard.IsAny(right) ? FromAnyRight(left, right) :
|
|
598
|
+
index_10.TypeGuard.IsObject(right) ? FromObjectRight(left, right) :
|
|
588
599
|
index_10.TypeGuard.IsVoid(right) ? ExtendsResult.True :
|
|
589
600
|
ExtendsResult.False);
|
|
590
601
|
}
|
|
@@ -592,36 +603,37 @@ function TVoid(left, right) {
|
|
|
592
603
|
function Visit(left, right) {
|
|
593
604
|
return (
|
|
594
605
|
// resolvable
|
|
595
|
-
(index_10.TypeGuard.IsTemplateLiteral(left) || index_10.TypeGuard.IsTemplateLiteral(right)) ?
|
|
596
|
-
(index_10.TypeGuard.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
index_10.TypeGuard.
|
|
600
|
-
index_10.TypeGuard.
|
|
601
|
-
index_10.TypeGuard.
|
|
602
|
-
index_10.TypeGuard.
|
|
603
|
-
index_10.TypeGuard.
|
|
604
|
-
index_10.TypeGuard.
|
|
605
|
-
index_10.TypeGuard.
|
|
606
|
-
index_10.TypeGuard.
|
|
607
|
-
index_10.TypeGuard.
|
|
608
|
-
index_10.TypeGuard.
|
|
609
|
-
index_10.TypeGuard.
|
|
610
|
-
index_10.TypeGuard.
|
|
611
|
-
index_10.TypeGuard.
|
|
612
|
-
index_10.TypeGuard.
|
|
613
|
-
index_10.TypeGuard.
|
|
614
|
-
index_10.TypeGuard.
|
|
615
|
-
index_10.TypeGuard.
|
|
616
|
-
index_10.TypeGuard.
|
|
617
|
-
index_10.TypeGuard.
|
|
618
|
-
index_10.TypeGuard.
|
|
619
|
-
index_10.TypeGuard.
|
|
620
|
-
index_10.TypeGuard.
|
|
621
|
-
index_10.TypeGuard.
|
|
622
|
-
index_10.TypeGuard.
|
|
623
|
-
index_10.TypeGuard.
|
|
624
|
-
|
|
606
|
+
(index_10.TypeGuard.IsTemplateLiteral(left) || index_10.TypeGuard.IsTemplateLiteral(right)) ? FromTemplateLiteral(left, right) :
|
|
607
|
+
(index_10.TypeGuard.IsRegExp(left) || index_10.TypeGuard.IsRegExp(right)) ? FromRegExp(left, right) :
|
|
608
|
+
(index_10.TypeGuard.IsNot(left) || index_10.TypeGuard.IsNot(right)) ? FromNot(left, right) :
|
|
609
|
+
// standard
|
|
610
|
+
index_10.TypeGuard.IsAny(left) ? FromAny(left, right) :
|
|
611
|
+
index_10.TypeGuard.IsArray(left) ? FromArray(left, right) :
|
|
612
|
+
index_10.TypeGuard.IsBigInt(left) ? FromBigInt(left, right) :
|
|
613
|
+
index_10.TypeGuard.IsBoolean(left) ? FromBoolean(left, right) :
|
|
614
|
+
index_10.TypeGuard.IsAsyncIterator(left) ? FromAsyncIterator(left, right) :
|
|
615
|
+
index_10.TypeGuard.IsConstructor(left) ? FromConstructor(left, right) :
|
|
616
|
+
index_10.TypeGuard.IsDate(left) ? FromDate(left, right) :
|
|
617
|
+
index_10.TypeGuard.IsFunction(left) ? FromFunction(left, right) :
|
|
618
|
+
index_10.TypeGuard.IsInteger(left) ? FromInteger(left, right) :
|
|
619
|
+
index_10.TypeGuard.IsIntersect(left) ? FromIntersect(left, right) :
|
|
620
|
+
index_10.TypeGuard.IsIterator(left) ? FromIterator(left, right) :
|
|
621
|
+
index_10.TypeGuard.IsLiteral(left) ? FromLiteral(left, right) :
|
|
622
|
+
index_10.TypeGuard.IsNever(left) ? FromNever(left, right) :
|
|
623
|
+
index_10.TypeGuard.IsNull(left) ? FromNull(left, right) :
|
|
624
|
+
index_10.TypeGuard.IsNumber(left) ? FromNumber(left, right) :
|
|
625
|
+
index_10.TypeGuard.IsObject(left) ? FromObject(left, right) :
|
|
626
|
+
index_10.TypeGuard.IsRecord(left) ? FromRecord(left, right) :
|
|
627
|
+
index_10.TypeGuard.IsString(left) ? FromString(left, right) :
|
|
628
|
+
index_10.TypeGuard.IsSymbol(left) ? FromSymbol(left, right) :
|
|
629
|
+
index_10.TypeGuard.IsTuple(left) ? FromTuple(left, right) :
|
|
630
|
+
index_10.TypeGuard.IsPromise(left) ? FromPromise(left, right) :
|
|
631
|
+
index_10.TypeGuard.IsUint8Array(left) ? FromUint8Array(left, right) :
|
|
632
|
+
index_10.TypeGuard.IsUndefined(left) ? FromUndefined(left, right) :
|
|
633
|
+
index_10.TypeGuard.IsUnion(left) ? FromUnion(left, right) :
|
|
634
|
+
index_10.TypeGuard.IsUnknown(left) ? FromUnknown(left, right) :
|
|
635
|
+
index_10.TypeGuard.IsVoid(left) ? FromVoid(left, right) :
|
|
636
|
+
Throw(`Unknown left type operand '${left[index_8.Kind]}'`));
|
|
625
637
|
}
|
|
626
638
|
function ExtendsCheck(left, right) {
|
|
627
639
|
return Visit(left, right);
|
|
@@ -26,6 +26,7 @@ import type { TOptional } from '../optional/index';
|
|
|
26
26
|
import type { TPromise } from '../promise/index';
|
|
27
27
|
import type { TReadonly } from '../readonly/index';
|
|
28
28
|
import type { TRef } from '../ref/index';
|
|
29
|
+
import type { TRegExp } from '../regexp/index';
|
|
29
30
|
import type { TSchema } from '../schema/index';
|
|
30
31
|
import type { TSymbol } from '../symbol/index';
|
|
31
32
|
import type { TTuple } from '../tuple/index';
|
|
@@ -104,6 +105,8 @@ export declare function IsRecursive(value: unknown): value is {
|
|
|
104
105
|
};
|
|
105
106
|
/** Returns true if the given value is TRef */
|
|
106
107
|
export declare function IsRef(value: unknown): value is TRef;
|
|
108
|
+
/** Returns true if the given value is TRegExp */
|
|
109
|
+
export declare function IsRegExp(value: unknown): value is TRegExp;
|
|
107
110
|
/** Returns true if the given value is TString */
|
|
108
111
|
export declare function IsString(value: unknown): value is TString;
|
|
109
112
|
/** Returns true if the given value is TSymbol */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.IsSchema = exports.IsKind = exports.IsVoid = exports.IsUnsafe = exports.IsUnknown = exports.IsUint8Array = exports.IsUnion = exports.IsUnionLiteral = exports.IsUndefined = exports.IsTuple = exports.IsTransform = exports.IsThis = exports.IsTemplateLiteral = exports.IsSymbol = exports.IsString = exports.IsRef = exports.IsRecursive = exports.IsRecord = exports.IsPromise = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsNot = exports.IsNever = exports.IsMappedResult = exports.IsMappedKey = exports.IsLiteralValue = exports.IsLiteral = exports.IsLiteralBoolean = exports.IsLiteralNumber = exports.IsLiteralString = exports.IsKindOf = exports.IsIterator = exports.IsIntersect = exports.IsProperties = exports.IsInteger = exports.IsFunction = exports.IsDate = exports.IsConstructor = exports.IsBoolean = exports.IsBigInt = exports.IsAsyncIterator = exports.IsArray = exports.IsAny = exports.IsOptional = exports.IsReadonly = exports.TypeGuardUnknownTypeError = void 0;
|
|
4
|
+
exports.IsSchema = exports.IsKind = exports.IsVoid = exports.IsUnsafe = exports.IsUnknown = exports.IsUint8Array = exports.IsUnion = exports.IsUnionLiteral = exports.IsUndefined = exports.IsTuple = exports.IsTransform = exports.IsThis = exports.IsTemplateLiteral = exports.IsSymbol = exports.IsString = exports.IsRegExp = exports.IsRef = exports.IsRecursive = exports.IsRecord = exports.IsPromise = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsNot = exports.IsNever = exports.IsMappedResult = exports.IsMappedKey = exports.IsLiteralValue = exports.IsLiteral = exports.IsLiteralBoolean = exports.IsLiteralNumber = exports.IsLiteralString = exports.IsKindOf = exports.IsIterator = exports.IsIntersect = exports.IsProperties = exports.IsInteger = exports.IsFunction = exports.IsDate = exports.IsConstructor = exports.IsBoolean = exports.IsBigInt = exports.IsAsyncIterator = exports.IsArray = exports.IsAny = exports.IsOptional = exports.IsReadonly = exports.TypeGuardUnknownTypeError = void 0;
|
|
5
5
|
const ValueGuard = require("./value");
|
|
6
6
|
const index_1 = require("../symbols/index");
|
|
7
7
|
const index_2 = require("../error/index");
|
|
@@ -31,6 +31,7 @@ const KnownTypes = [
|
|
|
31
31
|
'Promise',
|
|
32
32
|
'Record',
|
|
33
33
|
'Ref',
|
|
34
|
+
'RegExp',
|
|
34
35
|
'String',
|
|
35
36
|
'Symbol',
|
|
36
37
|
'TemplateLiteral',
|
|
@@ -360,6 +361,15 @@ function IsRef(value) {
|
|
|
360
361
|
ValueGuard.IsString(value.$ref));
|
|
361
362
|
}
|
|
362
363
|
exports.IsRef = IsRef;
|
|
364
|
+
/** Returns true if the given value is TRegExp */
|
|
365
|
+
function IsRegExp(value) {
|
|
366
|
+
// prettier-ignore
|
|
367
|
+
return (IsKindOf(value, 'RegExp') &&
|
|
368
|
+
IsOptionalString(value.$id) &&
|
|
369
|
+
ValueGuard.IsString(value.source) &&
|
|
370
|
+
ValueGuard.IsString(value.flags));
|
|
371
|
+
}
|
|
372
|
+
exports.IsRegExp = IsRegExp;
|
|
363
373
|
/** Returns true if the given value is TString */
|
|
364
374
|
function IsString(value) {
|
|
365
375
|
// prettier-ignore
|
|
@@ -502,6 +512,7 @@ function IsSchema(value) {
|
|
|
502
512
|
IsPromise(value) ||
|
|
503
513
|
IsRecord(value) ||
|
|
504
514
|
IsRef(value) ||
|
|
515
|
+
IsRegExp(value) ||
|
|
505
516
|
IsString(value) ||
|
|
506
517
|
IsSymbol(value) ||
|
|
507
518
|
IsTemplateLiteral(value) ||
|
|
@@ -18,6 +18,8 @@ export declare function IsNull(value: unknown): value is null;
|
|
|
18
18
|
export declare function IsNumber(value: unknown): value is number;
|
|
19
19
|
/** Returns true if this value is an object */
|
|
20
20
|
export declare function IsObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
21
|
+
/** Returns true if this value is RegExp */
|
|
22
|
+
export declare function IsRegExp(value: unknown): value is RegExp;
|
|
21
23
|
/** Returns true if this value is string */
|
|
22
24
|
export declare function IsString(value: unknown): value is string;
|
|
23
25
|
/** Returns true if this value is symbol */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.IsUndefined = exports.IsUint8Array = exports.IsSymbol = exports.IsString = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsIterator = exports.IsFunction = exports.IsDate = exports.IsBoolean = exports.IsBigInt = exports.IsArray = exports.IsAsyncIterator = void 0;
|
|
4
|
+
exports.IsUndefined = exports.IsUint8Array = exports.IsSymbol = exports.IsString = exports.IsRegExp = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsIterator = exports.IsFunction = exports.IsDate = exports.IsBoolean = exports.IsBigInt = exports.IsArray = exports.IsAsyncIterator = void 0;
|
|
5
5
|
/** Returns true if this value is an async iterator */
|
|
6
6
|
function IsAsyncIterator(value) {
|
|
7
7
|
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
|
|
@@ -52,6 +52,11 @@ function IsObject(value) {
|
|
|
52
52
|
return typeof value === 'object' && value !== null;
|
|
53
53
|
}
|
|
54
54
|
exports.IsObject = IsObject;
|
|
55
|
+
/** Returns true if this value is RegExp */
|
|
56
|
+
function IsRegExp(value) {
|
|
57
|
+
return value instanceof globalThis.RegExp;
|
|
58
|
+
}
|
|
59
|
+
exports.IsRegExp = IsRegExp;
|
|
55
60
|
/** Returns true if this value is string */
|
|
56
61
|
function IsString(value) {
|
|
57
62
|
return typeof value === 'string';
|