UNPKG

votcore

Version:

Vot Kit for Valensas Bots

59 lines (58 loc) 2.3 kB
import * as Joi from 'joi'; export * from './logger'; export * from './debug'; import { UrlPayload } from './../types'; /** * adds val in between every elements of array * state: [a, b, c] val: d * result: [a,d,b,d,c] */ export declare function addBetween(state: string[], val: any): string[]; /** * Gets the title and description of a page by parsing its index.html * * @returns Promise<UrlPayload | null> Resolves to null in case of errors otherwise resolves to UrlPayload */ export declare function getUrlTitleAndDescription(url: string): Promise<UrlPayload | null>; /** * Validates a JOI schema. Rejects the promise if validation fails. Resolves to modified version of the input (e.g defaults applied) * * @returns Promise<boolean> Promise of validation result */ export declare function validate(object: {} | undefined, schema: Joi.ObjectSchema): Promise<typeof object>; /** * Validates a JOI schema. Returns [error, value] where value is the modified version of the input (e.g defaults applied) * * @returns Promise<boolean> Promise of validation result */ export declare function validateFunctional(object: {} | undefined, schema: Joi.ObjectSchema): Promise<[{}, typeof object]>; /** * Validates a JOI schema. Resolves to true if validation passes else resolves to false. * * @returns Promise<boolean> Promise of validation result */ export declare function validateBoolean(object: {} | undefined, schema: Joi.ObjectSchema): Promise<boolean>; /** * Validates a single value using JOI. Resolves to true if validation passes else resolves to false. * * @returns Promise<boolean> Promise of validation result */ export declare function is(input: any, type: Joi.Schema): Promise<boolean>; /** * Converts a [Promise<[a, b]>, Promise<[c, d]>] to Promise<{ a: b, c: d}> * * @returns Promise<{ [t: string]: any }> An object created from pairs */ export declare function fromPairsPromise(pairs: Promise<[string, any]>[]): Promise<{ [t: string]: any; }>; /** * If the input is a value, puts it into an array otherwise returns the array. */ export declare function arrayify<I>(input: I | I[]): I[]; /** * Inverts keys and values of an object. If multiple keys have the same value, last key wins. */ export declare function inverseMap(map: {}): { [t: string]: any; };