Comparing version 0.35.0 to 0.36.0
@@ -531,2 +531,24 @@ 'use strict'; | ||
/** | ||
* Union creates an array of unique elements from all given arrays in order encountered | ||
* | ||
* @param {Array} arrays input arrays | ||
* @returns {Array} an array of unique elements from all given arrays | ||
* | ||
* @example | ||
* const result = arrays.union([2], [1, 2, 3, 1]); | ||
* > [2, 1, 3] | ||
*/ | ||
function union (...arrays) { | ||
return Array.from([...arrays].reduce((acc, curr, i) => { | ||
if (Array.isArray(curr)) { | ||
curr.reduce((res, cur) => { | ||
acc.add(cur); | ||
return res; | ||
}, ''); | ||
} | ||
return acc; | ||
}, new Set())); | ||
} | ||
/** | ||
* Removes all duplicate items of an array | ||
@@ -608,2 +630,3 @@ * | ||
tap: tap, | ||
union: union, | ||
unique: unique, | ||
@@ -610,0 +633,0 @@ zip: zip |
@@ -527,2 +527,24 @@ /** | ||
/** | ||
* Union creates an array of unique elements from all given arrays in order encountered | ||
* | ||
* @param {Array} arrays input arrays | ||
* @returns {Array} an array of unique elements from all given arrays | ||
* | ||
* @example | ||
* const result = arrays.union([2], [1, 2, 3, 1]); | ||
* > [2, 1, 3] | ||
*/ | ||
function union (...arrays) { | ||
return Array.from([...arrays].reduce((acc, curr, i) => { | ||
if (Array.isArray(curr)) { | ||
curr.reduce((res, cur) => { | ||
acc.add(cur); | ||
return res; | ||
}, ''); | ||
} | ||
return acc; | ||
}, new Set())); | ||
} | ||
/** | ||
* Removes all duplicate items of an array | ||
@@ -604,2 +626,3 @@ * | ||
tap: tap, | ||
union: union, | ||
unique: unique, | ||
@@ -606,0 +629,0 @@ zip: zip |
{ | ||
"name": "absurdum", | ||
"version": "0.35.0", | ||
"version": "0.36.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -70,2 +70,3 @@ [![GitHub Releases](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases) | ||
- [tap][arrays.tap] | ||
- [union][arrays.union] | ||
- [unique][arrays.unique] | ||
@@ -95,2 +96,3 @@ - [zip][arrays.zip] | ||
[arrays.tap]: ./docs/arrays/tap.md | ||
[arrays.union]: ./docs/arrays/union.md | ||
[arrays.unique]: ./docs/arrays/unique.md | ||
@@ -97,0 +99,0 @@ [arrays.zip]: ./docs/arrays/zip.md |
@@ -23,2 +23,3 @@ export { chunk } from "./chunk.js"; | ||
export { unique } from "./unique.js"; | ||
export { union } from "./union.js"; | ||
export { zip } from "./zip.js"; |
@@ -22,3 +22,4 @@ export { chunk } from './chunk.js'; | ||
export { tap } from './tap.js'; | ||
export { union } from './union.js'; | ||
export { unique } from './unique.js'; | ||
export { zip } from './zip.js'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131803
115
3319
134