Skip to content

Instantly share code, notes, and snippets.

@igorcaldeira
Created May 10, 2024 00:53
Show Gist options
  • Save igorcaldeira/fe6dc7195e15d62a4858f0e8318a6cf1 to your computer and use it in GitHub Desktop.
Save igorcaldeira/fe6dc7195e15d62a4858f0e8318a6cf1 to your computer and use it in GitHub Desktop.
JS Function to format a string based on mask (with imask)
// 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