UNPKG

1.01 kBTypeScriptView Raw
1/**
2 * Generated instances having a method [cloneMethod]
3 * will be automatically cloned whenever necessary
4 *
5 * This is pretty useful for statefull generated values.
6 * For instance, whenever you use a Stream you directly impact it.
7 * Implementing [cloneMethod] on the generated Stream would force
8 * the framework to clone it whenever it has to re-use it
9 * (mainly required for chrinking process)
10 *
11 * @remarks Since 1.8.0
12 * @public
13 */
14export declare const cloneMethod: unique symbol;
15/**
16 * Object instance that should be cloned from one generation/shrink to another
17 * @remarks Since 2.15.0
18 * @public
19 */
20export interface WithCloneMethod<T> {
21 [cloneMethod]: () => T;
22}
23/**
24 * Check if an instance has to be clone
25 * @remarks Since 2.15.0
26 * @public
27 */
28export declare function hasCloneMethod<T>(instance: T | WithCloneMethod<T>): instance is WithCloneMethod<T>;
29/**
30 * Clone an instance if needed
31 * @remarks Since 2.15.0
32 * @public
33 */
34export declare function cloneIfNeeded<T>(instance: T): T;