@zhsz/cool-design-dv
Version:
129 lines (128 loc) • 4.24 kB
TypeScript
/**
* 动画延时函数
* @function
* @param {function} callback 动画回调函数
* @return {number} id 标识
*
* @example
*
* import {requestAnimationFrame} from '$ui/utils/util'
* requestAnimationFrame(() => {
* // do sth ....
*
* })
*/
export declare const requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof globalThis.requestAnimationFrame;
/**
* 清除动画延时
* @function
* @param {number} id 标识
*
* @example
*
* import {requestAnimationFrame, cancelAnimationFrame} from '$ui/utils/util'
* const id = requestAnimationFrame(()= > {
* // do sth
* })
* cancelAnimationFrame(id)
*/
export declare const cancelAnimationFrame: ((handle: number) => void) & typeof globalThis.cancelAnimationFrame;
/**
* 判断两个对象是否相等
* @param {*} object 对象1
* @param {*} other 对象2
* @return {boolean}
*/
export declare function isEqual(object: any, other: any): boolean;
/**
* 防抖函数
* @param {function} fn 事件处理函数
* @param {number} [delay=20] 延迟时间
* @param {boolean} [isImmediate=false] 是否立刻执行
* @param {object} [context=this] 上下文对象
* @returns {Function} 事件处理函数
*/
export declare function debounce(fn: any, delay?: number, isImmediate?: boolean, context?: any): () => void;
/**
* 节流函数
* @param {function} fn 事件处理函数
* @param {object} [context=this] 上下文对象
* @param {boolean} [isImmediate=false] 是否立刻执行
* @returns {Function} 事件处理函数
*/
export declare function throttle(fn: any, context?: any, isImmediate?: boolean): () => void;
/**
* 生成随机GUID
* @return {string}
*/
export declare function guid(): string;
/**
* 生成唯一id
* @return {string}
*/
export declare function uid(): string;
/**
* 根据path查找对象或数组中的某个属性
* @param {object|array} object 要检索的对象
* @param {string|array} path 要获取属性的路径
* @param {string} [defaultValue] 如果解析值是 undefined ,这值会被返回。
* @return {undefined|*}
*
* @example
*
* import {get} from '$ui/utils/util'
* const object = { 'a': [{ 'b': { 'c': 3 } }] };
* get(object, 'a[0].b.c') // -> 3
*/
export declare function get(object: any, path: any, defaultValue: any): any;
/**
* 设置 object对象中对应 path 属性路径上的值,如果path不存在,则创建。 缺少的索引属性会创建为数组,而缺少的属性会创建为对象
* @param {object} object 要修改的对象
* @param {string|array} path 要设置的对象路径
* @param {*} value 要设置的值
*/
export declare function set(object: any, path: any, value: any): any;
/**
* 深拷贝
* @param {*} value 要深拷贝的值
* @return {*} 返回拷贝后的值
*/
export declare function cloneDeep(value: any): any;
/**
* 对数组按制定字段名称进行分组
* @param {Array} data 数组数组
* @param {string} [field=group] 分组字段名称
* @returns {object} 结果
*
* @example
* [{name:1, group:'a'},{name:2, group:'a'}, {name:3, group:'b'}] ->
* {
* 'a':[{name:1, group:'a'}, {name:2, group:'a'}]
* 'b': [{name:3, group:'b'}]
* }
*/
export declare function grouping(data?: never[], field?: string): {
default: never[];
};
/**
* 分页获取数据
* @param {Array} data 源数据
* @param {number} [page=1] 当前页面,1开始
* @param {number} [size=10] 页大小,默认10
* @return {Array}
*/
export declare function pager(data: any, page?: number, size?: number): any;
export declare function mulAdd(nums: any): any;
export declare function filterNonNumber(array: any): any;
export declare function getTwoPointDistance(pointOne: any, pointTwo: any): number;
export declare function getPolylineLength(points: any): any;
export declare function random(min: any, max: any): number;
/**
* @description Get the coordinates of the specified radian on the circle
* @param {Number} x Circle x coordinate
* @param {Number} y Circle y coordinate
* @param {Number} radius Circle radius
* @param {Number} radian Specfied radian
* @return {Array} Postion of point
*/
export declare function getCircleRadianPoint(x: any, y: any, radius: any, radian: any): any[];