-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: deprecate unused utils, add docs for genJSON (#212)
- Loading branch information
Showing
27 changed files
with
107 additions
and
1,788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
``` |
Oops, something went wrong.