tinybase 6.1.0-beta.1 → 6.1.0-beta.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.
Files changed (108) hide show
  1. package/@types/common/index.d.ts +4 -4
  2. package/@types/common/with-schemas/index.d.ts +4 -4
  3. package/@types/mergeable-store/index.d.ts +45 -20
  4. package/@types/mergeable-store/with-schemas/index.d.ts +49 -21
  5. package/@types/persisters/index.d.ts +1 -1
  6. package/@types/persisters/with-schemas/index.d.ts +1 -1
  7. package/index.js +19 -11
  8. package/indexes/index.js +15 -3
  9. package/indexes/with-schemas/index.js +15 -3
  10. package/mergeable-store/index.js +4 -8
  11. package/mergeable-store/with-schemas/index.js +4 -8
  12. package/min/index.js +1 -1
  13. package/min/index.js.gz +0 -0
  14. package/min/indexes/index.js +1 -1
  15. package/min/indexes/index.js.gz +0 -0
  16. package/min/indexes/with-schemas/index.js +1 -1
  17. package/min/indexes/with-schemas/index.js.gz +0 -0
  18. package/min/mergeable-store/index.js +1 -1
  19. package/min/mergeable-store/index.js.gz +0 -0
  20. package/min/mergeable-store/with-schemas/index.js +1 -1
  21. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  22. package/min/with-schemas/index.js +1 -1
  23. package/min/with-schemas/index.js.gz +0 -0
  24. package/package.json +9 -9
  25. package/readme.md +2 -2
  26. package/with-schemas/index.js +19 -11
  27. package/@types/_internal/queries/index.d.cts +0 -0
  28. package/@types/_internal/queries/with-schemas/index.d.cts +0 -22
  29. package/@types/_internal/store/index.d.cts +0 -3
  30. package/@types/_internal/store/with-schemas/index.d.cts +0 -106
  31. package/@types/_internal/ui-react/index.d.cts +0 -0
  32. package/@types/_internal/ui-react/with-schemas/index.d.cts +0 -1130
  33. package/@types/checkpoints/index.d.cts +0 -1059
  34. package/@types/checkpoints/with-schemas/index.d.cts +0 -1151
  35. package/@types/common/index.d.cts +0 -158
  36. package/@types/common/with-schemas/index.d.cts +0 -158
  37. package/@types/index.d.cts +0 -17
  38. package/@types/indexes/index.d.cts +0 -1064
  39. package/@types/indexes/with-schemas/index.d.cts +0 -1210
  40. package/@types/mergeable-store/index.d.cts +0 -1139
  41. package/@types/mergeable-store/with-schemas/index.d.cts +0 -1628
  42. package/@types/metrics/index.d.cts +0 -917
  43. package/@types/metrics/with-schemas/index.d.cts +0 -1004
  44. package/@types/persisters/index.d.cts +0 -1877
  45. package/@types/persisters/persister-automerge/index.d.cts +0 -165
  46. package/@types/persisters/persister-automerge/with-schemas/index.d.cts +0 -180
  47. package/@types/persisters/persister-browser/index.d.cts +0 -185
  48. package/@types/persisters/persister-browser/with-schemas/index.d.cts +0 -208
  49. package/@types/persisters/persister-cr-sqlite-wasm/index.d.cts +0 -159
  50. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.cts +0 -178
  51. package/@types/persisters/persister-durable-object-storage/index.d.cts +0 -122
  52. package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.cts +0 -136
  53. package/@types/persisters/persister-electric-sql/index.d.cts +0 -185
  54. package/@types/persisters/persister-electric-sql/with-schemas/index.d.cts +0 -204
  55. package/@types/persisters/persister-expo-sqlite/index.d.cts +0 -186
  56. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.cts +0 -205
  57. package/@types/persisters/persister-file/index.d.cts +0 -94
  58. package/@types/persisters/persister-file/with-schemas/index.d.cts +0 -107
  59. package/@types/persisters/persister-indexed-db/index.d.cts +0 -120
  60. package/@types/persisters/persister-indexed-db/with-schemas/index.d.cts +0 -135
  61. package/@types/persisters/persister-libsql/index.d.cts +0 -158
  62. package/@types/persisters/persister-libsql/with-schemas/index.d.cts +0 -177
  63. package/@types/persisters/persister-partykit-client/index.d.cts +0 -195
  64. package/@types/persisters/persister-partykit-client/with-schemas/index.d.cts +0 -210
  65. package/@types/persisters/persister-partykit-server/index.d.cts +0 -650
  66. package/@types/persisters/persister-partykit-server/with-schemas/index.d.cts +0 -695
  67. package/@types/persisters/persister-pglite/index.d.cts +0 -177
  68. package/@types/persisters/persister-pglite/with-schemas/index.d.cts +0 -196
  69. package/@types/persisters/persister-postgres/index.d.cts +0 -166
  70. package/@types/persisters/persister-postgres/with-schemas/index.d.cts +0 -185
  71. package/@types/persisters/persister-powersync/index.d.cts +0 -174
  72. package/@types/persisters/persister-powersync/with-schemas/index.d.cts +0 -193
  73. package/@types/persisters/persister-remote/index.d.cts +0 -117
  74. package/@types/persisters/persister-remote/with-schemas/index.d.cts +0 -133
  75. package/@types/persisters/persister-sqlite-wasm/index.d.cts +0 -175
  76. package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.cts +0 -195
  77. package/@types/persisters/persister-sqlite3/index.d.cts +0 -176
  78. package/@types/persisters/persister-sqlite3/with-schemas/index.d.cts +0 -195
  79. package/@types/persisters/persister-yjs/index.d.cts +0 -161
  80. package/@types/persisters/persister-yjs/with-schemas/index.d.cts +0 -176
  81. package/@types/persisters/with-schemas/index.d.cts +0 -2054
  82. package/@types/queries/index.d.cts +0 -3695
  83. package/@types/queries/with-schemas/index.d.cts +0 -4016
  84. package/@types/relationships/index.d.cts +0 -1320
  85. package/@types/relationships/with-schemas/index.d.cts +0 -1474
  86. package/@types/store/index.d.cts +0 -7598
  87. package/@types/store/with-schemas/index.d.cts +0 -9278
  88. package/@types/synchronizers/index.d.cts +0 -485
  89. package/@types/synchronizers/synchronizer-broadcast-channel/index.d.cts +0 -121
  90. package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.cts +0 -137
  91. package/@types/synchronizers/synchronizer-local/index.d.cts +0 -95
  92. package/@types/synchronizers/synchronizer-local/with-schemas/index.d.cts +0 -114
  93. package/@types/synchronizers/synchronizer-ws-client/index.d.cts +0 -160
  94. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.cts +0 -179
  95. package/@types/synchronizers/synchronizer-ws-server/index.d.cts +0 -736
  96. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +0 -765
  97. package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.cts +0 -311
  98. package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.cts +0 -349
  99. package/@types/synchronizers/synchronizer-ws-server-simple/index.d.cts +0 -144
  100. package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.cts +0 -144
  101. package/@types/synchronizers/with-schemas/index.d.cts +0 -503
  102. package/@types/ui-react/index.d.cts +0 -16640
  103. package/@types/ui-react/with-schemas/index.d.cts +0 -17281
  104. package/@types/ui-react-dom/index.d.cts +0 -1862
  105. package/@types/ui-react-dom/with-schemas/index.d.cts +0 -1994
  106. package/@types/ui-react-inspector/index.d.cts +0 -79
  107. package/@types/ui-react-inspector/with-schemas/index.d.cts +0 -1985
  108. package/@types/with-schemas/index.d.cts +0 -17
@@ -1,1059 +0,0 @@
1
- /**
2
- * The checkpoints module of the TinyBase project provides the ability to
3
- * create and track checkpoints made to the data in Store objects.
4
- *
5
- * The main entry point to this module is the createCheckpoints function, which
6
- * returns a new Checkpoints object. From there, you can create new checkpoints,
7
- * go forwards or backwards to others, and register listeners for when the list
8
- * of checkpoints change.
9
- * @packageDocumentation
10
- * @module checkpoints
11
- * @since v1.0.0
12
- */
13
- import type {Id, IdOrNull, Ids} from '../common/index.d.cts';
14
- import type {Store} from '../store/index.d.cts';
15
-
16
- /**
17
- * The CheckpointIds type is a representation of the list of checkpoint Ids
18
- * stored in a Checkpoints object.
19
- *
20
- * There are three parts to a CheckpointsIds array:
21
- *
22
- * - The 'backward' checkpoint Ids that can be rolled backward to (in other
23
- * words, the checkpoints in the undo stack for this Store). They are in
24
- * chronological order with the oldest checkpoint at the start of the array.
25
- * - The current checkpoint Id of the Store's state, or `undefined` if the
26
- * current state has not been checkpointed.
27
- * - The 'forward' checkpoint Ids that can be rolled forward to (in other words,
28
- * the checkpoints in the redo stack for this Store). They are in
29
- * chronological order with the newest checkpoint at the end of the array.
30
- * @category Identity
31
- * @since v1.0.0
32
- */
33
- export type CheckpointIds = [Ids, Id | undefined, Ids];
34
-
35
- /**
36
- * The CheckpointCallback type describes a function that takes a Checkpoint's
37
- * Id.
38
- *
39
- * A CheckpointCallback is provided when using the forEachCheckpoint method,
40
- * so that you can do something based on every Checkpoint in the Checkpoints
41
- * object. See that method for specific examples.
42
- * @param checkpointId The Id of the Checkpoint that the callback can operate
43
- * on.
44
- * @category Callback
45
- * @since v1.0.0
46
- */
47
- export type CheckpointCallback = (checkpointId: Id, label?: string) => void;
48
-
49
- /**
50
- * The CheckpointIdsListener type describes a function that is used to listen to
51
- * changes to the checkpoint Ids in a Checkpoints object.
52
- *
53
- * A CheckpointIdsListener is provided when using the addCheckpointIdsListener
54
- * method. See that method for specific examples.
55
- *
56
- * When called, a CheckpointIdsListener is given a reference to the Checkpoints
57
- * object.
58
- * @param checkpoints A reference to the Checkpoints object that changed.
59
- * @category Listener
60
- * @since v1.0.0
61
- */
62
- export type CheckpointIdsListener = (checkpoints: Checkpoints) => void;
63
-
64
- /**
65
- * The CheckpointListener type describes a function that is used to listen to
66
- * changes to a checkpoint's label in a Checkpoints object.
67
- *
68
- * A CheckpointListener is provided when using the addCheckpointListener method.
69
- * See that method for specific examples.
70
- *
71
- * When called, a CheckpointListener is given a reference to the Checkpoints
72
- * object, and the Id of the checkpoint whose label changed.
73
- * @param checkpoints A reference to the Checkpoints object that changed.
74
- * @param checkpointId The Id of the checkpoint that changed.
75
- * @category Listener
76
- * @since v1.0.0
77
- */
78
- export type CheckpointListener = (
79
- checkpoints: Checkpoints,
80
- checkpointId: Id,
81
- ) => void;
82
-
83
- /**
84
- * The CheckpointsListenerStats type describes the number of listeners
85
- * registered with the Checkpoints object, and can be used for debugging
86
- * purposes.
87
- *
88
- * A CheckpointsListenerStats object is returned from the getListenerStats
89
- * method.
90
- * @category Development
91
- * @since v1.0.0
92
- */
93
- export type CheckpointsListenerStats = {
94
- /**
95
- * The number of CheckpointIdsListener functions registered with the
96
- * Checkpoints object.
97
- * @category Stat
98
- * @since v1.0.0
99
- */
100
- checkpointIds: number;
101
- /**
102
- * The number of CheckpointListener functions registered with the Checkpoints
103
- * object.
104
- * @category Stat
105
- * @since v1.0.0
106
- */
107
- checkpoint: number;
108
- };
109
-
110
- /**
111
- * A Checkpoints object lets you set checkpoints on a Store, and move forward
112
- * and backward through them to create undo and redo functionality.
113
- *
114
- * Create a Checkpoints object easily with the createCheckpoints function. From
115
- * there, you can set checkpoints (with the addCheckpoint method), query the
116
- * checkpoints available (with the getCheckpointIds method), move forward and
117
- * backward through them (with the goBackward method, goForward method, and goTo
118
- * method), and add listeners for when the list checkpoints changes (with the
119
- * addCheckpointIdsListener method).
120
- *
121
- * Checkpoints work for both changes to tabular data and to keyed value data.
122
- *
123
- * Every checkpoint can be given a label which can be used to describe the
124
- * actions that changed the Store before this checkpoint. This can be useful for
125
- * interfaces that let users 'Undo [last action]'.
126
- * @example
127
- * This example shows a simple lifecycle of a Checkpoints object: from creation,
128
- * to adding a checkpoint, getting the list of available checkpoints, and then
129
- * registering and removing a listener for them.
130
- *
131
- * ```js
132
- * import {createCheckpoints, createStore} from 'tinybase';
133
- *
134
- * const store = createStore()
135
- * .setTables({pets: {fido: {sold: false}}})
136
- * .setValue('open', true);
137
- *
138
- * const checkpoints = createCheckpoints(store);
139
- * checkpoints.setSize(200);
140
- * console.log(checkpoints.getCheckpointIds());
141
- * // -> [[], '0', []]
142
- *
143
- * store.setCell('pets', 'fido', 'sold', true);
144
- * checkpoints.addCheckpoint('sale');
145
- * console.log(checkpoints.getCheckpointIds());
146
- * // -> [['0'], '1', []]
147
- *
148
- * checkpoints.goBackward();
149
- * console.log(store.getCell('pets', 'fido', 'sold'));
150
- * // -> false
151
- * console.log(checkpoints.getCheckpointIds());
152
- * // -> [[], '0', ['1']]
153
- *
154
- * store.setValue('open', false);
155
- * checkpoints.addCheckpoint('closed');
156
- * console.log(checkpoints.getCheckpointIds());
157
- * // -> [['0'], '2', []]
158
- *
159
- * checkpoints.goBackward();
160
- * console.log(store.getValue('open'));
161
- * // -> true
162
- * console.log(checkpoints.getCheckpointIds());
163
- * // -> [[], '0', ['2']]
164
- *
165
- * const listenerId = checkpoints.addCheckpointIdsListener(() => {
166
- * console.log(checkpoints.getCheckpointIds());
167
- * });
168
- * store.setCell('pets', 'fido', 'species', 'dog');
169
- * // -> [['0'], undefined, []]
170
- * checkpoints.addCheckpoint();
171
- * // -> [['0'], '3', []]
172
- * // Previous redo of checkpoints '1' and '2' are now not possible.
173
- *
174
- * checkpoints.delListener(listenerId);
175
- * ```
176
- * @see Using Checkpoints guide
177
- * @see Todo App demos
178
- * @see Drawing demo
179
- * @category Checkpoints
180
- * @since v1.0.0
181
- */
182
- export interface Checkpoints {
183
- //
184
- /**
185
- * The setSize method lets you specify how many checkpoints the Checkpoints
186
- * object will store.
187
- *
188
- * If you set more checkpoints than this size, the oldest checkpoints will be
189
- * pruned to make room for more recent ones.
190
- *
191
- * The default size for a newly-created Checkpoints object is 100.
192
- * @param size The number of checkpoints that this Checkpoints object should
193
- * hold.
194
- * @returns A reference to the Checkpoints object.
195
- * @example
196
- * This example creates a Store, adds a Checkpoints object, reduces the size
197
- * of the Checkpoints object dramatically and then creates more than that
198
- * number of checkpoints to demonstrate the oldest being pruned.
199
- *
200
- * ```js
201
- * import {createCheckpoints, createStore} from 'tinybase';
202
- *
203
- * const store = createStore().setTables({pets: {fido: {views: 0}}});
204
- *
205
- * const checkpoints = createCheckpoints(store);
206
- * checkpoints.setSize(2);
207
- * console.log(checkpoints.getCheckpointIds());
208
- * // -> [[], '0', []]
209
- *
210
- * store.setCell('pets', 'fido', 'views', 1);
211
- * checkpoints.addCheckpoint();
212
- * console.log(checkpoints.getCheckpointIds());
213
- * // -> [['0'], '1', []]
214
- *
215
- * store.setCell('pets', 'fido', 'views', 2);
216
- * checkpoints.addCheckpoint();
217
- * console.log(checkpoints.getCheckpointIds());
218
- * // -> [['0', '1'], '2', []]
219
- *
220
- * store.setCell('pets', 'fido', 'views', 3);
221
- * checkpoints.addCheckpoint();
222
- * console.log(checkpoints.getCheckpointIds());
223
- * // -> [['1', '2'], '3', []]
224
- * ```
225
- * @category Configuration
226
- * @since v1.0.0
227
- */
228
- setSize(size: number): Checkpoints;
229
-
230
- /**
231
- * The addCheckpoint method records a checkpoint of the Store into the
232
- * Checkpoints object that can be reverted to in the future.
233
- *
234
- * If no changes have been made to the Store since the last time a checkpoint
235
- * was made, this method will have no effect.
236
- *
237
- * The optional `label` parameter can be used to describe the actions that
238
- * changed the Store before this checkpoint. This can be useful for interfaces
239
- * that let users 'Undo [last action]'.
240
- * @param label An optional label to describe the actions leading up to this
241
- * checkpoint.
242
- * @returns The Id of the newly-created checkpoint.
243
- * @example
244
- * This example creates a Store, adds a Checkpoints object, and adds two
245
- * checkpoints, one with a label.
246
- *
247
- * ```js
248
- * import {createCheckpoints, createStore} from 'tinybase';
249
- *
250
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
251
- *
252
- * const checkpoints = createCheckpoints(store);
253
- * console.log(checkpoints.getCheckpointIds());
254
- * // -> [[], '0', []]
255
- *
256
- * store.setCell('pets', 'fido', 'species', 'dog');
257
- * const checkpointId1 = checkpoints.addCheckpoint();
258
- * console.log(checkpointId1);
259
- * // -> '1'
260
- *
261
- * console.log(checkpoints.getCheckpointIds());
262
- * // -> [['0'], '1', []]
263
- *
264
- * store.setCell('pets', 'fido', 'sold', true);
265
- * checkpoints.addCheckpoint('sale');
266
- * console.log(checkpoints.getCheckpointIds());
267
- * // -> [['0', '1'], '2', []]
268
- *
269
- * console.log(checkpoints.getCheckpoint('2'));
270
- * // -> 'sale'
271
- * ```
272
- * @category Setter
273
- * @since v1.0.0
274
- */
275
- addCheckpoint(label?: string): Id;
276
-
277
- /**
278
- * The setCheckpoint method updates the label for a checkpoint in the
279
- * Checkpoints object after it has been created.
280
- *
281
- * The `label` parameter can be used to describe the actions that changed the
282
- * Store before the given checkpoint. This can be useful for interfaces that
283
- * let users 'Undo [last action]'.
284
- *
285
- * Generally you will provide the `label` parameter when the addCheckpoint
286
- * method is called. Use this setCheckpoint method only when you need to
287
- * change the label at a later point.
288
- *
289
- * You cannot add a label to a checkpoint that does not yet exist.
290
- * @param checkpointId The Id of the checkpoint to set the label for.
291
- * @param label A label to describe the actions leading up to this checkpoint
292
- * or left undefined if you want to clear the current label.
293
- * @returns A reference to the Checkpoints object.
294
- * @example
295
- * This example creates a Store, adds a Checkpoints object, and sets two
296
- * checkpoints, one with a label, which are both then re-labelled.
297
- *
298
- * ```js
299
- * import {createCheckpoints, createStore} from 'tinybase';
300
- *
301
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
302
- *
303
- * const checkpoints = createCheckpoints(store);
304
- * console.log(checkpoints.getCheckpointIds());
305
- * // -> [[], '0', []]
306
- *
307
- * store.setCell('pets', 'fido', 'species', 'dog');
308
- * checkpoints.addCheckpoint();
309
- * store.setCell('pets', 'fido', 'sold', true);
310
- * checkpoints.addCheckpoint('sale');
311
- *
312
- * console.log(checkpoints.getCheckpoint('1'));
313
- * // -> ''
314
- * console.log(checkpoints.getCheckpoint('2'));
315
- * // -> 'sale'
316
- *
317
- * checkpoints.setCheckpoint('1', 'identified');
318
- * checkpoints.setCheckpoint('2', '');
319
- *
320
- * console.log(checkpoints.getCheckpoint('1'));
321
- * // -> 'identified'
322
- * console.log(checkpoints.getCheckpoint('2'));
323
- * // -> ''
324
- *
325
- * checkpoints.setCheckpoint('3', 'unknown');
326
- * console.log(checkpoints.getCheckpoint('3'));
327
- * // -> undefined
328
- * ```
329
- * @category Setter
330
- * @since v1.0.0
331
- */
332
- setCheckpoint(checkpointId: Id, label: string): Checkpoints;
333
-
334
- /**
335
- * The getStore method returns a reference to the underlying Store that is
336
- * backing this Checkpoints object.
337
- * @returns A reference to the Store.
338
- * @example
339
- * This example creates a Checkpoints object against a newly-created Store
340
- * and then gets its reference in order to update its data and set a
341
- * checkpoint.
342
- *
343
- * ```js
344
- * import {createCheckpoints, createStore} from 'tinybase';
345
- *
346
- * const checkpoints = createCheckpoints(createStore());
347
- * checkpoints.getStore().setCell('pets', 'fido', 'species', 'dog');
348
- * checkpoints.addCheckpoint();
349
- * console.log(checkpoints.getCheckpointIds());
350
- * // -> [['0'], '1', []]
351
- * ```
352
- * @category Getter
353
- * @since v1.0.0
354
- */
355
- getStore(): Store;
356
-
357
- /**
358
- * The getCheckpointIds method returns an array of the checkpoint Ids being
359
- * managed by this Checkpoints object.
360
- *
361
- * The returned CheckpointIds array contains 'backward' checkpoint Ids, the
362
- * current checkpoint Id (if present), and the 'forward' checkpointIds.
363
- * Together, these are sufficient to understand the state of the Checkpoints
364
- * object and what movement is possible backward or forward through the
365
- * checkpoint stack.
366
- * @returns A CheckpointIds array, containing the checkpoint Ids managed by
367
- * this Checkpoints object.
368
- * @example
369
- * This example creates a Store, adds a Checkpoints object, and then gets the
370
- * Ids of the checkpoints as it sets them and moves around the stack.
371
- *
372
- * ```js
373
- * import {createCheckpoints, createStore} from 'tinybase';
374
- *
375
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
376
- *
377
- * const checkpoints = createCheckpoints(store);
378
- * console.log(checkpoints.getCheckpointIds());
379
- * // -> [[], '0', []]
380
- *
381
- * store.setCell('pets', 'fido', 'sold', true);
382
- * checkpoints.addCheckpoint('sale');
383
- * console.log(checkpoints.getCheckpointIds());
384
- * // -> [['0'], '1', []]
385
- *
386
- * checkpoints.goBackward();
387
- * console.log(checkpoints.getCheckpointIds());
388
- * // -> [[], '0', ['1']]
389
- *
390
- * checkpoints.goForward();
391
- * console.log(checkpoints.getCheckpointIds());
392
- * // -> [['0'], '1', []]
393
- * ```
394
- * @category Getter
395
- * @since v1.0.0
396
- */
397
- getCheckpointIds(): CheckpointIds;
398
-
399
- /**
400
- * The forEachCheckpoint method takes a function that it will then call for
401
- * each Checkpoint in a specified Checkpoints object.
402
- *
403
- * This method is useful for iterating over the structure of the Checkpoints
404
- * object in a functional style. The `checkpointCallback` parameter is a
405
- * CheckpointCallback function that will be called with the Id of each
406
- * Checkpoint.
407
- * @param checkpointCallback The function that should be called for every
408
- * Checkpoint.
409
- * @example
410
- * This example iterates over each Checkpoint in a Checkpoints object.
411
- *
412
- * ```js
413
- * import {createCheckpoints, createStore} from 'tinybase';
414
- *
415
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
416
- * const checkpoints = createCheckpoints(store);
417
- * store.setCell('pets', 'fido', 'sold', true);
418
- * checkpoints.addCheckpoint('sale');
419
- *
420
- * checkpoints.forEachCheckpoint((checkpointId, label) => {
421
- * console.log(`${checkpointId}:${label}`);
422
- * });
423
- * // -> '0:'
424
- * // -> '1:sale'
425
- * ```
426
- * @category Iterator
427
- * @since v1.0.0
428
- */
429
- forEachCheckpoint(checkpointCallback: CheckpointCallback): void;
430
-
431
- /**
432
- * The hasCheckpoint method returns a boolean indicating whether a given
433
- * Checkpoint exists in the Checkpoints object.
434
- * @param checkpointId The Id of a possible Checkpoint in the Checkpoints
435
- * object.
436
- * @returns Whether a Checkpoint with that Id exists.
437
- * @example
438
- * This example shows two simple Checkpoint existence checks.
439
- *
440
- * ```js
441
- * import {createCheckpoints, createStore} from 'tinybase';
442
- *
443
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
444
- * const checkpoints = createCheckpoints(store);
445
- * console.log(checkpoints.hasCheckpoint('0'));
446
- * // -> true
447
- * console.log(checkpoints.hasCheckpoint('1'));
448
- * // -> false
449
- * ```
450
- * @category Getter
451
- * @since v1.0.0
452
- */
453
- hasCheckpoint(checkpointId: Id): boolean;
454
-
455
- /**
456
- * The getCheckpoint method fetches the label for a checkpoint, if it had been
457
- * provided at the time of the addCheckpoint method or set subsequently with
458
- * the setCheckpoint method.
459
- *
460
- * If the checkpoint has had no label provided, this method will return an
461
- * empty string.
462
- * @param checkpointId The Id of the checkpoint to get the label for.
463
- * @returns A string label for the requested checkpoint, an empty string if it
464
- * was never set, or `undefined` if the checkpoint does not exist.
465
- * @example
466
- * This example creates a Store, adds a Checkpoints object, and sets a
467
- * checkpoint with a label, before retrieving it again.
468
- *
469
- * ```js
470
- * import {createCheckpoints, createStore} from 'tinybase';
471
- *
472
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
473
- *
474
- * const checkpoints = createCheckpoints(store);
475
- * store.setCell('pets', 'fido', 'sold', true);
476
- * console.log(checkpoints.addCheckpoint('sale'));
477
- * // -> '1'
478
- *
479
- * console.log(checkpoints.getCheckpoint('1'));
480
- * // -> 'sale'
481
- * ```
482
- * @example
483
- * This example creates a Store, adds a Checkpoints object, and sets a
484
- * checkpoint without a label, setting it subsequently. A non-existent
485
- * checkpoint return an `undefined` label.
486
- *
487
- * ```js
488
- * import {createCheckpoints, createStore} from 'tinybase';
489
- *
490
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
491
- *
492
- * const checkpoints = createCheckpoints(store);
493
- * store.setCell('pets', 'fido', 'sold', true);
494
- * checkpoints.addCheckpoint();
495
- * console.log(checkpoints.getCheckpoint('1'));
496
- * // -> ''
497
- *
498
- * checkpoints.setCheckpoint('1', 'sold');
499
- * console.log(checkpoints.getCheckpoint('1'));
500
- * // -> 'sold'
501
- *
502
- * console.log(checkpoints.getCheckpoint('2'));
503
- * // -> undefined
504
- * ```
505
- * @category Getter
506
- * @since v1.0.0
507
- */
508
- getCheckpoint(checkpointId: Id): string | undefined;
509
-
510
- /**
511
- * The addCheckpointIdsListener method registers a listener function with the
512
- * Checkpoints object that will be called whenever its set of checkpoints
513
- * changes.
514
- *
515
- * The provided listener is a CheckpointIdsListener function, and will be
516
- * called with a reference to the Checkpoints object.
517
- * @param listener The function that will be called whenever the checkpoints
518
- * change.
519
- * @returns A unique Id for the listener that can later be used to remove it.
520
- * @example
521
- * This example creates a Store, a Checkpoints object, and then registers a
522
- * listener that responds to any changes to the checkpoints.
523
- *
524
- * ```js
525
- * import {createCheckpoints, createStore} from 'tinybase';
526
- *
527
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
528
- *
529
- * const checkpoints = createCheckpoints(store);
530
- * console.log(checkpoints.getCheckpointIds());
531
- * // -> [[], '0', []]
532
- *
533
- * const listenerId = checkpoints.addCheckpointIdsListener(() => {
534
- * console.log('Checkpoint Ids changed');
535
- * console.log(checkpoints.getCheckpointIds());
536
- * });
537
- *
538
- * store.setCell('pets', 'fido', 'species', 'dog');
539
- * // -> 'Checkpoint Ids changed'
540
- * // -> [['0'], undefined, []]
541
- *
542
- * checkpoints.addCheckpoint();
543
- * // -> 'Checkpoint Ids changed'
544
- * // -> [['0'], '1', []]
545
- *
546
- * checkpoints.goBackward();
547
- * // -> 'Checkpoint Ids changed'
548
- * // -> [[], '0', ['1']]
549
- *
550
- * checkpoints.goForward();
551
- * // -> 'Checkpoint Ids changed'
552
- * // -> [['0'], '1', []]
553
- *
554
- * checkpoints.delListener(listenerId);
555
- * ```
556
- * @category Listener
557
- * @since v1.0.0
558
- */
559
- addCheckpointIdsListener(listener: CheckpointIdsListener): Id;
560
-
561
- /**
562
- * The addCheckpointListener method registers a listener function with the
563
- * Checkpoints object that will be called whenever the label of a checkpoint
564
- * changes.
565
- *
566
- * You can either listen to a single checkpoint label (by specifying the
567
- * checkpoint Id as the method's first parameter), or changes to any
568
- * checkpoint label (by providing a `null` wildcard).
569
- *
570
- * The provided listener is a CheckpointListener function, and will be called
571
- * with a reference to the Checkpoints object, and the Id of the checkpoint
572
- * whose label changed.
573
- * @param checkpointId The Id of the checkpoint to listen to, or `null` as a
574
- * wildcard.
575
- * @param listener The function that will be called whenever the checkpoint
576
- * label changes.
577
- * @returns A unique Id for the listener that can later be used to remove it.
578
- * @example
579
- * This example creates a Store, a Checkpoints object, and then registers a
580
- * listener that responds to any changes to a specific checkpoint label,
581
- * including when the checkpoint no longer exists.
582
- *
583
- * ```js
584
- * import {createCheckpoints, createStore} from 'tinybase';
585
- *
586
- * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
587
- *
588
- * const checkpoints = createCheckpoints(store);
589
- * console.log(checkpoints.getCheckpointIds());
590
- * // -> [[], '0', []]
591
- *
592
- * const listenerId = checkpoints.addCheckpointListener('1', () => {
593
- * console.log('Checkpoint 1 label changed');
594
- * console.log(checkpoints.getCheckpoint('1'));
595
- * });
596
- *
597
- * store.setCell('pets', 'fido', 'sold', true);
598
- * checkpoints.addCheckpoint('sale');
599
- * // -> 'Checkpoint 1 label changed'
600
- * // -> 'sale'
601
- *
602
- * checkpoints.setCheckpoint('1', 'sold');
603
- * // -> 'Checkpoint 1 label changed'
604
- * // -> 'sold'
605
- *
606
- * checkpoints.setCheckpoint('1', 'sold');
607
- * // The listener is not called when the label does not change.
608
- *
609
- * checkpoints.goTo('0');
610
- * store.setCell('pets', 'fido', 'sold', false);
611
- * // -> 'Checkpoint 1 label changed'
612
- * // -> undefined
613
- * // The checkpoint no longer exists.
614
- *
615
- * checkpoints.delListener(listenerId);
616
- * ```
617
- * @category Listener
618
- * @since v1.0.0
619
- */
620
- addCheckpointListener(
621
- checkpointId: IdOrNull,
622
- listener: CheckpointListener,
623
- ): Id;
624
-
625
- /**
626
- * The delListener method removes a listener that was previously added to the
627
- * Checkpoints object.
628
- *
629
- * Use the Id returned by the addCheckpointIdsListener method. Note that the
630
- * Checkpoints object may re-use this Id for future listeners added to it.
631
- * @param listenerId The Id of the listener to remove.
632
- * @returns A reference to the Checkpoints object.
633
- * @example
634
- * This example creates a Store, a Checkpoints object, registers a listener,
635
- * and then removes it.
636
- *
637
- * ```js
638
- * import {createCheckpoints, createStore} from 'tinybase';
639
- *
640
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
641
- *
642
- * const checkpoints = createCheckpoints(store);
643
- * console.log(checkpoints.getCheckpointIds());
644
- * // -> [[], '0', []]
645
- *
646
- * const listenerId = checkpoints.addCheckpointIdsListener(() => {
647
- * console.log('checkpoints changed');
648
- * });
649
- *
650
- * store.setCell('pets', 'fido', 'species', 'dog');
651
- * // -> 'checkpoints changed'
652
- *
653
- * checkpoints.addCheckpoint();
654
- * // -> 'checkpoints changed'
655
- *
656
- * checkpoints.delListener(listenerId);
657
- *
658
- * store.setCell('pets', 'fido', 'sold', 'true');
659
- * // -> undefined
660
- * // The listener is not called.
661
- * ```
662
- * @category Listener
663
- * @since v1.0.0
664
- */
665
- delListener(listenerId: Id): Checkpoints;
666
-
667
- /**
668
- * The goBackward method moves the state of the underlying Store back to the
669
- * previous checkpoint, effectively performing an 'undo' on the Store data.
670
- *
671
- * If there is no previous checkpoint to return to, this method has no effect.
672
- * @returns A reference to the Checkpoints object.
673
- * @example
674
- * This example creates a Store, a Checkpoints object, makes a change and then
675
- * goes backward to the state of the Store before the change.
676
- *
677
- * ```js
678
- * import {createCheckpoints, createStore} from 'tinybase';
679
- *
680
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
681
- *
682
- * const checkpoints = createCheckpoints(store);
683
- * console.log(checkpoints.getCheckpointIds());
684
- * // -> [[], '0', []]
685
- *
686
- * store.setCell('pets', 'fido', 'sold', true);
687
- * checkpoints.addCheckpoint('sale');
688
- * console.log(checkpoints.getCheckpointIds());
689
- * // -> [['0'], '1', []]
690
- *
691
- * checkpoints.goBackward();
692
- * console.log(store.getCell('pets', 'fido', 'sold'));
693
- * // -> false
694
- * console.log(checkpoints.getCheckpointIds());
695
- * // -> [[], '0', ['1']]
696
- * ```
697
- * @category Movement
698
- * @since v1.0.0
699
- */
700
- goBackward(): Checkpoints;
701
-
702
- /**
703
- * The goForward method moves the state of the underlying Store forwards to a
704
- * future checkpoint, effectively performing an 'redo' on the Store data.
705
- *
706
- * If there is no future checkpoint to return to, this method has no effect.
707
- *
708
- * Note that if you have previously used the goBackward method to undo
709
- * changes, the forwards 'redo' stack will only exist while you do not make
710
- * changes to the Store. In general the goForward method is expected to be
711
- * used to redo changes that were just undone.
712
- * @returns A reference to the Checkpoints object.
713
- * @example
714
- * This example creates a Store, a Checkpoints object, makes a change and then
715
- * goes backward to the state of the Store before the change. It then goes
716
- * forward again to restore the state with the changes.
717
- *
718
- * ```js
719
- * import {createCheckpoints, createStore} from 'tinybase';
720
- *
721
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
722
- *
723
- * const checkpoints = createCheckpoints(store);
724
- * console.log(checkpoints.getCheckpointIds());
725
- * // -> [[], '0', []]
726
- *
727
- * store.setCell('pets', 'fido', 'sold', true);
728
- * checkpoints.addCheckpoint('sale');
729
- * console.log(checkpoints.getCheckpointIds());
730
- * // -> [['0'], '1', []]
731
- *
732
- * checkpoints.goBackward();
733
- * console.log(store.getCell('pets', 'fido', 'sold'));
734
- * // -> false
735
- * console.log(checkpoints.getCheckpointIds());
736
- * // -> [[], '0', ['1']]
737
- *
738
- * checkpoints.goForward();
739
- * console.log(store.getCell('pets', 'fido', 'sold'));
740
- * // -> true
741
- * console.log(checkpoints.getCheckpointIds());
742
- * // -> [['0'], '1', []]
743
- * ```
744
- * @example
745
- * This example creates a Store, a Checkpoints object, makes a change and then
746
- * goes backward to the state of the Store before the change. It makes a new
747
- * change, the redo stack disappears, and then the attempt to forward again
748
- * has no effect.
749
- *
750
- * ```js
751
- * import {createCheckpoints, createStore} from 'tinybase';
752
- *
753
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
754
- *
755
- * const checkpoints = createCheckpoints(store);
756
- * console.log(checkpoints.getCheckpointIds());
757
- * // -> [[], '0', []]
758
- *
759
- * store.setCell('pets', 'fido', 'sold', true);
760
- * checkpoints.addCheckpoint('sale');
761
- * console.log(checkpoints.getCheckpointIds());
762
- * // -> [['0'], '1', []]
763
- *
764
- * checkpoints.goBackward();
765
- * console.log(store.getCell('pets', 'fido', 'sold'));
766
- * // -> false
767
- * console.log(checkpoints.getCheckpointIds());
768
- * // -> [[], '0', ['1']]
769
- *
770
- * store.setCell('pets', 'fido', 'color', 'brown');
771
- * console.log(checkpoints.getCheckpointIds());
772
- * // -> [['0'], undefined, []]
773
- *
774
- * checkpoints.goForward();
775
- * console.log(store.getCell('pets', 'fido', 'sold'));
776
- * // -> false
777
- * console.log(checkpoints.getCheckpointIds());
778
- * // -> [['0'], undefined, []]
779
- * // The original change cannot be redone.
780
- * ```
781
- * @category Movement
782
- * @since v1.0.0
783
- */
784
- goForward(): Checkpoints;
785
-
786
- /**
787
- * The goTo method moves the state of the underlying Store backwards or
788
- * forwards to a specified checkpoint.
789
- *
790
- * If there is no checkpoint with the Id specified, this method has no effect.
791
- * @param checkpointId The Id of the checkpoint to move to.
792
- * @returns A reference to the Checkpoints object.
793
- * @example
794
- * This example creates a Store, a Checkpoints object, makes two changes and
795
- * then goes directly to the state of the Store before the two changes. It
796
- * then goes forward again one change, also using the goTo method. Finally it
797
- * tries to go to a checkpoint that does not exist.
798
- *
799
- * ```js
800
- * import {createCheckpoints, createStore} from 'tinybase';
801
- *
802
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
803
- *
804
- * const checkpoints = createCheckpoints(store);
805
- * console.log(checkpoints.getCheckpointIds());
806
- * // -> [[], '0', []]
807
- *
808
- * store.setCell('pets', 'fido', 'color', 'brown');
809
- * checkpoints.addCheckpoint('identification');
810
- * store.setCell('pets', 'fido', 'sold', true);
811
- * checkpoints.addCheckpoint('sale');
812
- * console.log(checkpoints.getCheckpointIds());
813
- * // -> [['0', '1'], '2', []]
814
- *
815
- * checkpoints.goTo('0');
816
- * console.log(store.getTables());
817
- * // -> {pets: {fido: {sold: false}}}
818
- * console.log(checkpoints.getCheckpointIds());
819
- * // -> [[], '0', ['1', '2']]
820
- *
821
- * checkpoints.goTo('1');
822
- * console.log(store.getTables());
823
- * // -> {pets: {fido: {sold: false, color: 'brown'}}}
824
- * console.log(checkpoints.getCheckpointIds());
825
- * // -> [['0'], '1', ['2']]
826
- *
827
- * checkpoints.goTo('3');
828
- * console.log(store.getTables());
829
- * // -> {pets: {fido: {sold: false, color: 'brown'}}}
830
- * console.log(checkpoints.getCheckpointIds());
831
- * // -> [['0'], '1', ['2']]
832
- * ```
833
- * @category Movement
834
- * @since v1.0.0
835
- */
836
- goTo(checkpointId: Id): Checkpoints;
837
-
838
- /**
839
- * The clear method resets this Checkpoints object to its initial state,
840
- * removing all the checkpoints it has been managing.
841
- *
842
- * Obviously this method should be used with caution as it destroys the
843
- * ability to undo or redo recent changes to the Store (though of course the
844
- * Store itself is not reset by this method).
845
- *
846
- * This method can be useful when a Store is being loaded via a Persister
847
- * asynchronously after the Checkpoints object has been attached, and you
848
- * don't want users to be able to undo the initial load of the data. In this
849
- * case you could call the clear method immediately after the initial load so
850
- * that that is the baseline from which all subsequent changes are tracked.
851
- * @returns A reference to the Checkpoints object.
852
- * @example
853
- * This example creates a Store, a Checkpoints object, adds a listener, makes
854
- * a change and then clears the checkpoints.
855
- *
856
- * ```js
857
- * import {createCheckpoints, createStore} from 'tinybase';
858
- *
859
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
860
- *
861
- * const checkpoints = createCheckpoints(store);
862
- * console.log(checkpoints.getCheckpointIds());
863
- * // -> [[], '0', []]
864
- *
865
- * const listenerId = checkpoints.addCheckpointIdsListener(() => {
866
- * console.log('checkpoints changed');
867
- * });
868
- *
869
- * store.setCell('pets', 'fido', 'color', 'brown');
870
- * // -> 'checkpoints changed'
871
- * checkpoints.addCheckpoint();
872
- * // -> 'checkpoints changed'
873
- * store.setCell('pets', 'fido', 'sold', true);
874
- * // -> 'checkpoints changed'
875
- * checkpoints.addCheckpoint();
876
- * // -> 'checkpoints changed'
877
- *
878
- * console.log(store.getTables());
879
- * // -> {pets: {fido: {sold: true, color: 'brown'}}}
880
- * console.log(checkpoints.getCheckpointIds());
881
- * // -> [['0', '1'], '2', []]
882
- *
883
- * checkpoints.clear();
884
- * // -> 'checkpoints changed'
885
- *
886
- * console.log(store.getTables());
887
- * // -> {pets: {fido: {sold: true, color: 'brown'}}}
888
- * console.log(checkpoints.getCheckpointIds());
889
- * // -> [[], '0', []]
890
- *
891
- * checkpoints.delListener(listenerId);
892
- * ```
893
- * @category Lifecycle
894
- * @since v1.0.0
895
- */
896
- clear(): Checkpoints;
897
-
898
- /**
899
- * The clearForward method resets just the 'redo' checkpoints it has been
900
- * managing.
901
- *
902
- * Obviously this method should be used with caution as it destroys the
903
- * ability to redo recent changes to the Store (though of course the Store
904
- * itself is not reset by this method).
905
- *
906
- * This method can be useful when you want to prohibit a user from redoing
907
- * changes they have undone. The 'backward' redo stack, and current checkpoint
908
- * are not affected.
909
- * @returns A reference to the Checkpoints object.
910
- * @example
911
- * This example creates a Store, a Checkpoints object, adds a listener, makes
912
- * a change and then clears the forward checkpoints.
913
- *
914
- * ```js
915
- * import {createCheckpoints, createStore} from 'tinybase';
916
- *
917
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
918
- *
919
- * const checkpoints = createCheckpoints(store);
920
- * console.log(checkpoints.getCheckpointIds());
921
- * // -> [[], '0', []]
922
- *
923
- * const listenerId = checkpoints.addCheckpointIdsListener(() => {
924
- * console.log('checkpoints changed');
925
- * });
926
- *
927
- * store.setCell('pets', 'fido', 'color', 'brown');
928
- * // -> 'checkpoints changed'
929
- * checkpoints.addCheckpoint();
930
- * // -> 'checkpoints changed'
931
- * store.setCell('pets', 'fido', 'sold', true);
932
- * // -> 'checkpoints changed'
933
- * checkpoints.addCheckpoint();
934
- * // -> 'checkpoints changed'
935
- * checkpoints.goBackward();
936
- * // -> 'checkpoints changed'
937
- *
938
- * console.log(store.getTables());
939
- * // -> {pets: {fido: {color: 'brown', sold: false}}}
940
- * console.log(checkpoints.getCheckpointIds());
941
- * // -> [['0'], '1', ['2']]
942
- *
943
- * checkpoints.clearForward();
944
- * // -> 'checkpoints changed'
945
- *
946
- * console.log(checkpoints.getCheckpointIds());
947
- * // -> [['0'], '1', []]
948
- *
949
- * checkpoints.delListener(listenerId);
950
- * ```
951
- * @category Lifecycle
952
- * @since v4.5.3
953
- */
954
- clearForward(): Checkpoints;
955
-
956
- /**
957
- * The destroy method should be called when this Checkpoints object is no
958
- * longer used.
959
- *
960
- * This guarantees that all of the listeners that the object registered with
961
- * the underlying Store are removed and it can be correctly garbage collected.
962
- * @example
963
- * This example creates a Store, adds a Checkpoints object (that registers a
964
- * CellListener with the underlying Store), and then destroys it again,
965
- * removing the listener.
966
- *
967
- * ```js
968
- * import {createCheckpoints, createStore} from 'tinybase';
969
- *
970
- * const store = createStore().setTables({pets: {fido: {sold: false}}});
971
- *
972
- * const checkpoints = createCheckpoints(store);
973
- * console.log(store.getListenerStats().cell);
974
- * // -> 1
975
- *
976
- * checkpoints.destroy();
977
- *
978
- * console.log(store.getListenerStats().cell);
979
- * // -> 0
980
- * ```
981
- * @category Lifecycle
982
- * @since v1.0.0
983
- */
984
- destroy(): void;
985
-
986
- /**
987
- * The getListenerStats method provides a set of statistics about the
988
- * listeners registered with the Checkpoints object, and is used for debugging
989
- * purposes.
990
- *
991
- * The CheckpointsListenerStats object contains a breakdown of the different
992
- * types of listener.
993
- *
994
- * The method is intended to be used during development to ensure your
995
- * application is not leaking listener registrations, for example.
996
- * @returns A CheckpointsListenerStats object containing Checkpoints listener
997
- * statistics.
998
- * @example
999
- * This example gets the listener statistics of a Checkpoints object.
1000
- *
1001
- * ```js
1002
- * import {createCheckpoints, createStore} from 'tinybase';
1003
- *
1004
- * const store = createStore();
1005
- * const checkpoints = createCheckpoints(store);
1006
- * checkpoints.addCheckpointIdsListener(() => {
1007
- * console.log('Checkpoint Ids changed');
1008
- * });
1009
- * checkpoints.addCheckpointListener(null, () => {
1010
- * console.log('Checkpoint label changed');
1011
- * });
1012
- *
1013
- * console.log(checkpoints.getListenerStats());
1014
- * // -> {checkpointIds: 1, checkpoint: 1}
1015
- * ```
1016
- * @category Development
1017
- * @since v1.0.0
1018
- */
1019
- getListenerStats(): CheckpointsListenerStats;
1020
- //
1021
- }
1022
-
1023
- /**
1024
- * The createCheckpoints function creates a Checkpoints object, and is the main
1025
- * entry point into the checkpoints module.
1026
- *
1027
- * A given Store can only have one Checkpoints object associated with it. If you
1028
- * call this function twice on the same Store, your second call will return a
1029
- * reference to the Checkpoints object created by the first.
1030
- * @param store The Store for which to set Checkpoints.
1031
- * @returns A reference to the new Checkpoints object.
1032
- * @example
1033
- * This example creates a Checkpoints object.
1034
- *
1035
- * ```js
1036
- * import {createCheckpoints, createStore} from 'tinybase';
1037
- *
1038
- * const store = createStore();
1039
- * const checkpoints = createCheckpoints(store);
1040
- * console.log(checkpoints.getCheckpointIds());
1041
- * // -> [[], '0', []]
1042
- * ```
1043
- * @example
1044
- * This example creates a Checkpoints object, and calls the method a second
1045
- * time for the same Store to return the same object.
1046
- *
1047
- * ```js
1048
- * import {createCheckpoints, createStore} from 'tinybase';
1049
- *
1050
- * const store = createStore();
1051
- * const checkpoints1 = createCheckpoints(store);
1052
- * const checkpoints2 = createCheckpoints(store);
1053
- * console.log(checkpoints1 === checkpoints2);
1054
- * // -> true
1055
- * ```
1056
- * @category Creation
1057
- * @since v1.0.0
1058
- */
1059
- export function createCheckpoints(store: Store): Checkpoints;