refactor code

This commit is contained in:
Andre Staltz 2023-12-20 09:34:42 +02:00
parent 62c321a1b8
commit b0cfedbb00
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
3 changed files with 19 additions and 8 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ pnpm-lock.yaml
package-lock.json package-lock.json
coverage coverage
*~ *~
lib/*.d.ts

View File

@ -130,8 +130,15 @@ function initGC(peer, config) {
: kbRemaining > 0 : kbRemaining > 0
? `${kbRemaining}KB` ? `${kbRemaining}KB`
: `${bytesRemaining}B` : `${bytesRemaining}B`
// prettier-ignore if (bytesRemaining > 0) {
debug('Log is %s% full (only %s of free space), needs cleanup', percentUsed.toFixed(0), remaining) // 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) { function monitorLogSize(maxLogBytes) {
assertDBPlugin(peer) assertDBPlugin(peer)
/** Number of records that match roughly 1% of the max log size */ /** 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 const CHECKPOINT = Math.floor((maxLogBytes * 0.01) / 500) // assuming 1 record = 500 bytes
function checkLogSize() { function checkLogSize() {
assertDBPlugin(peer) assertDBPlugin(peer)

View File

@ -11,8 +11,7 @@
}, },
"main": "index.js", "main": "index.js",
"files": [ "files": [
"*.js", "lib/**"
"lib/*.js"
], ],
"exports": { "exports": {
".": { ".": {
@ -42,10 +41,14 @@
"rimraf": "^4.4.0", "rimraf": "^4.4.0",
"secret-handshake-ext": "^0.0.8", "secret-handshake-ext": "^0.0.8",
"secret-stack": "~7.1.0", "secret-stack": "~7.1.0",
"ssb-box": "^1.0.1" "ssb-box": "^1.0.1",
"typescript": "^5.1.3"
}, },
"scripts": { "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": "prettier --write \"(lib|test)/**/*.js\"",
"format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.js\"", "format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.js\"",
"coverage": "c8 --reporter=lcov npm run test" "coverage": "c8 --reporter=lcov npm run test"