@codexcentral/mask-text-to-symbol
v1.1.0
Published
Takes a string as input and returns a new string with all characters replaced by an specified symbol.
Downloads
3
Maintainers
Readme
mask-text-to-symbol
Takes a string as input and returns a new string with all characters replaced by an specified symbol.
Installation
npm install @codexcentral/mask-text-to-symbol
Usage
1. Importing...
import { maskTextToSymbol } from "@codexcentral/mask-text-to-symbol";
2. Call the functions
Example with default symbol
const text = "password";
const password = maskTextToSymbol({ text });
console.log(password);
// { original: 'password', masked: '********' }
Example with symbol
const text = 'password';
const password = maskTextToSymbol({ text, symbol: 'a' });
console.log(password);
// { original: 'password', masked: 'aaaaaaaa'}
Attributes
| Attribute | Type | Mandatory |
| ---------- | -------- | --------------------------------------- |
| text | string
| true |
| symbol | number
| false (default: *
) |
Wrapper function as a Helper (optional)
1. Import the function
import { maskTextToSymbol, TMaskTextToSymbol } from "@codexcentral/mask-text-to-symbol";
2. Create the Helper function
const maskTextToSymbolHelper = ({ text, symbol }: TMaskTextToSymbol) => {
return maskTextToSymbol({ text, symbol });
};
Credits
These code was written by Roberto Silva Z.