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

metrohash

v2.8.0

Published

Node.js bindings for MetroHash hashing library

Downloads

1,296

Readme

node-metrohash

Wrapper around MetroHash.

Build Status Build status

Installation

$ npm install metrohash

API change!

Between v1 and v2, the API for this library has changed to allow for maximum hashing speed.

The biggest change is that a calculated hash is now returned as a (hex-encoded) string instead of a Buffer.

If a Buffer is still required, it's easy to convert the string:

let buffer = Buffer.from(metrohash64('input'), 'hex');

Also, the .hash() methods for the hasher classes have been removed in favor of standalone functions (see below).

Usage

The module exports 2 classes, MetroHash64 and MetroHash128, and two functions, metrohash64 and metrohash128.

The classes are meant for incremental hashing, the functions for standalone hash calculations.

The class constructors and functions accept an optional seed numerical argument, which defaults to 0.

Class interface

const MetroHash64 = require('metrohash').MetroHash64;

// Constructor.
MetroHash64(seed? : number) : this

// Update.
MetroHash64#update(input : String | Buffer) : this

// Finalize and get hash digest.
MetroHash64#digest() : String

(likewise for MetroHash128).

Function interface

const metrohash64 = require('metrohash').metrohash64;

metrohash64(input : String | Buffer, seed? : number) : String

(likewise for metrohash128).

Examples

//// Classes

const MetroHash64 = require('metrohash').MetroHash64;

// Instantiate using seed 123 (`new` is optional).
let hash = new MetroHash64(123);

// Update using a string as input.
hash.update('Hello, World!');

// The same as above:
// hash.update('Hello, ').update('World!');

// Finalize to get the digest as a hex string.
let digest = hash.digest();

//// Functions
const metrohash64 = require('metrohash').metrohash64;

let digest = metrohash64('Hello, World!', 123);

Speed

From v2.0 onwards, MetroHash is pretty fast.