tinybase 1.3.3 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const e=(e,t)=>e.includes(t),t=(e,t)=>e.forEach(t),n=e=>e.length,s=e=>0==n(e),r=e=>e.slice(1),o=(e,t)=>e.push(t),c=e=>e.pop(),l=e=>null==e,i=(e,t,n)=>l(e)?n?.():t(e),a=(e,t)=>e?.has(t)??!1,d=e=>l(e)||0==(e=>e.size)(e),h=(e,t)=>e?.forEach(t),u=(e,t)=>e?.delete(t),p=e=>new Map(e),C=(e,t)=>e?.get(t),g=(e,t,n)=>l(n)?(u(e,t),e):e?.set(t,n),k=(e,t,n)=>(a(e,t)||e.set(t,n()),C(e,t)),f=e=>new Set(e),L=(e,t,o)=>n(o)<2?((e,t)=>e?.add(t))(s(o)?e:k(e,o[0],f),t):L(k(e,o[0],p),t,r(o)),w=e=>{const n=(o,c,...l)=>i(o,(o=>s(l)?e(o,c):t([l[0],null],(e=>n(C(o,e),c,...r(l))))));return n},v=Object.freeze,S=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((r=>{let S,z,E,I=100,M=p(),b=1;const j=f(),x=p(),[y,B,F]=(e=>{let s,r=0;const a=[],d=p();return[(t,n,o=[])=>{s??=e();const l=c(a)??""+r++;return g(d,l,[t,n,o]),L(n,l,o),l},(e,t=[],...n)=>w(h)(e,(e=>i(C(d,e),(([e])=>e(s,...t,...n)))),...t),e=>i(C(d,e),(([,t,s])=>(w(u)(t,e,...s),g(d,e),n(a)<1e3&&o(a,e),s)),(()=>[])),(e,r,o)=>i(C(d,e),(([e,,c])=>{const i=(...a)=>{const d=n(a);d==n(c)?e(s,...a,...o(a)):l(c[d])?t(r[d](...a),(e=>i(...a,e))):i(...a,c[d])};i()}))]})((()=>V)),O=p(),T=p(),W=[],m=[],q=(e,t)=>{b=0,r.transaction((()=>h(C(O,t),((t,n)=>h(t,((t,s)=>h(t,((t,o)=>l(t[e])?r.delCell(n,s,o,!0):r.setCell(n,s,o,t[e]))))))))),b=1},A=e=>{g(O,e),g(T,e),B(x,[e])},D=(e,s)=>t(((e,t)=>e.splice(0,t))(e,s??n(e)),A),G=()=>D(W,n(W)-I),H=r.addCellListener(null,null,null,((e,t,n,s,r,l)=>{if(b){i(S,(()=>{o(W,S),G(),D(m),S=void 0,E=1}));const e=k(M,t,p),a=k(e,n,p),h=k(a,s,(()=>[l,void 0]));h[1]=r,h[0]===r&&d(g(a,s))&&d(g(e,n))&&d(g(M,t))&&(S=c(W),E=1),P()}})),J=(e="")=>(l(S)&&(S=""+z++,g(O,S,M),R(S,e),M=p(),E=1),S),K=()=>{s(W)||(m.unshift(J()),q(0,S),S=c(W),E=1)},N=()=>{s(m)||(o(W,S),S=m.shift(),q(1,S),E=1)},P=()=>{E&&(B(j),E=0)},Q=e=>{const t=J(e);return P(),t},R=(e,t)=>(U(e)&&C(T,e)!==t&&(g(T,e,t),B(x,[e])),V),U=e=>a(O,e),V={setSize:e=>(I=e,G(),V),addCheckpoint:Q,setCheckpoint:R,getStore:()=>r,getCheckpointIds:()=>[[...W],S,[...m]],forEachCheckpoint:e=>{return t=e,h(T,((e,n)=>t(n,e)));var t},hasCheckpoint:U,getCheckpoint:e=>C(T,e),goBackward:()=>(K(),P(),V),goForward:()=>(N(),P(),V),goTo:t=>{const n=e(W,t)?K:e(m,t)?N:null;for(;!l(n)&&t!=S;)n();return P(),V},addCheckpointIdsListener:e=>y(e,j),addCheckpointListener:(e,t)=>y(t,x,[e]),delListener:e=>(F(e),V),clear:()=>(D(W),D(m),l(S)||A(S),S=void 0,z=0,Q(),V),destroy:()=>{r.delListener(H)},getListenerStats:()=>({})};return v(V.clear())}));export{S as createCheckpoints};
1
+ const e=(e,t)=>e.includes(t),t=(e,t)=>e.forEach(t),n=e=>e.length,r=e=>0==n(e),s=e=>e.slice(1),o=(e,t)=>e.push(t),c=e=>e.pop(),l=e=>null==e,i=(e,t,n)=>l(e)?n?.():t(e),a=(e,t)=>e?.has(t)??!1,d=e=>l(e)||0==(e=>e.size)(e),h=(e,t)=>e?.forEach(t),u=(e,t)=>e?.delete(t),p=e=>new Map(e),C=(e,t)=>e?.get(t),g=(e,t,n)=>l(n)?(u(e,t),e):e?.set(t,n),k=(e,t,n)=>(a(e,t)||g(e,t,n()),C(e,t)),f=e=>new Set(e),L=(e,t,o)=>n(o)<2?((e,t)=>e?.add(t))(r(o)?e:k(e,o[0],f),t):L(k(e,o[0],p),t,s(o)),w=e=>{const n=(o,c,...l)=>i(o,(o=>r(l)?e(o,c):t([l[0],null],(e=>n(C(o,e),c,...s(l))))));return n},v=Object.freeze,S=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((s=>{let S,z,E,I=100,M=p(),b=1;const j=f(),x=p(),[y,B,F]=(e=>{let r,s=0;const a=[],d=p();return[(t,n,o=[])=>{r??=e();const l=c(a)??""+s++;return g(d,l,[t,n,o]),L(n,l,o),l},(e,t=[],...n)=>w(h)(e,(e=>i(C(d,e),(([e])=>e(r,...t,...n)))),...t),e=>i(C(d,e),(([,t,r])=>(w(u)(t,e,...r),g(d,e),n(a)<1e3&&o(a,e),r)),(()=>[])),(e,s,o)=>i(C(d,e),(([e,,c])=>{const i=(...a)=>{const d=n(a);d==n(c)?e(r,...a,...o(a)):l(c[d])?t(s[d](...a),(e=>i(...a,e))):i(...a,c[d])};i()}))]})((()=>V)),O=p(),T=p(),W=[],m=[],q=(e,t)=>{b=0,s.transaction((()=>h(C(O,t),((t,n)=>h(t,((t,r)=>h(t,((t,o)=>l(t[e])?s.delCell(n,r,o,!0):s.setCell(n,r,o,t[e]))))))))),b=1},A=e=>{g(O,e),g(T,e),B(x,[e])},D=(e,r)=>t(((e,t)=>e.splice(0,t))(e,r??n(e)),A),G=()=>D(W,n(W)-I),H=s.addCellListener(null,null,null,((e,t,n,r,s,l)=>{if(b){i(S,(()=>{o(W,S),G(),D(m),S=void 0,E=1}));const e=k(M,t,p),a=k(e,n,p),h=k(a,r,(()=>[l,void 0]));h[1]=s,h[0]===s&&d(g(a,r))&&d(g(e,n))&&d(g(M,t))&&(S=c(W),E=1),P()}})),J=(e="")=>(l(S)&&(S=""+z++,g(O,S,M),R(S,e),M=p(),E=1),S),K=()=>{r(W)||(m.unshift(J()),q(0,S),S=c(W),E=1)},N=()=>{r(m)||(o(W,S),S=m.shift(),q(1,S),E=1)},P=()=>{E&&(B(j),E=0)},Q=e=>{const t=J(e);return P(),t},R=(e,t)=>(U(e)&&C(T,e)!==t&&(g(T,e,t),B(x,[e])),V),U=e=>a(O,e),V={setSize:e=>(I=e,G(),V),addCheckpoint:Q,setCheckpoint:R,getStore:()=>s,getCheckpointIds:()=>[[...W],S,[...m]],forEachCheckpoint:e=>{return t=e,h(T,((e,n)=>t(n,e)));var t},hasCheckpoint:U,getCheckpoint:e=>C(T,e),goBackward:()=>(K(),P(),V),goForward:()=>(N(),P(),V),goTo:t=>{const n=e(W,t)?K:e(m,t)?N:null;for(;!l(n)&&t!=S;)n();return P(),V},addCheckpointIdsListener:e=>y(e,j),addCheckpointListener:(e,t)=>y(t,x,[e]),delListener:e=>(F(e),V),clear:()=>(D(W),D(m),l(S)||A(S),S=void 0,z=0,Q(),V),destroy:()=>{s.delListener(H)},getListenerStats:()=>({})};return v(V.clear())}));export{S as createCheckpoints};
Binary file
package/lib/common.js CHANGED
@@ -1 +1 @@
1
- const o=(o,t)=>o<t?-1:1;export{o as defaultSorter};
1
+ const o=(o,t)=>o<t?-1:1,t=o=>""+o;export{o as defaultSorter,t as id};
package/lib/common.js.gz CHANGED
Binary file
@@ -30,7 +30,7 @@ const mapSet = (map, key, value) =>
30
30
  isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
31
31
  const mapEnsure = (map, key, getDefaultValue) => {
32
32
  if (!collHas(map, key)) {
33
- map.set(key, getDefaultValue());
33
+ mapSet(map, key, getDefaultValue());
34
34
  }
35
35
  return mapGet(map, key);
36
36
  };
@@ -1,3 +1,6 @@
1
+ const EMPTY_STRING = '';
2
+
1
3
  const defaultSorter = (sortKey1, sortKey2) => (sortKey1 < sortKey2 ? -1 : 1);
4
+ const id = (key) => EMPTY_STRING + key;
2
5
 
3
- export {defaultSorter};
6
+ export {defaultSorter, id};
@@ -41,7 +41,7 @@ const mapSet = (map, key, value) =>
41
41
  isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
42
42
  const mapEnsure = (map, key, getDefaultValue) => {
43
43
  if (!collHas(map, key)) {
44
- map.set(key, getDefaultValue());
44
+ mapSet(map, key, getDefaultValue());
45
45
  }
46
46
  return mapGet(map, key);
47
47
  };
@@ -46,7 +46,7 @@ const mapSet = (map, key, value) =>
46
46
  isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
47
47
  const mapEnsure = (map, key, getDefaultValue) => {
48
48
  if (!collHas(map, key)) {
49
- map.set(key, getDefaultValue());
49
+ mapSet(map, key, getDefaultValue());
50
50
  }
51
51
  return mapGet(map, key);
52
52
  };
@@ -36,7 +36,7 @@ const mapSet = (map, key, value) =>
36
36
  isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
37
37
  const mapEnsure = (map, key, getDefaultValue) => {
38
38
  if (!collHas(map, key)) {
39
- map.set(key, getDefaultValue());
39
+ mapSet(map, key, getDefaultValue());
40
40
  }
41
41
  return mapGet(map, key);
42
42
  };
@@ -256,7 +256,7 @@ const createRelationships = getCreateFunction((store) => {
256
256
  hasRelationship,
257
257
  getLocalTableId,
258
258
  getRelationship,
259
- _setRelationship,
259
+ ,
260
260
  setDefinition,
261
261
  delDefinition,
262
262
  destroy,
@@ -390,6 +390,7 @@ export type CellListener = (
390
390
  * @param cellId The Id of the Cell that was being changed.
391
391
  * @param invalidCells An array of the values of the Cell that were invalid.
392
392
  * @category Listener
393
+ * @since v1.1.0
393
394
  */
394
395
  export type InvalidCellListener = (
395
396
  store: Store,
@@ -521,6 +522,7 @@ export type CellSchema =
521
522
  * different value and then changed back.
522
523
  *
523
524
  * @category Transaction
525
+ * @since v1.2.0
524
526
  */
525
527
  export type ChangedCells = {
526
528
  [tableId: Id]: {
@@ -543,6 +545,7 @@ export type ChangedCells = {
543
545
  * change a Cell during the transaction are described.
544
546
  *
545
547
  * @category Transaction
548
+ * @since v1.2.0
546
549
  */
547
550
  export type InvalidCells = {
548
551
  [tableId: Id]: {
@@ -1710,7 +1713,7 @@ export interface Store {
1710
1713
  *
1711
1714
  * @param actions The function to be executed as a transaction.
1712
1715
  * @param doRollback An optional callback that should return `true` if you
1713
- * want to rollback the transaction at the end.
1716
+ * want to rollback the transaction at the end. Since v1.2.0.
1714
1717
  * @returns Whatever value the provided transaction function returns.
1715
1718
  * @example
1716
1719
  * This example makes changes to two Cells, first outside, and secondly
@@ -1846,6 +1849,7 @@ export interface Store {
1846
1849
  * // -> 'Fido changed'
1847
1850
  * ```
1848
1851
  * @category Transaction
1852
+ * @since v1.3.0
1849
1853
  */
1850
1854
  startTransaction(): Store;
1851
1855
 
@@ -1923,6 +1927,7 @@ export interface Store {
1923
1927
  * // -> {pets: {fido: {species: 'dog', color: 'brown'}}}
1924
1928
  * ```
1925
1929
  * @category Transaction
1930
+ * @since v1.3.0
1926
1931
  */
1927
1932
  finishTransaction(
1928
1933
  doRollback?: (
@@ -2897,6 +2902,7 @@ export interface Store {
2897
2902
  * store.delListener(listenerId);
2898
2903
  * ```
2899
2904
  * @category Listener
2905
+ * @since v1.1.0
2900
2906
  */
2901
2907
  addInvalidCellListener(
2902
2908
  tableId: IdOrNull,
@@ -2971,6 +2977,7 @@ export interface Store {
2971
2977
  * store.delListener(listenerId).delListener(listenerId2);
2972
2978
  * ```
2973
2979
  * @category Listener
2980
+ * @since v1.3.0
2974
2981
  */
2975
2982
  addWillFinishTransactionListener(listener: TransactionListener): Id;
2976
2983
 
@@ -3040,6 +3047,7 @@ export interface Store {
3040
3047
  * store.delListener(listenerId).delListener(listenerId2);
3041
3048
  * ```
3042
3049
  * @category Listener
3050
+ * @since v1.3.0
3043
3051
  */
3044
3052
  addDidFinishTransactionListener(listener: TransactionListener): Id;
3045
3053
 
@@ -11,6 +11,7 @@ const DEFAULT = 'default';
11
11
  const arrayPair = (value) => [value, value];
12
12
  const arrayHas = (array, value) => array.includes(value);
13
13
  const arrayForEach = (array, cb) => array.forEach(cb);
14
+ const arrayMap = (array, cb) => array.map(cb);
14
15
  const arrayLength = (array) => array.length;
15
16
  const arrayIsEmpty = (array) => arrayLength(array) == 0;
16
17
  const arrayReduce = (array, cb, initial) => array.reduce(cb, initial);
@@ -65,7 +66,7 @@ const mapSet = (map, key, value) =>
65
66
  isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
66
67
  const mapEnsure = (map, key, getDefaultValue) => {
67
68
  if (!collHas(map, key)) {
68
- map.set(key, getDefaultValue());
69
+ mapSet(map, key, getDefaultValue());
69
70
  }
70
71
  return mapGet(map, key);
71
72
  };
@@ -176,15 +177,17 @@ const getListenerFunctions = (getThing) => {
176
177
  return [addListener, callListeners, delListener, callListener];
177
178
  };
178
179
 
180
+ const id = (key) => EMPTY_STRING + key;
181
+
179
182
  const transformMap = (map, toBeLikeObject, setId, delId = mapSet) => {
180
183
  const idsToDelete = arrayFilter(
181
184
  mapKeys(map),
182
- (id) => !objHas(toBeLikeObject, id),
185
+ (id2) => !objHas(toBeLikeObject, id2),
183
186
  );
184
- arrayForEach(objIds(toBeLikeObject), (id) =>
185
- setId(map, id, toBeLikeObject[id]),
187
+ arrayForEach(objIds(toBeLikeObject), (id2) =>
188
+ setId(map, id2, toBeLikeObject[id2]),
186
189
  );
187
- arrayForEach(idsToDelete, (id) => delId(map, id));
190
+ arrayForEach(idsToDelete, (id2) => delId(map, id2));
188
191
  return map;
189
192
  };
190
193
  const getCellType = (cell) => {
@@ -198,15 +201,15 @@ const validate = (obj, validateChild, onInvalidObj) => {
198
201
  onInvalidObj?.();
199
202
  return false;
200
203
  }
201
- objForEach(obj, (child, id) => {
202
- if (!validateChild(child, id)) {
203
- objDel(obj, id);
204
+ objForEach(obj, (child, id2) => {
205
+ if (!validateChild(child, id2)) {
206
+ objDel(obj, id2);
204
207
  }
205
208
  });
206
209
  return !objIsEmpty(obj);
207
210
  };
208
- const idsChanged = (ids, id, added) =>
209
- mapSet(ids, id, mapGet(ids, id) == -added ? void 0 : added);
211
+ const idsChanged = (ids, id2, added) =>
212
+ mapSet(ids, id2, mapGet(ids, id2) == -added ? void 0 : added);
210
213
  const createStore = () => {
211
214
  let hasSchema;
212
215
  let cellsTouched;
@@ -235,7 +238,7 @@ const createStore = () => {
235
238
  validate(schema, (tableSchema) =>
236
239
  validate(tableSchema, (cellSchema) => {
237
240
  if (
238
- !validate(cellSchema, (_child, id) => arrayHas([TYPE, DEFAULT], id))
241
+ !validate(cellSchema, (_child, id2) => arrayHas([TYPE, DEFAULT], id2))
239
242
  ) {
240
243
  return false;
241
244
  }
@@ -381,7 +384,7 @@ const createStore = () => {
381
384
  ),
382
385
  );
383
386
  const getNewRowId = (tableMap) => {
384
- const rowId = '' + nextRowId++;
387
+ const rowId = EMPTY_STRING + nextRowId++;
385
388
  if (!collHas(tableMap, rowId)) {
386
389
  return rowId;
387
390
  }
@@ -532,26 +535,28 @@ const createStore = () => {
532
535
  }
533
536
  }
534
537
  };
535
- const fluentTransaction = (actions) => {
536
- transaction(actions);
538
+ const fluentTransaction = (actions, ...args) => {
539
+ transaction(() => actions(...arrayMap(args, id)));
537
540
  return store;
538
541
  };
539
542
  const getTables = () =>
540
543
  mapToObj(tablesMap, (table) => mapToObj(table, mapToObj));
541
544
  const getTableIds = () => mapKeys(tablesMap);
542
- const getTable = (tableId) => mapToObj(mapGet(tablesMap, tableId), mapToObj);
543
- const getRowIds = (tableId) => mapKeys(mapGet(tablesMap, tableId));
545
+ const getTable = (tableId) =>
546
+ mapToObj(mapGet(tablesMap, id(tableId)), mapToObj);
547
+ const getRowIds = (tableId) => mapKeys(mapGet(tablesMap, id(tableId)));
544
548
  const getRow = (tableId, rowId) =>
545
- mapToObj(mapGet(mapGet(tablesMap, tableId), rowId));
549
+ mapToObj(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)));
546
550
  const getCellIds = (tableId, rowId) =>
547
- mapKeys(mapGet(mapGet(tablesMap, tableId), rowId));
551
+ mapKeys(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)));
548
552
  const getCell = (tableId, rowId, cellId) =>
549
- mapGet(mapGet(mapGet(tablesMap, tableId), rowId), cellId);
553
+ mapGet(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), id(cellId));
550
554
  const hasTables = () => !collIsEmpty(tablesMap);
551
- const hasTable = (tableId) => collHas(tablesMap, tableId);
552
- const hasRow = (tableId, rowId) => collHas(mapGet(tablesMap, tableId), rowId);
555
+ const hasTable = (tableId) => collHas(tablesMap, id(tableId));
556
+ const hasRow = (tableId, rowId) =>
557
+ collHas(mapGet(tablesMap, id(tableId)), id(rowId));
553
558
  const hasCell = (tableId, rowId, cellId) =>
554
- collHas(mapGet(mapGet(tablesMap, tableId), rowId), cellId);
559
+ collHas(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), id(cellId));
555
560
  const getJson = () => jsonString(tablesMap);
556
561
  const getSchemaJson = () => jsonString(schemaMap);
557
562
  const setTables = (tables) =>
@@ -559,19 +564,30 @@ const createStore = () => {
559
564
  validateTables(tables) ? setValidTables(tables) : 0,
560
565
  );
561
566
  const setTable = (tableId, table) =>
562
- fluentTransaction(() =>
563
- validateTable(table, tableId) ? setValidTable(tableId, table) : 0,
567
+ fluentTransaction(
568
+ (tableId2) =>
569
+ validateTable(table, tableId2) ? setValidTable(tableId2, table) : 0,
570
+ tableId,
564
571
  );
565
572
  const setRow = (tableId, rowId, row) =>
566
- fluentTransaction(() =>
567
- validateRow(tableId, rowId, row)
568
- ? setValidRow(tableId, getOrCreateTable(tableId), rowId, row)
569
- : 0,
573
+ fluentTransaction(
574
+ (tableId2, rowId2) =>
575
+ validateRow(id(tableId2), id(rowId2), row)
576
+ ? setValidRow(
577
+ id(tableId2),
578
+ getOrCreateTable(id(tableId2)),
579
+ id(rowId2),
580
+ row,
581
+ )
582
+ : 0,
583
+ tableId,
584
+ rowId,
570
585
  );
571
586
  const addRow = (tableId, row) =>
572
587
  transaction(() => {
573
588
  let rowId = void 0;
574
589
  if (validateRow(tableId, rowId, row)) {
590
+ tableId = id(tableId);
575
591
  setValidRow(
576
592
  tableId,
577
593
  getOrCreateTable(tableId),
@@ -582,32 +598,40 @@ const createStore = () => {
582
598
  return rowId;
583
599
  });
584
600
  const setPartialRow = (tableId, rowId, partialRow) =>
585
- fluentTransaction(() => {
586
- if (validateRow(tableId, rowId, partialRow, 1)) {
587
- const table = getOrCreateTable(tableId);
588
- objForEach(partialRow, (cell, cellId) =>
589
- setCellIntoDefaultRow(tableId, table, rowId, cellId, cell),
590
- );
591
- }
592
- });
601
+ fluentTransaction(
602
+ (tableId2, rowId2) => {
603
+ if (validateRow(tableId2, rowId2, partialRow, 1)) {
604
+ const table = getOrCreateTable(tableId2);
605
+ objForEach(partialRow, (cell, cellId) =>
606
+ setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),
607
+ );
608
+ }
609
+ },
610
+ tableId,
611
+ rowId,
612
+ );
593
613
  const setCell = (tableId, rowId, cellId, cell) =>
594
- fluentTransaction(() =>
595
- ifNotUndefined(
596
- getValidatedCell(
597
- tableId,
598
- rowId,
599
- cellId,
600
- isFunction(cell) ? cell(getCell(tableId, rowId, cellId)) : cell,
601
- ),
602
- (validCell) =>
603
- setCellIntoDefaultRow(
604
- tableId,
605
- getOrCreateTable(tableId),
606
- rowId,
607
- cellId,
608
- validCell,
614
+ fluentTransaction(
615
+ (tableId2, rowId2, cellId2) =>
616
+ ifNotUndefined(
617
+ getValidatedCell(
618
+ tableId2,
619
+ rowId2,
620
+ cellId2,
621
+ isFunction(cell) ? cell(getCell(tableId2, rowId2, cellId2)) : cell,
609
622
  ),
610
- ),
623
+ (validCell) =>
624
+ setCellIntoDefaultRow(
625
+ tableId2,
626
+ getOrCreateTable(tableId2),
627
+ rowId2,
628
+ cellId2,
629
+ validCell,
630
+ ),
631
+ ),
632
+ tableId,
633
+ rowId,
634
+ cellId,
611
635
  );
612
636
  const setJson = (json) => {
613
637
  try {
@@ -628,24 +652,42 @@ const createStore = () => {
628
652
  });
629
653
  const delTables = () => fluentTransaction(() => setValidTables({}));
630
654
  const delTable = (tableId) =>
631
- fluentTransaction(() =>
632
- collHas(tablesMap, tableId) ? delValidTable(tableId) : 0,
655
+ fluentTransaction(
656
+ (tableId2) =>
657
+ collHas(tablesMap, tableId2) ? delValidTable(tableId2) : 0,
658
+ tableId,
633
659
  );
634
660
  const delRow = (tableId, rowId) =>
635
- fluentTransaction(() =>
636
- ifNotUndefined(mapGet(tablesMap, tableId), (tableMap) =>
637
- collHas(tableMap, rowId) ? delValidRow(tableId, tableMap, rowId) : 0,
638
- ),
661
+ fluentTransaction(
662
+ (tableId2, rowId2) =>
663
+ ifNotUndefined(mapGet(tablesMap, tableId2), (tableMap) =>
664
+ collHas(tableMap, rowId2)
665
+ ? delValidRow(tableId2, tableMap, rowId2)
666
+ : 0,
667
+ ),
668
+ tableId,
669
+ rowId,
639
670
  );
640
671
  const delCell = (tableId, rowId, cellId, forceDel) =>
641
- fluentTransaction(() =>
642
- ifNotUndefined(mapGet(tablesMap, tableId), (tableMap) =>
643
- ifNotUndefined(mapGet(tableMap, rowId), (rowMap) =>
644
- collHas(rowMap, cellId)
645
- ? delValidCell(tableId, tableMap, rowId, rowMap, cellId, forceDel)
646
- : 0,
672
+ fluentTransaction(
673
+ (tableId2, rowId2, cellId2) =>
674
+ ifNotUndefined(mapGet(tablesMap, tableId2), (tableMap) =>
675
+ ifNotUndefined(mapGet(tableMap, rowId2), (rowMap) =>
676
+ collHas(rowMap, cellId2)
677
+ ? delValidCell(
678
+ tableId2,
679
+ tableMap,
680
+ rowId2,
681
+ rowMap,
682
+ cellId2,
683
+ forceDel,
684
+ )
685
+ : 0,
686
+ ),
647
687
  ),
648
- ),
688
+ tableId,
689
+ rowId,
690
+ cellId,
649
691
  );
650
692
  const delSchema = () =>
651
693
  fluentTransaction(() => {
@@ -741,11 +783,11 @@ const createStore = () => {
741
783
  ),
742
784
  );
743
785
  const forEachRow = (tableId, rowCallback) =>
744
- collForEach(mapGet(tablesMap, tableId), (rowMap, rowId) =>
786
+ collForEach(mapGet(tablesMap, id(tableId)), (rowMap, rowId) =>
745
787
  rowCallback(rowId, (cellCallback) => mapForEach(rowMap, cellCallback)),
746
788
  );
747
789
  const forEachCell = (tableId, rowId, cellCallback) =>
748
- mapForEach(mapGet(mapGet(tablesMap, tableId), rowId), cellCallback);
790
+ mapForEach(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), cellCallback);
749
791
  const addTablesListener = (listener, mutator) =>
750
792
  addListener(listener, tablesListeners[mutator ? 1 : 0]);
751
793
  const addTableIdsListener = (listener, mutator) =>