MCPcopy Create free account
hub / github.com/Effect-TS/effect / getUnchecked

Function getUnchecked

packages/effect/src/Chunk.ts:670–690  ·  view source on GitHub ↗
(self: Chunk<A>, i: number)

Source from the content-addressed store, hash-verified

668})
669
670const getUnchecked = <A>(self: Chunk<A>, i: number): A => {
671 switch (self.backing._tag) {
672 case "IEmpty": {
673 throw new Error(`Index out of bounds: ${i}`)
674 }
675 case "ISingleton": {
676 return self.backing.a
677 }
678 case "IArray": {
679 return self.backing.array[i]!
680 }
681 case "IConcat": {
682 return i < self.left.length
683 ? getUnchecked(self.left, i)
684 : getUnchecked(self.right, i - self.left.length)
685 }
686 case "ISlice": {
687 return getUnchecked(self.backing.chunk, i + self.backing.offset)
688 }
689 }
690}
691
692/**
693 * Appends the specified element to the end of the `Chunk`.

Callers 1

Chunk.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected