main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
804 bytes
|
Rev | Line | |
---|
[d565449] | 1 | var List = require('../common/List');
|
---|
| 2 |
|
---|
| 3 | module.exports = function createConvertors(walk) {
|
---|
| 4 | return {
|
---|
| 5 | fromPlainObject: function(ast) {
|
---|
| 6 | walk(ast, {
|
---|
| 7 | enter: function(node) {
|
---|
| 8 | if (node.children && node.children instanceof List === false) {
|
---|
| 9 | node.children = new List().fromArray(node.children);
|
---|
| 10 | }
|
---|
| 11 | }
|
---|
| 12 | });
|
---|
| 13 |
|
---|
| 14 | return ast;
|
---|
| 15 | },
|
---|
| 16 | toPlainObject: function(ast) {
|
---|
| 17 | walk(ast, {
|
---|
| 18 | leave: function(node) {
|
---|
| 19 | if (node.children && node.children instanceof List) {
|
---|
| 20 | node.children = node.children.toArray();
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 | });
|
---|
| 24 |
|
---|
| 25 | return ast;
|
---|
| 26 | }
|
---|
| 27 | };
|
---|
| 28 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.