From 63bbe0f72b0ad37b17f34f8f41ba4042564dc3b0 Mon Sep 17 00:00:00 2001
From: Kir_Antipov <kp.antipov@gmail.com>
Date: Sun, 4 Dec 2022 18:37:59 +0000
Subject: [PATCH] Made interfaces for delegates

Because built-in `Function` is not flexible
---
 src/utils/functions/async-func.ts | 16 ++++++++++++++++
 src/utils/functions/func.ts       | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 src/utils/functions/async-func.ts
 create mode 100644 src/utils/functions/func.ts

diff --git a/src/utils/functions/async-func.ts b/src/utils/functions/async-func.ts
new file mode 100644
index 0000000..0ce92ca
--- /dev/null
+++ b/src/utils/functions/async-func.ts
@@ -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>;
+}
diff --git a/src/utils/functions/func.ts b/src/utils/functions/func.ts
new file mode 100644
index 0000000..829280c
--- /dev/null
+++ b/src/utils/functions/func.ts
@@ -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;
+}