File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var toStr = Object . prototype . toString ;
4
- var fnToStr = Function . prototype . toString ;
5
- var isFnRegex = / ^ \s * a s y n c (?: \s + f u n c t i o n (?: \s + | \( ) | \s * \( ) / ;
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 * a s y n c (?: \s + f u n c t i o n (?: \s + | \( ) | \s * \( ) / ) ;
9
+
6
10
var hasToStringTag = require ( 'has-tostringtag/shams' ) ( ) ;
7
11
var getProto = require ( 'get-proto' ) ;
12
+
8
13
var getAsyncFunc = function ( ) { // eslint-disable-line consistent-return
9
14
if ( ! hasToStringTag ) {
10
15
return false ;
@@ -20,11 +25,11 @@ module.exports = function isAsyncFunction(fn) {
20
25
if ( typeof fn !== 'function' ) {
21
26
return false ;
22
27
}
23
- if ( isFnRegex . test ( fnToStr . call ( fn ) ) ) {
28
+ if ( isFnRegex ( fnToStr ( fn ) ) ) {
24
29
return true ;
25
30
}
26
31
if ( ! hasToStringTag ) {
27
- var str = toStr . call ( fn ) ;
32
+ var str = toStr ( fn ) ;
28
33
return str === '[object AsyncFunction]' ;
29
34
}
30
35
if ( ! getProto ) {
Original file line number Diff line number Diff line change 40
40
"url" : " https://github.com/inspect-js/is-async-function/issues"
41
41
},
42
42
"dependencies" : {
43
+ "call-bound" : " ^1.0.3" ,
43
44
"get-proto" : " ^1.0.1" ,
44
- "has-tostringtag" : " ^1.0.2"
45
+ "has-tostringtag" : " ^1.0.2" ,
46
+ "safe-regex-test" : " ^1.1.0"
45
47
},
46
48
"devDependencies" : {
47
49
"@ljharb/eslint-config" : " ^21.1.1" ,
You can’t perform that action at this time.
0 commit comments