@whitesev/utils 2.9.1 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +5 -3
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +5 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +5 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +5 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +5 -3
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +5 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Utils.d.ts +10 -3
- package/package.json +1 -1
- package/src/Utils.ts +9 -7
|
@@ -1567,9 +1567,16 @@ declare class Utils {
|
|
|
1567
1567
|
* fn(4,5);
|
|
1568
1568
|
* > 9
|
|
1569
1569
|
*/
|
|
1570
|
-
createFunction(code: string): (
|
|
1571
|
-
createFunction(param: string, code: string): (
|
|
1572
|
-
createFunction<
|
|
1570
|
+
createFunction<R = any>(code: string): () => R;
|
|
1571
|
+
createFunction<R = any>(param: string, code: string): (param: any) => R;
|
|
1572
|
+
createFunction<P extends string[]>(...params: [...P, code: string]): (...args: {
|
|
1573
|
+
[K in keyof P]: any;
|
|
1574
|
+
}) => any;
|
|
1575
|
+
createFunction<P extends string[], T extends boolean>(...params: [...P, code: string, isAsync: T]): T extends true ? (...params: {
|
|
1576
|
+
[K in keyof P]: any;
|
|
1577
|
+
}) => Promise<any> : (...args: {
|
|
1578
|
+
[K in keyof P]: any;
|
|
1579
|
+
}) => any;
|
|
1573
1580
|
}
|
|
1574
1581
|
declare const utils: Utils;
|
|
1575
1582
|
export { utils as Utils };
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -3799,19 +3799,21 @@ class Utils {
|
|
|
3799
3799
|
* fn(4,5);
|
|
3800
3800
|
* > 9
|
|
3801
3801
|
*/
|
|
3802
|
-
createFunction(code: string): (
|
|
3803
|
-
createFunction(param: string, code: string): (
|
|
3804
|
-
createFunction<
|
|
3805
|
-
|
|
3806
|
-
|
|
3802
|
+
createFunction<R = any>(code: string): () => R;
|
|
3803
|
+
createFunction<R = any>(param: string, code: string): (param: any) => R;
|
|
3804
|
+
createFunction<P extends string[]>(...params: [...P, code: string]): (...args: { [K in keyof P]: any }) => any;
|
|
3805
|
+
createFunction<P extends string[], T extends boolean>(
|
|
3806
|
+
...params: [...P, code: string, isAsync: T]
|
|
3807
|
+
): T extends true ? (...params: { [K in keyof P]: any }) => Promise<any> : (...args: { [K in keyof P]: any }) => any;
|
|
3807
3808
|
createFunction<A extends string[], T extends boolean>(
|
|
3808
3809
|
...args: [...A, code: string, isAsync?: T]
|
|
3809
3810
|
): T extends true ? (...args: any[]) => Promise<any> : (...args: any[]) => any {
|
|
3810
3811
|
let isAsync: string | boolean | undefined = args[args.length - 1];
|
|
3811
|
-
if (typeof isAsync
|
|
3812
|
+
if (typeof isAsync === "boolean") {
|
|
3813
|
+
args.splice(args.length - 1, 1);
|
|
3814
|
+
} else {
|
|
3812
3815
|
isAsync = false;
|
|
3813
3816
|
}
|
|
3814
|
-
args.splice(args.length - 1, 1);
|
|
3815
3817
|
if (isAsync) {
|
|
3816
3818
|
const AsyncFunctionConstructor = Object.getPrototypeOf(async function () {}).constructor;
|
|
3817
3819
|
return new AsyncFunctionConstructor(...args);
|