@mauchero/helpers
v1.0.84
Published
Generic functions to help dev
Downloads
90
Readme
helpers
Generic functions to help develop all apps
to use:
npm i @mauchero/helpers
helpers
warning
- this repo is private, but the code is public in npm
- do not put sensitive/confidential information here
current functions
Shortcuts
clog(message?: any, ...optionalParams: any[])
cloj(value: any, space: string | number | undefined = 2)
cloe(message?: any, ...optionalParams: any[])
jstr(value: any, space: string | number | undefined = 2)
API Related
recordError(db: firebase.Firestore, errorInfo: any): Promise<void>
Mathematics
arraySum(array: number[]): number
round(number: number, decimals: number): number
roundFloor(number: number, decimals: number): number
roundCeil(number: number, decimals: number): number
average(array: number[]): number
getHighestBetweenTwo(value1: number, value2: number): number
getLowestBetweenTwo(value1: number, value2: number): number
intToFloat(intValue: number, decimals?: number): number
Generic
removeDuplicates(arr: any[]): any[]
copyToClipboardWeb(copyText: string): Promise<boolean>
isObjEmpty(obj: Object): boolean
openInNewTab(url: string): void
reloadPage(): void
onClickUrl(url: string): () => void
varToString(varObj: Object): string
buildMap(keys: (keyof Object)[], values: any[]): Object
isHex(hex: any): boolean
hex2Int(hex: any): number
sleep(milliseconds: number): void
string2Float(strNumber: string): number
fetchImage(imageUrl: string): Promise<void>
reorderListSmallestToLargest(oldList: any[], orderKeyParam: string): any[]
reorderListLargestToSmallest(oldList: any[], orderKeyParam: string): any[]
checkCpfNumberValidity(cpf: string): boolean
reorderListSubParam(oldList: Object[], orderKeyParam: keyof Object, orderKeySubParam: keyof Object): Object[]
Formatting Stuff
formatPrice(numFloat: number, fiatSymbol: "BRL" | "USD" = "BRL"): string
formatPercentage(numFloat: number, fractionDigits: number = 2): string
formatCpf(cpf: string): string
formatPhone(phone: string): string
formatDate(date: string): string
isDateValid(date: string): boolean
isUserMinor(birthDate: string, minAge: number): boolean
calculateAge(birthDateStr: string): number
getOnlyNumbers(str: string): string
float2INFormat(number: number, decimals: number): string
darkenHexColor(hexColor: string, factor: number): string
removeSpaces(inputString: string): string
replacePtBrCharacters(inputString: string): string
Time
secsToDateTime(secs: number): string
secsToLocaleDateTime(secs: number): string
toLongFormatDateTime(secs: number): Date
getLocalTimezoneOffset(): number
toTimestamp(strDate: string): number
adjustDateMonthToName(date: string): string
numberToMonth(month: string): string