function mapById
mapById<
T extends { id: unknown; },
V,
>
(valueFrom: (item: T) => V): ((items: Iterable<T>) => Map<T["id"], V>)

Index items by id and a chosen value.

Type Parameters

T extends { id: unknown; }

Parameters

valueFrom: (item: T) => V

Return Type

((items: Iterable<T>) => Map<T["id"], V>)

Usage

import { mapById } from "docs/utilities.ts";