MCPcopy
hub / github.com/tinyplex/tinybase / setCell

Function setCell

src/store/index.ts:1628–1686  ·  view source on GitHub ↗
(
    tableId: Id,
    rowId: Id,
    cellId: Id,
    cell: Cell | MapCell,
    skipMiddleware?: boolean,
    skipRowMiddleware?: boolean,
  )

Source from the content-addressed store, hash-verified

1626 );
1627
1628 const setCell = (
1629 tableId: Id,
1630 rowId: Id,
1631 cellId: Id,
1632 cell: Cell | MapCell,
1633 skipMiddleware?: boolean,
1634 skipRowMiddleware?: boolean,
1635 ): Store =>
1636 fluentTransaction(
1637 (tableId, rowId, cellId) =>
1638 ifNotUndefined(
1639 getValidatedCell(
1640 tableId,
1641 rowId,
1642 cellId,
1643 isFunction(cell) ? cell(getCell(tableId, rowId, cellId)) : cell,
1644 ),
1645 (validCell) => {
1646 const tableMap = getOrCreateTable(tableId);
1647 ifNotUndefined(
1648 skipMiddleware || skipRowMiddleware || !middleware[14]?.()
1649 ? undefined
1650 : middleware[3],
1651 (willSetRow) => {
1652 const existingRowMap = mapGet(tableMap, rowId);
1653 const prospectiveRow: Row = {
1654 ...(existingRowMap ? mapToObj<Cell>(existingRowMap) : {}),
1655 [cellId]: validCell,
1656 };
1657 ifNotUndefined(
1658 whileMutating(() =>
1659 willSetRow(tableId, rowId, structuredClone(prospectiveRow)),
1660 ),
1661 (row) =>
1662 applyRowDirectly(
1663 tableId,
1664 tableMap,
1665 rowId,
1666 row,
1667 skipMiddleware,
1668 ),
1669 );
1670 },
1671 () =>
1672 setCellIntoNewRow(
1673 tableId,
1674 tableMap,
1675 rowId,
1676 cellId,
1677 validCell,
1678 skipMiddleware,
1679 ),
1680 );
1681 },
1682 ),
1683 tableId,
1684 rowId,
1685 cellId,

Callers 4

setOrDelCellFunction · 0.70
StateFunction · 0.50
TestFunction · 0.50
StateFunction · 0.50

Calls 11

isFunctionFunction · 0.90
mapGetFunction · 0.90
mapToObjFunction · 0.90
fluentTransactionFunction · 0.70
getValidatedCellFunction · 0.70
getCellFunction · 0.70
getOrCreateTableFunction · 0.70
whileMutatingFunction · 0.70
applyRowDirectlyFunction · 0.70
setCellIntoNewRowFunction · 0.70
willSetRowFunction · 0.50

Tested by 3

StateFunction · 0.40
TestFunction · 0.40
StateFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…