change method name

This commit is contained in:
Bruno Windels 2020-09-28 13:25:44 +02:00
parent 9498524369
commit 706ec97296
2 changed files with 15 additions and 14 deletions

View File

@ -16,8 +16,6 @@ limitations under the License.
// polyfills needed for IE11
const hasNativePromise = typeof window.Promise === "function";
// TODO: don't include a polyfill for promises as we already provide one
import "core-js/stable";
import "regenerator-runtime/runtime";
@ -28,12 +26,15 @@ import "mdn-polyfills/Element.prototype.closest";
// it will also include the file supporting *all* the encodings,
// weighing a good extra 500kb :-(
import "text-encoding";
import {Promifill} from "./utils/Promifill.js";
import Promise from "../lib/es6-promise/lib/es6-promise/promise.js";
// console.log("hasNativePromise", hasNativePromise);
// if (!hasNativePromise) {
window.Promise = Promifill;
// }
const flush = Promise._flush;
Promise._flush = function() {
console.log("manually flushing promise queue");
flush();
}
window.Promise = Promise;
// TODO: contribute this to mdn-polyfills
if (!Element.prototype.remove) {

View File

@ -52,11 +52,11 @@ export function reqAsPromise(req) {
return new Promise((resolve, reject) => {
req.addEventListener("success", event => {
resolve(event.target.result);
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
});
req.addEventListener("error", () => {
reject(new IDBRequestError(req));
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
});
});
}
@ -65,11 +65,11 @@ export function txnAsPromise(txn) {
return new Promise((resolve, reject) => {
txn.addEventListener("complete", () => {
resolve();
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
});
txn.addEventListener("abort", () => {
reject(new IDBRequestError(txn));
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
});
});
}
@ -79,14 +79,14 @@ export function iterateCursor(cursorRequest, processValue) {
return new Promise((resolve, reject) => {
cursorRequest.onerror = () => {
reject(new IDBRequestError(cursorRequest));
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
};
// collect results
cursorRequest.onsuccess = (event) => {
const cursor = event.target.result;
if (!cursor) {
resolve(false);
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
return; // end of results
}
const result = processValue(cursor.value, cursor.key);
@ -95,7 +95,7 @@ export function iterateCursor(cursorRequest, processValue) {
if (done) {
resolve(true);
Promise.flushQueue && Promise.flushQueue();
Promise._flush && Promise._flush();
} else if(jumpTo) {
cursor.continue(jumpTo);
} else {