feat: add async function
This commit is contained in:
@@ -14,6 +14,7 @@ interface FunctionConstructor extends Function {
|
||||
(...args: string[]): (...args: any[]) => any;
|
||||
new (...args: string[]): (...args: any[]) => any;
|
||||
prototype: Function;
|
||||
async<ArgsT extends any[], RetT>(func: (await: <T>(val: T) => Awaited<T>, args: ArgsT) => RetT): Promise<RetT>;
|
||||
}
|
||||
|
||||
interface CallableFunction extends Function {
|
||||
@@ -75,4 +76,10 @@ setProps(Function.prototype, {
|
||||
toString() {
|
||||
return 'function (...) { ... }';
|
||||
},
|
||||
});
|
||||
});
|
||||
setProps(Function, {
|
||||
async(func) {
|
||||
if (typeof func !== 'function') throw new TypeError('Expected func to be function.');
|
||||
return internals.makeAsync(func);
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user