legacy.js 380 B

123456789101112131415161718
  1. 'use strict';
  2. /** @type {import('.').AsyncFunctionConstructor | false} */
  3. var cached;
  4. /** @type {import('.')} */
  5. module.exports = function getAsyncFunction() {
  6. if (typeof cached === 'undefined') {
  7. try {
  8. // eslint-disable-next-line no-new-func
  9. cached = Function('return async function () {}')().constructor;
  10. } catch (e) {
  11. cached = false;
  12. }
  13. }
  14. return cached;
  15. };