|
Last change
on this file since ae6cd79 was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
672 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | exports.__esModule = true;
|
|---|
| 4 |
|
|---|
| 5 | /** @type {import('./visit').default} */
|
|---|
| 6 | exports.default = function visit(node, keys, visitorSpec) {
|
|---|
| 7 | if (!node || !keys) {
|
|---|
| 8 | return;
|
|---|
| 9 | }
|
|---|
| 10 | const type = node.type;
|
|---|
| 11 | const visitor = visitorSpec[type];
|
|---|
| 12 | if (typeof visitor === 'function') {
|
|---|
| 13 | visitor(node);
|
|---|
| 14 | }
|
|---|
| 15 | const childFields = keys[type];
|
|---|
| 16 | if (!childFields) {
|
|---|
| 17 | return;
|
|---|
| 18 | }
|
|---|
| 19 | childFields.forEach((fieldName) => {
|
|---|
| 20 | // @ts-expect-error TS sucks with concat
|
|---|
| 21 | [].concat(node[fieldName]).forEach((item) => {
|
|---|
| 22 | visit(item, keys, visitorSpec);
|
|---|
| 23 | });
|
|---|
| 24 | });
|
|---|
| 25 |
|
|---|
| 26 | const exit = visitorSpec[`${type}:Exit`];
|
|---|
| 27 | if (typeof exit === 'function') {
|
|---|
| 28 | exit(node);
|
|---|
| 29 | }
|
|---|
| 30 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.