mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 01:41:05 -05:00
Made interfaces for delegates
Because built-in `Function` is not flexible
This commit is contained in:
parent
d263c15393
commit
63bbe0f72b
2 changed files with 32 additions and 0 deletions
16
src/utils/functions/async-func.ts
Normal file
16
src/utils/functions/async-func.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Represents an async function that takes any number of arguments of type `P` and returns a value of type `R`.
|
||||
*
|
||||
* @template P - An array of parameter types.
|
||||
* @template R - The return type of the function.
|
||||
*/
|
||||
export interface AsyncFunc<P extends unknown[] = unknown[], R = unknown> {
|
||||
/**
|
||||
* Calls the function with the specified arguments.
|
||||
*
|
||||
* @param args The arguments to pass to the function.
|
||||
*
|
||||
* @returns A promise resolving to the result of calling the function.
|
||||
*/
|
||||
(...args: P): Promise<R>;
|
||||
}
|
16
src/utils/functions/func.ts
Normal file
16
src/utils/functions/func.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Represents a function that takes any number of arguments of type `P` and returns a value of type `R`.
|
||||
*
|
||||
* @template P - An array of parameter types.
|
||||
* @template R - The return type of the function.
|
||||
*/
|
||||
export interface Func<P extends unknown[] = unknown[], R = unknown> {
|
||||
/**
|
||||
* Calls the function with the specified arguments.
|
||||
*
|
||||
* @param args The arguments to pass to the function.
|
||||
*
|
||||
* @returns The result of calling the function.
|
||||
*/
|
||||
(...args: P): R;
|
||||
}
|
Loading…
Reference in a new issue