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

hazz

v1.1.0

Published

Hazz, a pseudo-random-data-filled-table to generate k indipendent and uniform, very fast (non-cryptographic) hash functions.

Downloads

82

Readme

Hazz

NPM VERSION CODACY BADGE CODECLIMATE-TEST-COVERAGE LICENSE

NODE VERSION TRAVIS CI BUILD BUILD STATUS DEVDEPENDENCY STATUS

NPM MONTHLY NPM YEARLY NPM TOTAL

NPM GRAPH

Hazz, a pseudo-random-data-filled-table to generate k indipendent and uniform, very fast (non-cryptographic) hash functions.

If you need to hash arbitrary long length inputs, without using a fixed (big) size pseudo-random table, a fast way is to simulate a set of indipendent hash functions using a single crpyto-digest (with a sha-512 digest we can simulate up to 16 functions). Take a look to Mazz (the fast way of the tonto).

Install

$ npm install hazz [-g]

require:

var Hazz  = require( 'hazz' );

Run Tests

to run all test files, install devDependencies:

 $ cd hazz/
 # install or update devDependencies
 $ npm install 
 # run tests
 $ npm test

to execute a single test file simply do:

 $ node test/file-name.js

Constructor

Specify how many bytes to parse (at max), from every input key to hash, then the number of functions to use.

NOTE:

  • default value for input length is 16 byte.
  • default and minimum value for hfn is 2

Arguments between [] are optional.

Hazz( [ Number max_input_length [, Number hfn ] ] )
// or
new Hazz( [ Number max_input_length [, Number hfn ] ] )

Properties

/*
 * the table containing pseudo-random data for generating hash numbers.
 * NOTE: the size of the table is: (max_input_length * hfn) kilobytes,
 * it doesn't depends on the expected population.
 */
Hazz.table

/*
 * max input key length  
 */
Hazz.ilength

/*
 * total number of hash functions  
 */
Hazz.hfn

Methods

Arguments between [] are optional.

/*
 * re-fill table with fresh pseudo-random numbers
 */
Hazz#refill() : Hazz

/*
 * Specify a positive integer (from 0 to k-1) to use the k-th
 * hash function. If specified it returns a number within a
 * range.
 * 
 * NOTE: 
 *  - the input should be a Buffer (no Strings or Arrays).
 *  - the minimum range is obviously 2 (0, 1).
 *  - the integers produced are at min 4 byte long (>= 2^24),
 *    longer the input parsed, bigger the numbers produced.
 */
Hazz#do( Number hfn, Buffer data [, Number range ] ) : Number

/*
 * hash with all functions in parallel,
 * it returns an array of results
 */
Hazz#all( Buffer data [, Number range ] ) : Array

See examples.

MIT License

Copyright (c) 2017-present < Guglielmo Ferri : [email protected] >

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

GA