source: imaps-frontend/node_modules/jsx-ast-utils/lib/values/Literal.js@ d565449

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

Update repo after prototype presentation

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