source: frontend/node_modules/is-async-function/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 830 bytes
Line 
1'use strict';
2
3var callBound = require('call-bound');
4var safeRegexTest = require('safe-regex-test');
5
6var toStr = callBound('Object.prototype.toString');
7var fnToStr = callBound('Function.prototype.toString');
8var isFnRegex = safeRegexTest(/^\s*async(?:\s+function(?:\s+|\()|\s*\()/);
9
10var hasToStringTag = require('has-tostringtag/shams')();
11var getProto = require('get-proto');
12
13var getAsyncFunc = require('async-function');
14
15/** @type {import('.')} */
16module.exports = function isAsyncFunction(fn) {
17 if (typeof fn !== 'function') {
18 return false;
19 }
20 if (isFnRegex(fnToStr(fn))) {
21 return true;
22 }
23 if (!hasToStringTag) {
24 var str = toStr(fn);
25 return str === '[object AsyncFunction]';
26 }
27 if (!getProto) {
28 return false;
29 }
30 var asyncFunc = getAsyncFunc();
31 return asyncFunc && asyncFunc.prototype === getProto(fn);
32};
Note: See TracBrowser for help on using the repository browser.