entries

Expands a matrix into a flat list of entries in ascending key order, each row left to right.

import { Matrix } from "@teakit/matrix";

Matrix.entries({ b: [3], a: [1, 2] });
// [
//   { key: "a", rowIndex: 0, colIndex: 0, value: 1 },
//   { key: "a", rowIndex: 0, colIndex: 1, value: 2 },
//   { key: "b", rowIndex: 1, colIndex: 0, value: 3 },
// ]

API Reference

Signature

Matrix.entries<T, TKey extends string>(
  matrix: Matrix<T, TKey>,
): MatrixEntry<T, TKey>[];
// MatrixEntry: { key, rowIndex, colIndex, value }

Parameters

ParameterTypeRequiredNotes
matrixMatrix<T, TKey>YesSource matrix.

Returns

An array of { key, rowIndex, colIndex, value }, ordered by ascending key then column. rowIndex follows the ascending key order.

Throws

Does not throw.

Agent Contract

FieldValue
Kindstatic traversal
Canonical nameentries
AliasesNone
Mutates inputsNo
ReturnsMatrixEntry<T, TKey>[]

Agent Notes

  • entries uses colIndex; the inverse, fromEntries, uses index to place values back into rows.
  • The shapes differ: entries returns MatrixEntry, fromEntries consumes MatrixEntryInput.