Skip to content

Instantly share code, notes, and snippets.

@Xotabu4
Forked from SergeyPirogov/promise
Last active February 6, 2020 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xotabu4/b7c081cb4e5d1625fce211950755e9b7 to your computer and use it in GitHub Desktop.
Save Xotabu4/b7c081cb4e5d1625fce211950755e9b7 to your computer and use it in GitHub Desktop.
const sendCommand = (target, method, params) => {
return new Promise((resolve, reject) => {
chrome.debugger.sendCommand(target, method, params, result => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else {
resolve(result);
console.log(method, result);
}
});
}).catch(err => {
console.log(method, err);
});
}
const result = await sendCommand('foo', 'bar', {params: true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment