clone

Explicitly copies a known sheet: a new outer object and new row arrays, keys ascending, with cell references preserved.

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

const input = { b: [1, 2], a: [3] };
const copy = Sheet.clone(input);
// { a: [3], b: [1, 2] }  (keys ascending)
copy !== input; // true
copy.a !== input.a; // true (rows are new arrays)

// Cell values are not deep-copied.
const cell = { v: 1 };
Sheet.clone({ a: [cell] }).a[0] === cell; // true

API Reference

Signature

Sheet.clone<T, TKey extends string>(
  sheet: Sheet<T, TKey>,
): Sheet<T, TKey>;

Parameters

ParameterTypeRequiredNotes
sheetSheet<T, TKey>YesA value already known to be a sheet.

Returns

A new sheet with keys ascending and each row copied; cell values share references.

Throws

Does not throw.

Agent Contract

FieldValue
Kindstatic helper
Canonical nameclone
AliasesNone
Mutates inputsNo
ReturnsSheet<T, TKey>

Agent Notes

  • Use clone for a value you already trust is a sheet; for unknown/external input use from, which validates first.