I got tired of hand-rolling PII redaction for logs, so I built it into a small text utility package
Описание и применение
Маленькая библиотека TypeScript, позволяющая автоматически маскировать электронные адреса и номера телефонов в логах без использования тяжёлых NLP‑решений.
Задача
Developers often need to mask emails and phone numbers in logs or support tickets, but existing solutions are either heavyweight NLP libraries or paid APIs, leaving a gap for a lightweight, dependency-free utility.
Результат
The library offers a lightweight, zero-dependency solution for masking emails and phone numbers in free-form text, reducing manual regex work and improving consistency.
Рабочий процесс
- 1. Install textconvert via npm.
- 2. Import
redactfrom the library. - 3. Call
redactwith the text to mask, optionally passing options for types or maskChar. - 4. Receive the masked string with PII replaced by asterisks or custom characters.
Доказательства
It scans free-form text — not just a single known value — and masks every email and phone number it finds, in place, leaving everything else untouched.
redact finds matches with extractEmails (and an equivalent internal scanner for phone numbers), then masks each one with maskText.
- Дата записи: 2026-09-09T22:30:58.200Z