Repository URL to install this package:
|
Version:
1.1.16 ▾
|
import { Serializable } from 'typings'
import { fromIshToBoolean, autofixSafe } from 'exotic'
import { stateTreeIdentifier } from 'modules/identifier'
// @todo validate - just means mainly no fns?
const stringifyClone = (pureJSON: Serializable): Serializable => {
const dead = JSON.stringify(pureJSON)
const live = JSON.parse(dead)
return live
}
const transformWithMagicIdentifier = (snapshot, current = undefined) => {
const cloned = stringifyClone(snapshot || {})
cloned.__identifier = stateTreeIdentifier(current || cloned)
return autofixSafe(cloned)
}
export {
stringifyClone,
transformWithMagicIdentifier,
transformWithMagicIdentifier as autofixTransform,
}