1 | /**
|
2 | Retrieve the missing values in a collection based on an array of items.
|
3 |
|
4 | @hidden
|
5 |
|
6 | @param source - Source collection to search through.
|
7 | @param items - Items to search for.
|
8 | @param maxValues - Maximum number of values after the search process is stopped. Default: 5.
|
9 | */
|
10 | const hasItems = (source, items, maxValues = 5) => {
|
11 | const missingValues = [];
|
12 | for (const value of items) {
|
13 | if (source.has(value)) {
|
14 | continue;
|
15 | }
|
16 | missingValues.push(value);
|
17 | if (missingValues.length === maxValues) {
|
18 | return missingValues;
|
19 | }
|
20 | }
|
21 | return missingValues.length === 0 ? true : missingValues;
|
22 | };
|
23 | export default hasItems;
|