Skip to content

Commit 96217bf

Browse files
committed
Overload the getFormattedNumber utility
1 parent 1891209 commit 96217bf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export const cleanInput = (input: any, pattern: string) => {
3636
return Array.from(pattern, c => input[0] === c || slots.has(c) ? input.shift() || c : c);
3737
}
3838

39-
export const getFormattedNumber = (rawValue: any, pattern: string) => {
39+
export const getFormattedNumber = (rawValue: any, pattern?: string) => {
4040
/** Returns the reformatted input value based on the given pattern */
41+
pattern = pattern || getMetadata(rawValue)?.[3] || "";
4142
return displayFormat(cleanInput(rawValue, pattern.replaceAll(/\d/g, ".")).join(""));
4243
}
4344

0 commit comments

Comments
 (0)