Getting Started
Try It Online
You can try MaskIO directly in your browser on StackBlitz.
Installation
MaskIO can be installed into an existing project. you can install it with:
sh
$ npm add -D maskio
sh
$ pnpm add -D maskio
sh
$ yarn add -D maskio
Use Case
ts
import { maskText, maskObject } from 'maskio';
/** 字符串掩码 */
const text = maskText('1234567890123456', 'bankCard') // '************3456'
const sourceObject = {
firstCode: '123456',
otherCode: {
resultCode: '123',
name: '小明',
},
};
const config = { '^.*Code$': 'all', '^otherCode\.name$': 'userName' }
/** 对象掩码 */
const object = maskObject(sourceObject, config) // '{"firstCode":"******","otherCode":{"resultCode":"***","name":"*明"}}'
TIP
A proficient understanding of regular expressions is required.