1 | /**
|
2 | * @since 0.3.2
|
3 | */
|
4 | import * as t from 'io-ts'
|
5 | /**
|
6 | * Changes the output type of the given runtime type
|
7 | *
|
8 | * @example
|
9 | * import * as t from 'io-ts'
|
10 | * import { mapOutput } from 'io-ts-types/lib/mapOutput'
|
11 | * import { optionFromNullable } from 'io-ts-types/lib/optionFromNullable'
|
12 | * import { none, some } from 'fp-ts/lib/Option'
|
13 | *
|
14 | * // Input: t.Type<Option<number>, number | null, t.mixed>
|
15 | * const Input = optionFromNullable(t.number)
|
16 | *
|
17 | * const toUndefined = <A>(x: A | null): A | undefined => (x === null ? undefined : x)
|
18 | *
|
19 | * // Output: t.Type<Option<number>, number | undefined, t.mixed>
|
20 | * const Output = mapOutput(Input, toUndefined)
|
21 | *
|
22 | * assert.strictEqual(Output.encode(none), undefined)
|
23 | * assert.strictEqual(Output.encode(some(1)), 1)
|
24 | *
|
25 | * @since 0.3.2
|
26 | */
|
27 | export declare function mapOutput<A, O, I, P>(codec: t.Type<A, O, I>, f: (p: O) => P, name?: string): t.Type<A, P, I>
|
28 |
|
\ | No newline at end of file |