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 4.0.0 to 4.1.0

26

dist/arr.d.ts

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

/**
* Keeps the items in the array that meet the condition
* specified in the given `predicate` callback function.
*
*
* @param {Function} predicate

@@ -296,2 +297,11 @@ *

/**
* Inverse of the `filter` method, removing all items in the array satisfying
* the condition specified in the given `predicate` callback function.
*
* @param {Function} predicate
*
* @returns {Arr<T>}
*/
reject(predicate: (value: T, index: number, array: Arr<T>) => unknown): Arr<T>;
/**
* Removes `undefined` and `null` values from the array.

@@ -373,2 +383,16 @@ *

/**
* Keep only unique items in the array.
*
* @returns {Arr}
*/
unique(): Arr<T>;
/**
* Keep only unique items in the array identified by the given `selector`.
*
* @param {Function}
*
* @returns {Array}
*/
uniqueBy(selector: (item: T, index: number, array: Arr<T>) => unknown): Arr<T>;
/**
* Add one or more items to the beginning of the array.

@@ -375,0 +399,0 @@ *

@@ -31,3 +31,6 @@ 'use strict';

static isIterable(value) {
return Array.from(value).length > 0;
if (value == null) {
return false;
}
return typeof value[Symbol.iterator] === 'function';
}

@@ -364,5 +367,3 @@ /**

push(...values) {
for (const value of this.resolveValues(...values)) {
this.values.push(value);
}
this.values.push(...this.resolveValues(...values));
return this;

@@ -379,3 +380,3 @@ }

return values.flatMap(value => {
if (value === null || value === undefined) {
if (value == null) {
return value;

@@ -401,2 +402,15 @@ }

/**
* Inverse of the `filter` method, removing all items in the array satisfying
* the condition specified in the given `predicate` callback function.
*
* @param {Function} predicate
*
* @returns {Arr<T>}
*/
reject(predicate) {
return this.filter((item, index) => {
return !predicate(item, index, this);
});
}
/**
* Removes `undefined` and `null` values from the array.

@@ -408,3 +422,3 @@ *

return this.filter(item => {
return item !== null && item !== undefined;
return item != null;
});

@@ -513,2 +527,27 @@ }

/**
* Keep only unique items in the array.
*
* @returns {Arr}
*/
unique() {
return new Arr(new Set(this.values));
}
/**
* Keep only unique items in the array identified by the given `selector`.
*
* @param {Function}
*
* @returns {Array}
*/
uniqueBy(selector) {
const exists = new Set();
return this.reject((item, index) => {
const id = selector(item, index, this);
if (exists.has(id)) {
return true;
}
exists.add(id);
});
}
/**
* Add one or more items to the beginning of the array.

@@ -515,0 +554,0 @@ *

10

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

@@ -10,8 +10,8 @@ "bugs": {

"devDependencies": {
"@supercharge/eslint-config-typescript": "~2.3.0",
"@supercharge/eslint-config-typescript": "~2.3.1",
"@supercharge/tsconfig": "~4.0.0",
"c8": "~7.12.0",
"eslint": "~8.21.0",
"expect": "~28.1.3",
"typescript": "~4.7.4",
"eslint": "~8.26.0",
"expect": "~29.2.2",
"typescript": "~4.8.4",
"uvu": "~0.5.6"

@@ -18,0 +18,0 @@ },

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