flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

11
VISUALIZACION/node_modules/babylon-walk/HISTORY.md generated vendored Executable file
View file

@ -0,0 +1,11 @@
# 1.0.2 / 2016-09-11
- Fix packaging issue
# 1.0.1 / 2016-09-11
- Fix packaging issue
# 1.0.0 / 2016-09-11
- Initial release

7
VISUALIZACION/node_modules/babylon-walk/LICENSE.md generated vendored Executable file
View file

@ -0,0 +1,7 @@
Copyright (c) 2016 Tiancheng "Timothy" Gu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

126
VISUALIZACION/node_modules/babylon-walk/README.md generated vendored Executable file
View file

@ -0,0 +1,126 @@
# babylon-walk
Lightweight AST traversal tools for [Babylon] ASTs.
Babylon is the parser used by the [Babel] project, which supplies the wonderful [babel-traverse] module for walking Babylon ASTs. Problem is, babel-traverse is very heavyweight, as it is designed to supply utilities to make all sorts of AST transformations possible. For simple AST walking without transformation, babel-traverse brings a lot of overhead.
This module loosely implements the API of Acorn parser's [walk module], which is a lightweight AST walker for the ESTree AST format.
In my tests, babylon-walk's ancestor walker (the most complex walker provided by this module) is about 8 times faster than babel-traverse, if the visitors are cached and the same AST is used for all runs. It is about 16 times faster if a fresh AST is used every run.
[![Dependency Status](https://img.shields.io/david/pugjs/babylon-walk.svg)](https://david-dm.org/pugjs/babylon-walk)
[![NPM version](https://img.shields.io/npm/v/babylon-walk.svg)](https://www.npmjs.com/package/babylon-walk)
[Babylon]: https://github.com/babel/babylon
[Babel]: https://babeljs.io/
[babel-traverse]: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#toc-babel-traverse
[walk module]: https://github.com/ternjs/acorn#distwalkjs
## Installation
```sh
$ npm install babylon-walk
```
## API
```js
var walk = require('babylon-walk');
```
### walk.simple(node, visitors, state)
Do a simple walk over the AST. `node` should be the AST node to walk, and `visitors` an object containing Babel [visitors]. Each visitor function will be called as `(node, state)`, where `node` is the AST node, and `state` is the same `state` passed to `walk.simple`.
When `walk.simple` is called with a fresh set of visitors, it will first "explode" the visitors (e.g. expanding `Visitor(node, state) {}` to `Visitor() { enter(node, state) {} }`). This exploding process can take some time, so it is recommended to [cache your visitors] and communicate state leveraging the `state` parameter. (One difference between the linked article and babylon-walk is that the state is only accessible through the `state` variable, never as `this`.)
All [babel-types] aliases (e.g. `Expression`) and the union syntax (e.g. `'Identifier|AssignmentPattern'(node, state) {}`) work.
### walk.ancestor(node, visitors, state)
Do a simple walk over the AST, but memoizing the ancestors of the node and making them available to the visitors. `node` should be the AST node to walk, and `visitors` an object containing Babel [visitors]. Each visitor function will be called as `(node, state, ancestors)`, where `node` is the AST node, `state` is the same `state` passed to `walk.ancestor`, and `ancestors` is an array of ancestors to the node (with the outermost node being `[0]` and the current node being `[ancestors.length - 1]`). If `state` is not specified in the call to `walk.ancestor`, the `state` parameter will be set to `ancestors`.
When `walk.ancestor` is called with a fresh set of visitors, it will first "explode" the visitors (e.g. expanding `Visitor(node, state) {}` to `Visitor() { enter(node, state) {} }`). This exploding process can take some time, so it is recommended to [cache your visitors] and communicate state leveraging the `state` parameter. (One difference between the linked article and babylon-walk is that the state is only accessible through the `state` variable, never as `this`.)
All [babel-types] aliases (e.g. `Expression`) and the union syntax (e.g. `'Identifier|AssignmentPattern'(node, state) {}`) work.
### walk.recursive(node, visitors, state)
Do a recursive walk over the AST, where the visitors are responsible for continuing the walk on the child nodes of their target node. `node` should be the AST node to walk, and `visitors` an object containing Babel [visitors]. Each visitor function will be called as `(node, state, c)`, where `node` is the AST node, `state` is the same `state` passed to `walk.recursive`, and `c` is a function that takes a single node as argument and continues walking _that_ node. If no visitor for a node is provided, the default walker algorithm will still be used.
When `walk.recursive` is called with a fresh set of visitors, it will first "explode" the visitors (e.g. expanding `Visitor(node, state) {}` to `Visitor() { enter(node, state) {} }`). This exploding process can take some time, so it is recommended to [cache your visitors] and communicate state leveraging the `state` parameter. (One difference between the linked article and babylon-walk is that the state is only accessible through the `state` variable, never as `this`.)
Unlike other babylon-walk walkers, `walk.recursive` does not call the `exit` visitor, only the `enter` (the default) visitor, of a specific node type.
All [babel-types] aliases (e.g. `Expression`) and the union syntax (e.g. `'Identifier|AssignmentPattern'(node, state) {}`) work.
In the following example, we are trying to count the number of functions in the outermost scope. This means, that we can simply walk all the statements and increment a counter if it is a function declaration or expression, and then stop walking. Note that we do not specify a visitor for the `Program` node, and the default algorithm for walking `Program` nodes is used (which is what we want). Also of note is how I bring the `visitors` object outside of `countFunctions` so that the object can be cached to improve performance.
```js
import * as t from 'babel-types';
import {parse} from 'babylon';
const visitors = {
Statement(node, state, c) {
if (t.isVariableDeclaration(node)) {
for (let declarator of node.declarations) {
// Continue walking the declarator
c(declarator);
}
} else if (t.isFunctionDeclaration(node)) {
state.counter++;
}
},
VariableDeclarator(node, state) {
if (t.isFunction(node.init)) {
state.counter++;
}
}
};
function countFunctions(node) {
const state = {
counter: 0
};
walk.recursive(node, visitors, state);
return state.counter;
}
const ast = parse(`
// Counts
var a = () => {};
// Counts
function b() {
// Doesn't count
function c() {
}
}
// Counts
const c = function d() {};
`);
countFunctions(ast);
// = 3
```
[babel-types]: https://github.com/babel/babel/tree/master/packages/babel-types
[cache your visitors]: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#toc-optimizing-nested-visitors
[visitors]: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#toc-visitors
## Caveat
For those of you migrating from Acorn to Babylon, there are a few things to be aware of.
1. The visitor caching suggestions do not apply to Acorn's walk module, but do for babylon-walk.
2. babylon-walk does not provide any of the other functions Acorn's walk module provides (e.g. `make`, `findNode*`).
3. babylon-walk does not use a `base` variable. The walker algorithm is the same as what babel-traverse uses.
- That means certain nodes that are not walked by Acorn, such as the `property` property of a non-computed `MemberExpression`, are walked by babylon-walk.
## License
MIT

271
VISUALIZACION/node_modules/babylon-walk/lib/explode.js generated vendored Executable file
View file

@ -0,0 +1,271 @@
"use strict";
exports.__esModule = true;
var _typeof2 = require("babel-runtime/helpers/typeof");
var _typeof3 = _interopRequireDefault(_typeof2);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.default = explode;
exports.verify = verify;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _lodash = require("lodash.clone");
var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* explode() will take a visitor object with all of the various shorthands
* that we support, and validates & normalizes it into a common format, ready
* to be used in traversal
*
* The various shorthands are:
* * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`
* * `"Identifier|NumericLiteral": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`
* * Aliases in `babel-types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`
*
* Other normalizations are:
* * `enter` and `exit` functions are wrapped in arrays, to ease merging of
* visitors
*/
// Copied from babel-traverse, but with virtual types handling removed
// https://github.com/babel/babel/blob/07b3dc18a09f2217b38a3a63c8613add6df1b47d/packages/babel-traverse/src/visitors.js
// import * as messages from 'babel-messages';
function explode(visitor) {
if (visitor._exploded) return visitor;
visitor._exploded = true;
// normalise pipes
for (var nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
var parts = nodeType.split("|");
if (parts.length === 1) continue;
var fns = visitor[nodeType];
delete visitor[nodeType];
for (var _iterator = parts, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var part = _ref;
visitor[part] = fns;
}
}
// verify data structure
verify(visitor);
// make sure there's no __esModule type since this is because we're using loose mode
// and it sets __esModule to be enumerable on all modules :(
delete visitor.__esModule;
// ensure visitors are objects
ensureEntranceObjects(visitor);
// ensure enter/exit callbacks are arrays
ensureCallbackArrays(visitor);
// add aliases
for (var _nodeType in visitor) {
if (shouldIgnoreKey(_nodeType)) continue;
var _fns = visitor[_nodeType];
var aliases = t.FLIPPED_ALIAS_KEYS[_nodeType];
var deprecratedKey = t.DEPRECATED_KEYS[_nodeType];
if (deprecratedKey) {
console.trace("Visitor defined for " + _nodeType + " but it has been renamed to " + deprecratedKey);
aliases = [deprecratedKey];
}
if (!aliases) continue;
// clear it from the visitor
delete visitor[_nodeType];
for (var _iterator2 = aliases, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var alias = _ref2;
var existing = visitor[alias];
if (existing) {
mergePair(existing, _fns);
} else {
visitor[alias] = (0, _lodash2.default)(_fns);
}
}
}
for (var _nodeType2 in visitor) {
if (shouldIgnoreKey(_nodeType2)) continue;
ensureCallbackArrays(visitor[_nodeType2]);
}
return visitor;
}
function verify(visitor) {
if (visitor._verified) return;
if (typeof visitor === "function") {
// throw new Error(messages.get("traverseVerifyRootFunction"));
throw new Error("You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?");
}
for (var nodeType in visitor) {
if (nodeType === "enter" || nodeType === "exit") {
validateVisitorMethods(nodeType, visitor[nodeType]);
}
if (shouldIgnoreKey(nodeType)) continue;
if (t.TYPES.indexOf(nodeType) < 0) {
// throw new Error(messages.get("traverseVerifyNodeType", nodeType));
throw new Error("You gave us a visitor for the node type " + nodeType + " but it's not a valid type");
}
var visitors = visitor[nodeType];
if ((typeof visitors === "undefined" ? "undefined" : (0, _typeof3.default)(visitors)) === "object") {
for (var visitorKey in visitors) {
if (visitorKey === "enter" || visitorKey === "exit") {
// verify that it just contains functions
validateVisitorMethods(nodeType + "." + visitorKey, visitors[visitorKey]);
} else {
// throw new Error(messages.get("traverseVerifyVisitorProperty", nodeType, visitorKey));
throw new Error("You passed `traverse()` a visitor object with the property " + nodeType + " that has the invalid property " + visitorKey);
}
}
}
}
visitor._verified = true;
}
function validateVisitorMethods(path, val) {
var fns = [].concat(val);
for (var _iterator3 = fns, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var fn = _ref3;
if (typeof fn !== "function") {
throw new TypeError("Non-function found defined in " + path + " with type " + (typeof fn === "undefined" ? "undefined" : (0, _typeof3.default)(fn)));
}
}
}
function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
var newVisitor = {};
var _loop = function _loop(key) {
var fns = oldVisitor[key];
// not an enter/exit array of callbacks
if (!Array.isArray(fns)) return "continue";
fns = fns.map(function (fn) {
var newFn = fn;
if (state) {
newFn = function newFn(path) {
return fn.call(state, path, state);
};
}
if (wrapper) {
newFn = wrapper(state.key, key, newFn);
}
return newFn;
});
newVisitor[key] = fns;
};
for (var key in oldVisitor) {
var _ret = _loop(key);
if (_ret === "continue") continue;
}
return newVisitor;
}
function ensureEntranceObjects(obj) {
for (var key in obj) {
if (shouldIgnoreKey(key)) continue;
var fns = obj[key];
if (typeof fns === "function") {
obj[key] = { enter: fns };
}
}
}
function ensureCallbackArrays(obj) {
if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];
if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];
}
function shouldIgnoreKey(key) {
// internal/hidden key
if (key[0] === "_") return true;
// ignore function keys
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
// ignore other options
if (key === "blacklist" || key === "noScope" || key === "skipKeys") return true;
return false;
}
function mergePair(dest, src) {
for (var key in src) {
dest[key] = [].concat(dest[key] || [], src[key]);
}
}

282
VISUALIZACION/node_modules/babylon-walk/lib/index.js generated vendored Executable file
View file

@ -0,0 +1,282 @@
'use strict';
exports.__esModule = true;
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.simple = simple;
exports.ancestor = ancestor;
exports.recursive = recursive;
var _babelTypes = require('babel-types');
var t = _interopRequireWildcard(_babelTypes);
var _explode = require('./explode.js');
var _explode2 = _interopRequireDefault(_explode);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function simple(node, visitors, state) {
if (!node) return;
visitors = (0, _explode2.default)(visitors);
(function c(node) {
if (!node) return;
var _ref = visitors[node.type] || {};
var enter = _ref.enter;
var exit = _ref.exit;
if (enter) {
for (var _iterator = enter, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref2;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
}
var visitor = _ref2;
visitor(node, state);
}
}
for (var _iterator2 = t.VISITOR_KEYS[node.type] || [], _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref3;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref3 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref3 = _i2.value;
}
var key = _ref3;
var subNode = node[key];
if (Array.isArray(subNode)) {
for (var _iterator4 = subNode, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) {
var _ref5;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref5 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref5 = _i4.value;
}
var subSubNode = _ref5;
c(subSubNode);
}
} else {
c(subNode);
}
}
if (exit) {
for (var _iterator3 = exit, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) {
var _ref4;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref4 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref4 = _i3.value;
}
var _visitor = _ref4;
_visitor(node, state);
}
}
})(node);
}
function ancestor(node, visitors, state) {
if (!node) return;
visitors = (0, _explode2.default)(visitors);
var ancestors = [];
(function c(node) {
if (!node) return;
var _ref6 = visitors[node.type] || {};
var enter = _ref6.enter;
var exit = _ref6.exit;
var isNew = node != ancestors[ancestors.length - 1];
if (isNew) ancestors.push(node);
if (enter) {
for (var _iterator5 = enter, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) {
var _ref7;
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref7 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref7 = _i5.value;
}
var visitor = _ref7;
visitor(node, state || ancestors, ancestors);
}
}
for (var _iterator6 = t.VISITOR_KEYS[node.type] || [], _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : (0, _getIterator3.default)(_iterator6);;) {
var _ref8;
if (_isArray6) {
if (_i6 >= _iterator6.length) break;
_ref8 = _iterator6[_i6++];
} else {
_i6 = _iterator6.next();
if (_i6.done) break;
_ref8 = _i6.value;
}
var key = _ref8;
var subNode = node[key];
if (Array.isArray(subNode)) {
for (var _iterator8 = subNode, _isArray8 = Array.isArray(_iterator8), _i8 = 0, _iterator8 = _isArray8 ? _iterator8 : (0, _getIterator3.default)(_iterator8);;) {
var _ref10;
if (_isArray8) {
if (_i8 >= _iterator8.length) break;
_ref10 = _iterator8[_i8++];
} else {
_i8 = _iterator8.next();
if (_i8.done) break;
_ref10 = _i8.value;
}
var subSubNode = _ref10;
c(subSubNode);
}
} else {
c(subNode);
}
}
if (exit) {
for (var _iterator7 = exit, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : (0, _getIterator3.default)(_iterator7);;) {
var _ref9;
if (_isArray7) {
if (_i7 >= _iterator7.length) break;
_ref9 = _iterator7[_i7++];
} else {
_i7 = _iterator7.next();
if (_i7.done) break;
_ref9 = _i7.value;
}
var _visitor2 = _ref9;
_visitor2(node, state || ancestors, ancestors);
}
}
if (isNew) ancestors.pop();
})(node);
}
function recursive(node, visitors, state) {
if (!node) return;
visitors = (0, _explode2.default)(visitors);
(function c(node) {
if (!node) return;
var _ref11 = visitors[node.type] || {};
var enter = _ref11.enter;
if (enter && enter.length) {
for (var _iterator9 = enter, _isArray9 = Array.isArray(_iterator9), _i9 = 0, _iterator9 = _isArray9 ? _iterator9 : (0, _getIterator3.default)(_iterator9);;) {
var _ref12;
if (_isArray9) {
if (_i9 >= _iterator9.length) break;
_ref12 = _iterator9[_i9++];
} else {
_i9 = _iterator9.next();
if (_i9.done) break;
_ref12 = _i9.value;
}
var visitor = _ref12;
visitor(node, state, c);
}
} else {
for (var _iterator10 = t.VISITOR_KEYS[node.type] || [], _isArray10 = Array.isArray(_iterator10), _i10 = 0, _iterator10 = _isArray10 ? _iterator10 : (0, _getIterator3.default)(_iterator10);;) {
var _ref13;
if (_isArray10) {
if (_i10 >= _iterator10.length) break;
_ref13 = _iterator10[_i10++];
} else {
_i10 = _iterator10.next();
if (_i10.done) break;
_ref13 = _i10.value;
}
var key = _ref13;
var subNode = node[key];
if (Array.isArray(subNode)) {
for (var _iterator11 = subNode, _isArray11 = Array.isArray(_iterator11), _i11 = 0, _iterator11 = _isArray11 ? _iterator11 : (0, _getIterator3.default)(_iterator11);;) {
var _ref14;
if (_isArray11) {
if (_i11 >= _iterator11.length) break;
_ref14 = _iterator11[_i11++];
} else {
_i11 = _iterator11.next();
if (_i11.done) break;
_ref14 = _i11.value;
}
var subSubNode = _ref14;
c(subSubNode);
}
} else {
c(subNode);
}
}
}
})(node);
}

30
VISUALIZACION/node_modules/babylon-walk/package.json generated vendored Executable file
View file

@ -0,0 +1,30 @@
{
"name": "babylon-walk",
"version": "1.0.2",
"description": "Lightweight Babylon AST traversal",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"files": [
"lib",
"src"
],
"scripts": {
"prepublish": "babel -d lib src"
},
"repository": {
"type": "git",
"url": "https://github.com/pugjs/babylon-walk.git"
},
"author": "Timothy Gu <timothygu99@gmail.com>",
"license": "MIT",
"dependencies": {
"babel-runtime": "^6.11.6",
"babel-types": "^6.15.0",
"lodash.clone": "^4.5.0"
},
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.14.0"
}
}

202
VISUALIZACION/node_modules/babylon-walk/src/explode.js generated vendored Executable file
View file

@ -0,0 +1,202 @@
// Copied from babel-traverse, but with virtual types handling removed
// https://github.com/babel/babel/blob/07b3dc18a09f2217b38a3a63c8613add6df1b47d/packages/babel-traverse/src/visitors.js
// import * as messages from 'babel-messages';
import * as t from "babel-types";
import clone from "lodash.clone";
/**
* explode() will take a visitor object with all of the various shorthands
* that we support, and validates & normalizes it into a common format, ready
* to be used in traversal
*
* The various shorthands are:
* * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`
* * `"Identifier|NumericLiteral": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`
* * Aliases in `babel-types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`
*
* Other normalizations are:
* * `enter` and `exit` functions are wrapped in arrays, to ease merging of
* visitors
*/
export default function explode(visitor) {
if (visitor._exploded) return visitor;
visitor._exploded = true;
// normalise pipes
for (let nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
let parts = nodeType.split("|");
if (parts.length === 1) continue;
let fns = visitor[nodeType];
delete visitor[nodeType];
for (let part of parts) {
visitor[part] = fns;
}
}
// verify data structure
verify(visitor);
// make sure there's no __esModule type since this is because we're using loose mode
// and it sets __esModule to be enumerable on all modules :(
delete visitor.__esModule;
// ensure visitors are objects
ensureEntranceObjects(visitor);
// ensure enter/exit callbacks are arrays
ensureCallbackArrays(visitor);
// add aliases
for (let nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
let fns = visitor[nodeType];
let aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
let deprecratedKey = t.DEPRECATED_KEYS[nodeType];
if (deprecratedKey) {
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`);
aliases = [deprecratedKey];
}
if (!aliases) continue;
// clear it from the visitor
delete visitor[nodeType];
for (let alias of aliases) {
let existing = visitor[alias];
if (existing) {
mergePair(existing, fns);
} else {
visitor[alias] = clone(fns);
}
}
}
for (let nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
ensureCallbackArrays(visitor[nodeType]);
}
return visitor;
}
export function verify(visitor) {
if (visitor._verified) return;
if (typeof visitor === "function") {
// throw new Error(messages.get("traverseVerifyRootFunction"));
throw new Error("You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?");
}
for (let nodeType in visitor) {
if (nodeType === "enter" || nodeType === "exit") {
validateVisitorMethods(nodeType, visitor[nodeType]);
}
if (shouldIgnoreKey(nodeType)) continue;
if (t.TYPES.indexOf(nodeType) < 0) {
// throw new Error(messages.get("traverseVerifyNodeType", nodeType));
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
}
let visitors = visitor[nodeType];
if (typeof visitors === "object") {
for (let visitorKey in visitors) {
if (visitorKey === "enter" || visitorKey === "exit") {
// verify that it just contains functions
validateVisitorMethods(`${nodeType}.${visitorKey}`, visitors[visitorKey]);
} else {
// throw new Error(messages.get("traverseVerifyVisitorProperty", nodeType, visitorKey));
throw new Error(`You passed \`traverse()\` a visitor object with the property ${nodeType} that has the invalid property ${visitorKey}`)
}
}
}
}
visitor._verified = true;
}
function validateVisitorMethods(path, val) {
let fns = [].concat(val);
for (let fn of fns) {
if (typeof fn !== "function") {
throw new TypeError(`Non-function found defined in ${path} with type ${typeof fn}`);
}
}
}
function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
let newVisitor = {};
for (let key in oldVisitor) {
let fns = oldVisitor[key];
// not an enter/exit array of callbacks
if (!Array.isArray(fns)) continue;
fns = fns.map(function (fn) {
let newFn = fn;
if (state) {
newFn = function (path) {
return fn.call(state, path, state);
};
}
if (wrapper) {
newFn = wrapper(state.key, key, newFn);
}
return newFn;
});
newVisitor[key] = fns;
}
return newVisitor;
}
function ensureEntranceObjects(obj) {
for (let key in obj) {
if (shouldIgnoreKey(key)) continue;
let fns = obj[key];
if (typeof fns === "function") {
obj[key] = { enter: fns };
}
}
}
function ensureCallbackArrays(obj) {
if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];
if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];
}
function shouldIgnoreKey(key) {
// internal/hidden key
if (key[0] === "_") return true;
// ignore function keys
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
// ignore other options
if (key === "blacklist" || key === "noScope" || key === "skipKeys") return true;
return false;
}
function mergePair(dest, src) {
for (let key in src) {
dest[key] = [].concat(dest[key] || [], src[key]);
}
}

107
VISUALIZACION/node_modules/babylon-walk/src/index.js generated vendored Executable file
View file

@ -0,0 +1,107 @@
import * as t from 'babel-types';
import explode from './explode.js';
export function simple(node, visitors, state) {
if (!node) return;
visitors = explode(visitors);
(function c(node) {
if (!node) return;
const {enter, exit} = visitors[node.type] || {};
if (enter) {
for (let visitor of enter) {
visitor(node, state);
}
}
for (let key of t.VISITOR_KEYS[node.type] || []) {
let subNode = node[key];
if (Array.isArray(subNode)) {
for (let subSubNode of subNode) {
c(subSubNode);
}
} else {
c(subNode);
}
}
if (exit) {
for (let visitor of exit) {
visitor(node, state);
}
}
})(node);
}
export function ancestor(node, visitors, state) {
if (!node) return;
visitors = explode(visitors);
let ancestors = [];
(function c(node) {
if (!node) return;
const {enter, exit} = visitors[node.type] || {};
let isNew = node != ancestors[ancestors.length - 1];
if (isNew) ancestors.push(node);
if (enter) {
for (let visitor of enter) {
visitor(node, state || ancestors, ancestors);
}
}
for (let key of t.VISITOR_KEYS[node.type] || []) {
let subNode = node[key];
if (Array.isArray(subNode)) {
for (let subSubNode of subNode) {
c(subSubNode);
}
} else {
c(subNode);
}
}
if (exit) {
for (let visitor of exit) {
visitor(node, state || ancestors, ancestors);
}
}
if (isNew) ancestors.pop();
})(node);
}
export function recursive(node, visitors, state) {
if (!node) return;
visitors = explode(visitors);
(function c(node) {
if (!node) return;
const {enter} = visitors[node.type] || {};
if (enter && enter.length) {
for (let visitor of enter) {
visitor(node, state, c);
}
} else {
for (let key of t.VISITOR_KEYS[node.type] || []) {
let subNode = node[key];
if (Array.isArray(subNode)) {
for (let subSubNode of subNode) {
c(subSubNode);
}
} else {
c(subNode);
}
}
}
})(node);
}