Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@supercharge/arrays

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supercharge/arrays - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

10

dist/arr.d.ts

@@ -155,4 +155,12 @@ declare type Values<T> = Array<T | Iterable<T> | undefined | null>;

*/
groupBy<R = any>(key: keyof T): R;
groupBy<R = any>(key: keyof T | ((item: T) => any)): R;
/**
* Create a value receiving callback.
*
* @param {*} value
*
* @returns {Function}
*/
private valueRetriever;
/**
* Determine whether the array contains the given `value`.

@@ -159,0 +167,0 @@ *

@@ -182,7 +182,8 @@ 'use strict';

groupBy(key) {
if (String(key).includes('.')) {
if (typeof key === 'string' && key.includes('.')) {
throw new Error('We do not support nested grouping yet. Please send a PR for that feature.');
}
const selector = this.valueRetriever(key);
return this.reduce((carry, item) => {
const group = item[key] || '';
const group = selector(item) || '';
if (carry[group] === undefined) {

@@ -196,2 +197,16 @@ carry[group] = [];

/**
* Create a value receiving callback.
*
* @param {*} value
*
* @returns {Function}
*/
valueRetriever(value) {
return typeof value === 'function'
? value
: function (item) {
return item[value];
};
}
/**
* Determine whether the array contains the given `value`.

@@ -198,0 +213,0 @@ *

4

package.json
{
"name": "@supercharge/arrays",
"description": "Array utilities for Node.js and JavaScript",
"version": "3.1.0",
"version": "3.2.0",
"author": "Marcus Pöhls <marcus@superchargejs.com>",

@@ -12,3 +12,3 @@ "bugs": {

"@supercharge/tsconfig": "~1.0.0",
"c8": "~7.11.0",
"c8": "~7.11.2",
"eslint": "~7.32.0",

@@ -15,0 +15,0 @@ "expect": "~27.5.1",

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