Skip to content

Commit

Permalink
Update @types/hast, utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 7, 2023
1 parent 8876c24 commit 5dd4218
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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<Content> | null | undefined} [ignore=[]]
* @property {Array<RootContent> | null | undefined} [ignore=[]]
* Nodes to exclude from the resulting tree.
* These are not counted towards `size`.
*/
Expand All @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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<Content>} */
/** @type {Array<RootContent>} */
const children = []
let index = -1

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5dd4218

Please sign in to comment.