mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
25 lines
630 B
TypeScript
25 lines
630 B
TypeScript
import { logger } from '../logger';
|
|
|
|
// Return true if the match string is found at index in content
|
|
export function matchAt(
|
|
content: string,
|
|
index: number,
|
|
match: string
|
|
): boolean {
|
|
return content.substring(index, index + match.length) === match;
|
|
}
|
|
|
|
// Replace oldString with newString at location index of content
|
|
export function replaceAt(
|
|
content: string,
|
|
index: number,
|
|
oldString: string,
|
|
newString: string
|
|
): string {
|
|
logger.trace(`Replacing ${oldString} with ${newString} at index ${index}`);
|
|
return (
|
|
content.substr(0, index) +
|
|
newString +
|
|
content.substr(index + oldString.length)
|
|
);
|
|
}
|