import formatToCNPJ from './formatToCNPJ' ; import formatToCPF from './formatToCPF' ; param value const canFormatToCPF = ( value ) : boolean => ( value . match ( /\d/g ) ?. length ?? 0 ) <= 11 ; example param value const formatToCPFOrCNPJ = ( value ) : string => canFormatToCPF ( value ) ? formatToCPF ( value ) : formatToCNPJ ( value ) ; export default formatToCPFOrCNPJ ;