New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

index-array-by

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

index-array-by - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

package.json
{
"name": "index-array-by",
"version": "1.2.0",
"version": "1.2.1",
"description": "A utility function to index arrays by any criteria",

@@ -5,0 +5,0 @@ "main": "dist/index-array-by.min.js",

@@ -35,5 +35,5 @@ # index-array-by

Use `indexBy` to index it by a given attribute (string type `keyAccessor`) or any other custom criteria (function type `keyAccessor`). You can also pass an array of `keyAccessors` to retrieve a nested object recursively indexed by the multiple keys.
Use the third parameter (`multiItem`) to indicate whether each key should point to a single item (unadvised if the keys are not unique) or an array of multiple items (default behavior). This parameter also accepts a transformation function with the method to reduce multiple items into a single one.
A fourth optional parameter (`flattenKeys`) (default: `false`) allows you to receive a flat array structure instead of the default nested format, with each item formatted as `{ keys: [<ordered unique keys for the item>], vals: <single or multiple item> }`.
Use the third parameter (`multiItem`) to indicate whether each key should point to a single item (unadvised if the keys are not unique) or an array of multiple items (default behavior).
```

@@ -97,2 +97,5 @@ indexBy(people, 'surname', false);

The `multiItem` parameter also accepts a transformation function with the method to reduce multiple items into a single one. In this case, it's keeping only the max age.
```

@@ -109,2 +112,5 @@ indexBy(people, 'name', items => Math.max(...items.map(item => item.age)));

A fourth optional parameter (`flattenKeys`) (default: `false`) allows you to receive a flat array structure instead of the default nested format, with each item formatted as `{ keys: [<ordered unique keys for the item>], vals: <single or multiple item> }`.
```

@@ -111,0 +117,0 @@ indexBy(people, ['name', 'surname'], true, true));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc