1- import { pipe , asyncMap , asyncCollectArray , every , zip , take , range , collectSet } from "@hyperjump/pact" ;
1+ import { pipe , asyncMap , asyncCollectArray , zip } from "@hyperjump/pact" ;
22import * as Browser from "@hyperjump/browser" ;
33import * as Instance from "../lib/instance.js" ;
44import { Validation } from "../lib/experimental.js" ;
@@ -23,23 +23,35 @@ const interpret = (items, instance, context) => {
2323 return true ;
2424 }
2525
26+ let isValid = true ;
27+ let index = 0 ;
28+
2629 if ( typeof items === "string" ) {
27- return every ( ( itemValue ) => Validation . interpret ( items , itemValue , context ) , Instance . iter ( instance ) ) ;
30+ for ( const item of Instance . iter ( instance ) ) {
31+ if ( ! Validation . interpret ( items , item , context ) ) {
32+ isValid = false ;
33+ }
34+
35+ context . evaluatedItems ?. add ( index ++ ) ;
36+ }
2837 } else {
29- return pipe (
30- zip ( items , Instance . iter ( instance ) ) ,
31- take ( Instance . length ( instance ) ) ,
32- every ( ( [ prefixItem , item ] ) => Validation . interpret ( prefixItem , item , context ) )
33- ) ;
38+ for ( const [ tupleItem , tupleInstance ] of zip ( items , Instance . iter ( instance ) ) ) {
39+ if ( ! tupleInstance ) {
40+ break ;
41+ }
42+
43+ if ( ! Validation . interpret ( tupleItem , tupleInstance , context ) ) {
44+ isValid = false ;
45+ }
46+
47+ context . evaluatedItems ?. add ( index ) ;
48+ index ++ ;
49+ }
3450 }
51+
52+ return isValid ;
3553} ;
3654
3755const simpleApplicator = true ;
3856
39- const collectEvaluatedItems = ( items , instance , context ) => {
40- return interpret ( items , instance , context ) && ( typeof items === "string"
41- ? collectSet ( range ( 0 , Instance . length ( instance ) ) )
42- : collectSet ( range ( 0 , items . length ) ) ) ;
43- } ;
44-
45- export default { id, compile, interpret, simpleApplicator, collectEvaluatedItems } ;
57+ export default { id, compile, interpret, simpleApplicator } ;
0 commit comments