Repository URL to install this package:
|
Version:
2.1.1 ▾
|
/**
* @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 }