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

smart-buffer

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-buffer - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

20

lib/smart-buffer.js

@@ -183,2 +183,22 @@ var SmartBuffer = (function () {

/**
* Reads a null terminated sequence of bytes from the underlying buffer.
* @returns {Buffer} Buffer containing the read bytes.
*/
SmartBuffer.prototype.readBufferNT = function () {
var nullpos = this.length;
for (var i = this._readOffset; i < this.length; i++) {
if (this.buff[i] == 0x00) {
nullpos = i;
break;
}
}
var ret = this.buff.slice(this._readOffset, nullpos);
this._readOffset = nullpos + 1;
return ret;
};
/*

@@ -185,0 +205,0 @@ Write Operations

2

package.json
{
"name": "smart-buffer",
"version": "1.0.4",
"version": "1.0.5",
"description": "A smarter Buffer that keeps track of its own read and write positions while growing endlessly.",

@@ -5,0 +5,0 @@ "main": "lib/smart-buffer.js",

@@ -191,2 +191,18 @@ var SmartBuffer = require('../lib/smart-buffer.js');

describe("Null Terminated Buffer Reading", function () {
var buff = new SmartBuffer();
buff.writeBuffer(new Buffer([0x01, 0x02, 0x03, 0x04, 0x00, 0x01, 0x02, 0x03]));
var read1 = buff.readBufferNT();
var read2 = buff.readBufferNT();
it("Should return a length of 4 for the four bytes before the first null in the buffer.", function () {
assert.equal(read1.length, 4);
});
it("Should return a length of 3 for the three bytes after the first null in the buffer after reading to end.", function () {
assert.equal(read2.length, 3);
});
})
});

@@ -193,0 +209,0 @@

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