Skip to content

mapify

Create a new `Map` instance from an array.

Usage

const array = [
{ id: 1, name: "Fred" },
{ id: 2, name: "Annie" },
];
mapify(
array,
(item) => item.id,
(item) => item.name,
);
// Map(2) { 1 => 'Fred', 2 => 'Annie' }

Installation

Terminal window
npx atmx add helper mapify