UNPKG

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