sonic-boom
Advanced tools
Comparing version 4.0.1 to 4.1.0
22
index.js
@@ -19,2 +19,5 @@ 'use strict' | ||
const [major, minor] = process.versions.node.split('.').map(Number) | ||
const kCopyBuffer = major >= 22 && minor >= 7 | ||
function openFile (file, sonic) { | ||
@@ -99,3 +102,3 @@ sonic._opening = true | ||
let { fd, dest, minLength, maxLength, maxWrite, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {} | ||
let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {} | ||
@@ -119,2 +122,4 @@ fd = fd || dest | ||
this.maxWrite = maxWrite || MAX_WRITE | ||
this._periodicFlush = periodicFlush || 0 | ||
this._periodicFlushTimer = undefined | ||
this.sync = sync || false | ||
@@ -248,2 +253,7 @@ this.writable = true | ||
}) | ||
if (this._periodicFlush !== 0) { | ||
this._periodicFlushTimer = setInterval(() => this.flush(null), this._periodicFlush) | ||
this._periodicFlushTimer.unref() | ||
} | ||
} | ||
@@ -643,2 +653,8 @@ | ||
} else { | ||
// fs.write will need to copy string to buffer anyway so | ||
// we do it here to avoid the overhead of calculating the buffer size | ||
// in releaseWritingBuf. | ||
if (kCopyBuffer) { | ||
this._writingBuf = Buffer.from(this._writingBuf) | ||
} | ||
fs.write(this.fd, this._writingBuf, release) | ||
@@ -654,2 +670,6 @@ } | ||
if (sonic._periodicFlushTimer !== undefined) { | ||
clearInterval(sonic._periodicFlushTimer) | ||
} | ||
sonic.destroyed = true | ||
@@ -656,0 +676,0 @@ sonic._bufs = [] |
{ | ||
"name": "sonic-boom", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Extremely fast utf8 only stream implementation", | ||
@@ -37,3 +37,4 @@ "main": "index.js", | ||
"@fastify/pre-commit": "^2.1.0", | ||
"@types/node": "^20.1.0", | ||
"@sinonjs/fake-timers": "^11.2.2", | ||
"@types/node": "^22.0.0", | ||
"fastbench": "^1.0.1", | ||
@@ -40,0 +41,0 @@ "proxyquire": "^2.1.3", |
@@ -65,2 +65,3 @@ # sonic-boom | ||
* `maxWrite`: the maximum number of bytes that can be written; default: 16384 | ||
* `periodicFlush`: calls `flush` every x`ms`. | ||
* `sync`: perform writes synchronously (similar to `console.log`). | ||
@@ -67,0 +68,0 @@ * `fsync`: perform a [fsyncSync](https://nodejs.org/api/fs.html#fsfsyncsyncfd) every time a write is completed. |
@@ -15,2 +15,3 @@ // Type definitions for sonic-boom 0.7 | ||
maxWrite?: number | ||
periodicFlush?: number | ||
sync?: boolean | ||
@@ -17,0 +18,0 @@ fsync?: boolean |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
84972
25
2711
153
1
9
15