MCPcopy Index your code
hub / github.com/Effect-TS/effect / toReadonlyArray_

Function toReadonlyArray_

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

Source from the content-addressed store, hash-verified

293) => S extends NonEmptyChunk<any> ? RA.NonEmptyArray<Chunk.Infer<S>> : Array<Chunk.Infer<S>> = toArray_ as any
294
295const toReadonlyArray_ = <A>(self: Chunk<A>): ReadonlyArray<A> => {
296 switch (self.backing._tag) {
297 case "IEmpty": {
298 return emptyArray
299 }
300 case "IArray": {
301 return self.backing.array
302 }
303 default: {
304 const arr = new Array<A>(self.length)
305 copyToArray(self, arr, 0)
306 self.backing = {
307 _tag: "IArray",
308 array: arr
309 }
310 self.left = _empty
311 self.right = _empty
312 self.depth = 0
313 return arr
314 }
315 }
316}
317
318/**
319 * 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