3
3
// passed tree.
4
4
5
5
/**
6
- * @typedef {import('hast').Root } Root
7
- * @typedef {import('hast').Content } Content
6
+ * @typedef {import('hast').RootContent } RootContent
7
+ * @typedef {import('hast').Nodes } Nodes
8
8
* @typedef {import('hast').Text } Text
9
9
*/
10
10
11
11
/**
12
- * @typedef {Root | Content } Node
13
- *
14
12
* @typedef Options
15
13
* Configuration.
16
14
* @property {number | null | undefined } [size=140]
32
30
* If `maxCharacterStrip` characters are walked back and no nice break point
33
31
* is found, the bad break point is used.
34
32
* Set `maxCharacterStrip: 0` to not find a nice break.
35
- * @property {Array<Content > | null | undefined } [ignore=[]]
33
+ * @property {Array<RootContent > | null | undefined } [ignore=[]]
36
34
* Nodes to exclude from the resulting tree.
37
35
* These are not counted towards `size`.
38
36
*/
@@ -45,7 +43,7 @@ const empty = []
45
43
/**
46
44
* Truncate the tree to a certain number of characters.
47
45
*
48
- * @template {Node } Tree
46
+ * @template {Nodes } Tree
49
47
* Type of tree.
50
48
* @param {Tree } tree
51
49
* Tree to truncate.
@@ -111,9 +109,9 @@ export function truncate(tree, options) {
111
109
/**
112
110
* Transform in `preorder`.
113
111
*
114
- * @param {Node } node
112
+ * @param {Nodes } node
115
113
* Node to truncate.
116
- * @returns {Node }
114
+ * @returns {Nodes }
117
115
* Shallow copy of `node`.
118
116
*/
119
117
function preorder ( node ) {
@@ -126,11 +124,11 @@ export function truncate(tree, options) {
126
124
searchSize += node . value . length
127
125
}
128
126
129
- /** @type {Node } */
127
+ /** @type {Nodes } */
130
128
const replacement = { ...node }
131
129
132
130
if ( 'children' in node ) {
133
- /** @type {Array<Content > } */
131
+ /** @type {Array<RootContent > } */
134
132
const children = [ ]
135
133
let index = - 1
136
134
0 commit comments