@dotup/dotup-ts-types
Version:
Typescript types and helper
28 lines (27 loc) • 1.69 kB
TypeScript
import { PropertyNamesOnly, TypedProperty } from "./types";
export declare class ObjectTools {
static get<T>(obj: object, path: string): T;
/**
* The classes must use the toStringTag symbol.
*/
static isInstanceOf<T>(value: any, instanceOf: {
new (): any;
}): value is T;
static GetMethodNames(obj: any, ...excluded: string[]): string[];
static hasMethod<T>(obj: T, name: string): boolean;
static GetOwnMethodNames<T>(instance: any, ...excluded: string[]): string[];
static GetValue<T, K extends keyof T>(obj: T, key: K): T[K];
static CopyNullProps<TSource, Props extends PropertyNamesOnly<TSource>, TTarget extends Pick<TSource, Props>>(source: TSource, ...props: Props[]): TTarget;
static CopyProps<TSource, Props extends PropertyNamesOnly<TSource>, TTarget extends Pick<TSource, Props>>(source: TSource, ...props: Props[]): TTarget;
static OmitProps<TSource, Props extends PropertyNamesOnly<TSource>, TTarget extends Omit<TSource, Props>>(source: TSource, ...props: Props[]): TTarget;
static CopyEachSource<TSource, TTarget>(source: TSource, target: TTarget): TTarget;
static CopyEachTarget<TSource, TTarget>(source: TSource, target: TTarget): TTarget;
static DeepMerge<T>(source: Partial<T>, target: Partial<T>): void;
static DeepEquals<T>(source: T, target: T): boolean;
static DeepMerge2<T>(source: Partial<T>, target: Partial<T>): any;
static DeepCopy<T>(obj: T): T;
static ObjectFromArray<T extends {
[Key in K]: string;
}, // This is required for the reduce to work
K extends PropertyNamesOnly<T>>(array: Array<T>, indexKey: K): TypedProperty<T>;
}