UNPKG

topkat-utils

Version:

A comprehensive collection of TypeScript/JavaScript utility functions for common programming tasks. Includes validation, object manipulation, date handling, string formatting, and more. Zero dependencies, fully typed, and optimized for performance.

82 lines (81 loc) 3.34 kB
/// <reference types="node" /> import { Color } from './types'; export declare const logger: any; /** // console colored output // * console.log(C.green(C.dim('Hey bro !'))) // * or C.log() // will use color defined by themes // * or C.line('MY TITLE', 53) // * or C.gradientize(myLongString) */ export declare const C: { dim: (str: any) => string; green: (str: any) => string; red: (str: any) => string; yellow: (str: any) => string; grey: (str: any) => string; magenta: (str: any) => string; cyan: (str: any) => string; blue: (str: any) => string; primary: (str: any) => string; reset: string; output: (code: any, str?: string) => string; rgb: (r: any, g?: number, b?: number) => string; bg: (r?: any, g?: any, b?: any) => string; /** Output a line of title */ line(title?: string, length?: number, clr?: Color, char?: string): void; /** Eg: ['cell1', 'cell2', 'cell3'], [25, 15] will start cell2 at 25 and cell 3 at 25 + 15 * @param {Array} limits default divide the viewport */ cols(strings: any, limits?: number[], clr?: Color): void; /** Console log alias */ log(...stringsCtxMayBeFirstParam: any[]): void; logClr(str: any, clr?: Color): void; info(...str: any[]): void; success(...str: any[]): void; /** First param **false** to avoid logging stack trace */ error: (...errors: any[]) => any; /** First param **false** to avoid logging stack trace */ warning: (...str: any[]) => any; customError: (color: any, ...str: any[]) => any; customWarning: (color: any, ...str: any[]) => any; applicationError: (color: any, ...str: any[]) => any; warningLight: (_: any, ...str: any[]) => any; dimStrSplit(...logs: any[]): string; notifShow(): void; /** Keep in memory the logs to show when needed with C.notifShow() * Ex: C.notification('info', str); */ notification(type: any, ...messages: any[]): void; notifications: any[]; /** Gratientize lines of text (separated by \n) */ gradientize(str?: string, rgb1?: Color, rgb2?: Color, bgRgb?: Color, paddingY?: number): void; debugModeLog(title: any, ...string: any[]): void; /** allow to clear the last lines written to console */ clearLastLines(n?: number): void; }; /** * Call this at each steps of your progress and change the step value * @param {Number} step Number of "char" to output * @param {String} char Default: '.' * @param {String} msg String before char. Final output will be `${str}${char.repeat(step)}` */ export declare function cliProgressBar(step: number, char?: string, msg?: string): void; type loadingSpinnerTypes = 'arrow' | 'dots'; /** This allow an intuitive inline loading spinner with a check mark when loading as finished or a red cross for errors */ export declare class cliLoadingSpinner { /** Please use it like spinner.start('myStuff') then spinner.end() * @param {String} type in: ['arrow', 'dots'] */ frameRate: number; animFrames: string[]; activeProcess: any; frameNb: number; progressMessage: string; interval: any; constructor(type?: loadingSpinnerTypes, activeProcess?: NodeJS.Process); start(msg: any): void; end(error?: boolean): void; error(): void; } export declare function dim(str?: string): string; export {};