File tree 2 files changed +18
-10
lines changed
2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 46
46
"node" : " >=8"
47
47
},
48
48
"dependencies" : {
49
- "@medv/blessed" : " ^2.0.0 " ,
49
+ "@medv/blessed" : " ^2.0.1 " ,
50
50
"chalk" : " ^3.0.0" ,
51
51
"indent-string" : " ^4.0.0" ,
52
52
"lossless-json" : " ^1.0.3" ,
53
53
"string-width" : " ^4.2.0"
54
54
},
55
55
"devDependencies" : {
56
56
"ava" : " ^2.4.0" ,
57
- "pkg" : " ^4.4.1 " ,
57
+ "pkg" : " ^4.4.2 " ,
58
58
"release-it" : " ^12.4.3"
59
59
}
60
60
}
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
function reduce ( json , code ) {
4
- if ( / ^ \. / . test ( code ) ) {
5
- const fx = eval ( `function fn() {
6
- return ${ code === '.' ? 'this' : 'this' + code }
7
- }; fn` )
8
- return fx . call ( json )
4
+ if ( '.' === code ) {
5
+ return json
9
6
}
10
7
11
8
if ( '?' === code ) {
12
9
return Object . keys ( json )
13
10
}
14
11
15
- const fx = eval ( `function fn() {
12
+ if ( / ^ \. \[ / . test ( code ) ) {
13
+ return eval ( `function fn() {
14
+ return this${ code . substring ( 1 ) }
15
+ }; fn` ) . call ( json )
16
+ }
17
+
18
+ if ( / ^ \. / . test ( code ) ) {
19
+ return eval ( `function fn() {
20
+ return this${ code }
21
+ }; fn` ) . call ( json )
22
+ }
23
+
24
+ const fn = eval ( `function fn() {
16
25
return ${ code }
17
- }; fn` )
26
+ }; fn` ) . call ( json )
18
27
19
- const fn = fx . call ( json )
20
28
if ( typeof fn === 'function' ) {
21
29
return fn ( json )
22
30
}
You can’t perform that action at this time.
0 commit comments