rich-domain
Version:
This package provide utils file and interfaces to assistant build a complex application with domain driving design
26 lines • 1.16 kB
TypeScript
/**
* @description Removes characters from a string based on a condition defined by the provided `IsChar` function.
*
* @param target The input string from which characters will be removed.
* @param IsChar A callback function that determines whether a character should be removed.
* It receives a character as input and returns `true` if the character should be removed, or `false` otherwise.
*
* @returns A new string with the characters removed based on the `IsChar` condition.
* If the input `target` is not a string, it returns the input as is.
*
* @example
* ```typescript
* // Example 1: Remove all vowels
* const isVowel = (char: string) => 'aeiou'.includes(char.toLowerCase());
* const result = RemoveChars("Hello, World!", isVowel);
* console.log(result); // "Hll, Wrld!"
*
* // Example 2: Remove all digits
* const isDigit = (char: string) => /\d/.test(char);
* const result = RemoveChars("123abc456", isDigit);
* console.log(result); // "abc"
* ```
*/
export declare const RemoveChars: (target: string, IsChar: (char: string) => boolean) => string;
export default RemoveChars;
//# sourceMappingURL=remove-chars.util.d.ts.map