npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fake-file-generator

v1.1.1

Published

File generator at specific type and size

Downloads

408

Readme

fake-file-generator

Fake file generator is a node.js utility to generate files without size limits

stream-based lightweight package with no dependencies

Valid and Invalid files

  • Valid files: filled with valid content for the specific type of file, for example a generated valid file hello.txt of 300 bytes, opened with a text editor, it results in a valid txt file with text content inside.
  • Invalid Files: filled with zero filled buffer placeholder content, for example a generated invalid file: hello.mp3 of 300 bytes, opened with a mp3 player, it results in a compromised and unplayable file.

currently, the only supported valid file is: txt.

the valid txt file is generated with the placeholder: "START-->" at the beginning of the file and the placeholder "<--END" at the end of the file, between "START-->" and "<--END" is filled with a string pattern of characters from a to z.

here an example of the generated content of a valid txt file: START-->abcdefghilmnopqr<--END

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

Install in your project and use as js module:

$ npm install fake-file-generator

Install globally and use as CLI:

$ npm install -g fake-file-generator

Usage

3 modes of usage:

1) JS Module Mode

Require in a js file and use as a module

const FakeFileGenerator = require('fake-file-generator');

const filePath = 'output/hello.txt'; // file path to generate 
const size = 10000; // size of the file in bytes (10MB)

// FakeFileGenerator.makeFile() return a promise resolved when the file is completely written on the file system

// invalid generic file
FakeFileGenerator.makeFile(filePath, size)
    .then(() => {
        console.log('file generated!');
    })
    .catch(console.error);

// valid txt file
const options = { type: 'txt' }
FakeFileGenerator.makeFile(filePath, size, options)
    .then(() => {
        console.log('file generated!');
    })
    .catch(console.error);

2) CLI Mode

Run as a node CLI program and pass parameters directly to it

invalid generic file:
$ fake-file-generator --fileName hello.txt --size 1000
valid txt file:
$ fake-file-generator --fileName hello.txt --size 1000 --type txt

3) Interactive CLI Mode

Run as a node CLI program with no parameters and follow the program instructions

$ fake-file-generator