Skip to content

Commit 401a2de

Browse files
committed
Refactor code-style
* Add more docs to JSDoc
1 parent 8eca708 commit 401a2de

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

lib/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,38 @@
33
*/
44

55
/**
6-
* @template {Node} [Tree=Node]
7-
* @typedef {import('./complex-types.js').MapFunction<Tree>} MapFunction
6+
* @template {Node} [Kind=Node]
7+
* Node type.
8+
* @typedef {import('./complex-types.js').MapFunction<Kind>} MapFunction
89
* Function called with a node, its index, and its parent to produce a new
910
* node.
1011
*/
1112

1213
/**
1314
* Create a new tree by mapping all nodes with the given function.
1415
*
15-
* @template {Node} Tree
16+
* @template {Node} Kind
1617
* Type of input tree.
17-
* @param {Tree} tree
18+
* @param {Kind} tree
1819
* Tree to map.
19-
* @param {MapFunction<Tree>} mapFunction
20+
* @param {MapFunction<Kind>} mapFunction
2021
* Function called with a node, its index, and its parent to produce a new
2122
* node.
22-
* @returns {Tree}
23+
* @returns {Kind}
2324
* New mapped tree.
2425
*/
2526
export function map(tree, mapFunction) {
2627
// @ts-expect-error Looks like a children.
2728
return preorder(tree, null, null)
2829

29-
/** @type {import('./complex-types.js').MapFunction<Tree>} */
30+
/** @type {import('./complex-types.js').MapFunction<Kind>} */
3031
function preorder(node, index, parent) {
31-
var newNode = Object.assign({}, mapFunction(node, index, parent))
32+
const newNode = Object.assign({}, mapFunction(node, index, parent))
3233

3334
if ('children' in node) {
3435
// @ts-expect-error Looks like a parent.
3536
newNode.children = node.children.map(function (
36-
/** @type {import('./complex-types.js').InclusiveDescendant<Tree>} */ child,
37+
/** @type {import('./complex-types.js').InclusiveDescendant<Kind>} */ child,
3738
/** @type {number} */ index
3839
) {
3940
return preorder(child, index, node)

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@
6767
"trailingComma": "none"
6868
},
6969
"xo": {
70-
"prettier": true,
71-
"rules": {
72-
"no-var": "off",
73-
"prefer-arrow-callback": "off"
74-
}
70+
"prettier": true
7571
},
7672
"remarkConfig": {
7773
"plugins": [

0 commit comments

Comments
 (0)