This commit is contained in:
2026-03-24 23:31:13 +01:00
parent 8e5a4b08bb
commit 9b8dd103f9
1605 changed files with 885298 additions and 43 deletions

View File

@@ -0,0 +1,32 @@
'use strict';
const List = require('../utils/List.cjs');
function createConvertor(walk) {
return {
fromPlainObject(ast) {
walk(ast, {
enter(node) {
if (node.children && node.children instanceof List.List === false) {
node.children = new List.List().fromArray(node.children);
}
}
});
return ast;
},
toPlainObject(ast) {
walk(ast, {
leave(node) {
if (node.children && node.children instanceof List.List) {
node.children = node.children.toArray();
}
}
});
return ast;
}
};
}
exports.createConvertor = createConvertor;

View File

@@ -0,0 +1,8 @@
'use strict';
const create = require('./create.cjs');
const index$1 = require('../walker/index.cjs');
const index = create.createConvertor(index$1);
module.exports = index;