File tree Expand file tree Collapse file tree 3 files changed +28
-40
lines changed Expand file tree Collapse file tree 3 files changed +28
-40
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33 * @typedef {import('./index.js').State } State
44 */
55
6- import { all } from './all .js'
6+ import { all } from './one .js'
77import { name } from './name.js'
88import { value } from './value.js'
99
Original file line number Diff line number Diff line change 11/**
2+ * @typedef {import('unist').Parent } UnistParent
23 * @typedef {import('xast').Root } Root
34 * @typedef {import('xast').RootChildMap } RootChildMap
45 * @typedef {import('./index.js').State } State
56 */
67
78/**
89 * @typedef {Root | RootChildMap[keyof RootChildMap] } Node
10+ * @typedef {Extract<Node, UnistParent> } Parent
11+ * @typedef {Parent['children'][number] } Child
912 */
1013
11- import { all } from './all.js'
1214import { element } from './element.js'
1315import { text } from './text.js'
1416import { comment } from './comment.js'
@@ -57,3 +59,27 @@ export function one(node, state) {
5759
5860 return result
5961}
62+
63+ /**
64+ * Serialize all children of `parent`.
65+ *
66+ * @param {Parent } parent
67+ * xast parent node.
68+ * @param {State } state
69+ * Info passed around about the current state.
70+ * @returns {string }
71+ * Serialized XML.
72+ */
73+ export function all ( parent , state ) {
74+ /** @type {Array<Child> } */
75+ const children = ( parent && parent . children ) || [ ]
76+ let index = - 1
77+ /** @type {Array<string> } */
78+ const results = [ ]
79+
80+ while ( ++ index < children . length ) {
81+ results [ index ] = one ( children [ index ] , state )
82+ }
83+
84+ return results . join ( '' )
85+ }
You can’t perform that action at this time.
0 commit comments