init source

This commit is contained in:
Le Viet
2022-03-07 22:07:57 +07:00
parent e4376f3777
commit 8aba590a8d
11240 changed files with 1012977 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = extractValueFromLogicalExpression;
/**
* Extractor function for a LogicalExpression type value node.
* A logical expression is `a && b` or `a || b`, so we evaluate both sides
* and return the extracted value of the expression.
*
* @param - value - AST Value object with type `LogicalExpression`
* @returns - The extracted value converted to correct type.
*/
function extractValueFromLogicalExpression(value) {
// eslint-disable-next-line global-require
var getValue = require('./index.js').default;
var operator = value.operator,
left = value.left,
right = value.right;
var leftVal = getValue(left);
var rightVal = getValue(right);
return operator === '&&' ? leftVal && rightVal : leftVal || rightVal;
}