-
-
Save surma/d473bc68902984e6ade4fbe34ed55c3c to your computer and use it in GitHub Desktop.
This file contains 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
function randomString(bytes) { | |
let arr = new Array(bytes).fill(0); | |
arr = arr.map(_ => Math.floor(Math.random() * 256)); | |
return btoa(arr); | |
} | |
const idLen = 16; | |
function randomObject(depth, width) { | |
const r = {}; | |
for(let i = 0; i < width; i++) { | |
if(depth == 0) { | |
r[randomString(idLen)] = i; | |
} else { | |
r[randomString(idLen)] = randomObject(depth-1, width); | |
} | |
} | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment