import { Stream } from '../../../stream/Stream'; /** * A `Shrinkable` holds an internal value of type `T` * and can shrink it to smaller `TShrink` values * * @public */ export declare class Shrinkable { readonly value_: T; readonly shrink: () => Stream>; /** * State storing the result of hasCloneMethod * If `true` the value will be cloned each time it gets accessed */ readonly hasToBeCloned: boolean; /** * Flag indicating whether or not the this.value has already been called once * If so, the underlying will be cloned * Only set when hasToBeCloned = true */ private readOnce; /** * Safe value of the shrinkable * Depending on `hasToBeCloned` it will either be `value_` or a clone of it */ readonly value: T; /** * @param value - Internal value of the shrinkable * @param shrink - Function producing Stream of shrinks associated to value */ constructor(value_: T, shrink?: () => Stream>); /** * Create another shrinkable by mapping all values using the provided `mapper` * Both the original value and the shrunk ones are impacted * * @param mapper - Map function, to produce a new element based on an old one * @returns New shrinkable with mapped elements */ map(mapper: (t: T) => U): Shrinkable; /** * Create another shrinkable * by filtering its shrunk values against `predicate` * * All the shrunk values produced by the resulting `Shrinkable` * satisfy `predicate(value) == true` * * WARNING: * When using refinement - `(t: T) => t is U` - only the shrunk values are ensured to be of type U. * The type of the current value of the Shrinkable is your responsability. * * @param refinement - Predicate, to test each produced element. Return true to keep the element, false otherwise * @returns New shrinkable filtered using predicate */ filter(refinement: (t: TShrink) => t is U): Shrinkable; /** * Create another shrinkable * by filtering its shrunk values against `predicate` * * All the shrunk values produced by the resulting `Shrinkable` * satisfy `predicate(value) == true` * * @param predicate - Predicate, to test each produced element. Return true to keep the element, false otherwise * @returns New shrinkable filtered using predicate */ filter(predicate: (t: TShrink) => boolean): Shrinkable; }