Skip to content

Commit

Permalink
Revision 0.32.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Nov 29, 2023
1 parent e266d50 commit 00b22b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/type/exclude/exclude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ import { TTemplateLiteral as IsTemplateLiteralType, TUnion as IsUnionType } from
// ExcludeResolve
// ------------------------------------------------------------------
// prettier-ignore
export type ExcludeTemplateLiteralResult<T extends string> = UnionResolve<AssertRest<UnionToTuple<{ [K in T]: TLiteral<K> }[T]>>>
type ExcludeTemplateLiteralResult<T extends string> = UnionResolve<AssertRest<UnionToTuple<{ [K in T]: TLiteral<K> }[T]>>>
// prettier-ignore
export type ExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (
type ExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (
Exclude<Static<T>, Static<U>> extends infer S ? ExcludeTemplateLiteralResult<Assert<S, string>> : never
)
// prettier-ignore
export type ExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
type ExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K]
}[number]>> extends infer R extends TSchema[] ? UnionResolve<R> : never
// prettier-ignore
export type ExcludeResolve<T extends TSchema, U extends TSchema> =
type ExcludeResolve<T extends TSchema, U extends TSchema> =
T extends TTemplateLiteral ? ExcludeTemplateLiteral<T, U> :
T extends TUnion<infer S> ? ExcludeArray<S, U> :
T extends U
Expand Down
6 changes: 5 additions & 1 deletion src/value/transform/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ function Visit(schema: TSchema, references: TSchema[], value: any): any {
return Default(schema_, value)
}
}
// prettier-ignore
/**
* `[Internal]` Decodes the value and returns the result. This function requires that
* the caller `Check` the value before use. Passing unchecked values may result in
* undefined behavior. Refer to the `Value.Decode()` for implementation details.
*/
export function Decode(schema: TSchema, references: TSchema[], value: unknown): unknown {
return Visit(schema, references, value)
}
7 changes: 6 additions & 1 deletion src/value/transform/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ function Visit(schema: TSchema, references: TSchema[], value: any): any {
return Default(schema_, value)
}
}
// prettier-ignore
/**
* `[Internal]` Encodes the value and returns the result. This function expects the
* caller to pass a statically checked value. This function does not check the encoded
* result, meaning the result should be passed to `Check` before use. Refer to the
* `Value.Encode()` function for implementation details.
*/
export function Encode(schema: TSchema, references: TSchema[], value: unknown): unknown {
return Visit(schema, references, value)
}

0 comments on commit 00b22b3

Please sign in to comment.