Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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 4,934,712 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.