map-fns
Version:
<h1 align="center"> <code>map-fns</code> </h1>
20 lines (19 loc) • 568 B
TypeScript
import { AnyMap } from "../types";
/**
* Creates a new map populated with every key in `keys` where the value
* behind each `k` in `keys` is `map[k]`.
*
* ```tsx
* partialMap({ a: 1, b: 2, c: 3 }, ["a", "c"]);
* //=> {
* // a: 1,
* // c: 3,
* // }
* ```
*
* @param map The original map.
* @param keys The keys to include in the new map.
* @returns a new `map` populated with every key in `keys` where the value
* behind each `k` in `keys` is `map[k]`.
*/
export default function partialMap<M extends AnyMap>(map: M, keys: Array<keyof M>): M;