tinybase 6.4.2 → 6.5.1

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 (51) hide show
  1. package/@types/omni/index.d.ts +1 -0
  2. package/@types/omni/with-schemas/index.d.ts +1 -0
  3. package/@types/persisters/index.d.ts +1 -0
  4. package/@types/persisters/persister-react-native-mmkv/index.d.ts +118 -0
  5. package/@types/persisters/persister-react-native-mmkv/with-schemas/index.d.ts +132 -0
  6. package/@types/persisters/with-schemas/index.d.ts +1 -0
  7. package/common/index.js +1 -1
  8. package/common/with-schemas/index.js +1 -1
  9. package/index.js +1 -1
  10. package/mergeable-store/index.js +1 -1
  11. package/mergeable-store/with-schemas/index.js +1 -1
  12. package/min/index.js +1 -1
  13. package/min/index.js.gz +0 -0
  14. package/min/mergeable-store/index.js +1 -1
  15. package/min/mergeable-store/index.js.gz +0 -0
  16. package/min/mergeable-store/with-schemas/index.js +1 -1
  17. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  18. package/min/omni/index.js +1 -1
  19. package/min/omni/index.js.gz +0 -0
  20. package/min/omni/with-schemas/index.js +1 -1
  21. package/min/omni/with-schemas/index.js.gz +0 -0
  22. package/min/persisters/persister-react-native-mmkv/index.js +1 -0
  23. package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
  24. package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -0
  25. package/min/persisters/persister-react-native-mmkv/with-schemas/index.js.gz +0 -0
  26. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  27. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  28. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  29. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  30. package/min/with-schemas/index.js +1 -1
  31. package/min/with-schemas/index.js.gz +0 -0
  32. package/omni/index.js +48 -4
  33. package/omni/with-schemas/index.js +48 -4
  34. package/package.json +44 -4
  35. package/persisters/persister-react-native-mmkv/index.js +459 -0
  36. package/persisters/persister-react-native-mmkv/with-schemas/index.js +459 -0
  37. package/readme.md +1 -1
  38. package/releases.md +16 -1
  39. package/synchronizers/index.js +1 -1
  40. package/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
  41. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
  42. package/synchronizers/synchronizer-local/index.js +1 -1
  43. package/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  44. package/synchronizers/synchronizer-ws-client/index.js +1 -1
  45. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  46. package/synchronizers/synchronizer-ws-server/index.js +1 -1
  47. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  48. package/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  49. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  50. package/synchronizers/with-schemas/index.js +1 -1
  51. package/with-schemas/index.js +1 -1
@@ -0,0 +1,459 @@
1
+ const EMPTY_STRING = '';
2
+
3
+ const isUndefined = (thing) => thing == void 0;
4
+ const ifNotUndefined = (value, then, otherwise) =>
5
+ isUndefined(value) ? otherwise?.() : then(value);
6
+ const isArray = (thing) => Array.isArray(thing);
7
+ const size = (arrayOrString) => arrayOrString.length;
8
+ const test = (regex, subject) => regex.test(subject);
9
+ const errorNew = (message) => {
10
+ throw new Error(message);
11
+ };
12
+ const tryCatch = async (action, then1, then2) => {
13
+ try {
14
+ return await action();
15
+ } catch (error) {
16
+ /* istanbul ignore next */
17
+ then1?.(error);
18
+ }
19
+ };
20
+
21
+ const arrayForEach = (array, cb) => array.forEach(cb);
22
+ const arrayClear = (array, to) => array.splice(0, to);
23
+ const arrayPush = (array, ...values) => array.push(...values);
24
+ const arrayShift = (array) => array.shift();
25
+
26
+ const collSize = (coll) => coll?.size ?? 0;
27
+ const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
28
+ const collIsEmpty = (coll) => isUndefined(coll) || collSize(coll) == 0;
29
+ const collForEach = (coll, cb) => coll?.forEach(cb);
30
+ const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
31
+
32
+ const object = Object;
33
+ const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
34
+ const isObject = (obj) =>
35
+ !isUndefined(obj) &&
36
+ ifNotUndefined(
37
+ getPrototypeOf(obj),
38
+ (objPrototype) =>
39
+ objPrototype == object.prototype ||
40
+ isUndefined(getPrototypeOf(objPrototype)),
41
+
42
+ /* istanbul ignore next */
43
+ () => true,
44
+ );
45
+ const objIds = object.keys;
46
+ const objFreeze = object.freeze;
47
+ const objSize = (obj) => size(objIds(obj));
48
+ const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
49
+
50
+ const mapNew = (entries) => new Map(entries);
51
+ const mapGet = (map, key) => map?.get(key);
52
+ const mapSet = (map, key, value) =>
53
+ isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
54
+ const mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {
55
+ if (!collHas(map, key)) {
56
+ mapSet(map, key, getDefaultValue());
57
+ } else {
58
+ hadExistingValue?.(mapGet(map, key));
59
+ }
60
+ return mapGet(map, key);
61
+ };
62
+ const visitTree = (node, path, ensureLeaf, pruneLeaf, p = 0) =>
63
+ ifNotUndefined(
64
+ (ensureLeaf ? mapEnsure : mapGet)(
65
+ node,
66
+ path[p],
67
+ p > size(path) - 2 ? ensureLeaf : mapNew,
68
+ ),
69
+ (nodeOrLeaf) => {
70
+ if (p > size(path) - 2) {
71
+ if (pruneLeaf?.(nodeOrLeaf)) {
72
+ mapSet(node, path[p]);
73
+ }
74
+ return nodeOrLeaf;
75
+ }
76
+ const leaf = visitTree(nodeOrLeaf, path, ensureLeaf, pruneLeaf, p + 1);
77
+ if (collIsEmpty(nodeOrLeaf)) {
78
+ mapSet(node, path[p]);
79
+ }
80
+ return leaf;
81
+ },
82
+ );
83
+
84
+ const INTEGER = /^\d+$/;
85
+ const getPoolFunctions = () => {
86
+ const pool = [];
87
+ let nextId = 0;
88
+ return [
89
+ (reuse) => (reuse ? arrayShift(pool) : null) ?? EMPTY_STRING + nextId++,
90
+ (id) => {
91
+ if (test(INTEGER, id) && size(pool) < 1e3) {
92
+ arrayPush(pool, id);
93
+ }
94
+ },
95
+ ];
96
+ };
97
+
98
+ const setNew = (entryOrEntries) =>
99
+ new Set(
100
+ isArray(entryOrEntries) || isUndefined(entryOrEntries)
101
+ ? entryOrEntries
102
+ : [entryOrEntries],
103
+ );
104
+ const setAdd = (set, value) => set?.add(value);
105
+
106
+ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
107
+ const leaves = [];
108
+ const deep = (node, p) =>
109
+ p == size(path)
110
+ ? arrayPush(leaves, node)
111
+ : path[p] === null
112
+ ? collForEach(node, (node2) => deep(node2, p + 1))
113
+ : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
114
+ deep(deepIdSet, 0);
115
+ return leaves;
116
+ };
117
+ const getListenerFunctions = (getThing) => {
118
+ let thing;
119
+ const [getId, releaseId] = getPoolFunctions();
120
+ const allListeners = mapNew();
121
+ const addListener = (
122
+ listener,
123
+ idSetNode,
124
+ path,
125
+ pathGetters = [],
126
+ extraArgsGetter = () => [],
127
+ ) => {
128
+ thing ??= getThing();
129
+ const id = getId(1);
130
+ mapSet(allListeners, id, [
131
+ listener,
132
+ idSetNode,
133
+ path,
134
+ pathGetters,
135
+ extraArgsGetter,
136
+ ]);
137
+ setAdd(visitTree(idSetNode, path ?? [EMPTY_STRING], setNew), id);
138
+ return id;
139
+ };
140
+ const callListeners = (idSetNode, ids, ...extraArgs) =>
141
+ arrayForEach(getWildcardedLeaves(idSetNode, ids), (set) =>
142
+ collForEach(set, (id) =>
143
+ mapGet(allListeners, id)[0](thing, ...(ids ?? []), ...extraArgs),
144
+ ),
145
+ );
146
+ const delListener = (id) =>
147
+ ifNotUndefined(mapGet(allListeners, id), ([, idSetNode, idOrNulls]) => {
148
+ visitTree(idSetNode, idOrNulls ?? [EMPTY_STRING], void 0, (idSet) => {
149
+ collDel(idSet, id);
150
+ return collIsEmpty(idSet) ? 1 : 0;
151
+ });
152
+ mapSet(allListeners, id);
153
+ releaseId(id);
154
+ return idOrNulls;
155
+ });
156
+ const callListener = (id) =>
157
+ ifNotUndefined(
158
+ mapGet(allListeners, id),
159
+ ([listener, , path = [], pathGetters, extraArgsGetter]) => {
160
+ const callWithIds = (...ids) => {
161
+ const index = size(ids);
162
+ if (index == size(path)) {
163
+ listener(thing, ...ids, ...extraArgsGetter(ids));
164
+ } else if (isUndefined(path[index])) {
165
+ arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
166
+ callWithIds(...ids, id2),
167
+ );
168
+ } else {
169
+ callWithIds(...ids, path[index]);
170
+ }
171
+ };
172
+ callWithIds();
173
+ },
174
+ );
175
+ return [addListener, callListeners, delListener, callListener];
176
+ };
177
+
178
+ const scheduleRunning = mapNew();
179
+ const scheduleActions = mapNew();
180
+ const getStoreFunctions = (
181
+ persist = 1 /* StoreOnly */,
182
+ store,
183
+ isSynchronizer,
184
+ ) =>
185
+ persist != 1 /* StoreOnly */ && store.isMergeable()
186
+ ? [
187
+ 1,
188
+ store.getMergeableContent,
189
+ () => store.getTransactionMergeableChanges(!isSynchronizer),
190
+ ([[changedTables], [changedValues]]) =>
191
+ !objIsEmpty(changedTables) || !objIsEmpty(changedValues),
192
+ store.setDefaultContent,
193
+ ]
194
+ : persist != 2 /* MergeableStoreOnly */
195
+ ? [
196
+ 0,
197
+ store.getContent,
198
+ store.getTransactionChanges,
199
+ ([changedTables, changedValues]) =>
200
+ !objIsEmpty(changedTables) || !objIsEmpty(changedValues),
201
+ store.setContent,
202
+ ]
203
+ : errorNew('Store type not supported by this Persister');
204
+ const createCustomPersister = (
205
+ store,
206
+ getPersisted,
207
+ setPersisted,
208
+ addPersisterListener,
209
+ delPersisterListener,
210
+ onIgnoredError,
211
+ persist,
212
+ extra = {},
213
+ isSynchronizer = 0,
214
+ scheduleId = [],
215
+ ) => {
216
+ let status = 0; /* Idle */
217
+ let loads = 0;
218
+ let saves = 0;
219
+ let action;
220
+ let autoLoadHandle;
221
+ let autoSaveListenerId;
222
+ mapEnsure(scheduleRunning, scheduleId, () => 0);
223
+ mapEnsure(scheduleActions, scheduleId, () => []);
224
+ const statusListeners = mapNew();
225
+ const [
226
+ isMergeableStore,
227
+ getContent,
228
+ getChanges,
229
+ hasChanges,
230
+ setDefaultContent,
231
+ ] = getStoreFunctions(persist, store, isSynchronizer);
232
+ const [addListener, callListeners, delListenerImpl] = getListenerFunctions(
233
+ () => persister,
234
+ );
235
+ const setStatus = (newStatus) => {
236
+ if (newStatus != status) {
237
+ status = newStatus;
238
+ callListeners(statusListeners, void 0, status);
239
+ }
240
+ };
241
+ const run = async () => {
242
+ /* istanbul ignore else */
243
+ if (!mapGet(scheduleRunning, scheduleId)) {
244
+ mapSet(scheduleRunning, scheduleId, 1);
245
+ while (
246
+ !isUndefined((action = arrayShift(mapGet(scheduleActions, scheduleId))))
247
+ ) {
248
+ await tryCatch(action, onIgnoredError);
249
+ }
250
+ mapSet(scheduleRunning, scheduleId, 0);
251
+ }
252
+ };
253
+ const setContentOrChanges = (contentOrChanges) => {
254
+ (isMergeableStore && isArray(contentOrChanges?.[0])
255
+ ? contentOrChanges?.[2] === 1
256
+ ? store.applyMergeableChanges
257
+ : store.setMergeableContent
258
+ : contentOrChanges?.[2] === 1
259
+ ? store.applyChanges
260
+ : store.setContent)(contentOrChanges);
261
+ };
262
+ const load = async (initialContent) => {
263
+ /* istanbul ignore else */
264
+ if (status != 2 /* Saving */) {
265
+ setStatus(1 /* Loading */);
266
+ loads++;
267
+ await schedule(async () => {
268
+ await tryCatch(
269
+ async () => {
270
+ const content = await getPersisted();
271
+ if (isArray(content)) {
272
+ setContentOrChanges(content);
273
+ } else if (initialContent) {
274
+ setDefaultContent(initialContent);
275
+ } else {
276
+ errorNew(`Content is not an array: ${content}`);
277
+ }
278
+ },
279
+ () => {
280
+ if (initialContent) {
281
+ setDefaultContent(initialContent);
282
+ }
283
+ },
284
+ );
285
+ setStatus(0 /* Idle */);
286
+ });
287
+ }
288
+ return persister;
289
+ };
290
+ const startAutoLoad = async (initialContent) => {
291
+ stopAutoLoad();
292
+ await load(initialContent);
293
+ await tryCatch(
294
+ async () =>
295
+ (autoLoadHandle = await addPersisterListener(
296
+ async (content, changes) => {
297
+ if (changes || content) {
298
+ /* istanbul ignore else */
299
+ if (status != 2 /* Saving */) {
300
+ setStatus(1 /* Loading */);
301
+ loads++;
302
+ setContentOrChanges(changes ?? content);
303
+ setStatus(0 /* Idle */);
304
+ }
305
+ } else {
306
+ await load();
307
+ }
308
+ },
309
+ )),
310
+ onIgnoredError,
311
+ );
312
+ return persister;
313
+ };
314
+ const stopAutoLoad = async () => {
315
+ if (autoLoadHandle) {
316
+ await tryCatch(
317
+ () => delPersisterListener(autoLoadHandle),
318
+ onIgnoredError,
319
+ );
320
+ autoLoadHandle = void 0;
321
+ }
322
+ return persister;
323
+ };
324
+ const isAutoLoading = () => !isUndefined(autoLoadHandle);
325
+ const save = async (changes) => {
326
+ /* istanbul ignore else */
327
+ if (status != 1 /* Loading */) {
328
+ setStatus(2 /* Saving */);
329
+ saves++;
330
+ await schedule(async () => {
331
+ await tryCatch(() => setPersisted(getContent, changes), onIgnoredError);
332
+ setStatus(0 /* Idle */);
333
+ });
334
+ }
335
+ return persister;
336
+ };
337
+ const startAutoSave = async () => {
338
+ stopAutoSave();
339
+ await save();
340
+ autoSaveListenerId = store.addDidFinishTransactionListener(() => {
341
+ const changes = getChanges();
342
+ if (hasChanges(changes)) {
343
+ save(changes);
344
+ }
345
+ });
346
+ return persister;
347
+ };
348
+ const stopAutoSave = async () => {
349
+ if (autoSaveListenerId) {
350
+ store.delListener(autoSaveListenerId);
351
+ autoSaveListenerId = void 0;
352
+ }
353
+ return persister;
354
+ };
355
+ const isAutoSaving = () => !isUndefined(autoSaveListenerId);
356
+ const startAutoPersisting = async (
357
+ initialContent,
358
+ startSaveFirst = false,
359
+ ) => {
360
+ const [call1, call2] = startSaveFirst
361
+ ? [startAutoSave, startAutoLoad]
362
+ : [startAutoLoad, startAutoSave];
363
+ await call1(initialContent);
364
+ await call2(initialContent);
365
+ return persister;
366
+ };
367
+ const stopAutoPersisting = async (stopSaveFirst = false) => {
368
+ const [call1, call2] = stopSaveFirst
369
+ ? [stopAutoSave, stopAutoLoad]
370
+ : [stopAutoLoad, stopAutoSave];
371
+ await call1();
372
+ await call2();
373
+ return persister;
374
+ };
375
+ const getStatus = () => status;
376
+ const addStatusListener = (listener) =>
377
+ addListener(listener, statusListeners);
378
+ const delListener = (listenerId) => {
379
+ delListenerImpl(listenerId);
380
+ return store;
381
+ };
382
+ const schedule = async (...actions) => {
383
+ arrayPush(mapGet(scheduleActions, scheduleId), ...actions);
384
+ await run();
385
+ return persister;
386
+ };
387
+ const getStore = () => store;
388
+ const destroy = () => {
389
+ arrayClear(mapGet(scheduleActions, scheduleId));
390
+ return stopAutoPersisting();
391
+ };
392
+ const getStats = () => ({loads, saves});
393
+ const persister = {
394
+ load,
395
+ startAutoLoad,
396
+ stopAutoLoad,
397
+ isAutoLoading,
398
+ save,
399
+ startAutoSave,
400
+ stopAutoSave,
401
+ isAutoSaving,
402
+ startAutoPersisting,
403
+ stopAutoPersisting,
404
+ getStatus,
405
+ addStatusListener,
406
+ delListener,
407
+ schedule,
408
+ getStore,
409
+ destroy,
410
+ getStats,
411
+ ...extra,
412
+ };
413
+ return objFreeze(persister);
414
+ };
415
+
416
+ const STORAGE = 'storage';
417
+ const createReactNativeMmkvPersister = (
418
+ store,
419
+ storage,
420
+ storageName = STORAGE,
421
+ onIgnoredError,
422
+ ) => {
423
+ const getPersisted = async () => {
424
+ const data = storage.getString(storageName);
425
+ const value = data === void 0 ? void 0 : JSON.parse(data);
426
+ return Promise.resolve(value);
427
+ };
428
+ const setPersisted = async (getContent) => {
429
+ const content = getContent();
430
+ if (content !== void 0) {
431
+ storage.set(storageName, JSON.stringify(content));
432
+ }
433
+ };
434
+ const addPersisterListener = (listener) =>
435
+ storage.addOnValueChangedListener((key) => {
436
+ if (key === storageName) {
437
+ const value = storage.getString(storageName);
438
+ if (value) {
439
+ listener(JSON.parse(value));
440
+ }
441
+ }
442
+ });
443
+ const delPersisterListener = (storageListener) => {
444
+ storageListener.remove();
445
+ };
446
+ return createCustomPersister(
447
+ store,
448
+ getPersisted,
449
+ setPersisted,
450
+ addPersisterListener,
451
+ delPersisterListener,
452
+ onIgnoredError,
453
+ 3,
454
+ // StoreOrMergeableStore
455
+ {getStorageName: () => storageName},
456
+ );
457
+ };
458
+
459
+ export {createReactNativeMmkvPersister};
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <link rel="preload" as="image" href="https://tinybase.org/react.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/indexeddb.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/cloudflare.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/postgresql.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/pglite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/sqlite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/bun.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/expo.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/electric.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/turso.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/powersync.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/partykit.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/yjs.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/crsqlite.png"><link rel="preload" as="image" href="https://tinybase.org/automerge.svg?asImg"><link rel="preload" as="image" href="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"><link rel="preload" as="image" href="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"><link rel="preload" as="image" href="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"><link rel="preload" as="image" href="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://github.com/cpojer.png?size=48"><link rel="preload" as="image" href="https://github.com/expo.png?size=48"><link rel="preload" as="image" href="https://github.com/beekeeb.png?size=48"><link rel="preload" as="image" href="https://github.com/cancelself.png?size=48"><link rel="preload" as="image" href="https://github.com/WonderPanda.png?size=48"><link rel="preload" as="image" href="https://github.com/arpitBhalla.png?size=48"><link rel="preload" as="image" href="https://github.com/behrends.png?size=48"><link rel="preload" as="image" href="https://github.com/betomoedano.png?size=48"><link rel="preload" as="image" href="https://github.com/brentvatne.png?size=48"><link rel="preload" as="image" href="https://github.com/byCedric.png?size=48"><link rel="preload" as="image" href="https://github.com/circadian-risk.png?size=48"><link rel="preload" as="image" href="https://github.com/cubecull.png?size=48"><link rel="preload" as="image" href="https://github.com/erwinkn.png?size=48"><link rel="preload" as="image" href="https://github.com/ezra-en.png?size=48"><link rel="preload" as="image" href="https://github.com/feychenie.png?size=48"><link rel="preload" as="image" href="https://github.com/flaming-codes.png?size=48"><link rel="preload" as="image" href="https://github.com/fostertheweb.png?size=48"><link rel="preload" as="image" href="https://github.com/Giulio987.png?size=48"><link rel="preload" as="image" href="https://github.com/hi-ogawa.png?size=48"><link rel="preload" as="image" href="https://github.com/itsdevcoffee.png?size=48"><link rel="preload" as="image" href="https://github.com/jbolda.png?size=48"><link rel="preload" as="image" href="https://github.com/Kayoo-asso.png?size=48"><link rel="preload" as="image" href="https://github.com/kotofurumiya.png?size=48"><link rel="preload" as="image" href="https://github.com/Kudo.png?size=48"><link rel="preload" as="image" href="https://github.com/learn-anything.png?size=48"><link rel="preload" as="image" href="https://github.com/lluc.png?size=48"><link rel="preload" as="image" href="https://github.com/marksteve.png?size=48"><link rel="preload" as="image" href="https://github.com/miking-the-viking.png?size=48"><link rel="preload" as="image" href="https://github.com/mjamesderocher.png?size=48"><link rel="preload" as="image" href="https://github.com/mouktardev.png?size=48"><link rel="preload" as="image" href="https://github.com/nickmessing.png?size=48"><link rel="preload" as="image" href="https://github.com/nikitavoloboev.png?size=48"><link rel="preload" as="image" href="https://github.com/nkzw-tech.png?size=48"><link rel="preload" as="image" href="https://github.com/palerdot.png?size=48"><link rel="preload" as="image" href="https://github.com/PorcoRosso85.png?size=48"><link rel="preload" as="image" href="https://github.com/primodiumxyz.png?size=48"><link rel="preload" as="image" href="https://github.com/shaneosullivan.png?size=48"><link rel="preload" as="image" href="https://github.com/sudo-self.png?size=48"><link rel="preload" as="image" href="https://github.com/SuperSonicHub1.png?size=48"><link rel="preload" as="image" href="https://github.com/threepointone.png?size=48"><link rel="preload" as="image" href="https://github.com/uptonking.png?size=48"><link rel="preload" as="image" href="https://github.com/ViktorZhurbin.png?size=48"><link rel="preload" as="image" href="https://github.com/wilkerlucio.png?size=48"><link rel="preload" as="image" href="https://tinybase.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinywidgets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinytick.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/youtube.webp"><section id="hero"><h2 id="a-reactive-data-store-sync-engine">A <em>reactive</em> data store &amp; <span><em>sync</em> engine</span></h2></section><p><a href="https://tinybase.org/guides/releases/#v6-4"><em>NEW!</em> v6.4 release</a></p><p><span id="one-with">&quot;The One With React Native SQLite!&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It&#x27;s <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It&#x27;s <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://tinybase.org/api/persister-browser">browser storage</a>, <a href="https://tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It&#x27;s Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it&#x27;s especially great for local-first apps: where data is stored locally on the user&#x27;s device and that can be run offline. It&#x27;s tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.3kB - 11.7kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends.</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img src="https://tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img src="https://tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img src="https://tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><p>(Baffled by all these logos? Check out our <a href="https://tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/6.4.1" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/the-essentials/creating-stores/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <link rel="preload" as="image" href="https://tinybase.org/react.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/indexeddb.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/cloudflare.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/postgresql.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/pglite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/sqlite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/bun.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/expo.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/electric.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/turso.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/powersync.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/partykit.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/yjs.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/crsqlite.png"><link rel="preload" as="image" href="https://tinybase.org/automerge.svg?asImg"><link rel="preload" as="image" href="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"><link rel="preload" as="image" href="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"><link rel="preload" as="image" href="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"><link rel="preload" as="image" href="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://github.com/cpojer.png?size=48"><link rel="preload" as="image" href="https://github.com/expo.png?size=48"><link rel="preload" as="image" href="https://github.com/beekeeb.png?size=48"><link rel="preload" as="image" href="https://github.com/cancelself.png?size=48"><link rel="preload" as="image" href="https://github.com/WonderPanda.png?size=48"><link rel="preload" as="image" href="https://github.com/arpitBhalla.png?size=48"><link rel="preload" as="image" href="https://github.com/behrends.png?size=48"><link rel="preload" as="image" href="https://github.com/betomoedano.png?size=48"><link rel="preload" as="image" href="https://github.com/brentvatne.png?size=48"><link rel="preload" as="image" href="https://github.com/byCedric.png?size=48"><link rel="preload" as="image" href="https://github.com/circadian-risk.png?size=48"><link rel="preload" as="image" href="https://github.com/cubecull.png?size=48"><link rel="preload" as="image" href="https://github.com/erwinkn.png?size=48"><link rel="preload" as="image" href="https://github.com/ezra-en.png?size=48"><link rel="preload" as="image" href="https://github.com/feychenie.png?size=48"><link rel="preload" as="image" href="https://github.com/flaming-codes.png?size=48"><link rel="preload" as="image" href="https://github.com/fostertheweb.png?size=48"><link rel="preload" as="image" href="https://github.com/Giulio987.png?size=48"><link rel="preload" as="image" href="https://github.com/hi-ogawa.png?size=48"><link rel="preload" as="image" href="https://github.com/itsdevcoffee.png?size=48"><link rel="preload" as="image" href="https://github.com/jbolda.png?size=48"><link rel="preload" as="image" href="https://github.com/Kayoo-asso.png?size=48"><link rel="preload" as="image" href="https://github.com/kotofurumiya.png?size=48"><link rel="preload" as="image" href="https://github.com/Kudo.png?size=48"><link rel="preload" as="image" href="https://github.com/learn-anything.png?size=48"><link rel="preload" as="image" href="https://github.com/lluc.png?size=48"><link rel="preload" as="image" href="https://github.com/marksteve.png?size=48"><link rel="preload" as="image" href="https://github.com/miking-the-viking.png?size=48"><link rel="preload" as="image" href="https://github.com/mjamesderocher.png?size=48"><link rel="preload" as="image" href="https://github.com/mouktardev.png?size=48"><link rel="preload" as="image" href="https://github.com/nickmessing.png?size=48"><link rel="preload" as="image" href="https://github.com/nikitavoloboev.png?size=48"><link rel="preload" as="image" href="https://github.com/nkzw-tech.png?size=48"><link rel="preload" as="image" href="https://github.com/palerdot.png?size=48"><link rel="preload" as="image" href="https://github.com/PorcoRosso85.png?size=48"><link rel="preload" as="image" href="https://github.com/primodiumxyz.png?size=48"><link rel="preload" as="image" href="https://github.com/shaneosullivan.png?size=48"><link rel="preload" as="image" href="https://github.com/sudo-self.png?size=48"><link rel="preload" as="image" href="https://github.com/SuperSonicHub1.png?size=48"><link rel="preload" as="image" href="https://github.com/threepointone.png?size=48"><link rel="preload" as="image" href="https://github.com/uptonking.png?size=48"><link rel="preload" as="image" href="https://github.com/ViktorZhurbin.png?size=48"><link rel="preload" as="image" href="https://github.com/wilkerlucio.png?size=48"><link rel="preload" as="image" href="https://tinybase.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinywidgets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinytick.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/youtube.webp"><section id="hero"><h2 id="a-reactive-data-store-sync-engine">A <em>reactive</em> data store &amp; <span><em>sync</em> engine</span></h2></section><p><a href="https://tinybase.org/guides/releases/#v6-5"><em>NEW!</em> v6.5 release</a></p><p><span id="one-with">&quot;The One With MMKV!&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It&#x27;s <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It&#x27;s <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://tinybase.org/api/persister-browser">browser storage</a>, <a href="https://tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It&#x27;s Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it&#x27;s especially great for local-first apps: where data is stored locally on the user&#x27;s device and that can be run offline. It&#x27;s tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.3kB - 11.7kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends.</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img src="https://tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img src="https://tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img src="https://tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><p>(Baffled by all these logos? Check out our <a href="https://tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/6.5.0" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/the-essentials/creating-stores/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  import {createStore} from 'tinybase';
package/releases.md CHANGED
@@ -1,4 +1,19 @@
1
- <link rel="preload" as="image" href="https://tinybase.org/partykit.gif"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://tinybase.org/car-analysis.webp"><link rel="preload" as="image" href="https://tinybase.org/movie-database.webp"><p>This is a reverse chronological list of the major TinyBase releases, with highlighted features.</p><hr><h1 id="v6-4">v6.4</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-sqlite/"><code>persister-react-native-sqlite</code></a> module, which allows you to persist data in a React Native SQLite database via the <a href="https://github.com/andpor/react-native-sqlite-storage">react-native-sqlite-storage</a> library.</p><p>Usage should be as simple as this:</p>
1
+ <link rel="preload" as="image" href="https://tinybase.org/partykit.gif"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://tinybase.org/car-analysis.webp"><link rel="preload" as="image" href="https://tinybase.org/movie-database.webp"><p>This is a reverse chronological list of the major TinyBase releases, with highlighted features.</p><hr><h1 id="v6-5">v6.5</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-mmkv/"><code>persister-react-native-mmkv</code></a> module, which allows you to persist data in a React Native MMKV store via the <a href="https://github.com/mrousavy/react-native-mmkv">react-native-mmkv</a> library.</p><p>Usage should be as simple as this:</p>
2
+
3
+ ```js yolo
4
+ import {MMKV} from 'react-native-mmkv';
5
+ import {createStore} from 'tinybase';
6
+ import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
7
+
8
+ const storage = new MMKV();
9
+ const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
10
+ const persister = createReactNativeMmkvPersister(store, storage);
11
+
12
+ await persister.save();
13
+ // Store will be saved to the MMKV store.
14
+ ```
15
+
16
+ <p>A huge shout out to <a href="https://github.com/JeremyBarbet">Jérémy Barbet</a> for this new persister!</p><hr><h1 id="v6-4">v6.4</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-sqlite/"><code>persister-react-native-sqlite</code></a> module, which allows you to persist data in a React Native SQLite database via the <a href="https://github.com/andpor/react-native-sqlite-storage">react-native-sqlite-storage</a> library.</p><p>Usage should be as simple as this:</p>
2
17
 
3
18
  ```js yolo
4
19
  import {enablePromise, openDatabase} from 'react-native-sqlite-storage';
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -120,7 +120,7 @@ const getUniqueId = (length = 16) =>
120
120
  arrayReduce(
121
121
  getRandomValues(new Uint8Array(length)),
122
122
  (uniqueId, number) => uniqueId + encode(number),
123
- '',
123
+ EMPTY_STRING,
124
124
  );
125
125
 
126
126
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -120,7 +120,7 @@ const getUniqueId = (length = 16) =>
120
120
  arrayReduce(
121
121
  getRandomValues(new Uint8Array(length)),
122
122
  (uniqueId, number) => uniqueId + encode(number),
123
- '',
123
+ EMPTY_STRING,
124
124
  );
125
125
 
126
126
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -147,7 +147,7 @@ const getUniqueId = (length = 16) =>
147
147
  arrayReduce(
148
148
  getRandomValues(new Uint8Array(length)),
149
149
  (uniqueId, number) => uniqueId + encode(number),
150
- '',
150
+ EMPTY_STRING,
151
151
  );
152
152
 
153
153
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -147,7 +147,7 @@ const getUniqueId = (length = 16) =>
147
147
  arrayReduce(
148
148
  getRandomValues(new Uint8Array(length)),
149
149
  (uniqueId, number) => uniqueId + encode(number),
150
- '',
150
+ EMPTY_STRING,
151
151
  );
152
152
 
153
153
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -253,7 +253,7 @@ const getUniqueId = (length = 16) =>
253
253
  arrayReduce(
254
254
  getRandomValues(new Uint8Array(length)),
255
255
  (uniqueId, number) => uniqueId + encode(number),
256
- '',
256
+ EMPTY_STRING,
257
257
  );
258
258
 
259
259
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);