intersect
import { intersect } from "jsr:@ende/collections";function
function intersect<T>(...iterables: Iterable<T>[]): T[]Returns all distinct elements that appear at least once in each of the given iterables.
...iterables: Iterable<T>[]The iterables to intersect.
Returns
An array of distinct elements that appear at least once in each of the given iterables.
Example: Basic usage
import { intersect } from "@ende/collections/intersect";
import { assertEquals } from "@ende/assert";
const lisaInterests = ["Cooking", "Music", "Hiking"];
const kimInterests = ["Music", "Tennis", "Cooking"];
const commonInterests = intersect(lisaInterests, kimInterests);
assertEquals(commonInterests, ["Cooking", "Music"]);