Skip to content

Commit a79ac77

Browse files
committed
Refactor to make code more readable
1 parent 6fc0102 commit a79ac77

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ module.exports = shiftHeading
77
var floor = Math.floor
88
var min = 1
99
var max = 6
10-
var offset = 48 // '0'.charCodeAt(0)
10+
11+
// Character codes.
12+
var digit0 = 48
1113

1214
function shiftHeading(tree, shift) {
1315
if (
@@ -35,7 +37,7 @@ function shiftHeading(tree, shift) {
3537
name === 'h5' ||
3638
name === 'h6'
3739
) {
38-
rank = name.charCodeAt(1) - offset + shift
40+
rank = name.charCodeAt(1) - digit0 + shift
3941
node.tagName = 'h' + (rank > max ? max : rank < min ? min : rank)
4042
}
4143
}

0 commit comments

Comments
 (0)