diff options
Diffstat (limited to 'app/javascript/helpers/clone.js')
| -rw-r--r-- | app/javascript/helpers/clone.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/javascript/helpers/clone.js b/app/javascript/helpers/clone.js new file mode 100644 index 000000000..00127e2b1 --- /dev/null +++ b/app/javascript/helpers/clone.js @@ -0,0 +1,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 +}
\ No newline at end of file |
