Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
The array-uniq npm package is a simple and efficient utility for removing duplicate values from an array. It is designed to work with arrays containing primitive values such as strings, numbers, and booleans.
Removing duplicates from an array
This feature allows you to pass an array to the array-uniq function, which then returns a new array with all duplicate values removed. It works with numbers, strings, and booleans.
const arrayUniq = require('array-uniq');
const uniqueArray = arrayUniq([1, 1, 2, 3, 3]);
console.log(uniqueArray); // Output: [1, 2, 3]
lodash.uniq is part of the Lodash library, which provides a more comprehensive set of tools for working with arrays and objects. Unlike array-uniq, lodash.uniq supports arrays of objects and uses a custom comparator for uniqueness, which makes it more flexible but slightly slower for simple cases.
The uniq package offers similar functionality to array-uniq but includes additional features such as the ability to specify a custom iterator function to determine uniqueness. This can be useful for more complex comparison logic but adds overhead for simple use cases.
Create an array without duplicates
$ npm install array-uniq
import arrayUniq from 'array-uniq';
arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
FAQs
Create an array without duplicates
The npm package array-uniq receives a total of 6,495,882 weekly downloads. As such, array-uniq popularity was classified as popular.
We found that array-uniq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.