diff --git a/.gitignore b/.gitignore index 3ef31a7..6544272 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ pnpm-lock.yaml package-lock.json coverage *~ +lib/*.d.ts diff --git a/lib/index.js b/lib/index.js index b50f758..0a3bd33 100644 --- a/lib/index.js +++ b/lib/index.js @@ -130,8 +130,15 @@ function initGC(peer, config) { : kbRemaining > 0 ? `${kbRemaining}KB` : `${bytesRemaining}B` - // prettier-ignore - debug('Log is %s% full (only %s of free space), needs cleanup', percentUsed.toFixed(0), remaining) + if (bytesRemaining > 0) { + // prettier-ignore + debug('Log is %s% full (only %s of free space), needs cleanup', percentUsed.toFixed(0), remaining) + } else if (bytesRemaining === 0) { + debug('Log is full, needs cleanup') + } else { + // prettier-ignore + debug('Log is %s% full (%s beyond limit), needs cleanup', percentUsed.toFixed(0), remaining.slice(1)) + } } /** @@ -160,8 +167,8 @@ function initGC(peer, config) { function monitorLogSize(maxLogBytes) { assertDBPlugin(peer) - /** Number of records that match roughly 1% of the max log size */ - const CHECKPOINT = Math.floor((maxLogBytes * 0.01) / 500) // assuming 1 record = 500 bytes + /** Number of records that match roughly 1% of the max log size */ + const CHECKPOINT = Math.floor((maxLogBytes * 0.01) / 500) // assuming 1 record = 500 bytes function checkLogSize() { assertDBPlugin(peer) diff --git a/package.json b/package.json index ce927b4..0a0dd6e 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,7 @@ }, "main": "index.js", "files": [ - "*.js", - "lib/*.js" + "lib/**" ], "exports": { ".": { @@ -42,10 +41,14 @@ "rimraf": "^4.4.0", "secret-handshake-ext": "^0.0.8", "secret-stack": "~7.1.0", - "ssb-box": "^1.0.1" + "ssb-box": "^1.0.1", + "typescript": "^5.1.3" }, "scripts": { - "test": "node --test", + "clean-check": "tsc --build --clean", + "prepublishOnly": "npm run clean-check && tsc --build", + "postpublish": "npm run clean-check", + "test": "npm run clean-check && node --test", "format-code": "prettier --write \"(lib|test)/**/*.js\"", "format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.js\"", "coverage": "c8 --reporter=lcov npm run test"