Add initial support for toArray and array-based object values.
This commit is contained in:
@@ -33,18 +33,22 @@ const lines = [
|
||||
` vite ^3.2.3`,
|
||||
` vitest ^0.24.5`,
|
||||
``,
|
||||
`author`,
|
||||
` name Joshua Bemenderfer`,
|
||||
` email josh@thederf.com`,
|
||||
` `,
|
||||
` Further comments below. As I will now demonstrate, there is no simple`,
|
||||
` even if embedded`,
|
||||
` way of dealing with this problem.`,
|
||||
`author`,
|
||||
` name Second Person`,
|
||||
` email second@secondperson.com`,
|
||||
` More text,`,
|
||||
` across two lines.`,
|
||||
`authors`,
|
||||
` author`,
|
||||
` name Joshua Bemenderfer`,
|
||||
` email josh@thederf.com`,
|
||||
` `,
|
||||
` Further comments below. As I will now demonstrate, there is no simple`,
|
||||
` even if embedded`,
|
||||
` way of dealing with this problem.`,
|
||||
` author`,
|
||||
` name Second Person`,
|
||||
` email second@secondperson.com`,
|
||||
` More text,`,
|
||||
` across two lines.`,
|
||||
`list`,
|
||||
` - item1`,
|
||||
` - item2`
|
||||
]
|
||||
|
||||
// Schema
|
||||
@@ -69,7 +73,7 @@ async function main() {
|
||||
const { toLineArray } = useDocument(createStringReader(lines))
|
||||
console.dir(await toLineArray(), { depth: null })
|
||||
|
||||
const { head, tail, each, match, toObject } = useDocument(createStringReader(lines))
|
||||
const { head, tail, each, match, toArray, toObject } = useDocument(createStringReader(lines))
|
||||
|
||||
const structure = await toObject({
|
||||
'name': true,
|
||||
@@ -80,10 +84,9 @@ async function main() {
|
||||
}),
|
||||
'scripts': () => toObject({ '#any': true }),
|
||||
'devDependencies': () => toObject(),
|
||||
'author': {
|
||||
type: 'collection',
|
||||
handle: () => toObject({ name: true, email: true, '#text': true })
|
||||
}
|
||||
'authors': () => toArray({
|
||||
'author': () => toObject({ name: true, email: true, '#text': true })
|
||||
}),
|
||||
})
|
||||
|
||||
console.dir(structure, { depth: null })
|
||||
|
||||
Reference in New Issue
Block a user