Socket
Socket
Sign inDemoInstall

@babel/traverse

Package Overview
Dependencies
Maintainers
4
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/traverse - npm Package Compare versions

Comparing version 8.0.0-alpha.1 to 8.0.0-alpha.2

18

lib/cache.js

@@ -1,2 +0,3 @@

export let path = new WeakMap();
let pathsCache = new WeakMap();
export { pathsCache as path };
export let scope = new WeakMap();

@@ -8,3 +9,3 @@ export function clear() {

export function clearPath() {
path = new WeakMap();
pathsCache = new WeakMap();
}

@@ -14,3 +15,16 @@ export function clearScope() {

}
const nullHub = Object.freeze({});
export function getCachedPaths(hub, parent) {
;
return pathsCache.get(hub ?? nullHub)?.get(parent);
}
export function getOrCreateCachedPaths(hub, parent) {
;
let parents = pathsCache.get(hub ?? nullHub);
if (!parents) pathsCache.set(hub ?? nullHub, parents = new WeakMap());
let paths = parents.get(parent);
if (!paths) parents.set(parent, paths = new Map());
return paths;
}
//# sourceMappingURL=cache.js.map

8

lib/path/index.js

@@ -10,3 +10,3 @@ import * as virtualTypes from "./lib/virtual-types.js";

import * as t from "@babel/types";
import { path as pathCache } from "../cache.js";
import * as cache from "../cache.js";
import generator from "@babel/generator";

@@ -63,7 +63,3 @@ import * as NodePath_ancestry from "./ancestry.js";

const targetNode = container[key];
let paths = pathCache.get(parent);
if (!paths) {
paths = new Map();
pathCache.set(parent, paths);
}
const paths = cache.getOrCreateCachedPaths(hub, parent);
let path = paths.get(targetNode);

@@ -70,0 +66,0 @@ if (!path) {

@@ -131,9 +131,4 @@ import * as _t from "@babel/types";

}
export function isExistentialTypeParam() {
throw new Error("`path.isExistentialTypeParam` has been renamed to `path.isExistsTypeAnnotation()` in Babel 7.");
}
export function isNumericLiteralTypeAnnotation() {
throw new Error("`path.isNumericLiteralTypeAnnotation()` has been renamed to `path.isNumberLiteralTypeAnnotation()` in Babel 7.");
}
;
//# sourceMappingURL=virtual-types-validator.js.map

@@ -1,2 +0,2 @@

import { path as pathCache } from "../cache.js";
import { getCachedPaths } from "../cache.js";
import PathHoister from "./lib/hoister.js";

@@ -146,3 +146,3 @@ import NodePath from "./index.js";

if (!this.parent) return;
const paths = pathCache.get(this.parent);
const paths = getCachedPaths(this.hub, this.parent) || [];
for (const [, path] of paths) {

@@ -149,0 +149,0 @@ if (typeof path.key === "number" && path.key >= fromIndex) {

import { hooks } from "./lib/removal-hooks.js";
import { path as pathCache } from "../cache.js";
import { getCachedPaths } from "../cache.js";
import { REMOVED, SHOULD_SKIP } from "./index.js";

@@ -37,3 +37,5 @@ export function remove() {

this._traverseFlags |= SHOULD_SKIP | REMOVED;
if (this.parent) pathCache.get(this.parent).delete(this.node);
if (this.parent) {
getCachedPaths(this.hub, this.parent).delete(this.node);
}
this.node = null;

@@ -40,0 +42,0 @@ }

import { codeFrameColumns } from "@babel/code-frame";
import traverse from "../index.js";
import NodePath from "./index.js";
import { path as pathCache } from "../cache.js";
import { getCachedPaths } from "../cache.js";
import { parse } from "@babel/parser";

@@ -35,3 +35,3 @@ import * as _t from "@babel/types";

inheritTrailingComments(nodes[nodes.length - 1], this.node);
pathCache.get(this.parent)?.delete(this.node);
getCachedPaths(this.hub, this.parent)?.delete(this.node);
this.node = this.container[this.key] = null;

@@ -123,3 +123,3 @@ const paths = this.insertAfter(nodes);

this.debug(`Replace with ${node?.type}`);
pathCache.get(this.parent)?.set(node, this).delete(this.node);
getCachedPaths(this.hub, this.parent)?.set(node, this).delete(this.node);
this.node = this.container[this.key] = node;

@@ -126,0 +126,0 @@ }

@@ -6,8 +6,12 @@ import TraversalContext from "./context.js";

} = _t;
export function traverseNode(node, opts, scope, state, path, skipKeys) {
export function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) {
const keys = VISITOR_KEYS[node.type];
if (!keys) return false;
const context = new TraversalContext(scope, opts, state, path);
if (visitSelf) {
if (skipKeys?.[path.parentKey]) return false;
return context.visitQueue([path]);
}
for (const key of keys) {
if (skipKeys && skipKeys[key]) continue;
if (skipKeys?.[key]) continue;
if (context.visit(node, key)) {

@@ -14,0 +18,0 @@ return true;

{
"name": "@babel/traverse",
"version": "8.0.0-alpha.1",
"version": "8.0.0-alpha.2",
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",

@@ -19,10 +19,10 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/code-frame": "^8.0.0-alpha.1",
"@babel/generator": "^8.0.0-alpha.1",
"@babel/helper-environment-visitor": "^8.0.0-alpha.1",
"@babel/helper-function-name": "^8.0.0-alpha.1",
"@babel/helper-hoist-variables": "^8.0.0-alpha.1",
"@babel/helper-split-export-declaration": "^8.0.0-alpha.1",
"@babel/parser": "^8.0.0-alpha.1",
"@babel/types": "^8.0.0-alpha.1",
"@babel/code-frame": "^8.0.0-alpha.2",
"@babel/generator": "^8.0.0-alpha.2",
"@babel/helper-environment-visitor": "^8.0.0-alpha.2",
"@babel/helper-function-name": "^8.0.0-alpha.2",
"@babel/helper-hoist-variables": "^8.0.0-alpha.2",
"@babel/helper-split-export-declaration": "^8.0.0-alpha.2",
"@babel/parser": "^8.0.0-alpha.2",
"@babel/types": "^8.0.0-alpha.2",
"debug": "^4.1.0",

@@ -32,3 +32,4 @@ "globals": "^13.5.0"

"devDependencies": {
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.1"
"@babel/core": "^8.0.0-alpha.2",
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.2"
},

@@ -35,0 +36,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc