Filter items in the iterator such that no two items fulfill the same predicate.
import { pipe } from "yta";import { of, toArray, uniqueOn } from "yta/sync";pipe( of( { id: 1, type: "a" }, { id: 2, type: "b" }, { id: 3, type: "a" }, { id: 4, type: "c" }, ), uniqueOn(({ type }) => type), toArray(),);// => [// { id: 1, type: "a" },// { id: 2, type: "b" },// { id: 4, type: "c" },// ] Copy
import { pipe } from "yta";import { of, toArray, uniqueOn } from "yta/sync";pipe( of( { id: 1, type: "a" }, { id: 2, type: "b" }, { id: 3, type: "a" }, { id: 4, type: "c" }, ), uniqueOn(({ type }) => type), toArray(),);// => [// { id: 1, type: "a" },// { id: 2, type: "b" },// { id: 4, type: "c" },// ]
The item type
The predicate type
The predicated function
Filter items in the iterator such that no two items fulfill the same predicate.