Handy functions
// Default import
const gokit = require('gokit');
// Named import
const {cap} = require('gokit');
// Default import
import gokit from 'gokit';
// Named import
import {cap} from 'gokit';
-
cap(str:string)
Converts first letter to uppercase
const str = 'some string'; console.log(cap(str)); // Some string
-
fcap(str: string)
Converts first letter of each string to uppercase
const str = 'some string'; console.log(fcap(str)); // Some String
-
ftrim(str: string)
Removes all extra spaces
const str = ' some string '; console.log(ftrim(str)); // some string
-
fname(str: string)
Breaks fullname into 3 parts (firstname, middlename, lastname). Returns an object with keys (first, middle, last). Removes all extra spaces and converts all letters to lowercase.
const fullname = ' Mike John Doe Ali '; console.log(fname(fullname)) // output ⬇️ { first: 'mike', middle: 'john doe', last: 'ali' }