zip

Zips several sheets, combining same-position values into tuples, over the union of their keys.

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

Sheet.zip([{ a: [1, 2] }, { a: [10] }]);
// { a: [[1, 10], [2, undefined]] }  (missing -> undefined)

Sheet.zip([{ a: [1] }, { b: [2] }]);
// { a: [[1, undefined]], b: [[undefined, 2]] }  (union keys, ascending)

// "-" is kept in the tuple, not skipped.
Sheet.zip([{ a: ["-"] }, { a: [5] }]);
// { a: [["-", 5]] }

API Reference

Signature

Sheet.zip<TSheets extends readonly [Sheet, ...Sheet[]]>(
  sheets: TSheets,
): Sheet<SheetZipValues<TSheets>, SheetUnionKeys<TSheets>>;

Parameters

ParameterTypeRequiredNotes
sheets[Sheet, ...Sheet[]]YesNon-empty array.

Returns

A sheet keyed by the union of input keys (ascending), each cell a tuple with one value per input sheet. Each key's row length is the max across inputs; a sheet missing a key or column contributes undefined.

Throws

  • SHEET_INVALID_ZIP_INPUT — non-array / empty sheets.

Agent Contract

FieldValue
Kindstatic combinator
Canonical namezip
AliasesNone
Mutates inputsNo
ReturnsSheet<SheetZipValues<TSheets>, SheetUnionKeys<TSheets>>

Agent Notes

  • zip is merge with an identity tuple resolver; use merge when you need to reduce the values instead.
  • A present "-" stays in the tuple; only a missing key/column is undefined.