(source: string, next: string)
| 411 | * @returns The longest overlapping edge, or an empty string if none exists. |
| 412 | */ |
| 413 | export function suffixPrefixOverlap(source: string, next: string): string { |
| 414 | for (let len = next.length; len >= 0; len--) { |
| 415 | const prefix = next.slice(0, len) |
| 416 | if (source.endsWith(prefix)) { |
| 417 | return prefix |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | return '' |
| 422 | } |
| 423 | |
| 424 | export const escapeString = (str: string) => { |
| 425 | return JSON.stringify(str).slice(1, -1) |