Created
October 14, 2022 12:57
-
-
Save joduplessis/33721f810110ce07effb9cb99fe11e70 to your computer and use it in GitHub Desktop.
Recursively create tokens from JS objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { objects } from './objects' | |
const createTokenObject = (obj) => { | |
let o = {} | |
Object.keys(obj).map((key) => { | |
if (typeof obj[key] == "object") { | |
o[String(key)] = createTokenObject(obj[key]) | |
} else { | |
o[String(key)] = { value: obj[key] } | |
} | |
}) | |
return o | |
} | |
console.log(JSON.stringify(createTokenObject(objects))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment