All files / utils ii.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                          2x    
/**
 * 立即调用函数并返回其返回值。
 *
 * 注:`ii = immediately invoke`
 *
 * @param fn 要调用的函数
 * @returns 返回被调用函数的返回值
 * @example
 * ```typescript
 * ii(() => 1) // => 1
 * ```
 */
export function ii<R, F extends () => R = () => R>(fn: F): R {
  return fn()
}