t-comm
Version:
专业、稳定、纯粹的工具库
34 lines (33 loc) • 603 B
TypeScript
/**
* 将字符串转为函数
* @param {string} func 字符串
* @returns {Function} 字符串对应的函数
*
* @example
*
* parseFunction('()=>console.log(1)')
*
* // ()=>console.log(1)
*/
export declare function parseFunction(func: any): any;
/**
* 记忆函数:缓存函数的运算结果
* @param {Function} fn 输入函数
* @returns {any} 函数计算结果
*
* @example
* function test(a) {
* return a + 2
* }
*
* const cachedTest = cached(test)
*
* cachedTest(1)
*
* // => 3
*
* cachedTest(1)
*
* // => 3
*/
export declare function cached(fn: Function): any;