flatMap<Input, Output>( mapper: Object, name?: string, mapFailure?: Object,): Object
mapper: Object
Optionalname: string
Optional
mapFailure: Object = ...
import { x } from 'unhoax'import pipe from 'just-pipe' // or elsewhereconst numberFromString = pipe( x.string, x.map(Number), x.flatMap(x.number.parse),) Copy
import { x } from 'unhoax'import pipe from 'just-pipe' // or elsewhereconst numberFromString = pipe( x.string, x.map(Number), x.flatMap(x.number.parse),)
import { 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 } Copy
import { 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 }
Example
Example: not using pipe