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

Function toReadonlyArray_

packages/effect/src/Chunk.ts:408–429  ·  view source on GitHub ↗
(self: Chunk<A>)

Source from the content-addressed store, hash-verified

406) => S extends NonEmptyChunk<any> ? RA.NonEmptyArray<Chunk.Infer<S>> : Array<Chunk.Infer<S>> = toArray_ as any
407
408const toReadonlyArray_ = <A>(self: Chunk<A>): ReadonlyArray<A> => {
409 switch (self.backing._tag) {
410 case "IEmpty": {
411 return emptyArray
412 }
413 case "IArray": {
414 return self.backing.array
415 }
416 default: {
417 const arr = new Array<A>(self.length)
418 copyToArray(self, arr, 0)
419 self.backing = {
420 _tag: "IArray",
421 array: arr
422 }
423 self.left = _empty
424 self.right = _empty
425 self.depth = 0
426 return arr
427 }
428 }
429}
430
431/**
432 * Converts a `Chunk` into a `ReadonlyArray`. If the provided `Chunk` is

Callers

nothing calls this directly

Calls 1

copyToArrayFunction · 0.85

Tested by

no test coverage detected