UNPKG

@mos-connection/helper

Version:

Helper functions for the MOS-connection library

41 lines 2.34 kB
import { AnyXMLObject, AnyXMLValue, AnyXMLValueSingular } from '@mos-connection/model'; /** * Ensures that the returned value is an array. * If the input is not an array, it will be wrapped in an array. */ export declare function ensureArray<A, B>(v: A | B | B[]): (A | B)[]; export declare function ensureArray<T>(v: T | T[]): T[]; /** * Ensures that the returned value is a string literal. * If the input value is not of the correct type, will throw (if strict) or return the fallback value. */ export declare function ensureStringLiteral<T extends string>(xmlValue: AnyXMLValue, options: T[], strict: boolean, fallback: T): T; /** * Ensures that the returned value is a string. * If the input value is not of the correct type, will throw (if strict) or return the fallback value. */ export declare function ensureString(value: AnyXMLValue, strict: boolean, fallback?: string): string; /** * Ensures that the returned value is an object. * If the input value is not of the correct type, will throw (if strict) or return the fallback value. */ export declare function ensureXMLObject(value: AnyXMLValue, strict: boolean, fallback?: AnyXMLObject): AnyXMLObject; /** * Ensures that the returned value is a singular value (ie a string or undefined). * If the input value is not of the correct type, will throw (if strict) or return the fallback value. */ export declare function ensureSingular(value: AnyXMLValue, strict: boolean): AnyXMLValueSingular; /** * Ensures that the returned value is an array containing only singular values * If the input value is not of the correct type, will throw (if strict) or return an empty array */ export declare function ensureSingularArray(value: AnyXMLValue, strict: boolean): AnyXMLValueSingular[]; /** * Ensures that the returned value is an array containing only XMLObjects * If the input value is not of the correct type, will throw (if strict) or return an empty array */ export declare function ensureXMLObjectArray(value: AnyXMLValue, strict: boolean): AnyXMLObject[]; export declare function isSingular(value: AnyXMLValue): value is AnyXMLValueSingular; export declare function isSingularArray(value: AnyXMLValue): value is AnyXMLValueSingular[]; export declare function isXMLObject(value: AnyXMLValue): value is AnyXMLObject; //# sourceMappingURL=ensureMethods.d.ts.map