Fix browser compatibility (#18)
This commit is contained in:
parent
bddde18124
commit
b98a872b13
4
index.js
4
index.js
|
@ -22,7 +22,7 @@ const pTimeout = (promise, milliseconds, fallback, options) => new Promise((reso
|
||||||
...options
|
...options
|
||||||
};
|
};
|
||||||
|
|
||||||
const timer = options.customTimers.setTimeout(() => {
|
const timer = options.customTimers.setTimeout.call(undefined, () => {
|
||||||
if (typeof fallback === 'function') {
|
if (typeof fallback === 'function') {
|
||||||
try {
|
try {
|
||||||
resolve(fallback());
|
resolve(fallback());
|
||||||
|
@ -49,7 +49,7 @@ const pTimeout = (promise, milliseconds, fallback, options) => new Promise((reso
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
} finally {
|
} finally {
|
||||||
options.customTimers.clearTimeout(timer);
|
options.customTimers.clearTimeout.call(undefined, timer);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue