UNPKG

@ssv/core

Version:

Core utilities, components and services for browser and node

34 lines (33 loc) 1.5 kB
import { Dictionary } from "./collection"; /** * parseBool configuration to add/remove possible values. * * @type {Dictionary<boolean>} */ export declare const PARSE_BOOL_CONFIG: Dictionary<boolean>; /** * Interpolates the string with the data specified by using the prefix (:) default as token. * e.g. 'api/:lang/games' => 'api/en/games' * @param {string} value string template to interpolate * @param {*} data data object to replace tokens * @param {string} [interpolatePrefix=":"] interpolation token prefix * @returns {string} string interpolated */ export declare function interpolate(value: string, data: any, interpolatePrefix?: string): string; /** * Parses a value to boolean "humanized", which can also be configured in order to add additional values. e.g. * true => `"true"`, `"1"`, `"yes"`, `"y"`, `"on"` * false => `"false"`, `"0"`, `"no"`, `"n"`, `"off"` or non existent. * @param value value to parse * @returns `true`, `false` */ export declare function parseBool(value: string | boolean | number | null | undefined): boolean; /** * Replaces all occurrences with a string with the specified value. * * @param {string} value value to search within * @param {string} search value to search for e.g. "//" * @param {string} replacement value to replace with e.g. "/" * @returns {string} Returns string with the replaced values */ export declare function replaceAll(value: string, search: string | RegExp, replacement: string): string;