Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const callback = _Callback(cif, retType.size, argc, errorReportCallback, (retval, params) => {
debug('Callback function being invoked')
try {
const args = [];
for (var i = 0; i < argc; i++) {
const type = argTypes[i];
const argPtr = params.readPointer(i * ref.sizeof.pointer, type.size);
argPtr.type = type;
args.push(argPtr.deref());
}
// Invoke the user-given function
const result = func.apply(null, args);
try {
ref.set(retval, 0, result, retType);
} catch (e) {
e.message = 'error setting return value - ' + e.message;
throw e;
}
} catch (e) {
return e;
}
});