Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
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
It's already pretty fast, but will be much faster when Set becomes available in V8 (especially with large arrays).
$ npm install --save array-uniq
var arrayUniq = require('array-uniq');
arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
MIT © Sindre Sorhus
FAQs
Create an array without duplicates
The npm package array-uniq receives a total of 3,661,145 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.