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

hoopy

v0.1.4

Published

Like an array, but rounder.

Downloads

15,862,815

Readme

hoopy

Build status Package status Downloads License

Like an array, but rounder.

Huh?

Hoopy is a circular array data type. It extends Array so that out-of-bounds indices wrap back round to the start of the array (or if they're negative indices, they wrap back round to the end of the array).

What's it useful for?

If you want a fixed-length buffer for streamed I/O, Hoopy can do that for you.

How do I install it?

Via npm:

npm i hoopy --save

Or if you just want the git repo:

git clone [email protected]:philbooth/hoopy.git

How do I use it?

Loading the library

const Hoopy = require('hoopy');

Creating arrays

const hoopy = new Hoopy(10);
assert(Array.isArray(hoopy));

You must pass a size argument to the Hoopy constructor, otherwise it will throw.

Accessing array items

for (let i = 0; i < hoopy.length; ++i) {
  hoopy[i] = i;
  console.log(hoopy[i]);
}

You can read and write array items using square brackets for indexing as you would with a normal array. However, if you write to an out-of-bounds index, it will not increase the length of the array. Instead the index is applied modulo the array length, wrapping back round to the start. Negative indices work in reverse, wrapping back round to the end of the array.

The methods push, pop, shift and unshift will throw if called. Future versions of the library may implement sane behaviour for them. All of the other Array methods work normally.

Growing the array

hoopy.grow(50);

The grow method adds items to the array. It takes one argument, which is the number of items to grow the array by. The new length of the array will be the old length plus the number you pass to grow.

If the current state of the array includes overflowed indices, grow will take care to move those items in to the freshly-created available space, so that the correct order is maintained for your data.

The caller is responsible for ensuring they don't overwrite unprocessed items. If you need to increase the size of the array, you must call grow.

Is there a change log?

Yes.

How do I set up the dev environment?

To install the dependencies:

npm i

To run the tests:

npm t

To lint the code:

npm run lint

What license is it released under?

MIT.