Search


Search something to see results

map

Type Parameters

  • Input
  • Output

Parameters

  • mapper: Object
  • Optionalname: string

Returns Object

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' } }