Skip to content

Instantly share code, notes, and snippets.

@SergeyPirogov
Created February 6, 2020 14:29
Show Gist options
  • Select an option

  • Save SergeyPirogov/db9d2adafb14a7e8c4b4c1d16f29c3ff to your computer and use it in GitHub Desktop.

Select an option

Save SergeyPirogov/db9d2adafb14a7e8c4b4c1d16f29c3ff to your computer and use it in GitHub Desktop.

Revisions

  1. SergeyPirogov created this gist Feb 6, 2020.
    13 changes: 13 additions & 0 deletions promise
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const sendCommand = (target, method, params) =>
    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);
    });