Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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];
uniqs(list);
// => [3, 2, 1, { foo: 23 }]
You can pass multiple lists to create a union:
uniqs([2, 1, 1], [2, 3, 3, 4], [4, 3, 2]);
// => [2, 1, 3, 4]
Passing individual items works too:
uniqs(3, 2, 2, [1, 1, 2]);
// => [3, 2, 1]
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:
module.exports = function uniqs() {
var list = Array.prototype.concat.apply([], arguments);
return list.filter(function(item, i) {
return i == list.indexOf(item);
});
};
MIT
FAQs
Tiny utility to create unions and de-duplicated lists
The npm package uniqs receives a total of 2,389,714 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.