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 🙏

© 2025 – Pkg Stats / Ryan Hefner

appendable-buffer

v1.1.0

Published

A data structure on top of raw buffers that lets you append to buffers.

Downloads

2

Readme

appendable-buffer

A data structure on top of raw buffers that lets you append to buffers.

First, allocate a large (say, 1mb) buffer fill with zeros. Then inside of that, we create linked lists of contigious regions (blocks). lets say we have a lot of lists of numbers, and we don't know how many we'll need. We start of allocating enough space for say 8 items - then when that fills, we append another block but this time for 16 and so on. On average everything will be half full, and we can access any point by following the pointers - since each block gets bigger, we only need to follow O(log(N)) links, which is acceptable. Also, it can be quickly read in or written to disk without parsing, and it will not interact with garbage collection, since that doesn't touch raw memory.

example

var Appendable = require('appendable-buffer')
var b = new Buffer(1024*1024)
var a = Appendable(b)
//get a block that fits 8 32 bit ints
var i = a.alloc(4*8)
//write values to that block + offset within that block
a.writeUInt32BE(1, i, 0)
a.writeUInt32BE(2, i, 4)
a.writeUInt32BE(1, i, 8)
a.writeUInt32BE(3, i, 12)
a.writeUInt32BE(4, i, 16)
a.writeUInt32BE(5, i, 20)
a.writeUInt32BE(6, i, 24)
a.writeUInt32BE(7, i, 28)
a.writeUInt32BE(8, i, 32)
//we cannot write past the end!
assert.throws(function () {
  a.writeUInt32BE(9, i, 36)
})

//but we can extend the buffer
var i2 = a.alloc(16*4, i)
//i2 is the second block. we can access this directly,
//or via the first block.
a.writeUInt32BE(9, i, 36)

assert.equal(a.readUInt32BE(i, 36), a.readUInt32BE(i2, 0))

api: a = Appendable(buffer)

create an instance from a new buffer (or reload a buffer from disk)

a.available()

return the amount of space available in bytes

new_block_index = a.alloc(size, block_index?)

allocate another block, appending to block_index if it is provided. returns the index of the newly created block.

a.writeUInt32BE (value, block_index, index)

write a 32 bit int to the blockat block_index. follows links to the next block if necessary, and throws if index is out of bounds.

value = a.readUInt32BE (block_index, index)

read a 32 bit int to the block at block_index. follows links to the next block if necessary, and throws if index is out of bounds.

size = a.size(block_index)

sum the size of the block at block_index and link from there.

License

MIT