UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

31 lines (30 loc) 1.01 kB
/** * Generic string type but with the given prefix prepended to it. * * @category String * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export type WithPrefix<Prefix extends string> = `${Prefix}${string}`; /** * Adds a prefix to a string if it does not already exist. * * @category String * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function addPrefix<const Prefix extends string>({ value, prefix, }: { value: unknown; prefix: Prefix; }): WithPrefix<Prefix>; /** * Removes a prefix from a string if it exists. * * @category String * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function removePrefix<const Prefix extends string>({ value, prefix, }: { value: string; prefix: Prefix; }): string;