UNPKG

@naverpay/hidash

Version:

improved lodash

18 lines (16 loc) 961 B
/** * @description * Creates a function that invokes `func` as long as it's called less than `initialN` times. * Subsequent calls to the new function return the result of the last `func` invocation. * This behavior is similar to lodash's `_.before` function. * * @template T - The type of the function to restrict. * @param {number} initialN - The number determining how many times `func` can be called. * `func` is invoked if called less than `initialN` times (i.e., up to `initialN - 1` times). * If `initialN` is less than or equal to 1, `func` will not be invoked. * @param {T} func - The function to restrict. * @returns {(...args: Parameters<T>) => ReturnType<T>} Returns the new restricted function. * @throws {TypeError} If `func` is not a function. */ declare function before<T extends (...args: Parameters<T>) => ReturnType<T>>(initialN: number, func: T): (...args: Parameters<T>) => ReturnType<T>; export { before, before as default };