@@ -27,36 +27,35 @@ const genWrappedFunc = ({
27
27
// to complete compilation. If this gets invoked and not the subsequent
28
28
// call, then our data will be inaccurate, sadly
29
29
addEndEvent ( ) ;
30
- const normalArgMap = a => wrap ( a , pluginName , smp ) ;
31
30
let ret ;
32
31
if ( endType === "wrapDone" )
33
32
ret = func . apply (
34
33
context ,
35
- args . map ( a => wrap ( a , pluginName , smp , addEndEvent ) )
34
+ args . map ( ( a ) => wrap ( a , pluginName , smp , addEndEvent ) )
36
35
) ;
37
36
else if ( endType === "async" ) {
38
37
const argsButLast = args . slice ( 0 , args . length - 1 ) ;
39
38
const callback = args [ args . length - 1 ] ;
40
39
ret = func . apply (
41
40
context ,
42
- argsButLast . map ( normalArgMap ) . concat ( ( ...callbackArgs ) => {
41
+ argsButLast . concat ( ( ...callbackArgs ) => {
43
42
addEndEvent ( ) ;
44
43
callback ( ...callbackArgs ) ;
45
44
} )
46
45
) ;
47
46
} else if ( endType === "promise" )
48
- ret = func . apply ( context , args . map ( normalArgMap ) ) . then ( promiseArg => {
47
+ ret = func . apply ( context , args ) . then ( ( promiseArg ) => {
49
48
addEndEvent ( ) ;
50
49
return promiseArg ;
51
50
} ) ;
52
- else ret = func . apply ( context , args . map ( normalArgMap ) ) ;
51
+ else ret = func . apply ( context , args ) ;
53
52
addEndEvent ( ) ;
54
53
55
54
return ret ;
56
55
} ;
57
56
58
57
const genPluginMethod = ( orig , pluginName , smp , type ) =>
59
- function ( method , func ) {
58
+ function ( method , func ) {
60
59
const timeEventName = pluginName + "/" + type + "/" + method ;
61
60
const wrappedFunc = genWrappedFunc ( {
62
61
func,
@@ -70,7 +69,7 @@ const genPluginMethod = (orig, pluginName, smp, type) =>
70
69
} ;
71
70
72
71
const wrapTap = ( tap , pluginName , smp , type , method ) =>
73
- function ( id , func ) {
72
+ function ( id , func ) {
74
73
const timeEventName = pluginName + "/" + type + "/" + method ;
75
74
const wrappedFunc = genWrappedFunc ( {
76
75
func,
@@ -83,7 +82,7 @@ const wrapTap = (tap, pluginName, smp, type, method) =>
83
82
} ;
84
83
85
84
const wrapTapAsync = ( tapAsync , pluginName , smp , type , method ) =>
86
- function ( id , func ) {
85
+ function ( id , func ) {
87
86
const timeEventName = pluginName + "/" + type + "/" + method ;
88
87
const wrappedFunc = genWrappedFunc ( {
89
88
func,
@@ -97,7 +96,7 @@ const wrapTapAsync = (tapAsync, pluginName, smp, type, method) =>
97
96
} ;
98
97
99
98
const wrapTapPromise = ( tapPromise , pluginName , smp , type , method ) =>
100
- function ( id , func ) {
99
+ function ( id , func ) {
101
100
const timeEventName = pluginName + "/" + type + "/" + method ;
102
101
const wrappedFunc = genWrappedFunc ( {
103
102
func,
@@ -115,12 +114,12 @@ const wrapHooks = (orig, pluginName, smp, type) => {
115
114
const hooks = orig . hooks ;
116
115
if ( ! hooks ) return hooks ;
117
116
const prevWrapped = wrappedHooks . find (
118
- w =>
117
+ ( w ) =>
119
118
w . pluginName === pluginName && ( w . orig === hooks || w . wrapped === hooks )
120
119
) ;
121
120
if ( prevWrapped ) return prevWrapped . wrapped ;
122
121
123
- const genProxy = method => {
122
+ const genProxy = ( method ) => {
124
123
const proxy = new Proxy ( hooks [ method ] , {
125
124
get : ( target , property ) => {
126
125
const raw = Reflect . get ( target , property ) ;
@@ -170,7 +169,8 @@ const construcNamesToWrap = [
170
169
const wrappedObjs = [ ] ;
171
170
const findWrappedObj = ( orig , pluginName ) => {
172
171
const prevWrapped = wrappedObjs . find (
173
- w => w . pluginName === pluginName && ( w . orig === orig || w . wrapped === orig )
172
+ ( w ) =>
173
+ w . pluginName === pluginName && ( w . orig === orig || w . wrapped === orig )
174
174
) ;
175
175
if ( prevWrapped ) return prevWrapped . wrapped ;
176
176
} ;
@@ -179,15 +179,15 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
179
179
const prevWrapped = findWrappedObj ( orig , pluginName ) ;
180
180
if ( prevWrapped ) return prevWrapped ;
181
181
182
- const getOrigConstrucName = target =>
182
+ const getOrigConstrucName = ( target ) =>
183
183
target && target . constructor && target . constructor . name ;
184
- const getShouldWrap = target => {
184
+ const getShouldWrap = ( target ) => {
185
185
const origConstrucName = getOrigConstrucName ( target ) ;
186
186
return construcNamesToWrap . includes ( origConstrucName ) ;
187
187
} ;
188
188
const shouldWrap = getShouldWrap ( orig ) ;
189
189
const shouldSoftWrap = Object . keys ( orig )
190
- . map ( k => orig [ k ] )
190
+ . map ( ( k ) => orig [ k ] )
191
191
. some ( getShouldWrap ) ;
192
192
193
193
let wrappedReturn ;
@@ -196,7 +196,7 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
196
196
const vanillaFunc = orig . name === "next" ;
197
197
wrappedReturn =
198
198
vanillaFunc && addEndEvent
199
- ? function ( ) {
199
+ ? function ( ) {
200
200
// do this before calling the callback, since the callback can start
201
201
// the next plugin step
202
202
addEndEvent ( ) ;
@@ -238,12 +238,6 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
238
238
Object . defineProperty ( ret , "name" , {
239
239
value : raw . name ,
240
240
} ) ;
241
- const funcProxy = new Proxy ( ret , {
242
- get : ( target , property ) => {
243
- return raw [ property ] ;
244
- } ,
245
- } ) ;
246
- return funcProxy ;
247
241
}
248
242
249
243
return raw ;
0 commit comments