Skip to content

lukeburns/weak-index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

weak-index

weak-index allows you to weakly assign unique ids to tuples of objects.

You should provide a hash function that takes an array of integers to a unique primitive data type. If you do not provide a hash function, weak-index will use the Cantor tuple function, which works well for small numbers of indexes.

npm i weak-index

example

const hash = require('object-hash')
const { WeakIndex } = require('weak-index')

const ids = new WeakIndex(hash)
const o1 = {}, o2 = {}, o3 = {}
console.log(ids.put(o1))
console.log(ids.put(o1, o2))
console.log(ids.put(o2, o1))
console.log(ids.put(o1, o2, o3))

About

weakly assign unique ids to tuples of objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published