function distinct
distinct<T>(array: Iterable<T>): T[]Returns all distinct elements in the given array, preserving order by first occurrence.
Examples
Example 1
Example 1
import { distinct } from "@std/collections/distinct"; import { assertEquals } from "@std/assert/assert_equals"; const numbers = [3, 2, 5, 2, 5]; const distinctNumbers = distinct(numbers); assertEquals(distinctNumbers, [3, 2, 5]);
Type Parameters
TParameters
array: Iterable<T>Return Type
T[]