File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,20 @@ module.exports = size
6
6
7
7
function size ( node , test ) {
8
8
var is = convert ( test )
9
- var children = node && node . children
10
- var length = ( children && children . length ) || 0
11
- var count = 0
12
- var index = - 1
13
- var child
9
+ return fastSize ( node )
14
10
15
- while ( ++ index < length ) {
16
- child = children [ index ]
11
+ function fastSize ( node ) {
12
+ var children = node && node . children
13
+ var count = 0
14
+ var index = - 1
17
15
18
- if ( is ( child , index , node ) ) {
19
- count ++
16
+ if ( children && children . length ) {
17
+ while ( ++ index < children . length ) {
18
+ if ( is ( children [ index ] , index , node ) ) count ++
19
+ count += fastSize ( children [ index ] )
20
+ }
20
21
}
21
22
22
- count += size ( child , test )
23
+ return count
23
24
}
24
-
25
- return count
26
25
}
Original file line number Diff line number Diff line change 67
67
"esnext" : false ,
68
68
"ignores" : [
69
69
" unist-util-size.js"
70
- ]
70
+ ],
71
+ "rules" : {
72
+ "unicorn/explicit-length-check" : " off"
73
+ }
71
74
},
72
75
"remarkConfig" : {
73
76
"plugins" : [
You can’t perform that action at this time.
0 commit comments