Skip to content

Commit

Permalink
feat(types): add js docs in types
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Sep 7, 2022
1 parent daa84d0 commit daf0e8e
Show file tree
Hide file tree
Showing 18 changed files with 1,353 additions and 119 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ console.log(Json.removeDuplicated(array)) // [1, 2, 4]

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

console.log(sortedValue) // a, b or c
console.log(raffledValue) // a, b or c
```

---
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@secjs/utils",
"version": "1.9.7",
"version": "1.9.8",
"description": "Utils functions and classes for Node.js",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down
8 changes: 4 additions & 4 deletions src/Helpers/Clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class Clean {
* Remove all falsy values from array.
*
* @param {any[]} array
* @param {boolean?} removeEmpty
* @param {boolean?} cleanInsideObjects
* @param {boolean} [removeEmpty]
* @param {boolean} [cleanInsideObjects]
* @return {any[]}
*/
static cleanArray(array, removeEmpty = false, cleanInsideObjects = false) {
Expand Down Expand Up @@ -47,8 +47,8 @@ export class Clean {
* Remove all falsy values from object.
*
* @param {any} object
* @param {boolean?} removeEmpty
* @param {boolean?} cleanInsideArrays
* @param {boolean} [removeEmpty]
* @param {boolean} [cleanInsideArrays]
* @return {any}
*/
static cleanObject(object, removeEmpty = false, cleanInsideArrays = false) {
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Config {
* Get the value from configuration files.
*
* @param {string} key
* @param {any?} defaultValue
* @param {any} [defaultValue]
* @return {any}
*/
static get(key, defaultValue = undefined) {
Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/Debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class Debug {
/**
* Format and throw the message in the stdout accordingly to the namespace.
*
* @param {string|Object} message
* @param {string} namespace
* @param {string|any} message
* @param {string} [namespace]
* @return {void}
*/
static log(message, namespace = 'api:main') {
Expand Down
22 changes: 11 additions & 11 deletions src/Helpers/Exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class Exception extends Error {
/**
* Creates a new instance of Exception.
*
* @param {string?} content
* @param {number?} status
* @param {string?} code
* @param {string?} help
* @param {string} [content]
* @param {number} [status]
* @param {string} [code]
* @param {string} [help]
* @return {Exception}
*/
constructor(content, status = 500, code, help) {
Expand Down Expand Up @@ -70,7 +70,7 @@ export class Exception extends Error {
/**
* Transform the exception to a valid JSON Object.
*
* @param stack
* @param [stack] {boolean}
* @return {{
* code: string,
* name: string,
Expand All @@ -97,12 +97,12 @@ export class Exception extends Error {
/**
* Prettify the error using Youch API.
*
* @param {any?} options
* @param {string?} options.prefix
* @param {boolean?} options.hideMessage
* @param {boolean?} options.hideErrorTitle
* @param {boolean?} options.displayShortPath
* @param {boolean?} options.displayMainFrameOnly
* @param {any} [options]
* @param {string} [options.prefix]
* @param {boolean} [options.hideMessage]
* @param {boolean} [options.hideErrorTitle]
* @param {boolean} [options.displayShortPath]
* @param {boolean} [options.displayMainFrameOnly]
* @return {Promise<string>}
*/
async prettify(options) {
Expand Down
6 changes: 3 additions & 3 deletions src/Helpers/Exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Exec {
* @param {string} command
* @param {{
* ignoreErrors?: boolean
* }?} options
* }} [options]
* @throws {NodeCommandException}
* @return {Promise<{ stdout: string, stderr: string }>}
*/
Expand All @@ -62,9 +62,9 @@ export class Exec {
/**
* Download an archive to determined path.
*
* @param {string} url
* @param {string} name
* @param {string?} path
* @param {string} path
* @param {string} url
* @return {Promise<File>}
*/
static async download(name, path, url) {
Expand Down
22 changes: 11 additions & 11 deletions src/Helpers/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class File {
* Creates a new instance of File.
*
* @param {string} filePath
* @param {Buffer?} content
* @param {boolean?} mockedValues
* @param {boolean?} isCopy
* @param {Buffer} [content]
* @param {boolean} [mockedValues]
* @param {boolean} [isCopy]
* @return {File}
*/
constructor(
Expand Down Expand Up @@ -262,7 +262,7 @@ export class File {
* @param {{
* withContent?: boolean,
* isInternalLoad?: boolean
* }?} options
* }} [options]
* @return {File}
*/
loadSync(options) {
Expand Down Expand Up @@ -313,7 +313,7 @@ export class File {
* @param {{
* withContent?: boolean,
* isInternalLoad?: boolean
* }?} options
* }} [options]
* @return {Promise<File>}
*/
async load(options) {
Expand Down Expand Up @@ -430,7 +430,7 @@ export class File {
* @param {{
* withContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {File}
*/
copySync(path, options) {
Expand Down Expand Up @@ -458,7 +458,7 @@ export class File {
* @param {{
* withContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {Promise<File>}
*/
async copy(path, options) {
Expand Down Expand Up @@ -486,7 +486,7 @@ export class File {
* @param {{
* withContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {File}
*/
moveSync(path, options) {
Expand Down Expand Up @@ -518,7 +518,7 @@ export class File {
* @param {{
* withContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {Promise<File>}
*/
async move(path, options) {
Expand Down Expand Up @@ -614,7 +614,7 @@ export class File {
*
* @param {{
* saveContent?: boolean
* }?} options
* }} [options]
* @return {Buffer}
*/
getContentSync(options) {
Expand All @@ -636,7 +636,7 @@ export class File {
*
* @param {{
* saveContent?: boolean
* }?} options
* }} [options]
* @return {Promise<Buffer>}
*/
async getContent(options) {
Expand Down
28 changes: 14 additions & 14 deletions src/Helpers/Folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class Folder {
* Creates a new instance of Folder.
*
* @param {string} folderPath
* @param {boolean} mockedValues
* @param {boolean} isCopy
* @param {boolean} [mockedValues]
* @param {boolean} [isCopy]
* @return {Folder}
*/
constructor(folderPath, mockedValues = false, isCopy = false) {
Expand Down Expand Up @@ -168,7 +168,7 @@ export class Folder {
* Get sub files of folder.
*
* @param {Folder[]} folders
* @param {string?} pattern
* @param {string} [pattern]
* @return {File[]}
*/
static #getSubFiles(folders, pattern) {
Expand Down Expand Up @@ -200,7 +200,7 @@ export class Folder {
*
* @param {Folder} folder
* @param {boolean} recursive
* @param {string?} pattern
* @param {string} [pattern]
* @return {Folder[]}
*/
static #getSubFolders(folder, recursive, pattern) {
Expand Down Expand Up @@ -294,7 +294,7 @@ export class Folder {
* withSub?: boolean,
* withFileContent?: boolean,
* isInternalLoad?: boolean,
* }?} options
* }} [options]
* @return {Folder}
*/
loadSync(options) {
Expand Down Expand Up @@ -341,7 +341,7 @@ export class Folder {
* withSub?: boolean,
* withFileContent?: boolean,
* isInternalLoad?: boolean,
* }?} options
* }} [options]
* @return {Promise<Folder>}
*/
async load(options) {
Expand Down Expand Up @@ -433,7 +433,7 @@ export class Folder {
* withSub?: boolean,
* withFileContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {Folder}
*/
copySync(path, options) {
Expand Down Expand Up @@ -481,7 +481,7 @@ export class Folder {
* withSub?: boolean,
* withFileContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {Promise<Folder>}
*/
async copy(path, options) {
Expand Down Expand Up @@ -533,7 +533,7 @@ export class Folder {
* withSub?: boolean,
* withFileContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {Folder}
*/
moveSync(path, options) {
Expand Down Expand Up @@ -583,7 +583,7 @@ export class Folder {
* withSub?: boolean,
* withFileContent?: boolean,
* mockedValues?: boolean
* }?} options
* }} [options]
* @return {Promise<Folder>}
*/
async move(path, options) {
Expand Down Expand Up @@ -632,8 +632,8 @@ export class Folder {
/**
* Get all the files of folder using glob pattern.
*
* @param {string?} pattern
* @param {boolean?} recursive
* @param {string} [pattern]
* @param {boolean} [recursive]
* @return {File[]}
*/
getFilesByPattern(pattern, recursive = false) {
Expand Down Expand Up @@ -665,8 +665,8 @@ export class Folder {
/**
* Get all the folders of folder using glob pattern.
*
* @param {string?} pattern
* @param {boolean?} recursive
* @param {string} [pattern]
* @param {boolean} [recursive]
* @return {Folder[]}
*/
getFoldersByPattern(pattern, recursive = false) {
Expand Down
8 changes: 4 additions & 4 deletions src/Helpers/Is.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Is {
/**
* Verify if is valid Empty.
*
* @param {string, Object, Array} value
* @param {string|any|any[]} value
* @return {boolean}
*/
static Empty(value) {
Expand All @@ -102,7 +102,7 @@ export class Is {
/**
* Verify if is a valid Cep.
*
* @param {string, number} cep
* @param {string|number} cep
* @return {boolean}
*/
static Cep(cep) {
Expand All @@ -114,7 +114,7 @@ export class Is {
/**
* Verify if is a valid Cpf.
*
* @param {string, number} cpf
* @param {string|number} cpf
* @return {boolean}
*/
static Cpf(cpf) {
Expand All @@ -126,7 +126,7 @@ export class Is {
/**
* Verify if is a valid Cnpj.
*
* @param {string, number} cnpj
* @param {string|number} cnpj
* @return {boolean}
*/
static Cnpj(cnpj) {
Expand Down
12 changes: 6 additions & 6 deletions src/Helpers/Json.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class Json {
}

/**
* Remove all keys from data that is not inside array keys
* Remove all keys from data that is not inside array keys.
*
* @param {any} data
* @param {any[]} keys
Expand All @@ -102,7 +102,7 @@ export class Json {
}

/**
* Remove all duplicated values from the array
* Remove all duplicated values from the array.
*
* @param {any[]} array
* @return {any[]}
Expand All @@ -112,12 +112,12 @@ export class Json {
}

/**
* Sort an index value from the array
* Raffle any value from the array.
*
* @param {any[]} array
* @return {number}
* @return {any}
*/
static sort(array) {
static raffle(array) {
const index = Math.random() * array.length

return array[Math.floor(index)]
Expand All @@ -127,7 +127,7 @@ export class Json {
* Get the object properties based on key.
*
* @param {string} key
* @param {any?} defaultValue
* @param {any} [defaultValue]
* @param {any} object
* @return {any|undefined}
*/
Expand Down
Loading

0 comments on commit daf0e8e

Please sign in to comment.