uttype
v0.11.0
Published
Tiny helper library with some useful functions / types.
Downloads
21
Readme
uttype
Tiny helper library with some useful functions / types.
Types
assert
AssertTrue
AssertFalse
built-in extra
OmitByType
PickByType
PickReadonly
OmitReadonly
PartialByKey
RequiredByKey
DeepPartial
DeepRequired
ExtractOptional
ExtractNonNullable
OmitKeys
union
RecordValues
Functions
entries
function entries<T extends Recordable>(obj: T): [keyof T, T[keyof T]][]
entriesFind
function entriesFind<T extends Recordable = Recordable>(obj: T, predicate: (item: [keyof T, T[keyof T]]) => boolean): [keyof T, T[keyof T]] | undefined
oneOf
function oneOf<T extends unknown[] = unknown[]>(value: T[number], values: T): value is T[number]
debounce
function debounce<F extends (...args: any[]) => any>(func: F, wait: number): F
throttle
function throttle<F extends (...args: any[]) => any>(func: F, limit: number): F
loop
function loop<T>(arr: T[], callback: (item: T, index: number) => void): void
rangeLoop
function rangeLoop(start: number, end: number, callback: (index: number) => void): void
loopAsync
function loopAsync<T>(arr: T[], callback: (item: T, index: number) => Promise<void>): void
mapObject
function mapObject<T extends Recordable, V>(obj: T, cb: (value: T[keyof T], key: keyof T) => V): { [key in keyof T]: V; }
omitKeys
function omitKeys<T extends object, K extends keyof T>(obj: T, keys: K[]): Prettify<OmitKeys<T, K>>
removeNullishFields
function removeNullishFields<T extends object>(obj: T): ExtractNonNullable<T>
License
MIT