Rocky_Mountain_Vending/.pnpm-store/v10/files/6e/8018e2d54242edf46d35e84412797afe821cf19b8c962b4efb41d6b06f3668b7689b7fdb2f1f8febe69922e145eb8bcf06bca6abc0290f67ce624dd1ecaa47
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

85 lines
2 KiB
Text

import type {ApplyDefaultOptions} from './internal';
type ReplaceOptions = {
all?: boolean;
};
type DefaultReplaceOptions = {
all: false;
};
/**
Represents a string with some or all matches replaced by a replacement.
Use-case:
- `kebab-case-path` to `dotted.path.notation`
- Changing date/time format: `01-08-2042` → `01/08/2042`
- Manipulation of type properties, for example, removal of prefixes
@example
```
import {Replace} from 'type-fest';
declare function replace<
Input extends string,
Search extends string,
Replacement extends string
>(
input: Input,
search: Search,
replacement: Replacement
): Replace<Input, Search, Replacement>;
declare function replaceAll<
Input extends string,
Search extends string,
Replacement extends string
>(
input: Input,
search: Search,
replacement: Replacement
): Replace<Input, Search, Replacement, {all: true}>;
// The return type is the exact string literal, not just `string`.
replace('hello ?', '?', '🦄');
//=> 'hello 🦄'
replace('hello ??', '?', '❓');
//=> 'hello ❓?'
replaceAll('10:42:00', ':', '-');
//=> '10-42-00'
replaceAll('__userName__', '__', '');
//=> 'userName'
replaceAll('My Cool Title', ' ', '');
//=> 'MyCoolTitle'
```
@category String
@category Template literal
*/
export type Replace<
Input extends string,
Search extends string,
Replacement extends string,
Options extends ReplaceOptions = {},
> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
type _Replace<
Input extends string,
Search extends string,
Replacement extends string,
Options extends Required<ReplaceOptions>,
Accumulator extends string = '',
> = Search extends string // For distributing `Search`
? Replacement extends string // For distributing `Replacement`
? Input extends `${infer Head}${Search}${infer Tail}`
? Options['all'] extends true
? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`>
: `${Head}${Replacement}${Tail}`
: `${Accumulator}${Input}`
: never
: never;