UNPKG

@signaldb/core

Version:

SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON in

16 lines (15 loc) 640 B
//#region src/utils/intersection.ts /** * Computes the intersection of multiple arrays, returning an array of unique elements * that are present in all the input arrays. * @template T - The type of elements in the arrays. * @param arrays - A variable number of arrays to compute the intersection of. * @returns An array containing the unique elements found in all the input arrays. * - If no arrays are provided, returns an empty array. */ function intersection(...arrays) { if (arrays.length === 0) return []; return [...new Set(arrays.reduce((a, b) => a.filter((c) => b.includes(c))))]; } //#endregion exports.default = intersection;