1
- import { pipe , asyncMap , asyncCollectArray , every , zip , take , range , collectSet } from "@hyperjump/pact" ;
1
+ import { pipe , asyncMap , asyncCollectArray , zip } from "@hyperjump/pact" ;
2
2
import * as Browser from "@hyperjump/browser" ;
3
3
import * as Instance from "../lib/instance.js" ;
4
4
import { Validation } from "../lib/experimental.js" ;
@@ -23,23 +23,35 @@ const interpret = (items, instance, context) => {
23
23
return true ;
24
24
}
25
25
26
+ let isValid = true ;
27
+ let index = 0 ;
28
+
26
29
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
+ }
28
37
} 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
+ }
34
50
}
51
+
52
+ return isValid ;
35
53
} ;
36
54
37
55
const simpleApplicator = true ;
38
56
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