51 lines
761 B
JavaScript
51 lines
761 B
JavaScript
import { parse } from './core.js'
|
|
|
|
const schemaTCE = `
|
|
types
|
|
primitive object, tail as type
|
|
any primitive
|
|
|
|
root object
|
|
types object, optional
|
|
any primitive
|
|
|
|
root object
|
|
any primitive
|
|
`
|
|
|
|
const schema = {
|
|
types: {
|
|
primitive: {
|
|
type: 'object',
|
|
tail: 'type',
|
|
values: {
|
|
type: 'string',
|
|
any: 'primitive'
|
|
}
|
|
},
|
|
},
|
|
root: {
|
|
type: 'object',
|
|
values: {
|
|
types: {
|
|
type: 'object',
|
|
optional: true,
|
|
values: {
|
|
any: 'primitive'
|
|
}
|
|
},
|
|
root: {
|
|
type: 'object',
|
|
values: {
|
|
any: 'primitive'
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
console.dir(await parse(schemaTCE.split('\n'), schema), { depth: null })
|
|
}
|
|
|
|
main() |