import { IMix } from '../../typings' ; import { createFullMatch , createUnitMatch } from '../const/regs' ; export const useMix = ( rule , val ) => { if ( rule . type === '&' ) { const vals = val . split ( /\s+/ ) ; for ( let i = 0 ; i < vals . length ; i ++ ) { const v = rule . unit [ i ] ; if ( ! createFullMatch ( v ) . test ( vals [ i ] ) ) { return false ; } } return true ; } else { let _val = val ; for ( let i = rule . unit . length ; i -- ; ) { const reg = createUnitMatch ( rule . unit [ i ] ) ; _val = _val . replace ( reg , ' ' ) ; } return ! _val . trim ( ) ; } } ;