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
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.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 | */
|
---|
13 | function 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.