Masking emails? Obvious. Tokens? Critical. But names? Somehow they always sneak into logs, dashboards, exports—fully visible like it’s no big deal. Until it is. Names are still personal data, and once they’re everywhere, good luck cleaning that up. That’s exactly where mask-name comes in: a tiny, zero-dependency utility to mask names properly across Latin and CJK (Chinese/Japanese) scripts, without breaking readability or context.
1. Basic usage (Latin names)
import { maskName } from "@ekaone/mask-name";
maskName("Eka Prasetia");
// → { masked: "E*a P*****ia", script: "latin", original: "Eka Prasetia" }
You still recognize the person. You just don’t expose the full name to the world. That’s the sweet spot.
2. CJK support (this is where it gets interesting)
maskName("张伟");
// → { masked: "张*", script: "cjk", original: "张伟" }
maskName("田中さくら", { locale: "ja" });
// → { masked: "田**くら", script: "cjk", original: "田中さくら" }
No hacks, no weird splitting logic. It understands character-based names out of the box.
3. Real-world messy input (mixed scripts)
maskName("John 田中");
// → { masked: "J**n 田*", script: "cjk", original: "John 田中" }
Because real data is never clean. And yes, this still works without you babysitting it.
That’s it — keep it simple
If your app logs names, shows user data, or exports anything remotely sensitive, this is one of those utilities.
Wanna try, install it 👇🏼
npm install @ekaone/mask-name
# or
yarn add @ekaone/mask-name
# or
pnpm add @ekaone/mask-name
👉 Codebase: https://github.com/ekaone/mask-name
Small, predictable, and does exactly what it should—no more, no less.
Happy coding!😄
Top comments (0)