Skip to content

Commit

Permalink
utils: Override async functions with async functions
Browse files Browse the repository at this point in the history
Closes: #2110
  • Loading branch information
vanvugt committed Mar 20, 2024
1 parent 506dd02 commit 56ba256
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,15 @@ export class InjectionsHandler extends BasicHandler {
if (!(original instanceof Function))
throw new Error(`Virtual function ${name}() is not available for ${object}`);

object[name] = function (...args) {
return injectedFunction.call(this, original, ...args);
};
if (original.constructor.name === "AsyncFunction") {
object[name] = async function (...args) {
return injectedFunction.call(this, original, ...args);
};
} else {
object[name] = function (...args) {
return injectedFunction.call(this, original, ...args);
};
}
return [object, name, original];
}

Expand Down

0 comments on commit 56ba256

Please sign in to comment.