add tests for write coalescer

This commit is contained in:
Nystik
2026-05-15 00:16:47 +02:00
parent ad8252b216
commit 01b79e6659
2 changed files with 149 additions and 1 deletions

View File

@@ -150,4 +150,13 @@ async function flushAll() {
await Promise.race([Promise.allSettled(writes), timeout]);
}
module.exports = { writeCoalesced, getPending, flushAll };
// Test-only: clear all internal state. Not exported for production use.
function _reset() {
for (const entry of pending.values()) {
clearTimeout(entry.timer);
}
pending.clear();
lastWriteTime.clear();
}
module.exports = { writeCoalesced, getPending, flushAll, _reset };