flatMap<Input, Output>(mapper: Object, name?: string): Object
mapper: Object
Optionalname: string
Optional
import * as x from 'unhoax'const mapNumberFromString = x.flatMap((value: string) => x.number.parse(Number(value)))const numberFromString = mapNumberFromString(string)numberFromString.parse('12') // { success: true, value: 12 }// or, using pipeimport pipe from 'just-pipe'const numberFromString = pipe( x.string, x.map(Number), x.flatMap(x.number.parse),) Copy
import * as x from 'unhoax'const mapNumberFromString = x.flatMap((value: string) => x.number.parse(Number(value)))const numberFromString = mapNumberFromString(string)numberFromString.parse('12') // { success: true, value: 12 }// or, using pipeimport pipe from 'just-pipe'const numberFromString = pipe( x.string, x.map(Number), x.flatMap(x.number.parse),)
Example