npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ekaone/masker

v0.0.4

Published

Universal masking library, detects data type and applies appropriate masking automatically. Zero dependencies. TypeScript-native.

Readme

@ekaone/masker

Universal masking library — detects data type and applies appropriate masking automatically.

Zero dependencies. TypeScript-native. Works in Node.js, Deno, Bun, and the browser.

Features

  • Auto-detectionmask(value) just works for 12 data types
  • Explicit overridemask(value, { type: 'ssn' }) when you know the type
  • Format-preserving — keeps spaces, dashes, @ symbols by default
  • Configurable — custom mask char, reveal start/end counts
  • Object helpermaskObject(obj) uses key name hints to bias detection
  • Log sanitizermaskString(text) scrubs tokens from free-form log lines
  • TypeScript-native — full types, discriminated union results

Install

npm install @ekaone/masker
# or
pnpm add @ekaone/masker

Quick Start

import { mask, detect, maskObject, maskString } from "@ekaone/masker";

// Auto-detect and mask
mask("[email protected]");
// { masked: "jo*******@example.com", type: "email", confidence: 0.98 }

mask("4111 1111 1111 1111");
// { masked: "**** **** **** 1111", type: "credit_card", confidence: 0.92 }

mask("123-45-6789");
// { masked: "***-**-6789", type: "ssn", confidence: 0.97 }

mask("(415) 867-5309");
// { masked: "(***) ***-5309", type: "phone", confidence: 0.88 }

mask("192.168.100.42");
// { masked: "192.168.***.**, type: "ip_address", confidence: 0.93 }

mask("eyJhbGci....eyJzdWI....SflKxw...");
// {
//   original: 'eyJhbGci....eyJzdWI....SflKxw...',
//   masked: 'eyJh************************w...',
//   type: 'api_key',
//   confidence: 0.6
// }

Supported Types

| Type | Example input | Strategy | |-----------------|----------------------------|---------------------------------------| | email | [email protected] | Mask local part, keep domain | | phone | (415) 867-5309 | Mask all but last 4 digits | | credit_card | 4111 1111 1111 1111 | Mask all but last 4, preserve spaces | | ssn | 123-45-6789 | Mask all but last 4 | | ip_address | 192.168.100.42 | Mask last two octets | | url | https://api.io/v1?k=abc | Preserve host, mask path/query | | jwt | aaa.bbb.ccc | Keep header, mask payload + signature | | api_key | sk-proj-abc123XYZ | Reveal first/last 4 chars | | iban | GB29NWBK601613... | Reveal country + check digits only | | passport | AB1234567 | Reveal first 2 chars | | date_of_birth | 1990-07-15 | Reveal year only | | name | Margaret Thatcher | Reveal first letter of each word | | generic | anything else | Reveal first + last char |

API

mask(value, options?): MaskResult

Auto-detect or force-type and mask a string.

interface MaskOptions {
  type?: MaskType;        // force a specific type
  revealStart?: number;   // chars to show at start (type-dependent default)
  revealEnd?: number;     // chars to show at end
  char?: string;          // mask character (default: '*')
  preserveFormat?: boolean; // keep separators (default: true)
}

interface MaskResult {
  original: string;
  masked: string;
  type: MaskType;
  confidence: number;     // 0–1
}

detect(value): { type: MaskType; confidence: number }

Identify the data type without masking.

detect("[email protected]"); // { type: "email", confidence: 0.98 }

maskObject(obj, options?)

Mask all string fields in a plain object. Key name hints (e.g. email, ssn, token) bias the type detection.

maskObject({
  email: "[email protected]",
  phone: "555-123-4567",
  apiKey: "sk-abc123xyz456abc",
  age: 30,                      // non-strings are untouched
});
// {
//   email: 'al***@example.com',
//   phone: '***-***-4567',
//   apiKey: 'sk-a**********6abc',
//   age: 30
// }

maskString(text, options?)

Sanitize sensitive tokens found inside a free-form string. Useful for log scrubbing.

maskString("Request from [email protected] at 192.168.1.1 token=sk-abc123def456");
// "Request from us**@example.com at 192.168.*.* token=sk-a*******f456"

Options Examples

// Custom mask character
mask("123-45-6789", { char: "•" });
// "•••-••-6789"

// Custom reveal window
mask("sk-proj-abc123XYZ789", { revealStart: 6, revealEnd: 0 });
// "sk-pro*************"

// Disable format preservation
mask("4111 1111 1111 1111", { preserveFormat: false });
// "************1111"

License

MIT © Eka Prasetia

Links