Comparing version 9.1.0 to 9.5.0
@@ -0,0 +0,0 @@ /*files.js*/ |
{ | ||
"name": "utilsac", | ||
"version": "9.1.0", | ||
"version": "9.5.0", | ||
"description": "JavaScript General Purpose Utility Functions", | ||
@@ -5,0 +5,0 @@ "main": "files.js", |
@@ -41,3 +41,4 @@ # JavaScript General Purpose Utility Functions | ||
timePromise, | ||
memoizeAsStrings | ||
memoizeAsStrings, | ||
deepCopy | ||
} from "path.../utility.js"; | ||
@@ -44,0 +45,0 @@ ``` |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -14,3 +14,4 @@ export { | ||
timePromise, | ||
memoizeAsStrings | ||
memoizeAsStrings, | ||
deepCopy | ||
}; | ||
@@ -63,6 +64,6 @@ | ||
The last call is always eventually executed | ||
the returned function always returns undefined | ||
*/ | ||
let timeOutId = 0; | ||
@@ -259,3 +260,3 @@ let lastTime = Number.MIN_SAFE_INTEGER; | ||
*/ | ||
const previousResults = {}; | ||
@@ -275,1 +276,21 @@ return function (...args) { | ||
}; | ||
/** | ||
only works with undefined, null, Numbers, Symbols, Objects, Arrays, | ||
warning does not work with cyclic objects | ||
*/ | ||
const deepCopy = (x) => { | ||
if (!x || typeof x !== 'object') { | ||
return x; | ||
} | ||
if (Array.isArray(x)) { | ||
return x.map(cloneDeep); | ||
} | ||
const copy = {} | ||
for (let key in x) { | ||
copy[i] = cloneDeep(x[i]); | ||
} | ||
return copy; | ||
}; |
Sorry, the diff of this file is not supported yet
24280
490
68