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:
705 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * Extractor function for a CallExpression type value node.
|
---|
| 3 | * A call expression looks like `bar()`
|
---|
| 4 | * This will return `bar` as the value to indicate its existence,
|
---|
| 5 | * since we can not execute the function bar in a static environment.
|
---|
| 6 | *
|
---|
| 7 | * @param - value - AST Value object with type `CallExpression`
|
---|
| 8 | * @returns - The extracted value converted to correct type.
|
---|
| 9 | */
|
---|
| 10 | export default function extractValueFromCallExpression(value) {
|
---|
| 11 | // eslint-disable-next-line global-require
|
---|
| 12 | const getValue = require('.').default;
|
---|
| 13 | const args = Array.isArray(value.arguments) ? value.arguments.map((x) => getValue(x)).join(', ') : '';
|
---|
| 14 | return `${getValue(value.callee)}${value.optional ? '?.' : ''}(${args})`;
|
---|
| 15 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.