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

Function delValidCell

src/store/index.ts:904–944  ·  view source on GitHub ↗
(
    tableId: Id,
    table: TableMap,
    rowId: Id,
    row: RowMap,
    cellId: Id,
    forceDel?: boolean,
    skipMiddleware?: boolean,
  )

Source from the content-addressed store, hash-verified

902 };
903
904 const delValidCell = (
905 tableId: Id,
906 table: TableMap,
907 rowId: Id,
908 row: RowMap,
909 cellId: Id,
910 forceDel?: boolean,
911 skipMiddleware?: boolean,
912 ): void => {
913 const defaultCell = mapGet(
914 mapGet(tablesSchemaRowCache, tableId)?.[0],
915 cellId,
916 );
917 if (!isUndefined(defaultCell) && !forceDel) {
918 return setValidCell(tableId, rowId, row, cellId, defaultCell);
919 }
920 if (
921 skipMiddleware ||
922 (whileMutating(() => middleware[10]?.(tableId, rowId, cellId)) ?? true)
923 ) {
924 const delCell = (cellId: Id) => {
925 cellChanged(tableId, rowId, cellId, mapGet(row, cellId));
926 cellIdsChanged(tableId, rowId, cellId, -1);
927 mapSet(row, cellId);
928 };
929 if (isUndefined(defaultCell)) {
930 delCell(cellId);
931 } else {
932 mapForEach(row, delCell);
933 }
934 if (collIsEmpty(row)) {
935 rowIdsChanged(tableId, rowId, -1);
936 if (collIsEmpty(mapSet(table, rowId))) {
937 tableIdsChanged(tableId, -1);
938 mapSet(tablesMap, tableId);
939 mapSet(tablePoolFunctions, tableId);
940 mapSet(tableCellIds, tableId);
941 }
942 }
943 }
944 };
945
946 const delValidValue = (valueId: Id, skipMiddleware?: boolean): void => {
947 const defaultValue = mapGet(valuesDefaulted, valueId);

Callers 3

setValidRowFunction · 0.70
applyRowDirectlyFunction · 0.70
delCellFunction · 0.70

Calls 10

mapGetFunction · 0.90
isUndefinedFunction · 0.90
mapForEachFunction · 0.90
collIsEmptyFunction · 0.90
mapSetFunction · 0.90
setValidCellFunction · 0.70
whileMutatingFunction · 0.70
delCellFunction · 0.70
rowIdsChangedFunction · 0.70
tableIdsChangedFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…