Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
The uniqs npm package is a simple utility that allows you to filter out duplicate values from an array. It is particularly useful when you need to ensure that a list contains only unique items.
Removing duplicates from an array
This feature allows you to pass an array to the uniqs function, and it returns a new array with all the duplicate values removed, leaving only unique items.
[...new Set([1, 2, 2, 3, 4, 4, 5])] // returns [1, 2, 3, 4, 5]
lodash.uniq is a method from the popular Lodash library that produces a duplicate-free version of an array. It is similar to uniqs but comes as part of a larger utility library, which might be more suitable for projects that require a wide range of utility functions.
Underscore.js is a utility library that contains a uniq function, which is similar to uniqs. It offers a broader set of utility functions for manipulating and working with data. Unlike uniqs, which is focused solely on array deduplication, Underscore provides a more extensive toolkit for various operations.
array-unique is another npm package that removes duplicate values from an array. It is similar to uniqs in functionality but may have different performance characteristics or implementation details.
Example:
var uniqs = require('uniqs');
var foo = { foo: 23 };
var list = [ 3, 2, 2, 1, foo, foo ];
console.log(uniqs(list));
Output:
[ 3, 2, 1, { foo: 23 } ]
This package has been written to accompany utilities like flatten as alternative to full-blown libraries like underscore or lodash.
The implementation is optimized for simplicity rather than performance and looks like this:
var filter = Array.prototype.filter;
var indexOf = Array.prototype.indexOf;
module.exports = function uniqs(list) {
if (!list) return [];
return filter.call(list, function(item, i) {
return i == indexOf.call(list, item);
});
};
MIT
FAQs
Tiny utility to create unions and de-duplicated lists
The npm package uniqs receives a total of 1,684,436 weekly downloads. As such, uniqs popularity was classified as popular.
We found that uniqs 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.