File tree Expand file tree Collapse file tree 8 files changed +9
-85
lines changed
babel-helper-function-name
babel-helper-get-function-arity Expand file tree Collapse file tree 8 files changed +9
-85
lines changed Original file line number Diff line number Diff line change 14
14
},
15
15
"main" : " ./lib/index.js" ,
16
16
"dependencies" : {
17
- "@babel/helper-get-function-arity" : " workspace:^" ,
18
17
"@babel/template" : " workspace:^" ,
19
18
"@babel/types" : " workspace:^"
20
19
},
Original file line number Diff line number Diff line change 1
- import getFunctionArity from "@babel/helper-get-function-arity" ;
2
1
import template from "@babel/template" ;
3
2
import {
4
3
NOT_LOCAL_BINDING ,
5
4
cloneNode ,
6
5
identifier ,
7
6
isAssignmentExpression ,
7
+ isAssignmentPattern ,
8
8
isFunction ,
9
9
isIdentifier ,
10
10
isLiteral ,
11
11
isNullLiteral ,
12
12
isObjectMethod ,
13
13
isObjectProperty ,
14
14
isRegExpLiteral ,
15
+ isRestElement ,
15
16
isTemplateLiteral ,
16
17
isVariableDeclarator ,
17
18
toBindingIdentifierName ,
18
19
} from "@babel/types" ;
19
20
import type * as t from "@babel/types" ;
20
21
22
+ function getFunctionArity ( node : t . Function ) : number {
23
+ const count = node . params . findIndex (
24
+ param => isAssignmentPattern ( param ) || isRestElement ( param ) ,
25
+ ) ;
26
+ return count === - 1 ? node . params . length : count ;
27
+ }
28
+
21
29
const buildPropertyMethodAssignmentWrapper = template ( `
22
30
(function (FUNCTION_KEY) {
23
31
function FUNCTION_ID() {
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 16
16
" ./packages/babel-helper-explode-assignable-expression/src/**/*.ts" ,
17
17
" ./packages/babel-helper-fixtures/src/**/*.ts" ,
18
18
" ./packages/babel-helper-function-name/src/**/*.ts" ,
19
- " ./packages/babel-helper-get-function-arity/src/**/*.ts" ,
20
19
" ./packages/babel-helper-hoist-variables/src/**/*.ts" ,
21
20
" ./packages/babel-helper-member-expression-to-functions/src/**/*.ts" ,
22
21
" ./packages/babel-helper-module-imports/src/**/*.ts" ,
190
189
"@babel/helper-function-name" : [
191
190
" ./packages/babel-helper-function-name/src"
192
191
],
193
- "@babel/helper-get-function-arity" : [
194
- " ./packages/babel-helper-get-function-arity/src"
195
- ],
196
192
"@babel/helper-hoist-variables" : [
197
193
" ./packages/babel-helper-hoist-variables/src"
198
194
],
Original file line number Diff line number Diff line change @@ -691,7 +691,6 @@ __metadata:
691
691
version: 0.0.0-use.local
692
692
resolution: "@babel/helper-function-name@workspace:packages/babel-helper-function-name"
693
693
dependencies:
694
- "@babel/helper-get-function-arity": "workspace:^"
695
694
"@babel/template": "workspace:^"
696
695
"@babel/types": "workspace:^"
697
696
languageName: unknown
@@ -706,14 +705,6 @@ __metadata:
706
705
languageName: node
707
706
linkType: hard
708
707
709
- "@babel/helper-get-function-arity@workspace:^, @babel/helper-get-function-arity@workspace:packages/babel-helper-get-function-arity":
710
- version: 0.0.0-use.local
711
- resolution: "@babel/helper-get-function-arity@workspace:packages/babel-helper-get-function-arity"
712
- dependencies:
713
- "@babel/types": "workspace:^"
714
- languageName: unknown
715
- linkType: soft
716
-
717
708
"@babel/helper-hoist-variables@npm:^7.15.4, @babel/helper-hoist-variables@npm:^7.16.7":
718
709
version: 7.16.7
719
710
resolution: "@babel/helper-hoist-variables@npm:7.16.7"
You can’t perform that action at this time.
0 commit comments