mask-js

2.1.0 • Public • Published

mask-js build status Code Coverage License NPM version

mask-js

A library that exposes functions to masks strings. To use it, it's pretty simple. First, you need to install it:

npm i mask-js

Then, you can import its functions and use at will:

import {maskJs, maskCurrency} from 'mask-js';
 
console.log(maskJs('(99) 99', '0123456') === '(01) 23'); // true
console.log(maskCurrency('12345') === 123.45); // true

The library also supports optional digits. For example:

import maskJs from 'mask-js';
 
console.log(maskJs('(99) 9999?9', '0123456') === '(01) 23456'); // true
console.log(maskJs('(99) 999-9?9', '012345') === '(01) 234-5'); // true
console.log(maskJs('(99) 99?9-9?9', '012345') === '(01) 23-45'); // true
console.log(maskJs('(99) 9999?9-9999', '0123456789') === '(01) 2345-6789'); // true
console.log(maskJs('(99) 9999?9-9999', '01234567890') === '(01) 23456-7890'); // true

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i mask-js

    Weekly Downloads

    793

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    23.1 kB

    Total Files

    21

    Last publish

    Collaborators

    • brunokrebs