UNPKG

3.33 kBTypeScriptView Raw
1import { ClassType } from "./ClassTransformer";
2import { ClassTransformOptions } from "./ClassTransformOptions";
3export { ClassTransformer } from "./ClassTransformer";
4export { ClassTransformOptions } from "./ClassTransformOptions";
5export * from "./metadata/ExposeExcludeOptions";
6export * from "./decorators";
7/**
8 * Converts class (constructor) object to plain (literal) object. Also works with arrays.
9 */
10export declare function classToPlain<T>(object: T, options?: ClassTransformOptions): Object;
11export declare function classToPlain<T>(object: T[], options?: ClassTransformOptions): Object[];
12/**
13 * Converts class (constructor) object to plain (literal) object.
14 * Uses given plain object as source object (it means fills given plain object with data from class object).
15 * Also works with arrays.
16 */
17export declare function classToPlainFromExist<T>(object: T, plainObject: Object, options?: ClassTransformOptions): Object;
18export declare function classToPlainFromExist<T>(object: T, plainObjects: Object[], options?: ClassTransformOptions): Object[];
19/**
20 * Converts plain (literal) object to class (constructor) object. Also works with arrays.
21 */
22export declare function plainToClass<T, V>(cls: ClassType<T>, plain: V[], options?: ClassTransformOptions): T[];
23export declare function plainToClass<T, V>(cls: ClassType<T>, plain: V, options?: ClassTransformOptions): T;
24/**
25 * Converts plain (literal) object to class (constructor) object.
26 * Uses given object as source object (it means fills given object with data from plain object).
27 * Also works with arrays.
28 */
29export declare function plainToClassFromExist<T, V>(clsObject: T[], plain: V[], options?: ClassTransformOptions): T[];
30export declare function plainToClassFromExist<T, V>(clsObject: T, plain: V, options?: ClassTransformOptions): T;
31/**
32 * Converts class (constructor) object to new class (constructor) object. Also works with arrays.
33 */
34export declare function classToClass<T>(object: T, options?: ClassTransformOptions): T;
35export declare function classToClass<T>(object: T[], options?: ClassTransformOptions): T[];
36/**
37 * Converts class (constructor) object to plain (literal) object.
38 * Uses given plain object as source object (it means fills given plain object with data from class object).
39 * Also works with arrays.
40 */
41export declare function classToClassFromExist<T>(object: T, fromObject: T, options?: ClassTransformOptions): T;
42export declare function classToClassFromExist<T>(object: T, fromObjects: T[], options?: ClassTransformOptions): T[];
43/**
44 * Serializes given object to a JSON string.
45 */
46export declare function serialize<T>(object: T, options?: ClassTransformOptions): string;
47export declare function serialize<T>(object: T[], options?: ClassTransformOptions): string;
48/**
49 * Deserializes given JSON string to a object of the given class.
50 */
51export declare function deserialize<T>(cls: ClassType<T>, json: string, options?: ClassTransformOptions): T;
52/**
53 * Deserializes given JSON string to an array of objects of the given class.
54 */
55export declare function deserializeArray<T>(cls: ClassType<T>, json: string, options?: ClassTransformOptions): T[];
56/**
57 * Enum representing the different transformation types.
58 */
59export declare enum TransformationType {
60 PLAIN_TO_CLASS = 0,
61 CLASS_TO_PLAIN = 1,
62 CLASS_TO_CLASS = 2
63}