Skip to content

Instantly share code, notes, and snippets.

@shaohua
Created May 22, 2015 16:53
Show Gist options
  • Save shaohua/e183a596e8d12db7c508 to your computer and use it in GitHub Desktop.
Save shaohua/e183a596e8d12db7c508 to your computer and use it in GitHub Desktop.
Generate random size js
#!/usr/bin/env node
/*
https://gist.github.com/stangah/04e7ce784ab64beb9919
Call from command line to create files of various sizes:
node fileCreatorThingy.js 1 10 100 200 300
*/
var fs = require('fs');
var argv = require('yargs').argv;
var createFileOfSize = function(kb) {
var line = new Array(1020);
for(var i=0; i<line.length; i++) {
line[i] = 0;
}
line = '/*' + line.join('') + '*/';
var sizedChunk = '';
for(var i = kb ; i > 0; i--) {
sizedChunk += line + '\n';
}
fs.writeFile(kb + 'k.js', sizedChunk);
};
argv._.forEach(function(size) {
createFileOfSize(size);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment