serializable-bptree 5.0.3 → 5.0.5
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/dist/cjs/index.cjs +19 -12
- package/dist/esm/index.mjs +19 -12
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -197,12 +197,21 @@ var BPTree = class {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
bufferForNodeCreate(node) {
|
|
200
|
+
if (node.id === this.root.id) {
|
|
201
|
+
this._strategyDirty = true;
|
|
202
|
+
}
|
|
200
203
|
this._nodeCreateBuffer.set(node.id, node);
|
|
201
204
|
}
|
|
202
205
|
bufferForNodeUpdate(node) {
|
|
206
|
+
if (node.id === this.root.id) {
|
|
207
|
+
this._strategyDirty = true;
|
|
208
|
+
}
|
|
203
209
|
this._nodeUpdateBuffer.set(node.id, node);
|
|
204
210
|
}
|
|
205
211
|
bufferForNodeDelete(node) {
|
|
212
|
+
if (node.id === this.root.id) {
|
|
213
|
+
this._strategyDirty = true;
|
|
214
|
+
}
|
|
206
215
|
this._nodeDeleteBuffer.set(node.id, node);
|
|
207
216
|
}
|
|
208
217
|
/**
|
|
@@ -327,16 +336,16 @@ var BPTreeSync = class extends BPTree {
|
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
338
|
}
|
|
330
|
-
if (this.root === node && node.keys.length === 1) {
|
|
339
|
+
if (this.root.id === node.id && node.keys.length === 1) {
|
|
331
340
|
const keys = node.keys;
|
|
332
341
|
this.bufferForNodeDelete(this.root);
|
|
333
342
|
this.root = this.getNode(keys[0]);
|
|
334
343
|
this.root.parent = null;
|
|
335
344
|
this.strategy.head.root = this.root.id;
|
|
336
|
-
this._strategyDirty = true;
|
|
337
345
|
this.bufferForNodeUpdate(this.root);
|
|
338
346
|
return;
|
|
339
|
-
} else if (this.root === node) {
|
|
347
|
+
} else if (this.root.id === node.id) {
|
|
348
|
+
this.bufferForNodeUpdate(this.root);
|
|
340
349
|
return;
|
|
341
350
|
} else if (node.keys.length < Math.ceil(this.order / 2) && !node.leaf || node.values.length < Math.ceil((this.order - 1) / 2) && node.leaf) {
|
|
342
351
|
if (node.parent === null) {
|
|
@@ -513,11 +522,10 @@ var BPTreeSync = class extends BPTree {
|
|
|
513
522
|
}
|
|
514
523
|
}
|
|
515
524
|
_insertInParent(node, value, pointer) {
|
|
516
|
-
if (this.root === node) {
|
|
525
|
+
if (this.root.id === node.id) {
|
|
517
526
|
const root = this._createNode(false, [node.id, pointer.id], [value]);
|
|
518
527
|
this.root = root;
|
|
519
528
|
this.strategy.head.root = root.id;
|
|
520
|
-
this._strategyDirty = true;
|
|
521
529
|
node.parent = root.id;
|
|
522
530
|
pointer.parent = root.id;
|
|
523
531
|
this.bufferForNodeCreate(root);
|
|
@@ -732,7 +740,7 @@ var BPTreeSync = class extends BPTree {
|
|
|
732
740
|
if (keys.length > 1) {
|
|
733
741
|
keys.splice(keys.indexOf(key), 1);
|
|
734
742
|
this.bufferForNodeUpdate(node);
|
|
735
|
-
} else if (node === this.root) {
|
|
743
|
+
} else if (node.id === this.root.id) {
|
|
736
744
|
node.values.splice(i, 1);
|
|
737
745
|
node.keys.splice(i, 1);
|
|
738
746
|
this.bufferForNodeUpdate(node);
|
|
@@ -890,16 +898,16 @@ var BPTreeAsync = class extends BPTree {
|
|
|
890
898
|
}
|
|
891
899
|
}
|
|
892
900
|
}
|
|
893
|
-
if (this.root === node && node.keys.length === 1) {
|
|
901
|
+
if (this.root.id === node.id && node.keys.length === 1) {
|
|
894
902
|
const keys = node.keys;
|
|
895
903
|
this.bufferForNodeDelete(this.root);
|
|
896
904
|
this.root = await this.getNode(keys[0]);
|
|
897
905
|
this.root.parent = null;
|
|
898
906
|
this.strategy.head.root = this.root.id;
|
|
899
|
-
this._strategyDirty = true;
|
|
900
907
|
this.bufferForNodeUpdate(this.root);
|
|
901
908
|
return;
|
|
902
|
-
} else if (this.root === node) {
|
|
909
|
+
} else if (this.root.id === node.id) {
|
|
910
|
+
this.bufferForNodeUpdate(this.root);
|
|
903
911
|
return;
|
|
904
912
|
} else if (node.keys.length < Math.ceil(this.order / 2) && !node.leaf || node.values.length < Math.ceil((this.order - 1) / 2) && node.leaf) {
|
|
905
913
|
if (node.parent === null) {
|
|
@@ -1076,11 +1084,10 @@ var BPTreeAsync = class extends BPTree {
|
|
|
1076
1084
|
}
|
|
1077
1085
|
}
|
|
1078
1086
|
async _insertInParent(node, value, pointer) {
|
|
1079
|
-
if (this.root === node) {
|
|
1087
|
+
if (this.root.id === node.id) {
|
|
1080
1088
|
const root = await this._createNode(false, [node.id, pointer.id], [value]);
|
|
1081
1089
|
this.root = root;
|
|
1082
1090
|
this.strategy.head.root = root.id;
|
|
1083
|
-
this._strategyDirty = true;
|
|
1084
1091
|
node.parent = root.id;
|
|
1085
1092
|
pointer.parent = root.id;
|
|
1086
1093
|
this.bufferForNodeCreate(root);
|
|
@@ -1295,7 +1302,7 @@ var BPTreeAsync = class extends BPTree {
|
|
|
1295
1302
|
if (keys.length > 1) {
|
|
1296
1303
|
keys.splice(keys.indexOf(key), 1);
|
|
1297
1304
|
this.bufferForNodeUpdate(node);
|
|
1298
|
-
} else if (node === this.root) {
|
|
1305
|
+
} else if (node.id === this.root.id) {
|
|
1299
1306
|
node.values.splice(i, 1);
|
|
1300
1307
|
node.keys.splice(i, 1);
|
|
1301
1308
|
this.bufferForNodeUpdate(node);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -163,12 +163,21 @@ var BPTree = class {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
bufferForNodeCreate(node) {
|
|
166
|
+
if (node.id === this.root.id) {
|
|
167
|
+
this._strategyDirty = true;
|
|
168
|
+
}
|
|
166
169
|
this._nodeCreateBuffer.set(node.id, node);
|
|
167
170
|
}
|
|
168
171
|
bufferForNodeUpdate(node) {
|
|
172
|
+
if (node.id === this.root.id) {
|
|
173
|
+
this._strategyDirty = true;
|
|
174
|
+
}
|
|
169
175
|
this._nodeUpdateBuffer.set(node.id, node);
|
|
170
176
|
}
|
|
171
177
|
bufferForNodeDelete(node) {
|
|
178
|
+
if (node.id === this.root.id) {
|
|
179
|
+
this._strategyDirty = true;
|
|
180
|
+
}
|
|
172
181
|
this._nodeDeleteBuffer.set(node.id, node);
|
|
173
182
|
}
|
|
174
183
|
/**
|
|
@@ -293,16 +302,16 @@ var BPTreeSync = class extends BPTree {
|
|
|
293
302
|
}
|
|
294
303
|
}
|
|
295
304
|
}
|
|
296
|
-
if (this.root === node && node.keys.length === 1) {
|
|
305
|
+
if (this.root.id === node.id && node.keys.length === 1) {
|
|
297
306
|
const keys = node.keys;
|
|
298
307
|
this.bufferForNodeDelete(this.root);
|
|
299
308
|
this.root = this.getNode(keys[0]);
|
|
300
309
|
this.root.parent = null;
|
|
301
310
|
this.strategy.head.root = this.root.id;
|
|
302
|
-
this._strategyDirty = true;
|
|
303
311
|
this.bufferForNodeUpdate(this.root);
|
|
304
312
|
return;
|
|
305
|
-
} else if (this.root === node) {
|
|
313
|
+
} else if (this.root.id === node.id) {
|
|
314
|
+
this.bufferForNodeUpdate(this.root);
|
|
306
315
|
return;
|
|
307
316
|
} else if (node.keys.length < Math.ceil(this.order / 2) && !node.leaf || node.values.length < Math.ceil((this.order - 1) / 2) && node.leaf) {
|
|
308
317
|
if (node.parent === null) {
|
|
@@ -479,11 +488,10 @@ var BPTreeSync = class extends BPTree {
|
|
|
479
488
|
}
|
|
480
489
|
}
|
|
481
490
|
_insertInParent(node, value, pointer) {
|
|
482
|
-
if (this.root === node) {
|
|
491
|
+
if (this.root.id === node.id) {
|
|
483
492
|
const root = this._createNode(false, [node.id, pointer.id], [value]);
|
|
484
493
|
this.root = root;
|
|
485
494
|
this.strategy.head.root = root.id;
|
|
486
|
-
this._strategyDirty = true;
|
|
487
495
|
node.parent = root.id;
|
|
488
496
|
pointer.parent = root.id;
|
|
489
497
|
this.bufferForNodeCreate(root);
|
|
@@ -698,7 +706,7 @@ var BPTreeSync = class extends BPTree {
|
|
|
698
706
|
if (keys.length > 1) {
|
|
699
707
|
keys.splice(keys.indexOf(key), 1);
|
|
700
708
|
this.bufferForNodeUpdate(node);
|
|
701
|
-
} else if (node === this.root) {
|
|
709
|
+
} else if (node.id === this.root.id) {
|
|
702
710
|
node.values.splice(i, 1);
|
|
703
711
|
node.keys.splice(i, 1);
|
|
704
712
|
this.bufferForNodeUpdate(node);
|
|
@@ -856,16 +864,16 @@ var BPTreeAsync = class extends BPTree {
|
|
|
856
864
|
}
|
|
857
865
|
}
|
|
858
866
|
}
|
|
859
|
-
if (this.root === node && node.keys.length === 1) {
|
|
867
|
+
if (this.root.id === node.id && node.keys.length === 1) {
|
|
860
868
|
const keys = node.keys;
|
|
861
869
|
this.bufferForNodeDelete(this.root);
|
|
862
870
|
this.root = await this.getNode(keys[0]);
|
|
863
871
|
this.root.parent = null;
|
|
864
872
|
this.strategy.head.root = this.root.id;
|
|
865
|
-
this._strategyDirty = true;
|
|
866
873
|
this.bufferForNodeUpdate(this.root);
|
|
867
874
|
return;
|
|
868
|
-
} else if (this.root === node) {
|
|
875
|
+
} else if (this.root.id === node.id) {
|
|
876
|
+
this.bufferForNodeUpdate(this.root);
|
|
869
877
|
return;
|
|
870
878
|
} else if (node.keys.length < Math.ceil(this.order / 2) && !node.leaf || node.values.length < Math.ceil((this.order - 1) / 2) && node.leaf) {
|
|
871
879
|
if (node.parent === null) {
|
|
@@ -1042,11 +1050,10 @@ var BPTreeAsync = class extends BPTree {
|
|
|
1042
1050
|
}
|
|
1043
1051
|
}
|
|
1044
1052
|
async _insertInParent(node, value, pointer) {
|
|
1045
|
-
if (this.root === node) {
|
|
1053
|
+
if (this.root.id === node.id) {
|
|
1046
1054
|
const root = await this._createNode(false, [node.id, pointer.id], [value]);
|
|
1047
1055
|
this.root = root;
|
|
1048
1056
|
this.strategy.head.root = root.id;
|
|
1049
|
-
this._strategyDirty = true;
|
|
1050
1057
|
node.parent = root.id;
|
|
1051
1058
|
pointer.parent = root.id;
|
|
1052
1059
|
this.bufferForNodeCreate(root);
|
|
@@ -1261,7 +1268,7 @@ var BPTreeAsync = class extends BPTree {
|
|
|
1261
1268
|
if (keys.length > 1) {
|
|
1262
1269
|
keys.splice(keys.indexOf(key), 1);
|
|
1263
1270
|
this.bufferForNodeUpdate(node);
|
|
1264
|
-
} else if (node === this.root) {
|
|
1271
|
+
} else if (node.id === this.root.id) {
|
|
1265
1272
|
node.values.splice(i, 1);
|
|
1266
1273
|
node.keys.splice(i, 1);
|
|
1267
1274
|
this.bufferForNodeUpdate(node);
|