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

iobuffer

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobuffer - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "iobuffer",
"version": "1.0.2",
"version": "1.0.3",
"description": "Read and write binary data on ArrayBuffers",

@@ -5,0 +5,0 @@ "main": "src/iobuffer.js",

@@ -81,3 +81,3 @@ # iobuffer

* readInt8
* readUint8
* readUint8 / readByte / readBytes(n)
* readInt16

@@ -89,2 +89,3 @@ * readUint16

* readFloat64
* readChar / readChars(n)

@@ -91,0 +92,0 @@ ## License

@@ -24,2 +24,15 @@ 'use strict';

readByte() {
return this._data.getUint8(this.offset++);
}
readBytes(n) {
if (n === undefined) n = 1;
var bytes = new Uint8Array(n);
for (var i = 0; i < n; i++) {
bytes[i] = this.readByte();
}
return bytes;
}
readInt16() {

@@ -60,4 +73,17 @@ var value = this._data.getInt16(this.offset, this.littleEndian);

}
readChar() {
return String.fromCharCode(this.readInt8());
}
readChars(n) {
if (n === undefined) n = 1;
var str = '';
for (var i = 0; i < n; i++) {
str += this.readChar();
}
return str;
}
}
module.exports = InputBuffer;

@@ -37,11 +37,9 @@ 'use strict';

it('readUint8', function () {
it('readUint8 / readByte / readBytes', function () {
buffer.readUint8().should.equal(0);
buffer.readUint8().should.equal(255);
buffer.readUint8().should.equal(0);
buffer.readUint8().should.equal(255);
buffer.readUint8().should.equal(255);
buffer.readUint8().should.equal(0);
buffer.readUint8().should.equal(255);
buffer.readUint8().should.equal(0);
buffer.readByte().should.equal(0);
buffer.readByte().should.equal(255);
Array.from(buffer.readBytes()).should.eql([255]);
Array.from(buffer.readBytes(3)).should.eql([0, 255, 0]);
});

@@ -81,2 +79,10 @@

});
it('readChar(s)', function () {
var chars = 'hello'.split('').map(char => char.charCodeAt(0));
var buffer = new InputBuffer(new Uint8Array(chars));
buffer.readChar().should.equal('h');
buffer.readChars().should.equal('e');
buffer.readChars(3).should.equal('llo');
});
});
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