|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
950 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.default = extractValueFromUpdateExpression;
|
|---|
| 7 | /**
|
|---|
| 8 | * Extractor function for an UpdateExpression type value node.
|
|---|
| 9 | * An update expression is an expression with an update operator.
|
|---|
| 10 | * For example, foo++ will evaluate to foo + 1.
|
|---|
| 11 | *
|
|---|
| 12 | * @param - value - AST Value object with type `UpdateExpression`
|
|---|
| 13 | * @returns - The extracted value converted to correct type.
|
|---|
| 14 | */
|
|---|
| 15 | function extractValueFromUpdateExpression(value) {
|
|---|
| 16 | // eslint-disable-next-line global-require
|
|---|
| 17 | var getValue = require('.').default;
|
|---|
| 18 | var operator = value.operator,
|
|---|
| 19 | argument = value.argument,
|
|---|
| 20 | prefix = value.prefix;
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | var val = getValue(argument);
|
|---|
| 24 |
|
|---|
| 25 | switch (operator) {
|
|---|
| 26 | case '++':
|
|---|
| 27 | return prefix ? ++val : val++; // eslint-disable-line no-plusplus
|
|---|
| 28 | case '--':
|
|---|
| 29 | return prefix ? --val : val--; // eslint-disable-line no-plusplus
|
|---|
| 30 | default:
|
|---|
| 31 | return undefined;
|
|---|
| 32 | }
|
|---|
| 33 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.