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.
@@ -43,6 +43,7 @@ export type CheckpointIds = [Ids, Id | undefined, Ids];
43
43
  * When called, a CheckpointIdsListener is given a reference to the Checkpoints
44
44
  * object.
45
45
  *
46
+ * @param checkpoints A reference to the Checkpoints object that changed.
46
47
  * @category Listener
47
48
  */
48
49
  export type CheckpointIdsListener = (checkpoints: Checkpoints) => void;
@@ -57,6 +58,8 @@ export type CheckpointIdsListener = (checkpoints: Checkpoints) => void;
57
58
  * When called, a CheckpointListener is given a reference to the Checkpoints
58
59
  * object, and the Id of the checkpoint whose label changed.
59
60
  *
61
+ * @param checkpoints A reference to the Checkpoints object that changed.
62
+ * @param checkpointId The Id of the checkpoint that changed.
60
63
  * @category Listener
61
64
  */
62
65
  export type CheckpointListener = (
@@ -75,7 +78,14 @@ export type CheckpointListener = (
75
78
  * @category Development
76
79
  */
77
80
  export type CheckpointsListenerStats = {
81
+ /**
82
+ * The number of CheckpointIdsListeners registered with the Checkpoints
83
+ * object.
84
+ */
78
85
  checkpointIds?: number;
86
+ /**
87
+ * The number of CheckpointListeners registered with the Checkpoints object.
88
+ */
79
89
  checkpoint?: number;
80
90
  };
81
91
 
@@ -101,7 +111,7 @@ export type CheckpointsListenerStats = {
101
111
  * to adding a checkpoint, getting the list of available checkpoints, and then
102
112
  * registering and removing a listener for them.
103
113
  *
104
- * ```tsx
114
+ * ```js
105
115
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
106
116
  *
107
117
  * const checkpoints = createCheckpoints(store);
@@ -132,6 +142,7 @@ export type CheckpointsListenerStats = {
132
142
  * checkpoints.delListener(listenerId);
133
143
  * checkpoints.destroy();
134
144
  * ```
145
+ * @category Checkpoints
135
146
  */
136
147
  export interface Checkpoints {
137
148
  /**
@@ -151,7 +162,7 @@ export interface Checkpoints {
151
162
  * of the Checkpoints object dramatically and then creates more than that
152
163
  * number of checkpoints to demonstrate the oldest being pruned.
153
164
  *
154
- * ```tsx
165
+ * ```js
155
166
  * const store = createStore().setTables({pets: {fido: {views: 0}}});
156
167
  *
157
168
  * const checkpoints = createCheckpoints(store);
@@ -196,7 +207,7 @@ export interface Checkpoints {
196
207
  * This example creates a Store, adds a Checkpoints object, and adds two
197
208
  * checkpoints, one with a label.
198
209
  *
199
- * ```tsx
210
+ * ```js
200
211
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
201
212
  *
202
213
  * const checkpoints = createCheckpoints(store);
@@ -245,7 +256,7 @@ export interface Checkpoints {
245
256
  * This example creates a Store, adds a Checkpoints object, and sets two
246
257
  * checkpoints, one with a label, which are both then re-labelled.
247
258
  *
248
- * ```tsx
259
+ * ```js
249
260
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
250
261
  *
251
262
  * const checkpoints = createCheckpoints(store);
@@ -288,7 +299,7 @@ export interface Checkpoints {
288
299
  * and then gets its reference in order to update its data and set a
289
300
  * checkpoint.
290
301
  *
291
- * ```tsx
302
+ * ```js
292
303
  * const checkpoints = createCheckpoints(createStore());
293
304
  * checkpoints.getStore().setCell('pets', 'fido', 'species', 'dog');
294
305
  * checkpoints.addCheckpoint();
@@ -315,7 +326,7 @@ export interface Checkpoints {
315
326
  * This example creates a Store, adds a Checkpoints object, and then gets the
316
327
  * Ids of the checkpoints as it sets them and moves around the stack.
317
328
  *
318
- * ```tsx
329
+ * ```js
319
330
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
320
331
  *
321
332
  * const checkpoints = createCheckpoints(store);
@@ -354,7 +365,7 @@ export interface Checkpoints {
354
365
  * This example creates a Store, adds a Checkpoints object, and sets a
355
366
  * checkpoint with a label, before retrieving it again.
356
367
  *
357
- * ```tsx
368
+ * ```js
358
369
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
359
370
  *
360
371
  * const checkpoints = createCheckpoints(store);
@@ -370,7 +381,7 @@ export interface Checkpoints {
370
381
  * checkpoint without a label, setting it subsequently. A non-existent
371
382
  * checkpoint return an `undefined` label.
372
383
  *
373
- * ```tsx
384
+ * ```js
374
385
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
375
386
  *
376
387
  * const checkpoints = createCheckpoints(store);
@@ -405,7 +416,7 @@ export interface Checkpoints {
405
416
  * This example creates a Store, a Checkpoints object, and then registers a
406
417
  * listener that responds to any changes to the checkpoints.
407
418
  *
408
- * ```tsx
419
+ * ```js
409
420
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
410
421
  *
411
422
  * const checkpoints = createCheckpoints(store);
@@ -463,7 +474,7 @@ export interface Checkpoints {
463
474
  * listener that responds to any changes to a specific checkpoint label,
464
475
  * including when the checkpoint no longer exists.
465
476
  *
466
- * ```tsx
477
+ * ```js
467
478
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
468
479
  *
469
480
  * const checkpoints = createCheckpoints(store);
@@ -516,7 +527,7 @@ export interface Checkpoints {
516
527
  * This example creates a Store, a Checkpoints object, registers a listener,
517
528
  * and then removes it.
518
529
  *
519
- * ```tsx
530
+ * ```js
520
531
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
521
532
  *
522
533
  * const checkpoints = createCheckpoints(store);
@@ -554,7 +565,7 @@ export interface Checkpoints {
554
565
  * This example creates a Store, a Checkpoints object, makes a change and then
555
566
  * goes backward to the state of the Store before the change.
556
567
  *
557
- * ```tsx
568
+ * ```js
558
569
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
559
570
  *
560
571
  * const checkpoints = createCheckpoints(store);
@@ -572,6 +583,7 @@ export interface Checkpoints {
572
583
  * console.log(checkpoints.getCheckpointIds());
573
584
  * // -> [[], '0', ['1']]
574
585
  * ```
586
+ * @category Movement
575
587
  */
576
588
  goBackward(): Checkpoints;
577
589
 
@@ -592,7 +604,7 @@ export interface Checkpoints {
592
604
  * goes backward to the state of the Store before the change. It then goes
593
605
  * forward again to restore the state with the changes.
594
606
  *
595
- * ```tsx
607
+ * ```js
596
608
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
597
609
  *
598
610
  * const checkpoints = createCheckpoints(store);
@@ -622,7 +634,7 @@ export interface Checkpoints {
622
634
  * change, the redo stack disappears, and then the attempt to forward again
623
635
  * has no effect.
624
636
  *
625
- * ```tsx
637
+ * ```js
626
638
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
627
639
  *
628
640
  * const checkpoints = createCheckpoints(store);
@@ -651,6 +663,7 @@ export interface Checkpoints {
651
663
  * // -> [['0'], undefined, []]
652
664
  * // The original change cannot be redone.
653
665
  * ```
666
+ * @category Movement
654
667
  */
655
668
  goForward(): Checkpoints;
656
669
 
@@ -668,7 +681,7 @@ export interface Checkpoints {
668
681
  * then goes forward again one change, also using the goTo method. Finally it
669
682
  * tries to go to a checkpoint that does not exist.
670
683
  *
671
- * ```tsx
684
+ * ```js
672
685
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
673
686
  *
674
687
  * const checkpoints = createCheckpoints(store);
@@ -700,6 +713,7 @@ export interface Checkpoints {
700
713
  * console.log(checkpoints.getCheckpointIds());
701
714
  * // -> [['0'], '1', ['2']]
702
715
  * ```
716
+ * @category Movement
703
717
  */
704
718
  goTo(checkpointId: Id): Checkpoints;
705
719
 
@@ -724,7 +738,7 @@ export interface Checkpoints {
724
738
  * This example creates a Store, a Checkpoints object, adds a listener, makes
725
739
  * a change and then clears the checkpoints.
726
740
  *
727
- * ```tsx
741
+ * ```js
728
742
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
729
743
  *
730
744
  * const checkpoints = createCheckpoints(store);
@@ -773,7 +787,7 @@ export interface Checkpoints {
773
787
  * CellListener with the underlying Store), and then destroys it again,
774
788
  * removing the listener.
775
789
  *
776
- * ```tsx
790
+ * ```js
777
791
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
778
792
  *
779
793
  * const checkpoints = createCheckpoints(store);
@@ -807,7 +821,7 @@ export interface Checkpoints {
807
821
  * @example
808
822
  * This example gets the listener statistics of a Checkpoints object.
809
823
  *
810
- * ```tsx
824
+ * ```js
811
825
  * const store = createStore();
812
826
  * const checkpoints = createCheckpoints(store);
813
827
  * checkpoints.addCheckpointIdsListener(() => {
@@ -840,7 +854,7 @@ export interface Checkpoints {
840
854
  * @example
841
855
  * This example creates a Checkpoints object.
842
856
  *
843
- * ```tsx
857
+ * ```js
844
858
  * const store = createStore();
845
859
  * const checkpoints = createCheckpoints(store);
846
860
  * console.log(checkpoints.getCheckpointIds());
@@ -850,12 +864,13 @@ export interface Checkpoints {
850
864
  * This example creates a Checkpoints object, and calls the method a second
851
865
  * time for the same Store to return the same object.
852
866
  *
853
- * ```tsx
867
+ * ```js
854
868
  * const store = createStore();
855
869
  * const checkpoints1 = createCheckpoints(store);
856
870
  * const checkpoints2 = createCheckpoints(store);
857
871
  * console.log(checkpoints1 === checkpoints2);
858
872
  * // -> true
859
873
  * ```
874
+ * @category Creation
860
875
  */
861
876
  export function createCheckpoints(store: Store): Checkpoints;
@@ -43,6 +43,7 @@ export type CheckpointIds = [Ids, Id | undefined, Ids];
43
43
  * When called, a CheckpointIdsListener is given a reference to the Checkpoints
44
44
  * object.
45
45
  *
46
+ * @param checkpoints A reference to the Checkpoints object that changed.
46
47
  * @category Listener
47
48
  */
48
49
  export type CheckpointIdsListener = (checkpoints: Checkpoints) => void;
@@ -57,6 +58,8 @@ export type CheckpointIdsListener = (checkpoints: Checkpoints) => void;
57
58
  * When called, a CheckpointListener is given a reference to the Checkpoints
58
59
  * object, and the Id of the checkpoint whose label changed.
59
60
  *
61
+ * @param checkpoints A reference to the Checkpoints object that changed.
62
+ * @param checkpointId The Id of the checkpoint that changed.
60
63
  * @category Listener
61
64
  */
62
65
  export type CheckpointListener = (
@@ -75,7 +78,14 @@ export type CheckpointListener = (
75
78
  * @category Development
76
79
  */
77
80
  export type CheckpointsListenerStats = {
81
+ /**
82
+ * The number of CheckpointIdsListeners registered with the Checkpoints
83
+ * object.
84
+ */
78
85
  checkpointIds?: number;
86
+ /**
87
+ * The number of CheckpointListeners registered with the Checkpoints object.
88
+ */
79
89
  checkpoint?: number;
80
90
  };
81
91
 
@@ -101,7 +111,7 @@ export type CheckpointsListenerStats = {
101
111
  * to adding a checkpoint, getting the list of available checkpoints, and then
102
112
  * registering and removing a listener for them.
103
113
  *
104
- * ```tsx
114
+ * ```js
105
115
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
106
116
  *
107
117
  * const checkpoints = createCheckpoints(store);
@@ -132,6 +142,7 @@ export type CheckpointsListenerStats = {
132
142
  * checkpoints.delListener(listenerId);
133
143
  * checkpoints.destroy();
134
144
  * ```
145
+ * @category Checkpoints
135
146
  */
136
147
  export interface Checkpoints {
137
148
  /**
@@ -151,7 +162,7 @@ export interface Checkpoints {
151
162
  * of the Checkpoints object dramatically and then creates more than that
152
163
  * number of checkpoints to demonstrate the oldest being pruned.
153
164
  *
154
- * ```tsx
165
+ * ```js
155
166
  * const store = createStore().setTables({pets: {fido: {views: 0}}});
156
167
  *
157
168
  * const checkpoints = createCheckpoints(store);
@@ -196,7 +207,7 @@ export interface Checkpoints {
196
207
  * This example creates a Store, adds a Checkpoints object, and adds two
197
208
  * checkpoints, one with a label.
198
209
  *
199
- * ```tsx
210
+ * ```js
200
211
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
201
212
  *
202
213
  * const checkpoints = createCheckpoints(store);
@@ -245,7 +256,7 @@ export interface Checkpoints {
245
256
  * This example creates a Store, adds a Checkpoints object, and sets two
246
257
  * checkpoints, one with a label, which are both then re-labelled.
247
258
  *
248
- * ```tsx
259
+ * ```js
249
260
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
250
261
  *
251
262
  * const checkpoints = createCheckpoints(store);
@@ -288,7 +299,7 @@ export interface Checkpoints {
288
299
  * and then gets its reference in order to update its data and set a
289
300
  * checkpoint.
290
301
  *
291
- * ```tsx
302
+ * ```js
292
303
  * const checkpoints = createCheckpoints(createStore());
293
304
  * checkpoints.getStore().setCell('pets', 'fido', 'species', 'dog');
294
305
  * checkpoints.addCheckpoint();
@@ -315,7 +326,7 @@ export interface Checkpoints {
315
326
  * This example creates a Store, adds a Checkpoints object, and then gets the
316
327
  * Ids of the checkpoints as it sets them and moves around the stack.
317
328
  *
318
- * ```tsx
329
+ * ```js
319
330
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
320
331
  *
321
332
  * const checkpoints = createCheckpoints(store);
@@ -354,7 +365,7 @@ export interface Checkpoints {
354
365
  * This example creates a Store, adds a Checkpoints object, and sets a
355
366
  * checkpoint with a label, before retrieving it again.
356
367
  *
357
- * ```tsx
368
+ * ```js
358
369
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
359
370
  *
360
371
  * const checkpoints = createCheckpoints(store);
@@ -370,7 +381,7 @@ export interface Checkpoints {
370
381
  * checkpoint without a label, setting it subsequently. A non-existent
371
382
  * checkpoint return an `undefined` label.
372
383
  *
373
- * ```tsx
384
+ * ```js
374
385
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
375
386
  *
376
387
  * const checkpoints = createCheckpoints(store);
@@ -405,7 +416,7 @@ export interface Checkpoints {
405
416
  * This example creates a Store, a Checkpoints object, and then registers a
406
417
  * listener that responds to any changes to the checkpoints.
407
418
  *
408
- * ```tsx
419
+ * ```js
409
420
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
410
421
  *
411
422
  * const checkpoints = createCheckpoints(store);
@@ -463,7 +474,7 @@ export interface Checkpoints {
463
474
  * listener that responds to any changes to a specific checkpoint label,
464
475
  * including when the checkpoint no longer exists.
465
476
  *
466
- * ```tsx
477
+ * ```js
467
478
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
468
479
  *
469
480
  * const checkpoints = createCheckpoints(store);
@@ -516,7 +527,7 @@ export interface Checkpoints {
516
527
  * This example creates a Store, a Checkpoints object, registers a listener,
517
528
  * and then removes it.
518
529
  *
519
- * ```tsx
530
+ * ```js
520
531
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
521
532
  *
522
533
  * const checkpoints = createCheckpoints(store);
@@ -554,7 +565,7 @@ export interface Checkpoints {
554
565
  * This example creates a Store, a Checkpoints object, makes a change and then
555
566
  * goes backward to the state of the Store before the change.
556
567
  *
557
- * ```tsx
568
+ * ```js
558
569
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
559
570
  *
560
571
  * const checkpoints = createCheckpoints(store);
@@ -572,6 +583,7 @@ export interface Checkpoints {
572
583
  * console.log(checkpoints.getCheckpointIds());
573
584
  * // -> [[], '0', ['1']]
574
585
  * ```
586
+ * @category Movement
575
587
  */
576
588
  goBackward(): Checkpoints;
577
589
 
@@ -592,7 +604,7 @@ export interface Checkpoints {
592
604
  * goes backward to the state of the Store before the change. It then goes
593
605
  * forward again to restore the state with the changes.
594
606
  *
595
- * ```tsx
607
+ * ```js
596
608
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
597
609
  *
598
610
  * const checkpoints = createCheckpoints(store);
@@ -622,7 +634,7 @@ export interface Checkpoints {
622
634
  * change, the redo stack disappears, and then the attempt to forward again
623
635
  * has no effect.
624
636
  *
625
- * ```tsx
637
+ * ```js
626
638
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
627
639
  *
628
640
  * const checkpoints = createCheckpoints(store);
@@ -651,6 +663,7 @@ export interface Checkpoints {
651
663
  * // -> [['0'], undefined, []]
652
664
  * // The original change cannot be redone.
653
665
  * ```
666
+ * @category Movement
654
667
  */
655
668
  goForward(): Checkpoints;
656
669
 
@@ -668,7 +681,7 @@ export interface Checkpoints {
668
681
  * then goes forward again one change, also using the goTo method. Finally it
669
682
  * tries to go to a checkpoint that does not exist.
670
683
  *
671
- * ```tsx
684
+ * ```js
672
685
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
673
686
  *
674
687
  * const checkpoints = createCheckpoints(store);
@@ -700,6 +713,7 @@ export interface Checkpoints {
700
713
  * console.log(checkpoints.getCheckpointIds());
701
714
  * // -> [['0'], '1', ['2']]
702
715
  * ```
716
+ * @category Movement
703
717
  */
704
718
  goTo(checkpointId: Id): Checkpoints;
705
719
 
@@ -724,7 +738,7 @@ export interface Checkpoints {
724
738
  * This example creates a Store, a Checkpoints object, adds a listener, makes
725
739
  * a change and then clears the checkpoints.
726
740
  *
727
- * ```tsx
741
+ * ```js
728
742
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
729
743
  *
730
744
  * const checkpoints = createCheckpoints(store);
@@ -773,7 +787,7 @@ export interface Checkpoints {
773
787
  * CellListener with the underlying Store), and then destroys it again,
774
788
  * removing the listener.
775
789
  *
776
- * ```tsx
790
+ * ```js
777
791
  * const store = createStore().setTables({pets: {fido: {sold: false}}});
778
792
  *
779
793
  * const checkpoints = createCheckpoints(store);
@@ -807,7 +821,7 @@ export interface Checkpoints {
807
821
  * @example
808
822
  * This example gets the listener statistics of a Checkpoints object.
809
823
  *
810
- * ```tsx
824
+ * ```js
811
825
  * const store = createStore();
812
826
  * const checkpoints = createCheckpoints(store);
813
827
  * checkpoints.addCheckpointIdsListener(() => {
@@ -840,7 +854,7 @@ export interface Checkpoints {
840
854
  * @example
841
855
  * This example creates a Checkpoints object.
842
856
  *
843
- * ```tsx
857
+ * ```js
844
858
  * const store = createStore();
845
859
  * const checkpoints = createCheckpoints(store);
846
860
  * console.log(checkpoints.getCheckpointIds());
@@ -850,12 +864,13 @@ export interface Checkpoints {
850
864
  * This example creates a Checkpoints object, and calls the method a second
851
865
  * time for the same Store to return the same object.
852
866
  *
853
- * ```tsx
867
+ * ```js
854
868
  * const store = createStore();
855
869
  * const checkpoints1 = createCheckpoints(store);
856
870
  * const checkpoints2 = createCheckpoints(store);
857
871
  * console.log(checkpoints1 === checkpoints2);
858
872
  * // -> true
859
873
  * ```
874
+ * @category Creation
860
875
  */
861
876
  export function createCheckpoints(store: Store): Checkpoints;