Skip to content

Commit

Permalink
chore: add internal typings
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Jun 12, 2024
1 parent e433632 commit 3845e07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/traverse.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/**
* @typedef { import('./types.js').EnterFn } EnterFn
* @typedef { import('./types.js').LeaveFn } LeaveFn
*/

/**
* Traverse a moddle tree, depth first from top to bottom
* and call the passed visitor fn.
*
* @param {ModdleElement} element
* @param {{ enter?: Function; leave?: Function }} options
* @param {{ enter?: EnterFn; leave?: LeaveFn }} options
*/
module.exports = function traverse(element, options) {

Expand Down
5 changes: 5 additions & 0 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type ModdleElement = any;

export type EnterFn = (element: ModdleElement) => boolean | null;

export type LeaveFn = (element: ModdleElement) => void;

0 comments on commit 3845e07

Please sign in to comment.