@@ -21,11 +21,12 @@ function isDeterministic (method, engine, buildState) {
2121 if ( engine . isData ( method , func ) ) return true
2222 if ( ! engine . methods [ func ] ) throw new Error ( `Method '${ func } ' was not found in the Logic Engine.` )
2323
24- if ( engine . methods [ func ] . traverse === false ) {
24+ if ( engine . methods [ func ] . lazy ) {
2525 return typeof engine . methods [ func ] . deterministic === 'function'
2626 ? engine . methods [ func ] . deterministic ( lower , buildState )
2727 : engine . methods [ func ] . deterministic
2828 }
29+
2930 return typeof engine . methods [ func ] . deterministic === 'function'
3031 ? engine . methods [ func ] . deterministic ( lower , buildState )
3132 : engine . methods [ func ] . deterministic &&
@@ -44,7 +45,7 @@ function isSyncDeep (method, engine, buildState) {
4445 const lower = method [ func ]
4546 if ( engine . isData ( method , func ) ) return true
4647 if ( ! engine . methods [ func ] ) throw new Error ( `Method '${ func } ' was not found in the Logic Engine.` )
47- if ( engine . methods [ func ] . traverse === false ) return typeof engine . methods [ func ] [ Sync ] === 'function' ? engine . methods [ func ] [ Sync ] ( lower , buildState ) : engine . methods [ func ] [ Sync ]
48+ if ( engine . methods [ func ] . lazy ) return typeof engine . methods [ func ] [ Sync ] === 'function' ? engine . methods [ func ] [ Sync ] ( lower , buildState ) : engine . methods [ func ] [ Sync ]
4849 return typeof engine . methods [ func ] [ Sync ] === 'function' ? engine . methods [ func ] [ Sync ] ( lower , buildState ) : engine . methods [ func ] [ Sync ] && isSyncDeep ( lower , engine , buildState )
4950 }
5051
@@ -121,7 +122,7 @@ const defaultMethods = {
121122 min : ( data ) => Math . min ( ...data ) ,
122123 in : ( [ item , array ] ) => ( array || [ ] ) . includes ( item ) ,
123124 preserve : {
124- traverse : false ,
125+ lazy : true ,
125126 method : declareSync ( ( i ) => i , true ) ,
126127 [ Sync ] : ( ) => true
127128 } ,
@@ -182,7 +183,7 @@ const defaultMethods = {
182183
183184 return engine . run ( onFalse , context , { above } )
184185 } ,
185- traverse : false
186+ lazy : true
186187 } ,
187188 '<' : ( args ) => {
188189 if ( args . length === 2 ) return args [ 0 ] < args [ 1 ]
@@ -289,7 +290,7 @@ const defaultMethods = {
289290 if ( Array . isArray ( data ) && data . length ) return `(${ data . map ( ( i ) => buildString ( i , buildState ) ) . join ( ' || ' ) } )`
290291 return `(${ buildString ( data , buildState ) } ).reduce((a,b) => a||b, false)`
291292 } ,
292- traverse : false
293+ lazy : true
293294 } ,
294295 '??' : defineCoalesce ( ) ,
295296 try : defineCoalesce ( downgrade ) ,
@@ -319,7 +320,7 @@ const defaultMethods = {
319320 }
320321 return item
321322 } ,
322- traverse : false ,
323+ lazy : true ,
323324 deterministic : ( data , buildState ) => isDeterministic ( data , buildState . engine , buildState ) ,
324325 compile : ( data , buildState ) => {
325326 if ( ! buildState . engine . truthy [ OriginalImpl ] ) {
@@ -352,7 +353,6 @@ const defaultMethods = {
352353 const result = defaultMethods . val . method ( key , context , above , engine , Unfound )
353354 return result !== Unfound
354355 } ,
355- traverse : true ,
356356 deterministic : false
357357 } ,
358358 val : {
@@ -444,7 +444,7 @@ const defaultMethods = {
444444 all : createArrayIterativeMethod ( 'every' , true ) ,
445445 none : {
446446 [ Sync ] : ( data , buildState ) => isSyncDeep ( data , buildState . engine , buildState ) ,
447- traverse : false ,
447+ lazy : true ,
448448 // todo: add async build & build
449449 method : ( val , context , above , engine ) => {
450450 return ! defaultMethods . some . method ( val , context , above , engine )
@@ -580,7 +580,7 @@ const defaultMethods = {
580580 defaultValue
581581 )
582582 } ,
583- traverse : false
583+ lazy : true
584584 } ,
585585 '!' : ( value , _1 , _2 , engine ) => Array . isArray ( value ) ? ! engine . truthy ( value [ 0 ] ) : ! engine . truthy ( value ) ,
586586 '!!' : ( value , _1 , _2 , engine ) => Boolean ( Array . isArray ( value ) ? engine . truthy ( value [ 0 ] ) : engine . truthy ( value ) ) ,
@@ -598,7 +598,6 @@ const defaultMethods = {
598598 return res
599599 } ,
600600 deterministic : true ,
601- traverse : true ,
602601 optimizeUnary : true ,
603602 compile : ( data , buildState ) => {
604603 if ( typeof data === 'string' ) return JSON . stringify ( data )
@@ -611,7 +610,7 @@ const defaultMethods = {
611610 } ,
612611 keys : ( [ obj ] ) => typeof obj === 'object' ? Object . keys ( obj ) : [ ] ,
613612 pipe : {
614- traverse : false ,
613+ lazy : true ,
615614 [ Sync ] : ( data , buildState ) => isSyncDeep ( data , buildState . engine , buildState ) ,
616615 method : ( args , context , above , engine ) => {
617616 if ( ! Array . isArray ( args ) ) throw new Error ( 'Data for pipe must be an array' )
@@ -638,7 +637,7 @@ const defaultMethods = {
638637 }
639638 } ,
640639 eachKey : {
641- traverse : false ,
640+ lazy : true ,
642641 [ Sync ] : ( data , buildState ) => isSyncDeep ( Object . values ( data [ Object . keys ( data ) [ 0 ] ] ) , buildState . engine , buildState ) ,
643642 method : ( object , context , above , engine ) => {
644643 const result = Object . keys ( object ) . reduce ( ( accumulator , key ) => {
@@ -744,7 +743,7 @@ function defineCoalesce (func) {
744743 }
745744 return `(${ buildString ( data , buildState ) } ).reduce((a,b) => ${ funcCall } (a) ?? b, null)`
746745 } ,
747- traverse : false
746+ lazy : true
748747 }
749748}
750749
@@ -814,7 +813,7 @@ function createArrayIterativeMethod (name, useTruthy = false) {
814813
815814 return buildState . compile `(${ selector } || [])[${ name } ]((i, x, z) => ${ useTruthyMethod } (${ method } (i, x, ${ aboveArray } )))`
816815 } ,
817- traverse : false
816+ lazy : true
818817 }
819818}
820819defaultMethods [ '?:' ] = defaultMethods . if
0 commit comments