Socket
Socket
Sign inDemoInstall

bufio

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufio - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

lib/struct.js

2

lib/bufio.js

@@ -16,2 +16,3 @@ /*!

const HashWriter = require('./hashwriter');
const Struct = require('./struct');

@@ -25,2 +26,3 @@ exports.encoding = encoding;

exports.HashWriter = HashWriter;
exports.Struct = Struct;

@@ -27,0 +29,0 @@ exports.read = function read(data, zeroCopy) {

3

lib/reader.js

@@ -92,3 +92,3 @@ /*!

this.offset += off;
return off;
return this;
}

@@ -158,2 +158,3 @@

this.stack.length = 0;
return this;
}

@@ -160,0 +161,0 @@

{
"name": "bufio",
"version": "0.0.1",
"version": "0.0.2",
"description": "Buffer and serialization utilities for javascript",

@@ -5,0 +5,0 @@ "keywords": [

@@ -21,2 +21,45 @@ # bufio

## Struct Usage
``` js
const bio = require('bufio');
class MyStruct extends bio.Struct {
constructor() {
super();
this.str = 'hello';
this.value = 0;
}
write(bw) {
bw.writeVarString(this.str, 'ascii');
bw.writeU64(this.value);
return this;
}
read(br) {
this.str = br.readVarString('ascii');
this.value = br.readU64();
return this;
}
}
const obj = new MyStruct();
console.log('Buffer:');
console.log(obj.encode());
console.log('Decoded:');
console.log(MyStruct.decode(obj.encode()));
console.log('Hex:');
console.log(obj.toHex());
console.log('Decoded:');
console.log(MyStruct.fromHex(obj.toHex()));
console.log('Base64:');
console.log(obj.toBase64());
```
## Contribution and License Agreement

@@ -23,0 +66,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