UNPKG

@n1k1t/mock-server

Version:

The ultimate toolkit to intercept, transform, and simulate HTTP/WS traffic with type-safe expectations

38 lines 1.12 kB
export declare const cast: <T>(payload: T) => T; export declare const wait: (ms: number) => Promise<void> & { value: number; abort: () => void; }; /** * @example * ```ts * const counter = buildCounter(5); * * counter() // 6 * counter() // 7 * counter(2) // 9 * ``` */ export declare const buildCounter: (initial?: number, step?: number) => (value?: number) => number; export declare const serializeRegExp: (exp: RegExp) => Pick<RegExp, "source" | "flags">; export declare const parseJsonSafe: <T extends object>(serializedJson: string) => { readonly status: "OK"; readonly result: T; readonly error?: undefined; } | { readonly status: "ERROR"; readonly error: Error; readonly result?: T; }; /** Joins propeties arrays and renames keys to lower case */ export declare const formatHeaders: (headers: object) => Record<string, string>; /** * Cuts massive string to a cunks with limited length * * @example * ```ts * cut('foobarbaz', 3) // ['foo', 'bar', 'baz'] * ``` */ export declare const cut: (value: string, length: number) => string[]; //# sourceMappingURL=common.d.ts.map