map<Input, Output>(mapper: Object, name?: string): Object
mapper: Object
Optionalname: string
Optional
import * as x from 'unhoax'const mapToUppercase = x.map((value: string) => value.toUpperCase())const upperString = mapToUppercase(x.string)upperString.parse('a') // { success: true, value: 'A' }import pipe from 'just-pipe'const schema = pipe( x.object({ name: upperString }), x.map((data) => ({ _tag: 'Person' as const, ...data })),)schema.parse({ name: 'Jack' })// { success: true, value: { _tag: 'Person', name: 'JACK' } } Copy
import * as x from 'unhoax'const mapToUppercase = x.map((value: string) => value.toUpperCase())const upperString = mapToUppercase(x.string)upperString.parse('a') // { success: true, value: 'A' }import pipe from 'just-pipe'const schema = pipe( x.object({ name: upperString }), x.map((data) => ({ _tag: 'Person' as const, ...data })),)schema.parse({ name: 'Jack' })// { success: true, value: { _tag: 'Person', name: 'JACK' } }
Example