tinybase 0.9.2 → 0.9.3

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.
@@ -24,7 +24,7 @@ import {Id, IdOrNull, Ids, Json} from './common.d';
24
24
  * individual Table objects, keyed by their Id.
25
25
  *
26
26
  * @example
27
- * ```tsx
27
+ * ```js
28
28
  * const tables: Tables = {
29
29
  * pets: {
30
30
  * fido: {species: 'dog', color: 'brown'},
@@ -49,7 +49,7 @@ export type Tables = {[tableId: Id]: Table};
49
49
  * Id.
50
50
  *
51
51
  * @example
52
- * ```tsx
52
+ * ```js
53
53
  * const table: Table = {
54
54
  * fido: {species: 'dog', color: 'brown'},
55
55
  * felix: {species: 'cat'},
@@ -67,7 +67,7 @@ export type Table = {[rowId: Id]: Row};
67
67
  * object containing individual Cell objects, keyed by their Id.
68
68
  *
69
69
  * @example
70
- * ```tsx
70
+ * ```js
71
71
  * const row: Row = {species: 'dog', color: 'brown'};
72
72
  * ```
73
73
  * @category Store
@@ -82,7 +82,7 @@ export type Row = {[cellId: Id]: Cell};
82
82
  * number, or boolean.
83
83
  *
84
84
  * @example
85
- * ```tsx
85
+ * ```js
86
86
  * const cell: Cell = 'dog';
87
87
  * ```
88
88
  * @category Store
@@ -97,6 +97,9 @@ export type Cell = string | number | boolean;
97
97
  * can do something based on every Table in the Store. See that method for
98
98
  * specific examples.
99
99
  *
100
+ * @param tableId The Id of the Table that the callback can operate on.
101
+ * @param forEachRow A function that will let you iterate over the Row objects
102
+ * in this Table.
100
103
  * @category Callback
101
104
  */
102
105
  export type TableCallback = (
@@ -112,6 +115,9 @@ export type TableCallback = (
112
115
  * do something based on every Row in a Table. See that method for specific
113
116
  * examples.
114
117
  *
118
+ * @param rowId The Id of the Row that the callback can operate on.
119
+ * @param forEachRow A function that will let you iterate over the Cell values
120
+ * in this Row.
115
121
  * @category Callback
116
122
  */
117
123
  export type RowCallback = (
@@ -127,6 +133,8 @@ export type RowCallback = (
127
133
  * do something based on every Cell in a Row. See that method for specific
128
134
  * examples.
129
135
  *
136
+ * @param cellId The Id of the Cell that the callback can operate on.
137
+ * @param cell The value of the Cell.
130
138
  * @category Callback
131
139
  */
132
140
  export type CellCallback = (cellId: Id, cell: Cell) => void;
@@ -139,6 +147,7 @@ export type CellCallback = (cellId: Id, cell: Cell) => void;
139
147
  * new one, such as when incrementing a number. See that method for specific
140
148
  * examples.
141
149
  *
150
+ * @param cell The current value of the Cell to map to a new value.
142
151
  * @category Callback
143
152
  */
144
153
  export type MapCell = (cell: Cell | undefined) => Cell;
@@ -151,6 +160,7 @@ export type MapCell = (cell: Cell | undefined) => Cell;
151
160
  * setMetricDefinition method of a Metrics object, or the setIndexDefinition
152
161
  * method of an Indexes object. See those methods for specific examples.
153
162
  *
163
+ * @param cellId The Id of the Cell to fetch the value for.
154
164
  * @category Callback
155
165
  */
156
166
  export type GetCell = (cellId: Id) => Cell | undefined;
@@ -170,6 +180,9 @@ export type GetCell = (cellId: Id) => Cell | undefined;
170
180
  * callListener method rather than due to a real change in the Store), the
171
181
  * GetCellChange function will not be present.
172
182
  *
183
+ * @param store A reference to the Store that changed.
184
+ * @param getCellChange A function that returns information about any Cell's
185
+ * changes.
173
186
  * @category Listener
174
187
  */
175
188
  export type TablesListener = (
@@ -186,6 +199,7 @@ export type TablesListener = (
186
199
  *
187
200
  * When called, a TableIdsListener is given a reference to the Store.
188
201
  *
202
+ * @param store A reference to the Store that changed.
189
203
  * @category Listener
190
204
  */
191
205
  export type TableIdsListener = (store: Store) => void;
@@ -205,6 +219,10 @@ export type TableIdsListener = (store: Store) => void;
205
219
  * callListener method rather than due to a real change in the Store), the
206
220
  * GetCellChange function will not be present.
207
221
  *
222
+ * @param store A reference to the Store that changed.
223
+ * @param tableId The Id of the Table that changed.
224
+ * @param getCellChange A function that returns information about any Cell's
225
+ * changes.
208
226
  * @category Listener
209
227
  */
210
228
  export type TableListener = (
@@ -223,6 +241,8 @@ export type TableListener = (
223
241
  * When called, a RowIdsListener is given a reference to the Store, and the Id
224
242
  * of the Table whose Row Ids changed.
225
243
  *
244
+ * @param store A reference to the Store that changed.
245
+ * @param tableId The Id of the Table that changed.
226
246
  * @category Listener
227
247
  */
228
248
  export type RowIdsListener = (store: Store, tableId: Id) => void;
@@ -243,6 +263,11 @@ export type RowIdsListener = (store: Store, tableId: Id) => void;
243
263
  * callListener method rather than due to a real change in the Store), the
244
264
  * GetCellChange function will not be present.
245
265
  *
266
+ * @param store A reference to the Store that changed.
267
+ * @param tableId The Id of the Table that changed.
268
+ * @param rowId The Id of the Row that changed.
269
+ * @param getCellChange A function that returns information about any Cell's
270
+ * changes.
246
271
  * @category Listener
247
272
  */
248
273
  export type RowListener = (
@@ -262,6 +287,10 @@ export type RowListener = (
262
287
  * When called, a CellIdsListener is given a reference to the Store, the Id of
263
288
  * the Table that changed, and the Id of the Row whose Cell Ids changed.
264
289
  *
290
+ * @param store A reference to the Store that changed.
291
+ * @param tableId The Id of the Table that changed.
292
+ * @param rowId The Id of the Row that changed.
293
+ * changes.
265
294
  * @category Listener
266
295
  */
267
296
  export type CellIdsListener = (store: Store, tableId: Id, rowId: Id) => void;
@@ -284,6 +313,14 @@ export type CellIdsListener = (store: Store, tableId: Id, rowId: Id) => void;
284
313
  * GetCellChange function will not be present and the new and old values of the
285
314
  * Cell will be the same.
286
315
  *
316
+ * @param store A reference to the Store that changed.
317
+ * @param tableId The Id of the Table that changed.
318
+ * @param rowId The Id of the Row that changed.
319
+ * @param cellId The Id of the Cell that changed.
320
+ * @param newCell The new value of the Cell that changed.
321
+ * @param oldCell The old value of the Cell that changed.
322
+ * @param getCellChange A function that returns information about any Cell's
323
+ * changes.
287
324
  * @category Listener
288
325
  */
289
326
  export type CellListener = (
@@ -297,21 +334,37 @@ export type CellListener = (
297
334
  ) => void;
298
335
 
299
336
  /**
300
- * The GetCellChange type describes a function that returns information about a
301
- * Cell's changes during a transaction.
337
+ * The GetCellChange type describes a function that returns information about
338
+ * any Cell's changes during a transaction.
302
339
  *
303
340
  * A GetCellChange function is provided to every listener when called due the
304
341
  * Store changing. The listener can then fetch the previous value of a Cell
305
342
  * before the current transaction, the new value after it, and a convenience
306
343
  * flag that indicates that the value has changed.
307
344
  *
345
+ * @param tableId The Id of the Table to inspect.
346
+ * @param rowId The Id of the Row to inspect.
347
+ * @param cellId The Id of the Cell to inspect.
348
+ * @returns A CellChange array containing information about the Cell's changes.
308
349
  * @category Listener
309
350
  */
310
- export type GetCellChange = (
311
- tableId: Id,
312
- rowId: Id,
313
- cellId: Id,
314
- ) => [changed: boolean, oldCell: Cell | undefined, newCell: Cell | undefined];
351
+ export type GetCellChange = (tableId: Id, rowId: Id, cellId: Id) => CellChange;
352
+
353
+ /**
354
+ * The CellChange type describes a Cell's changes during a transaction.
355
+ *
356
+ * This is returned by the GetCellChange function that is provided to every
357
+ * listener when called. This array contains the previous value of a Cell
358
+ * before the current transaction, the new value after it, and a convenience
359
+ * flag that indicates that the value has changed.
360
+ *
361
+ * @category Listener
362
+ */
363
+ export type CellChange = [
364
+ changed: boolean,
365
+ oldCell: Cell | undefined,
366
+ newCell: Cell | undefined,
367
+ ];
315
368
 
316
369
  /**
317
370
  * The Schema type describes the structure of a Store in terms of valid Table
@@ -326,7 +379,7 @@ export type GetCellChange = (
326
379
  * which each Row may contain a string `species` Cell, and is guaranteed to
327
380
  * contain a boolean `sold` Cell that defaults to `false`.
328
381
  *
329
- *```tsx
382
+ *```js
330
383
  * const schema: Schema = {
331
384
  * pets: {
332
385
  * species: {type: 'string'},
@@ -361,7 +414,7 @@ export type Schema = {
361
414
  * When applied to a Store, this CellSchema ensures a boolean Cell is always
362
415
  * present, and defaults it to `false`.
363
416
  *
364
- *```tsx
417
+ *```js
365
418
  * const requiredBoolean: CellSchema = {type: 'boolean', default: false};
366
419
  * ```
367
420
  * @category Schema
@@ -392,12 +445,33 @@ export type CellSchema =
392
445
  * @category Development
393
446
  */
394
447
  export type StoreListenerStats = {
448
+ /**
449
+ * The number of TablesListeners registered with the Store.
450
+ */
395
451
  tables?: number;
452
+ /**
453
+ * The number of TableIdsListeners registered with the Store.
454
+ */
396
455
  tableIds?: number;
456
+ /**
457
+ * The number of TableListeners registered with the Store.
458
+ */
397
459
  table?: number;
460
+ /**
461
+ * The number of RowIdsListeners registered with the Store.
462
+ */
398
463
  rowIds?: number;
464
+ /**
465
+ * The number of RowListeners registered with the Store.
466
+ */
399
467
  row?: number;
468
+ /**
469
+ * The number of CellIdsListeners registered with the Store.
470
+ */
400
471
  cellIds?: number;
472
+ /**
473
+ * The number of CellListeners registered with the Store.
474
+ */
401
475
  cell?: number;
402
476
  };
403
477
 
@@ -467,10 +541,10 @@ export type StoreListenerStats = {
467
541
  * |Cell Ids|getCellIds|-|-|addCellIdsListener|
468
542
  * |Cell|getCell|setCell|delCell|addCellListener|
469
543
  *
470
- * Additionally, there are two extra methods to manipulate a Row. The addRow
471
- * method is like the setRow method but automatically assigns it a new unique
472
- * Id. And the setPartialRow method lets you update multiple Cell values in a
473
- * Row without affecting the others.
544
+ * Additionally, there are two extra methods to manipulate Row objects. The
545
+ * addRow method is like the setRow method but automatically assigns it a new
546
+ * unique Id. And the setPartialRow method lets you update multiple Cell values
547
+ * in a Row without affecting the others.
474
548
  *
475
549
  * The transaction method is used to wrap multiple changes to the Store so that
476
550
  * the relevant listeners only fire once.
@@ -521,7 +595,7 @@ export type StoreListenerStats = {
521
595
  * This example shows a very simple lifecycle of a Store: from creation, to
522
596
  * adding and getting some data, and then registering and removing a listener.
523
597
  *
524
- * ```tsx
598
+ * ```js
525
599
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
526
600
  * console.log(store.getRow('pets', 'fido'));
527
601
  * // -> {species: 'dog'}
@@ -539,6 +613,7 @@ export type StoreListenerStats = {
539
613
  *
540
614
  * store.delListener(listenerId);
541
615
  * ```
616
+ * @category Store
542
617
  */
543
618
  export interface Store {
544
619
  /**
@@ -553,7 +628,7 @@ export interface Store {
553
628
  * @example
554
629
  * This example retrieves the data in a Store.
555
630
  *
556
- * ```tsx
631
+ * ```js
557
632
  * const store = createStore().setTables({
558
633
  * pets: {fido: {species: 'dog'}},
559
634
  * species: {dog: {price: 5}},
@@ -565,7 +640,7 @@ export interface Store {
565
640
  * This example retrieves the Tables of an empty Store, returning an empty
566
641
  * object.
567
642
  *
568
- * ```tsx
643
+ * ```js
569
644
  * const store = createStore();
570
645
  * console.log(store.getTables());
571
646
  * // -> {}
@@ -590,7 +665,7 @@ export interface Store {
590
665
  * @example
591
666
  * This example retrieves the Table Ids in a Store.
592
667
  *
593
- * ```tsx
668
+ * ```js
594
669
  * const store = createStore().setTables({
595
670
  * pets: {fido: {species: 'dog'}},
596
671
  * species: {dog: {price: 5}},
@@ -602,7 +677,7 @@ export interface Store {
602
677
  * This example retrieves the Table Ids of an empty Store, returning an empty
603
678
  * array.
604
679
  *
605
- * ```tsx
680
+ * ```js
606
681
  * const store = createStore();
607
682
  * console.log(store.getTableIds());
608
683
  * // -> []
@@ -624,7 +699,7 @@ export interface Store {
624
699
  * @example
625
700
  * This example retrieves the data in a single Table.
626
701
  *
627
- * ```tsx
702
+ * ```js
628
703
  * const store = createStore().setTables({
629
704
  * pets: {fido: {species: 'dog'}},
630
705
  * species: {dog: {price: 5}},
@@ -636,7 +711,7 @@ export interface Store {
636
711
  * This example retrieves a Table that does not exist, returning an empty
637
712
  * object.
638
713
  *
639
- * ```tsx
714
+ * ```js
640
715
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
641
716
  * console.log(store.getTable('employees'));
642
717
  * // -> {}
@@ -658,7 +733,7 @@ export interface Store {
658
733
  * @example
659
734
  * This example retrieves the Row Ids in a Table.
660
735
  *
661
- * ```tsx
736
+ * ```js
662
737
  * const store = createStore().setTables({
663
738
  * pets: {
664
739
  * fido: {species: 'dog'},
@@ -672,7 +747,7 @@ export interface Store {
672
747
  * This example retrieves the Row Ids of a Table that does not exist,
673
748
  * returning an empty array.
674
749
  *
675
- * ```tsx
750
+ * ```js
676
751
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
677
752
  * console.log(store.getRowIds('employees'));
678
753
  * // -> []
@@ -695,7 +770,7 @@ export interface Store {
695
770
  * @example
696
771
  * This example retrieves the data in a single Row.
697
772
  *
698
- * ```tsx
773
+ * ```js
699
774
  * const store = createStore().setTables({
700
775
  * pets: {
701
776
  * fido: {species: 'dog'},
@@ -709,7 +784,7 @@ export interface Store {
709
784
  * This example retrieves a Row that does not exist, returning an empty
710
785
  * object.
711
786
  *
712
- * ```tsx
787
+ * ```js
713
788
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
714
789
  * console.log(store.getRow('pets', 'felix'));
715
790
  * // -> {}
@@ -733,7 +808,7 @@ export interface Store {
733
808
  * @example
734
809
  * This example retrieves the Cell Ids in a Row.
735
810
  *
736
- * ```tsx
811
+ * ```js
737
812
  * const store = createStore().setTables({
738
813
  * pets: {
739
814
  * fido: {species: 'dog', color: 'brown'},
@@ -746,7 +821,7 @@ export interface Store {
746
821
  * This example retrieves the Cell Ids of a Cell that does not exist,
747
822
  * returning an empty array.
748
823
  *
749
- * ```tsx
824
+ * ```js
750
825
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
751
826
  * console.log(store.getCellIds('pets', 'felix'));
752
827
  * // -> []
@@ -770,7 +845,7 @@ export interface Store {
770
845
  * @example
771
846
  * This example retrieves a single Cell.
772
847
  *
773
- * ```tsx
848
+ * ```js
774
849
  * const store = createStore().setTables({
775
850
  * pets: {fido: {species: 'dog', color: 'brown'}},
776
851
  * });
@@ -780,7 +855,7 @@ export interface Store {
780
855
  * @example
781
856
  * This example retrieves a Cell that does not exist, returning `undefined`.
782
857
  *
783
- * ```tsx
858
+ * ```js
784
859
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
785
860
  * console.log(store.getCell('pets', 'fido', 'color'));
786
861
  * // -> undefined
@@ -798,7 +873,7 @@ export interface Store {
798
873
  * @example
799
874
  * This example shows two simple Table existence checks.
800
875
  *
801
- * ```tsx
876
+ * ```js
802
877
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
803
878
  * console.log(store.hasTable('pets'));
804
879
  * // -> true
@@ -819,7 +894,7 @@ export interface Store {
819
894
  * @example
820
895
  * This example shows two simple Row existence checks.
821
896
  *
822
- * ```tsx
897
+ * ```js
823
898
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
824
899
  * console.log(store.hasRow('pets', 'fido'));
825
900
  * // -> true
@@ -841,7 +916,7 @@ export interface Store {
841
916
  * @example
842
917
  * This example shows two simple Cell existence checks.
843
918
  *
844
- * ```tsx
919
+ * ```js
845
920
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
846
921
  * console.log(store.hasCell('pets', 'fido', 'species'));
847
922
  * // -> true
@@ -860,7 +935,7 @@ export interface Store {
860
935
  * @example
861
936
  * This example serializes the contents of a Store.
862
937
  *
863
- * ```tsx
938
+ * ```js
864
939
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
865
940
  * console.log(store.getJson());
866
941
  * // -> '{"pets":{"fido":{"species":"dog"}}}'
@@ -868,7 +943,7 @@ export interface Store {
868
943
  * @example
869
944
  * This example serializes the contents of an empty Store.
870
945
  *
871
- * ```tsx
946
+ * ```js
872
947
  * const store = createStore();
873
948
  * console.log(store.getJson());
874
949
  * // -> '{}'
@@ -889,7 +964,7 @@ export interface Store {
889
964
  * @example
890
965
  * This example serializes the Schema of a Store.
891
966
  *
892
- * ```tsx
967
+ * ```js
893
968
  * const store = createStore().setSchema({
894
969
  * pets: {
895
970
  * species: {type: 'string'},
@@ -902,7 +977,7 @@ export interface Store {
902
977
  * @example
903
978
  * This example serializes the Schema of an empty Store.
904
979
  *
905
- * ```tsx
980
+ * ```js
906
981
  * const store = createStore();
907
982
  * console.log(store.getSchemaJson());
908
983
  * // -> '{}'
@@ -932,7 +1007,7 @@ export interface Store {
932
1007
  * @example
933
1008
  * This example sets the data of a Store.
934
1009
  *
935
- * ```tsx
1010
+ * ```js
936
1011
  * const store = createStore().setTables({
937
1012
  * pets: {fido: {species: 'dog'}},
938
1013
  * species: {dog: {price: 5}},
@@ -944,7 +1019,7 @@ export interface Store {
944
1019
  * This example attempts to set the data of an existing Store with partly
945
1020
  * invalid, and then completely invalid, Tables objects.
946
1021
  *
947
- * ```tsx
1022
+ * ```js
948
1023
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
949
1024
  *
950
1025
  * store.setTables({pets: {felix: {species: 'cat', bug: []}}});
@@ -983,7 +1058,7 @@ export interface Store {
983
1058
  * @example
984
1059
  * This example sets the data of a single Table.
985
1060
  *
986
- * ```tsx
1061
+ * ```js
987
1062
  * const store = createStore().setTable('pets', {
988
1063
  * fido: {species: 'dog'},
989
1064
  * felix: {species: 'cat'},
@@ -995,7 +1070,7 @@ export interface Store {
995
1070
  * This example attempts to set the data of an existing Store with partly
996
1071
  * invalid, and then completely invalid, Table objects.
997
1072
  *
998
- * ```tsx
1073
+ * ```js
999
1074
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1000
1075
  *
1001
1076
  * store.setTable('pets', {felix: {species: 'cat', bug: []}});
@@ -1036,7 +1111,7 @@ export interface Store {
1036
1111
  * @example
1037
1112
  * This example sets the data of a single Row.
1038
1113
  *
1039
- * ```tsx
1114
+ * ```js
1040
1115
  * const store = createStore().setRow('pets', 'fido', {species: 'dog'});
1041
1116
  * console.log(store.getTables());
1042
1117
  * // -> {pets: {fido: {species: 'dog'}}}
@@ -1045,7 +1120,7 @@ export interface Store {
1045
1120
  * This example attempts to set the data of an existing Store with partly
1046
1121
  * invalid, and then completely invalid, Row objects.
1047
1122
  *
1048
- * ```tsx
1123
+ * ```js
1049
1124
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1050
1125
  *
1051
1126
  * store.setRow('pets', 'fido', {color: 'brown', bug: []});
@@ -1085,7 +1160,7 @@ export interface Store {
1085
1160
  * @example
1086
1161
  * This example adds a single Row.
1087
1162
  *
1088
- * ```tsx
1163
+ * ```js
1089
1164
  * const store = createStore();
1090
1165
  * console.log(store.addRow('pets', {species: 'dog'}));
1091
1166
  * // -> '0'
@@ -1096,7 +1171,7 @@ export interface Store {
1096
1171
  * This example attempts to add Rows to an existing Store with partly invalid,
1097
1172
  * and then completely invalid, Row objects.
1098
1173
  *
1099
- * ```tsx
1174
+ * ```js
1100
1175
  * const store = createStore().setTables({pets: {'0': {species: 'dog'}}});
1101
1176
  *
1102
1177
  * console.log(store.addRow('pets', {species: 'cat', bug: []}));
@@ -1138,7 +1213,7 @@ export interface Store {
1138
1213
  * @example
1139
1214
  * This example sets some of the data of a single Row.
1140
1215
  *
1141
- * ```tsx
1216
+ * ```js
1142
1217
  * const store = createStore().setTables({
1143
1218
  * pets: {fido: {species: 'dog', color: 'brown'}},
1144
1219
  * });
@@ -1150,7 +1225,7 @@ export interface Store {
1150
1225
  * This example attempts to set some of the data of an existing Store with
1151
1226
  * partly invalid, and then completely invalid, Row objects.
1152
1227
  *
1153
- * ```tsx
1228
+ * ```js
1154
1229
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1155
1230
  *
1156
1231
  * store.setPartialRow('pets', 'fido', {color: 'brown', bug: []});
@@ -1192,7 +1267,7 @@ export interface Store {
1192
1267
  * @example
1193
1268
  * This example sets the value of a single Cell.
1194
1269
  *
1195
- * ```tsx
1270
+ * ```js
1196
1271
  * const store = createStore().setCell('pets', 'fido', 'species', 'dog');
1197
1272
  * console.log(store.getTables());
1198
1273
  * // -> {pets: {fido: {species: 'dog'}}}
@@ -1200,7 +1275,7 @@ export interface Store {
1200
1275
  * @example
1201
1276
  * This example sets the data of a single Cell by mapping the existing value.
1202
1277
  *
1203
- * ```tsx
1278
+ * ```js
1204
1279
  * const increment = (cell) => cell + 1;
1205
1280
  * const store = createStore().setTables({pets: {fido: {visits: 1}}});
1206
1281
  *
@@ -1212,7 +1287,7 @@ export interface Store {
1212
1287
  * This example attempts to set the data of an existing Store with an invalid
1213
1288
  * Cell value.
1214
1289
  *
1215
- * ```tsx
1290
+ * ```js
1216
1291
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1217
1292
  *
1218
1293
  * store.setCell('pets', 'fido', 'bug', []);
@@ -1237,7 +1312,7 @@ export interface Store {
1237
1312
  * @example
1238
1313
  * This example sets the contents of a Store from a serialization.
1239
1314
  *
1240
- * ```tsx
1315
+ * ```js
1241
1316
  * const store = createStore();
1242
1317
  * store.setJson('{"pets":{"fido":{"species":"dog"}}}');
1243
1318
  * console.log(store.getTables());
@@ -1247,7 +1322,7 @@ export interface Store {
1247
1322
  * This example attempts to set the contents of a Store from an invalid
1248
1323
  * serialization.
1249
1324
  *
1250
- * ```tsx
1325
+ * ```js
1251
1326
  * const store = createStore();
1252
1327
  * store.setJson('{"pets":{"fido":{');
1253
1328
  * console.log(store.getTables());
@@ -1273,7 +1348,7 @@ export interface Store {
1273
1348
  * @example
1274
1349
  * This example sets the Schema of a Store after it has been created.
1275
1350
  *
1276
- * ```tsx
1351
+ * ```js
1277
1352
  * const store = createStore().setSchema({
1278
1353
  * pets: {
1279
1354
  * species: {type: 'string'},
@@ -1295,7 +1370,7 @@ export interface Store {
1295
1370
  * @example
1296
1371
  * This example removes the data of a Store.
1297
1372
  *
1298
- * ```tsx
1373
+ * ```js
1299
1374
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1300
1375
  *
1301
1376
  * store.delTables();
@@ -1314,7 +1389,7 @@ export interface Store {
1314
1389
  * @example
1315
1390
  * This example removes a Table from a Store.
1316
1391
  *
1317
- * ```tsx
1392
+ * ```js
1318
1393
  * const store = createStore().setTables({
1319
1394
  * pets: {fido: {species: 'dog'}},
1320
1395
  * species: {dog: {price: 5}},
@@ -1339,7 +1414,7 @@ export interface Store {
1339
1414
  * @example
1340
1415
  * This example removes a Row from a Table.
1341
1416
  *
1342
- * ```tsx
1417
+ * ```js
1343
1418
  * const store = createStore().setTables({
1344
1419
  * pets: {fido: {species: 'dog'}, felix: {species: 'cat'}},
1345
1420
  * });
@@ -1382,7 +1457,7 @@ export interface Store {
1382
1457
  * @example
1383
1458
  * This example removes a Cell from a Row without a Schema.
1384
1459
  *
1385
- * ```tsx
1460
+ * ```js
1386
1461
  * const store = createStore().setTables({
1387
1462
  * pets: {fido: {species: 'dog', sold: true}},
1388
1463
  * });
@@ -1395,7 +1470,7 @@ export interface Store {
1395
1470
  * This example removes a Cell from a Row with a Schema that defaults its
1396
1471
  * value.
1397
1472
  *
1398
- * ```tsx
1473
+ * ```js
1399
1474
  * const store = createStore()
1400
1475
  * .setTables({
1401
1476
  * pets: {fido: {species: 'dog', sold: true}},
@@ -1415,7 +1490,7 @@ export interface Store {
1415
1490
  * This example removes a Cell from a Row with a Schema that defaults its
1416
1491
  * value, but uses the `forceDel` parameter to override it.
1417
1492
  *
1418
- * ```tsx
1493
+ * ```js
1419
1494
  * const store = createStore()
1420
1495
  * .setTables({
1421
1496
  * pets: {fido: {species: 'dog', sold: true}, felix: {species: 'cat'}},
@@ -1442,7 +1517,7 @@ export interface Store {
1442
1517
  * @example
1443
1518
  * This example removes the Schema of a Store.
1444
1519
  *
1445
- * ```tsx
1520
+ * ```js
1446
1521
  * const store = createStore().setSchema({pets: {species: {type: 'string'}}});
1447
1522
  * store.delSchema();
1448
1523
  * console.log(store.getSchemaJson());
@@ -1481,7 +1556,7 @@ export interface Store {
1481
1556
  * within, a transaction. In the second case, the Row listener is only called
1482
1557
  * once.
1483
1558
  *
1484
- * ```tsx
1559
+ * ```js
1485
1560
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1486
1561
  * store.addRowListener('pets', 'fido', () => console.log('Fido changed'));
1487
1562
  *
@@ -1501,7 +1576,7 @@ export interface Store {
1501
1576
  * called once - and with the final value - only if there is a net overall
1502
1577
  * change.
1503
1578
  *
1504
- * ```tsx
1579
+ * ```js
1505
1580
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1506
1581
  * store.addCellListener(
1507
1582
  * 'pets',
@@ -1543,7 +1618,7 @@ export interface Store {
1543
1618
  * This example iterates over each Table in a Store, and lists each Row Id
1544
1619
  * within them.
1545
1620
  *
1546
- * ```tsx
1621
+ * ```js
1547
1622
  * const store = createStore().setTables({
1548
1623
  * pets: {fido: {species: 'dog'}},
1549
1624
  * species: {dog: {price: 5}},
@@ -1575,7 +1650,7 @@ export interface Store {
1575
1650
  * This example iterates over each Row in a Table, and lists each Cell Id
1576
1651
  * within them.
1577
1652
  *
1578
- * ```tsx
1653
+ * ```js
1579
1654
  * const store = createStore().setTables({
1580
1655
  * pets: {
1581
1656
  * fido: {species: 'dog'},
@@ -1607,7 +1682,7 @@ export interface Store {
1607
1682
  * @example
1608
1683
  * This example iterates over each Cell in a Row, and lists its value.
1609
1684
  *
1610
- * ```tsx
1685
+ * ```js
1611
1686
  * const store = createStore().setTables({
1612
1687
  * pets: {fido: {species: 'dog', color: 'brown'}},
1613
1688
  * });
@@ -1647,7 +1722,7 @@ export interface Store {
1647
1722
  * This example registers a listener that responds to any changes to the whole
1648
1723
  * Store.
1649
1724
  *
1650
- * ```tsx
1725
+ * ```js
1651
1726
  * const store = createStore().setTables({
1652
1727
  * pets: {fido: {species: 'dog', color: 'brown'}},
1653
1728
  * });
@@ -1666,7 +1741,7 @@ export interface Store {
1666
1741
  * This example registers a listener that responds to any changes to the whole
1667
1742
  * Store, and which also mutates the Store itself.
1668
1743
  *
1669
- * ```tsx
1744
+ * ```js
1670
1745
  * const store = createStore().setTables({
1671
1746
  * pets: {fido: {species: 'dog', color: 'brown'}},
1672
1747
  * });
@@ -1713,7 +1788,7 @@ export interface Store {
1713
1788
  * This example registers a listener that responds to any change to the Table
1714
1789
  * Ids.
1715
1790
  *
1716
- * ```tsx
1791
+ * ```js
1717
1792
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1718
1793
  * const listenerId = store.addTableIdsListener((store) => {
1719
1794
  * console.log('Table Ids changed');
@@ -1730,7 +1805,7 @@ export interface Store {
1730
1805
  * This example registers a listener that responds to any change to the Table
1731
1806
  * Ids, and which also mutates the Store itself.
1732
1807
  *
1733
- * ```tsx
1808
+ * ```js
1734
1809
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1735
1810
  * const listenerId = store.addTableIdsListener(
1736
1811
  * (store) => store.setCell('meta', 'update', 'store', true),
@@ -1743,6 +1818,7 @@ export interface Store {
1743
1818
  *
1744
1819
  * store.delListener(listenerId);
1745
1820
  * ```
1821
+ * @category Listener
1746
1822
  */
1747
1823
  addTableIdsListener(listener: TableIdsListener, mutator?: boolean): Id;
1748
1824
 
@@ -1778,7 +1854,7 @@ export interface Store {
1778
1854
  * This example registers a listener that responds to any changes to a
1779
1855
  * specific Table.
1780
1856
  *
1781
- * ```tsx
1857
+ * ```js
1782
1858
  * const store = createStore().setTables({
1783
1859
  * pets: {fido: {species: 'dog', color: 'brown'}},
1784
1860
  * });
@@ -1800,7 +1876,7 @@ export interface Store {
1800
1876
  * This example registers a listener that responds to any changes to any
1801
1877
  * Table.
1802
1878
  *
1803
- * ```tsx
1879
+ * ```js
1804
1880
  * const store = createStore().setTables({
1805
1881
  * pets: {fido: {species: 'dog', color: 'brown'}},
1806
1882
  * });
@@ -1819,7 +1895,7 @@ export interface Store {
1819
1895
  * This example registers a listener that responds to any changes to a
1820
1896
  * specific Table, and which also mutates the Store itself.
1821
1897
  *
1822
- * ```tsx
1898
+ * ```js
1823
1899
  * const store = createStore().setTables({
1824
1900
  * pets: {fido: {species: 'dog', color: 'brown'}},
1825
1901
  * });
@@ -1875,7 +1951,7 @@ export interface Store {
1875
1951
  * This example registers a listener that responds to any change to the Row
1876
1952
  * Ids of a specific Table.
1877
1953
  *
1878
- * ```tsx
1954
+ * ```js
1879
1955
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1880
1956
  * const listenerId = store.addRowIdsListener('pets', (store) => {
1881
1957
  * console.log('Row Ids for pets table changed');
@@ -1892,7 +1968,7 @@ export interface Store {
1892
1968
  * This example registers a listener that responds to any change to the Row
1893
1969
  * Ids of any Table.
1894
1970
  *
1895
- * ```tsx
1971
+ * ```js
1896
1972
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1897
1973
  * const listenerId = store.addRowIdsListener(null, (store, tableId) => {
1898
1974
  * console.log(`Row Ids for ${tableId} table changed`);
@@ -1912,7 +1988,7 @@ export interface Store {
1912
1988
  * This example registers a listener that responds to any change to the Row
1913
1989
  * Ids of a specific Table, and which also mutates the Store itself.
1914
1990
  *
1915
- * ```tsx
1991
+ * ```js
1916
1992
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
1917
1993
  * const listenerId = store.addRowIdsListener(
1918
1994
  * 'pets',
@@ -1926,6 +2002,7 @@ export interface Store {
1926
2002
  *
1927
2003
  * store.delListener(listenerId);
1928
2004
  * ```
2005
+ * @category Listener
1929
2006
  */
1930
2007
  addRowIdsListener(
1931
2008
  tableId: IdOrNull,
@@ -1971,7 +2048,7 @@ export interface Store {
1971
2048
  * This example registers a listener that responds to any changes to a
1972
2049
  * specific Row.
1973
2050
  *
1974
- * ```tsx
2051
+ * ```js
1975
2052
  * const store = createStore().setTables({
1976
2053
  * pets: {fido: {species: 'dog', color: 'brown'}},
1977
2054
  * });
@@ -1993,7 +2070,7 @@ export interface Store {
1993
2070
  * @example
1994
2071
  * This example registers a listener that responds to any changes to any Row.
1995
2072
  *
1996
- * ```tsx
2073
+ * ```js
1997
2074
  * const store = createStore().setTables({
1998
2075
  * pets: {fido: {species: 'dog', color: 'brown'}},
1999
2076
  * });
@@ -2016,7 +2093,7 @@ export interface Store {
2016
2093
  * This example registers a listener that responds to any changes to a
2017
2094
  * specific Row, and which also mutates the Store itself.
2018
2095
  *
2019
- * ```tsx
2096
+ * ```js
2020
2097
  * const store = createStore().setTables({
2021
2098
  * pets: {fido: {species: 'dog', color: 'brown'}},
2022
2099
  * });
@@ -2083,7 +2160,7 @@ export interface Store {
2083
2160
  * This example registers a listener that responds to any change to the Cell
2084
2161
  * Ids of a specific Row.
2085
2162
  *
2086
- * ```tsx
2163
+ * ```js
2087
2164
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
2088
2165
  * const listenerId = store.addCellIdsListener('pets', 'fido', (store) => {
2089
2166
  * console.log('Cell Ids for fido row in pets table changed');
@@ -2100,7 +2177,7 @@ export interface Store {
2100
2177
  * This example registers a listener that responds to any change to the Cell
2101
2178
  * Ids of any Row.
2102
2179
  *
2103
- * ```tsx
2180
+ * ```js
2104
2181
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
2105
2182
  * const listenerId = store.addCellIdsListener(
2106
2183
  * null,
@@ -2124,7 +2201,7 @@ export interface Store {
2124
2201
  * This example registers a listener that responds to any change to the Cell
2125
2202
  * Ids of a specific Row, and which also mutates the Store itself.
2126
2203
  *
2127
- * ```tsx
2204
+ * ```js
2128
2205
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
2129
2206
  * const listenerId = store.addCellIdsListener(
2130
2207
  * 'pets',
@@ -2140,6 +2217,7 @@ export interface Store {
2140
2217
  *
2141
2218
  * store.delListener(listenerId);
2142
2219
  * ```
2220
+ * @category Listener
2143
2221
  */
2144
2222
  addCellIdsListener(
2145
2223
  tableId: IdOrNull,
@@ -2188,7 +2266,7 @@ export interface Store {
2188
2266
  * This example registers a listener that responds to any changes to a
2189
2267
  * specific Cell.
2190
2268
  *
2191
- * ```tsx
2269
+ * ```js
2192
2270
  * const store = createStore().setTables({
2193
2271
  * pets: {fido: {species: 'dog', color: 'brown'}},
2194
2272
  * });
@@ -2213,7 +2291,7 @@ export interface Store {
2213
2291
  * @example
2214
2292
  * This example registers a listener that responds to any changes to any Cell.
2215
2293
  *
2216
- * ```tsx
2294
+ * ```js
2217
2295
  * const store = createStore().setTables({
2218
2296
  * pets: {fido: {species: 'dog', color: 'brown'}},
2219
2297
  * });
@@ -2239,7 +2317,7 @@ export interface Store {
2239
2317
  * This example registers a listener that responds to any changes to a
2240
2318
  * specific Cell, and which also mutates the Store itself.
2241
2319
  *
2242
- * ```tsx
2320
+ * ```js
2243
2321
  * const store = createStore().setTables({
2244
2322
  * pets: {fido: {species: 'dog', color: 'brown'}},
2245
2323
  * });
@@ -2283,7 +2361,7 @@ export interface Store {
2283
2361
  * valid values. After that list changes, the listener is called to apply the
2284
2362
  * condition to the existing data.
2285
2363
  *
2286
- * ```tsx
2364
+ * ```js
2287
2365
  * const validColors = ['walnut', 'brown', 'black'];
2288
2366
  * const store = createStore();
2289
2367
  * const listenerId = store.addCellListener(
@@ -2328,7 +2406,7 @@ export interface Store {
2328
2406
  * @example
2329
2407
  * This example registers a listener and then removes it.
2330
2408
  *
2331
- * ```tsx
2409
+ * ```js
2332
2410
  * const store = createStore().setTables({
2333
2411
  * pets: {fido: {species: 'dog', color: 'brown'}},
2334
2412
  * });
@@ -2365,7 +2443,7 @@ export interface Store {
2365
2443
  * @example
2366
2444
  * This example gets the listener statistics of a small and simple Store.
2367
2445
  *
2368
- * ```tsx
2446
+ * ```js
2369
2447
  * const store = createStore();
2370
2448
  * store.addTablesListener(() => console.log('Tables changed'));
2371
2449
  * store.addRowIdsListener(() => console.log('Row Ids changed'));
@@ -2392,7 +2470,7 @@ export interface Store {
2392
2470
  * @example
2393
2471
  * This example creates a Store.
2394
2472
  *
2395
- * ```tsx
2473
+ * ```js
2396
2474
  * const store = createStore();
2397
2475
  * console.log(store.getTables());
2398
2476
  * // -> {}
@@ -2400,7 +2478,7 @@ export interface Store {
2400
2478
  * @example
2401
2479
  * This example creates a Store with some initial data:
2402
2480
  *
2403
- * ```tsx
2481
+ * ```js
2404
2482
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
2405
2483
  * console.log(store.getTables());
2406
2484
  * // -> {pets: {fido: {species: 'dog'}}}
@@ -2408,7 +2486,7 @@ export interface Store {
2408
2486
  * @example
2409
2487
  * This example creates a Store with some initial data and a Schema:
2410
2488
  *
2411
- * ```tsx
2489
+ * ```js
2412
2490
  * const store = createStore()
2413
2491
  * .setTables({pets: {fido: {species: 'dog'}}})
2414
2492
  * .setSchema({
@@ -2420,5 +2498,6 @@ export interface Store {
2420
2498
  * console.log(store.getTables());
2421
2499
  * // -> {pets: {fido: {species: 'dog', sold: false}}}
2422
2500
  * ```
2501
+ * @category Creation
2423
2502
  */
2424
2503
  export function createStore(): Store;