Skip to content

group

Sorts an `array` of items into groups. The return value is a map where the keys are the group IDs the given `getGroupId` function produced and the value is an array of each item in that group.

Usage

group([1, 2, 3, 4], (n) => (n % 2 === 0 ? "even" : "odd")); // { even: [2], odd: [1, 3, 4] }

Installation

Terminal window
npx atmx add helper group