test/dummy/node_modules/@babel/traverse/lib/visitors.js in disco_app-0.18.0 vs test/dummy/node_modules/@babel/traverse/lib/visitors.js in disco_app-0.18.1
- old
+ new
@@ -5,22 +5,20 @@
});
exports.explode = explode;
exports.verify = verify;
exports.merge = merge;
-var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types"));
+var virtualTypes = require("./path/lib/virtual-types");
-var t = _interopRequireWildcard(require("@babel/types"));
+var _t = require("@babel/types");
-var _clone = _interopRequireDefault(require("lodash/clone"));
+const {
+ DEPRECATED_KEYS,
+ FLIPPED_ALIAS_KEYS,
+ TYPES
+} = _t;
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
-
function explode(visitor) {
if (visitor._exploded) return visitor;
visitor._exploded = true;
for (const nodeType of Object.keys(visitor)) {
@@ -66,16 +64,16 @@
}
for (const nodeType of Object.keys(visitor)) {
if (shouldIgnoreKey(nodeType)) continue;
const fns = visitor[nodeType];
- let aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
- const deprecratedKey = t.DEPRECATED_KEYS[nodeType];
+ let aliases = FLIPPED_ALIAS_KEYS[nodeType];
+ const deprecatedKey = DEPRECATED_KEYS[nodeType];
- if (deprecratedKey) {
- console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`);
- aliases = [deprecratedKey];
+ if (deprecatedKey) {
+ console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`);
+ aliases = [deprecatedKey];
}
if (!aliases) continue;
delete visitor[nodeType];
@@ -83,11 +81,11 @@
const existing = visitor[alias];
if (existing) {
mergePair(existing, fns);
} else {
- visitor[alias] = (0, _clone.default)(fns);
+ visitor[alias] = Object.assign({}, fns);
}
}
}
for (const nodeType of Object.keys(visitor)) {
@@ -110,11 +108,11 @@
validateVisitorMethods(nodeType, visitor[nodeType]);
}
if (shouldIgnoreKey(nodeType)) continue;
- if (t.TYPES.indexOf(nodeType) < 0) {
+ if (TYPES.indexOf(nodeType) < 0) {
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
}
const visitors = visitor[nodeType];
@@ -182,10 +180,14 @@
if (wrapper) {
newFn = wrapper(state.key, key, newFn);
}
+ if (newFn !== fn) {
+ newFn.toString = () => fn.toString();
+ }
+
return newFn;
});
newVisitor[key] = fns;
}
@@ -224,10 +226,10 @@
function shouldIgnoreKey(key) {
if (key[0] === "_") return true;
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
- if (key === "blacklist" || key === "noScope" || key === "skipKeys") {
+ if (key === "denylist" || key === "noScope" || key === "skipKeys" || key === "blacklist") {
return true;
}
return false;
}
\ No newline at end of file