diff --git a/lib/log/errors.js b/lib/log/errors.js index fcf756b..9f925f6 100644 --- a/lib/log/errors.js +++ b/lib/log/errors.js @@ -49,10 +49,8 @@ function delDuringCompactErr() { } function compactWithMaxLiveStreamErr() { - return new Error( - 'Compaction cannot run if there are live streams ' + - 'configured with opts.lt or opts.lte' - ) + // prettier-ignore + return new Error('Compaction cannot run if there are live streams configured with opts.lt or opts.lte') } function appendLargerThanBlockErr() { @@ -64,11 +62,8 @@ function appendTransactionWantsArrayErr() { } function unexpectedTruncationErr() { - return new Error( - 'truncate() is trying to *increase* the log size, ' + - 'which is totally unexpected. ' + - 'There may be a logic bug in async-append-only-log' - ) + // prettier-ignore + return new Error('truncate() is trying to *increase* the log size, which is totally unexpected. There may be a logic bug in the log') } module.exports = { diff --git a/lib/log/index.js b/lib/log/index.js index 3e1a637..d6a4808 100644 --- a/lib/log/index.js +++ b/lib/log/index.js @@ -6,7 +6,7 @@ const Obv = require('obz') // @ts-ignore const AtomicFile = require('atomic-file-rw') // @ts-ignore const debounce = require('lodash.debounce') // @ts-ignore const isBufferZero = require('is-buffer-zero') // @ts-ignore -const debug = require('debug')('async-append-only-log') // @ts-ignore +const debug = require('debug')('log') // @ts-ignore const mutexify = require('mutexify') const { diff --git a/test/del.test.js b/test/del.test.js index b5da84b..d80a91b 100644 --- a/test/del.test.js +++ b/test/del.test.js @@ -5,7 +5,7 @@ const os = require('node:os') const p = require('node:util').promisify const rimraf = require('rimraf') const SecretStack = require('secret-stack') -const AAOL = require('async-append-only-log') +const Log = require('../lib/log') const push = require('push-stream') const caps = require('ppppp-caps') const Keypair = require('ppppp-keypair') @@ -59,7 +59,7 @@ test('del', async (t) => { await p(peer.close)(true) - const log = AAOL(path.join(DIR, 'db.bin'), { + const log = Log(path.join(DIR, 'db.bin'), { cacheSize: 1, blockSize: 64 * 1024, codec: { @@ -74,18 +74,16 @@ test('del', async (t) => { const persistedMsgs = await new Promise((resolve, reject) => { let persistedMsgs = [] - log.stream({ offsets: true, values: true, sizes: true }).pipe( - push.drain( - function drainEach({ offset, value, size }) { - if (value) { - persistedMsgs.push(value.msg) - } - }, - function drainEnd(err) { - if (err) return reject(err) - resolve(persistedMsgs) + log.scan( + function drainEach(offset, rec, size) { + if (rec) { + persistedMsgs.push(rec.msg) } - ) + }, + function drainEnd(err) { + if (err) return reject(err) + resolve(persistedMsgs) + } ) }) diff --git a/test/erase.test.js b/test/erase.test.js index 77259af..ef0601f 100644 --- a/test/erase.test.js +++ b/test/erase.test.js @@ -5,7 +5,7 @@ const os = require('node:os') const p = require('node:util').promisify const rimraf = require('rimraf') const SecretStack = require('secret-stack') -const AAOL = require('async-append-only-log') +const Log = require('../lib/log') const push = require('push-stream') const caps = require('ppppp-caps') const Keypair = require('ppppp-keypair')