Repository URL to install this package:
|
Version:
3.0.0 ▾
|
/**
* @note - was in view-container
* @todo move to chain
*/
import { fliphash, stringify } from 'chain-able-boost'
// here we can create those unique ids for selectors, keys,
// identity-obj-proxy
let identityIndex = 0
// reuse from registry
let identities = new Map()
function toIdentity(...args) {
const arg = args.length === 0 ? args[0] : args
// if (identities.has(arg)) {
// return identities.get(arg)
// }
// increment to keep unique
identityIndex += 1
const hashcode = '' + identityIndex + stringify(arg)
const hashstring = fliphash(hashcode)
// save it for later
// identities.set(arg, hashstring)
return hashstring
}
export { toIdentity }
export default toIdentity