Skip to content

Commit aa1a4b1

Browse files
committed
Refactor to improve bundle size
1 parent 8fb4cd5 commit aa1a4b1

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@ var visit = require('unist-util-visit')
44

55
module.exports = shiftHeading
66

7-
var floor = Math.floor
8-
var min = 1
9-
var max = 6
10-
11-
// Character codes.
12-
var digit0 = 48
13-
147
function shiftHeading(tree, shift) {
158
if (
169
typeof shift !== 'number' ||
1710
!shift ||
1811
!isFinite(shift) ||
19-
floor(shift) !== shift
12+
Math.floor(shift) !== shift
2013
) {
2114
throw new Error('Expected a non-null finite integer, not `' + shift + '`')
2215
}
@@ -37,8 +30,8 @@ function shiftHeading(tree, shift) {
3730
name === 'h5' ||
3831
name === 'h6'
3932
) {
40-
rank = name.charCodeAt(1) - digit0 + shift
41-
node.tagName = 'h' + (rank > max ? max : rank < min ? min : rank)
33+
rank = name.charCodeAt(1) - 48 /* `0` */ + shift
34+
node.tagName = 'h' + (rank > 6 ? 6 : rank < 1 ? 1 : rank)
4235
}
4336
}
4437
}

0 commit comments

Comments
 (0)