Comparing version 3.0.2 to 3.0.3
{ | ||
"name": "jembadb", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Json Embeddable Appendable Database", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -28,2 +28,3 @@ 'use strict'; | ||
this.loadedBlocks = []; | ||
this.newBlocks = []; | ||
this.deltas = new Map(); | ||
@@ -137,3 +138,3 @@ | ||
this.blockList.set(this.currentBlockIndex, block); | ||
this.loadedBlocks.push(this.currentBlockIndex); | ||
this.newBlocks.push(this.currentBlockIndex); | ||
this.blocksNotFinalized.set(this.currentBlockIndex, 1); | ||
@@ -172,2 +173,13 @@ | ||
unloadBlocksIfNeeded() { | ||
const nb = []; | ||
for (const index of this.newBlocks) { | ||
if (index < this.lastSavedBlockIndex) { | ||
this.loadedBlocks.push(index); | ||
} else { | ||
nb.push(index); | ||
} | ||
} | ||
this.newBlocks = nb; | ||
if (this.loadedBlocks.length <= this.loadedBlocksCount) | ||
@@ -177,9 +189,5 @@ return; | ||
//check loaded | ||
let missed = new Set(); | ||
while (this.loadedBlocks.length > this.loadedBlocksCount) { | ||
const index = this.loadedBlocks.shift(); | ||
if (index >= this.lastSavedBlockIndex) { | ||
missed.add(index); | ||
continue; | ||
} | ||
const block = this.blockList.get(index); | ||
@@ -192,4 +200,2 @@ | ||
} | ||
this.loadedBlocks = this.loadedBlocks.concat(Array.from(missed)); | ||
} | ||
@@ -196,0 +202,0 @@ |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
181016
4763
0
16