@metreeca/core - v0.9.22
    Preparing search index...

    Module arrays

    General-purpose array operations.

    Normalising a Value to an Array

    Coerce an optional or single-or-many value into an array for uniform iteration:

    import { some } from '@metreeca/core/arrays';

    const tags = some(input); // undefined -> [], "x" -> ["x"], ["x", "y"] -> ["x", "y"]

    Retaining Unique Values

    Keep the unique values of an array, dropping later duplicates:

    import { unique } from '@metreeca/core/arrays';

    unique([1, 1, 2, 3, 3]); // [1, 2, 3]

    Combining Arrays as Sets

    Merge several arrays into their union or narrow them to their shared intersection, deduplicating either way:

    import { intersection, union } from '@metreeca/core/arrays';

    union([[1, 2], [2, 3]]); // [1, 2, 3]
    intersection([[1, 2, 3], [2, 3, 4]]); // [2, 3]

    Type Aliases

    Some

    Zero, one, or many values of type T.

    Functions

    some

    Normalises a Some value into an array.

    unique

    Retains the unique values of an array.

    union

    Combines arrays into their set union.

    intersection

    Reduces arrays to their set intersection.