Array Indexing Utility
JSON →index-array-by is a lightweight utility function, currently at version 1.4.2, designed for efficiently indexing JavaScript arrays of objects based on various criteria. It enables developers to transform a flat list into a nested object or array structure. Key differentiators include its flexibility in defining index keys, supporting string property names, an array of property names for hierarchical indexing, or custom accessor functions for complex key generation. The library also provides robust handling for duplicate keys, allowing the user to specify whether each index key should map to a single item (potentially overwriting duplicates if not unique) or an array of all matching items (the default behavior). Furthermore, it supports custom transformation functions for reducing multiple items into a single value, and an optional parameter to flatten the output into an array of { keys, vals } objects. It is actively maintained, shipping with TypeScript types to enhance developer experience and provide strong type checking in modern JavaScript environments.
Traffic · last 30 days ↑100% vs prev 7d
top countries 🇺🇸 United States · 🇫🇷 France · 🇨🇦 Canada · 🇩🇪 Germany · 🇮🇩 Indonesia