Skip to content

Commit

Permalink
type: more type export.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 30, 2021
1 parent 896d9ab commit d030781
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Expand Up @@ -3,6 +3,9 @@ import {Plugin} from 'unified'
import visit from './visit'
import { propertiesHandle, nextChild, prevChild, getCommentObject } from './utils'

export * from './visit'
export * from './utils'

export type MdastTransformer = (tree: Root) => void

export type RehypeAttrsOptions = {
Expand Down
6 changes: 3 additions & 3 deletions src/visit.ts
@@ -1,8 +1,8 @@
import { Root, Parent, Content } from 'ts-mdast'

type Callback = (node: Root | Content | Parent, index: number, parent: Parent | Content) => void
export type VisitCallback = (node: Root | Content | Parent, index: number, parent: Parent | Content) => void

export default function visit(tree: Root, element: string, callback: Callback) {
export default function visit(tree: Root, element: string, callback: VisitCallback) {
if (!element || !tree || !callback || typeof callback !== 'function') {
return
}
Expand All @@ -11,7 +11,7 @@ export default function visit(tree: Root, element: string, callback: Callback) {
}
}

function handle(tree: Content[], element: string, parent: Parent | Content, callback: Callback) {
function handle(tree: Content[], element: string, parent: Parent | Content, callback: VisitCallback) {
tree.forEach((item, index) => {
if (item.type === element) {
callback(item, index, parent)
Expand Down

0 comments on commit d030781

Please sign in to comment.