MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / createTableStateStore

Function createTableStateStore

packages/core/src/runtime/localState.ts:364–394  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

362
363/** Create a new table state store instance. */
364export function createTableStateStore(): TableStateStore {
365 const table = new Map<string, TableLocalState>();
366
367 return Object.freeze({
368 get: (id) => table.get(id) ?? DEFAULT_TABLE_STATE,
369 set: (id, patch) => {
370 const prev = table.get(id) ?? DEFAULT_TABLE_STATE;
371 const next: TableLocalState = Object.freeze({
372 scrollTop: patch.scrollTop !== undefined ? patch.scrollTop : prev.scrollTop,
373 focusedRowIndex:
374 patch.focusedRowIndex !== undefined ? patch.focusedRowIndex : prev.focusedRowIndex,
375 focusedColumnIndex:
376 patch.focusedColumnIndex !== undefined
377 ? patch.focusedColumnIndex
378 : prev.focusedColumnIndex,
379 lastClickedKey:
380 patch.lastClickedKey !== undefined ? patch.lastClickedKey : prev.lastClickedKey,
381 viewportHeight:
382 patch.viewportHeight !== undefined ? patch.viewportHeight : prev.viewportHeight,
383 startIndex: patch.startIndex !== undefined ? patch.startIndex : prev.startIndex,
384 endIndex: patch.endIndex !== undefined ? patch.endIndex : prev.endIndex,
385 });
386 table.set(id, next);
387 return next;
388 },
389 delete: (id) => {
390 table.delete(id);
391 },
392 keys: () => table.keys(),
393 });
394}
395
396/* ========== Tree State Store (GitHub issue #122) ========== */
397

Calls 4

keysMethod · 0.65
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected