3.0.0 • Published 1 year ago

@saulx/hash v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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 }))