UNPKG

clonus

Version:

Ultimate object cloning library.

43 lines (42 loc) 1.77 kB
import { CloneConfig } from "./cloneConfig"; import { Cloner } from "./cloner"; import { CloneContext } from "./cloneContext"; export declare const SelfClone: unique symbol; export declare const GetSelfCloner: unique symbol; /** * Will clone {@link input}. * * @param input Input to be cloned. * @param options Optional options to influence the cloning operations. See {@link CloneConfig}. * @returns Cloned value/object of {@link input}. */ export declare function makeClone<T>(input: T, options?: { config?: CloneConfig; setupConfig?: (x: CloneConfig) => void; }): T; /** * Will clone {@link input}. * * @param input Input to be cloned. * @param context Contextual information about cloning operation. See {@link CloneContext}. * @returns Cloned value/object of {@link input}. */ export declare function makeContextualClone<T>(input: T, context: CloneContext): T; /** * The basic implementation of object cloning operation. * * @param input Input (object) to be cloned. * @param context Contextual information about cloning operation. See {@link CloneContext}. * @returns Cloned object of {@link input}. */ export declare function makeBasicObjectClone<T extends object>(input: T, context: CloneContext): T; export declare function cloneObjectKeys<T extends object>(original: T, result: T, context: CloneContext): void; /** * Will resolve proper cloner for specified {@link input}. * If no cloner is eligible, the NULL is returned. * * @param input Input supposed to be cloned. * @param context Contextual information about cloning operation. See {@link CloneContext}. * @returns NULL or cloner supposed to be used to clone the specified {@link input}. */ export declare function resolveCloner<T>(input: T, context: CloneContext): Cloner;