Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 23, 2023
1 parent dc17b1d commit a8e08cc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,36 @@
* @typedef {import('unist').Node} Node
*
* @typedef ProxyFields
* @property {Parent|null} parent
* Extra fields found in a proxied node.
* @property {Parent | null} parent
* Parent link (or `null` for the root).
* @property {Node} node
* Link to the original node
*
* @typedef {Node & ProxyFields} Proxy
* Proxied node
* Proxied node.
*/

/** @type {WeakMap<Node, Proxy>} */
const cache = new WeakMap()

/**
* @param {Node} node
* Add parent references to a proxy of `tree`.
*
* @param {Node} tree
* Create a proxy of `node` that acts like the original tree upon reading, but
* each proxied node has a reference to its parent node.
* @returns {Proxy}
* Proxy of `node`.
*/
export function parents(node) {
return wrapNode(node, null)
export function parents(tree) {
return wrapNode(tree, null)
}

/**
* @param {Node} node
* Node to wrap.
* @param {Parent|null} parent
* @param {Parent | null} parent
* Parent of `node`.
* @returns {Proxy}
* Proxy of `node`.
Expand Down

0 comments on commit a8e08cc

Please sign in to comment.