distinct
import { distinct } from "jsr:@ende/collections";function
function distinct<T>(array: Iterable<T>): T[]Returns all distinct elements in the given array, preserving order by first occurrence.
Uniqueness is determined by same-value-zero equality.
array: Iterable<T>The array to filter for distinct elements.
Returns
An array of distinct elements in the input array.
Example: Basic usage
import { distinct } from "@ende/collections/distinct";
import { assertEquals } from "@ende/assert";
const numbers = [3, 2, 5, 2, 5];
const distinctNumbers = distinct(numbers);
assertEquals(distinctNumbers, [3, 2, 5]);