@@ -89,9 +89,7 @@ export function isDeterministic (method, engine, buildState) {
8989function isDeepSync ( method , engine ) {
9090 if ( ! engine . async ) return true
9191
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 ) )
9593
9694 if ( typeof method === 'object' ) {
9795 const func = Object . keys ( method ) [ 0 ]
@@ -120,10 +118,10 @@ function buildString (method, buildState = {}) {
120118 const {
121119 notTraversed = [ ] ,
122120 functions = { } ,
123- methods = [ ] ,
124- state,
121+ // methods = [],
122+ // state,
125123 async,
126- above = [ ] ,
124+ // above = [],
127125 processing = [ ] ,
128126 values = [ ] ,
129127 engine
@@ -147,16 +145,12 @@ function buildString (method, buildState = {}) {
147145
148146 function makeAsync ( result ) {
149147 buildState . asyncDetected = buildState . asyncDetected || asyncDetected
150-
151- if ( async && asyncDetected ) {
152- return `await ${ result } `
153- }
148+ if ( async && asyncDetected ) return `await ${ result } `
154149 return result
155150 }
156151
157152 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
160154
161155 if ( method && typeof method === 'object' ) {
162156 if ( ! func ) return pushValue ( method )
@@ -192,62 +186,20 @@ function buildString (method, buildState = {}) {
192186 functions [ func ] = 1
193187 asyncDetected = ! isSync ( engine . methods [ func ] )
194188
195- return makeAsync (
196- `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')'
197- )
189+ return makeAsync ( `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')' )
198190 } else {
199191 if ( engine . methods [ func ] && ( typeof engine . methods [ func ] . traverse === 'undefined' ? true : engine . methods [ func ] . traverse ) ) {
200192 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 )
204194
205- return makeAsync (
206- `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')'
207- )
195+ return makeAsync ( `gen["${ func } "](` + buildString ( method [ func ] , buildState ) + ')' )
208196 } 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 )
244198
245199 functions [ func ] = 1
246200 notTraversed . push ( method [ func ] )
247201
248- return makeAsync (
249- `gen["${ func } "](` + `notTraversed[${ notTraversed . length - 1 } ]` + ')'
250- )
202+ return makeAsync ( `gen["${ func } "](` + `notTraversed[${ notTraversed . length - 1 } ]` + ')' )
251203 }
252204 }
253205 }
@@ -354,18 +306,14 @@ function processBuiltString (method, str, buildState) {
354306 }
355307 } )
356308
357- if ( ! Object . keys ( functions ) . length ) {
358- return method
359- }
309+ if ( ! Object . keys ( functions ) . length ) return method
360310
361311 let copyStateCall = 'state[Override] = context;'
362312 // console.log(buildState.useContext)
363313
364314 if ( ! buildState . useContext ) {
365315 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' )
369317 }
370318
371319 methods . truthy = engine . truthy
0 commit comments