Skip to content

Commit

Permalink
chore: deprecate unused utils, add docs for genJSON (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
andr-ll committed Sep 18, 2023
1 parent 0ef9481 commit 405dd33
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 1,788 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ import nuti from 'nuti';
const { nuti } = require('nuti');
```

## Available utilities
## Docs for available utilities

1. [logger](./docs/logger.md)
2. [timeout](./docs/timeout.md)
3. [flag](./docs/flag.md)
4. [prettify](./docs/prettify.md)
5. [rand](./docs/rand.md)
6. [http](./docs/httpClient.md)
7. [clone](./docs/clone.md)
8. [floats](./docs/floats.md)
9. [validate / buildSchema](./docs/validate.md)
3. [rand](./docs/rand.md)
4. [clone](./docs/clone.md)
5. [floats](./docs/floats.md)
6. [genJSON](./docs/genJSON.md)

[npm-img]: https://img.shields.io/npm/v/nuti.svg?logo=npm
[npm-url]: https://www.npmjs.com/package/nuti
Expand Down
39 changes: 0 additions & 39 deletions docs/flag.md

This file was deleted.

98 changes: 98 additions & 0 deletions docs/genJSON.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
## Description

A function which creates desired JSON file from given input.

## Usage

### Create single json object:

```ts
import nuti from 'nuti';

await nuti.genJSON({
path: './result.json',
data: {
name: () => nuti.rand.str(),
age: () => nuti.rand.numb(0, 100),
createdAt: () => nuti.rand.date(),
isOnline: false,
something: 'static string value',
},
});
```

The `./result.json` should look as following:

```json
{
"name": "shZGAPzT",
"age": 38,
"createdAt": "2023-09-15T20:42:15.997Z",
"isOnline": false,
"something": "static string value"
}
```

### Create array of json objects:

```ts
import nuti from 'nuti';

await nuti.genJSON({
path: './result.json',
data: [
{
name: () => nuti.rand.str(),
age: () => nuti.rand.numb(0, 100),
createdAt: () => nuti.rand.date(),
isOnline: false,
something: 'static string value',
},
],
amount: 5,
});
```

The `./result.json` should look as following:

<-- cspell:disable -->

```json
[
{
"name": "jfIoRdcl",
"age": 5,
"createdAt": "2023-09-04T20:44:09.779Z",
"isOnline": false,
"something": "static string value"
},
{
"name": "xeZqPGhA",
"age": 93,
"createdAt": "2023-09-05T20:44:09.780Z",
"isOnline": false,
"something": "static string value"
},
{
"name": "iMeIuLph",
"age": 100,
"createdAt": "2023-09-07T20:44:09.780Z",
"isOnline": false,
"something": "static string value"
},
{
"name": "TtbnARmH",
"age": 36,
"createdAt": "2023-09-10T20:44:09.780Z",
"isOnline": false,
"something": "static string value"
},
{
"name": "cBAXcTHL",
"age": 11,
"createdAt": "2023-09-18T20:44:09.780Z",
"isOnline": false,
"something": "static string value"
}
]
```

0 comments on commit 405dd33

Please sign in to comment.