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 / toThingIdentifier.ts
Size: Mime:
/**
 * @alias toValueEqIdentity
 */
import { toIdentityHash } from './toIdentityHash'
import { IDENTIFIER_REFERENCE_REGISTRY } from './IDENTIFIER_REGISTRY'

/**
 * we extract the 3 key properties into this
 */
const small = Object.seal({
  label: '',
  value: '',
  type: '',

  // meta: '',
  // if we had, why use this
  // identifier: '',
})

function toThingIdentifier(obj) {
  if (IDENTIFIER_REFERENCE_REGISTRY.has(obj)) {
    return IDENTIFIER_REFERENCE_REGISTRY.get(obj)
  }

  // reuse for perf
  small.label = obj.label
  small.value = obj.value
  small.type = obj.type
  // could simplify here or ignore
  // small.meta = obj.meta

  return toIdentityHash(small)
}

export { toThingIdentifier }