zena:iterable-utils

zena
import {…} from 'zena:iterable-utils';

Classes

FilterIterator

zena
final class FilterIterator<T> implements Iterator<T>
Implements Iterator<T>

An Iterator that yields elements matching a predicate.

Constructors
zena
new(iter: Iterator<T>, predicate: (item: T) => boolean)
#
Methods
zena
next(): inline (true, T) | inline (false, _)
#

FilteredIterable

zena
final class FilteredIterable<T> implements Iterable<T>
Implements Iterable<T>

An Iterable that lazily filters elements using a predicate.

Constructors
zena
new(source: Iterable<T>, predicate: (item: T) => boolean)
#
Methods
zena
filter(predicate: (item: T) => boolean): Iterable<T>
#
zena
contains(value: T): boolean
#
zena
all(predicate: (item: T) => boolean): boolean
#
zena
some(predicate: (item: T) => boolean): boolean
#
zena
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
#
zena
find(predicate: (item: T) => boolean): inline (true, T) | inline (false, _)
#

Mixins

IterableUtils

zena
mixin IterableUtils<T> on Iterable<T>
Extends Iterable<T>

Common iteration utilities for any collection that implements Iterable.

Methods
zena
filter(predicate: (item: T) => boolean): Iterable<T>
#

Returns a new iterable containing only the elements that match the predicate.

zena
contains(value: T): boolean
#

Checks if the collection contains the specified value using equality.

zena
all(predicate: (item: T) => boolean): boolean
#

Returns true if all elements match the given predicate. Returns true if the collection is empty.

zena
some(predicate: (item: T) => boolean): boolean
#

Returns true if at least one element matches the given predicate. Returns false if the collection is empty.

zena
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
#

Reduces the collection to a single value by accumulating state.

zena
find(predicate: (item: T) => boolean): inline (true, T) | inline (false, _)
#

Finds the first element that matches the predicate. Returns an inline tuple (true, item) if found, or (false, _) if not.