-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* preparing for migration to manifest v3 * update manifest file * Change $.Deferred() to native Promise * Add fetchAdapter to axios(hotfix) * refactor jquery.whencallsequentially.js to native Promise(local scraper fix) * little fixes and improvements * interceptors fix * refactor all calls of removeCurrentContentSelector() to native Promise * removing axios fetchAdapter where its not needed * update version * update yarn.lock * update yarn.lock2
- Loading branch information
1 parent
9bcf6cd
commit 029c808
Showing
15 changed files
with
3,146 additions
and
2,921 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,14 @@ | ||
/** | ||
* @author Martins Balodis | ||
* | ||
* An alternative version of $.when which can be used to execute asynchronous | ||
* calls sequentially one after another. | ||
* | ||
* @returns $.Deferred().promise() | ||
*/ | ||
$.whenCallSequentially = function (functionCalls) { | ||
const deferredResonse = $.Deferred(); | ||
const resultData = new Array(); | ||
let promiseChain = Promise.resolve([]); | ||
|
||
// nothing to do | ||
if (functionCalls.length === 0) { | ||
return deferredResonse.resolve(resultData).promise(); | ||
} | ||
|
||
let currentDeferred = functionCalls.shift()(); | ||
// execute synchronous calls synchronously | ||
while (currentDeferred.state() === 'resolved') { | ||
currentDeferred.done(function (data) { | ||
resultData.push(data); | ||
}); | ||
if (functionCalls.length === 0) { | ||
return deferredResonse.resolve(resultData).promise(); | ||
} | ||
currentDeferred = functionCalls.shift()(); | ||
} | ||
|
||
// handle async calls | ||
var interval = setInterval(function () { | ||
// handle mixed sync calls | ||
while (currentDeferred.state() === 'resolved') { | ||
currentDeferred.done(function (data) { | ||
functionCalls.forEach(func => { | ||
promiseChain = promiseChain.then(resultData => { | ||
return func().then(data => { | ||
resultData.push(data); | ||
return resultData; | ||
}); | ||
if (functionCalls.length === 0) { | ||
clearInterval(interval); | ||
deferredResonse.resolve(resultData); | ||
break; | ||
} | ||
currentDeferred = functionCalls.shift()(); | ||
} | ||
}, 10); | ||
}); | ||
}); | ||
|
||
return deferredResonse.promise(); | ||
return promiseChain; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.