0.4.0 • Published 9 months ago

@radicjs/utils v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@radicjs/utils

Installation

npm i @radicjs/utils
yarn add @radicjs/utils

Declaration

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

StFile% Stmts% Branch% Funcs% LinesUncovered Line #s
🟔All files69.3739.136069.28
🟢 Toposort.ts90.985.717590.6942,50,151-153
🟢 camelCase.ts100100100100
🟢 cloneDeep.ts1001000100
🟢 kebabCase.ts100100100100
🟢 kindOf.ts100100100100
🟢 merge.ts1001000100
šŸ”“Ā obj.ts29.412.7712.528.5714,43,54-66,77-127
🟢 snakeCase.ts100100100100
🟢 startCase.ts100100100100
🟢 str.ts80.4363.6371.4281.81100-101,112-115,127-129
🟢 wait.ts100100100100

License:

MIT License

Author:

Robin Radic

Repository:

GitHub - robinradic/radicjs

0.4.0

9 months ago

0.3.1

9 months ago

0.3.0

9 months ago

0.2.0

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago