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 11'use strict' ;
22
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+
610var hasToStringTag = require ( 'has-tostringtag/shams' ) ( ) ;
711var getProto = require ( 'get-proto' ) ;
12+
813var getAsyncFunc = function ( ) { // eslint-disable-line consistent-return
914 if ( ! hasToStringTag ) {
1015 return false ;
@@ -20,11 +25,11 @@ module.exports = function isAsyncFunction(fn) {
2025 if ( typeof fn !== 'function' ) {
2126 return false ;
2227 }
23- if ( isFnRegex . test ( fnToStr . call ( fn ) ) ) {
28+ if ( isFnRegex ( fnToStr ( fn ) ) ) {
2429 return true ;
2530 }
2631 if ( ! hasToStringTag ) {
27- var str = toStr . call ( fn ) ;
32+ var str = toStr ( fn ) ;
2833 return str === '[object AsyncFunction]' ;
2934 }
3035 if ( ! getProto ) {
Original file line number Diff line number Diff line change 4040 "url" : " https://github.com/inspect-js/is-async-function/issues"
4141 },
4242 "dependencies" : {
43+ "call-bound" : " ^1.0.3" ,
4344 "get-proto" : " ^1.0.1" ,
44- "has-tostringtag" : " ^1.0.2"
45+ "has-tostringtag" : " ^1.0.2" ,
46+ "safe-regex-test" : " ^1.1.0"
4547 },
4648 "devDependencies" : {
4749 "@ljharb/eslint-config" : " ^21.1.1" ,
You can’t perform that action at this time.
0 commit comments