0.0.1 • Published 8 months ago

rnd-file v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

node-rnd-file

npm codecov

Generation of a random files with Node.JS.

This module uses fs write streams, so in addition to file's name and path, you can specify each data chunk size, which will be passed into a stream. Default chunk size: 1 KB.

Installation

npm i rnd-file

Available options

Option nameDescriptionDefault
fileNameFile name as a String'random.file'
filePathPath to a file as a Stringos.tmpdir()
fileSizeFile size in bytes as a Number1024
chunkSizeChunk size in bytes as a Number1024
hashAlgoAlgorithm name to generate file's hash as a String'md5'

Usage Example:

const rndFile = require('rnd-file');

// Generates random 4KB file /tmp/myfile.
async function generateRandomFile() {
  const file = await rndFile({
    filePath: '/tmp',
    fileName: 'myfile',
    fileSize: 4096,
    chunkSize: 1024,
  });

  console.log('Generated file:', file);
}

generateRandomFile();
0.0.1

8 months ago