New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

offset-buffer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

offset-buffer

Node.js Buffer wrapper that keeps track of your read and write offsets

0.0.1
latest
npm
Version published
Weekly downloads
9
-30.77%
Maintainers
1
Weekly downloads
 
Created
Source

offset-buffer

Build Status

Node.js Buffer wrapper that keeps track of your read and write offsets.

It also includes support for reading and writing 24-bit and 64-bit integers (via the int24, and ref libraries respectively).

Example

var OffsetBuffer = require('offset-buffer'),
    ob = new OffsetBuffer(15),
    val;

// write offsets are managed automatically so you can do this:
ob.writeInt8(1);            // ob.write_offset = 1
ob.writeInt32BE(100;        // ob.write_offset = 5
ob.writeUInt64BE(1000);     // ob.write_offset = 13
ob.writeUInt16BE(10);       // ob.write_offset = 15

// you can also read from the buffer and it keeps track of your read offset:
val = ob.readInt8();        // ob.read_offset = 1
val = ob.readInt32BE();     // ob.read_offset = 5
val = ob.writeUInt64BE();   // ob.read_offset = 13
val = ob.writeUInt16BE();   // ob.read_offset = 15

// some extra convenience copy methods that keep track of your offsets
// (see code for more)
var buffer1 = new Buffer('abc'),
    buffer2 = new Buffer('def'),
    ob = new OffsetBuffer(6);

ob.copyFrom(buffer1);       // ob == 'abc'
ob.copyFrom(buffer2);       // ob == 'abcdef'

Install

npm install offset-buffer

Tests

npm test

License

MIT License

Keywords

offset

FAQs

Package last updated on 25 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts