@@ -89,9 +89,7 @@ export function isDeterministic (method, engine, buildState) {
89
89
function isDeepSync ( method , engine ) {
90
90
if ( ! engine . async ) return true
91
91
92
- if ( Array . isArray ( method ) ) {
93
- return method . every ( i => isDeepSync ( i , engine ) )
94
- }
92
+ if ( Array . isArray ( method ) ) return method . every ( i => isDeepSync ( i , engine ) )
95
93
96
94
if ( typeof method === 'object' ) {
97
95
const func = Object . keys ( method ) [ 0 ]
@@ -120,10 +118,10 @@ function buildString (method, buildState = {}) {
120
118
const {
121
119
notTraversed = [ ] ,
122
120
functions = { } ,
123
- methods = [ ] ,
124
- state,
121
+ // methods = [],
122
+ // state,
125
123
async,
126
- above = [ ] ,
124
+ // above = [],
127
125
processing = [ ] ,
128
126
values = [ ] ,
129
127
engine
@@ -147,16 +145,12 @@ function buildString (method, buildState = {}) {
147
145
148
146
function makeAsync ( result ) {
149
147
buildState . asyncDetected = buildState . asyncDetected || asyncDetected
150
-
151
- if ( async && asyncDetected ) {
152
- return `await ${ result } `
153
- }
148
+ if ( async && asyncDetected ) return `await ${ result } `
154
149
return result
155
150
}
156
151
157
152
const func = method && Object . keys ( method ) [ 0 ]
158
- buildState . useContext =
159
- buildState . useContext || ( engine . methods [ func ] || { } ) . useContext
153
+ buildState . useContext = buildState . useContext || ( engine . methods [ func ] || { } ) . useContext
160
154
161
155
if ( method && typeof method === 'object' ) {
162
156
if ( ! func ) return pushValue ( method )
@@ -192,62 +186,20 @@ function buildString (method, buildState = {}) {
192
186
functions [ func ] = 1
193
187
asyncDetected = ! isSync ( engine . methods [ func ] )
194
188
195
- return makeAsync (
196
- `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')'
197
- )
189
+ return makeAsync ( `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')' )
198
190
} else {
199
191
if ( engine . methods [ func ] && ( typeof engine . methods [ func ] . traverse === 'undefined' ? true : engine . methods [ func ] . traverse ) ) {
200
192
functions [ func ] = 1
201
- asyncDetected = Boolean (
202
- async && engine . methods [ func ] && engine . methods [ func ] . asyncMethod
203
- )
193
+ asyncDetected = Boolean ( async && engine . methods [ func ] && engine . methods [ func ] . asyncMethod )
204
194
205
- return makeAsync (
206
- `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')'
207
- )
195
+ return makeAsync ( `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')' )
208
196
} else {
209
- if ( engine . methods [ func ] ) {
210
- if ( async ) {
211
- if ( engine . methods [ func ] . asyncBuild || engine . methods [ func ] . build ) {
212
- const builder =
213
- engine . methods [ func ] . asyncBuild || engine . methods [ func ] . build
214
- const result = builder (
215
- method [ func ] ,
216
- state ,
217
- above ,
218
- engine ,
219
- buildState
220
- )
221
- methods . push ( result )
222
- asyncDetected = ! isSync ( result )
223
- return makeAsync ( `methods[${ methods . length - 1 } ]()` )
224
- }
225
- } else {
226
- if ( engine . methods [ func ] . build ) {
227
- methods . push (
228
- engine . methods [ func ] . build (
229
- method [ func ] ,
230
- state ,
231
- above ,
232
- engine ,
233
- buildState
234
- )
235
- )
236
- return makeAsync ( `methods[${ methods . length - 1 } ]()` )
237
- }
238
- }
239
- }
240
-
241
- asyncDetected = Boolean (
242
- async && engine . methods [ func ] && engine . methods [ func ] . asyncMethod
243
- )
197
+ asyncDetected = Boolean ( async && engine . methods [ func ] && engine . methods [ func ] . asyncMethod )
244
198
245
199
functions [ func ] = 1
246
200
notTraversed . push ( method [ func ] )
247
201
248
- return makeAsync (
249
- `gen["${ func } "](` + `notTraversed[${ notTraversed . length - 1 } ]` + ')'
250
- )
202
+ return makeAsync ( `gen["${ func } "](` + `notTraversed[${ notTraversed . length - 1 } ]` + ')' )
251
203
}
252
204
}
253
205
}
@@ -354,18 +306,14 @@ function processBuiltString (method, str, buildState) {
354
306
}
355
307
} )
356
308
357
- if ( ! Object . keys ( functions ) . length ) {
358
- return method
359
- }
309
+ if ( ! Object . keys ( functions ) . length ) return method
360
310
361
311
let copyStateCall = 'state[Override] = context;'
362
312
// console.log(buildState.useContext)
363
313
364
314
if ( ! buildState . useContext ) {
365
315
copyStateCall = ''
366
- while ( str . includes ( 'state[Override]' ) ) {
367
- str = str . replace ( 'state[Override]' , 'context' )
368
- }
316
+ str = str . replace ( / s t a t e \[ O v e r r i d e \] / g, 'context' )
369
317
}
370
318
371
319
methods . truthy = engine . truthy
0 commit comments