Skip to content

Commit 5ade7e4

Browse files
committed
Refactor code-style
* Add more docs to JSDoc
1 parent 109b81d commit 5ade7e4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
/**
22
* @typedef {import('hast').Root} Root
3-
* @typedef {Root['children'][number]|Root} Node
3+
* @typedef {import('hast').Content} Content
4+
*/
5+
6+
/**
7+
* @typedef {Content | Root} Node
48
*/
59

610
import {headingRank} from 'hast-util-heading-rank'
711
import {visit} from 'unist-util-visit'
812

13+
// To do next major: don’t return node.
914
/**
15+
* Change the rank of all headings (`h1` to `h6`) in `tree`.
16+
*
17+
* Mutates the tree.
18+
* Caps the rank so that shifting would not create invalid headings (so no `h0` or
19+
* `h7`).
20+
*
1021
* @template {Node} T
22+
* Node type.
1123
* @param {T} tree
24+
* Tree to change.
1225
* @param {number} shift
26+
* Non-null finite integer to use to shift ranks.
1327
* @returns {T}
28+
* Given, modified, tree.
1429
*/
1530
export function shiftHeading(tree, shift) {
1631
if (

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ There is no default export.
128128
### `shiftHeading(tree, shift)`
129129

130130
Change the rank of all headings (`h1` to `h6`) in `tree`.
131+
131132
Mutates the tree.
132133
Caps the rank so that shifting would not create invalid headings (so no `h0` or
133134
`h7`).

0 commit comments

Comments
 (0)