The type of values in the async iterable
The type of keys used for uniqueness checks (defaults to T)
A consumer function that returns a promise resolving to a boolean
This function processes an async iterable and determines if all values (or derived keys)
are unique. It returns true if all values are unique, and false as soon as it
encounters a duplicate. The function can use an optional mapping function to transform
values into keys before checking uniqueness, which is useful for complex objects.
// Check if all numbers are unique
const allUnique = await G.pipe(
G.ofIterable([1, 2, 3, 4, 5]),
G.areUnique()
); // true
const hasDuplicates = await G.pipe(
G.ofIterable([1, 2, 3, 3, 5]),
G.areUnique()
); // false
// Check uniqueness using a specific property
const users = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Charlie' }
];
const uniqueIds = await G.pipe(
G.ofIterable(users),
G.areUnique(user => user.id)
); // true
Creates a consumer that checks if all values in an async iterable are unique.