File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
packages/n4s/src/plugins/compounds Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1+ import { equals } from 'equals' ;
12import type { Lazy } from 'genEnforceLazy' ;
2- import { lengthEquals } from 'lengthEquals' ;
3- import { longerThan } from 'longerThan' ;
3+ import { greaterThan } from 'greaterThan' ;
44import ruleReturn , { RuleDetailedResult } from 'ruleReturn' ;
55import runLazyRule from 'runLazyRule' ;
66
77const REQUIRED_COUNT = 1 ;
88
99export function oneOf ( value : unknown , ...rules : Lazy [ ] ) : RuleDetailedResult {
10- const passing : RuleDetailedResult [ ] = [ ] ;
10+ let passingCount = 0 ;
1111 rules . some ( rule => {
1212 const res = runLazyRule ( rule , value ) ;
1313
1414 if ( res . pass ) {
15- passing . push ( res ) ;
15+ passingCount ++ ;
1616 }
1717
18- if ( longerThan ( passing , REQUIRED_COUNT ) ) {
18+ if ( greaterThan ( passingCount , REQUIRED_COUNT ) ) {
1919 return false ;
2020 }
2121 } ) ;
2222
23- return ruleReturn ( lengthEquals ( passing , REQUIRED_COUNT ) ) ;
23+ return ruleReturn ( equals ( passingCount , REQUIRED_COUNT ) ) ;
2424}
You can’t perform that action at this time.
0 commit comments