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

test-file-generator

v1.0.11

Published

Generates different file types for testing purposes. The content of the files is generated with a random function.

Downloads

25

Readme

Test file generator

This is a simple module to generate many different random files, which could be used for testing other algorithms that work with files.

Currently supported formats (jpeg, gif, cvs and txt).

| Image | Gif | | --------- | --------- | alt text | alt text

For other examples on random cvs / txt check the exampleOutput folder.

How to use from command line:

npm install -g test-file-generator    

generate --help

generate 

If you want to generate more than one file


generate --number 10

How to use from your project:

  • Install npm install test-file-generator or yarn install test-file-generator
  • Include in your project
import { TestFileGenerator } from 'test-file-generator';
let generator = new TestFileGenerator('txt');
generator.generateFile();
  1. To generate one txt file and random name, at the default path "./".
  let generator = new TestFileGenerator('txt');
  generator.generateFile();
  1. This will generate a gif file with the specified parameters.
  let generator = new TestFileGenerator('gif');
  generator.setLocation('my_path/');
  generator.setImageSize(100, 100);
  generator.setName('my_file_name');
  generator.generateFile();
  1. This will generate a cvs file of 3000 KB.
  let generator = new TestFileGenerator('csv');
  generator.setLocation('output/');
  generator.setSize(3000);
  generator.setName('my_file_name');
  generator.generateFile();

API:

| # | Method | Input / Type | Output / Type | Description |-----|---------------- | --------------- | --------------- | --------------- | 1 | new TestFileGenerator(type: string, clean?: boolean) | [required] type : string [optional] name: string [optional] location: string [optional] size: number [optional] clean: boolean | TestFileGenerator object | The constructor of the object. The default values for the optional parameters are: (name = 'random', location = ''./'', size = 20, clean = false), and even though not passed in the constructor for the images is (100, 100). If you want to modify any parameter just use setter methods.| 2 | generateFile() | None | boolean (true if created, false otherwise) | This method generates the file with the specified parameters. | 3 | setLocation(location: string) | string | None | This method sets the location on which the file is going to be written. | 4 | setName(location: string) | string | None | This method sets the name of the file. If not specified the file will have a random name which you can get with getName(). | 5 | setType(type: string) | string | None | This method sets the file type, currently supported (jpeg, gif, cvs and txt), lowercased. | 6 | setSize(size: number) | number | None | This method sets the size that the file should have, currently only works for txt and cvs file types. | 6 | setImageSize((x: number, y: number) | number, number | None | This method sets the size of the jpeg or gif to be generated. | 7 | setClean(location: string) | string | None | This method deletes the created file after creation (just for writing unit tests). | 8 | getLocation() | None | string | This method gets the file path. | 9 | getName() | None | string | This method gets the file name. | 10 | getSize() | None | string | This method gets the file generation setted size (only for cvs/txt). | 11 | getFileType() | None | string | This method gets the file type. |

License

MIT

Issues, errors, requests or contributions

Open an issue here