Skip to content

Commit daf0e8e

Browse files
committed
feat(types): add js docs in types
1 parent daa84d0 commit daf0e8e

File tree

18 files changed

+1353
-119
lines changed

18 files changed

+1353
-119
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ console.log(Json.removeDuplicated(array)) // [1, 2, 4]
474474

475475
```ts
476476
const array = ['a', 'b', 'c'] // Array length = 2 (0, 1, 2)
477-
const sortedValue = Json.sort(array) // Sorted value from the array, could be a, b or c
477+
const raffledValue = Json.raffle(array) // Raffled value from the array, could be a, b or c
478478

479-
console.log(sortedValue) // a, b or c
479+
console.log(raffledValue) // a, b or c
480480
```
481481

482482
---

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/utils",
3-
"version": "1.9.7",
3+
"version": "1.9.8",
44
"description": "Utils functions and classes for Node.js",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/Helpers/Clean.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export class Clean {
1414
* Remove all falsy values from array.
1515
*
1616
* @param {any[]} array
17-
* @param {boolean?} removeEmpty
18-
* @param {boolean?} cleanInsideObjects
17+
* @param {boolean} [removeEmpty]
18+
* @param {boolean} [cleanInsideObjects]
1919
* @return {any[]}
2020
*/
2121
static cleanArray(array, removeEmpty = false, cleanInsideObjects = false) {
@@ -47,8 +47,8 @@ export class Clean {
4747
* Remove all falsy values from object.
4848
*
4949
* @param {any} object
50-
* @param {boolean?} removeEmpty
51-
* @param {boolean?} cleanInsideArrays
50+
* @param {boolean} [removeEmpty]
51+
* @param {boolean} [cleanInsideArrays]
5252
* @return {any}
5353
*/
5454
static cleanObject(object, removeEmpty = false, cleanInsideArrays = false) {

src/Helpers/Config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class Config {
2626
* Get the value from configuration files.
2727
*
2828
* @param {string} key
29-
* @param {any?} defaultValue
29+
* @param {any} [defaultValue]
3030
* @return {any}
3131
*/
3232
static get(key, defaultValue = undefined) {

src/Helpers/Debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export class Debug {
5454
/**
5555
* Format and throw the message in the stdout accordingly to the namespace.
5656
*
57-
* @param {string|Object} message
58-
* @param {string} namespace
57+
* @param {string|any} message
58+
* @param {string} [namespace]
5959
* @return {void}
6060
*/
6161
static log(message, namespace = 'api:main') {

src/Helpers/Exception.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export class Exception extends Error {
1818
/**
1919
* Creates a new instance of Exception.
2020
*
21-
* @param {string?} content
22-
* @param {number?} status
23-
* @param {string?} code
24-
* @param {string?} help
21+
* @param {string} [content]
22+
* @param {number} [status]
23+
* @param {string} [code]
24+
* @param {string} [help]
2525
* @return {Exception}
2626
*/
2727
constructor(content, status = 500, code, help) {
@@ -70,7 +70,7 @@ export class Exception extends Error {
7070
/**
7171
* Transform the exception to a valid JSON Object.
7272
*
73-
* @param stack
73+
* @param [stack] {boolean}
7474
* @return {{
7575
* code: string,
7676
* name: string,
@@ -97,12 +97,12 @@ export class Exception extends Error {
9797
/**
9898
* Prettify the error using Youch API.
9999
*
100-
* @param {any?} options
101-
* @param {string?} options.prefix
102-
* @param {boolean?} options.hideMessage
103-
* @param {boolean?} options.hideErrorTitle
104-
* @param {boolean?} options.displayShortPath
105-
* @param {boolean?} options.displayMainFrameOnly
100+
* @param {any} [options]
101+
* @param {string} [options.prefix]
102+
* @param {boolean} [options.hideMessage]
103+
* @param {boolean} [options.hideErrorTitle]
104+
* @param {boolean} [options.displayShortPath]
105+
* @param {boolean} [options.displayMainFrameOnly]
106106
* @return {Promise<string>}
107107
*/
108108
async prettify(options) {

src/Helpers/Exec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Exec {
3737
* @param {string} command
3838
* @param {{
3939
* ignoreErrors?: boolean
40-
* }?} options
40+
* }} [options]
4141
* @throws {NodeCommandException}
4242
* @return {Promise<{ stdout: string, stderr: string }>}
4343
*/
@@ -62,9 +62,9 @@ export class Exec {
6262
/**
6363
* Download an archive to determined path.
6464
*
65-
* @param {string} url
6665
* @param {string} name
67-
* @param {string?} path
66+
* @param {string} path
67+
* @param {string} url
6868
* @return {Promise<File>}
6969
*/
7070
static async download(name, path, url) {

src/Helpers/File.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export class File {
3939
* Creates a new instance of File.
4040
*
4141
* @param {string} filePath
42-
* @param {Buffer?} content
43-
* @param {boolean?} mockedValues
44-
* @param {boolean?} isCopy
42+
* @param {Buffer} [content]
43+
* @param {boolean} [mockedValues]
44+
* @param {boolean} [isCopy]
4545
* @return {File}
4646
*/
4747
constructor(
@@ -262,7 +262,7 @@ export class File {
262262
* @param {{
263263
* withContent?: boolean,
264264
* isInternalLoad?: boolean
265-
* }?} options
265+
* }} [options]
266266
* @return {File}
267267
*/
268268
loadSync(options) {
@@ -313,7 +313,7 @@ export class File {
313313
* @param {{
314314
* withContent?: boolean,
315315
* isInternalLoad?: boolean
316-
* }?} options
316+
* }} [options]
317317
* @return {Promise<File>}
318318
*/
319319
async load(options) {
@@ -430,7 +430,7 @@ export class File {
430430
* @param {{
431431
* withContent?: boolean,
432432
* mockedValues?: boolean
433-
* }?} options
433+
* }} [options]
434434
* @return {File}
435435
*/
436436
copySync(path, options) {
@@ -458,7 +458,7 @@ export class File {
458458
* @param {{
459459
* withContent?: boolean,
460460
* mockedValues?: boolean
461-
* }?} options
461+
* }} [options]
462462
* @return {Promise<File>}
463463
*/
464464
async copy(path, options) {
@@ -486,7 +486,7 @@ export class File {
486486
* @param {{
487487
* withContent?: boolean,
488488
* mockedValues?: boolean
489-
* }?} options
489+
* }} [options]
490490
* @return {File}
491491
*/
492492
moveSync(path, options) {
@@ -518,7 +518,7 @@ export class File {
518518
* @param {{
519519
* withContent?: boolean,
520520
* mockedValues?: boolean
521-
* }?} options
521+
* }} [options]
522522
* @return {Promise<File>}
523523
*/
524524
async move(path, options) {
@@ -614,7 +614,7 @@ export class File {
614614
*
615615
* @param {{
616616
* saveContent?: boolean
617-
* }?} options
617+
* }} [options]
618618
* @return {Buffer}
619619
*/
620620
getContentSync(options) {
@@ -636,7 +636,7 @@ export class File {
636636
*
637637
* @param {{
638638
* saveContent?: boolean
639-
* }?} options
639+
* }} [options]
640640
* @return {Promise<Buffer>}
641641
*/
642642
async getContent(options) {

src/Helpers/Folder.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class Folder {
3333
* Creates a new instance of Folder.
3434
*
3535
* @param {string} folderPath
36-
* @param {boolean} mockedValues
37-
* @param {boolean} isCopy
36+
* @param {boolean} [mockedValues]
37+
* @param {boolean} [isCopy]
3838
* @return {Folder}
3939
*/
4040
constructor(folderPath, mockedValues = false, isCopy = false) {
@@ -168,7 +168,7 @@ export class Folder {
168168
* Get sub files of folder.
169169
*
170170
* @param {Folder[]} folders
171-
* @param {string?} pattern
171+
* @param {string} [pattern]
172172
* @return {File[]}
173173
*/
174174
static #getSubFiles(folders, pattern) {
@@ -200,7 +200,7 @@ export class Folder {
200200
*
201201
* @param {Folder} folder
202202
* @param {boolean} recursive
203-
* @param {string?} pattern
203+
* @param {string} [pattern]
204204
* @return {Folder[]}
205205
*/
206206
static #getSubFolders(folder, recursive, pattern) {
@@ -294,7 +294,7 @@ export class Folder {
294294
* withSub?: boolean,
295295
* withFileContent?: boolean,
296296
* isInternalLoad?: boolean,
297-
* }?} options
297+
* }} [options]
298298
* @return {Folder}
299299
*/
300300
loadSync(options) {
@@ -341,7 +341,7 @@ export class Folder {
341341
* withSub?: boolean,
342342
* withFileContent?: boolean,
343343
* isInternalLoad?: boolean,
344-
* }?} options
344+
* }} [options]
345345
* @return {Promise<Folder>}
346346
*/
347347
async load(options) {
@@ -433,7 +433,7 @@ export class Folder {
433433
* withSub?: boolean,
434434
* withFileContent?: boolean,
435435
* mockedValues?: boolean
436-
* }?} options
436+
* }} [options]
437437
* @return {Folder}
438438
*/
439439
copySync(path, options) {
@@ -481,7 +481,7 @@ export class Folder {
481481
* withSub?: boolean,
482482
* withFileContent?: boolean,
483483
* mockedValues?: boolean
484-
* }?} options
484+
* }} [options]
485485
* @return {Promise<Folder>}
486486
*/
487487
async copy(path, options) {
@@ -533,7 +533,7 @@ export class Folder {
533533
* withSub?: boolean,
534534
* withFileContent?: boolean,
535535
* mockedValues?: boolean
536-
* }?} options
536+
* }} [options]
537537
* @return {Folder}
538538
*/
539539
moveSync(path, options) {
@@ -583,7 +583,7 @@ export class Folder {
583583
* withSub?: boolean,
584584
* withFileContent?: boolean,
585585
* mockedValues?: boolean
586-
* }?} options
586+
* }} [options]
587587
* @return {Promise<Folder>}
588588
*/
589589
async move(path, options) {
@@ -632,8 +632,8 @@ export class Folder {
632632
/**
633633
* Get all the files of folder using glob pattern.
634634
*
635-
* @param {string?} pattern
636-
* @param {boolean?} recursive
635+
* @param {string} [pattern]
636+
* @param {boolean} [recursive]
637637
* @return {File[]}
638638
*/
639639
getFilesByPattern(pattern, recursive = false) {
@@ -665,8 +665,8 @@ export class Folder {
665665
/**
666666
* Get all the folders of folder using glob pattern.
667667
*
668-
* @param {string?} pattern
669-
* @param {boolean?} recursive
668+
* @param {string} [pattern]
669+
* @param {boolean} [recursive]
670670
* @return {Folder[]}
671671
*/
672672
getFoldersByPattern(pattern, recursive = false) {

src/Helpers/Is.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class Is {
7676
/**
7777
* Verify if is valid Empty.
7878
*
79-
* @param {string, Object, Array} value
79+
* @param {string|any|any[]} value
8080
* @return {boolean}
8181
*/
8282
static Empty(value) {
@@ -102,7 +102,7 @@ export class Is {
102102
/**
103103
* Verify if is a valid Cep.
104104
*
105-
* @param {string, number} cep
105+
* @param {string|number} cep
106106
* @return {boolean}
107107
*/
108108
static Cep(cep) {
@@ -114,7 +114,7 @@ export class Is {
114114
/**
115115
* Verify if is a valid Cpf.
116116
*
117-
* @param {string, number} cpf
117+
* @param {string|number} cpf
118118
* @return {boolean}
119119
*/
120120
static Cpf(cpf) {
@@ -126,7 +126,7 @@ export class Is {
126126
/**
127127
* Verify if is a valid Cnpj.
128128
*
129-
* @param {string, number} cnpj
129+
* @param {string|number} cnpj
130130
* @return {boolean}
131131
*/
132132
static Cnpj(cnpj) {

0 commit comments

Comments
 (0)