test/dummy/node_modules/@babel/traverse/lib/visitors.js in disco_app-0.18.1 vs test/dummy/node_modules/@babel/traverse/lib/visitors.js in disco_app-0.18.2

- old
+ new

@@ -5,20 +5,22 @@ }); exports.explode = explode; exports.verify = verify; exports.merge = merge; -var virtualTypes = require("./path/lib/virtual-types"); +var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types")); -var _t = require("@babel/types"); +var t = _interopRequireWildcard(require("@babel/types")); -const { - DEPRECATED_KEYS, - FLIPPED_ALIAS_KEYS, - TYPES -} = _t; +var _clone = _interopRequireDefault(require("lodash/clone")); +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)) { @@ -64,16 +66,16 @@ } for (const nodeType of Object.keys(visitor)) { if (shouldIgnoreKey(nodeType)) continue; const fns = visitor[nodeType]; - let aliases = FLIPPED_ALIAS_KEYS[nodeType]; - const deprecatedKey = DEPRECATED_KEYS[nodeType]; + let aliases = t.FLIPPED_ALIAS_KEYS[nodeType]; + const deprecratedKey = t.DEPRECATED_KEYS[nodeType]; - if (deprecatedKey) { - console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`); - aliases = [deprecatedKey]; + if (deprecratedKey) { + console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`); + aliases = [deprecratedKey]; } if (!aliases) continue; delete visitor[nodeType]; @@ -81,11 +83,11 @@ const existing = visitor[alias]; if (existing) { mergePair(existing, fns); } else { - visitor[alias] = Object.assign({}, fns); + visitor[alias] = (0, _clone.default)(fns); } } } for (const nodeType of Object.keys(visitor)) { @@ -108,11 +110,11 @@ validateVisitorMethods(nodeType, visitor[nodeType]); } if (shouldIgnoreKey(nodeType)) continue; - if (TYPES.indexOf(nodeType) < 0) { + if (t.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]; @@ -180,14 +182,10 @@ if (wrapper) { newFn = wrapper(state.key, key, newFn); } - if (newFn !== fn) { - newFn.toString = () => fn.toString(); - } - return newFn; }); newVisitor[key] = fns; } @@ -226,10 +224,10 @@ function shouldIgnoreKey(key) { if (key[0] === "_") return true; if (key === "enter" || key === "exit" || key === "shouldSkip") return true; - if (key === "denylist" || key === "noScope" || key === "skipKeys" || key === "blacklist") { + if (key === "blacklist" || key === "noScope" || key === "skipKeys") { return true; } return false; } \ No newline at end of file