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 🙏

© 2024 – Pkg Stats / Ryan Hefner

queue-buffer

v0.2.0

Published

A flex buffer which behaves as a dynamic queue with a complete but limited Buffer API.

Downloads

14

Readme

Queue-Buffer

A flex buffer which behaves as a dynamic queue with a complete but limited Buffer API.

  • Queue-Buffer extends Flex-Buffer.
  • Tested on Node 0.8-0.12, latest iojs on Mac, Linux and Windows.
  • Entities in the queue are kept in order and the only operations on the collection are the addition of entities to the rear terminal position, known as enqueue(write), and removal of entities from the front terminal position, known as dequeue(read).

NPM version Build Status Build status

Quick Start

npm install queue-buffer -S

then

QueueBuffer = require("queue-buffer");

buf = new QueueBuffer(10);
buf.write([1, 2, 3, 4, 5]);
buf.writeInt32LE(14);
buf.read(5);

API

QueueBuffer extends Flexbuffer, please see Flex-Buffer for more API info.

  • QueueBuffer.AUTO_RELEASE_THRESHOLD

    Auto release threshold(ms)

    • type: { number }
  • constructor (arg, opts = {})

    see FlexBuffer

    • param: arg { number | Buffer | Array | string }

      The same arg as Buffer.

    • param: opts { Object={} }

      options

    • option: autoRelease { boolean }

      auto release useless space

    • option: autoReleaseThreshold { number }

      auto release threshold(ms)

  • free ()

    Release useless space which has been read.

  • move (size)

    Move current read offset.

    • param: size { number }

      number of bytes to move, can be negative.

  • skip (size)

    Move current read offset forward.

    • param: size { number }

      number of bytes to skip

  • rewind (size)

    Move current read offset backward.

    • param: size { number }

      number of bytes to rewind

  • read (size) (alias: unshift, dequeue)

    Read bytes from the head of the buffer.

    • param: size { number }

      number of bytes to read

    • return: { Buffer }

      data

  • write (value, encoding = "utf8") (alias: push, enqueue)

    see FlexBuffer

    • param: value { number | string | Array | Buffer }

      The value to write

    • param: encoding { string="utf8" }

      string encoding

  • length

    length of the data

    • type: { number }

All the native Buffer API is wrapped. However, read* methods can only read data from head, with no offset argument.

Test

npm test

Benchmark

npm run benchmark

Environment: OS X 10.10.4, Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz

io.js v2.4.0

  • Read

    • Buffer x 721,399 ops/sec ±0.52% (93 runs sampled)
    • FlexBuffer x 656,232 ops/sec ±0.87% (90 runs sampled)
  • wrapped native API

    • Buffer x 17,708,521 ops/sec ±0.72% (93 runs sampled)
    • FlexBuffer x 12,937,044 ops/sec ±0.70% (91 runs sampled)

io.js v3.0.0

see https://github.com/dracupid/flex-buffer#benchmark for more info

  • Read

    • Buffer x 323,664 ops/sec ±0.68% (91 runs sampled)
    • FlexBuffer x 320,600 ops/sec ±0.75% (93 runs sampled)
  • wrapped native API

    • Buffer x 9,614,392 ops/sec ±0.70% (92 runs sampled)
    • FlexBuffer x 7,115,334 ops/sec ±0.68% (93 runs sampled)

License

MIT@Jingchen Zhao