Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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,510,618 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.