function byId
byId<T extends { id: number; }>(items: readonly T[]): Map<number, T>

Key items by their own id, so a caller can look one up. Hand-rolled because @std/collections.associateBy keys by a string and gives back an object, while every caller here has number ids and wants a Map.

Type Parameters

T extends { id: number; }

Parameters

items: readonly T[]

Return Type

Map<number, T>

Usage

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