New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simple-buffer-cursor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-buffer-cursor

Read and write to a buffer easily

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

simple-buffer-cursor

CircleCI Coverage Status

Simplify reading and writing to buffers by internally maintaining the position. This library exposes a wrapper for a buffer that uses similar read and write methods to those found in the Node Buffer API.

Usage:

npm install simple-buffer-cursor
const BufferCursor = require('simple-buffer-cursor');

let buffer = BufferCursor(Buffer.alloc(8));
buffer.writeUInt8(1);
buffer.writeUInt16BE(2);
buffer.writeUInt32BE(3);
buffer.writeBytes(Buffer.from([4]));
buffer.position = 0;
console.log(buffer.readUInt8());
console.log(buffer.readUInt16BE());
console.log(buffer.readUInt32BE());
console.log(buffer.readBytes());

API

  • position: number - the current buffer cursor position

  • eof: bool - whether the current position is at the end of the buffer

  • buffer: Buffer - the underlying buffer

  • readUInt8(): number - reads 1 byte

  • readUInt16LE(): number - reads 2 bytes as 16-bit little-endian unsigned integer

  • readUInt16BE(): number - reads 2 bytes as 16-bit big-endian unsigned integer

  • readUInt32LE(): number - reads 4 bytes as 32-bit little-endian unsigned integer

  • readUInt32BE(): number - reads 4 bytes as 32-bit big-endian unsigned integer

  • readBytes([len]): Buffer - reads the optionally specified number of bytes. If no length is supplied, it reads to the end of the buffer.

  • writeUInt8(number): undefined - writes 1 byte

  • writeUInt16LE(number): undefined - writes a number as a 16-bit little-endian unsigned integer

  • writeUInt16BE(number): undefined - writes a number as a 16-bit big-endian unsigned integer

  • writeUInt32LE(number): undefined - writes a number as a 32-bit little-endian unsigned integer

  • writeUInt32BE(number): undefined - writes a number as a 32-bit big-endian unsigned integer

  • writeBytes(buffer): undefined - writes the supplied buffer to the cursor buffer

Keywords

buffer

FAQs

Package last updated on 09 Feb 2019

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