File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
src/util/values/expressions Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ import getValue from './index' ;
2
+
3
+ const extract = value => {
4
+ const { operator, argument } = value ;
5
+
6
+ switch ( operator ) {
7
+ case '-' :
8
+ return - getValue ( argument ) ;
9
+ case '+' :
10
+ return Number ( getValue ( argument ) ) ;
11
+ case '!' :
12
+ return ! getValue ( argument ) ;
13
+ case '~' :
14
+ return ~ getValue ( argument ) ;
15
+ case 'typeof' :
16
+ case 'delete' :
17
+ case 'void' :
18
+ default :
19
+ return undefined ;
20
+ }
21
+ } ;
22
+
23
+ export default extract ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import FunctionExpression from './FunctionExpression';
6
6
import LogicalExpression from './LogicalExpression' ;
7
7
import MemberExpression from './MemberExpression' ;
8
8
import CallExpression from './CallExpression' ;
9
+ import UnaryExpression from './UnaryExpression' ;
9
10
10
11
const TYPES = {
11
12
Identifier,
@@ -15,7 +16,8 @@ const TYPES = {
15
16
FunctionExpression,
16
17
LogicalExpression,
17
18
MemberExpression,
18
- CallExpression
19
+ CallExpression,
20
+ UnaryExpression
19
21
} ;
20
22
21
23
const extract = value => {
You can’t perform that action at this time.
0 commit comments