aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/helpers/clone.js
blob: 00127e2b1664aad0e015d234da213c438ddab75b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import _ from 'lodash'

/* This function helps having a bit more security when we pass data from the backend to the React parts
  It clones the obj (window variable) and then conditionnaly delete the window variable
*/

export default function clone(window, key, deletable = false) {
  let obj = _.cloneDeep(window[key])
  
  if (deletable) delete window[key]
  return obj
}