Browse Source

Add DeepClone function in common file

Created a common file for shared functions. The first such function is
DeepClone, which will create a new variable in memory for the passed in
value.
ApisNecros 1 year ago
parent
commit
f629487f8a
1 changed files with 13 additions and 0 deletions
  1. 13 0
      IntComp/common.js

+ 13 - 0
IntComp/common.js

@@ -0,0 +1,13 @@
+/**
+ * Returns a fresh copy of the passed in value
+ *
+ * @param {unknown} toClone A value to clone
+ * @returns {unknown} A clone of the input
+ */
+function DeepClone(toClone) {
+    return JSON.parse(JSON.stringify(toClone));
+}
+
+module.exports = {
+    DeepClone: DeepClone,
+};