Package: effect
Module: Array
Pads or truncates an array to exactly n elements, filling with fill
if the array is shorter, or slicing if longer.
When to use
Use to ensure an array has a specific length, padding with a fill value or truncating as needed.
Details
Returns an empty array when n <= 0.
Example (Padding an array)
import { Array } from "effect"
console.log(Array.pad([1, 2, 3], 6, 0)) // [1, 2, 3, 0, 0, 0]
See
take — truncate without paddingreplicate — create an array of a single repeated valueSignature
declare const pad: { <A, T>(n: number, fill: T): (self: Array<A>) => Array<A | T>; <A, T>(self: Array<A>, n: number, fill: T): Array<A | T>; }
Since v3.8.4