function assertmatrix
assertmatrix(x: unknown): asserts x is matrix

Asserts that a value is a 2D matrix.

Throws a TypeError if the input is not a 2D matrix. Uses TypeScript's type assertion to narrow the type.

Examples

Valid matrix

import { assertThrows } from "jsr:@std/assert";

assertmatrix([[1, 2], [3, 4]]); // No error

Invalid input throws error

import { assertThrows } from "jsr:@std/assert";

assertThrows(() => assertmatrix([1, 2, 3]), TypeError, "Expected matrix");

Number throws error

import { assertThrows } from "jsr:@std/assert";

assertThrows(() => assertmatrix(5), TypeError, "Expected matrix");

Parameters

x: unknown

The value to check

Return Type

asserts x is matrix

Throws

If x is not a 2D matrix

Usage

import assertmatrix from "datatype/assertmatrix.ts";