callyflower
Version:
A collection of lightweight higher order functions to add customizable event handling to a function execution flow.
44 lines (43 loc) • 2.08 kB
TypeScript
/**
* Check if a value is a function
* @param func - The value to check
* @returns {func is (...args: any) => any} - True if the value is a function
*/
declare const isCallable: (func: any) => func is (...args: any) => any;
/**
* Check if a function is synchronous
* @param func - The function to check
* @returns {boolean} - True if the function is synchronous
*/
declare const isSynchronous: <F extends (...args: any) => any>(func: F) => boolean;
/**
* throw an error if the value is not a function
* @param func - The function to check
* @throws {Error} - If the value is not a function
*/
declare const throwIfNotCallable: (func: any) => void;
/**
* Merge options with am optional transformer function
* @template H - The type of the transformer function
* @param options {any} - The options to merge
* @param transformer {H} - The transformer function
* @returns {any} - The merged options, either synchronously or asynchronously. if the transformer function returns a promise, the result will be a promise
*/
declare function baseMerge<H extends (params: any) => any>(options: Parameters<H>[0], transformer?: H): Parameters<H>[0] | Promise<Parameters<H>[0]>;
/**
* Merge options with am optional transformer function synchronously
* @template H - The type of the transformer function
* @param options {any} - The options to merge
* @param transformer {H} - The transformer function
* @returns {any} - The merged options
*/
declare const syncMerge: <H extends (params: any) => any>(options: Parameters<H>[0], transformer?: H) => Parameters<H>[0];
/**
* Merge options with am optional transformer function asynchronously
* @template H - The type of the transformer function
* @param options {any} - The options to merge
* @param transformer {H} - The transformer function
* @returns {Promise<any>} - The merged options
*/
declare const asyncMerge: <H extends (params: any) => any>(options: Parameters<H>[0], transformer?: H) => Promise<Parameters<H>[0]>;
export { isCallable, isSynchronous, throwIfNotCallable, baseMerge, syncMerge, asyncMerge };