[READ-ONLY] Mirror of https://github.com/FoxxMD/redact-string. Redact part or all of a string foxxmd.github.io/redact-string
javascript redact redaction replace-text string string-manipulation typescript
0

Configure Feed

Select the types of activity you want to include in your feed.

Add missing definitions

FoxxMD (Jul 11, 2023, 11:41 AM EDT) 88ef3bb4 14077001

+40 -1
+16
dist/index.d.ts
··· 1 1 export interface RedactOptions { 2 + /** 3 + * Replace characters starting at the start or end of string (default start) 4 + * */ 2 5 replaceFrom?: 'start' | 'end'; 6 + /** 7 + * The character/string that characters are replaced with (default '*') 8 + * */ 3 9 replaceWith?: string; 10 + /** 11 + * Which type of characters to replace in the string (default any) 12 + * */ 4 13 replace?: 'any' | 'alphanumeric' | 'alpha' | 'numeric'; 5 14 } 15 + /** 16 + * Redact part or all of a string 17 + * 18 + * @param {string} str The string to redact 19 + * @param {number} visibleCount The number of characters to leave visible 20 + * @param {RedactOptions} options Define how redaction behavior occurs 21 + * */ 6 22 export declare const redactString: (str: string, visibleCount: number, options?: RedactOptions) => string; 7 23 export default redactString;
+7
dist/index.js
··· 1 1 "use strict"; 2 2 Object.defineProperty(exports, "__esModule", { value: true }); 3 3 exports.redactString = void 0; 4 + /** 5 + * Redact part or all of a string 6 + * 7 + * @param {string} str The string to redact 8 + * @param {number} visibleCount The number of characters to leave visible 9 + * @param {RedactOptions} options Define how redaction behavior occurs 10 + * */ 4 11 const redactString = (str, visibleCount, options) => { 5 12 const { replaceFrom = 'start', replaceWith = '*', replace = 'any' } = options || {}; 6 13 let replaceChar = `\\S`;
+17 -1
src/index.ts
··· 1 1 export interface RedactOptions { 2 + /** 3 + * Replace characters starting at the start or end of string (default start) 4 + * */ 2 5 replaceFrom?: 'start' | 'end' 6 + /** 7 + * The character/string that characters are replaced with (default '*') 8 + * */ 3 9 replaceWith?: string 10 + /** 11 + * Which type of characters to replace in the string (default any) 12 + * */ 4 13 replace?: 'any' | 'alphanumeric' | 'alpha' | 'numeric' 5 14 } 6 15 7 - export const redactString = (str: string, visibleCount: number, options?: RedactOptions) => { 16 + /** 17 + * Redact part or all of a string 18 + * 19 + * @param {string} str The string to redact 20 + * @param {number} visibleCount The number of characters to leave visible 21 + * @param {RedactOptions} options Define how redaction behavior occurs 22 + * */ 23 + export const redactString = (str: string, visibleCount: number, options?: RedactOptions): string => { 8 24 const { 9 25 replaceFrom = 'start', 10 26 replaceWith = '*',