Socket
Socket
Sign inDemoInstall

make-mega

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.41 to 0.2.0

100-mb.txt

35

index.js
const fs = require("fs"),
mb = 1000000,
oneMega = require('./one-mega'),
size = process.argv[2] || 100;
let content = "0";
function main() {
try {
if (size > 700)
throw new Error("Sorry, I can only make files up to 700mb.");
console.log("Generating base string...");
while (content.length < size * mb) {
let additive = content;
if (additive.length > mb * 600) additive = additive.substring(0, 10 * mb);
if (additive.length > mb * 500) additive = additive.substring(0, 50 * mb);
content = `${content}${additive}`;
}
console.log(`Trimming to ${size}mb...`);
const offset = content.length - mb * size;
content = content.substring(0, content.length - offset);
console.log(`Attempting to write...`);
// eslint-disable-next-line node/prefer-promises/fs
fs.writeFile(
Math.floor(content.length / 1000 / 1000) + "-mb.txt",
content,
error => {
if (error) throw error;
console.log(`${size}mb file successfully created.`);
}
);
const stream = fs.createWriteStream(size + "-mb.txt", { flags: 'a'});
[...Array(size)].forEach(function(item, index) {
stream.write(oneMega);
})
stream.end();
console.log(`${size}mb file successfully created.`);
} catch ({ message }) {

@@ -39,2 +20,4 @@ console.log(message);

main();
module.exports = main;
{
"name": "make-mega",
"version": "0.1.41",
"version": "0.2.0",
"description": "Make large files for testing in increments of one megabyte. ",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -24,1 +24,4 @@ # make-mega

```
## Releases
* 0.2.0 - Change to using a stream to append the data to the file. This should remove the previous file size limitations.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc