API Reference / @evolu/common / Assert / assertNonEmptyArray
Variable: assertNonEmptyArray()
const assertNonEmptyArray: <T>(arr, message?) => asserts arr is [T, ...T[]];
Defined in: packages/common/src/Assert.ts:63
Asserts that an array is non-empty.
Ensures the provided array has at least one element, helping TypeScript infer the array as non-empty when this is logically guaranteed but not statically known.
Example
assertNonEmptyArray([1, 2, 3]); // no-op
assertNonEmptyArray([]); // throws Error
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
arr | T [] |
message? | string |
Returns
asserts arr is [T, ...T[]]