non2DArray
non2DArray(value) is the same test as !is2DArray(value). The prefix exists so that a guard clause reads as a sentence rather than as a negation — see Validation conventions.
An empty array qualifies as "not two-dimensional", because is2DArray requires at least one row.
A caveat on types: the guard is declared as a type predicate, but it only narrows usefully when the value's own type already names unknown[][] as one of its cases. In the branch where the value is a matrix, TypeScript is left with never rather than a matrix type, so reach for is2DArray or require2DArray when the matrix has to be used after the check. As a plain boolean answer, non2DArray is exact in every case.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The value to check. |
Returns
boolean — true if the value is not a non-empty array of arrays; otherwise false.
In TypeScript the guard narrows arr to T inside the branch.
Examples
What counts as not two-dimensional
Reporting why a value was rejected
See also
is2DArray— the positive form.nonConsistent2DArray— also rejects a ragged matrix.require2DArray— throws instead of answering.
Source
This documentation was generated with AI (Claude) from the library's source code.