Created
May 10, 2024 00:53
-
-
Save igorcaldeira/fe6dc7195e15d62a4858f0e8318a6cf1 to your computer and use it in GitHub Desktop.
JS Function to format a string based on mask (with imask)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how to use :) | |
// mask: "(00) 0 0000-0000" | |
// input: "31999699601" | |
// result: "(31) 9 9969-9606" | |
export const maskContent = (mask, input) => { | |
const m = IMask.createMask({ | |
mask, | |
}); | |
m.resolve(input); | |
return m.value; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment