Skip to content

Commit d47e132

Browse files
committed
Refactor code-style
1 parent 1fa7d6b commit d47e132

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lib/index.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
2-
* @typedef {import('hast').Parent} HastParent
32
* @typedef {import('hast').Root} HastRoot
43
* @typedef {import('hast').DocType} HastDoctype
54
* @typedef {import('hast').Element} HastElement
65
* @typedef {import('hast').Text} HastText
76
* @typedef {import('hast').Comment} HastComment
8-
* @typedef {HastParent['children'][number]} HastChild
7+
* @typedef {import('hast').Content} HastChild
98
* @typedef {HastChild|HastRoot} HastNode
109
*
1110
* @callback AfterTransform
@@ -17,6 +16,7 @@
1716
* @returns {void}
1817
*
1918
* @typedef Options
19+
* Configuration (optional).
2020
* @property {boolean} [fragment=false]
2121
* Whether a DOM fragment should be returned
2222
* @property {Document} [document]
@@ -34,10 +34,22 @@
3434
* @property {AfterTransform} [afterTransform]
3535
*/
3636

37+
/* eslint-env browser */
38+
3739
import {webNamespaces} from 'web-namespaces'
3840
import {find, html, svg} from 'property-information'
3941

40-
/* eslint-env browser */
42+
/**
43+
* Transform a hast tree to a DOM tree
44+
*
45+
* @param {HastNode} node
46+
* @param {Options} [options]
47+
* @returns {Node}
48+
*/
49+
export function toDom(node, options = {}) {
50+
const {document: doc = document, ...rest} = options
51+
return transform(node, {doc, ...rest})
52+
}
4153

4254
/**
4355
* @param {HastNode} node
@@ -243,7 +255,7 @@ function element(node, ctx) {
243255
*
244256
* @template {Node} N
245257
* @param {N} node
246-
* @param {Array.<HastChild>} children
258+
* @param {Array<HastChild>} children
247259
* @param {Context} ctx
248260
* @returns {N}
249261
*/
@@ -257,15 +269,3 @@ function appendAll(node, children, ctx) {
257269

258270
return node
259271
}
260-
261-
/**
262-
* Transform a hast tree to a DOM tree
263-
*
264-
* @param {HastNode} node
265-
* @param {Options} [options]
266-
* @returns {Node}
267-
*/
268-
export function toDom(node, options = {}) {
269-
const {document: doc = document, ...rest} = options
270-
return transform(node, {doc, ...rest})
271-
}

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Document interface to use (default: `globalThis.document`).
9090

9191
###### `options.afterTransform`
9292

93-
Function called when a hast node is transformed into a DOM node (`Function?`).
93+
Function called after a hast node is transformed into a DOM node (`Function?`).
9494
Given the hast node that was handled as the first parameter and the
9595
corresponding DOM node as the second parameter.
9696

0 commit comments

Comments
 (0)