export const truncateWallet: (wallet: string, preDigits: number, postDigits: number | undefined) => string = (wallet: string, preDigits: number, postDigits = preDigits) => `${wallet.slice(0, preDigits)}...${wallet.slice(-(postDigits + 1), -1)}`;
export const isNumber = (s: string) => /^[0-9]+$/.test(s);

export const sanitize = (s: string) => {
  const chars = {
    '&': '&amp;',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#x27;',
    '/': '&#x2F;',
  } as {[key: string]: string};
  return s.replace(/[&<>"'/]/ig, (match) => chars[match]);
};
