1.2.2 • Published 12 months ago
remask v1.2.2
A lightweight, dependency free and framework agnostic multi-mask lib, with Typescript support.
Install
yarn add remask
Usage
import { mask } from 'remask'
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
and you can use unmask
function to remove any mask pattern:
unmask('12.345.678/0001-06')
// => 12345678000106
Currency
In currency mask, Remask use Intl.NumberFormater to mask and unmask values, so you need pass locale and currency params.
import { currency } from 'remask'
currency.mask({ locale: 'pt-BR', currency: 'BRL', value: 123456.78 })
// => R$ 123.456,78
currency.unmask({ locale: 'pt-BR', currency: 'BRL', value: 'R$ 123.456,78' })
// => 123456.78
License
MIT © Bruno Bertolini
1.2.0
12 months ago
1.1.0
12 months ago
1.0.1
1 year ago
1.0.0
1 year ago
1.2.2
12 months ago
1.2.1
12 months ago
0.1.0-alpha.5
5 years ago
0.1.0-alpha.4
5 years ago
0.1.0-alpha.3
5 years ago
0.1.0-alpha.2
5 years ago
0.1.0-alpha.1
5 years ago
0.1.0-alpha.0
5 years ago
0.0.0
6 years ago