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/modules / ___dist / state-tree / __identifier.js
Size: Mime:
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,
}