mirror of
https://github.com/tenrok/maska.git
synced 2026-05-15 11:59:38 +03:00
Cleanup of mask.js code
This commit is contained in:
+2
-3
@@ -16,9 +16,8 @@ export default function mask (value, mask, tokens, masked = true) {
|
||||
}
|
||||
iv++
|
||||
} else if (token && token.repeat) {
|
||||
const maskCharPrev = mask[im - 1]
|
||||
const tokenPrev = tokens[maskCharPrev]
|
||||
if (token && token.repeat && tokenPrev && !tokenPrev.pattern.test(valueChar)) {
|
||||
const tokenPrev = tokens[mask[im - 1]]
|
||||
if (tokenPrev && !tokenPrev.pattern.test(valueChar)) {
|
||||
im++
|
||||
} else {
|
||||
im--
|
||||
|
||||
@@ -45,6 +45,10 @@ test('12 #!#(#)', () => {
|
||||
expect(mask('12', '#!#(#)', tokens)).toBe('1#(2)')
|
||||
})
|
||||
|
||||
test('12 #!!#', () => {
|
||||
expect(mask('12', '#!!#', tokens)).toBe('1!2')
|
||||
})
|
||||
|
||||
test('12 +1 #', () => {
|
||||
expect(mask('12', '+1 #', tokens)).toBe('+1 2')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user