aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/getObjStructure.js
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-04-10 04:56:59 +0800
committerGitHub <noreply@github.com>2018-04-10 04:56:59 +0800
commitdf1f891585dc41a7d725d592902a84e432e66dc4 (patch)
treee450c931e8d6d4a1277fd57e330fa8882d7cc93f /app/scripts/lib/getObjStructure.js
parent931ce120737210cbbf6736b454580ac0610f527a (diff)
parent305f5f0034f347ee3eacbc4e6ef41817c1de9ab2 (diff)
downloadtangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.tar
tangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.tar.gz
tangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.tar.bz2
tangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.tar.lz
tangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.tar.xz
tangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.tar.zst
tangerine-wallet-browser-df1f891585dc41a7d725d592902a84e432e66dc4.zip
Merge branch 'master' into i3621-LogoPerformance
Diffstat (limited to 'app/scripts/lib/getObjStructure.js')
-rw-r--r--app/scripts/lib/getObjStructure.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/scripts/lib/getObjStructure.js b/app/scripts/lib/getObjStructure.js
new file mode 100644
index 000000000..3db389507
--- /dev/null
+++ b/app/scripts/lib/getObjStructure.js
@@ -0,0 +1,33 @@
+const clone = require('clone')
+
+module.exports = getObjStructure
+
+// This will create an object that represents the structure of the given object
+// it replaces all values with the result of their type
+
+// {
+// "data": {
+// "CurrencyController": {
+// "conversionDate": "number",
+// "conversionRate": "number",
+// "currentCurrency": "string"
+// }
+// }
+
+function getObjStructure(obj) {
+ const structure = clone(obj)
+ return deepMap(structure, (value) => {
+ return value === null ? 'null' : typeof value
+ })
+}
+
+function deepMap(target = {}, visit) {
+ Object.entries(target).forEach(([key, value]) => {
+ if (typeof value === 'object' && value !== null) {
+ target[key] = deepMap(value, visit)
+ } else {
+ target[key] = visit(value)
+ }
+ })
+ return target
+}