Skip to content

Instantly share code, notes, and snippets.

@Hibrix-net
Last active April 26, 2022 15:57
Show Gist options
  • Save Hibrix-net/a28efe8ba860474ce5180978fab12dfa to your computer and use it in GitHub Desktop.
Save Hibrix-net/a28efe8ba860474ce5180978fab12dfa to your computer and use it in GitHub Desktop.
Random object properties generator (example with 5.000 properties: keys with 21 chars, values with 6 chars)
const obj = {};
for (let index = 0; index < 5000; index++) {
obj[makeid(21)] = makeid(6);
}
function makeid(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
copy(obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment