Skip to content

unctionjs/mapKeys

Repository files navigation

@unction/mapKeys

Tests Stability Dependencies

MapperFunctionType<A, B> => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string => KeyedArray | Set | Record<string | number | symbol, unknown> | Map<B, unknown> | string

Map over a keyed functor's keys and return a new keyed functor having mapped the keys

const attributes = {
  name: "Kurtis Rainbolt-Greene",
  createdAt: new Date()
}

mapKeys(kebab)(attributes)

Would return:

{
  name: "Kurtis Rainbolt-Greene",
  "created-at": new Date()
}