source: imaps-frontend/node_modules/jsx-ast-utils/src/values/Literal.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 559 bytes
RevLine 
[d565449]1/**
2 * Extractor function for a Literal type value node.
3 *
4 * @param - value - AST Value object with type `Literal`
5 * @returns { String|Boolean } - The extracted value converted to correct type.
6 */
7export default function extractValueFromLiteral(value) {
8 const { value: extractedValue } = value;
9
10 const normalizedStringValue = typeof extractedValue === 'string' && extractedValue.toLowerCase();
11 if (normalizedStringValue === 'true') {
12 return true;
13 }
14
15 if (normalizedStringValue === 'false') {
16 return false;
17 }
18
19 return extractedValue;
20}
Note: See TracBrowser for help on using the repository browser.