isSheet

Returns whether a value is a valid sheet, using the same structure rule as from but without cloning.

import { Sheet } from "@teakit/sheet";

Sheet.isSheet({ "2024": [1, 2], "2025": [3] }); // true
Sheet.isSheet({}); // true (empty sheet)

Sheet.isSheet(null); // false
Sheet.isSheet([1, 2]); // false (top-level array)
Sheet.isSheet({ a: 1 }); // false (row is not an array)
Sheet.isSheet(new Date()); // false

// Narrow unknown input before using sheet APIs.
const input: unknown = { a: [1] };
if (Sheet.isSheet(input)) {
  Sheet.sum(input); // 1
}

API Reference

Signature

Sheet.isSheet(value: unknown): value is Sheet<unknown>;

Parameters

ParameterTypeRequiredNotes
valueunknownYesValue to inspect.

Returns

true for a plain object whose own enumerable string keys all map to dense arrays; false otherwise. Does not clone.

Throws

Does not throw.

Agent Contract

FieldValue
Kindstatic predicate
Canonical nameisSheet
AliasesNone
Mutates inputsNo
Returnsvalue is Sheet<unknown>

Agent Notes

  • Use isSheet for control flow; use assertSheet to throw, or from to validate and clone in one step.
  • Sparse-array rows are rejected, matching from.