|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
666 bytes
|
| Line | |
|---|
| 1 | import { intersection as intersection$1 } from '../../array/intersection.mjs';
|
|---|
| 2 | import { uniq } from '../../array/uniq.mjs';
|
|---|
| 3 | import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
|
|---|
| 4 |
|
|---|
| 5 | function intersection(...arrays) {
|
|---|
| 6 | if (arrays.length === 0) {
|
|---|
| 7 | return [];
|
|---|
| 8 | }
|
|---|
| 9 | if (!isArrayLikeObject(arrays[0])) {
|
|---|
| 10 | return [];
|
|---|
| 11 | }
|
|---|
| 12 | let result = uniq(Array.from(arrays[0]));
|
|---|
| 13 | for (let i = 1; i < arrays.length; i++) {
|
|---|
| 14 | const array = arrays[i];
|
|---|
| 15 | if (!isArrayLikeObject(array)) {
|
|---|
| 16 | return [];
|
|---|
| 17 | }
|
|---|
| 18 | result = intersection$1(result, Array.from(array));
|
|---|
| 19 | }
|
|---|
| 20 | return result;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | export { intersection };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.