@@ -49,6 +49,8 @@ export const styleVariables: any = {
4949
5050export const filterById = ( array = [ ] , id : string ) => array . filter ( item => item . _id !== id ) ;
5151
52+ export const itemsShown = ( paginator : any ) => Math . min ( paginator . length - ( paginator . pageIndex * paginator . pageSize ) , paginator . pageSize ) ;
53+
5254export const isInMap = ( tag : string , map : Map < string , boolean > ) => map . get ( tag ) ;
5355
5456export const mapToArray = ( map : Map < string , boolean > , equalValue ?) => {
@@ -79,26 +81,9 @@ export const urlToParamObject = (url: string) => url.split(';').reduce((params,
7981
8082export const toProperCase = ( string : string ) => `${ string . slice ( 0 , 1 ) . toUpperCase ( ) } ${ string . slice ( 1 ) } ` ;
8183
82- export const itemsShown = ( paginator ?: { length : number ; pageIndex : number ; pageSize : number } ) => {
83- if ( ! paginator ) {
84- return 0 ;
85- }
86- const remaining = paginator . length - ( paginator . pageIndex * paginator . pageSize ) ;
87- return Math . min ( Math . max ( remaining , 0 ) , paginator . pageSize ) ;
88- } ;
89-
9084export const stringToHex = ( string : string ) => string . split ( '' ) . map ( char => char . charCodeAt ( 0 ) . toString ( 16 ) ) . join ( '' ) ;
9185
92- export const hexToString = ( hex : string ) => {
93- if ( ! hex ) {
94- return '' ;
95- }
96- const matches = hex . match ( / .{ 1 , 2 } / g) ;
97- if ( ! matches ) {
98- return '' ;
99- }
100- return matches . map ( byte => String . fromCharCode ( parseInt ( byte , 16 ) ) ) . join ( '' ) ;
101- } ;
86+ export const hexToString = ( string : string ) => string . match ( / .{ 1 , 2 } / g) . map ( hex => String . fromCharCode ( parseInt ( hex , 16 ) ) ) . join ( '' ) ;
10287
10388export const ageFromBirthDate = ( currentTime : number , birthDate : string ) => {
10489 const now = new Date ( currentTime ) ;
0 commit comments