rt-tools
v0.1.74
Published
Package uses Angular Signals (Angular 16+).
Downloads
1,159
Readme
Set of utility types and functions for TypeScript
Package uses Angular Signals (Angular 16+).
Interfaces & Types
IDictionary
IntersectionType
Modify
IMapper
Nullable
PartialOmit
Primitive
- Makes selected props from a record optional
Optional
- Get the union type of all the values in an object, array or array-like type
ValuesType
Functions
isDateValid(date?: Date): boolean;
dateStringToDate(date: string | Date): Date;
- Indicates if the arguments are equal
isEqual<T>(f: T, s: T): boolean;
- Indicates if the content of two arrays is identical
areArraysEqual<T>(f: T[], s: T[]): boolean;
- Indicates if the content of two arrays is identical
areObjectsEqual<T>(f: T, s: T): boolean;
isNumber<T>(value: T | number | unknown | undefined): value is number;
initToday(): Date;
isToday(date: Date): boolean;
- Make shallow copy of passed object
removeFieldFromObject<T extends object, K extends string>(obj: T, key: K): Omit<T, K>;
- Allow to compare two values by provided comparator
safeCompare<T>(a: T, b: T, comparator: ComparatorType<T>): number;
- Allow to safely compare two string values
safeStrCompare(a: string, b: string): number;
- Allow to safely compare two number values
safeNumCompare(a: number, b: number): number;
- Allow composing comparison chain of several comparators that delegate comparison by the chain to the next comparators if current comparator returns 0
safeComparatorPipe(...comparators: Array<() => number>): number;
sortByAlphabet: <T extends object>(a: T, b: T, field: keyof T) => number;
sortByDate: (a: { [field: string]: any }, b: { [field: string]: any }, field: string) => number
stringifyHttpLikeParams<T extends {}>(params: T): { [param: string]: string | string[] }
transformArrayInput<T>(array: unknown): T[]