
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
mask-any-number
Advanced tools
Apply flexible numeric masks to any string. Perfect for phone numbers, documents, and custom input formatting.
A lightweight, flexible number-masking library — supports multiple mask patterns and automatically picks the best fit based on the input length.
npm install mask-any-number
or
yarn add mask-any-number
import { maskNumber, countries } from 'mask-any-number';
// Germany 🇩🇪
maskNumber('493012345678', countries.find(country => country.iso2 === 'DE').masks);
// "+49 30 1234 5678"
// Brazil 🇧🇷
maskNumber('5511998765432', countries.find(country => country.iso2 === 'BR').masks);
// "+55 11 99876 5432"
// US 🇺🇸
maskNumber('1234567890', countries.find(country => country.iso2 === 'US').masks);
// "(123) 456-7890"
import { maskNumber } from 'mask-any-number';
// Basic usage
maskNumber('1234567890', ['000-000-0000']); // "123-456-7890"
// Multiple masks, chooses first that fits
maskNumber('12345', ['000-000', '00000']); // "12345"
maskNumber('123456', ['000-000', '00000']); // "123-456"
### Phone Numbers
// US: (XXX) XXX-XXXX
maskNumber('1234567890', ['(000) 000-0000']); // "(123) 456-7890"
// Europe (DE): +49 XX XXXX XXXX
maskNumber('493012345678', ['+49 00 0000 0000']); // "+49 30 1234 5678"
// China: +86 10 1234 5678
maskNumber('861012345678', ['+86 00 0000 0000']); // "+86 10 1234 5678"
Parameter | Type | Description |
---|---|---|
value | string | Input numeric string to mask |
masks | string[] | Array of mask patterns using 0 as digit placeholder |
Return: string
— formatted number according to the first mask that fits.
Type | Input | Mask | Output |
---|---|---|---|
US Phone | 1234567890 | (000) 000-0000 | (123) 456-7890 |
EU Phone | 493012345678 | +49 00 0000 0000 | +49 30 1234 5678 |
CN Phone | 861012345678 | +86 00 0000 0000 | +86 10 1234 5678 |
const examples = [
{ value: '1234567890', masks: ['000-000-0000'] },
{ value: '31122025', masks: ['00/00/0000'] },
];
examples.forEach(({ value, masks }) => {
console.log(maskNumber(value, masks));
});
Use multiple masks to handle variable-length numbers.
Keep 0 as the digit placeholder; all other characters are treated as literals.
Ideal for phone numbers, dates, IDs, and other numeric inputs.
npm run build
npm link
Use multiple masks to handle variable-length numbers.
Keep 0 as the digit placeholder; all other characters are treated as literals.
Ideal for phone numbers, dates, IDs, and other numeric inputs.
npm run build
npm link
npm link mask-any-number
⚠️ After the initial link, you only need to run npm run build when updating the library.
Gabriel GitHub
MIT © 2025
FAQs
Apply flexible numeric masks to any string. Perfect for phone numbers, documents, and custom input formatting.
The npm package mask-any-number receives a total of 169 weekly downloads. As such, mask-any-number popularity was classified as not popular.
We found that mask-any-number demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.