Usage

Examples

import { mask } from 'node-masker'
const value = 'ABC1C83'
const pattern = 'AAA - 9S99'
mask(value, pattern)
// ABC - 1C83

Pattern can be a pattern array, so remask choose one pattern based on pattern/value length match

const patterns = ['999.999.999-99', '99.999.999/9999-99']
mask('12345678901', patterns) // gets firts pattern (999.999.999-99)
// 123.456.789-01
mask('12345678000106', patterns) // gets second pattern (99.999.999/9999-99)
// 12.345.678/0001-06

More Examples

import { mask } from 'node-masker'
// Converts value to masked phone
mask(1099911111, "(99) 9999-9999"); // -> (10) 9991-1111
// Converts value to masked date
mask(12122000, "99/99/9999"); // -> 12/12/2000
// Converts value to masked document
mask(99911111101, "999.999.999-99"); // -> 999.111.111-01
// Converts value to masked car plate
mask('ABC1234', "AAA-9999"); // -> ABC-1234
// Converts value to masked vehicle identification
mask('9BGRD08X04G117974', "SS.SS.SSSSS.S.S.SSSSSS"); // -> 9B.GR.D08X0.4.G.117974
/* Pass in an optional placeholder option to represent remaining
characters to be entered */
mask('4', {pattern: "(999) 999-9999", placeholder: "x"}); // -> (4xx) xxx-xxxx