1.1.0 • Published 5 months ago

@codexcentral/mask-text-to-symbol v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

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

AttributeTypeMandatory
textstringtrue
symbolnumberfalse (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.