@saulx/hash
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

hash

Fast, low collision hashing based on djb2

hash

Returns a 64 bit number, works for any data type

import { hash } from '@saulx/hash'
hash({ x: true })
hash([1, 2, 3])
hash('xyz')

hashObjectIgnoreKeyOrder

Returns a 64 bit number, works for objects and arrays - ignores order of keys in objects

import { hashObjectIgnoreKeyOrder } from '@saulx/hash'
console.log(
  hashObjectIgnoreKeyOrder({ x: true, y: true }) ===
    hashObjectIgnoreKeyOrder({ y: true, x: true })
)

hashCompact

Same as hash but returns a 62 bit string

import { hashCompact } from '@saulx/hash'

console.log(hashCompact({ x: true, y: true }))

Readme

Keywords

Package Sidebar

Install

npm i @saulx/hash

Weekly Downloads

479

Version

3.0.0

License

MIT

Unpacked Size

25.9 kB

Total Files

33

Last publish

Collaborators

  • saulx