Files
pulse-libs/projetos/@pulse-libs/core/dist/utils/index.d.mts
T
Pulse Agent 0889ee9117 feat(lib): add useLiveStream WS hook + useLiveMetrics + LiveMetricChart
feat(hooks): add useLiveStream generic WebSocket hook
  - supports websocket/sse/polling transports
  - exponential backoff reconnect with jitter
  - circular buffer with configurable size
  - typed filter callback per use case
  - manual disconnect + reconnect + error state

feat(hooks): add useLiveMetrics derived hook
  - sliding time-window cut
  - moving average (configurable window)
  - current / avg / min / max / ratePerSecond
  - zero allocations per tick (memoized)

feat(charts): add LiveMetricChart molecule (Recharts)
  - line + area variants, grid + tooltip
  - moving-average overlay (dashed)
  - ConnectionStatus atom in header
  - status bar + compact mode
  - 100% responsive, GPU via SVG ViewBox

feat(atoms): add ConnectionStatus indicator
  - 5 states: disconnected/connecting/connected/reconnecting/error
  - animated pulse, JetBrains Mono, pill style
  - exported helpers: formatLatency / formatBytes

docs(pkg): bump v0.1.0 → v0.2.0, add recharts peerDep
2026-05-20 22:59:10 -03:00

48 lines
1.9 KiB
TypeScript
Executable File

/**
* @pulse-libs/utils — Funções puras, zero dependências
* Usáveis em React, Vue, Node, browser
*/
declare const date: {
now: () => string;
format: (d: Date | string | number, fmt?: string) => string;
isToday: (d: Date | string) => boolean;
daysBetween: (a: Date, b: Date) => number;
};
declare const str: {
capitalize: (s: string) => string;
truncate: (s: string, max: number, suffix?: string) => string;
camelCase: (s: string) => string;
kebabCase: (s: string) => string;
slugify: (s: string) => string;
removeAccents: (s: string) => string;
maskEmail: (email: string) => string;
};
declare const num: {
clamp: (value: number, min: number, max: number) => number;
rand: (min: number, max: number) => number;
format: (n: number) => string;
percent: (part: number, total: number, decimals?: number) => number;
};
type ClassValue = string | boolean | null | undefined | Array<ClassValue>;
declare function cn(...inputs: ClassValue[]): string;
declare function debounce<T extends (...args: Parameters<T>) => void>(fn: T, ms: number): (...args: Parameters<T>) => void;
declare function throttle<T extends (...args: Parameters<T>) => void>(fn: T, ms: number): (...args: Parameters<T>) => void;
declare const storage: {
get: <T>(key: string, fallback: T) => T;
set: <T>(key: string, value: T) => void;
remove: (key: string) => void;
clear: (prefix?: string) => void;
};
declare const arr: {
unique: <T>(items: T[], key?: keyof T) => T[];
chunk: <T>(items: T[], size: number) => T[][];
shuffle: <T>(items: T[]) => T[];
};
declare const obj: {
pick: <T extends object, K extends keyof T>(o: T, keys: K[]) => Pick<T, K>;
omit: <T extends object, K extends keyof T>(o: T, keys: K[]) => Omit<T, K>;
isEmpty: (o: object | null | undefined) => boolean;
};
export { arr, cn, date, debounce, num, obj, storage, str, throttle };