I can't use promises because it force the user to convert everything to async functions for sync methods. Is there any way to force the proxy to not to return until the callback complete?
function callbackCase() {
function saySomething(callback) {
callback("Stackoverflow");
}
console.error = new Proxy(console.error, {
apply: (target, thisArg, args) => {
saySomething((result) => {
return result;
})
}
})
let test = console.error();
console.log("From Callback Case", test);
}
function nonCallbackCase() {
console.errors = new Proxy(console.error, {
apply: (target, thisArg, args) => {
return "Stackoverflow";
}
})
let test = console.errors();
console.log("From Non Callback Case", test);
}
callbackCase()
nonCallbackCase()