@sinclair/typebox 0.32.0-dev-26 → 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/index.d.mts +2 -2
- package/build/import/type/awaited/awaited.mjs +2 -6
- package/build/import/type/clone/value.mjs +6 -2
- package/build/import/type/composite/composite.d.mts +1 -2
- package/build/import/type/composite/composite.mjs +2 -2
- package/build/import/type/const/const.mjs +6 -6
- package/build/import/type/constructor/constructor.d.mts +1 -1
- package/build/import/type/constructor/constructor.mjs +1 -1
- package/build/import/type/deref/deref.mjs +1 -2
- package/build/import/type/discard/discard.mjs +2 -2
- package/build/import/type/enum/enum.mjs +3 -0
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +5 -5
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +7 -7
- package/build/import/type/exclude/exclude.mjs +0 -1
- package/build/import/type/extends/extends-check.mjs +137 -125
- package/build/import/type/extends/extends-from-mapped-key.d.mts +1 -1
- package/build/import/type/extends/extends-from-mapped-key.mjs +4 -5
- package/build/import/type/extends/extends-from-mapped-result.d.mts +5 -5
- package/build/import/type/extends/extends-from-mapped-result.mjs +7 -7
- package/build/import/type/extends/extends.mjs +0 -1
- package/build/import/type/extract/extract-from-mapped-result.d.mts +5 -5
- package/build/import/type/extract/extract-from-mapped-result.mjs +7 -7
- package/build/import/type/extract/extract.d.mts +1 -2
- package/build/import/type/extract/extract.mjs +4 -2
- 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/index.d.mts +1 -1
- package/build/import/type/index.mjs +1 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +4 -5
- package/build/import/type/indexed/indexed-from-mapped-result.d.mts +1 -1
- package/build/import/type/indexed/indexed-property-keys.d.mts +6 -6
- package/build/import/type/indexed/indexed-property-keys.mjs +3 -5
- package/build/import/type/indexed/indexed.d.mts +1 -1
- package/build/import/type/indexed/indexed.mjs +9 -27
- package/build/import/type/intersect/intersect-evaluated.mjs +3 -13
- package/build/import/type/intrinsic/capitalize.d.mts +2 -2
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +1 -1
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -5
- package/build/import/type/intrinsic/intrinsic.d.mts +2 -3
- package/build/import/type/intrinsic/intrinsic.mjs +2 -5
- package/build/import/type/intrinsic/lowercase.d.mts +2 -2
- package/build/import/type/intrinsic/uncapitalize.d.mts +2 -2
- package/build/import/type/intrinsic/uppercase.d.mts +2 -2
- package/build/import/type/iterator/iterator.mjs +1 -1
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -3
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -4
- package/build/import/type/keyof/keyof-property-keys.d.mts +3 -3
- package/build/import/type/keyof/keyof-property-keys.mjs +9 -15
- package/build/import/type/keyof/keyof.mjs +2 -8
- package/build/import/type/mapped/mapped.d.mts +6 -1
- package/build/import/type/mapped/mapped.mjs +21 -14
- package/build/import/type/not/not.mjs +1 -1
- package/build/import/type/object/object.d.mts +1 -1
- package/build/import/type/object/object.mjs +0 -1
- package/build/import/type/omit/index.d.mts +1 -0
- package/build/import/type/omit/index.mjs +1 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +4 -5
- package/build/import/type/omit/omit-from-mapped-result.d.mts +11 -0
- package/build/import/type/omit/omit-from-mapped-result.mjs +17 -0
- package/build/import/type/omit/omit.d.mts +6 -3
- package/build/import/type/omit/omit.mjs +11 -9
- package/build/import/type/optional/optional-from-mapped-result.d.mts +5 -5
- package/build/import/type/optional/optional-from-mapped-result.mjs +7 -7
- package/build/import/type/partial/partial-from-mapped-result.d.mts +5 -5
- package/build/import/type/partial/partial-from-mapped-result.mjs +4 -4
- package/build/import/type/partial/partial.d.mts +2 -3
- package/build/import/type/partial/partial.mjs +8 -21
- package/build/import/type/pick/index.d.mts +1 -0
- package/build/import/type/pick/index.mjs +1 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +4 -5
- package/build/import/type/pick/pick-from-mapped-result.d.mts +11 -0
- package/build/import/type/pick/pick-from-mapped-result.mjs +17 -0
- package/build/import/type/pick/pick.d.mts +5 -2
- package/build/import/type/pick/pick.mjs +11 -10
- package/build/import/type/promise/promise.mjs +1 -1
- package/build/import/type/readonly/readonly-from-mapped-result.d.mts +5 -5
- package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -4
- package/build/import/type/record/record.d.mts +5 -3
- package/build/import/type/record/record.mjs +13 -5
- package/build/import/type/ref/ref.mjs +1 -1
- package/build/import/type/regexp/regexp.d.mts +11 -4
- package/build/import/type/regexp/regexp.mjs +3 -3
- package/build/import/type/required/required-from-mapped-result.d.mts +5 -5
- package/build/import/type/required/required-from-mapped-result.mjs +7 -7
- package/build/import/type/required/required.d.mts +2 -3
- package/build/import/type/required/required.mjs +4 -14
- package/build/import/type/rest/rest.d.mts +2 -2
- package/build/import/type/rest/rest.mjs +1 -2
- package/build/import/type/schema/anyschema.d.mts +2 -1
- package/build/import/type/sets/index.d.mts +1 -0
- package/build/import/type/sets/index.mjs +1 -0
- package/build/import/type/sets/set.d.mts +24 -0
- package/build/import/type/sets/set.mjs +35 -0
- package/build/import/type/strict/strict.d.mts +1 -1
- package/build/import/type/strict/strict.mjs +1 -1
- package/build/import/type/template-literal/syntax.d.mts +1 -1
- package/build/import/type/template-literal/template-literal.d.mts +1 -1
- package/build/import/type/transform/transform.mjs +1 -1
- package/build/import/type/type/javascript.d.mts +2 -2
- package/build/import/type/type/javascript.mjs +1 -1
- package/build/import/type/type/json.d.mts +6 -2
- package/build/import/type/union/union-evaluated.mjs +3 -14
- 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/index.d.ts +2 -2
- package/build/require/type/awaited/awaited.js +2 -6
- package/build/require/type/clone/value.js +6 -2
- package/build/require/type/composite/composite.d.ts +1 -2
- package/build/require/type/composite/composite.js +5 -6
- package/build/require/type/const/const.js +6 -6
- package/build/require/type/constructor/constructor.d.ts +1 -1
- package/build/require/type/constructor/constructor.js +1 -1
- package/build/require/type/deref/deref.js +0 -1
- package/build/require/type/discard/discard.js +2 -2
- package/build/require/type/enum/enum.js +3 -0
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +5 -5
- package/build/require/type/exclude/exclude-from-mapped-result.js +7 -7
- package/build/require/type/exclude/exclude.js +0 -1
- package/build/require/type/extends/extends-check.js +137 -125
- package/build/require/type/extends/extends-from-mapped-key.d.ts +1 -1
- package/build/require/type/extends/extends-from-mapped-key.js +4 -5
- package/build/require/type/extends/extends-from-mapped-result.d.ts +5 -5
- package/build/require/type/extends/extends-from-mapped-result.js +7 -7
- package/build/require/type/extends/extends.js +0 -1
- package/build/require/type/extract/extract-from-mapped-result.d.ts +5 -5
- package/build/require/type/extract/extract-from-mapped-result.js +7 -7
- package/build/require/type/extract/extract.d.ts +1 -2
- package/build/require/type/extract/extract.js +4 -3
- 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/index.d.ts +1 -1
- package/build/require/type/index.js +1 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
- package/build/require/type/indexed/indexed-from-mapped-key.js +4 -5
- package/build/require/type/indexed/indexed-from-mapped-result.d.ts +1 -1
- package/build/require/type/indexed/indexed-property-keys.d.ts +6 -6
- package/build/require/type/indexed/indexed-property-keys.js +3 -5
- package/build/require/type/indexed/indexed.d.ts +1 -1
- package/build/require/type/indexed/indexed.js +9 -27
- package/build/require/type/intersect/intersect-evaluated.js +3 -13
- package/build/require/type/intrinsic/capitalize.d.ts +2 -2
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +1 -1
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +4 -5
- package/build/require/type/intrinsic/intrinsic.d.ts +2 -3
- package/build/require/type/intrinsic/intrinsic.js +2 -5
- package/build/require/type/intrinsic/lowercase.d.ts +2 -2
- package/build/require/type/intrinsic/uncapitalize.d.ts +2 -2
- package/build/require/type/intrinsic/uppercase.d.ts +2 -2
- package/build/require/type/iterator/iterator.js +1 -1
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -3
- package/build/require/type/keyof/keyof-from-mapped-result.js +4 -4
- package/build/require/type/keyof/keyof-property-keys.d.ts +3 -3
- package/build/require/type/keyof/keyof-property-keys.js +9 -15
- package/build/require/type/keyof/keyof.js +2 -8
- package/build/require/type/mapped/mapped.d.ts +6 -1
- package/build/require/type/mapped/mapped.js +21 -14
- package/build/require/type/not/not.js +1 -1
- package/build/require/type/object/object.d.ts +1 -1
- package/build/require/type/object/object.js +0 -1
- package/build/require/type/omit/index.d.ts +1 -0
- package/build/require/type/omit/index.js +1 -0
- package/build/require/type/omit/omit-from-mapped-key.js +4 -5
- package/build/require/type/omit/omit-from-mapped-result.d.ts +11 -0
- package/build/require/type/omit/omit-from-mapped-result.js +22 -0
- package/build/require/type/omit/omit.d.ts +6 -3
- package/build/require/type/omit/omit.js +10 -8
- package/build/require/type/optional/optional-from-mapped-result.d.ts +5 -5
- package/build/require/type/optional/optional-from-mapped-result.js +7 -7
- package/build/require/type/partial/partial-from-mapped-result.d.ts +5 -5
- package/build/require/type/partial/partial-from-mapped-result.js +4 -4
- package/build/require/type/partial/partial.d.ts +2 -3
- package/build/require/type/partial/partial.js +8 -21
- package/build/require/type/pick/index.d.ts +1 -0
- package/build/require/type/pick/index.js +1 -0
- package/build/require/type/pick/pick-from-mapped-key.js +4 -5
- package/build/require/type/pick/pick-from-mapped-result.d.ts +11 -0
- package/build/require/type/pick/pick-from-mapped-result.js +22 -0
- package/build/require/type/pick/pick.d.ts +5 -2
- package/build/require/type/pick/pick.js +10 -9
- package/build/require/type/promise/promise.js +1 -1
- package/build/require/type/readonly/readonly-from-mapped-result.d.ts +5 -5
- package/build/require/type/readonly/readonly-from-mapped-result.js +4 -4
- package/build/require/type/record/record.d.ts +5 -3
- package/build/require/type/record/record.js +12 -4
- package/build/require/type/ref/ref.js +1 -1
- package/build/require/type/regexp/regexp.d.ts +11 -4
- package/build/require/type/regexp/regexp.js +3 -3
- package/build/require/type/required/required-from-mapped-result.d.ts +5 -5
- package/build/require/type/required/required-from-mapped-result.js +7 -7
- package/build/require/type/required/required.d.ts +2 -3
- package/build/require/type/required/required.js +4 -14
- package/build/require/type/rest/rest.d.ts +2 -2
- package/build/require/type/rest/rest.js +1 -3
- package/build/require/type/schema/anyschema.d.ts +2 -1
- package/build/require/type/sets/index.d.ts +1 -0
- package/build/require/type/{operators → sets}/index.js +1 -1
- package/build/require/type/sets/set.d.ts +24 -0
- package/build/require/type/sets/set.js +47 -0
- package/build/require/type/strict/strict.d.ts +1 -1
- package/build/require/type/strict/strict.js +1 -1
- package/build/require/type/template-literal/parse.js +1 -1
- package/build/require/type/template-literal/syntax.d.ts +1 -1
- package/build/require/type/template-literal/template-literal.d.ts +1 -1
- package/build/require/type/transform/transform.js +1 -1
- package/build/require/type/type/javascript.d.ts +2 -2
- package/build/require/type/type/javascript.js +1 -1
- package/build/require/type/type/json.d.ts +6 -2
- package/build/require/type/union/union-evaluated.js +3 -14
- 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 +68 -67
- package/build/import/type/operators/index.d.mts +0 -1
- package/build/import/type/operators/index.mjs +0 -1
- package/build/import/type/operators/operators.d.mts +0 -24
- package/build/import/type/operators/operators.mjs +0 -77
- package/build/require/type/operators/index.d.ts +0 -1
- package/build/require/type/operators/operators.d.ts +0 -24
- package/build/require/type/operators/operators.js +0 -89
|
@@ -2,10 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExtract } from './extract';
|
|
5
|
-
type TFromProperties<
|
|
6
|
-
[K2 in keyof
|
|
5
|
+
type TFromProperties<P extends TProperties, T extends TSchema> = ({
|
|
6
|
+
[K2 in keyof P]: TExtract<P[K2], T>;
|
|
7
7
|
});
|
|
8
|
-
type TFromMappedResult<
|
|
9
|
-
export type TExtractFromMappedResult<
|
|
10
|
-
export declare function ExtractFromMappedResult<
|
|
8
|
+
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
|
+
export type TExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
+
export declare function ExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T, options: SchemaOptions): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -5,18 +5,18 @@ exports.ExtractFromMappedResult = void 0;
|
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const extract_1 = require("./extract");
|
|
7
7
|
// prettier-ignore
|
|
8
|
-
function FromProperties(
|
|
9
|
-
return globalThis.Object.getOwnPropertyNames(
|
|
10
|
-
return { ...Acc, [K2]: (0, extract_1.Extract)(
|
|
8
|
+
function FromProperties(P, T, options) {
|
|
9
|
+
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
10
|
+
return { ...Acc, [K2]: (0, extract_1.Extract)(P[K2], T, options) };
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromMappedResult(
|
|
15
|
-
return FromProperties(
|
|
14
|
+
function FromMappedResult(R, T, options) {
|
|
15
|
+
return FromProperties(R.properties, T, options);
|
|
16
16
|
}
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
function ExtractFromMappedResult(
|
|
19
|
-
const P = FromMappedResult(
|
|
18
|
+
function ExtractFromMappedResult(R, T, options) {
|
|
19
|
+
const P = FromMappedResult(R, T, options);
|
|
20
20
|
return (0, index_1.MappedResult)(P);
|
|
21
21
|
}
|
|
22
22
|
exports.ExtractFromMappedResult = ExtractFromMappedResult;
|
|
@@ -14,8 +14,7 @@ type TFromTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extra
|
|
|
14
14
|
type TFromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
|
|
15
15
|
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? T[K] : never;
|
|
16
16
|
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
|
|
17
|
-
|
|
18
|
-
export declare function ExtractResolve<L extends TSchema, R extends TSchema>(L: L, R: R): TExtractResolve<L, R>;
|
|
17
|
+
type TExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? TFromTemplateLiteral<T, U> : T extends TUnion<infer S> ? TFromArray<S, U> : T);
|
|
19
18
|
export type TExtract<T extends TSchema, U extends TSchema> = TExtractResolve<T, U>;
|
|
20
19
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
21
20
|
export declare function Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Extract =
|
|
4
|
+
exports.Extract = void 0;
|
|
5
5
|
const index_1 = require("../template-literal/index");
|
|
6
6
|
const index_2 = require("../union/index");
|
|
7
7
|
const index_3 = require("../never/index");
|
|
8
8
|
const index_4 = require("../extends/index");
|
|
9
9
|
const type_1 = require("../clone/type");
|
|
10
10
|
const extract_from_mapped_result_1 = require("./extract-from-mapped-result");
|
|
11
|
-
//
|
|
11
|
+
// ------------------------------------------------------------------
|
|
12
|
+
// TypeGuard
|
|
13
|
+
// ------------------------------------------------------------------
|
|
12
14
|
const type_2 = require("../guard/type");
|
|
13
15
|
// prettier-ignore
|
|
14
16
|
function ExtractResolve(L, R) {
|
|
@@ -21,7 +23,6 @@ function ExtractResolve(L, R) {
|
|
|
21
23
|
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? L :
|
|
22
24
|
(0, index_3.Never)());
|
|
23
25
|
}
|
|
24
|
-
exports.ExtractResolve = ExtractResolve;
|
|
25
26
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
26
27
|
function Extract(type, union, options = {}) {
|
|
27
28
|
if ((0, type_2.IsMappedResult)(type)) {
|
|
@@ -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';
|
|
@@ -35,7 +35,6 @@ export * from './null/index';
|
|
|
35
35
|
export * from './number/index';
|
|
36
36
|
export * from './object/index';
|
|
37
37
|
export * from './omit/index';
|
|
38
|
-
export * from './operators/index';
|
|
39
38
|
export * from './optional/index';
|
|
40
39
|
export * from './parameters/index';
|
|
41
40
|
export * from './partial/index';
|
|
@@ -53,6 +52,7 @@ export * from './required/index';
|
|
|
53
52
|
export * from './rest/index';
|
|
54
53
|
export * from './return-type/index';
|
|
55
54
|
export * from './schema/index';
|
|
55
|
+
export * from './sets/index';
|
|
56
56
|
export * from './static/index';
|
|
57
57
|
export * from './strict/index';
|
|
58
58
|
export * from './string/index';
|
|
@@ -52,7 +52,6 @@ __exportStar(require("./null/index"), exports);
|
|
|
52
52
|
__exportStar(require("./number/index"), exports);
|
|
53
53
|
__exportStar(require("./object/index"), exports);
|
|
54
54
|
__exportStar(require("./omit/index"), exports);
|
|
55
|
-
__exportStar(require("./operators/index"), exports);
|
|
56
55
|
__exportStar(require("./optional/index"), exports);
|
|
57
56
|
__exportStar(require("./parameters/index"), exports);
|
|
58
57
|
__exportStar(require("./partial/index"), exports);
|
|
@@ -70,6 +69,7 @@ __exportStar(require("./required/index"), exports);
|
|
|
70
69
|
__exportStar(require("./rest/index"), exports);
|
|
71
70
|
__exportStar(require("./return-type/index"), exports);
|
|
72
71
|
__exportStar(require("./schema/index"), exports);
|
|
72
|
+
__exportStar(require("./sets/index"), exports);
|
|
73
73
|
__exportStar(require("./static/index"), exports);
|
|
74
74
|
__exportStar(require("./strict/index"), exports);
|
|
75
75
|
__exportStar(require("./string/index"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import {
|
|
2
|
+
import type { Evaluate } from '../helpers/index';
|
|
3
|
+
import type { TProperties } from '../object/index';
|
|
3
4
|
import { type TIndex } from './indexed';
|
|
4
5
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
5
|
-
import { Evaluate } from '../helpers/index';
|
|
6
6
|
type TMappedIndexPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
7
7
|
[_ in K]: TIndex<T, [K]>;
|
|
8
8
|
};
|
|
@@ -9,11 +9,10 @@ function MappedIndexPropertyKey(T, K, options) {
|
|
|
9
9
|
return { [K]: (0, indexed_1.Index)(T, [K], options) };
|
|
10
10
|
}
|
|
11
11
|
// prettier-ignore
|
|
12
|
-
function MappedIndexPropertyKeys(T, K, options
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
: Acc);
|
|
12
|
+
function MappedIndexPropertyKeys(T, K, options) {
|
|
13
|
+
return K.reduce((Acc, L) => {
|
|
14
|
+
return { ...Acc, ...MappedIndexPropertyKey(T, L, options) };
|
|
15
|
+
}, {});
|
|
17
16
|
}
|
|
18
17
|
// prettier-ignore
|
|
19
18
|
function MappedIndexProperties(T, K, options) {
|
|
@@ -6,7 +6,7 @@ import { type TIndex } from './index';
|
|
|
6
6
|
type TFromProperties<T extends TSchema, P extends TProperties> = ({
|
|
7
7
|
[K2 in keyof P]: TIndex<T, TIndexPropertyKeys<P[K2]>>;
|
|
8
8
|
});
|
|
9
|
-
type TFromMappedResult<T extends TSchema,
|
|
9
|
+
type TFromMappedResult<T extends TSchema, R extends TMappedResult> = (TFromProperties<T, R['properties']>);
|
|
10
10
|
export type TIndexFromMappedResult<T extends TSchema, R extends TMappedResult, P extends TProperties = TFromMappedResult<T, R>> = (TMappedResult<P>);
|
|
11
11
|
export declare function IndexFromMappedResult<T extends TSchema, R extends TMappedResult, P extends TProperties = TFromMappedResult<T, R>>(T: T, R: R, options: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { type TTemplateLiteralGenerate, type TTemplateLiteral } from '../template-literal/index';
|
|
2
|
+
import type { TLiteral, TLiteralValue } from '../literal/index';
|
|
3
|
+
import type { TInteger } from '../integer/index';
|
|
4
|
+
import type { TNumber } from '../number/index';
|
|
5
|
+
import type { TSchema } from '../schema/index';
|
|
6
|
+
import type { TUnion } from '../union/index';
|
|
7
7
|
type TFromTemplateLiteral<T extends TTemplateLiteral, R extends string[] = TTemplateLiteralGenerate<T>> = (R);
|
|
8
8
|
type TFromUnion<T extends TSchema[], Acc extends string[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...TIndexPropertyKeys<L>, ...Acc]> : Acc);
|
|
9
9
|
type TFromLiteral<T extends TLiteralValue> = (T extends PropertyKey ? [`${T}`] : []);
|
|
@@ -6,7 +6,6 @@ const index_1 = require("../template-literal/index");
|
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
// TypeGuard
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
|
-
// prettier-ignore
|
|
10
9
|
const type_1 = require("../guard/type");
|
|
11
10
|
// prettier-ignore
|
|
12
11
|
function FromTemplateLiteral(T) {
|
|
@@ -15,10 +14,9 @@ function FromTemplateLiteral(T) {
|
|
|
15
14
|
}
|
|
16
15
|
// prettier-ignore
|
|
17
16
|
function FromUnion(T) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: []);
|
|
17
|
+
return T.reduce((Acc, L) => {
|
|
18
|
+
return [...Acc, ...IndexPropertyKeys(L)];
|
|
19
|
+
}, []);
|
|
22
20
|
}
|
|
23
21
|
// prettier-ignore
|
|
24
22
|
function FromLiteral(T) {
|
|
@@ -16,7 +16,7 @@ import { type TIndexFromMappedResult } from './indexed-from-mapped-result';
|
|
|
16
16
|
type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TFromKey<L, K>, TSchema>]> : Acc);
|
|
17
17
|
type TFromIntersectRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? TFromIntersectRest<R, [...Acc]> : TFromIntersectRest<R, [...Acc, L]> : Acc);
|
|
18
18
|
type TFromIntersect<T extends TSchema[], K extends PropertyKey> = (TIntersectEvaluated<TFromIntersectRest<TFromRest<T, K>>>);
|
|
19
|
-
type TFromUnionRest<T extends TSchema[]
|
|
19
|
+
type TFromUnionRest<T extends TSchema[]> = T;
|
|
20
20
|
type TFromUnion<T extends TSchema[], K extends PropertyKey> = (TUnionEvaluated<TFromUnionRest<TFromRest<T, K>>>);
|
|
21
21
|
type TFromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? TUnionEvaluated<T> : TNever);
|
|
22
22
|
type TFromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
|
|
@@ -14,33 +14,20 @@ const indexed_from_mapped_result_1 = require("./indexed-from-mapped-result");
|
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
15
|
const type_2 = require("../guard/type");
|
|
16
16
|
// prettier-ignore
|
|
17
|
-
function FromRest(T, K
|
|
18
|
-
|
|
19
|
-
return (T.length > 0
|
|
20
|
-
? FromRest(R, K, [...Acc, FromKey(L, K)])
|
|
21
|
-
: Acc);
|
|
17
|
+
function FromRest(T, K) {
|
|
18
|
+
return T.map(L => FromKey(L, K));
|
|
22
19
|
}
|
|
23
20
|
// prettier-ignore
|
|
24
|
-
function FromIntersectRest(T
|
|
25
|
-
|
|
26
|
-
return (T.length > 0
|
|
27
|
-
? (0, type_2.IsNever)(L)
|
|
28
|
-
? FromIntersectRest(R, [...Acc])
|
|
29
|
-
: FromIntersectRest(R, [...Acc, L])
|
|
30
|
-
: Acc);
|
|
21
|
+
function FromIntersectRest(T) {
|
|
22
|
+
return T.filter(L => !(0, type_2.IsNever)(L));
|
|
31
23
|
}
|
|
32
24
|
// prettier-ignore
|
|
33
25
|
function FromIntersect(T, K) {
|
|
34
26
|
return ((0, index_2.IntersectEvaluated)(FromIntersectRest(FromRest(T, K))));
|
|
35
27
|
}
|
|
36
28
|
// prettier-ignore
|
|
37
|
-
function FromUnionRest(T
|
|
38
|
-
|
|
39
|
-
return (T.length > 0
|
|
40
|
-
? (0, type_2.IsNever)(L)
|
|
41
|
-
? []
|
|
42
|
-
: FromUnionRest(R, Acc)
|
|
43
|
-
: Acc);
|
|
29
|
+
function FromUnionRest(T) {
|
|
30
|
+
return T; // review this
|
|
44
31
|
}
|
|
45
32
|
// prettier-ignore
|
|
46
33
|
function FromUnion(T, K) {
|
|
@@ -60,9 +47,7 @@ function FromArray(T, K) {
|
|
|
60
47
|
}
|
|
61
48
|
// prettier-ignore
|
|
62
49
|
function FromProperty(T, K) {
|
|
63
|
-
return (K in T
|
|
64
|
-
? T[K]
|
|
65
|
-
: (0, index_1.Never)());
|
|
50
|
+
return (K in T ? T[K] : (0, index_1.Never)());
|
|
66
51
|
}
|
|
67
52
|
// prettier-ignore
|
|
68
53
|
function FromKey(T, K) {
|
|
@@ -74,11 +59,8 @@ function FromKey(T, K) {
|
|
|
74
59
|
(0, index_1.Never)());
|
|
75
60
|
}
|
|
76
61
|
// prettier-ignore
|
|
77
|
-
function FromKeys(T, K
|
|
78
|
-
|
|
79
|
-
return (K.length > 0
|
|
80
|
-
? FromKeys(T, R, [...Acc, FromKey(T, L)])
|
|
81
|
-
: Acc);
|
|
62
|
+
function FromKeys(T, K) {
|
|
63
|
+
return K.map(L => FromKey(T, L));
|
|
82
64
|
}
|
|
83
65
|
// prettier-ignore
|
|
84
66
|
function FromSchema(T, K) {
|
|
@@ -15,25 +15,15 @@ const intersect_create_1 = require("./intersect-create");
|
|
|
15
15
|
const type_2 = require("../guard/type");
|
|
16
16
|
// prettier-ignore
|
|
17
17
|
function IsIntersectOptional(T) {
|
|
18
|
-
|
|
19
|
-
return (T.length > 0
|
|
20
|
-
? (0, type_2.IsOptional)(L)
|
|
21
|
-
? IsIntersectOptional(R)
|
|
22
|
-
: false
|
|
23
|
-
: true);
|
|
18
|
+
return T.every(L => (0, type_2.IsOptional)(L));
|
|
24
19
|
}
|
|
25
20
|
// prettier-ignore
|
|
26
21
|
function RemoveOptionalFromType(T) {
|
|
27
22
|
return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
|
|
28
23
|
}
|
|
29
24
|
// prettier-ignore
|
|
30
|
-
function RemoveOptionalFromRest(T
|
|
31
|
-
|
|
32
|
-
return (T.length > 0
|
|
33
|
-
? (0, type_2.IsOptional)(L)
|
|
34
|
-
? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
|
|
35
|
-
: RemoveOptionalFromRest(R, [...Acc, L])
|
|
36
|
-
: Acc);
|
|
25
|
+
function RemoveOptionalFromRest(T) {
|
|
26
|
+
return T.map(L => (0, type_2.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
|
|
37
27
|
}
|
|
38
28
|
// prettier-ignore
|
|
39
29
|
function ResolveIntersect(T, options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import { TIntrinsic } from './intrinsic';
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { type TIntrinsic } from './intrinsic';
|
|
3
3
|
export type TCapitalize<T extends TSchema> = TIntrinsic<T, 'Capitalize'>;
|
|
4
4
|
/** `[Json]` Intrinsic function to Capitalize LiteralString types */
|
|
5
5
|
export declare function Capitalize<T extends TSchema>(T: T, options?: SchemaOptions): TCapitalize<T>;
|
|
@@ -3,7 +3,7 @@ import type { TProperties } from '../object/index';
|
|
|
3
3
|
import { Assert } from '../helpers/index';
|
|
4
4
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
5
5
|
import { type TIntrinsic, type IntrinsicMode } from './intrinsic';
|
|
6
|
-
import { TLiteral, TLiteralValue } from '../literal/index';
|
|
6
|
+
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
7
7
|
type TMappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode> = {
|
|
8
8
|
[_ in K]: TIntrinsic<TLiteral<Assert<K, TLiteralValue>>, M>;
|
|
9
9
|
};
|
|
@@ -12,11 +12,10 @@ function MappedIntrinsicPropertyKey(K, M, options) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
// prettier-ignore
|
|
15
|
-
function MappedIntrinsicPropertyKeys(K, M, options
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: Acc);
|
|
15
|
+
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
16
|
+
return K.reduce((Acc, L) => {
|
|
17
|
+
return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
|
|
18
|
+
}, {});
|
|
20
19
|
}
|
|
21
20
|
// prettier-ignore
|
|
22
21
|
function MappedIntrinsicProperties(T, M, options) {
|
|
@@ -7,9 +7,8 @@ import { type TMappedKey } from '../mapped/index';
|
|
|
7
7
|
export type IntrinsicMode = 'Uppercase' | 'Lowercase' | 'Capitalize' | 'Uncapitalize';
|
|
8
8
|
type TFromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode> = M extends IntrinsicMode ? T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? [TIntrinsic<L, M>, ...TFromTemplateLiteral<R, M>] : T : T;
|
|
9
9
|
type TFromLiteralValue<T, M extends IntrinsicMode> = (T extends string ? M extends 'Uncapitalize' ? Uncapitalize<T> : M extends 'Capitalize' ? Capitalize<T> : M extends 'Uppercase' ? Uppercase<T> : M extends 'Lowercase' ? Lowercase<T> : string : T);
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<TFromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<FromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<TFromLiteralValue<S, M>> : T;
|
|
10
|
+
type TFromRest<T extends TSchema[], M extends IntrinsicMode, Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, M, [...Acc, TIntrinsic<L, M>]> : Acc;
|
|
11
|
+
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<TFromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<TFromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<TFromLiteralValue<S, M>> : T;
|
|
13
12
|
/** Applies an intrinsic string manipulation to the given type. */
|
|
14
13
|
export declare function Intrinsic<T extends TMappedKey, M extends IntrinsicMode>(schema: T, mode: M, options?: SchemaOptions): TIntrinsicFromMappedKey<T, M>;
|
|
15
14
|
/** Applies an intrinsic string manipulation to the given type. */
|
|
@@ -49,11 +49,8 @@ function FromLiteralValue(value, mode) {
|
|
|
49
49
|
value) : value.toString());
|
|
50
50
|
}
|
|
51
51
|
// prettier-ignore
|
|
52
|
-
function FromRest(T, M
|
|
53
|
-
|
|
54
|
-
return (T.length > 0
|
|
55
|
-
? FromRest(R, M, [...Acc, Intrinsic(L, M)])
|
|
56
|
-
: Acc);
|
|
52
|
+
function FromRest(T, M) {
|
|
53
|
+
return T.map(L => Intrinsic(L, M));
|
|
57
54
|
}
|
|
58
55
|
/** Applies an intrinsic string manipulation to the given type. */
|
|
59
56
|
function Intrinsic(schema, mode, options = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import { TIntrinsic } from './intrinsic';
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { type TIntrinsic } from './intrinsic';
|
|
3
3
|
export type TLowercase<T extends TSchema> = TIntrinsic<T, 'Lowercase'>;
|
|
4
4
|
/** `[Json]` Intrinsic function to Lowercase LiteralString types */
|
|
5
5
|
export declare function Lowercase<T extends TSchema>(T: T, options?: SchemaOptions): TLowercase<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import { TIntrinsic } from './intrinsic';
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { type TIntrinsic } from './intrinsic';
|
|
3
3
|
export type TUncapitalize<T extends TSchema> = TIntrinsic<T, 'Uncapitalize'>;
|
|
4
4
|
/** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
|
|
5
5
|
export declare function Uncapitalize<T extends TSchema>(T: T, options?: SchemaOptions): TUncapitalize<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import { TIntrinsic } from './intrinsic';
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { type TIntrinsic } from './intrinsic';
|
|
3
3
|
export type TUppercase<T extends TSchema> = TIntrinsic<T, 'Uppercase'>;
|
|
4
4
|
/** `[Json]` Intrinsic function to Uppercase LiteralString types */
|
|
5
5
|
export declare function Uppercase<T extends TSchema>(T: T, options?: SchemaOptions): TUppercase<T>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Iterator = void 0;
|
|
5
|
-
const index_1 = require("../symbols/index");
|
|
6
5
|
const type_1 = require("../clone/type");
|
|
6
|
+
const index_1 = require("../symbols/index");
|
|
7
7
|
/** `[JavaScript]` Creates an Iterator type */
|
|
8
8
|
function Iterator(items, options = {}) {
|
|
9
9
|
return {
|
|
@@ -5,7 +5,7 @@ import { type TKeyOf } from './keyof';
|
|
|
5
5
|
type TFromProperties<K extends TProperties> = ({
|
|
6
6
|
[K2 in keyof K]: TKeyOf<K[K2]>;
|
|
7
7
|
});
|
|
8
|
-
type TFromMappedResult<
|
|
9
|
-
export type TKeyOfFromMappedResult<
|
|
10
|
-
export declare function KeyOfFromMappedResult<
|
|
8
|
+
type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
|
|
9
|
+
export type TKeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
|
|
10
|
+
export declare function KeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -11,12 +11,12 @@ function FromProperties(K, options) {
|
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromMappedResult(
|
|
15
|
-
return FromProperties(
|
|
14
|
+
function FromMappedResult(R, options) {
|
|
15
|
+
return FromProperties(R.properties, options);
|
|
16
16
|
}
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
function KeyOfFromMappedResult(
|
|
19
|
-
const P = FromMappedResult(
|
|
18
|
+
function KeyOfFromMappedResult(R, options) {
|
|
19
|
+
const P = FromMappedResult(R, options);
|
|
20
20
|
return (0, index_1.MappedResult)(P);
|
|
21
21
|
}
|
|
22
22
|
exports.KeyOfFromMappedResult = KeyOfFromMappedResult;
|
|
@@ -6,11 +6,11 @@ import type { TUnion } from '../union/index';
|
|
|
6
6
|
import type { TTuple } from '../tuple/index';
|
|
7
7
|
import type { TArray } from '../array/index';
|
|
8
8
|
import type { TObject, TProperties } from '../object/index';
|
|
9
|
-
import {
|
|
9
|
+
import { type TSetUnionMany, type TSetIntersectMany } from '../sets/index';
|
|
10
10
|
type TFromRest<T extends TSchema[], Acc extends PropertyKey[][] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TKeyOfPropertyKeys<L>]> : Acc);
|
|
11
|
-
type FromIntersect<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] =
|
|
11
|
+
type FromIntersect<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = TSetUnionMany<C>> = R;
|
|
12
12
|
declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
|
|
13
|
-
type FromUnion<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] =
|
|
13
|
+
type FromUnion<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = TSetIntersectMany<C>> = R;
|
|
14
14
|
declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
|
|
15
15
|
type TFromTuple<T extends TSchema[], I extends string = ZeroString, Acc extends PropertyKey[] = []> = T extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? TFromTuple<R, Increment<I>, [...Acc, I]> : Acc;
|
|
16
16
|
type TFromArray<_ extends TSchema> = ([
|
|
@@ -2,38 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.KeyOfPattern = exports.KeyOfPropertyKeys = void 0;
|
|
5
|
-
const index_1 = require("../
|
|
6
|
-
const index_2 = require("../operators/index");
|
|
5
|
+
const index_1 = require("../sets/index");
|
|
7
6
|
// ------------------------------------------------------------------
|
|
8
7
|
// TypeGuard
|
|
9
8
|
// ------------------------------------------------------------------
|
|
10
|
-
// prettier-ignore
|
|
11
9
|
const type_1 = require("../guard/type");
|
|
12
10
|
// prettier-ignore
|
|
13
|
-
function FromRest(T
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: Acc);
|
|
11
|
+
function FromRest(T) {
|
|
12
|
+
return T.reduce((Acc, L) => {
|
|
13
|
+
return [...Acc, KeyOfPropertyKeys(L)];
|
|
14
|
+
}, []);
|
|
18
15
|
}
|
|
19
16
|
// prettier-ignore
|
|
20
17
|
function FromIntersect(T) {
|
|
21
18
|
const C = FromRest(T);
|
|
22
|
-
const R = (0,
|
|
19
|
+
const R = (0, index_1.SetUnionMany)(C);
|
|
23
20
|
return R;
|
|
24
21
|
}
|
|
25
22
|
// prettier-ignore
|
|
26
23
|
function FromUnion(T) {
|
|
27
24
|
const C = FromRest(T);
|
|
28
|
-
const R = (0,
|
|
25
|
+
const R = (0, index_1.SetIntersectMany)(C);
|
|
29
26
|
return R;
|
|
30
27
|
}
|
|
31
28
|
// prettier-ignore
|
|
32
|
-
function FromTuple(T
|
|
33
|
-
|
|
34
|
-
return (T.length > 0
|
|
35
|
-
? FromTuple(R, (0, index_1.Increment)(I), [...Acc, I])
|
|
36
|
-
: Acc);
|
|
29
|
+
function FromTuple(T) {
|
|
30
|
+
return T.map((_, I) => I.toString());
|
|
37
31
|
}
|
|
38
32
|
// prettier-ignore
|
|
39
33
|
function FromArray(_) {
|
|
@@ -11,16 +11,10 @@ const keyof_from_mapped_result_1 = require("./keyof-from-mapped-result");
|
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// TypeGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
|
-
// prettier-ignore
|
|
15
14
|
const type_2 = require("../guard/type");
|
|
16
15
|
// prettier-ignore
|
|
17
|
-
function FromPropertyKeys(T
|
|
18
|
-
|
|
19
|
-
return (T.length > 0
|
|
20
|
-
? L === '[number]'
|
|
21
|
-
? FromPropertyKeys(R, [...Acc, (0, index_2.Number)()])
|
|
22
|
-
: FromPropertyKeys(R, [...Acc, (0, index_1.Literal)(L)])
|
|
23
|
-
: Acc);
|
|
16
|
+
function FromPropertyKeys(T) {
|
|
17
|
+
return T.map(L => L === '[number]' ? (0, index_2.Number)() : (0, index_1.Literal)(L));
|
|
24
18
|
}
|
|
25
19
|
/** `[Json]` Creates a KeyOf type */
|
|
26
20
|
function KeyOf(T, options = {}) {
|