|
16 | 16 | * |
17 | 17 | * @typedef Result |
18 | 18 | * Results. |
19 | | - * @property {number | null} index |
| 19 | + * @property {number | undefined} index |
20 | 20 | * Index of the node right after the table of contents heading, `-1` if no |
21 | | - * heading was found, `null` if no `heading` was given. |
22 | | - * @property {number | null} endIndex |
| 21 | + * heading was found, `undefined` if no `heading` was given. |
| 22 | + * @property {number | undefined} endIndex |
23 | 23 | * Index of the first node after `heading` that is not part of its section, |
24 | | - * `-1` if no heading was found, `null` if no `heading` was given, same as |
25 | | - * `index` if there are no nodes between `heading` and the first heading in |
26 | | - * the table of contents. |
27 | | - * @property {List | null} map |
28 | | - * List representing the generated table of contents, `null` if no table of |
29 | | - * contents could be created, either because no heading was found or because |
30 | | - * no following headings were found. |
| 24 | + * `-1` if no heading was found, `undefined` if no `heading` was given, same |
| 25 | + * as `index` if there are no nodes between `heading` and the first heading |
| 26 | + * in the table of contents. |
| 27 | + * @property {List | undefined} map |
| 28 | + * List representing the generated table of contents, `undefined` if no table |
| 29 | + * of contents could be created, either because no heading was found or |
| 30 | + * because no following headings were found. |
31 | 31 | */ |
32 | 32 |
|
33 | 33 | import {search} from './search.js' |
@@ -60,8 +60,8 @@ export function toc(tree, options) { |
60 | 60 | const result = search(tree, heading, settings) |
61 | 61 |
|
62 | 62 | return { |
63 | | - index: heading ? result.index : null, |
64 | | - endIndex: heading ? result.endIndex : null, |
65 | | - map: result.map.length > 0 ? contents(result.map, settings) : null |
| 63 | + index: heading ? result.index : undefined, |
| 64 | + endIndex: heading ? result.endIndex : undefined, |
| 65 | + map: result.map.length > 0 ? contents(result.map, settings) : undefined |
66 | 66 | } |
67 | 67 | } |
0 commit comments