Shorthand form for ZTransducer.identity.
Shorthand form for ZTransducer.identity. Use as:
ZTransducer[Int].filter(_ % 2 != 0)
Reads the first n values from the stream and uses them to choose the transducer that will be used for the remainder of the stream.
Reads the first n values from the stream and uses them to choose the transducer that will be used for the remainder of the stream. If the stream ends before it has collected n values the partial chunk will be provided to f.
Creates a transducer accumulating incoming values into chunks of maximum
size n
.
Creates a transducer accumulating incoming values into maps of up to n
keys.
Creates a transducer accumulating incoming values into maps of up to n
keys. Elements are mapped to keys using the function key
; elements mapped
to the same key will be merged with the function f
.
Creates a transducer accumulating incoming values into sets of maximum size
n
.
Accumulates incoming elements into a chunk as long as they verify predicate
p
.
Accumulates incoming elements into a chunk as long as they verify effectful
predicate p
.
Creates a transducer that always dies with the specified exception.
Creates a transducer that starts consuming values as soon as one fails the
predicate p
.
Creates a transducer that starts consuming values as soon as one fails the
effectful predicate p
.
Creates a transducer that always fails with the specified failure.
Creates a transducer by folding over a structure of type O
for as long as
contFn
results in true
.
Creates a transducer by folding over a structure of type O
for as long as
contFn
results in true
. The transducer will emit a value when contFn
evaluates to false
and then restart the folding.
Creates a transducer by folding over a structure of type O
.
Creates a transducer by folding over a structure of type O
. The
transducer will fold the inputs until the stream ends, resulting in a
stream with one element.
Creates a transducer by effectfully folding over a structure of type O
.
Creates a transducer by effectfully folding over a structure of type O
.
The transducer will fold the inputs until the stream ends, resulting in a
stream with one element.
Creates a sink by effectfully folding over a structure of type S
.
Creates a transducer that folds elements of type I
into a structure of
type O
until max
elements have been folded.
Creates a transducer that folds elements of type I
into a structure of
type O
until max
elements have been folded.
Like foldWeighted, but with a constant cost function of 1.
Creates a transducer that effectfully folds elements of type I
into a
structure of type O
until max
elements have been folded.
Creates a transducer that effectfully folds elements of type I
into a
structure of type O
until max
elements have been folded.
Like foldWeightedM, but with a constant cost function of 1.
Creates a transducer that folds elements of type I
into a structure of
type O
, until max
worth of elements (determined by the costFn
) have
been folded.
Creates a transducer that folds elements of type I
into a structure of
type O
, until max
worth of elements (determined by the costFn
) have
been folded.
Elements that have an individual cost larger than max
will force the
transducer to cross the max
cost. See foldWeightedDecompose for a
variant that can handle these cases.
Creates a transducer that folds elements of type I
into a structure of
type O
, until max
worth of elements (determined by the costFn
) have
been folded.
Creates a transducer that folds elements of type I
into a structure of
type O
, until max
worth of elements (determined by the costFn
) have
been folded.
The decompose
function will be used for decomposing elements that cause
an O
aggregate to cross max
into smaller elements. For example:
Stream(1, 5, 1) .aggregate( ZTransducer .foldWeightedDecompose(List[Int]())((_, i: Int) => i.toLong, 4, (i: Int) => if (i > 1) Chunk(i - 1, 1) else Chunk(i)) { (acc, el) => el :: acc } .map(_.reverse) ) .runCollect
The stream would emit the elements List(1), List(4), List(1, 1)
.
Be vigilant with this function, it has to generate "simpler" values or the
fold may never end. A value is considered indivisible if decompose
yields
the empty chunk or a single-valued chunk. In these cases, there is no other
choice than to yield a value that will cross the threshold.
The foldWeightedDecomposeM allows the decompose function to return a
ZIO
value, and consequently it allows the transducer to fail.
Creates a transducer that effectfully folds elements of type I
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
Creates a transducer that effectfully folds elements of type I
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
The decompose
function will be used for decomposing elements that cause
an S
aggregate to cross max
into smaller elements. Be vigilant with
this function, it has to generate "simpler" values or the fold may never
end. A value is considered indivisible if decompose
yields the empty
chunk or a single-valued chunk. In these cases, there is no other choice
than to yield a value that will cross the threshold.
See foldWeightedDecompose for an example.
Creates a transducer that effectfully folds elements of type I
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
Creates a transducer that effectfully folds elements of type I
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
Elements that have an individual cost larger than max
will force the
transducer to cross the max
cost. See foldWeightedDecomposeM for a
variant that can handle these cases.
Creates a transducer that always evaluates the specified effect.
Creates a transducer that purely transforms incoming values.
Creates a transducer that effectfully transforms incoming values.
Creates a transducer from a chunk processing function.
Creates a transducer that groups adjacent elements by key, using the keying
function f
.
Creates a transducer that returns the first element of the stream, if it exists.
The identity transducer.
The identity transducer. Passes elements through.
Decodes chunks of ISO/IEC 8859-1 bytes into strings.
Decodes chunks of ISO/IEC 8859-1 bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Creates a transducer that returns the last element of the stream, if it exists.
Emits the provided chunk before emitting any other value.
Splits strings on newlines.
Splits strings on newlines. Handles both Windows newlines (\r\n
) and UNIX
newlines (\n
).
Splits strings on a delimiter.
Splits elements on a delimiter and transforms the splits into desired output.
Decodes chunks of US-ASCII bytes into strings.
Decodes chunks of US-ASCII bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Decodes chunks of UTF-16BE bytes into strings.
Decodes chunks of UTF-16BE bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Decodes chunks of UTF-16 bytes into strings.
Decodes chunks of UTF-16 bytes into strings. If no byte order mark is found big-endianness is assumed.
This transducer uses the endisn-specific String constructor's behavior when handling malformed byte sequences.
Decodes chunks of UTF-16LE bytes into strings.
Decodes chunks of UTF-16LE bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Decodes chunks of UTF-32BE bytes into strings.
Decodes chunks of UTF-32BE bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Decodes chunks of UTF-32 bytes into strings.
Decodes chunks of UTF-32 bytes into strings. If no byte order mark is found big-endianness is assumed.
Decodes chunks of UTF-32LE bytes into strings.
Decodes chunks of UTF-32LE bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Decodes chunks of UTF-8 bytes into strings.
Decodes chunks of UTF-8 bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.
Decodes chunks of Unicode bytes into strings.
Decodes chunks of Unicode bytes into strings.
Detects byte order marks for UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE or defaults to UTF-8 if no BOM is detected.