Skip to content

Instantly share code, notes, and snippets.

@zekrom-vale
Created July 23, 2019 02:41
Show Gist options
  • Save zekrom-vale/23d1b2762d0f56900dd04701c55fb50a to your computer and use it in GitHub Desktop.
Save zekrom-vale/23d1b2762d0f56900dd04701c55fb50a to your computer and use it in GitHub Desktop.
console.time("test");
Promise.all([
new Promise(r=>chrome.storage.sync.get(null, s=>r(s))),
new Promise(r=>chrome.storage.local.get(null, l=>r(l)))
]).then(x=>console.timeEnd("test"));
console.time("test2");
chrome.storage.sync.get(s=>{
chrome.storage.local.get(l=>console.timeEnd("test2"));
});
Promise.race([
Promise.all([
new Promise(r=>chrome.storage.sync.get(null, s=>r("Parallel"))),
new Promise(r=>chrome.storage.local.get(null, l=>r("Parallel")))
]),
new Promise(r=>{
chrome.storage.sync.get(null, s=>{
chrome.storage.local.get(null, l=>r("Synchronous"));
});
})
]).then(x=>console.log(x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment