Skip to content

Commit

Permalink
ESNext compatibility (dexie#812)
Browse files Browse the repository at this point in the history
* Check tests pass forcing Promise

Also removed template literal to plain string, as not templating needed

* Tests passed - check _global.Promise

all 239 tests passed on my machine with the prior commit (which would have been bypassed with the current if clause when running on a browser)
  • Loading branch information
mcshaz authored and dfahlander committed Mar 22, 2019
1 parent e05e103 commit 01dc4c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/functions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
declare var global;
export const keys = Object.keys;
export const isArray = Array.isArray;
export const _global =
const _global =
typeof self !== 'undefined' ? self :
typeof window !== 'undefined' ? window :
global;
if (!_global.Promise){
_global.Promise = Promise;
}
export { _global }

export function extend(obj, extension) {
if (typeof extension !== 'object') return obj;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const
nativePromiseInstanceAndProto = (()=>{
try {
// Be able to patch native async functions
return new Function(`let F=async ()=>{},p=F();return [p,Object.getPrototypeOf(p),Promise.resolve(),F.constructor];`)();
return new Function('let F=async ()=>{},p=F();return [p,Object.getPrototypeOf(p),Promise.resolve(),F.constructor];')();
} catch(e) {
var P = _global.Promise;
return P ?
Expand Down

0 comments on commit 01dc4c3

Please sign in to comment.