Permalink
Cannot retrieve contributors at this time
70 lines (54 sloc)
1.91 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/jsx-ast-utils/lib/values/index.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
exports.default = getValue; | |
exports.getLiteralValue = getLiteralValue; | |
var _Literal = require('./Literal'); | |
var _Literal2 = _interopRequireDefault(_Literal); | |
var _JSXElement = require('./JSXElement'); | |
var _JSXElement2 = _interopRequireDefault(_JSXElement); | |
var _JSXText = require('./JSXText'); | |
var _JSXText2 = _interopRequireDefault(_JSXText); | |
var _expressions = require('./expressions'); | |
var _expressions2 = _interopRequireDefault(_expressions); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// Composition map of types to their extractor functions. | |
var TYPES = { | |
Literal: _Literal2.default, | |
JSXElement: _JSXElement2.default, | |
JSXExpressionContainer: _expressions2.default, | |
JSXText: _JSXText2.default | |
}; | |
// Composition map of types to their extractor functions to handle literals. | |
var LITERAL_TYPES = _extends({}, TYPES, { | |
JSXElement: function JSXElement() { | |
return null; | |
}, | |
JSXExpressionContainer: _expressions.extractLiteral | |
}); | |
/** | |
* This function maps an AST value node | |
* to its correct extractor function for its | |
* given type. | |
* | |
* This will map correctly for *all* possible types. | |
* | |
* @param value - AST Value object on a JSX Attribute. | |
*/ | |
function getValue(value) { | |
return TYPES[value.type](value); | |
} | |
/** | |
* This function maps an AST value node | |
* to its correct extractor function for its | |
* given type. | |
* | |
* This will map correctly for *some* possible types that map to literals. | |
* | |
* @param value - AST Value object on a JSX Attribute. | |
*/ | |
function getLiteralValue(value) { | |
return LITERAL_TYPES[value.type](value); | |
} |