0.4.0 ⢠Published 9 months ago
@radicjs/utils v0.4.0
@radicjs/utils
Installation
npm i @radicjs/utilsyarn add @radicjs/utilsDeclaration
export {
camelCase, cloneDeep, constant, debounce, flatten, get,
has, identity, isArguments, isArrayLike, isArrayLikeObject,
isBuffer, isLength, isMap, isPlainObject, isSet, isTypedArray,
kebabCase, keys, keysIn, last, lowerCase, merge, now,
pad, set, snakeCase, startCase, stubFalse, toFinite,
toInteger, toNumber, toString, unset, upperCase, words
} from 'lodash';
export * from '@radicjs/type-check';
declare function defaults<T>(obj: Partial<T>, ...defaults: Partial<T>[]): T;
declare function copy<T>(object: T): T;
declare function deepClone<T extends any = any>(obj: any, hash?: any): T;
declare function mergeDeep(source?: any, target?: any): any;
declare function dotize(obj: any, prefix?: any): any;
declare const objectify: (obj: any, [k, v]: [any, any]) => any;
declare function strRandom(length?: number): string;
declare function strEnsureLeft(str: string, left: string): string;
declare function strEnsureRight(str: string, right: string): string;
declare function strStripLeft(str: string, left: string): string;
declare function strStripRight(str: string, right: string): string;
declare function ucfirst(string: string): string;
declare function lcfirst(string: string): string;
declare function parameters(str: string, params: Record<string, string>): string;
declare function escapeStringRegexp(string: string): string;
declare function strIs(pattern: string, value: string, ignoreCase?: boolean): boolean;
declare function uuid(): string;
declare function guid(): string;
declare class Toposort {
edges: any[];
Toposort: typeof Toposort;
add(item: string, deps?: string | string[]): this;
sort(): any[];
clear(): this;
}
type Constructor<Type = any> = new (...args: any[]) => Type;
type TupleToFunction<T extends any[], R = void> = (...args: T) => R;
type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Rest extends string ? PathValue<T[K], Rest> : never : never : P extends keyof T ? T[P] : never;
type DotNotation<T, Prefix extends string = ''> = {
[K in keyof T & string]: T[K] extends Record<string, any> ? DotNotation<T[K], `${Prefix}${K}.`> | `${Prefix}${K}` : `${Prefix}${K}`;
}[keyof T & string];
type DeepPartial<T> = T extends object ? {
[P in keyof T]?: DeepPartial<T[P]>;
} : T;
declare function wait(ms: number, cycles?: number): Promise<void>;
export { type Constructor, type DeepPartial, type DotNotation, type PathValue, Toposort, type TupleToFunction, copy, deepClone, defaults, dotize, escapeStringRegexp, guid, lcfirst, mergeDeep, objectify, parameters, strEnsureLeft, strEnsureRight, strIs, strRandom, strStripLeft, strStripRight, ucfirst, uuid, wait };Size
- Total:
92.26 kB - Gzip:
33.92 kB
Coverage
| St | File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
|---|---|---|---|---|---|---|
| š” | All files | 69.37 | 39.13 | 60 | 69.28 | |
| š¢ | Ā Toposort.ts | 90.9 | 85.71 | 75 | 90.69 | 42,50,151-153 |
| š¢ | Ā camelCase.ts | 100 | 100 | 100 | 100 | |
| š¢ | Ā cloneDeep.ts | 100 | 100 | 0 | 100 | |
| š¢ | Ā kebabCase.ts | 100 | 100 | 100 | 100 | |
| š¢ | Ā kindOf.ts | 100 | 100 | 100 | 100 | |
| š¢ | Ā merge.ts | 100 | 100 | 0 | 100 | |
| š“ | Ā obj.ts | 29.41 | 2.77 | 12.5 | 28.57 | 14,43,54-66,77-127 |
| š¢ | Ā snakeCase.ts | 100 | 100 | 100 | 100 | |
| š¢ | Ā startCase.ts | 100 | 100 | 100 | 100 | |
| š¢ | Ā str.ts | 80.43 | 63.63 | 71.42 | 81.81 | 100-101,112-115,127-129 |
| š¢ | Ā wait.ts | 100 | 100 | 100 | 100 |
License:
MIT License
Author:
Robin Radic