UNPKG

@dwp/govuk-casa

Version:

A framework for building GOVUK Collect-And-Submit-Applications

117 lines (116 loc) 3.35 kB
/** * @typedef {import("../casa").GlobalHook | import("../casa").PageHook} Hook * @access private */ /** * Determine if value is empty. Recurse over objects. * * @param {any} val Value to check * @returns {boolean} True if the object is empty * @access private */ export function isEmpty(val: any): boolean; /** * Test is a value can be stringified (numbers or strings) * * @param {any} value Item to test * @returns {boolean} Whether the value is stringable or not * @access private */ export function isStringable(value: any): boolean; /** * Extract the middleware functions that are relevant for the given hook and * path. * * @param {string} hookName Hook name (including scope prefix) * @param {string} path URL path to match (relative to mountUrl) * @param {Hook[]} hooks Hooks to be applied at the page level * @returns {Function[]} An array of middleware that should be applied * @access private */ export function resolveMiddlewareHooks(hookName: string, path: string, hooks?: Hook[]): Function[]; /** * Coerce an input to a string. * * @param {any} input Input to be stringified * @param {string} fallback Fallback to use if input can't be stringified * @returns {string} The stringified input * @access private */ export function stringifyInput(input: any, fallback: string, ...args: any[]): string; /** * Coerce an input to an integer. * * @param {any} input Input to be coerced. * @returns {number | undefined} The number as an integer or `undefined`. */ export function coerceInputToInteger(input: any): number | undefined; /** * Strip whitespace from a string. * * @param {string} value Value to be stripped of whitespace * @param {object} options Overrides for the default whitespace replacements * @returns {string} Value stripped of white space * @throws {TypeError} * @access private */ export function stripWhitespace(value: string, options: object): string; /** * Checks if the given string can be used as an object key. * * @param {string} key Proposed Object key * @returns {string} Same key if it's valid * @throws {Error} If proposed key is an invalid keyword * @access private */ export function notProto(key: string): string; /** * Validate a hook name. * * @param {string} hookName Hook name * @returns {void} * @throws {TypeError} * @throws {SyntaxError} * @access private */ export function validateHookName(hookName: string): void; /** * Validate a hook path. * * @param {string} path URL path * @returns {void} * @throws {TypeError} * @access private */ export function validateHookPath(path: string): void; /** * Validate a URL path. * * @param {string} path URL path * @returns {string} Same string, if valid * @throws {TypeError} * @throws {SyntaxError} * @access private */ export function validateUrlPath(path: string): string; /** * Validate a template name. * * @param {string} view Template name * @returns {void} * @throws {TypeError} * @throws {SyntaxError} * @access private */ export function validateView(view: string): void; /** * Validate a waypoint. * * @param {string} waypoint Waypoint * @returns {void} * @throws {TypeError} * @throws {SyntaxError} * @access private */ export function validateWaypoint(waypoint: string): void; export type Hook = import("../casa").GlobalHook | import("../casa").PageHook;