UNPKG

callyflower

Version:

A collection of lightweight higher order functions to add customizable event handling to a function execution flow.

13 lines (12 loc) 803 B
import { OnResultHandler } from "./types"; /** * Wraps a function with an `onResult` event handler, allowing modification of the function's result. * The returned function calls the original function and applies the `onResult` event afterward. * * @template F - The type of the function to wrap. * @param {F} callee - The original function to wrap. * @param {OnResultHandler<F>} onCall - The handler invoked before the function call to modify the arguments. * @returns {F} A new function that wraps the original function with the `onResult` event handler. */ declare const withOnResult: <F extends (...args: any) => any>(callee: F, onResult?: OnResultHandler<F>) => F | ((...args: Parameters<F>) => ReturnType<F>) | ((...args: Parameters<F>) => Promise<ReturnType<F>>); export { withOnResult };