UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

24 lines (23 loc) 979 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isAsync = isAsync; function isAsync(fn) { var _fn, _fn$n, _fn2, _fn3; const n = 'getMockImplementation'; if ((_fn = fn) !== null && _fn !== void 0 && (_fn$n = _fn[n]) !== null && _fn$n !== void 0 && _fn$n.call(_fn)) { fn = fn[n](); } const firstCheck = fn instanceof (async () => null).constructor; const secondCheck = ((_fn2 = fn) === null || _fn2 === void 0 || (_fn2 = _fn2.constructor) === null || _fn2 === void 0 ? void 0 : _fn2.name) === 'AsyncFunction'; if (firstCheck !== secondCheck) { return true; } const isAsyncFunctionBabelTranspiled = (_fn3 = fn) === null || _fn3 === void 0 || (_fn3 = _fn3.toString()) === null || _fn3 === void 0 || (_fn3 = _fn3.trim()) === null || _fn3 === void 0 ? void 0 : _fn3.match(/return _ref[^.]*\.apply/); if (isAsyncFunctionBabelTranspiled) { return true; } return firstCheck; } //# sourceMappingURL=isAsync.js.map