ts-commons
Advanced tools
Comparing version 1.0.18 to 1.0.19
@@ -0,0 +0,0 @@ { |
@@ -243,2 +243,10 @@ export declare class StringUtils { | ||
static snakeCase(str: string): string; | ||
/** | ||
* Replaces all text find in a string. | ||
* @example StringUtils.replaceAll(null, "a", "b") = null; | ||
* @example StringUtils.replaceAll(" ", " ", "a") = "a"; | ||
* @example StringUtils.replaceAll("aa", "a", "b") = "bb"; | ||
*/ | ||
static replaceAll(str: string, searchValue: string, replacer: string): string; | ||
private static escapeRegExp; | ||
} |
@@ -454,2 +454,19 @@ "use strict"; | ||
}; | ||
/** | ||
* Replaces all text find in a string. | ||
* @example StringUtils.replaceAll(null, "a", "b") = null; | ||
* @example StringUtils.replaceAll(" ", " ", "a") = "a"; | ||
* @example StringUtils.replaceAll("aa", "a", "b") = "bb"; | ||
*/ | ||
StringUtils.replaceAll = function (str, searchValue, replacer) { | ||
if (!object_utils_1.ObjectUtils.isString(str) || | ||
!object_utils_1.ObjectUtils.isString(searchValue) || | ||
!object_utils_1.ObjectUtils.isString(replacer)) { | ||
return str; | ||
} | ||
return str.replace(new RegExp(this.escapeRegExp(searchValue), "g"), replacer); | ||
}; | ||
StringUtils.escapeRegExp = function (str) { | ||
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); | ||
}; | ||
StringUtils.EMPTY = ""; | ||
@@ -456,0 +473,0 @@ StringUtils.INDEX_NOT_FOUND = -1; |
{ | ||
"name": "ts-commons", | ||
"version": "1.0.18", | ||
"version": "1.0.19", | ||
"description": "common methods for typescript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
199998
38
2066