/remask

A lightweight, dependency free and framework agnostic multi-mask lib, with Typescript support.

Primary LanguageTypeScriptMIT LicenseMIT

.github/workflows/ci.yml

reMask

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

License

MIT © Bruno Bertolini