src/mapObject.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import visit from "./visit"
import mapRecord from "./mapRecord"
import mapMap from "./mapMap"
import mapSet from "./mapSet"

export default <U extends any>(
  mapper: (v: unknown) => U,
  input: unknown,
): unknown =>
  visit(input, {
    record: mapRecord(mapper),
    map: mapMap(mapper),
    array: a => a.map(mapper),
    set: mapSet(mapper),
    primitive: p => p,
    object: o => o,
  })