Skip to content

Latest commit

 

History

History
32 lines (18 loc) · 1.34 KB

polyethylene.polyasynciterable.unique.md

File metadata and controls

32 lines (18 loc) · 1.34 KB

Home > polyethylene > PolyAsyncIterable > unique

PolyAsyncIterable.unique() method

Return an iteration of unique elements, where two elements are considered equal if the result of func(element) is the same for both elements.

Signature:

unique(func?: AsyncIndexedMapping<T, unknown>): PolyAsyncIterable<T>;

Parameters

Parameter Type Description
func AsyncIndexedMapping<T, unknown> A function that returns a _key_ used for uniqueness checks. If not passed, an identitity function is used.

Returns:

PolyAsyncIterable<T>

A new PolyAsyncIterable only elements for which func(element) returns a value that hasn't been seen before

Remarks

Note that the first element seen with a specific key is always the one yielded, and every other element afterwards is ignored.

If no key-mapping function is given, the elements theselves are used as keys. This is likely _not_ what you want in most situations unless elements are primitive types.