包详细信息

rnd-file

RomanBurunkov197MIT0.0.1

Generation of a random files with Node.JS.

generate, random, files

自述文件

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 name Description Default
fileName File name as a String 'random.file'
filePath Path to a file as a String os.tmpdir()
fileSize File size in bytes as a Number 1024
chunkSize Chunk size in bytes as a Number 1024
hashAlgo Algorithm 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();