typebox 1.1.20 → 1.1.22

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.
Files changed (210) hide show
  1. package/build/compile/compile.mjs +1 -0
  2. package/build/compile/validator.mjs +1 -1
  3. package/build/error/errors.mjs +1 -0
  4. package/build/format/iri-reference.mjs +1 -0
  5. package/build/format/uri-reference.mjs +1 -0
  6. package/build/guard/globals.d.mts +3 -3
  7. package/build/guard/guard.d.mts +1 -1
  8. package/build/schema/build.mjs +3 -3
  9. package/build/schema/engine/_functions.mjs +1 -1
  10. package/build/schema/engine/_guard.d.mts +3 -3
  11. package/build/schema/engine/_guard.mjs +3 -3
  12. package/build/schema/engine/_refine.d.mts +3 -3
  13. package/build/schema/engine/_refine.mjs +3 -3
  14. package/build/schema/engine/additionalProperties.d.mts +2 -2
  15. package/build/schema/engine/additionalProperties.mjs +2 -2
  16. package/build/schema/engine/anyOf.mjs +1 -1
  17. package/build/schema/engine/boolean.d.mts +2 -2
  18. package/build/schema/engine/boolean.mjs +2 -2
  19. package/build/schema/engine/const.d.mts +2 -2
  20. package/build/schema/engine/const.mjs +2 -2
  21. package/build/schema/engine/dependentRequired.d.mts +3 -3
  22. package/build/schema/engine/dependentRequired.mjs +3 -3
  23. package/build/schema/engine/enum.d.mts +2 -2
  24. package/build/schema/engine/enum.mjs +2 -2
  25. package/build/schema/engine/exclusiveMaximum.d.mts +2 -2
  26. package/build/schema/engine/exclusiveMaximum.mjs +2 -2
  27. package/build/schema/engine/exclusiveMinimum.d.mts +2 -2
  28. package/build/schema/engine/exclusiveMinimum.mjs +2 -2
  29. package/build/schema/engine/format.d.mts +2 -2
  30. package/build/schema/engine/format.mjs +2 -2
  31. package/build/schema/engine/maxItems.d.mts +2 -2
  32. package/build/schema/engine/maxItems.mjs +2 -2
  33. package/build/schema/engine/maxLength.d.mts +2 -2
  34. package/build/schema/engine/maxLength.mjs +2 -2
  35. package/build/schema/engine/maxProperties.d.mts +2 -2
  36. package/build/schema/engine/maxProperties.mjs +2 -2
  37. package/build/schema/engine/maximum.d.mts +2 -2
  38. package/build/schema/engine/maximum.mjs +2 -2
  39. package/build/schema/engine/minItems.d.mts +2 -2
  40. package/build/schema/engine/minItems.mjs +2 -2
  41. package/build/schema/engine/minLength.d.mts +2 -2
  42. package/build/schema/engine/minLength.mjs +2 -2
  43. package/build/schema/engine/minProperties.d.mts +2 -2
  44. package/build/schema/engine/minProperties.mjs +2 -2
  45. package/build/schema/engine/minimum.d.mts +2 -2
  46. package/build/schema/engine/minimum.mjs +2 -2
  47. package/build/schema/engine/multipleOf.d.mts +2 -2
  48. package/build/schema/engine/multipleOf.mjs +2 -2
  49. package/build/schema/engine/pattern.d.mts +2 -2
  50. package/build/schema/engine/pattern.mjs +2 -2
  51. package/build/schema/engine/recursiveRef.d.mts +1 -1
  52. package/build/schema/engine/recursiveRef.mjs +1 -1
  53. package/build/schema/engine/ref.d.mts +1 -1
  54. package/build/schema/engine/ref.mjs +1 -1
  55. package/build/schema/engine/required.d.mts +3 -3
  56. package/build/schema/engine/required.mjs +3 -3
  57. package/build/schema/engine/type.mjs +2 -2
  58. package/build/schema/engine/uniqueItems.d.mts +3 -3
  59. package/build/schema/engine/uniqueItems.mjs +3 -3
  60. package/build/schema/resolve/ref.mjs +1 -1
  61. package/build/schema/static/additionalProperties.mjs +1 -0
  62. package/build/schema/static/ref.mjs +1 -0
  63. package/build/schema/static/required.mjs +1 -0
  64. package/build/schema/static/static.mjs +1 -0
  65. package/build/schema/static/type.mjs +1 -0
  66. package/build/schema/static/unevaluatedProperties.mjs +1 -0
  67. package/build/system/environment/environment.d.mts +1 -1
  68. package/build/system/environment/environment.mjs +1 -1
  69. package/build/system/environment/evaluate.d.mts +9 -0
  70. package/build/system/environment/evaluate.mjs +37 -0
  71. package/build/system/memory/assign.mjs +1 -0
  72. package/build/system/memory/create.mjs +2 -1
  73. package/build/system/memory/discard.mjs +1 -0
  74. package/build/type/action/awaited.mjs +1 -0
  75. package/build/type/action/capitalize.mjs +1 -0
  76. package/build/type/action/conditional.mjs +1 -0
  77. package/build/type/action/constructor-parameters.mjs +1 -0
  78. package/build/type/action/evaluate.mjs +1 -0
  79. package/build/type/action/exclude.mjs +1 -0
  80. package/build/type/action/extract.mjs +1 -0
  81. package/build/type/action/indexed.mjs +1 -0
  82. package/build/type/action/instance-type.mjs +1 -0
  83. package/build/type/action/interface.mjs +1 -0
  84. package/build/type/action/keyof.mjs +1 -0
  85. package/build/type/action/lowercase.mjs +1 -0
  86. package/build/type/action/mapped.mjs +1 -0
  87. package/build/type/action/module.mjs +1 -0
  88. package/build/type/action/non-nullable.mjs +1 -0
  89. package/build/type/action/omit.mjs +1 -0
  90. package/build/type/action/options.mjs +1 -0
  91. package/build/type/action/parameters.mjs +1 -0
  92. package/build/type/action/partial.mjs +1 -0
  93. package/build/type/action/pick.mjs +1 -0
  94. package/build/type/action/readonly-type.mjs +1 -0
  95. package/build/type/action/required.mjs +1 -0
  96. package/build/type/action/return-type.mjs +1 -0
  97. package/build/type/action/uncapitalize.mjs +1 -0
  98. package/build/type/action/uppercase.mjs +1 -0
  99. package/build/type/engine/constructor-parameters/instantiate.mjs +1 -0
  100. package/build/type/engine/cyclic/extends.mjs +4 -4
  101. package/build/type/engine/cyclic/instantiate.mjs +1 -0
  102. package/build/type/engine/evaluate/broaden.mjs +1 -1
  103. package/build/type/engine/evaluate/compare.mjs +1 -0
  104. package/build/type/engine/exclude/instantiate.mjs +1 -0
  105. package/build/type/engine/extract/instantiate.mjs +1 -0
  106. package/build/type/engine/helpers/union.mjs +1 -0
  107. package/build/type/engine/indexed/from-array.mjs +1 -0
  108. package/build/type/engine/indexed/from-tuple.mjs +1 -0
  109. package/build/type/engine/interface/instantiate.mjs +1 -1
  110. package/build/type/engine/mapped/instantiate.mjs +1 -0
  111. package/build/type/engine/module/instantiate.mjs +1 -0
  112. package/build/type/engine/non-nullable/instantiate.mjs +1 -0
  113. package/build/type/engine/object/from-intersect.mjs +1 -0
  114. package/build/type/engine/object/from-type.mjs +1 -0
  115. package/build/type/engine/parameters/instantiate.mjs +1 -0
  116. package/build/type/engine/partial/from-type.mjs +1 -0
  117. package/build/type/engine/pick/instantiate.mjs +1 -0
  118. package/build/type/engine/record/from-key-integer.d.mts +2 -2
  119. package/build/type/engine/record/from-key-integer.mjs +1 -1
  120. package/build/type/engine/record/from-key-number.d.mts +1 -1
  121. package/build/type/engine/record/from-key-number.mjs +1 -1
  122. package/build/type/engine/required/from-type.mjs +1 -0
  123. package/build/type/engine/template-literal/encode.mjs +1 -1
  124. package/build/type/engine/template-literal/is-finite.mjs +1 -1
  125. package/build/type/engine/tuple/to-object.mjs +1 -0
  126. package/build/type/extends/extends-right.d.mts +1 -1
  127. package/build/type/extends/extends-right.mjs +1 -1
  128. package/build/type/extends/inference.mjs +1 -0
  129. package/build/type/extends/object.mjs +1 -0
  130. package/build/type/types/_codec.d.mts +1 -1
  131. package/build/type/types/_codec.mjs +1 -0
  132. package/build/type/types/base.d.mts +2 -2
  133. package/build/type/types/base.mjs +2 -2
  134. package/build/type/types/call.mjs +1 -0
  135. package/build/type/types/never.mjs +1 -0
  136. package/build/type/types/properties.mjs +0 -1
  137. package/build/type/types/record.mjs +1 -0
  138. package/build/type/types/ref.mjs +1 -0
  139. package/build/value/clean/from-base.d.mts +1 -1
  140. package/build/value/clean/from-base.mjs +1 -1
  141. package/build/value/codec/callback.mjs +2 -2
  142. package/build/value/codec/from-union.mjs +1 -1
  143. package/build/value/convert/from-array.mjs +3 -4
  144. package/build/value/convert/from-base.d.mts +1 -1
  145. package/build/value/convert/from-base.mjs +1 -1
  146. package/build/value/convert/from-bigint.d.mts +1 -1
  147. package/build/value/convert/from-bigint.mjs +1 -4
  148. package/build/value/convert/from-boolean.d.mts +1 -1
  149. package/build/value/convert/from-boolean.mjs +1 -4
  150. package/build/value/convert/from-integer.d.mts +1 -1
  151. package/build/value/convert/from-integer.mjs +1 -4
  152. package/build/value/convert/from-literal.mjs +4 -4
  153. package/build/value/convert/from-null.d.mts +1 -1
  154. package/build/value/convert/from-null.mjs +1 -4
  155. package/build/value/convert/from-number.d.mts +1 -1
  156. package/build/value/convert/from-number.mjs +1 -4
  157. package/build/value/convert/from-string.d.mts +1 -1
  158. package/build/value/convert/from-string.mjs +1 -4
  159. package/build/value/convert/from-type.d.mts +2 -2
  160. package/build/value/convert/from-type.mjs +21 -21
  161. package/build/value/convert/from-undefined.d.mts +1 -1
  162. package/build/value/convert/from-undefined.mjs +1 -4
  163. package/build/value/convert/from-void.d.mts +1 -1
  164. package/build/value/convert/from-void.mjs +1 -4
  165. package/build/value/convert/try/try-array.d.mts +2 -0
  166. package/build/value/convert/try/try-array.mjs +6 -0
  167. package/build/value/convert/try/try-bigint.mjs +4 -33
  168. package/build/value/convert/try/try-boolean.mjs +3 -26
  169. package/build/value/convert/try/try-null.mjs +2 -19
  170. package/build/value/convert/try/try-number.mjs +6 -38
  171. package/build/value/convert/try/try-result.mjs +0 -1
  172. package/build/value/convert/try/try-string.mjs +6 -50
  173. package/build/value/convert/try/try-undefined.mjs +2 -19
  174. package/build/value/convert/try/try.d.mts +1 -0
  175. package/build/value/convert/try/try.mjs +1 -0
  176. package/build/value/create/from-async-iterator.d.mts +1 -1
  177. package/build/value/create/from-async-iterator.mjs +1 -1
  178. package/build/value/create/from-base.d.mts +1 -1
  179. package/build/value/create/from-base.mjs +1 -1
  180. package/build/value/create/from-bigint.d.mts +1 -1
  181. package/build/value/create/from-bigint.mjs +1 -1
  182. package/build/value/create/from-boolean.d.mts +1 -1
  183. package/build/value/create/from-boolean.mjs +1 -1
  184. package/build/value/create/from-default.d.mts +1 -1
  185. package/build/value/create/from-default.mjs +1 -1
  186. package/build/value/create/from-integer.d.mts +1 -1
  187. package/build/value/create/from-integer.mjs +1 -1
  188. package/build/value/create/from-iterator.d.mts +1 -1
  189. package/build/value/create/from-iterator.mjs +1 -1
  190. package/build/value/create/from-literal.d.mts +1 -1
  191. package/build/value/create/from-literal.mjs +1 -1
  192. package/build/value/create/from-never.d.mts +1 -1
  193. package/build/value/create/from-never.mjs +1 -1
  194. package/build/value/create/from-null.d.mts +1 -1
  195. package/build/value/create/from-null.mjs +1 -1
  196. package/build/value/create/from-number.d.mts +1 -1
  197. package/build/value/create/from-number.mjs +1 -1
  198. package/build/value/create/from-record.d.mts +1 -1
  199. package/build/value/create/from-record.mjs +1 -1
  200. package/build/value/create/from-string.d.mts +1 -1
  201. package/build/value/create/from-string.mjs +1 -1
  202. package/build/value/create/from-symbol.d.mts +1 -1
  203. package/build/value/create/from-symbol.mjs +1 -1
  204. package/build/value/create/from-undefined.d.mts +1 -1
  205. package/build/value/create/from-undefined.mjs +1 -1
  206. package/build/value/create/from-void.d.mts +1 -1
  207. package/build/value/create/from-void.mjs +1 -1
  208. package/package.json +1 -1
  209. package/build/system/environment/can-evaluate.d.mts +0 -2
  210. package/build/system/environment/can-evaluate.mjs +0 -26
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../../system/memory/index.mjs';
3
4
  import { IsLiteralNumber, IsLiteralString } from '../../types/literal.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Guard } from '../../../guard/index.mjs';
3
4
  import { Memory } from '../../../system/memory/index.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../../system/memory/index.mjs';
3
4
  import { Null } from '../../types/null.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../../system/memory/index.mjs';
3
4
  import { Guard } from '../../../guard/index.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { IsCyclic } from '../../types/cyclic.mjs';
3
4
  import { IsIntersect } from '../../types/intersect.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../../system/memory/index.mjs';
3
4
  import { IsFunction } from '../../types/function.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { IsCyclic } from '../../types/cyclic.mjs';
3
4
  import { IsIntersect } from '../../types/intersect.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../../system/memory/index.mjs';
3
4
  import { Guard } from '../../../guard/index.mjs';
@@ -1,5 +1,5 @@
1
1
  import { type TSchema } from '../../types/schema.mjs';
2
2
  import { type TInteger } from '../../types/integer.mjs';
3
3
  import { type TRecord, IntegerKey } from '../../types/record.mjs';
4
- export type TFromIntegerKey<Key extends TInteger, Value extends TSchema, Result extends TSchema = TRecord<typeof IntegerKey, Value>> = Result;
5
- export declare function FromIntegerKey<Key extends TInteger, Value extends TSchema>(key: Key, value: Value): TFromIntegerKey<Key, Value>;
4
+ export type TFromIntegerKey<_Key extends TInteger, Value extends TSchema, Result extends TSchema = TRecord<typeof IntegerKey, Value>> = Result;
5
+ export declare function FromIntegerKey<Key extends TInteger, Value extends TSchema>(_key: Key, value: Value): TFromIntegerKey<Key, Value>;
@@ -1,7 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { IntegerKey } from '../../types/record.mjs';
3
3
  import { CreateRecord } from './record-create.mjs';
4
- export function FromIntegerKey(key, value) {
4
+ export function FromIntegerKey(_key, value) {
5
5
  const result = CreateRecord(IntegerKey, value);
6
6
  return result;
7
7
  }
@@ -2,4 +2,4 @@ import { type TSchema } from '../../types/schema.mjs';
2
2
  import { type TNumber } from '../../types/number.mjs';
3
3
  import { type TRecord, NumberKey } from '../../types/record.mjs';
4
4
  export type TFromNumberKey<Key extends TNumber, Value extends TSchema, Result extends TSchema = TRecord<typeof NumberKey, Value>> = Result;
5
- export declare function FromNumberKey<Key extends TNumber, Value extends TSchema>(key: Key, value: Value): TFromNumberKey<Key, Value>;
5
+ export declare function FromNumberKey<Key extends TNumber, Value extends TSchema>(_key: Key, value: Value): TFromNumberKey<Key, Value>;
@@ -1,7 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { NumberKey } from '../../types/record.mjs';
3
3
  import { CreateRecord } from './record-create.mjs';
4
- export function FromNumberKey(key, value) {
4
+ export function FromNumberKey(_key, value) {
5
5
  const result = CreateRecord(NumberKey, value);
6
6
  return result;
7
7
  }
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { IsCyclic } from '../../types/cyclic.mjs';
3
4
  import { IsIntersect } from '../../types/intersect.mjs';
@@ -39,7 +39,7 @@ function EncodeString(right, pattern) {
39
39
  function EncodeTemplateLiteral(templatePattern, right, pattern) {
40
40
  return EncodeTypes(right, `${pattern}${UnwrapTemplateLiteralPattern(templatePattern)}`);
41
41
  }
42
- function EncodeEnum(types, right, pattern, result = []) {
42
+ function EncodeEnum(types, right, pattern) {
43
43
  const variants = EnumValuesToVariants(types);
44
44
  return EncodeUnion(variants, right, pattern);
45
45
  }
@@ -3,7 +3,7 @@ import { Guard } from '../../../guard/index.mjs';
3
3
  import { IsSchema } from '../../types/schema.mjs';
4
4
  import { IsLiteral } from '../../types/literal.mjs';
5
5
  import { IsUnion } from '../../types/union.mjs';
6
- function FromLiteral(value) {
6
+ function FromLiteral(_value) {
7
7
  return true;
8
8
  }
9
9
  function FromTypesReduce(types) {
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Object } from '../../types/object.mjs';
3
4
  export function TupleElementsToProperties(types) {
@@ -15,7 +15,7 @@ import { type TEnumValuesToUnion } from '../engine/enum/index.mjs';
15
15
  type TExtendsRightInfer<Inferred extends TProperties, Name extends string, Left extends TSchema, Right extends TSchema, Result extends Result.TResult = (TExtendsLeft<Inferred, Left, Right> extends Result.TExtendsTrueLike<infer CheckInferred extends TProperties> ? Result.TExtendsTrue<Memory.TAssign<Memory.TAssign<Inferred, CheckInferred>, {
16
16
  [_ in Name]: Left;
17
17
  }>> : Result.TExtendsFalse)> = Result;
18
- type TExtendsRightAny<Inferred extends TProperties, Left extends TSchema, Result extends Result.TResult = Result.TExtendsTrue<Inferred>> = Result;
18
+ type TExtendsRightAny<Inferred extends TProperties, _Left extends TSchema, Result extends Result.TResult = Result.TExtendsTrue<Inferred>> = Result;
19
19
  type TExtendsRightEnum<Inferred extends TProperties, Left extends TSchema, Right extends TEnumValue[], Union extends TSchema = TEnumValuesToUnion<Right>> = TExtendsLeft<Inferred, Left, Union>;
20
20
  type TExtendsRightIntersect<Inferred extends TProperties, Left extends TSchema, Right extends TSchema[]> = (Right extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Left, Head> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsRightIntersect<Inferred, Left, Tail> : Result.TExtendsFalse : Result.TExtendsTrue<Inferred>);
21
21
  type TExtendsRightTemplateLiteral<Inferred extends TProperties, Left extends TSchema, Right extends string, Decoded extends TSchema = TTemplateLiteralDecode<Right>> = TExtendsLeft<Inferred, Left, Decoded>;
@@ -14,7 +14,7 @@ import { EnumValuesToUnion } from '../engine/enum/index.mjs';
14
14
  function ExtendsRightInfer(inferred, name, left, right) {
15
15
  return Result.Match(ExtendsLeft(inferred, left, right), checkInferred => Result.ExtendsTrue(Memory.Assign(Memory.Assign(inferred, checkInferred), { [name]: left })), () => Result.ExtendsFalse());
16
16
  }
17
- function ExtendsRightAny(inferred, left) {
17
+ function ExtendsRightAny(inferred, _left) {
18
18
  return Result.ExtendsTrue(inferred);
19
19
  }
20
20
  function ExtendsRightEnum(inferred, left, right) {
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Unreachable } from '../../system/unreachable/index.mjs';
3
4
  import { Memory } from '../../system/memory/index.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Unreachable } from '../../system/unreachable/index.mjs';
3
4
  import { Memory } from '../../system/memory/index.mjs';
@@ -13,7 +13,7 @@ export type TCodec<Type extends TSchema = TSchema, Decoded extends unknown = unk
13
13
  export declare class EncodeBuilder<Type extends TSchema, Decoded extends unknown> {
14
14
  private readonly type;
15
15
  private readonly decode;
16
- constructor(type: Type, decode: Function);
16
+ constructor(type: Type, decode: globalThis.Function);
17
17
  Encode<Callback extends TEncodeCallback<Type, Decoded>>(callback: Callback): TCodec<Type, Decoded>;
18
18
  }
19
19
  export declare class DecodeBuilder<Type extends TSchema> {
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../system/index.mjs';
3
4
  import { Guard } from '../../guard/index.mjs';
@@ -32,9 +32,9 @@ export declare class Base<Value extends unknown = unknown> implements TSchema, X
32
32
  readonly '~guard': XGuardInterface<Value>;
33
33
  constructor();
34
34
  /** Checks a value or returns false if invalid */
35
- Check(value: unknown): value is Value;
35
+ Check(_value: unknown): _value is Value;
36
36
  /** Returns errors for a value. Return an empty array if valid. */
37
- Errors(value: unknown): object[];
37
+ Errors(_value: unknown): object[];
38
38
  /** Converts a value into this type */
39
39
  Convert(value: unknown): unknown;
40
40
  /** Cleans a value according to this type */
@@ -47,11 +47,11 @@ export class Base {
47
47
  }));
48
48
  }
49
49
  /** Checks a value or returns false if invalid */
50
- Check(value) {
50
+ Check(_value) {
51
51
  return true;
52
52
  }
53
53
  /** Returns errors for a value. Return an empty array if valid. */
54
- Errors(value) {
54
+ Errors(_value) {
55
55
  return [];
56
56
  }
57
57
  /** Converts a value into this type */
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../system/memory/index.mjs';
3
4
  import { IsKind } from './schema.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../system/memory/index.mjs';
3
4
  import { IsKind } from './schema.mjs';
@@ -1,4 +1,3 @@
1
- // deno-lint-ignore-file no-array-constructor
2
1
  // deno-fmt-ignore-file
3
2
  import { Guard } from '../../guard/index.mjs';
4
3
  import { IsOptional } from './_optional.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file ban-types
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../system/memory/index.mjs';
3
4
  import { Guard } from '../../guard/index.mjs';
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file no-explicit-any
1
2
  // deno-fmt-ignore-file
2
3
  import { Memory } from '../../system/memory/index.mjs';
3
4
  import { IsKind } from './schema.mjs';
@@ -1,2 +1,2 @@
1
1
  import type { TProperties, Base } from '../../type/index.mjs';
2
- export declare function FromBase(context: TProperties, type: Base, value: unknown): unknown;
2
+ export declare function FromBase(_context: TProperties, type: Base, value: unknown): unknown;
@@ -1,4 +1,4 @@
1
1
  // deno-fmt-ignore-file
2
- export function FromBase(context, type, value) {
2
+ export function FromBase(_context, type, value) {
3
3
  return type.Clean(value);
4
4
  }
@@ -4,13 +4,13 @@ import { IsCodec } from '../../type/index.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Decode
6
6
  // ------------------------------------------------------------------
7
- function Decode(context, type, value) {
7
+ function Decode(_context, type, value) {
8
8
  return type['~codec'].decode(value);
9
9
  }
10
10
  // ------------------------------------------------------------------
11
11
  // Encode
12
12
  // ------------------------------------------------------------------
13
- function Encode(context, type, value) {
13
+ function Encode(_context, type, value) {
14
14
  return type['~codec'].encode(value);
15
15
  }
16
16
  // ------------------------------------------------------------------
@@ -21,7 +21,7 @@ function Decode(direction, context, type, value) {
21
21
  // Encode
22
22
  // ------------------------------------------------------------------
23
23
  function Encode(direction, context, type, value) {
24
- let exterior = Callback(direction, context, type, value);
24
+ const exterior = Callback(direction, context, type, value);
25
25
  for (const schema of UnionPrioritySort(type.anyOf, -1)) {
26
26
  const variant = FromType(direction, context, schema, Clone(exterior));
27
27
  if (!Check(context, schema, variant))
@@ -1,8 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { FromType } from './from-type.mjs';
3
- import { Guard } from '../../guard/index.mjs';
3
+ import { Try } from './try/index.mjs';
4
4
  export function FromArray(context, type, value) {
5
- return Guard.IsArray(value)
6
- ? value.map(value => FromType(context, type.items, value))
7
- : value;
5
+ const result = Try.TryArray(value);
6
+ return result.value.map(value => FromType(context, type.items, value));
8
7
  }
@@ -1,2 +1,2 @@
1
1
  import type { Base, TProperties } from '../../type/index.mjs';
2
- export declare function FromBase(context: TProperties, type: Base, value: unknown): unknown;
2
+ export declare function FromBase(_context: TProperties, type: Base, value: unknown): unknown;
@@ -1,4 +1,4 @@
1
1
  // deno-fmt-ignore-file
2
- export function FromBase(context, type, value) {
2
+ export function FromBase(_context, type, value) {
3
3
  return type.Convert(value);
4
4
  }
@@ -1,2 +1,2 @@
1
1
  import type { TBigInt, TProperties } from '../../type/index.mjs';
2
- export declare function FromBigInt(context: TProperties, type: TBigInt, value: unknown): unknown;
2
+ export declare function FromBigInt(_context: TProperties, _type: TBigInt, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromBigInt(context, type, value) {
5
- if (Guard.IsBigInt(value))
6
- return value;
3
+ export function FromBigInt(_context, _type, value) {
7
4
  const result = Try.TryBigInt(value);
8
5
  return Try.IsOk(result) ? result.value : value;
9
6
  }
@@ -1,2 +1,2 @@
1
1
  import type { TBoolean, TProperties } from '../../type/index.mjs';
2
- export declare function FromBoolean(context: TProperties, type: TBoolean, value: unknown): unknown;
2
+ export declare function FromBoolean(_context: TProperties, _type: TBoolean, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromBoolean(context, type, value) {
5
- if (Guard.IsBoolean(value))
6
- return value;
3
+ export function FromBoolean(_context, _type, value) {
7
4
  const result = Try.TryBoolean(value);
8
5
  return Try.IsOk(result) ? result.value : value;
9
6
  }
@@ -1,2 +1,2 @@
1
1
  import type { TInteger, TProperties } from '../../type/index.mjs';
2
- export declare function FromInteger(context: TProperties, type: TInteger, value: unknown): unknown;
2
+ export declare function FromInteger(_context: TProperties, _type: TInteger, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromInteger(context, type, value) {
5
- if (Guard.IsInteger(value))
6
- return value;
3
+ export function FromInteger(_context, _type, value) {
7
4
  const result = Try.TryNumber(value);
8
5
  return Try.IsOk(result) ? Math.trunc(result.value) : value;
9
6
  }
@@ -6,28 +6,28 @@ import { Try } from './try/index.mjs';
6
6
  // ------------------------------------------------------------------
7
7
  // BigInt
8
8
  // ------------------------------------------------------------------
9
- function FromLiteralBigInt(context, type, value) {
9
+ function FromLiteralBigInt(_context, type, value) {
10
10
  const result = Try.TryBigInt(value);
11
11
  return Try.IsOk(result) && Guard.IsEqual(type.const, result.value) ? result.value : value;
12
12
  }
13
13
  // ------------------------------------------------------------------
14
14
  // Boolean
15
15
  // ------------------------------------------------------------------
16
- function FromLiteralBoolean(context, type, value) {
16
+ function FromLiteralBoolean(_context, type, value) {
17
17
  const result = Try.TryBoolean(value);
18
18
  return Try.IsOk(result) && Guard.IsEqual(type.const, result.value) ? result.value : value;
19
19
  }
20
20
  // ------------------------------------------------------------------
21
21
  // Number
22
22
  // ------------------------------------------------------------------
23
- function FromLiteralNumber(context, type, value) {
23
+ function FromLiteralNumber(_context, type, value) {
24
24
  const result = Try.TryNumber(value);
25
25
  return Try.IsOk(result) && Guard.IsEqual(type.const, result.value) ? result.value : value;
26
26
  }
27
27
  // ------------------------------------------------------------------
28
28
  // String
29
29
  // ------------------------------------------------------------------
30
- function FromLiteralString(context, type, value) {
30
+ function FromLiteralString(_context, type, value) {
31
31
  const result = Try.TryString(value);
32
32
  return Try.IsOk(result) && Guard.IsEqual(type.const, result.value) ? result.value : value;
33
33
  }
@@ -1,2 +1,2 @@
1
1
  import type { TNull, TProperties } from '../../type/index.mjs';
2
- export declare function FromNull(context: TProperties, type: TNull, value: unknown): unknown;
2
+ export declare function FromNull(_context: TProperties, _type: TNull, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromNull(context, type, value) {
5
- if (Guard.IsNull(value))
6
- return value;
3
+ export function FromNull(_context, _type, value) {
7
4
  const result = Try.TryNull(value);
8
5
  return Try.IsOk(result) ? result.value : value;
9
6
  }
@@ -1,2 +1,2 @@
1
1
  import type { TNumber, TProperties } from '../../type/index.mjs';
2
- export declare function FromNumber(context: TProperties, type: TNumber, value: unknown): unknown;
2
+ export declare function FromNumber(_context: TProperties, _type: TNumber, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromNumber(context, type, value) {
5
- if (Guard.IsNumber(value))
6
- return value;
3
+ export function FromNumber(_context, _type, value) {
7
4
  const result = Try.TryNumber(value);
8
5
  return Try.IsOk(result) ? result.value : value;
9
6
  }
@@ -1,2 +1,2 @@
1
1
  import type { TString, TProperties } from '../../type/index.mjs';
2
- export declare function FromString(context: TProperties, type: TString, value: unknown): unknown;
2
+ export declare function FromString(_context: TProperties, _type: TString, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromString(context, type, value) {
5
- if (Guard.IsString(value))
6
- return value;
3
+ export function FromString(_context, _type, value) {
7
4
  const result = Try.TryString(value);
8
5
  return Try.IsOk(result) ? result.value : value;
9
6
  }
@@ -1,2 +1,2 @@
1
- import * as T from '../../type/index.mjs';
2
- export declare function FromType(context: T.TProperties, type: T.TSchema, value: unknown): unknown;
1
+ import * as Type from '../../type/index.mjs';
2
+ export declare function FromType(context: Type.TProperties, type: Type.TSchema, value: unknown): unknown;
@@ -1,5 +1,5 @@
1
1
  // deno-fmt-ignore-file
2
- import * as T from '../../type/index.mjs';
2
+ import * as Type from '../../type/index.mjs';
3
3
  import { FromArray } from './from-array.mjs';
4
4
  import { FromBase } from './from-base.mjs';
5
5
  import { FromBigInt } from './from-bigint.mjs';
@@ -21,25 +21,25 @@ import { FromUndefined } from './from-undefined.mjs';
21
21
  import { FromUnion } from './from-union.mjs';
22
22
  import { FromVoid } from './from-void.mjs';
23
23
  export function FromType(context, type, value) {
24
- return (T.IsArray(type) ? FromArray(context, type, value) :
25
- T.IsBase(type) ? FromBase(context, type, value) :
26
- T.IsBigInt(type) ? FromBigInt(context, type, value) :
27
- T.IsBoolean(type) ? FromBoolean(context, type, value) :
28
- T.IsCyclic(type) ? FromCyclic(context, type, value) :
29
- T.IsEnum(type) ? FromEnum(context, type, value) :
30
- T.IsInteger(type) ? FromInteger(context, type, value) :
31
- T.IsIntersect(type) ? FromIntersect(context, type, value) :
32
- T.IsLiteral(type) ? FromLiteral(context, type, value) :
33
- T.IsNull(type) ? FromNull(context, type, value) :
34
- T.IsNumber(type) ? FromNumber(context, type, value) :
35
- T.IsObject(type) ? FromObject(context, type, value) :
36
- T.IsRecord(type) ? FromRecord(context, type, value) :
37
- T.IsRef(type) ? FromRef(context, type, value) :
38
- T.IsString(type) ? FromString(context, type, value) :
39
- T.IsTemplateLiteral(type) ? FromTemplateLiteral(context, type, value) :
40
- T.IsTuple(type) ? FromTuple(context, type, value) :
41
- T.IsUndefined(type) ? FromUndefined(context, type, value) :
42
- T.IsUnion(type) ? FromUnion(context, type, value) :
43
- T.IsVoid(type) ? FromVoid(context, type, value) :
24
+ return (Type.IsArray(type) ? FromArray(context, type, value) :
25
+ Type.IsBase(type) ? FromBase(context, type, value) :
26
+ Type.IsBigInt(type) ? FromBigInt(context, type, value) :
27
+ Type.IsBoolean(type) ? FromBoolean(context, type, value) :
28
+ Type.IsCyclic(type) ? FromCyclic(context, type, value) :
29
+ Type.IsEnum(type) ? FromEnum(context, type, value) :
30
+ Type.IsInteger(type) ? FromInteger(context, type, value) :
31
+ Type.IsIntersect(type) ? FromIntersect(context, type, value) :
32
+ Type.IsLiteral(type) ? FromLiteral(context, type, value) :
33
+ Type.IsNull(type) ? FromNull(context, type, value) :
34
+ Type.IsNumber(type) ? FromNumber(context, type, value) :
35
+ Type.IsObject(type) ? FromObject(context, type, value) :
36
+ Type.IsRecord(type) ? FromRecord(context, type, value) :
37
+ Type.IsRef(type) ? FromRef(context, type, value) :
38
+ Type.IsString(type) ? FromString(context, type, value) :
39
+ Type.IsTemplateLiteral(type) ? FromTemplateLiteral(context, type, value) :
40
+ Type.IsTuple(type) ? FromTuple(context, type, value) :
41
+ Type.IsUndefined(type) ? FromUndefined(context, type, value) :
42
+ Type.IsUnion(type) ? FromUnion(context, type, value) :
43
+ Type.IsVoid(type) ? FromVoid(context, type, value) :
44
44
  value);
45
45
  }
@@ -1,2 +1,2 @@
1
1
  import type { TUndefined, TProperties } from '../../type/index.mjs';
2
- export declare function FromUndefined(context: TProperties, type: TUndefined, value: unknown): unknown;
2
+ export declare function FromUndefined(_context: TProperties, _type: TUndefined, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromUndefined(context, type, value) {
5
- if (Guard.IsUndefined(value))
6
- return value;
3
+ export function FromUndefined(_context, _type, value) {
7
4
  const result = Try.TryUndefined(value);
8
5
  return Try.IsOk(result) ? result.value : value;
9
6
  }
@@ -1,2 +1,2 @@
1
1
  import type { TVoid, TProperties } from '../../type/index.mjs';
2
- export declare function FromVoid(context: TProperties, type: TVoid, value: unknown): unknown;
2
+ export declare function FromVoid(_context: TProperties, _type: TVoid, value: unknown): unknown;
@@ -1,9 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Try } from './try/index.mjs';
4
- export function FromVoid(context, type, value) {
5
- if (Guard.IsUndefined(value))
6
- return value;
3
+ export function FromVoid(_context, _type, value) {
7
4
  const result = Try.TryUndefined(value);
8
5
  return Try.IsOk(result) ? (void 0) : value;
9
6
  }
@@ -0,0 +1,2 @@
1
+ import { type TOk } from './try-result.mjs';
2
+ export declare function TryArray(value: unknown): TOk<unknown[]>;
@@ -0,0 +1,6 @@
1
+ // deno-fmt-ignore-file
2
+ import { Guard } from '../../../guard/index.mjs';
3
+ import { Ok } from './try-result.mjs';
4
+ export function TryArray(value) {
5
+ return Guard.IsArray(value) ? Ok(value) : Ok([value]);
6
+ }
@@ -1,34 +1,13 @@
1
1
  // deno-fmt-ignore-file
2
- // deno-lint-ignore-file
3
2
  import { Guard } from '../../../guard/index.mjs';
4
3
  import { Ok, Fail } from './try-result.mjs';
5
4
  // ------------------------------------------------------------------
6
- // BigInt
7
- // ------------------------------------------------------------------
8
- // deno-coverage-ignore-start - unreachable | guarded
9
- function FromBigInt(value) {
10
- return Ok(value);
11
- }
12
- // deno-coverage-ignore-stop
13
- // ------------------------------------------------------------------
14
5
  // Boolean
15
6
  // ------------------------------------------------------------------
16
7
  function FromBoolean(value) {
17
8
  return Guard.IsEqual(value, true) ? Ok(BigInt(1)) : Ok(BigInt(0));
18
9
  }
19
10
  // ------------------------------------------------------------------
20
- // Number
21
- // ------------------------------------------------------------------
22
- function FromNumber(value) {
23
- return Ok(BigInt(Math.trunc(value)));
24
- }
25
- // ------------------------------------------------------------------
26
- // Null
27
- // ------------------------------------------------------------------
28
- function FromNull(value) {
29
- return Ok(BigInt(0));
30
- }
31
- // ------------------------------------------------------------------
32
11
  // String
33
12
  // ------------------------------------------------------------------
34
13
  const bigintPattern = /^-?(0|[1-9]\d*)n$/;
@@ -53,22 +32,14 @@ function FromString(value) {
53
32
  Fail());
54
33
  }
55
34
  // ------------------------------------------------------------------
56
- // Undefined
57
- // ------------------------------------------------------------------
58
- function FromUndefined(value) {
59
- return Ok(BigInt(0));
60
- }
61
- // ------------------------------------------------------------------
62
35
  // Try
63
36
  // ------------------------------------------------------------------
64
- // deno-coverage-ignore-start - unreachable | guarded
65
37
  export function TryBigInt(value) {
66
- return (Guard.IsBigInt(value) ? FromBigInt(value) :
38
+ return (Guard.IsBigInt(value) ? Ok(value) :
67
39
  Guard.IsBoolean(value) ? FromBoolean(value) :
68
- Guard.IsNumber(value) ? FromNumber(value) :
69
- Guard.IsNull(value) ? FromNull(value) :
40
+ Guard.IsNumber(value) ? Ok(BigInt(Math.trunc(value))) :
41
+ Guard.IsNull(value) ? Ok(BigInt(0)) :
70
42
  Guard.IsString(value) ? FromString(value) :
71
- Guard.IsUndefined(value) ? FromUndefined(value) :
43
+ Guard.IsUndefined(value) ? Ok(BigInt(0)) :
72
44
  Fail());
73
45
  }
74
- // deno-coverage-ignore-stop