Commit 7ab0b066 authored by Avi's avatar Avi

if/else for function to check and return other thing (hopefully) works!

parent 65d54771
......@@ -5,16 +5,44 @@ var promisify = (
) => {
GioType[`original_${asyncStuff}`] = GioType[asyncStuff];
GioType[asyncStuff] = function(...args) {
return new Promise((resolve, reject)=>{
this[`original_${asyncStuff}`](...args, function(source, res) {
try {
let result = source[finishStuff](res);
resolve(result);
} catch (error) {
reject(error);
}
});
// print(`This should be args.length here! ${args.length}`);
for(let i=0; i<args.length; i++){
print(`This should be which param index: ${i} and the value for this one is: ${args[i]}`);
print(`Please print the typeof here: ${typeof args[0]}`);
if(typeof args[i]==="function"){
// print("Yay this works!");
return this[asyncStuff];
}
else{
return new Promise((resolve, reject)=>{
this[`original_${asyncStuff}`](...args, function(source, res) {
try {
let result = source[finishStuff](res);
resolve(result);
} catch (error) {
reject(error);
}
});
});
}
// if(typeof args[i]==="object"){
// print("This worked huzzah whoo!");
// }
// else{
// print("This is not working yet oh noes!");
// }
}
// return new Promise((resolve, reject)=>{
// this[`original_${asyncStuff}`](...args, function(source, res) {
// try {
// let result = source[finishStuff](res);
// resolve(result);
// } catch (error) {
// reject(error);
// }
// });
});
// });
};
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment