![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
arr-union
Advanced tools
Package description
The arr-union npm package is designed to create an array of unique values, in order, from the provided arrays. It is particularly useful for combining arrays while removing duplicate entries efficiently.
Union of multiple arrays
This feature allows you to pass multiple arrays to the union function, which returns a new array that includes every unique element from the input arrays, preserving the order they appear in the input.
const union = require('arr-union');
let result = union([1, 2], [2, 3], [3, 4]);
console.log(result); // Output: [1, 2, 3, 4]
Lodash's union function offers similar functionality to arr-union. It creates an array of unique values, in order, from all given arrays using SameValueZero for equality comparisons. Compared to arr-union, lodash.union is part of a larger utility library, which might be preferable for projects that require additional utility functions beyond array union.
Underscore.js also provides a union function that computes the union of the passed-in arrays: the list of unique items, in order, that are present in one or more of the arrays. Like lodash, Underscore is a more comprehensive toolkit, which might be overkill if you only need the union functionality.
Readme
Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
This library is 15-20 times faster and more performant (scales better) than array-union, which just uses [].concat.apply([], arguments)
.
See the benchmarks.
#1: five-arrays.js
array-union.js x 245,487 ops/sec ±0.99% (96 runs sampled)
current.js x 5,267,661 ops/sec ±0.63% (98 runs sampled)
#2: ten-arrays.js
array-union.js x 134,784 ops/sec ±0.51% (94 runs sampled)
current.js x 1,919,143 ops/sec ±0.45% (100 runs sampled)
#3: two-arrays.js
array-union.js x 308,374 ops/sec ±0.75% (96 runs sampled)
current.js x 7,361,915 ops/sec ±0.67% (95 runs sampled)
Install with npm
$ npm i arr-union --save
var union = require('arr-union');
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
//=> ['a', 'b', 'c', 'd', 'e', 'f']
Returns only unique elements:
union(['a', 'a'], ['b', 'c']);
//=> ['a', 'b', 'c']
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on June 15, 2015.
FAQs
Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
The npm package arr-union receives a total of 12,290,094 weekly downloads. As such, arr-union popularity was classified as popular.
We found that arr-union 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.