serializable-bptree 6.0.1 → 6.0.2

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.
@@ -991,6 +991,9 @@ var BPTreeSync = class extends BPTree {
991
991
  }
992
992
  }
993
993
  getNode(id) {
994
+ if (this._nodeUpdateBuffer.has(id)) {
995
+ return this._nodeUpdateBuffer.get(id);
996
+ }
994
997
  if (this._nodeCreateBuffer.has(id)) {
995
998
  return this._nodeCreateBuffer.get(id);
996
999
  }
@@ -998,7 +1001,7 @@ var BPTreeSync = class extends BPTree {
998
1001
  return cache.raw;
999
1002
  }
1000
1003
  insertableNode(value) {
1001
- let node = this.root;
1004
+ let node = this.getNode(this.root.id);
1002
1005
  while (!node.leaf) {
1003
1006
  for (let i = 0, len = node.values.length; i < len; i++) {
1004
1007
  const nValue = node.values[i];
@@ -1878,6 +1881,9 @@ var BPTreeAsync = class extends BPTree {
1878
1881
  }
1879
1882
  }
1880
1883
  async getNode(id) {
1884
+ if (this._nodeUpdateBuffer.has(id)) {
1885
+ return this._nodeUpdateBuffer.get(id);
1886
+ }
1881
1887
  if (this._nodeCreateBuffer.has(id)) {
1882
1888
  return this._nodeCreateBuffer.get(id);
1883
1889
  }
@@ -1885,7 +1891,7 @@ var BPTreeAsync = class extends BPTree {
1885
1891
  return cache.raw;
1886
1892
  }
1887
1893
  async insertableNode(value) {
1888
- let node = this.root;
1894
+ let node = await this.getNode(this.root.id);
1889
1895
  while (!node.leaf) {
1890
1896
  for (let i = 0, len = node.values.length; i < len; i++) {
1891
1897
  const nValue = node.values[i];
@@ -957,6 +957,9 @@ var BPTreeSync = class extends BPTree {
957
957
  }
958
958
  }
959
959
  getNode(id) {
960
+ if (this._nodeUpdateBuffer.has(id)) {
961
+ return this._nodeUpdateBuffer.get(id);
962
+ }
960
963
  if (this._nodeCreateBuffer.has(id)) {
961
964
  return this._nodeCreateBuffer.get(id);
962
965
  }
@@ -964,7 +967,7 @@ var BPTreeSync = class extends BPTree {
964
967
  return cache.raw;
965
968
  }
966
969
  insertableNode(value) {
967
- let node = this.root;
970
+ let node = this.getNode(this.root.id);
968
971
  while (!node.leaf) {
969
972
  for (let i = 0, len = node.values.length; i < len; i++) {
970
973
  const nValue = node.values[i];
@@ -1844,6 +1847,9 @@ var BPTreeAsync = class extends BPTree {
1844
1847
  }
1845
1848
  }
1846
1849
  async getNode(id) {
1850
+ if (this._nodeUpdateBuffer.has(id)) {
1851
+ return this._nodeUpdateBuffer.get(id);
1852
+ }
1847
1853
  if (this._nodeCreateBuffer.has(id)) {
1848
1854
  return this._nodeCreateBuffer.get(id);
1849
1855
  }
@@ -1851,7 +1857,7 @@ var BPTreeAsync = class extends BPTree {
1851
1857
  return cache.raw;
1852
1858
  }
1853
1859
  async insertableNode(value) {
1854
- let node = this.root;
1860
+ let node = await this.getNode(this.root.id);
1855
1861
  while (!node.leaf) {
1856
1862
  for (let i = 0, len = node.values.length; i < len; i++) {
1857
1863
  const nValue = node.values[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serializable-bptree",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "Store the B+tree flexibly, not only in-memory.",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "main": "./dist/cjs/index.cjs",