import type { Terminator, TypeGuard } from "../../../types/concepts.mjs"; import type { CloneDeepFn } from "./schema.mjs"; export interface SearchCloneRequest { target: T; payload: P; } export interface SearchCloneResponse { cloned: T; payload: P; } export interface SearchCloneDeepPlugin { /** * The name of plugin, also plugin id. */ name: string; /** * The filter function to filter plugin inputs. */ filter: TypeGuard; /** * Determine how to create a cloned object. * A target object can be only created once. * Call the `skip` terminator function to tell that this plugin cannot create a curresponding new object. * @param original original object * @param skip terminator */ createObject?(original: T, skip: Terminator): T; /** * Determine how toclone deep the data of object. * If the plugin does not make contribution to get data of an object, just return an empty array. * @param original original object */ enumerateDataToClone?(original: T): Iterable>; /** * Determin how to connect the deep cloned data to the new object. * @param newObject cloned new object * @param response cloned data and previous clone request payload */ connectClonedData?(newObject: T, response: SearchCloneResponse): void; } declare type GeneralCloneDeepPlugin = SearchCloneDeepPlugin; export declare class CloneDeepBuilder { #private; constructor(); withSearch(search: "bfs" | "dfs"): this; withPlugin(plugin: GeneralCloneDeepPlugin): this; build(): CloneDeepFn; } interface JSONCloneDeepPluginPayload { descriptor: PropertyDescriptor; key: PropertyKey; } /** * The json clone deep plugin only supports: * Array (prototype === `Array.prototype`) * Simple object (prototype === `null` || prototype === `Object.prototype`) * With this plugin only, you can just clone where `JSON.parse(JSON.stringify(obj))` can! */ export declare class JSONCloneDeepPlugin implements SearchCloneDeepPlugin { name: string; filter: TypeGuard; createObject(original: object, skip: Terminator): object; enumerateDataToClone(original: object): Iterable>; connectClonedData(newObject: object, clonedData: SearchCloneResponse): void; } /** * In addition to the json plugin, this plugin includes user defined class. * Any instance of the constructors on global object will not be considered. */ export declare class CustomClassCloneDeepPlugin extends JSONCloneDeepPlugin { #private; name: string; createObject(original: object, skip: Terminator): object; } export declare class DateCloneDeepPlugin implements SearchCloneDeepPlugin { name: string; filter: TypeGuard; createObject(original: Date): Date; } export declare class SetCloneDeepPlugin implements SearchCloneDeepPlugin> { name: string; filter: TypeGuard>; createObject(): Set; enumerateDataToClone(original: Set): Iterable>; connectClonedData(newObject: Set, response: SearchCloneResponse): void; } interface MapCloneDeepPluginPayload { entry: [unknown, unknown]; map: WeakMap<[unknown, unknown], unknown>; } export declare class MapCloneDeepPlugin implements SearchCloneDeepPlugin, MapCloneDeepPluginPayload> { name: string; filter: TypeGuard>; createObject(): Map; enumerateDataToClone(original: Map): Iterable>; connectClonedData(newObject: Map, response: SearchCloneResponse): void; } export {}; //# sourceMappingURL=search-clone-deep.d.mts.map