Browse Source

Add deepClone function

ApisNecros 2 weeks ago
parent
commit
30cbe52823
1 changed files with 11 additions and 0 deletions
  1. 11 0
      common.js

+ 11 - 0
common.js

@@ -52,4 +52,15 @@ export function strToInt(string) {
  */
 export function clamp(value, min = -1, max = 1) {
     return Math.max(min, Math.min(max, value));
+}
+
+/**
+ * Deep clone a value
+ *
+ * @param {any} value
+ *
+ * @returns {any}
+ */
+export function deepClone(value) {
+    return JSON.parse(JSON.stringify(value));
 }