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