|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
-
- "use strict";
-
- const KEYS = require("./visitor-keys.json");
-
-
- const NODE_TYPES = Object.freeze(Object.keys(KEYS));
-
-
- for (const type of NODE_TYPES) {
- Object.freeze(KEYS[type]);
- }
- Object.freeze(KEYS);
-
-
- const KEY_BLACKLIST = new Set([
- "parent",
- "leadingComments",
- "trailingComments"
- ]);
-
-
- function filterKey(key) {
- return !KEY_BLACKLIST.has(key) && key[0] !== "_";
- }
-
-
-
-
-
- module.exports = Object.freeze({
-
-
-
- KEYS,
-
-
-
- getKeys(node) {
- return Object.keys(node).filter(filterKey);
- },
-
-
-
-
-
- unionWith(additionalKeys) {
- const retv = Object.assign({}, KEYS);
-
- for (const type of Object.keys(additionalKeys)) {
- if (retv.hasOwnProperty(type)) {
- const keys = new Set(additionalKeys[type]);
-
- for (const key of retv[type]) {
- keys.add(key);
- }
-
- retv[type] = Object.freeze(Array.from(keys));
- } else {
- retv[type] = Object.freeze(Array.from(additionalKeys[type]));
- }
- }
-
- return Object.freeze(retv);
- }
- });
|