You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

/**
* @fileoverview Patch for estraverse
* @author Toru Nagashima
* @copyright 2015 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
var estraverse = require("estraverse"),
jsxKeys = require("estraverse-fb/keys");
//------------------------------------------------------------------------------
// Helers
//------------------------------------------------------------------------------
var experimentalKeys = {
ExperimentalRestProperty: ["argument"],
ExperimentalSpreadProperty: ["argument"]
};
/**
* Adds a given keys to Syntax and VisitorKeys of estraverse.
*
* @param {object} keys - Key definitions to add.
* This is an object as map.
* Keys are the node type.
* Values are an array of property names to visit.
* @returns {void}
*/
function installKeys(keys) {
for (var key in keys) {
/* istanbul ignore else */
if (keys.hasOwnProperty(key)) {
estraverse.Syntax[key] = key;
if (keys[key]) {
estraverse.VisitorKeys[key] = keys[key];
}
}
}
}
// Add JSX node types.
installKeys(jsxKeys);
// Add Experimental node types.
installKeys(experimentalKeys);
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
module.exports = estraverse;