( key: Key, value: Value )
| 9761 | ): OptionFromNullishOr<S> { |
| 9762 | return NullishOr(schema).pipe(decodeTo( |
| 9763 | Option(toType(schema)), |
| 9764 | SchemaTransformation.optionFromNullishOr(options) |
| 9765 | )) |
| 9766 | } |
| 9767 | |
| 9768 | /** |
| 9769 | * Type-level representation returned by {@link OptionFromOptionalKey}. |
| 9770 | * |
| 9771 | * @category models |
| 9772 | * @since 4.0.0 |
| 9773 | */ |
| 9774 | export interface OptionFromOptionalKey<S extends Constraint> extends decodeTo<Option<toType<S>>, optionalKey<S>> { |
| 9775 | readonly "Rebuild": OptionFromOptionalKey<S> |
| 9776 | } |
| 9777 | |
| 9778 | /** |
| 9779 | * Decodes an optional value `A` to a required `Option<A>` value. |
| 9780 | * |
| 9781 | * **Details** |
| 9782 | * |
| 9783 | * Decoding maps a missing key to `None` and a present value to `Some`. |
| 9784 | * Encoding maps `None` to a missing key and maps `Some` to its value. |
| 9785 | * |
| 9786 | * @category schemas |
| 9787 | * @since 4.0.0 |
| 9788 | */ |
| 9789 | export function OptionFromOptionalKey<S extends Constraint>(schema: S): OptionFromOptionalKey<S> { |
| 9790 | return optionalKey(schema).pipe(decodeTo( |
| 9791 | Option(toType(schema)), |
| 9792 | SchemaTransformation.optionFromOptionalKey() |
| 9793 | )) |
| 9794 | } |
| 9795 | |
| 9796 | /** |
| 9797 | * Type-level representation returned by {@link OptionFromOptional}. |
| 9798 | * |
| 9799 | * @category models |
| 9800 | * @since 4.0.0 |
| 9801 | */ |
| 9802 | export interface OptionFromOptional<S extends Constraint> extends decodeTo<Option<toType<S>>, optional<S>> { |
| 9803 | readonly "Rebuild": OptionFromOptional<S> |
| 9804 | } |
| 9805 | |
| 9806 | /** |
| 9807 | * Decodes an optional or `undefined` value `A` to a required `Option<A>` |
| 9808 | * value. |
| 9809 | * |
| 9810 | * **Details** |
| 9811 | * |
| 9812 | * Decoding maps a missing key or a present `undefined` value to `None`, and |
| 9813 | * maps all other values to `Some`. Encoding maps `None` to a missing key and |
| 9814 | * maps `Some` to its value. |
| 9815 | * |
| 9816 | * @category schemas |
| 9817 | * @since 4.0.0 |
| 9818 | */ |
| 9819 | export function OptionFromOptional<S extends Constraint>(schema: S): OptionFromOptional<S> { |
| 9820 | return optional(schema).pipe(decodeTo( |
nothing calls this directly
no test coverage detected
searching dependent graphs…