Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sonic-boom

Package Overview
Dependencies
Maintainers
4
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sonic-boom - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

10

index.js

@@ -90,3 +90,3 @@ 'use strict'

let { fd, dest, minLength, maxLength, sync, append = true, mode, mkdir, retryEAGAIN } = opts || {}
let { fd, dest, minLength, maxLength, maxWrite, sync, append = true, mode, mkdir, retryEAGAIN } = opts || {}

@@ -108,2 +108,3 @@ fd = fd || dest

this.maxLength = maxLength || 0
this.maxWrite = maxWrite || MAX_WRITE
this.sync = sync || false

@@ -123,4 +124,4 @@ this.append = append || false

}
if (this.minLength >= MAX_WRITE) {
throw new Error(`minLength should be smaller than MAX_WRITE (${MAX_WRITE})`)
if (this.minLength >= this.maxWrite) {
throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`)
}

@@ -155,2 +156,3 @@

}
this.emit('write', n)

@@ -236,3 +238,3 @@ this._len -= n

bufs.length === 0 ||
bufs[bufs.length - 1].length + data.length > MAX_WRITE
bufs[bufs.length - 1].length + data.length > this.maxWrite
) {

@@ -239,0 +241,0 @@ bufs.push('' + data)

4

package.json
{
"name": "sonic-boom",
"version": "2.7.0",
"version": "2.8.0",
"description": "Extremely fast utf8 only stream implementation",

@@ -38,3 +38,3 @@ "main": "index.js",

"proxyquire": "^2.1.0",
"standard": "^16.0.3",
"standard": "^17.0.0",
"tap": "^16.0.0",

@@ -41,0 +41,0 @@ "tsd": "^0.20.0",

@@ -65,2 +65,3 @@ # sonic-boom

to exceed `maxLength`, the data written is dropped and a `drop` event is emitted with the dropped data
* `maxWrite`: the maximum number of bytes that can be written; default: 16384
* `sync`: perform writes synchronously (similar to `console.log`).

@@ -116,4 +117,35 @@ * `append`: appends writes to dest file instead of truncating it (default `true`).

### Events
#### SonicBoom#close
See [Stream#close](https://nodejs.org/api/stream.html#event-close). The `'close'` event when the instance has been closed.
#### SonicBoom#drain
See [Stream#drain](https://nodejs.org/api/stream.html#event-drain). The `'drain'` event is emitted when source can resume sending data.
#### SonicBoom#drop <any>
When destination file maximal length is reached, the `'drop'` event is emitted with data that could not be written.
#### SonicBoom#error <Error>
The `'error'` event is emitted when the destination file can not be opened, or written.
#### SonicBoom#finish
See [Stream#finish](https://nodejs.org/api/stream.html#event-finish). The `'finish'` event after calling `end()` method and when all data was written.
#### SonicBoom#ready
The `'ready'` event occurs when the created instance is ready to process input.
#### SonicBoom#write <number>
The `'write'` event occurs every time data is written to the underlying file. It emits the number of written bytes.
## License
MIT

@@ -779,2 +779,34 @@ 'use strict'

})
test('emit write events', (t) => {
t.plan(7)
const dest = file()
const stream = new SonicBoom({ dest, sync })
stream.on('ready', () => {
t.pass('ready emitted')
})
let length = 0
stream.on('write', (bytes) => {
length += bytes
})
t.ok(stream.write('hello world\n'))
t.ok(stream.write('something else\n'))
stream.end()
stream.on('finish', () => {
fs.readFile(dest, 'utf8', (err, data) => {
t.error(err)
t.equal(data, 'hello world\nsomething else\n')
t.equal(length, 27)
})
})
stream.on('close', () => {
t.pass('close emitted')
})
})
}

@@ -1131,3 +1163,3 @@

test('retryEAGAIN receives remaining buffer if exceeds MAX_WRITE', (t) => {
test('retryEAGAIN receives remaining buffer if exceeds maxWrite', (t) => {
t.plan(17)

@@ -1542,3 +1574,3 @@

test('should throw if minLength >= MAX_WRITE', (t) => {
test('should throw if minLength >= maxWrite', (t) => {
t.plan(1)

@@ -1555,1 +1587,8 @@ t.throws(() => {

})
test('make sure `maxWrite` is passed', (t) => {
t.plan(1)
const dest = file()
const stream = new SonicBoom({ dest, maxLength: 65536 })
t.equal(stream.maxLength, 65536)
})

@@ -14,2 +14,3 @@ // Type definitions for sonic-boom 0.7

minLength?: number
maxWrite?: number
sync?: boolean

@@ -16,0 +17,0 @@ append?: boolean

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc