<A = never>(n: number): Array<A | undefined>Creates a new Array of the specified length with all slots uninitialized.
When to use
Use when you need a pre-sized array that will be filled imperatively.
Details
Elements are typed as A | undefined because the slots are empty.
Example (Allocating a fixed-size array)
import { Array } from "effect"
const result = Array.allocate<number>(3)
console.log(result.length) // 3constructorsmakeBy
Source effect/Array.ts:1731 lines
export const const allocate: <A = never>(
n: number
) => Array<A | undefined>
Creates a new Array of the specified length with all slots uninitialized.
When to use
Use when you need a pre-sized array that will be filled imperatively.
Details
Elements are typed as A | undefined because the slots are empty.
Example (Allocating a fixed-size array)
import { Array } from "effect"
const result = Array.allocate<number>(3)
console.log(result.length) // 3
allocate = <function (type parameter) A in <A = never>(n: number): Array<A | undefined>A = never>(n: numbern: number): interface Array<T>Array<function (type parameter) A in <A = never>(n: number): Array<A | undefined>A | undefined> => new const Array: ArrayConstructor
new (arrayLength?: number) => any[] (+2 overloads)
Array(n: numbern)