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 3.1.0 to 3.2.0

12

index.js

@@ -158,2 +158,14 @@ 'use strict'

this._len -= n
// In case of multi-byte characters, the length of the written buffer
// may be different from the length of the string. Let's make sure
// we do not have an accumulated string with a negative length.
// This also mean that ._len is not precise, but it's not a problem as some
// writes might be triggered earlier than ._minLength.
if (this._len < 0) {
this._len = 0
}
// TODO if we have a multi-byte character in the buffer, we need to
// n might not be the same as this._writingBuf.length, so we might loose
// characters here. The solution to this problem is to use a Buffer for _writingBuf.
this._writingBuf = this._writingBuf.slice(n)

@@ -160,0 +172,0 @@

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1648,1 +1648,38 @@ 'use strict'

})
test('._len must always be equal or greater than 0', (t) => {
t.plan(3)
const dest = file()
const fd = fs.openSync(dest, 'w')
const stream = new SonicBoom({ fd, sync: true })
t.ok(stream.write('hello world 👀\n'))
t.ok(stream.write('another line 👀\n'))
t.equal(stream._len, 0)
stream.end()
})
test('._len must always be equal or greater than 0', (t) => {
const n = 20
t.plan(n + 3)
const dest = file()
const fd = fs.openSync(dest, 'w')
const stream = new SonicBoom({ fd, sync: true, minLength: 20 })
let str = ''
for (let i = 0; i < 20; i++) {
t.ok(stream.write('👀'))
str += '👀'
}
t.equal(stream._len, 0)
fs.readFile(dest, 'utf8', (err, data) => {
t.error(err)
t.equal(data, str)
})
})
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