Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/identifier / src / toIdentity.ts
Size: Mime:
/**
 * @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