Registry / productivity / mascaration

mascaration

JSON →
library1.0.0jsnpmunverified

String formatter library for applying and removing masks (e.g., phone, ZIP code) with support for multiple mask patterns and automatic best-match selection. Current stable version: 1.0.0 (no recent updates). TypeScript definitions included. Lightweight alternative to libraries like `cleave.js` or `imask`; focus on simplicity and type safety.

npm install mascaration
INSTALL
IMPORT
SIG · MASCARATION
M
mascaration
productivityjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

formatter
import { formatter } from 'mascaration'
import formatter from 'mascaration'
Named import, not default. ESM/CJS compatible.
unmask
import { unmask } from 'mascaration'
const unmask = require('mascaration').unmask
Named export. CJS require works but TS prefers import.
formatter with array
formatter(['(##) #####-####', '(##) ####-####'], '21944440102')
formatter('(##) #####-####', '21944440102')
First argument can be string (single mask) or array (multiple masks). Array helps if input length varies.

Shows single mask, multiple masks with auto-detect, and unmasking.

import { formatter, unmask } from 'mascaration'; // Single mask const zip = formatter('#####-###', '88130000'); console.log(zip); // 88130-000 // Multiple masks (best match) const phone1 = formatter(['(##) #####-####', '(##) ####-####'], '2144440102'); console.log(phone1); // (21) 4444-0102 const phone2 = formatter(['(##) #####-####', '(##) ####-####'], '21944440102'); console.log(phone2); // (21) 94444-0102 // Unmask const clean = unmask('88130-000'); console.log(clean); // 88130000
Debug
Known issues
gotchaArray of masks is order-sensitive: first mask that matches length is used.
fix
Order masks from most to least restrictive pattern.
affects: >=1.0.0
gotchaMask characters: '#' represents a digit (0-9). Other characters are literals.
fix
Use '#' for each digit position; e.g., '###-###-####' for US phone.
affects: >=1.0.0
gotchaunmask only removes non-digit characters; letters or symbols in masked value may persist.
fix
Ensure input to unmask contains only digits and mask symbols.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: formatter is not a function
Default import instead of named import.
fix
Use `import { formatter } from 'mascaration'`.
Cannot find module 'mascaration'
Package not installed or typo.
fix
Run `npm install mascaration` and check spelling.
Argument of type 'string' is not assignable to parameter of type 'string[]'
Passing a single string to an array parameter.
fix
Wrap the mask in an array: `formatter(['(##) ####-####'], '1234')`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
mascaration — npm install mascaration · libregistry