-
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] - Add ConditionalExpression expression handler.
- Loading branch information
1 parent
a62360d
commit d25a918
Showing
4 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
import getValue from './index'; | ||
|
||
|
||
|
||
/** | ||
* Extractor function for a ConditionalExpression type value node. | ||
* | ||
* @param - value - AST Value object with type `ConditionalExpression` | ||
* @returns - The extracted value converted to correct type. | ||
*/ | ||
export default function extractValueFromConditionalExpression(value) { | ||
const { | ||
test, | ||
alternate, | ||
consequent | ||
} = value; | ||
|
||
return getValue(test) ? getValue(alternate) : getValue(consequent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters