Files
jasmine/spec/helpers/asyncAwait.js
2019-05-21 18:23:48 -07:00

27 lines
583 B
JavaScript

(function(env) {
function getAsyncCtor() {
try {
eval('var func = async function(){};');
} catch (e) {
return null;
}
return Object.getPrototypeOf(func).constructor;
}
function hasAsyncAwaitSupport() {
return getAsyncCtor() !== null;
}
env.makeAsyncAwaitFunction = function() {
var AsyncFunction = getAsyncCtor();
return new AsyncFunction('');
};
env.requireAsyncAwait = function() {
if (!hasAsyncAwaitSupport()) {
env.pending('Environment does not support async/await functions');
}
};
})(jasmine.getEnv());