@dev.arlamend7/js-ts
Version:
A lib of typescript to help any programer
85 lines (65 loc) • 1.84 kB
Markdown
# Javascript && Typescript
I use a jest library to test all functions
It`s a package with some extensions, functions and others things.
Everything that a use almost every day.
I'll create a c# library too.
## Common
#### Extensions providers by this package
```ts
interface Array<T> {
Distinct(): T[];
isNullOrEmpty(): boolean;
Sum(map?: (arg: T, index: number) => number, startValue?: number): number;
Max(map?: (arg: T, index: number) => number): number;
Min(map?: (arg: T, index: number) => number): number;
Remove(elem: (arg: T) => Boolean): void;
}
interface Date {
SameAs(Date: Date): boolean;
isBeetween(dateStart: Date, dateEnd: Date): boolean;
}
interface Number {
[Symbol.iterator]: () => Generator<number, void, number[]>;
}
interface String {
RemoveAccents(): string;
isNullOrWhiteSpace(): boolean;
JustNumbers(): string;
}
```
#### functions
```ts
function debounce(fn: Function, milissegundos: number, ...args: any[]): () => void;
function Paginar<T>(array: T[], request?: PaginacaoRequest): PaginacaoResponse<T>;
```
## Utils
```ts
function isRequired: (value: any) => never;
class Validator {
CPF(str: string): boolean;
CNPJ(str: string): boolean;
CellPhone(str: string): boolean;
}
class Formatter {
get CONST_REGEX(): {
CPF: RegExp;
CNPJ: RegExp;
CELLPHONE: RegExp;
};
CPF(text: string): string;
CNPJ(text: string): string;
CellPhone(text: string): string;
}
```
## Web
```ts
class NotificationService {
notifications: Map<string, Notification>;
addNotification(key: string, Title: string, options?: NotificationOptions): void;
Notify(notification: globalThis.Notification): void;
NotifyByKey(key: string): void;
}
```