Chunk80
Constructors
emptyconstCreates an empty Chunk.fromIterableconstCreates a new Chunk from an iterable collection of values.isChunkconstChecks whether u is a Chunk<unknown> Example (Checking for chunks) ts import { Chunk } from "effect" const chunk = Chunk.make(1, 2, 3) const array = [1, 2, 3] console.log(Chunk.isChunk(chunk)) // true console.log(Chunk.isChunk(array)) // false console.log(Chunk.isChunk("string")) // false makeconstBuilds a NonEmptyChunk from an non-empty collection of elements.makeByconstReturns a non-empty Chunk of length n with element i initialized by f(i).ofconstBuilds a NonEmptyChunk from a single element.rangeconstCreates a non-empty Chunk of consecutive integers from start through end, inclusive.Models
Elements
chunksOfconstGroups elements in chunks of up to n elements.containsconstReturns a function that checks if a Chunk contains a given value using the default Equivalence.containsWithconstReturns a function that checks if a Chunk contains a given value using a provided isEquivalent function.dedupeconstRemoves duplicate elements from a Chunk, preserving the first occurrence of each value.dropconstDrops the first up to n elements from the chunk.dropRightconstDrops the last n elements.dropWhileconstDrops all elements so long as the predicate returns true.everyconstChecks whether a predicate holds true for every Chunk element.findFirstconstReturns the first element that satisfies the specified predicate, or None if no such element exists.findFirstIndexconstReturns the first index for which a predicate holds.findLastconstFinds the last element for which a predicate holds.findLastIndexconstReturns the last index for which a predicate holds.getconstGets the value at an index in a Chunk safely, returning None when the index is out of bounds.headconstReturns the first element of this chunk safely if it exists.headNonEmptyconstReturns the first element of this non empty chunk.intersectionconstCreates a Chunk of values that are included in both chunks.isEmptyconstDetermines if the chunk is empty.isNonEmptyconstDetermines if the chunk is not empty.lastconstReturns the last element of this chunk safely if it exists.lastNonEmptyconstReturns the last element of this non empty chunk.modifyconstApplies a function to the element at the specified index safely, creating a new Chunk, or returns None if the index is out of bounds.removeconstDeletes the element at the specified index, creating a new Chunk.replaceconstChanges the element at the specified index safely, creating a new Chunk, or returns None if the index is out of bounds.reverseconstReverses the order of elements in a Chunk.sizeconstRetrieves the size of the chunk.someconstChecks whether a predicate holds true for some Chunk element.tailconstReturns every element after the first safely, or None when the chunk is empty.tailNonEmptyconstReturns every element after the first from a non-empty chunk.takeconstTakes the first up to n elements from the chunk.takeRightconstTakes the last n elements.takeWhileconstTakes all elements so long as the predicate returns true.unionconstCreates a Chunks of unique values, in order, from all given Chunks.unzipconstTakes a Chunk of pairs and returns two corresponding Chunks.Combinators
Mapping
Filtering
compactconstFilters out optional values Example (Compacting optional values) ts import { Chunk, Option } from "effect" const chunk = Chunk.make(Option.some(1), Option.none(), Option.some(3)) const result = Chunk.compact(chunk) console.log(Chunk.toArray(result)) // [1, 3] dedupeAdjacentconstDeduplicates adjacent elements that are identical.differenceconstCreates a Chunk of values not included in the other given Chunk.differenceWithconstCreates a Chunk of values not included in the other given Chunk using the provided isEquivalent function.filterconstReturns a filtered subset of the elements.filterMapconstReturns a filtered and mapped subset of the elements.filterMapWhileconstTransforms all elements of the chunk for as long as the specified function succeeds.partitionconstSplits a chunk using a Filter into failures and successes.separateconstSeparates a chunk of Result values into a chunk of failures and a chunk of successes.Sequencing
Combining
appendconstAppends the specified element to the end of the Chunk.appendAllconstConcatenates two chunks, combining their elements.prependconstPrepends an element to the front of a Chunk, creating a new NonEmptyChunk.prependAllconstPrepends the specified prefix chunk to the beginning of the specified chunk.Converting
Folding
Instances
Sorting
Splitting
splitconstSplits a chunk into up to n chunks, distributing elements in order.splitAtconstReturns two splits of this chunk at the specified index.splitNonEmptyAtconstSplits a NonEmptyChunk at n, returning a non-empty prefix and the remaining suffix.splitWhereconstSplits this chunk on the first element that matches this predicate.Type Lambdas
Unsafe
fromArrayUnsafeconstWraps an array into a chunk without copying.fromNonEmptyArrayUnsafeconstWraps a non-empty array into a non-empty chunk without copying.getUnsafeconstGets an element at the specified index without returning an Option.headUnsafeconstReturns the first element of this chunk.lastUnsafeconstReturns the last element of this chunk.