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

hashie

v1.1.4

Published

hashie is a small library that implements a hash data structure.

Downloads

5

Readme

Hashie

Hashie is a small library that implements a hash data structure.

Installation

npm i hashie

Usage

var Hashie = require('hashie');

//create a new Hashie object with the desired key.
var myHash = new Hashie(10);

myHash.add(10);
myHash.add(43);
myHash.add(20);
myHash.print();
myHash.erase(10);

What it does

For every element you want to insert (e.g. 543) a new key is generated with a custom modulo (on creation). So the key for var myHash = new Hashie(10) would be yourNumber % 10. Hashie will push in the position 3 (from 543) and insert the number 543 there.

API methods

The following methods exist for Hashie (more coming):

//Adds element to data structure
myHash.add(number);

//Erases certain element
myHash.erase(number);

//Finds a certain element (boolean)
myHash.find(number);

//Returns the amount of elements in the hash
myHash.getCounter();

//Returns the kays used so far
myHash.getKeyChain();

//Returns the whole data structure
myHash.getHashTable();

//Returns the singular array stored in the hash
myHash.drawer(0); //index of drawer

//Erases a certain element of the hash
myHash.erase(x) // number to be deleted

//Prints the hash
myHash.print();

//Resets the hash
myHash.dump();

Data types

Hashie accepts ints and floats for now.

Colissions

Since it's an array, colissions are handled with a simple push method. so the drawer with key 3 can have multiple values (543, 643, 943, 743, etc).

Optimization

Hashie is designed for large amounts of data that avoid many colissions (e.g. 01192543 with a key of % 100 to be 43). For a set of 150,000 ids, there'd only be around 150 colissions (which is good). This means that for searching for a specific piece of data, instead of looking in 150,000 elements, you'd only look at about 150

Avoid

Adding numbers with the same key (430, 320, 540, 870) exclusively, as this will only generate a single array.