Created
July 18, 2019 08:52
-
-
Save aal89/d458d78e21bcef942ab66934b1438693 to your computer and use it in GitHub Desktop.
Generates text files with random numbers of a particular size. Size is given in kb's as first parameter, defaults to 100.
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
const fs = require("fs"); | |
const lineLength = 126; | |
const sizeInKb = process.argv[2] || 100; | |
let data = ""; | |
for(var i = 0; i < sizeInKb * 1024; i++) { | |
if (i && i % lineLength === 0) { | |
data += "\n"; | |
} else { | |
data += Math.floor(Math.random() * 10); | |
} | |
} | |
fs.writeFileSync(`./${sizeInKb}kb.txt`, data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment