[gjs: 4/6] Gio: Compare the number of arguments passed with the original function




commit 588402611bd73bdd398eb1e50c305f36e1029da1
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Jul 8 04:20:35 2022 +0200

    Gio: Compare the number of arguments passed with the original function
    
    In case an use intended to call the original function we can just guess
    this by comparing the number of arguments, given that we don't have
    optional arguments in Gjs, so if this value matches then it's clear that
    the original one has to be called instead.

 modules/core/overrides/Gio.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/modules/core/overrides/Gio.js b/modules/core/overrides/Gio.js
index fab7af024..041002a53 100644
--- a/modules/core/overrides/Gio.js
+++ b/modules/core/overrides/Gio.js
@@ -430,7 +430,7 @@ function _promisify(proto, asyncFunc,
         return;
     proto[originalFuncName] = proto[asyncFunc];
     proto[asyncFunc] = function (...args) {
-        if (!args.every(arg => typeof arg !== 'function'))
+        if (args.length === this[originalFuncName].length)
             return this[originalFuncName](...args);
         return new Promise((resolve, reject) => {
             let {stack: callStack} = new Error();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]