simontonsoftware / s-libs

A collection of libraries for any of javascript, rxjs, or angular.
MIT License
43 stars 5 forks source link

[micro-dash] Feature request: `mapKeys()` #63

Closed ersimont closed 2 years ago

ersimont commented 2 years ago
import { transform } from '@s-libs/micro-dash';

export function mapKeys<E>(
  obj: Record<string, E>,
  iteratee: (value: E, key: string) => string,
): any {
  return transform(obj, (accumulator, value, key) => {
    accumulator[iteratee(value, key)] = value;
  });
}
ersimont commented 2 years ago

This is coming in the next release