msk
Small library to mask strings
Install
$ npm install msk
Usage
const msk = ; // "+55 (21) 2222-2222" msk// "22231-000"
API
msk(str, mask)
Returns a formatted string based on the mask prodived
str
Type: string
A string to apply the mask.
mask
Type: string
A mask is formed based on the following symbols:
Symbol | Accepts |
---|---|
9 |
Numbers ([0-9] ) |
A |
Letters ([A-ú] ) |
S |
Alphanumeric chars ([A-ú0-9] ) |
* |
Anything |
other char | Specified char |
msk.fit(str, mask)
Returns a formatted string removing the exceeding characters.
Examples
// "+55 (21) 2222-2222"
// "V6G 1C9"
// "I-love-msk"
msk// "22231-000"
License
MIT © VTEX