mirror of
https://github.com/tenrok/maska.git
synced 2026-06-20 20:00:34 +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++
|
iv++
|
||||||
} else if (token && token.repeat) {
|
} else if (token && token.repeat) {
|
||||||
const maskCharPrev = mask[im - 1]
|
const tokenPrev = tokens[mask[im - 1]]
|
||||||
const tokenPrev = tokens[maskCharPrev]
|
if (tokenPrev && !tokenPrev.pattern.test(valueChar)) {
|
||||||
if (token && token.repeat && tokenPrev && !tokenPrev.pattern.test(valueChar)) {
|
|
||||||
im++
|
im++
|
||||||
} else {
|
} else {
|
||||||
im--
|
im--
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ test('12 #!#(#)', () => {
|
|||||||
expect(mask('12', '#!#(#)', tokens)).toBe('1#(2)')
|
expect(mask('12', '#!#(#)', tokens)).toBe('1#(2)')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('12 #!!#', () => {
|
||||||
|
expect(mask('12', '#!!#', tokens)).toBe('1!2')
|
||||||
|
})
|
||||||
|
|
||||||
test('12 +1 #', () => {
|
test('12 +1 #', () => {
|
||||||
expect(mask('12', '+1 #', tokens)).toBe('+1 2')
|
expect(mask('12', '+1 #', tokens)).toBe('+1 2')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user