From daf0e8e4d589418b94e24dbebb3fea62c4c8a09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Wed, 7 Sep 2022 12:06:39 -0300 Subject: [PATCH] feat(types): add js docs in types --- README.md | 4 +- package.json | 2 +- src/Helpers/Clean.js | 8 +- src/Helpers/Config.js | 2 +- src/Helpers/Debug.js | 4 +- src/Helpers/Exception.js | 22 +- src/Helpers/Exec.js | 6 +- src/Helpers/File.js | 22 +- src/Helpers/Folder.js | 28 +- src/Helpers/Is.js | 8 +- src/Helpers/Json.js | 12 +- src/Helpers/Number.js | 3 +- src/Helpers/Parser.js | 6 +- src/Helpers/Path.js | 85 +-- src/Helpers/String.js | 8 +- src/Helpers/Uuid.js | 5 +- src/index.d.ts | 1241 +++++++++++++++++++++++++++++++++++++- tests/Unit/JsonTest.js | 6 +- 18 files changed, 1353 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index ed62eaf..aea3337 100644 --- a/README.md +++ b/README.md @@ -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 ``` --- diff --git a/package.json b/package.json index e089359..eb397c3 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/src/Helpers/Clean.js b/src/Helpers/Clean.js index e124a0a..c97e427 100644 --- a/src/Helpers/Clean.js +++ b/src/Helpers/Clean.js @@ -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) { @@ -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) { diff --git a/src/Helpers/Config.js b/src/Helpers/Config.js index a3f9a48..5c70245 100644 --- a/src/Helpers/Config.js +++ b/src/Helpers/Config.js @@ -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) { diff --git a/src/Helpers/Debug.js b/src/Helpers/Debug.js index 9c7666f..08a53a9 100644 --- a/src/Helpers/Debug.js +++ b/src/Helpers/Debug.js @@ -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') { diff --git a/src/Helpers/Exception.js b/src/Helpers/Exception.js index cfc195d..b0e4a46 100644 --- a/src/Helpers/Exception.js +++ b/src/Helpers/Exception.js @@ -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) { @@ -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, @@ -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} */ async prettify(options) { diff --git a/src/Helpers/Exec.js b/src/Helpers/Exec.js index 9bef37a..7a610aa 100644 --- a/src/Helpers/Exec.js +++ b/src/Helpers/Exec.js @@ -37,7 +37,7 @@ export class Exec { * @param {string} command * @param {{ * ignoreErrors?: boolean - * }?} options + * }} [options] * @throws {NodeCommandException} * @return {Promise<{ stdout: string, stderr: string }>} */ @@ -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} */ static async download(name, path, url) { diff --git a/src/Helpers/File.js b/src/Helpers/File.js index 902b588..84bd149 100644 --- a/src/Helpers/File.js +++ b/src/Helpers/File.js @@ -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( @@ -262,7 +262,7 @@ export class File { * @param {{ * withContent?: boolean, * isInternalLoad?: boolean - * }?} options + * }} [options] * @return {File} */ loadSync(options) { @@ -313,7 +313,7 @@ export class File { * @param {{ * withContent?: boolean, * isInternalLoad?: boolean - * }?} options + * }} [options] * @return {Promise} */ async load(options) { @@ -430,7 +430,7 @@ export class File { * @param {{ * withContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {File} */ copySync(path, options) { @@ -458,7 +458,7 @@ export class File { * @param {{ * withContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {Promise} */ async copy(path, options) { @@ -486,7 +486,7 @@ export class File { * @param {{ * withContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {File} */ moveSync(path, options) { @@ -518,7 +518,7 @@ export class File { * @param {{ * withContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {Promise} */ async move(path, options) { @@ -614,7 +614,7 @@ export class File { * * @param {{ * saveContent?: boolean - * }?} options + * }} [options] * @return {Buffer} */ getContentSync(options) { @@ -636,7 +636,7 @@ export class File { * * @param {{ * saveContent?: boolean - * }?} options + * }} [options] * @return {Promise} */ async getContent(options) { diff --git a/src/Helpers/Folder.js b/src/Helpers/Folder.js index edeba90..15ac72d 100644 --- a/src/Helpers/Folder.js +++ b/src/Helpers/Folder.js @@ -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) { @@ -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) { @@ -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) { @@ -294,7 +294,7 @@ export class Folder { * withSub?: boolean, * withFileContent?: boolean, * isInternalLoad?: boolean, - * }?} options + * }} [options] * @return {Folder} */ loadSync(options) { @@ -341,7 +341,7 @@ export class Folder { * withSub?: boolean, * withFileContent?: boolean, * isInternalLoad?: boolean, - * }?} options + * }} [options] * @return {Promise} */ async load(options) { @@ -433,7 +433,7 @@ export class Folder { * withSub?: boolean, * withFileContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {Folder} */ copySync(path, options) { @@ -481,7 +481,7 @@ export class Folder { * withSub?: boolean, * withFileContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {Promise} */ async copy(path, options) { @@ -533,7 +533,7 @@ export class Folder { * withSub?: boolean, * withFileContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {Folder} */ moveSync(path, options) { @@ -583,7 +583,7 @@ export class Folder { * withSub?: boolean, * withFileContent?: boolean, * mockedValues?: boolean - * }?} options + * }} [options] * @return {Promise} */ async move(path, options) { @@ -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) { @@ -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) { diff --git a/src/Helpers/Is.js b/src/Helpers/Is.js index ecac747..9a5f4d3 100644 --- a/src/Helpers/Is.js +++ b/src/Helpers/Is.js @@ -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) { @@ -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) { @@ -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) { @@ -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) { diff --git a/src/Helpers/Json.js b/src/Helpers/Json.js index 3b0ff05..4f9aed5 100644 --- a/src/Helpers/Json.js +++ b/src/Helpers/Json.js @@ -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 @@ -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[]} @@ -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)] @@ -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} */ diff --git a/src/Helpers/Number.js b/src/Helpers/Number.js index 0692ae4..52d7405 100644 --- a/src/Helpers/Number.js +++ b/src/Helpers/Number.js @@ -46,9 +46,8 @@ export class Number { Math.sin(dLon / 2) const center = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) - const distance = radius * center - return distance + return radius * center } /** diff --git a/src/Helpers/Parser.js b/src/Helpers/Parser.js index a109213..66d7972 100644 --- a/src/Helpers/Parser.js +++ b/src/Helpers/Parser.js @@ -37,7 +37,7 @@ export class Parser { * separator?: string, * pairSeparator?: string, * lastSeparator?: string - * }?} options + * }} [options] * @return {string} */ static arrayToString(values, options) { @@ -153,7 +153,7 @@ export class Parser { /** * Parses a byte format to number. * - * @param {string, number} byte + * @param {string|number} byte * @return {number} */ static byteToSize(byte) { @@ -184,7 +184,7 @@ export class Parser { /** * Parses the status code number to it reason in string. * - * @param {string, number} status + * @param {string|number} status * @return {string} */ static statusCodeToReason(status) { diff --git a/src/Helpers/Path.js b/src/Helpers/Path.js index ea22ffb..35926e1 100644 --- a/src/Helpers/Path.js +++ b/src/Helpers/Path.js @@ -16,6 +16,7 @@ export class Path { /** * Set a default beforePath for all Path methods that * use Path.pwd. + * * @type {string} */ static defaultBeforePath = '' @@ -23,7 +24,7 @@ export class Path { /** * Return the pwd path of your project. * - * @param {string?} subPath + * @param {string} [subPath] * @return {string} */ static pwd(subPath = sep) { @@ -39,7 +40,7 @@ export class Path { /** * Return the app path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static app(subPath = sep) { @@ -49,7 +50,7 @@ export class Path { /** * Return the bootstrap path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static bootstrap(subPath = sep) { @@ -59,7 +60,7 @@ export class Path { /** * Return the config path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static config(subPath = sep) { @@ -69,7 +70,7 @@ export class Path { /** * Return the database path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static database(subPath = sep) { @@ -79,7 +80,7 @@ export class Path { /** * Return the lang path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static lang(subPath = sep) { @@ -89,7 +90,7 @@ export class Path { /** * Return the node_modules path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static nodeModules(subPath = sep) { @@ -99,7 +100,7 @@ export class Path { /** * Return the providers' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static providers(subPath = sep) { @@ -109,7 +110,7 @@ export class Path { /** * Return the public path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static public(subPath = sep) { @@ -119,7 +120,7 @@ export class Path { /** * Return the resources' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static resources(subPath = sep) { @@ -129,7 +130,7 @@ export class Path { /** * Return the routes' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static routes(subPath = sep) { @@ -139,7 +140,7 @@ export class Path { /** * Return the storage path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static storage(subPath = sep) { @@ -149,7 +150,7 @@ export class Path { /** * Return the tests' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static tests(subPath = sep) { @@ -159,7 +160,7 @@ export class Path { /** * Return the logs' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static logs(subPath = sep) { @@ -169,7 +170,7 @@ export class Path { /** * Return the views' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static views(subPath = sep) { @@ -179,7 +180,7 @@ export class Path { /** * Return the assets' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static assets(subPath = sep) { @@ -189,7 +190,7 @@ export class Path { /** * Return the locales' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static locales(subPath = sep) { @@ -199,7 +200,7 @@ export class Path { /** * Return the facades' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static facades(subPath = sep) { @@ -209,7 +210,7 @@ export class Path { /** * Return the stubs' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static stubs(subPath = sep) { @@ -219,7 +220,7 @@ export class Path { /** * Return the http path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static http(subPath = sep) { @@ -229,7 +230,7 @@ export class Path { /** * Return the console path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static console(subPath = sep) { @@ -239,7 +240,7 @@ export class Path { /** * Return the services' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static services(subPath = sep) { @@ -249,7 +250,7 @@ export class Path { /** * Return the migrations' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static migrations(subPath = sep) { @@ -259,7 +260,7 @@ export class Path { /** * Return the seeders' path of your project. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static seeders(subPath = sep) { @@ -269,7 +270,7 @@ export class Path { /** * Return the .bin path of your node_modules. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static bin(subPath = sep) { @@ -279,7 +280,7 @@ export class Path { /** * Return the tmp path of your vm. * - * @param {string?} subPath + * @param {string} subPath * @return {string} */ static vmTmp(subPath = sep) { @@ -290,12 +291,26 @@ export class Path { return this.#removeSlashes(tmpDir) } + /** + * Return the home path of your vm. + * + * @param {string} subPath + * @return {string} + */ + static vmHome(subPath = sep) { + const osHomeDir = homedir() + + const homeDir = osHomeDir.concat(sep, normalize(subPath)) + + return this.#removeSlashes(homeDir) + } + /** * Return the execution path of where this method * is being called. * - * @param {string?} subPath - * @param {number?} stackIndex + * @param {string} subPath + * @param {number} [stackIndex] * @return {string} */ static this(subPath = sep, stackIndex = 1) { @@ -310,20 +325,6 @@ export class Path { return this.#removeSlashes(execDir) } - /** - * Return the home path of your vm. - * - * @param {string?} subPath - * @return {string} - */ - static vmHome(subPath = sep) { - const osHomeDir = homedir() - - const homeDir = osHomeDir.concat(sep, normalize(subPath)) - - return this.#removeSlashes(homeDir) - } - /** * Remove additional slashes from path. * diff --git a/src/Helpers/String.js b/src/Helpers/String.js index e46d645..e26150d 100644 --- a/src/Helpers/String.js +++ b/src/Helpers/String.js @@ -61,7 +61,7 @@ export class String { * Transforms the string to "snake_case". * * @param {string} value - * @param {boolean?} capitalize + * @param {boolean} [capitalize] * @return {string} */ static toSnakeCase(value, capitalize) { @@ -98,7 +98,7 @@ export class String { * Transforms the string to "Sentence case". * * @param {string} value - * @param {boolean?} capitalize + * @param {boolean} [capitalize] * @return {string} */ static toSentenceCase(value, capitalize) { @@ -113,7 +113,7 @@ export class String { * Transforms the string to "dot.case". * * @param {string} value - * @param {boolean?} capitalize + * @param {boolean} [capitalize] * @return {string} */ static toDotCase(value, capitalize) { @@ -140,7 +140,7 @@ export class String { * Transforms a string to "dash-case" * * @param {string} value - * @param {boolean} capitalize + * @param {boolean} [capitalize] * @return {string} */ static toDashCase(value, capitalize) { diff --git a/src/Helpers/Uuid.js b/src/Helpers/Uuid.js index 8185b68..e6147a8 100644 --- a/src/Helpers/Uuid.js +++ b/src/Helpers/Uuid.js @@ -16,7 +16,7 @@ export class Uuid { * Verify if string is a valid uuid. * * @param {string} token - * @param {boolean?} isPrefixed + * @param {boolean} [isPrefixed] * @return {boolean} */ static verify(token, isPrefixed = false) { @@ -30,7 +30,7 @@ export class Uuid { /** * Generate an uuid token * - * @param {string?} prefix + * @param {string} [prefix] * @return {string} */ static generate(prefix) { @@ -116,7 +116,6 @@ export class Uuid { * * @param {string} prefix * @param {string?} token - * @throws {InvalidUuidException} * @return {string} */ static changeOrGenerate(prefix, token) { diff --git a/src/index.d.ts b/src/index.d.ts index c394bf7..7dad621 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -92,12 +92,28 @@ export declare interface DBConnectionContract { } export declare class Clean { + /** + * Remove all falsy values from array. + * + * @param {any[]} array + * @param {boolean} [removeEmpty] + * @param {boolean} [cleanInsideObjects] + * @return {any[]} + */ static cleanArray( array: any[], removeEmpty?: boolean, cleanInsideObjects?: boolean, ): any[] + /** + * Remove all falsy values from object. + * + * @param {any} object + * @param {boolean} [removeEmpty] + * @param {boolean} [cleanInsideArrays] + * @return {any} + */ static cleanObject( object: any, removeEmpty?: boolean, @@ -106,26 +122,92 @@ export declare class Clean { } export declare class Config { + /** + * Map structure to save all configuration files. + * + * @type {Map} + */ static configs: Map + /** + * Get the value from configuration files. + * + * @param {string} key + * @param {any} [defaultValue] + * @return {any} + */ static get(key: string, defaultValue?: any): any + /** + * Load the configuration file only if it has + * not been loaded yet. + * + * @param {string} path + * @param {number} [callNumber] + * @return {Promise} + */ safeLoad(path: string, callNumber?: number): Promise + /** + * Load the configuration file. + * + * @param {string} path + * @param {number} [callNumber] + * @return {Promise} + */ load(path: string, callNumber?: number): Promise } export declare class Debug { + /** + * Format the message using Chalk API. + * + * @param {string} message + * @return {string} + */ static format(message: string): string + /** + * Format and throw the message in the stdout accordingly to the namespace. + * + * @param {string|any} message + * @param {string} [namespace] + * @return {void} + */ static log(message: string | any, namespace?: string): void } export declare class Exception extends Error { + /** + * Creates a new instance of Exception. + * + * @param {string} [content] + * @param {number} [status] + * @param {string} [code] + * @param {string} [help] + * @return {Exception} + */ constructor(content?: string, status?: number, code?: string, help?: string) + /** + * Transform the exception to a valid JSON Object. + * + * @param {boolean} [stack] + * @return {ExceptionJSON} + */ toJSON(stack?: boolean): ExceptionJSON + /** + * 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] + * @return {Promise} + */ prettify(options?: { prefix?: string hideMessage?: boolean @@ -136,15 +218,67 @@ export declare class Exception extends Error { } export declare class Exec { + /** + * Sleep the code in the line that this function + * is being called. + * + * @param {number} ms + * @return {Promise} + */ static sleep(ms: number): Promise + /** + * Execute a command of child process exec as promise. + * + * @param {string} command + * @param {{ + * ignoreErrors?: boolean + * }} [options] + * @throws {NodeCommandException} + * @return {Promise<{ stdout: string, stderr: string }>} + */ static command( command: string, options?: { ignoreErrors?: boolean }, ): Promise<{ stdout: string; stderr: string }> + /** + * Download an archive to determined path. + * + * @param {string} name + * @param {string} path + * @param {string} url + * @return {Promise} + */ static download(name: string, path: string, url: string): Promise + /** + * Paginate a collection of data. + * + * @param {any[]} data + * @param {number} total + * @param {{ + * page?: number, + * limit?: number, + * resourceUrl?: string + * }} pagination + * @return {{ + * data: any[], + * meta: { + * totalItems: number, + * itemsPerPage: number, + * totalPages: number, + * currentPage: number, + * itemCount: number + * }, + * links: { + * next: string, + * previous: string, + * last: string, + * first: string + * } + * }} + */ static pagination( data: any[], total: number, @@ -183,6 +317,15 @@ export declare class File { public extension: string + /** + * Creates a new instance of File. + * + * @param {string} filePath + * @param {Buffer} [content] + * @param {boolean} [mockedValues] + * @param {boolean} [isCopy] + * @return {File} + */ constructor( filePath: string, content?: Buffer, @@ -190,61 +333,211 @@ export declare class File { isCopy?: boolean, ) + /** + * Remove the file it's existing or not. + * + * @param {string} filePath + * @return {Promise} + */ static safeRemove(filePath: string): Promise + /** + * Verify if file exists. + * + * @param {string} filePath + * @return {boolean} + */ static existsSync(filePath: string): boolean + /** + * Verify if file exists. + * + * @param {string} filePath + * @return {Promise} + */ static exists(filePath: string): Promise + /** + * Verify if path is from file or directory. + * + * @param {string} path + * @return {boolean} + */ static isFileSync(path: string): boolean + /** + * Verify if path is from file or directory. + * + * @param {string} path + * @return {Promise} + */ static isFile(path: string): Promise + /** + * Create fake file with determined size. + * + * @param {string} filePath + * @param {number} size + * @return {Promise} + */ static createFileOfSize(filePath: string, size?: number): Promise + /** + * Returns the file as a JSON object. + * + * @return {FileJSON} + */ toJSON(): FileJSON + /** + * Load or create the file. + * + * @param {{ + * withContent?: boolean, + * isInternalLoad?: boolean + * }} [options] + * @return {File} + */ loadSync(options?: { withContent?: boolean; isInternalLoad?: boolean }): File + /** + * Load or create the file. + * + * @param {{ + * withContent?: boolean, + * isInternalLoad?: boolean + * }} [options] + * @return {Promise} + */ load(options?: { withContent?: boolean isInternalLoad?: boolean }): Promise + /** + * Remove the file. + * + * @return {void} + */ removeSync(): void + /** + * Remove the file. + * + * @return {Promise} + */ remove(): Promise + /** + * Create a copy of the file. + * + * @param {string} path + * @param {{ + * withContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {File} + */ copySync( path: string, options?: { withContent?: boolean; mockedValues?: boolean }, ): File + /** + * Create a copy of the file. + * + * @param {string} path + * @param {{ + * withContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {Promise} + */ copy( path: string, options?: { withContent?: boolean; mockedValues?: boolean }, ): Promise + /** + * Move the file to other path. + * + * @param {string} path + * @param {{ + * withContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {File} + */ moveSync( path: string, options?: { withContent?: boolean; mockedValues?: boolean }, ): File + /** + * Move the file to other path. + * + * @param {string} path + * @param {{ + * withContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {Promise} + */ move( path: string, options?: { withContent?: boolean; mockedValues?: boolean }, ): Promise + /** + * Append any data to the file. + * + * @param {string|Buffer} data + * @return {File} + */ appendSync(data: string | Buffer): File + /** + * Append any data to the file. + * + * @param {string|Buffer} data + * @return {Promise} + */ append(data: string | Buffer): Promise + /** + * Prepend any data to the file. + * + * @param {string|Buffer} data + * @return {File} + */ prependSync(data: string | Buffer): File + /** + * Prepend any data to the file. + * + * @param {string|Buffer} data + * @return {Promise} + */ prepend(data: string | Buffer): Promise + /** + * Get only the content of the file. + * + * @param {{ + * saveContent?: boolean + * }} [options] + * @return {Buffer} + */ getContentSync(options?: { saveContent?: boolean }): Buffer + /** + * Get only the content of the file. + * + * @param {{ + * saveContent?: boolean + * }} [options] + * @return {Promise} + */ getContent(options?: { saveContent?: boolean }): Promise } @@ -271,40 +564,136 @@ export declare class Folder { public folderExists: boolean + /** + * Creates a new instance of Folder. + * + * @param {string} folderPath + * @param {boolean} [mockedValues] + * @param {boolean} [isCopy] + * @return {Folder} + */ constructor(folderPath: string, mockedValues?: boolean, isCopy?: boolean) + /** + * Get the size of the folder. + * + * @param {string} folderPath + * @return {number} + */ static folderSizeSync(folderPath: string): number + /** + * Get the size of the folder. + * + * @param {string} folderPath + * @return {Promise} + */ static folderSize(folderPath: string): Promise + /** + * Remove the folder it's existing or not. + * + * @param {string} folderPath + * @return {Promise} + */ static safeRemove(folderPath: string): Promise + /** + * Verify if folder exists. + * + * @param {string} folderPath + * @return {boolean} + */ static existsSync(folderPath: string): boolean + /** + * Verify if folder exists. + * + * @param {string} folderPath + * @return {Promise} + */ static exists(folderPath: string): Promise + /** + * Verify if path is from folder or file. + * + * @param {string} path + * @return {boolean} + */ static isFolderSync(path: string): boolean + /** + * Verify if path is from folder or file. + * + * @param {string} path + * @return {Promise} + */ static isFolder(path: string): Promise + /** + * Returns the file as a JSON object. + * + * @return {FolderJSON} + */ toJSON(): FolderJSON + /** + * Load or create the folder. + * + * @param {{ + * withSub?: boolean, + * withFileContent?: boolean, + * isInternalLoad?: boolean, + * }} [options] + * @return {Folder} + */ loadSync(options?: { withSub?: boolean withFileContent?: boolean isInternalLoad?: boolean }): Folder + /** + * Load or create the folder. + * + * @param {{ + * withSub?: boolean, + * withFileContent?: boolean, + * isInternalLoad?: boolean, + * }} [options] + * @return {Promise} + */ load(options?: { withSub?: boolean withFileContent?: boolean isInternalLoad?: boolean }): Promise + /** + * Remove the folder. + * + * @return {void} + */ removeSync(): void + /** + * Remove the folder. + * + * @return {Promise} + */ remove(): Promise + /** + * Create a copy of the folder. + * + * @param {string} path + * @param {{ + * withSub?: boolean, + * withFileContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {Folder} + */ copySync( path: string, options?: { @@ -314,6 +703,17 @@ export declare class Folder { }, ): Folder + /** + * Create a copy of the folder. + * + * @param {string} path + * @param {{ + * withSub?: boolean, + * withFileContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {Promise} + */ copy( path: string, options?: { @@ -323,6 +723,17 @@ export declare class Folder { }, ): Promise + /** + * Move the folder to other path. + * + * @param {string} path + * @param {{ + * withSub?: boolean, + * withFileContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {Folder} + */ moveSync( path: string, options?: { @@ -332,6 +743,17 @@ export declare class Folder { }, ): Folder + /** + * Move the folder to other path. + * + * @param {string} path + * @param {{ + * withSub?: boolean, + * withFileContent?: boolean, + * mockedValues?: boolean + * }} [options] + * @return {Promise} + */ move( path: string, options?: { @@ -341,134 +763,512 @@ export declare class Folder { }, ): Promise + /** + * Get all the files of folder using glob pattern. + * + * @param {string} [pattern] + * @param {boolean} [recursive] + * @return {File[]} + */ getFilesByPattern(pattern?: string, recursive?: boolean): File[] + /** + * Get all the folders of folder using glob pattern. + * + * @param {string} [pattern] + * @param {boolean} [recursive] + * @return {Folder[]} + */ getFoldersByPattern(pattern?: string, recursive?: boolean): Folder[] } export declare class Is { + /** + * Verify if is valid Uuid. + * + * @param {string} value + * @return {boolean} + */ static Uuid(value: string): boolean + /** + * Verify if is valid Json. + * + * @param {string} value + * @return {boolean} + */ static Json(value: string): boolean + /** + * Verify if is valid Ip. + * + * @param {string} value + * @return {boolean} + */ static Ip(value: string): boolean + /** + * Verify if is valid Empty. + * + * @param {string|any|any[]} value + * @return {boolean} + */ static Empty(value: string | any | any[]): boolean + /** + * Verify if is a valid Cep. + * + * @param {string|number} cep + * @return {boolean} + */ static Cep(cep: string | number): boolean + /** + * Verify if is a valid Cpf. + * + * @param {string|number} cpf + * @return {boolean} + */ static Cpf(cpf: string | number): boolean + /** + * Verify if is a valid Cnpj. + * + * @param {string|number} cnpj + * @return {boolean} + */ static Cnpj(cnpj: string | number): boolean + /** + * Verify if is a valid Async function. + * + * @param {any} value + * @return {boolean} + */ static Async(value: any): value is Promise + /** + * Verify if is a valid Undefined. + * + * @param {any} value + * @return {boolean} + */ static Undefined(value: any): value is undefined + /** + * Verify if is a valid Null. + * + * @param {any} value + * @return {boolean} + */ static Null(value: any): value is null + /** + * Verify if is a valid Boolean. + * + * @param {any} value + * @return {boolean} + */ static Boolean(value: any): value is boolean + /** + * Verify if is a valid Buffer. + * + * @param {any} value + * @return {boolean} + */ static Buffer(value: any): value is Buffer + /** + * Verify if is a valid Number. + * + * @param {any} value + * @return {boolean} + */ static Number(value: any): value is number + /** + * Verify if is a valid String. + * + * @param {any} value + * @return {boolean} + */ static String(value: any): value is string + /** + * Verify if is a valid Object. + * + * @param {any} value + * @return {boolean} + */ static Object(value: any): value is Object + /** + * Verify if is a valid Date. + * + * @param {any} value + * @return {boolean} + */ static Date(value: any): value is Date + /** + * Verify if is a valid Array. + * + * @param {any} value + * @return {boolean} + */ static Array(value: any): value is any[] + /** + * Verify if is a valid Regexp. + * + * @param {any} value + * @return {boolean} + */ static Regexp(value: any): value is RegExp + /** + * Verify if is a valid Error. + * + * @param {any} value + * @return {boolean} + */ static Error(value: any): value is Error + /** + * Verify if is a valid Function. + * + * @param {any} value + * @return {boolean} + */ static Function(value: any): value is Function + /** + * Verify if is a valid Class. + * + * @param {any} value + * @return {boolean} + */ static Class(value: any): boolean + /** + * Verify if is a valid Integer. + * + * @param {any} value + * @return {boolean} + */ static Integer(value: any): value is number + /** + * Verify if is a valid Float. + * + * @param {any} value + * @return {boolean} + */ static Float(value: any): value is number + /** + * Verify if is a valid ArrayOfObjects. + * + * @param {any[]} value + * @return {boolean} + */ static ArrayOfObjects(value: any[]): boolean } export declare class Json { + /** + * Deep copy any object properties without reference. + * + * @param {any} object + * @return {any} + */ static copy(object: any): any + /** + * Find all JSON inside string and return it. + * + * @param {string} text + * @return {string[]} + */ static getJson(text: string): string[] + /** + * Reviver callback. + * + * @callback reviver + * @param {any} this + * @param {string} key + * @param {any} value + * @return any + */ + + /** + * Converts a JSON string into an object without exception. + * + * @param {string} text + * @param {reviver} [reviver] + * @return {any} + */ static parse(text: string, reviver?: any): any + /** + * Observe changes inside objects. + * + * @param {any} object + * @param {function} func + * @param {...any[]} args + * @return {any} + */ static observeChanges(object: any, func: any, ...args: any[]) + /** + * Remove all keys from data that is not inside array keys. + * + * @param {any} data + * @param {any[]} keys + * @return {any[]} + */ static fillable(data: any, keys: any[]): any[] + /** + * Remove all duplicated values from the array. + * + * @param {any[]} array + * @return {any[]} + */ static removeDuplicated(array: any[]): any[] - static sort(array: any[]): number - + /** + * Raffle any value from the array. + * + * @param {any[]} array + * @return {number} + */ + static raffle(array: any[]): number + + /** + * Get the object properties based on key. + * + * @param {string} key + * @param {any} [defaultValue] + * @param {any} object + * @return {any|undefined} + */ static get(object: any, key: string, defaultValue?: any): any | undefined } export class Module { + /** + * Get the module first export match or default. + * + * @param {any|Promise} module + * @return {Promise} + */ static get(module: any | Promise): Promise + /** + * Get the module first export match or default with alias. + * + * @param {any|Promise} module + * @param {string} subAlias + * @return {Promise<{ alias: string, module: any }>} + */ static getWithAlias(module: any | Promise, subAlias: string): Promise<{ alias: string, module: any }> + /** + * Get all modules first export match or default and return + * as array. + * + * @param {any[]|Promise} modules + * @return {Promise} + */ static getAll(modules: any[] | Promise): Promise + /** + * Get all modules first export match or default with alias and return + * as array. + * + * @param {any[]|Promise} modules + * @param {string} subAlias + * @return {Promise} + */ static getAllWithAlias(modules: any[] | Promise, subAlias: string): Promise<{ alias: string, module: any }[]> + /** + * Same as get method, but import the path directly. + * + * @param {string} path + * @return {Promise} + */ static getFrom(path: string): Promise + /** + * Same as getWithAlias method, but import the path directly. + * + * @param {string} path + * @param {string} subAlias + * @return {Promise<{ alias: string, module: any }>} + */ static getFromWithAlias(path: string, subAlias: string): Promise<{ alias: string, module: any }> + /** + * Same as getAll method but import everything in the path directly. + * + * @param {string} path + * @return {Promise} + */ static getAllFrom(path: string): Promise + /** + * Same as getAllWithAlias method but import everything in the path directly. + * + * @param {string} path + * @param {string} subAlias + * @return {Promise<{ alias: string, module: any }[]>} + */ static getAllFromWithAlias(path: string, subAlias: string): Promise<{ alias: string, module: any }[]> + /** + * Verify if folder exists and get all .js files inside. + * + * @param {string} path + * @return {Promise} + */ static getAllJSFilesFrom(path: string): Promise + /** + * Import a full path using the path href to ensure compatibility + * between OS's. + * + * @param {string} path + * @return {Promise} + */ static import(path: string): Promise + /** + * Create the __dirname property. Set in global if necessary. + * + * @param {string} [url] + * @param {boolean} [setInGlobal] + * @return {string} + */ static createDirname(url?: string, setInGlobal?: boolean): string + /** + * Create the __filename property. Set in global if necessary. + * + * @param {string} [url] + * @param {boolean} [setInGlobal] + * @return {string} + */ static createFilename(url?: string, setInGlobal?: boolean): string } - export declare class Number { + /** + * Get the higher number from an array of numbers. + * + * @param {number[]} numbers + * @return {number} + */ static getHigher(numbers: number[]): number + /** + * Get km radius between two coordinates. + * + * @param {{ latitude: number, longitude: number }} centerCord + * @param {{ latitude: number, longitude: number }} pointCord + * @return {number} + */ static getKmRadius( centerCord: CoordinateContract, pointCord: CoordinateContract, ): number + /** + * Get the lower number from an array of numbers. + * + * @param {number[]} numbers + * @return {number} + */ static getLower(numbers: number[]): number + /** + * Extract all numbers inside a string and + * return as a unique number. + * + * @param {string} string + * @return {number} + */ static extractNumber(string: string): number + /** + * Extract all numbers inside a string. + * + * @param {string} string + * @return {number[]} + */ static extractNumbers(string: string): number[] + /** + * The average of all numbers in function arguments. + * + * @param {number[]} args + * @return {number} + */ static argsAverage(...args: number[]): number + /** + * The average of all numbers in the array. + * + * @param {number[]} array + * @return {number} + */ static arrayAverage(array: number[]): number + /** + * Generate a random integer from a determined interval of numbers. + * + * @param {number} min + * @param {number} max + * @return {number} + */ static randomIntFromInterval(min: number, max: number): number } export declare class Options { + /** + * Creates an option object with default values. + * + * @param {any} object + * @param {any} defaultValues + * @return {any} + */ static create(object: Partial, defaultValues: Partial): T } export declare class Parser { + /** + * Parse a string to array. + * + * @param {string} string + * @param {string} separator + * @return {string[]} + */ static stringToArray(string: string, separator: string): string[] + /** + * Parse an array of strings to a string. + * + * @param {string[]} values + * @param {{ + * separator?: string, + * pairSeparator?: string, + * lastSeparator?: string + * }} [options] + * @return {string} + */ static arrayToString( values: string[], options?: { @@ -478,14 +1278,53 @@ export declare class Parser { }, ): string + /** + * Parse a string to number or Coordinate. + * + * @param {string} string + * @param {boolean} isCoordinate + * @throws {InvalidNumberException} + * @return {number} + */ static stringToNumber(string: string, isCoordinate: boolean): number + /** + * Parse an object to form data. + * + * @param {any} object + * @return {string} + */ static jsonToFormData(object: any): string + /** + * Parse form data to json. + * + * @param {string} formData + * @return {any} + */ static formDataToJson(formData: string): any + /** + * Parses all links inside the string to HTML link + * with . + * + * @param {string} string + * @return {string} + */ static linkToHref(string: string): any + /** + * Parses a number to Byte format. + * + * @param {number} value + * @param {object} [options] + * @param {number} [options.decimalPlaces=2] + * @param {number} [options.fixedDecimals=false] + * @param {string} [options.thousandsSeparator=] + * @param {string} [options.unit=] + * @param {string} [options.unitSeparator=] + * @return {string} + */ static sizeToByte( value, options?: { @@ -497,139 +1336,535 @@ export declare class Parser { }, ): string + /** + * Parses a byte format to number. + * + * @param {string|number} byte + * @return {number} + */ static byteToSize(byte: string | number): number + /** + * Parses a string to MS format. + * + * @param {string} value + * @return {number} + */ static timeToMs(value: string): number + /** + * Parses an MS number to time format. + * + * @param {number} value + * @param {boolean} long + * @return {string} + */ static msToTime(value: number, long: boolean): string + /** + * Parses the status code number to it reason in string. + * + * @param {string|number} status + * @return {string} + */ static statusCodeToReason(status: string | number): string + /** + * Parses the reason in string to it status code number + * + * @param {string} reason + * @return {number} + */ static reasonToStatusCode(reason: string): number + /** + * Parses the database connection url to connection object. + * + * @param {string} url + * @return {DBConnectionContract} + */ static dbUrlToConnectionObj(url: string): DBConnectionContract + /** + * Parses the database connection object to connection url. + * + * @param {DBConnectionContract} object + * @return {string} + */ static connectionObjToDbUrl(object?: DBConnectionContract): string } export declare class Path { + /** + * Set a default beforePath for all Path methods that + * use Path.pwd. + * + * @type {string} + */ static defaultBeforePath: string + /** + * Return the pwd path of your project. + * + * @param {string} [subPath] + * @return {string} + */ static pwd(subPath?: string): string + /** + * Return the app path of your project. + * + * @param {string} subPath + * @return {string} + */ static app(subPath?: string): string + /** + * Return the bootstrap path of your project. + * + * @param {string} subPath + * @return {string} + */ static bootstrap(subPath?: string): string + /** + * Return the config path of your project. + * + * @param {string} subPath + * @return {string} + */ static config(subPath?: string): string + /** + * Return the database path of your project. + * + * @param {string} subPath + * @return {string} + */ static database(subPath?: string): string + /** + * Return the lang path of your project. + * + * @param {string} subPath + * @return {string} + */ static lang(subPath?: string): string + /** + * Return the node_modules path of your project. + * + * @param {string} subPath + * @return {string} + */ static nodeModules(subPath?: string): string + /** + * Return the providers' path of your project. + * + * @param {string} subPath + * @return {string} + */ static providers(subPath?: string): string + /** + * Return the public path of your project. + * + * @param {string} subPath + * @return {string} + */ static public(subPath?: string): string + /** + * Return the resources' path of your project. + * + * @param {string} subPath + * @return {string} + */ static resources(subPath?: string): string + /** + * Return the routes' path of your project. + * + * @param {string} subPath + * @return {string} + */ static routes(subPath?: string): string + /** + * Return the storage path of your project. + * + * @param {string} subPath + * @return {string} + */ static storage(subPath?: string): string + /** + * Return the tests' path of your project. + * + * @param {string} subPath + * @return {string} + */ static tests(subPath?: string): string + /** + * Return the logs' path of your project. + * + * @param {string} subPath + * @return {string} + */ static logs(subPath?: string): string + /** + * Return the views' path of your project. + * + * @param {string} subPath + * @return {string} + */ static views(subPath?: string): string + /** + * Return the assets' path of your project. + * + * @param {string} subPath + * @return {string} + */ static assets(subPath?: string): string + /** + * Return the locales' path of your project. + * + * @param {string} subPath + * @return {string} + */ static locales(subPath?: string): string + /** + * Return the facades' path of your project. + * + * @param {string} subPath + * @return {string} + */ static facades(subPath?: string): string + /** + * Return the stubs' path of your project. + * + * @param {string} subPath + * @return {string} + */ static stubs(subPath?: string): string + /** + * Return the http path of your project. + * + * @param {string} subPath + * @return {string} + */ static http(subPath?: string): string + /** + * Return the console path of your project. + * + * @param {string} subPath + * @return {string} + */ static console(subPath?: string): string + /** + * Return the services' path of your project. + * + * @param {string} subPath + * @return {string} + */ static services(subPath?: string): string + /** + * Return the migrations' path of your project. + * + * @param {string} subPath + * @return {string} + */ static migrations(subPath?: string): string + /** + * Return the seeders' path of your project. + * + * @param {string} subPath + * @return {string} + */ static seeders(subPath?: string): string + /** + * Return the .bin path of your node_modules. + * + * @param {string} subPath + * @return {string} + */ static bin(subPath?: string): string + /** + * Return the tmp path of your vm. + * + * @param {string} subPath + * @return {string} + */ static vmTmp(subPath?: string): string + /** + * Return the home path of your vm. + * + * @param {string} subPath + * @return {string} + */ static vmHome(subPath?: string): string + /** + * Return the execution path of where this method + * is being called. + * + * @param {string} subPath + * @param {number} [stackIndex] + * @return {string} + */ static this(subPath?: string, stackIndex?: number): string } export declare class Route { + /** + * Get the query string in form data format. + * + * @param {string} route + * @return {string} + */ static getQueryString(route: string): string + /** + * Remove query params from the route. + * + * @param {string} route + * @return {string} + */ static removeQueryParams(route: string): string + /** + * Get object with ?&queryParams values from route. + * + * @param {string} route + * @return {any} + */ static getQueryParamsValue(route: string): any + /** + * Get array with ?&queryParams name from route. + * + * @param {string} route + * @return {string[]} + */ static getQueryParamsName(route: string): string[] + /** + * Get object with :params values from route. + * + * @param {string} routeWithParams + * @param {string} routeWithValues + * @return {any} + */ static getParamsValue(routeWithParams: string, routeWithValues: string): any + /** + * Get array with :params name from route. + * + * @param {string} route + * @return {string[]} + */ static getParamsName(route: string): string[] + /** + * Create a matcher RegExp for any route. + * + * @param {string} route + * @return {RegExp} + */ static createMatcher(route: string): RegExp } export declare class String { + /** + * Generate random string by size. + * + * @param {number} size + * @return {string} + */ static generateRandom(size: number): string + /** + * Generate random color in hexadecimal format. + * + * @return {string} + */ static generateRandomColor(): string + /** + * Normalizes the string in base64 format removing + * special chars. + * + * @param {string} value + * @return {string} + */ static normalizeBase64(value: string): string + /** + * Transforms the string to "camelCase". + * + * @param {string} value + * @return {string} + */ static toCamelCase(value: string): string + /** + * Transforms the string to "snake_case". + * + * @param {string} value + * @param {boolean} [capitalize] + * @return {string} + */ static toSnakeCase(value: string, capitalize?: boolean): string + /** + * Transforms the string to "CONSTANT_CASE". + * + * @param {string} value + * @return {string} + */ static toConstantCase(value: string): string + /** + * Transforms the string to "PascalCase". + * + * @param {string} value + * @return {string} + */ static toPascalCase(value: string): string + /** + * Transforms the string to "Sentence case". + * + * @param {string} value + * @param {boolean} [capitalize] + * @return {string} + */ static toSentenceCase(value: string, capitalize?: boolean): string + /** + * Transforms the string to "dot.case". + * + * @param {string} value + * @param {boolean} [capitalize] + * @return {string} + */ static toDotCase(value: string, capitalize?: boolean): string + /** + * Removes all sorted cases from string. + * + * @param {string} value + * @return {string} + */ static toNoCase(value: string): string + /** + * Transforms a string to "dash-case" + * + * @param {string} value + * @param {boolean} [capitalize] + * @return {string} + */ static toDashCase(value: string, capitalize?: boolean): string + /** + * Transforms a word to plural. + * + * @param {string} word + * @return {string} + */ static pluralize(word: string): string + /** + * Transforms a word to singular. + * + * @param {string} word + * @return {string} + */ static singularize(word: string): string + /** + * Transforms a number to your ordinal format. + * + * @param {string,number} value + * @return {string} + */ static ordinalize(value: string | number): string } export declare class Uuid { + /** + * Verify if string is a valid uuid. + * + * @param {string} token + * @param {boolean} [isPrefixed] + * @return {boolean} + */ static verify(token: string, isPrefixed?: boolean): boolean + /** + * Generate an uuid token + * + * @param {string} [prefix] + * @return {string} + */ static generate(prefix?: string): string + /** + * Return the token without his prefix. + * + * @param {string} token + * @return {string} + */ static getToken(token: string): string + /** + * Return the prefix without his token. + * + * @param {string} token + * @return {string|null} + */ static getPrefix(token: string): string | null + /** + * Inject a prefix in the uuid token. + * + * @param {string} prefix + * @param {string} token + * @return {string} + */ static injectPrefix(prefix: string, token: string): string + /** + * Change the prefix of and uuid token + * + * @param {string} newPrefix + * @param {string} token + * @return {string} + */ static changePrefix(newPrefix: string, token: string): string + /** + * Change the token prefix or generate a new one + * + * @param {string} prefix + * @param {string?} token + * @return {string} + */ static changeOrGenerate(prefix: string, token?: string): string } diff --git a/tests/Unit/JsonTest.js b/tests/Unit/JsonTest.js index c4cdaec..ea582fa 100644 --- a/tests/Unit/JsonTest.js +++ b/tests/Unit/JsonTest.js @@ -86,12 +86,12 @@ test.group('Json Class', () => { assert.deepEqual(Json.removeDuplicated(array), [1, 2, 3, 4, 5]) }) - test('should be able to sort any value from the array', async ({ assert }) => { + test('should be able to raffle any value from the array', async ({ assert }) => { const array = [1, 2, 3, 4, 5] - const sortedValue = Json.sort(array) + const raffledValue = Json.raffle(array) - assert.isDefined(array.find(a => a === sortedValue)) + assert.isDefined(array.find(a => a === raffledValue)) }) test('should be able to get nested properties from object', async ({ assert }) => {