isSubset
Import from @varavel/vdl-plugin-sdk/utils/arrays.
function isSubset<T>(superset, subset): boolean;
Checks if the subset array is entirely contained within the superset array.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of elements contained in the arrays. |
Parameters
| Parameter | Type | Description |
|---|---|---|
superset | readonly T[] | The array that may contain all elements of the subset. |
subset | readonly T[] | The array to check against the superset. |
Returns
boolean
Returns true if all elements of the subset are present in the superset, otherwise returns false.
Examples
const superset = [1, 2, 3, 4, 5];
const subset = [2, 3, 4];
isSubset(superset, subset); // true
const superset = ['a', 'b', 'c'];
const subset = ['a', 'd'];
isSubset(superset, subset); // false