Files
pulse-libs/projetos/@pulse-libs/core/dist/utils/index.d.mts
T
pulse-agent bbdb68a6de feat(lib-core): biblioteca atomica @pulse-libs/core v1.0.0-beta.1
Esta commit conteudo a estrutura atomica completa:

- types:     Result<T,E>, AsyncState<T>, Paginated<T>, SortConfig<T>
- utils:     date, str, num, cn, debounce, throttle, storage, arr, obj
- validators: Zod schemas — email, password, uuid, url, phone, CPF/CNPJ, sanitizedStr, safeParse
- hooks:     useToggle, useAsync, useDebounce, useLocalStorage, useMedia, useInterval, useOnClickOutside, useClipboard, useFetch
- components: Button, Input, Alert, Card, Spinner (atomic design pattern)
- build:     tsup v8 ESM+CJS + DTS + sourcemaps — 0 erros
- tests:     57 testes 100% usuarios
- docker:    multi-stage Dockerfile (node 20-alpine)
- config:    vitest, tsup, tsconfig strict, .npmignore

Filosofia atomica:/utils ← /types ← /validators ← /hooks ← /components
Build: npm run build | Test: npm test | Publish: npm publish

🤖 Generated with Pulse (openclaw + nova-self-improver)
2026-05-19 21:43:03 -03:00

48 lines
1.9 KiB
TypeScript

/**
* @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 };