import { sprintf } from 'sprintf-js' ; returns { String } export function spanAllZeroes ( s ) { return s . replace ( /(0+)/g , '<span class="zero">$1</span>' ) ; } returns { String } export function spanAll ( s , offset = 0 ) { const letters = s . split ( '' ) ; return letters . map ( ( n , i ) => sprintf ( '<span class="digit value-%s position-%d">%s</span>' , n , i + offset , spanAllZeroes ( n ) ) ) . join ( '' ) ; } function spanLeadingZeroesSimple ( group ) { return group . replace ( /^(0+)/ , '<span class="zero">$1</span>' ) ; } returns { String } export function spanLeadingZeroes ( address ) { const groups = address . split ( ':' ) ; return groups . map ( ( g ) => spanLeadingZeroesSimple ( g ) ) . join ( ':' ) ; } returns { String } export function simpleGroup ( addressString , offset = 0 ) { const groups = addressString . split ( ':' ) ; return groups . map ( ( g , i ) => { if ( /group-v4/ . test ( g ) ) { return g ; } return sprintf ( '<span class="hover-group group-%d">%s</span>' , i + offset , spanLeadingZeroesSimple ( g ) ) ; } ) ; }