API reference@evolu/commonAssert › assertLength

const assertLength: <Value, Length>(
  value: Value,
  expectedLength: Length,
) => asserts value is Value & { length: Length };

Defined in: packages/common/src/Assert.ts:834

Asserts that a value has the expected length and narrows its length.

Example

import { assertLength, assertType } from "@evolu/common";

const values: ReadonlyArray<string> = ["Ada", "Grace"];
assertLength(values, 2);
assertType<typeof values.length, 2>();