Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fnv1a

schwarzkopfb40.7kMIT1.1.1TypeScript support: included

Simple 32 bit FNV-1a hash algorithm implementation.

hash, fnv, fnv1a, algorithm

readme

view on npm npm module downloads per month node version license

fnv1a

Simple and fast 32 bit FNV-1a hash for node.js based on this.

Usage

import { equal } from 'assert'
import hash from 'fnv1a'

const value = hash('node.js')

// decimal
equal(value, 3096844302)

// hexadecimal
equal(value.toString(16), 'b896180e')

// string
equal(value.toString(36), '1f7s4cu')

Note: importing via require() is also supported.

Installation

npm install fnv1a

License

MIT license.

changelog

1.1.0

  • let override hash base init value per call (through 2nd argument)
  • rewrite in TypeScript (so provide type declarations)
  • support importing the module both via import and require