Skip to content

objectify

Convert an array to a dictionary by mapping each item into a dictionary key & value.

Usage

objectify([1, 2, 3], (n) => "#" + n);
// { '#1': 1, '#2': 2, '#3': 3 }
objectify(
[
{ id: 1, name: "John" },
{ id: 2, name: "Jane" },
],
(obj) => obj.id,
(obj) => obj.name,
);
// { 1: 'John', 2: 'Jane' }

Installation

Terminal window
npx atmx add helper objectify