import { get } from '../../collections'; import { isFunction, type Path, type PathToType, type Stringable, type Trim, type UnionToIntersection } from '../../types'; /** * Type of a value that will be used to replace a placeholder in a template. */ export type TemplateValue = Stringable | string; /** * Type of a fallback value when a template key is not found. */ export type TemplateFallback = string | ((key: string) => string); /** * Type of a template string with placeholders. */ const TEMPLATE_PLACEHOLDER = /\{\s*([^{}]+?)\s*\}/gm; /** * Removes the placeholder syntax from a template string. * * @example * type Base = ClearPlaceholder<'{user.name}'>; // 'user.name' * type Unbalanced = ClearPlaceholder<'{user.name'>; // 'user.name' * type Spaces = ClearPlaceholder<'{ user.name }'>; // 'user.name' */ export type ClearPlaceholder = In extends `${string}{${infer Template}` ? ClearPlaceholder