Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parcel/babylon-walk

Package Overview
Dependencies
Maintainers
1
Versions
396
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/babylon-walk - npm Package Compare versions

Comparing version 2.0.0-nightly.1799 to 2.0.0-nightly.1804

lib/traverse.js

7

lib/explode.js

@@ -38,3 +38,5 @@ "use strict";

function explode(visitor) {
if (visitor._exploded) return visitor;
// $FlowFixMe
if (visitor._exploded) return visitor; // $FlowFixMe
visitor._exploded = true; // normalise pipes

@@ -92,4 +94,5 @@

ensureCallbackArrays(visitor[nodeType]);
}
} // $FlowFixMe
return visitor;

@@ -96,0 +99,0 @@ }

@@ -9,2 +9,8 @@ "use strict";

exports.recursive = recursive;
Object.defineProperty(exports, "traverse", {
enumerable: true,
get: function () {
return _traverse.default;
}
});

@@ -15,2 +21,4 @@ var t = _interopRequireWildcard(require("@babel/types"));

var _traverse = _interopRequireDefault(require("./traverse"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -22,5 +30,5 @@

function simple(node, visitors, state) {
function simple(node, _visitors, state) {
if (!node) return;
visitors = (0, _explode.default)(visitors);
const visitors = (0, _explode.default)(_visitors);

@@ -41,2 +49,3 @@ (function c(node) {

for (let key of t.VISITOR_KEYS[node.type] || []) {
// $FlowFixMe
let subNode = node[key];

@@ -61,5 +70,5 @@

function ancestor(node, visitors, state) {
function ancestor(node, _visitors, state) {
if (!node) return;
visitors = (0, _explode.default)(visitors);
const visitors = (0, _explode.default)(_visitors);
let ancestors = [];

@@ -78,2 +87,3 @@

for (let visitor of enter) {
// $FlowFixMe
visitor(node, state || ancestors, ancestors);

@@ -84,2 +94,3 @@ }

for (let key of t.VISITOR_KEYS[node.type] || []) {
// $FlowFixMe
let subNode = node[key];

@@ -98,2 +109,3 @@

for (let visitor of exit) {
// $FlowFixMe
visitor(node, state || ancestors, ancestors);

@@ -107,5 +119,5 @@ }

function recursive(node, visitors, state) {
function recursive(node, _visitors, state) {
if (!node) return;
visitors = (0, _explode.default)(visitors);
const visitors = (0, _explode.default)(_visitors);

@@ -124,2 +136,3 @@ (function c(node) {

for (let key of t.VISITOR_KEYS[node.type] || []) {
// $FlowFixMe
let subNode = node[key];

@@ -126,0 +139,0 @@

{
"name": "@parcel/babylon-walk",
"version": "2.0.0-nightly.1799+db7e3a12",
"version": "2.0.0-nightly.1804+a1a2515f",
"license": "MIT",

@@ -19,3 +19,3 @@ "publishConfig": {

},
"gitHead": "db7e3a12105630abc44058bff7a88eb612f12e75"
"gitHead": "a1a2515ff8710c0ebc56fb6dc0aad72b6f6dec48"
}

@@ -110,2 +110,10 @@ # babylon-walk

### walk.traverse(node, visitors, state)
Visitors get called as `(path, state)`. Every `Path` has these methods (similar to `@babel/traverse`):
- `skip()`
- `replaceWith(node)`
- `remove()`
[babel-types]: https://github.com/babel/babel/tree/master/packages/babel-types

@@ -112,0 +120,0 @@ [cache your visitors]: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#toc-optimizing-nested-visitors

@@ -0,3 +1,5 @@

// @flow
// Copied from babel-traverse, but with virtual types handling removed
// https://github.com/babel/babel/blob/07b3dc18a09f2217b38a3a63c8613add6df1b47d/packages/babel-traverse/src/visitors.js
import type {Visitors, VisitorsExploded} from './index';

@@ -22,4 +24,6 @@ // import * as messages from 'babel-messages';

*/
export default function explode(visitor) {
export default function explode<T>(visitor: Visitors<T>): VisitorsExploded<T> {
// $FlowFixMe
if (visitor._exploded) return visitor;
// $FlowFixMe
visitor._exploded = true;

@@ -91,6 +95,7 @@

// $FlowFixMe
return visitor;
}
export function verify(visitor) {
export function verify(visitor: any) {
if (visitor._verified) return;

@@ -152,3 +157,3 @@

function ensureEntranceObjects(obj) {
function ensureEntranceObjects(obj: any) {
for (let key in obj) {

@@ -164,3 +169,3 @@ if (shouldIgnoreKey(key)) continue;

function ensureCallbackArrays(obj) {
function ensureCallbackArrays(obj: any) {
if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];

@@ -184,3 +189,3 @@ if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];

function mergePair(dest, src) {
function mergePair(dest: any, src: any) {
for (let key in src) {

@@ -187,0 +192,0 @@ dest[key] = [].concat(dest[key] || [], src[key]);

@@ -0,8 +1,30 @@

// @flow
import type {Node} from '@babel/types';
import * as t from '@babel/types';
import explode from './explode.js';
import traverse from './traverse';
export function simple(node, visitors, state) {
export type Visitors<F> = {
[string]: F | {|enter?: F, exit?: F|},
shouldSkip?: Node => boolean,
...
};
export type VisitorsExploded<F> = {
[string]: {|
enter?: Array<F>,
exit?: Array<F>,
|},
shouldSkip?: Node => boolean,
...
};
export function simple<T>(
node: Node,
_visitors: Visitors<(any, T) => void>,
state: T,
) {
if (!node) return;
visitors = explode(visitors);
const visitors: VisitorsExploded<(any, T) => void> = explode(_visitors);

@@ -21,2 +43,3 @@ (function c(node) {

for (let key of t.VISITOR_KEYS[node.type] || []) {
// $FlowFixMe
let subNode = node[key];

@@ -40,6 +63,10 @@ if (Array.isArray(subNode)) {

export function ancestor(node, visitors, state) {
export function ancestor<T>(
node: Node,
_visitors: Visitors<(any, T, Array<Node>) => void>,
state: T,
) {
if (!node) return;
visitors = explode(visitors);
const visitors = explode<(any, T, Array<Node>) => void>(_visitors);
let ancestors = [];

@@ -57,2 +84,3 @@

for (let visitor of enter) {
// $FlowFixMe
visitor(node, state || ancestors, ancestors);

@@ -63,2 +91,3 @@ }

for (let key of t.VISITOR_KEYS[node.type] || []) {
// $FlowFixMe
let subNode = node[key];

@@ -76,2 +105,3 @@ if (Array.isArray(subNode)) {

for (let visitor of exit) {
// $FlowFixMe
visitor(node, state || ancestors, ancestors);

@@ -85,6 +115,12 @@ }

export function recursive(node, visitors, state) {
export function recursive<T>(
node: Node,
_visitors: Visitors<(any, T, recurse: (Node) => void) => void>,
state: T,
) {
if (!node) return;
visitors = explode(visitors);
const visitors = explode<(any, T, recurse: (Node) => void) => void>(
_visitors,
);

@@ -102,2 +138,3 @@ (function c(node) {

for (let key of t.VISITOR_KEYS[node.type] || []) {
// $FlowFixMe
let subNode = node[key];

@@ -115,1 +152,3 @@ if (Array.isArray(subNode)) {

}
export {traverse};
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