helper-fns
Advanced tools
Comparing version 2.5.18 to 2.5.19
@@ -137,11 +137,64 @@ declare const assert: (condition: boolean, message: string) => asserts condition; | ||
declare const debounce: (func: Function, wait: number, immediate?: boolean) => (this: any) => void; | ||
/** | ||
* It takes a callback function as an argument and returns the time taken to execute that function | ||
* @param {Function} callback - Function - The function to be executed. | ||
* @returns [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
*/ | ||
declare const timeTaken: (callback: Function) => number; | ||
/** | ||
* It replaces all instances of &, <, >, ', and " with their respective HTML | ||
* entities | ||
* @param {string} str - The string to unescape. | ||
* @returns the string with the tags replaced with the corresponding characters. | ||
*/ | ||
declare const unescapeHTML: (str: string) => string; | ||
/** | ||
* If the function is called again before the timeout is up, reset the timeout and use the latest | ||
* arguments. | ||
* @param {Function} func - The function to be executed | ||
* @param {number} wait - The number of milliseconds to throttle invocations to. | ||
* @returns A function that will call the function passed in after a certain amount of time has passed. | ||
*/ | ||
declare const throttle: (func: Function, wait: number) => () => void; | ||
declare const formatDuration: (ms: number) => string; | ||
/** | ||
* "Replace every word in a string with a capitalized version of that word." | ||
* | ||
* The first thing we do is use the replace() method to replace every word in the string with a | ||
* capitalized version of that word | ||
* @param {string} str - string - The string to be capitalized. | ||
* @returns A function that takes a string as an argument and returns a string with every word | ||
* capitalized. | ||
*/ | ||
declare const capitalizeEveryWord: (str: string) => string; | ||
/** | ||
* If the string exists, return the first character of the string in lowercase, followed by the rest of | ||
* the string. Otherwise, return an empty string. | ||
* @param {string} str - string - the string to be converted | ||
* @returns The first character of the string is being converted to lowercase and then concatenated | ||
* with the rest of the string. | ||
*/ | ||
declare const lowerFirst: (str: string) => string; | ||
/** | ||
* It returns an array of unique values from two arrays. | ||
* @param a - Array<unknown> | ||
* @param b - Array<unknown> | ||
* @param [duplicates=true] - boolean | ||
* @returns [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
*/ | ||
declare const union: (a: Array<unknown>, b: Array<unknown>, duplicates?: boolean) => Array<unknown>; | ||
declare const isDate: (dateString: string) => boolean; | ||
/** | ||
* It returns a new array with the last n elements removed | ||
* @param {any[]} arr - The array to query. | ||
* @param [n=1] - The number of elements to drop from the end of the array. | ||
* @returns [1, 2, 3, 4, 5] | ||
*/ | ||
declare const dropRight: (arr: any[], n?: number) => any[]; | ||
/** | ||
* It takes a string and an object with a key and iv property, and returns an encrypted string | ||
* @param {string} text - The text to be encrypted | ||
* @param config - { | ||
* @returns The encrypted text | ||
*/ | ||
declare const encrypt: (text: string, config: { | ||
@@ -151,3 +204,14 @@ key: string; | ||
}) => string; | ||
/** | ||
* It takes an enum and returns an array of strings | ||
* @param _enum - The enum you want to convert to a string array. | ||
* @returns An array of strings | ||
*/ | ||
declare const enumToString: (_enum: Record<any, any>) => string[]; | ||
/** | ||
* It decrypts a string using AES-256-CBC. | ||
* @param {string} encrypted - The encrypted string you want to decrypt. | ||
* @param config - { | ||
* @returns The decrypted string. | ||
*/ | ||
declare const decrypt: (encrypted: string, config: { | ||
@@ -157,9 +221,58 @@ key: string; | ||
}) => string; | ||
/** | ||
* It reads a file and returns a promise that resolves to the file's contents | ||
* @param {string} path - The path to the file you want to read. | ||
* @returns A promise that resolves to the contents of the file at the given path. | ||
*/ | ||
declare const readFile: (path: string) => Promise<unknown>; | ||
/** | ||
* "Return a random number between a and b, inclusive." | ||
* | ||
* The function takes two optional parameters, a and b, and returns a random number between them. If a | ||
* and b are omitted, the function returns a random number between 1 and 9 | ||
* @param [a=1] - The lower bound of the random number. | ||
* @param [b=9] - The upper bound of the random number to be generated. | ||
* @returns A random number between a and b. | ||
*/ | ||
declare const randomNumber: (a?: number, b?: number) => number; | ||
/** | ||
* It creates an array of size 'size' and then maps each element to a random hexadecimal number and | ||
* then joins them all together | ||
* @param {number} size - The number of characters you want in your hex string. | ||
*/ | ||
declare const randomHex: (size: number) => string; | ||
/** | ||
* It takes a string and replaces all instances of a given identifier with a random number | ||
* @param {string} str - The string to be replaced. | ||
* @param [identifier=X] - The string that will be replaced with a random number. | ||
* @returns A function that takes a string and an identifier and returns a string with the identifier | ||
* replaced with a random number. | ||
*/ | ||
declare const orderedToken: (str: string, identifier?: string) => string; | ||
/** | ||
* Return the string after the first occurrence of the given substring. | ||
* @param {string} str - The string to search in | ||
* @param {string} substr - The substring to search for. | ||
* @returns The string after the first occurrence of the given substring. | ||
*/ | ||
declare const strAfter: (str: string, substr: string) => string; | ||
/** | ||
* Return the part of the string before the first occurrence of the given substring. | ||
* @param {string} str - The string to search in | ||
* @param {string} substr - The substring to search for. | ||
* @returns The string before the first instance of the substring. | ||
*/ | ||
declare const strBefore: (str: string, substr: string) => string; | ||
/** | ||
* If the value is not null, undefined, or an empty string, return true, otherwise return false. | ||
* @param {any} value - any - The value to check. | ||
* @returns A function that takes a value and returns a boolean | ||
*/ | ||
declare const isNotEmpty: (value: any) => boolean; | ||
/** | ||
* It creates a new instance of the same type as the given instance, copies all the properties of the | ||
* given instance to the new instance, and returns the new instance | ||
* @param {T} instance - The instance to clone. | ||
* @returns A new instance of the same class as the instance passed in. | ||
*/ | ||
declare const clone: <T extends { | ||
@@ -166,0 +279,0 @@ constructor: Function; |
{ | ||
"name": "helper-fns", | ||
"type": "module", | ||
"version": "2.5.18", | ||
"version": "2.5.19", | ||
"packageManager": "pnpm@7.2.1", | ||
@@ -15,4 +15,2 @@ "description": "Some common utilities functions for everyday backend usage with zero dependencies", | ||
"bugs": "https://github.com/rubiin/helper-fns/issues", | ||
"keywords": [], | ||
"sideEffects": false, | ||
"exports": { | ||
@@ -25,5 +23,2 @@ ".": { | ||
}, | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"typesVersions": { | ||
@@ -37,29 +32,9 @@ "*": { | ||
}, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "unbuild", | ||
"dev": "unbuild --stub", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"prepublishOnly": "nr build", | ||
"release": "bumpp && npm publish", | ||
"start": "esno src/index.ts", | ||
"test": "vitest", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^0.34.0", | ||
"@antfu/ni": "^0.18.8", | ||
"@types/node": "^18.11.18", | ||
"bumpp": "^8.2.1", | ||
"eslint": "^8.31.0", | ||
"esno": "^0.16.3", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.9.4", | ||
"unbuild": "^1.0.2", | ||
"vite": "^4.0.4", | ||
"vitest": "^0.26.3" | ||
} | ||
"dist", | ||
"*.d.ts" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
37196
435
1
1