Small library to mask strings
$ npm install msk
const msk = require("msk");
msk("552122222222", "+99 (99) 9999-9999")
// "+55 (21) 2222-2222"
msk.fit("22231-0004131", "99999-999")
// "22231-000"
Returns a formatted string based on the mask prodived
Type: string
A string to apply the 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 |
Returns a formatted string removing the exceeding characters.
msk("552122222222", "+99 (99) 9999-9999")
// "+55 (21) 2222-2222"
msk("V6G1C9", "A9A 9A9")
// "V6G 1C9"
msk("I love msk", "*-****-***")
// "I-love-msk"
msk.fit("22231-0004131", "99999-999")
// "22231-000"
MIT © VTEX