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

xxhash

v0.3.0

Published

An xxhash binding for node.js

Downloads

27,938

Readme

Description

An xxhash binding for node.js.

Build Status Build status

Requirements

Install

npm install xxhash

Examples

  • Hash a file in one step:
var XXHash = require('xxhash');
var fs = require('fs');

var file = fs.readFileSync('somefile');
var result = XXHash.hash(file, 0xCAFEBABE);
  • Hash a file in multiple steps:
var XXHash = require('xxhash');
var fs = require('fs');

var hasher = new XXHash(0xCAFEBABE);

fs.createReadStream('somefile')
  .on('data', function(data) {
    hasher.update(data);
  })
  .on('end', function() {
    console.log('Hash value = ' + hasher.digest());
  });
  • Hash a file with a hash stream:
var HashStream = require('xxhash').Stream;
var fs = require('fs');

var hasher = new HashStream(0xCAFEBABE);

fs.createReadStream('somefile')
  .pipe(hasher)
  .on('finish', function() {
    console.log('Hash value = ' + hasher.read());
  });

API

XXHash Static Methods

  • hash(< Buffer >data, < mixed >seed[, < mixed >encbuf]) - mixed - Performs a single/one-time 32-bit hash of data with the given seed. seed can be an unsigned integer or a Buffer containing (1 <= n <= 4) bytes to use for the seed. The resulting hash is returned. The format of the hash depends on the value of encbuf. If encbuf is a string and one of: buffer, hex, base64, or binary, then the hash value will be encoded in the appropriate format. If encbuf is a Buffer of at least 4 bytes, then the hash value will be written to encbuf and encbuf will be returned. Otherwise, if encbuf is not supplied, then the hash will be an unsigned integer.

  • hash64(< Buffer >data, < mixed >seed[, < mixed >encbuf]) - mixed - Performs a single/one-time 64-bit hash of data with the given seed. seed can be an unsigned integer or a Buffer containing (1 <= n <= 8) bytes to use for the seed. The resulting hash is returned. The format of the hash depends on the value of encbuf. If encbuf is a string and one of: buffer, hex, base64, or binary, then the hash value will be encoded in the appropriate format. If encbuf is a Buffer of at least 8 bytes, then the hash value will be written to encbuf and encbuf will be returned. The default value for encbuf is 'buffer'.

XXHash Static Properties

  • Stream(< mixed >seed[, < integer >bits][, < mixed >encbuf]) - DuplexStream - A stream constructor that takes in the seed to use. Write data to the stream and when the stream ends, a bits-bit (32 or 64) hash value (format determined by encbuf) is available on the readable side. The values for seed and encbuf are described above in hash().

  • XXHash64(< mixed >seed) - This is the 64-bit Hash constructor. It is only needed if you want to use the old streaming interface (update()/digest()) instead of the streams2 interface described above.

XXHash Methods

  • (constructor)(< mixed >seed) - Creates and returns a new 32-bit Hash instance with the given seed. The values for seed are described above in hash().

  • update(< Buffer >data) - (void) - Update the hash using data.

  • digest([< mixed >encbuf]) - mixed - The values for encbuf and the resulting hash value format is described in hash().