|
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 |
|
|---|
| 3 | var callBound = require('call-bound');
|
|---|
| 4 | var safeRegexTest = require('safe-regex-test');
|
|---|
| 5 |
|
|---|
| 6 | var toStr = callBound('Object.prototype.toString');
|
|---|
| 7 | var fnToStr = callBound('Function.prototype.toString');
|
|---|
| 8 | var isFnRegex = safeRegexTest(/^\s*async(?:\s+function(?:\s+|\()|\s*\()/);
|
|---|
| 9 |
|
|---|
| 10 | var hasToStringTag = require('has-tostringtag/shams')();
|
|---|
| 11 | var getProto = require('get-proto');
|
|---|
| 12 |
|
|---|
| 13 | var getAsyncFunc = require('async-function');
|
|---|
| 14 |
|
|---|
| 15 | /** @type {import('.')} */
|
|---|
| 16 | module.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.