@codexcentral/mask-text-to-symbol
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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.

Package Sidebar

Install

npm i @codexcentral/mask-text-to-symbol

Weekly Downloads

1

Version

1.1.0

License

Apache-2.0

Unpacked Size

18 kB

Total Files

15

Last publish

Collaborators

  • roberto.silva