@pacote/non-empty-array
An array type guaranteed to have at least one element.
The module consumes and returns plain JavaScript arrays, but is typed to prevent the TypeScript compiler from handling arrays that might be empty.
One instance where non-empty arrays are useful is when combined with
@pacote/result
to create a Validation
data type that
accumulates multiple errors as Result<T, NonEmptyArray<Error>>
. This is
because a failing computation must have at least one error.
Installation
yarn add @pacote/non-empty-array
License
MIT © Luís Rodrigues.