UNPKG

f5-conx-core

Version:

F5 SDK for JavaScript with Typescript type definitions

61 lines (60 loc) 1.82 kB
import { AxiosResponseWithTimings } from './httpModels'; /** * delays async response of function * https://stackoverflow.com/questions/38956121/how-to-add-delay-to-promise-inside-then * @param ms time to wait * @param value value to return */ export declare function wait<T>(ms: number, value?: T): Promise<T>; /** * validates json blob * @param json * @returns parsed json object */ export declare function isValidJson(json: string): Promise<unknown>; /** * builds a short randon uuid - just for some randomness during testing * * @param length * @example * getRandomUUID(8) // returns 8pSJP15R * */ export declare function getRandomUUID(length: number, options?: { simple: boolean; }): string; export declare function isObject(a: unknown): boolean; export declare function isArray(a: unknown): boolean; /** * Verify file against provided hash * * @param file local file location * @param hash expected SHA 256 hash * * @returns true/false based on hash verification result */ export declare function verifyHash(file: string, extensionHash: string): boolean; /** * returns simplified http response object * * ```ts * return { * data: resp.data, * headers: resp.headers, * status: resp.status, * statusText: resp.statusText, * request: { * uuid: resp.config.uuid, * baseURL: resp.config.baseURL, * url: resp.config.url, * method: resp.request.method, * headers: resp.config.headers, * protocol: resp.config.httpsAgent.protocol, * timings: resp.request.timings * } * } * ``` * @param resp orgininal axios response with timing * @returns simplified http response */ export declare function simplifyHttpResponse(resp: AxiosResponseWithTimings): Promise<AxiosResponseWithTimings>;