From 13ad73ea58547cf15eb7e8e1000a586bee16b305 Mon Sep 17 00:00:00 2001 From: mvelten Date: Wed, 18 Oct 2023 08:49:52 +0200 Subject: [PATCH] finally added jsdoc comments to the export functions --- src/lib/dataGuard.ts | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/lib/dataGuard.ts b/src/lib/dataGuard.ts index 429633a..fc030e9 100644 --- a/src/lib/dataGuard.ts +++ b/src/lib/dataGuard.ts @@ -137,9 +137,32 @@ function unmaskContent(value: string): { isUnmasked: boolean; content: string } return { isUnmasked, content }; } -// Overload signatures +/** + * Masks sensitive parts of a string based on predefined and custom patterns. + * + * @param {string} value - The string to mask. + * @returns {string} The masked string. + */ export function maskString(value: string): string; + +/** + * Masks sensitive parts of a string based on provided options. + * + * @param {string} value - The string to mask. + * @param {Partial} options - The options to customize the masking process. + * @returns {string} The masked string. + */ export function maskString(value: string, options: Partial): string; + +/** + * Masks sensitive parts of a string based on specified types and optionally custom patterns and options. + * + * @param {string} value - The string to mask. + * @param {SensitiveContentKey[]} types - The types of sensitive content to mask. + * @param {Record} [customSensitiveContentRegExp] - Custom regular expressions for detecting sensitive content. + * @param {Partial} [options] - The options to customize the masking process. + * @returns {string} The masked string. + */ export function maskString( value: string, types: SensitiveContentKey[], // This remains non-optional @@ -147,7 +170,6 @@ export function maskString( options?: Partial ): string; -// Function implementation export function maskString( value: string, typesOrOptions?: SensitiveContentKey[] | Partial, // This should be optional @@ -287,6 +309,16 @@ function performMasking(key: string, value: unknown, options: Partial} [options={}] - Optional masking options. + * @returns {T} The masked data. + */ export function maskData(item: T, options: Partial = {}): T { const { keyCheck = shouldMaskKey, immutable = true } = options; @@ -321,6 +353,14 @@ export function maskData(item: T, options: Partial = {}): T return item as T; } +/** + * Masks arguments of a function call, based on the provided masking options. + * + * @template T + * @param {unknown[]} args - The original arguments to mask. + * @param {IMaskDataOptions} [options] - Optional masking options. + * @returns {T[]} The masked arguments. + */ export function maskArguments(args: unknown[], options?: IMaskDataOptions): T[] { if (isNullish(args) || args.length === 0) return args as T[]; return args.map(arg =>