Chrome | 119.0.0 | own | function | (...args) => {
const me = globalThis[bindingName];
if (needsHandle && args.slice(1).some(arg => arg !== undefined)) throw new Error(`exposeBindingHandle supports a single argument, ${args.length} received`);
let callbacks = me['callbacks'];
if (!callbacks) {
callbacks = new Map();
me['callbacks'] = callbacks;
}
const seq = (me['lastSeq'] || 0) + 1;
me['lastSeq'] = seq;
let handles = me['handles'];
if (!handles) {
handles = new Map();
me['handles'] = handles;
}
const promise = new Promise((resolve, reject) => callbacks.set(seq, {
resolve,
reject
}));
let payload;
if (needsHandle) {
handles.set(seq, args[0]);
payload = {
name: bindingName,
seq
};
} else {
const serializedArgs = args.map(a => utilityScriptSerializers.serializeAsCallArgument(a, v => {
return {
fallThrough: v
};
}));
payload = {
name: bindingName,
seq,
serializedArgs
};
}
binding(JSON.stringify(payload));
return promise;
} |
Safari | 15.0.0 | own | function | (...args) => {
const me = globalThis[bindingName];
if (needsHandle && args.slice(1).some(arg => arg !== undefined)) throw new Error(`exposeBindingHandle supports a single argument, ${args.length} received`);
let callbacks = me['callbacks'];
if (!callbacks) {
callbacks = new Map();
me['callbacks'] = callbacks;
}
const seq = (me['lastSeq'] || 0) + 1;
me['lastSeq'] = seq;
let handles = me['handles'];
if (!handles) {
handles = new Map();
me['handles'] = handles;
}
const promise = new Promise((resolve, reject) => callbacks.set(seq, {
resolve,
reject
}));
let payload;
if (needsHandle) {
handles.set(seq, args[0]);
payload = {
name: bindingName,
seq
};
} else {
const serializedArgs = args.map(a => utilityScriptSerializers.serializeAsCallArgument(a, v => {
return {
fallThrough: v
};
}));
payload = {
name: bindingName,
seq,
serializedArgs
};
}
binding(JSON.stringify(payload));
return promise;
} |