@ryanuo/utils / common
common
提供项目通用工具类、基础类型和公共逻辑,避免代码重复。
Date
| Function | Description |
|---|---|
| dateFormat | 日期格式化 |
Other
| Name | Description |
|---|---|
| dayjs | - |
| curry | Converts a function into a curried function. The feature of a curried function is that it can receive one or more arguments, and returns a new function until all required arguments are received, then executes the original function. |
| debounce | Function debouncing A debouncing function is used to limit the frequency of executing a function within a specified time frame, preventing it from being called too frequently. If the function is called again within the specified interval, the previous call will be canceled and the timer will reset. |
| getUuid | Generate a unique UUID UUID (Universally Unique Identifier) is a standard used in distributed systems to uniquely identify information This function implements a simple UUID generation algorithm, primarily used to generate unique identifiers for use in applications |
| safeJSONParse | Safely parses a JSON string |
| throttle | 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. |
compress
| Function | Description |
|---|---|
| compress | Compresses a UTF-8 string into a Base64 URI-safe format. |
| decompress | Decompresses a string produced by compress. |
crypto
| Function | Description |
|---|---|
| decrypt | Decrypts a string previously encrypted with encrypt. Applies URI decoding, Base64 decoding, and XOR decryption. |
| encrypt | Encrypts a string using XOR, Base64, and URI encoding for safe transmission. |
| xor | Performs XOR encryption or decryption on a string using a given key. |
is
| Function | Description |
|---|---|
| isBoolean | Checks if the value is a boolean |
| isBrowser | Checks if the current environment is a browser |
| isDate | Checks if the value is an date |
| isEmptyObject | Check if an object is empty. |
| isFunction | Checks if the value is a function |
| isNull | Checks if the value is an null |
| isNumber | Checks if the value is a number |
| isObject | Checks if the value is an object |
| isRegExp | Checks if the value is an regexp |
| isString | Checks if the value is an string |
| isUndefined | Checks if the value is an undefined |
type
| Function | Description |
|---|---|
| deepClone | 安全的深拷贝(处理循环引用) |
| getTypeName | Get the type name of the value |
| numberToFixed | Convert a number to a fixed value with specified decimal places. |
| toString | to string type of value [Object.prototype.toString] |