@instantdb/core 0.22.86-experimental.split-store.20183617880.1 → 0.22.86-experimental.split-store.20243647937.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/core",
3
- "version": "0.22.86-experimental.split-store.20183617880.1",
3
+ "version": "0.22.86-experimental.split-store.20243647937.1",
4
4
  "description": "Instant's core local abstraction",
5
5
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "dependencies": {
54
54
  "mutative": "^1.0.10",
55
55
  "uuid": "^11.1.0",
56
- "@instantdb/version": "0.22.86-experimental.split-store.20183617880.1"
56
+ "@instantdb/version": "0.22.86-experimental.split-store.20243647937.1"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest",
package/src/store.ts CHANGED
@@ -201,19 +201,22 @@ function deleteInMap(m, path) {
201
201
  deleteInMap(m.get(head), tail);
202
202
  }
203
203
 
204
- function setInMap(m, path, value) {
205
- if (path.length === 0) throw new Error('path must have at least one element');
206
- if (path.length === 1) {
207
- m.set(path[0], value);
208
- return;
204
+ function setInMap(m: Map<any, any>, path: any[], value: any) {
205
+ let current = m;
206
+ const lastI = path.length - 1;
207
+ for (let i = 0; i < lastI; i++) {
208
+ const part = path[i];
209
+
210
+ let nextMap = current.get(part);
211
+ if (nextMap === undefined) {
212
+ nextMap = new Map();
213
+ current.set(part, nextMap);
214
+ }
215
+ current = nextMap;
209
216
  }
210
- const [head, ...tail] = path;
211
- let nextM = m.get(head);
212
- if (!nextM) {
213
- nextM = new Map();
214
- m.set(head, nextM);
217
+ if (lastI > -1) {
218
+ current.set(path[lastI], value);
215
219
  }
216
- setInMap(nextM, tail, value);
217
220
  }
218
221
 
219
222
  function isDateAttr(attr: InstantDBAttr) {