# test-file-generator

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

Latest version **1.0.11** (published 2020-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install test-file-generator
pnpm add test-file-generator
yarn add test-file-generator
bun add test-file-generator
```

Provides the command `generate`.

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2020-12-03 |
| First published | 2020-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | M-G |
| Maintainers | pacmax02 |
| Keywords | File, generator, javascript, typescript, nodejs, random, JPEG, GIF, CVS, TXT |

## Links

- npm: https://www.npmjs.com/package/test-file-generator
- Repository: https://github.com/pacmax2/file-generator
- Homepage: https://github.com/pacmax2/file-generator#readme
- Issues: https://github.com/pacmax2/file-generator/issues
- npm.io page: https://npm.io/package/test-file-generator

## Dependencies (3)

- [jimp](https://npm.io/package/jimp.md) ^0.16.1
- [yargs](https://npm.io/package/yargs.md) ^16.1.1
- [omggif](https://npm.io/package/omggif.md) ^1.0.10

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.11 (latest) — 2020-12-03
- 1.0.10 — 2020-12-03
- 1.0.9 — 2020-12-03
- 1.0.8 — 2020-12-03
- 1.0.6 — 2020-12-03
- 1.0.5 — 2020-12-01
- 1.0.4 — 2020-12-01
- 1.0.3 — 2020-12-01
- 1.0.2 — 2020-11-08
- 1.0.1 — 2020-11-06
- 1.0.0 — 2020-10-30

## 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](https://github.com/pacmax2/test-file-generator/blob/main/exampleOutput/dsfuiak7qg9.png?raw=true) | ![alt text](https://github.com/pacmax2/test-file-generator/blob/main/exampleOutput/9v4qvs9619i.gif?raw=true)

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

##  How to use from command line:

```bash
npm install -g test-file-generator    

generate --help

generate 
```

If you want to generate more than one file
```bash

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 
  
```typescript
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 "**./**". 
```typescript
  let generator = new TestFileGenerator('txt');
  generator.generateFile();
```
  2. This will generate a gif file with the specified parameters.
```typescript
  let generator = new TestFileGenerator('gif');
  generator.setLocation('my_path/');
  generator.setImageSize(100, 100);
  generator.setName('my_file_name');
  generator.generateFile();
```
  3. This will generate a cvs file of 3000 KB.
```typescript
  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 <br> [**optional**] name: string <br> [**optional**] location: string <br> [**optional**] size: number <br> [**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**](https://github.com/pacmax2/file-generator/issues)

---
_Source: https://npm.io/package/test-file-generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
