web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

index.ts (537B)


      1 export const root_symbol = "ยป`,-";
      2 
      3 export function text_enc(data: string): Uint8Array {
      4     return new TextEncoder().encode(data);
      5 }
      6 
      7 export function text_dec(data: Uint8Array): string {
      8     return new TextDecoder().decode(data);
      9 }
     10 
     11 export const str_cap = (val?: string): string => {
     12     if (!val) return ``;
     13     return `${val[0].toUpperCase()}${val.slice(1)}`;
     14 };
     15 
     16 export const str_cap_words = (val?: string): string => {
     17     if (!val) return ``;
     18     return val.split(` `).map(i => i ? str_cap(i) : ``).filter(i => !!i).join(` `);
     19 };