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

Function applyChanges

src/store/index.ts:1719–1755  ·  view source on GitHub ↗
(changes: Changes)

Source from the content-addressed store, hash-verified

1717 );
1718
1719 const applyChanges = (changes: Changes): Store =>
1720 fluentTransaction(() =>
1721 ifTransformed(
1722 changes,
1723 () =>
1724 ifNotUndefined(
1725 middleware[13],
1726 (willApplyChanges) =>
1727 whileMutating(() => willApplyChanges(structuredClone(changes))),
1728 () => changes,
1729 ),
1730 (changes): void => {
1731 objMap(changes[0], (table, tableId) =>
1732 isUndefined(table)
1733 ? delTable(tableId)
1734 : objMap(table, (row, rowId) =>
1735 isUndefined(row)
1736 ? delRow(tableId, rowId)
1737 : objMap(row, (cell, cellId) =>
1738 setOrDelCell(
1739 tableId,
1740 rowId,
1741 cellId,
1742 cell as CellOrUndefined,
1743 undefined,
1744 true,
1745 ),
1746 ),
1747 ),
1748 );
1749 objMap(changes[1], (value, valueId) =>
1750 setOrDelValue(valueId, value as ValueOrUndefined),
1751 );
1752 },
1753 contentOrChangesIsEqual,
1754 ),
1755 );
1756
1757 const setTablesJson = (tablesJson: Json): Store => {
1758 tryCatch(() => setOrDelTables(jsonParse(tablesJson)));

Callers

nothing calls this directly

Calls 10

objMapFunction · 0.90
isUndefinedFunction · 0.90
fluentTransactionFunction · 0.70
ifTransformedFunction · 0.70
whileMutatingFunction · 0.70
delTableFunction · 0.70
delRowFunction · 0.70
setOrDelCellFunction · 0.70
setOrDelValueFunction · 0.70
willApplyChangesFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…