diff --git a/lib/index.js b/lib/index.js index 22cc530..950404b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,14 +3,12 @@ // passed tree. /** - * @typedef {import('hast').Root} Root - * @typedef {import('hast').Content} Content + * @typedef {import('hast').RootContent} RootContent + * @typedef {import('hast').Nodes} Nodes * @typedef {import('hast').Text} Text */ /** - * @typedef {Root | Content} Node - * * @typedef Options * Configuration. * @property {number | null | undefined} [size=140] @@ -32,7 +30,7 @@ * If `maxCharacterStrip` characters are walked back and no nice break point * is found, the bad break point is used. * Set `maxCharacterStrip: 0` to not find a nice break. - * @property {Array | null | undefined} [ignore=[]] + * @property {Array | null | undefined} [ignore=[]] * Nodes to exclude from the resulting tree. * These are not counted towards `size`. */ @@ -45,7 +43,7 @@ const empty = [] /** * Truncate the tree to a certain number of characters. * - * @template {Node} Tree + * @template {Nodes} Tree * Type of tree. * @param {Tree} tree * Tree to truncate. @@ -111,9 +109,9 @@ export function truncate(tree, options) { /** * Transform in `preorder`. * - * @param {Node} node + * @param {Nodes} node * Node to truncate. - * @returns {Node} + * @returns {Nodes} * Shallow copy of `node`. */ function preorder(node) { @@ -126,11 +124,11 @@ export function truncate(tree, options) { searchSize += node.value.length } - /** @type {Node} */ + /** @type {Nodes} */ const replacement = {...node} if ('children' in node) { - /** @type {Array} */ + /** @type {Array} */ const children = [] let index = -1 diff --git a/package.json b/package.json index 3c6bc1a..009e65f 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ "index.js" ], "dependencies": { - "@types/hast": "^2.0.0", - "micromark-util-character": "^1.0.0" + "@types/hast": "^3.0.0", + "micromark-util-character": "^2.0.0" }, "devDependencies": { "@types/node": "^20.0.0", "c8": "^8.0.0", - "hast-util-select": "^5.0.0", - "hastscript": "^7.0.0", + "hast-util-select": "^6.0.0", + "hastscript": "^8.0.0", "prettier": "^3.0.0", "remark-cli": "^11.0.0", "remark-preset-wooorm": "^9.0.0",