formatToHiddenDigits function formats a string by replacing digits within a specified range with a hiding character, such as *.ts
import { formatToHiddenDigits } from "@arkyn/shared";
valuestringoptionsobjectrange (optional)number | [number, number]n): Hides the first n digits.-n): Hides the last n digits.[start, end]: Hides the digits from start to end (inclusive).3 (hides the first three digits).hider (optional)string*string with the specified digits hidden.javascript
import { formatToHiddenDigits } from "./formatToHiddenDigits";const result = formatToHiddenDigits("123-456-7890", { range: 3 });console.log(result); // Output: "***-456-7890"
javascript
import { formatToHiddenDigits } from "./formatToHiddenDigits";const result = formatToHiddenDigits("123-456-7890", {range: [4, 6],hider: "#",});console.log(result); // Output: "123-###-7890"
javascript
import { formatToHiddenDigits } from "./formatToHiddenDigits";const result = formatToHiddenDigits("123-456-7890", { range: -4 });console.log(result); // Output: "123-456-****"