Custom enum utilities for safer and more efficient list processing.
Summary
Functions
Runs the given function concurrently over the enum using Task.async_stream/3,
short-circuiting on the first error, and collecting only successful results.
Iterates over an enumerable, applying a function that returns {:ok, value}, {:error, reason}, or :skip.
Returns a list of unique elements from the given enumerable, preserving order.
Functions
@spec reduce_async_while_ok(Enumerable.t(), (term() -> term()), keyword()) :: {:ok, list()} | {:error, term()}
Runs the given function concurrently over the enum using Task.async_stream/3,
short-circuiting on the first error, and collecting only successful results.
@spec reduce_while_ok(Enumerable.t(), list(), (term() -> {:ok, term()} | {:error, term()} | :skip)) :: {:ok, list()} | {:error, term()}
Iterates over an enumerable, applying a function that returns {:ok, value}, {:error, reason}, or :skip.
- Accumulates all returned values into a list.
- Halts and returns
{:error, reason}if any element returns an error. - Skips over elements if
:skipis returned. - Returns
{:ok, list}when all elements succeed.
@spec uniq(Enumerable.t()) :: list()
Returns a list of unique elements from the given enumerable, preserving order.