mine-h5-ui
Version:
一款轻量级、模块化基于 Vue3.x 的 H5 前端 UI 组件库 👍
62 lines (61 loc) • 1.65 kB
TypeScript
import { FormatTimeBack, FormatData, DTCallback, ThrottleBack, DebounceBack, LockedCallback, LockedBack, CalculationBack } from '../../MeAPI/types';
/**
* 工具函数
* @example
* ```ts
* import { useUtils } from 'mine-h5-ui'
*
* const { varType, cloneDeep, isLeapyear, formatTime, countDown, throttle, debounce, locked, addZero, calculation, generateRandom, retarder } = useUtils()
* console.log(varType.isString('')) // 输出: true
* ```
*/
export declare const useUtils: () => {
/**
* 变量类型判断
*/
varType: (type: string, value: unknown) => boolean;
/**
* 深拷贝变量 - 递归算法(recursive algorithm)
*/
cloneDeep: (arg: any) => any;
/**
* 判断是否是闰年
*/
isLeapyear: (num: number) => boolean;
/**
* 时间转换
*/
formatTime: (arg?: string | number | Date) => FormatTimeBack;
/**
* 倒计时
*/
countDown: (num: number, format?: string) => Partial< FormatData>;
/**
* 节流
*/
throttle: (fn: DTCallback, time?: number) => ThrottleBack;
/**
* 防抖
*/
debounce: (fn: DTCallback, time?: number) => DebounceBack;
/**
* 锁定
*/
locked: (fn: LockedCallback, time?: number) => LockedBack;
/**
* 加 0 补位
*/
addZero: (str: string, float1: number, float2: number) => string;
/**
* 加减乘除运算
*/
calculation: (num1: number, num2: number) => CalculationBack;
/**
* 生成随机数
*/
generateRandom: () => string;
/**
* 延迟器
*/
retarder: (time?: number) => Promise<boolean>;
};