UNPKG

2 kBTypeScriptView Raw
1/**
2 * Use this symbol to define a custom serializer for your instances.
3 * Serializer must be a function returning a string (see {@link WithToStringMethod}).
4 *
5 * @remarks Since 2.17.0
6 * @public
7 */
8export declare const toStringMethod: unique symbol;
9/**
10 * Interface to implement for {@link toStringMethod}
11 *
12 * @remarks Since 2.17.0
13 * @public
14 */
15export declare type WithToStringMethod = {
16 [toStringMethod]: () => string;
17};
18/**
19 * Check if an instance implements {@link WithToStringMethod}
20 *
21 * @remarks Since 2.17.0
22 * @public
23 */
24export declare function hasToStringMethod<T>(instance: T): instance is T & WithToStringMethod;
25/**
26 * Use this symbol to define a custom serializer for your instances.
27 * Serializer must be a function returning a promise of string (see {@link WithAsyncToStringMethod}).
28 *
29 * Please note that:
30 * 1. It will only be useful for asynchronous properties.
31 * 2. It has to return barely instantly.
32 *
33 * @remarks Since 2.17.0
34 * @public
35 */
36export declare const asyncToStringMethod: unique symbol;
37/**
38 * Interface to implement for {@link asyncToStringMethod}
39 *
40 * @remarks Since 2.17.0
41 * @public
42 */
43export declare type WithAsyncToStringMethod = {
44 [asyncToStringMethod]: () => Promise<string>;
45};
46/**
47 * Check if an instance implements {@link WithAsyncToStringMethod}
48 *
49 * @remarks Since 2.17.0
50 * @public
51 */
52export declare function hasAsyncToStringMethod<T>(instance: T): instance is T & WithAsyncToStringMethod;
53/**
54 * Convert any value to its fast-check string representation
55 *
56 * @param value - Value to be converted into a string
57 *
58 * @remarks Since 1.15.0
59 * @public
60 */
61export declare function stringify<Ts>(value: Ts): string;
62/**
63 * Convert any value to its fast-check string representation
64 *
65 * This asynchronous version is also able to dig into the status of Promise
66 *
67 * @param value - Value to be converted into a string
68 *
69 * @remarks Since 2.17.0
70 * @public
71 */
72export declare function asyncStringify<Ts>(value: Ts): Promise<string>;