nonConsistent2DArray
nonConsistent2DArray(value) is the same test as !isConsistent2DArray(value), written so that a guard clause reads forwards — see Validation conventions.
Like non2DArray, it is best used for its boolean answer: after the check TypeScript does not hand back a usable matrix type. requireConsistent2DArray is what validates and returns the matrix.
It reports true for two different situations: a matrix whose rows differ in length, and a value that is not a matrix at all. They are indistinguishable from the result alone, so use non2DArray when the difference matters.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The value to check. |
Returns
boolean — true if the value is not a non-empty array of arrays of equal length; otherwise false.
In TypeScript the guard narrows arr to T inside the branch.
Examples
Both failing cases
Telling the two apart
See also
isConsistent2DArray— the positive form.non2DArray— rejects only the non-matrices.requireConsistent2DArray— throws, and names the offending row.
Source
This documentation was generated with AI (Claude) from the library's source code.