UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

17 lines 517 B
export function isAsync(fn) { const n = 'getMockImplementation'; if (fn?.[n]?.()) { fn = fn[n](); } const firstCheck = fn instanceof (async () => null).constructor; const secondCheck = fn?.constructor?.name === 'AsyncFunction'; if (firstCheck !== secondCheck) { return true; } const isAsyncFunctionBabelTranspiled = fn?.toString()?.trim()?.match(/return _ref[^.]*\.apply/); if (isAsyncFunctionBabelTranspiled) { return true; } return firstCheck; } //# sourceMappingURL=isAsync.js.map