npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

npm-netbuffer

v1.0.8

Published

NetBuffer for reading and writing bytes in buffer

Readme

NetBuffer

NetBuffer is a helper library to write/read binary data

Features:

  • Grows the Buffer size as needed
  • Useful string operations. (Null terminating strings)
  • the buffer offset will automatically increase after each reading and writing so no need to handle it manually
  • Allows inserting values at specific offset in the Buffer
  • Allows reading values at specific offset in the Buffer
  • Compress and decompress the buffer with zlib library

Instalation

npm install npm-netbuffer --save  

Usage

const buffer = require('npm-netbuffer');  
let netBuffer = new buffer(2);  
netBuffer.writeU8(255); // or buff.writeExt(buff.u8, 255);  
netBuffer.writeS8(-127); // or buff.writeExt(buff.s8, -127);  
  
console.log("Bytes:", netBuffer.bytes, "Size:", netBuffer.size, "Offset:", netBuffer.tell);  
  
netBuffer.seek = 0; // Reset current offset to 0  
let value_1 = netBuffer.readU8(); // or buff.readExt(buff.u8);  
let value_2 = netBuffer.readS8(); // or buff.readExt(buff.s8);  
  
console.log(value_1, value_2);  
Output : Bytes: <Buffer ff 81> Size: 2 Offset: 2  
Output : 255 -127  

API

netBuffer(size)

Constructor: initialize with a size.

netBuffer numeric methods

readInt8, readInt16LE, readInt32LE, readUInt8, readUInt16LE, readUInt32LE, writeInt8, writeInt16LE, writeInt32LE, writeUInt8, writeUInt16LE, writeUInt32LE

.seek

Set the buffer offset
Exmaple : netBuffer.seek = 2;

.tell

Get the buffer current offset
Example : let currentOffset = netBuffer.tell;

.size

Get the buffer size
Example : let currentOffset = netBuffer.size;

.sizeof(type)

type: The type of data that is to be checked.
Return the size (in bytes) of any of the given data constants(listed here)

.resize(size)

Resize the buffer to be the size (in bytes) that you specify.

.copy(offset, size, dest_buffer, dest_offset)

offset : The data offset to start copying from (in bytes).
size : The size of the data to copy (in bytes).
dest_buffer : The index of the buffer to copy to.
dest_offset : The offset position to copy the data to (in bytes).

This function can be used to copy a segment (or all) of the data stored in the buffer to another.

.compress()

With this function you can compress all of the buffer using zlib compression.

.decompress()

With this function you can decompress the buffer using zlib compression.

Write

.writeS8(value) Write signed 8bit integer.
.writeU8(value) Write unsigned 8bit integer.
.writeS16(value) Write signed 16bit integer.
.writeU16(value) Write unsigned 16bit integer.
.writeS32(value) Write signed 32bit integer.
.writeU32(value) Write unsigned 32bit integer.
.writeString(value) Write a string of any size, finalized with a null terminating character.
.writeText(value) Write a string of any size, without the final null terminating character.
.writeExt(value, type) Write data to the buffer with a value and given type (listed here).

Read

.readS8()Read signed 8bit integer.
.readU8()Read unsigned 8bit integer.
.readS16()Read signed 16bit integer.
.readU16()Read unsigned 16bit integer.
.readS32()Read signed 32bit integer.
.readU32()Read unsigned 32bit integer.
.readString()Read a string of any size.
.readtext()Read a string of any size, without the final null terminating character.
.readExt(type) Read data from the buffer with a given type (listed here).

BufferTypes

.s8

A signed, 8bit integer. This can be a positive or negative value from -128 to 127 (0 is classed as positive).

.u8

An unsigned, 8bit integer. This is a positive value from 0 to 255.

.s16

A signed, 16bit integer. This can be a positive or negative value from -32,768 to 32,767 (0 is classed as positive).

.u16

An unsigned, 16bit integer. This is a positive value from 0 - 65,535.

.s32

A signed, 32bit integer. This can be a positive or negative value from -2,147,483,648 to 2,147,483,647 (0 is classed as positive).

.u32

An unsigned, 32bit integer. This is a positive value from 0 to 4,294,967,295.

.string

A string of any size, finalized with a null terminating character.

.text

A string of any size, without the final null terminating character.

author :

Ali Jahandideh [email protected]