Mimic the Presidio anonymizer's default `replace`: each span → ` `.
(text: string, results: Span[])
| 13 | |
| 14 | /** Mimic the Presidio anonymizer's default `replace`: each span → `<ENTITY_TYPE>`. */ |
| 15 | function applyReplace(text: string, results: Span[]): string { |
| 16 | let out = text |
| 17 | for (const s of [...results].sort((a, b) => b.start - a.start)) { |
| 18 | out = `${out.slice(0, s.start)}<${s.entity_type}>${out.slice(s.end)}` |
| 19 | } |
| 20 | return out |
| 21 | } |
| 22 | |
| 23 | /** Analyzer mock: flags `a@b.com` as EMAIL_ADDRESS when that entity is in scope. */ |
| 24 | function emailSpans(text: string, entities: string[] | undefined): Span[] { |