File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ Below are the module categories available in the utility library:
7474| [ Ai] ( https://utils.ryanuo.cc/api/ai/ ) | [ linearRegression()] ( https://utils.ryanuo.cc/api/ai/functions/linearRegression.html ) ;[ normalizeData()] ( https://utils.ryanuo.cc/api/ai/functions/normalizeData.html ) ;[ normalizeMinMax()] ( https://utils.ryanuo.cc/api/ai/functions/normalizeMinMax.html ) |
7575| [ Algorithm] ( https://utils.ryanuo.cc/api/algorithm/ ) | [ binarySearch()] ( https://utils.ryanuo.cc/api/algorithm/functions/binarySearch.html ) ;[ bubbleSort()] ( https://utils.ryanuo.cc/api/algorithm/functions/bubbleSort.html ) ;[ fibonacciDP()] ( https://utils.ryanuo.cc/api/algorithm/functions/fibonacciDP.html ) ;[ fibonacciRecursive()] ( https://utils.ryanuo.cc/api/algorithm/functions/fibonacciRecursive.html ) ;[ isPrime()] ( https://utils.ryanuo.cc/api/algorithm/functions/isPrime.html ) ;[ quickSort()] ( https://utils.ryanuo.cc/api/algorithm/functions/quickSort.html ) |
7676| [ Browser] ( https://utils.ryanuo.cc/api/browser/ ) | [ copyToClipboard()] ( https://utils.ryanuo.cc/api/browser/functions/copyToClipboard.html ) ;[ enterFullScreen()] ( https://utils.ryanuo.cc/api/browser/functions/enterFullScreen.html ) ;[ isMobile()] ( https://utils.ryanuo.cc/api/browser/functions/isMobile.html ) ;[ manageClasses()] ( https://utils.ryanuo.cc/api/browser/functions/manageClasses.html ) ;[ onceEventListener()] ( https://utils.ryanuo.cc/api/browser/functions/onceEventListener.html ) ;[ downloadFile()] ( https://utils.ryanuo.cc/api/browser/functions/downloadFile.html ) ;[ safeStorage()] ( https://utils.ryanuo.cc/api/browser/variables/safeStorage.html ) ;[ getUrlParams()] ( https://utils.ryanuo.cc/api/browser/functions/getUrlParams.html ) ;[ getUrlParamsString()] ( https://utils.ryanuo.cc/api/browser/functions/getUrlParamsString.html ) |
77- | [Common](https://utils.ryanuo.cc/api/common/) | [dateFormat()](https://utils.ryanuo.cc/api/common/functions/dateFormat.html);[dayjs()](https://utils.ryanuo.cc/api/common/variables/dayjs.html);[curry()](https://utils.ryanuo.cc/api/common/functions/curry.html);[debounce()](https://utils.ryanuo.cc/api/common/functions/debounce.html);[getUuid()](https://utils.ryanuo.cc/api/common/functions/getUuid.html);[safeJSONParse()](https://utils.ryanuo.cc/api/common/functions/safeJSONParse.html);[throttle()](https://utils.ryanuo.cc/api/common/functions/throttle.html);[isBoolean()](https://utils.ryanuo.cc/api/common/functions/isBoolean.html);[isBrowser()](https://utils.ryanuo.cc/api/common/functions/isBrowser.html);[isDate()](https://utils.ryanuo.cc/api/common/functions/isDate.html);[isEmptyObject()](https://utils.ryanuo.cc/api/common/functions/isEmptyObject.html);[isFunction()](https://utils.ryanuo.cc/api/common/functions/isFunction.html);[isNull()](https://utils.ryanuo.cc/api/common/functions/isNull.html);[isNumber()](https://utils.ryanuo.cc/api/common/functions/isNumber.html);[isObject()](https://utils.ryanuo.cc/api/common/functions/isObject.html);[isRegExp()](https://utils.ryanuo.cc/api/common/functions/isRegExp.html);[isString()](https://utils.ryanuo.cc/api/common/functions/isString.html);[isUndefined()](https://utils.ryanuo.cc/api/common/functions/isUndefined.html);[deepClone()](https://utils.ryanuo.cc/api/common/functions/deepClone.html);[getTypeName()](https://utils.ryanuo.cc/api/common/functions/getTypeName.html);[numberToFixed()](https://utils.ryanuo.cc/api/common/functions/numberToFixed.html);[toString()](https://utils.ryanuo.cc/api/common/functions/toString.html) |
77+ | [Common](https://utils.ryanuo.cc/api/common/) | [dateFormat()](https://utils.ryanuo.cc/api/common/functions/dateFormat.html);[dayjs()](https://utils.ryanuo.cc/api/common/variables/dayjs.html);[curry()](https://utils.ryanuo.cc/api/common/functions/curry.html);[debounce()](https://utils.ryanuo.cc/api/common/functions/debounce.html);[getUuid()](https://utils.ryanuo.cc/api/common/functions/getUuid.html);[safeJSONParse()](https://utils.ryanuo.cc/api/common/functions/safeJSONParse.html);[throttle()](https://utils.ryanuo.cc/api/common/functions/throttle.html);[compress()](https://utils.ryanuo.cc/api/common/functions/compress.html);[decompress()](https://utils.ryanuo.cc/api/common/functions/decompress.html);[decrypt()](https://utils.ryanuo.cc/api/common/functions/decrypt.html);[encrypt()](https://utils.ryanuo.cc/api/common/functions/encrypt.html);[xor()](https://utils.ryanuo.cc/api/common/functions/xor.html);[isBoolean()](https://utils.ryanuo.cc/api/common/functions/isBoolean.html);[isBrowser()](https://utils.ryanuo.cc/api/common/functions/isBrowser.html);[isDate()](https://utils.ryanuo.cc/api/common/functions/isDate.html);[isEmptyObject()](https://utils.ryanuo.cc/api/common/functions/isEmptyObject.html);[isFunction()](https://utils.ryanuo.cc/api/common/functions/isFunction.html);[isNull()](https://utils.ryanuo.cc/api/common/functions/isNull.html);[isNumber()](https://utils.ryanuo.cc/api/common/functions/isNumber.html);[isObject()](https://utils.ryanuo.cc/api/common/functions/isObject.html);[isRegExp()](https://utils.ryanuo.cc/api/common/functions/isRegExp.html);[isString()](https://utils.ryanuo.cc/api/common/functions/isString.html);[isUndefined()](https://utils.ryanuo.cc/api/common/functions/isUndefined.html);[deepClone()](https://utils.ryanuo.cc/api/common/functions/deepClone.html);[getTypeName()](https://utils.ryanuo.cc/api/common/functions/getTypeName.html);[numberToFixed()](https://utils.ryanuo.cc/api/common/functions/numberToFixed.html);[toString()](https://utils.ryanuo.cc/api/common/functions/toString.html) |
7878| [ Finance] ( https://utils.ryanuo.cc/api/finance/ ) | [ formatCurrency()] ( https://utils.ryanuo.cc/api/finance/functions/formatCurrency.html ) ;[ calculatePercentage()] ( https://utils.ryanuo.cc/api/finance/functions/calculatePercentage.html ) ;[ compare()] ( https://utils.ryanuo.cc/api/finance/functions/compare.html ) ;[ preciseAdd()] ( https://utils.ryanuo.cc/api/finance/functions/preciseAdd.html ) ;[ preciseDiv()] ( https://utils.ryanuo.cc/api/finance/functions/preciseDiv.html ) ;[ preciseMul()] ( https://utils.ryanuo.cc/api/finance/functions/preciseMul.html ) ;[ preciseSub()] ( https://utils.ryanuo.cc/api/finance/functions/preciseSub.html ) ;[ roundTo()] ( https://utils.ryanuo.cc/api/finance/functions/roundTo.html ) ;[ decimal()] ( https://utils.ryanuo.cc/api/finance/variables/decimal.html ) |
7979| [ Graphics] ( https://utils.ryanuo.cc/api/graphics/ ) | [ hexToRgba()] ( https://utils.ryanuo.cc/api/graphics/functions/hexToRgba.html ) ;[ lerpColor()] ( https://utils.ryanuo.cc/api/graphics/functions/lerpColor.html ) ;[ rgbaToHex()] ( https://utils.ryanuo.cc/api/graphics/functions/rgbaToHex.html ) |
8080| [ Network] ( https://utils.ryanuo.cc/api/network/ ) | [ checkNetworkStatus()] ( https://utils.ryanuo.cc/api/network/functions/checkNetworkStatus.html ) ;[ fetchWithTimeout()] ( https://utils.ryanuo.cc/api/network/functions/fetchWithTimeout.html ) ;[ getClientIP()] ( https://utils.ryanuo.cc/api/network/functions/getClientIP.html ) ;[ getIndexedDBCache()] ( https://utils.ryanuo.cc/api/network/functions/getIndexedDBCache.html ) ;[ parallelRequests()] ( https://utils.ryanuo.cc/api/network/functions/parallelRequests.html ) ;[ request()] ( https://utils.ryanuo.cc/api/network/functions/request.html ) |
Original file line number Diff line number Diff line change 1+ [ @ryanuo/utils ] ( ../../index.md ) / [ common] ( ../index.md ) / compress
2+
3+ # Function: compress()
4+
5+ ``` ts
6+ function compress(str ): string ;
7+ ```
8+
9+ Compresses a UTF-8 string into a Base64 URI-safe format.
10+
11+ ## Parameters
12+
13+ ### str
14+
15+ ` string `
16+
17+ The string to compress.
18+
19+ ## Returns
20+
21+ ` string `
22+
23+ The compressed, Base64-encoded string.
24+
25+ ## Example
26+
27+ ``` ts twoslash
28+ import { compress } from ' @ryanuo/utils'
29+ compress (' hello world' ) // => 'aGVsbG8lMjB3b3JsZA%3D%3D'
30+ ```
Original file line number Diff line number Diff line change 1+ [ @ryanuo/utils ] ( ../../index.md ) / [ common] ( ../index.md ) / decompress
2+
3+ # Function: decompress()
4+
5+ ``` ts
6+ function decompress(str ): string ;
7+ ```
8+
9+ Decompresses a string produced by [ compress] ( compress.md ) .
10+
11+ ## Parameters
12+
13+ ### str
14+
15+ ` string `
16+
17+ The compressed Base64 string.
18+
19+ ## Returns
20+
21+ ` string `
22+
23+ The original decompressed string.
24+
25+ ## Example
26+
27+ ``` ts twoslash
28+ import { decompress } from ' @ryanuo/utils'
29+ decompress (compress (' hello world' )) // => 'hello world'
30+ ```
Original file line number Diff line number Diff line change 1+ [ @ryanuo/utils ] ( ../../index.md ) / [ common] ( ../index.md ) / decrypt
2+
3+ # Function: decrypt()
4+
5+ ``` ts
6+ function decrypt(str , key ? ): string ;
7+ ```
8+
9+ Decrypts a string previously encrypted with [ encrypt] ( encrypt.md ) .
10+ Applies URI decoding, Base64 decoding, and XOR decryption.
11+
12+ ## Parameters
13+
14+ ### str
15+
16+ ` string `
17+
18+ The encrypted string.
19+
20+ ### key?
21+
22+ ` string `
23+
24+ Optional decryption key (must match the encryption key).
25+
26+ ## Returns
27+
28+ ` string `
29+
30+ The decrypted plain text string.
31+
32+ ## Example
33+
34+ ``` ts twoslash
35+ import { encrypt , decrypt } from ' @ryanuo/utils'
36+ const enc = encrypt (' hello world' , ' key' )
37+ decrypt (enc , ' key' ) // => 'hello world'
38+ ```
Original file line number Diff line number Diff line change 1+ [ @ryanuo/utils ] ( ../../index.md ) / [ common] ( ../index.md ) / encrypt
2+
3+ # Function: encrypt()
4+
5+ ``` ts
6+ function encrypt(str , key ? ): string ;
7+ ```
8+
9+ Encrypts a string using XOR, Base64, and URI encoding for safe transmission.
10+
11+ ## Parameters
12+
13+ ### str
14+
15+ ` string `
16+
17+ The plain text to encrypt.
18+
19+ ### key?
20+
21+ ` string `
22+
23+ Optional encryption key, defaults to ` 'ryanuo' ` .
24+
25+ ## Returns
26+
27+ ` string `
28+
29+ The encrypted, URI-safe string.
30+
31+ ## Example
32+
33+ ``` ts twoslash
34+ import { encrypt } from ' @ryanuo/utils'
35+ encrypt (' hello world' , ' key' ) // => '%4D%0A...'
36+ ```
Original file line number Diff line number Diff line change 1+ [ @ryanuo/utils ] ( ../../index.md ) / [ common] ( ../index.md ) / xor
2+
3+ # Function: xor()
4+
5+ ``` ts
6+ function xor(str , key ): string ;
7+ ```
8+
9+ Performs XOR encryption or decryption on a string using a given key.
10+
11+ ## Parameters
12+
13+ ### str
14+
15+ ` string `
16+
17+ The string to process.
18+
19+ ### key
20+
21+ ` string ` = ` 'ryanuo' `
22+
23+ The encryption key, defaults to ` 'ryanuo' ` .
24+
25+ ## Returns
26+
27+ ` string `
28+
29+ The XOR-transformed string.
30+
31+ ## Example
32+
33+ ``` ts twoslash
34+ import { xor } from ' @ryanuo/utils'
35+ xor (' abc' , ' key' ) // Encrypt
36+ xor (xor (' abc' , ' key' ), ' key' ) // Decrypt (reversible)
37+ ```
Original file line number Diff line number Diff line change 2121| [ safeJSONParse] ( functions/safeJSONParse.md ) | Safely parses a JSON string |
2222| [ throttle] ( functions/throttle.md ) | Creates a throttled function that only executes the original function at most once per ` delay ` milliseconds. If ` immediate ` is true, the original function will be executed immediately upon the first call within the ` delay ` period. |
2323
24+ ## compress
25+
26+ | Function | Description |
27+ | ------ | ------ |
28+ | [ compress] ( functions/compress.md ) | Compresses a UTF-8 string into a Base64 URI-safe format. |
29+ | [ decompress] ( functions/decompress.md ) | Decompresses a string produced by [ compress] ( functions/compress.md ) . |
30+
31+ ## crypto
32+
33+ | Function | Description |
34+ | ------ | ------ |
35+ | [ decrypt] ( functions/decrypt.md ) | Decrypts a string previously encrypted with [ encrypt] ( functions/encrypt.md ) . Applies URI decoding, Base64 decoding, and XOR decryption. |
36+ | [ encrypt] ( functions/encrypt.md ) | Encrypts a string using XOR, Base64, and URI encoding for safe transmission. |
37+ | [ xor] ( functions/xor.md ) | Performs XOR encryption or decryption on a string using a given key. |
38+
2439## is
2540
2641| Function | Description |
You can’t perform that action at this time.
0 commit comments