Skip to content

atelier-saulx/hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published