cafe-utility 10.28.0 → 10.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -181,7 +181,7 @@ declare type VariantGroup = {
|
|
|
181
181
|
declare function explodeReplace(string: string, substring: string, variants: string[]): string[];
|
|
182
182
|
declare function generateVariants(string: string, groups: VariantGroup[], count: number, generator?: () => number): string[];
|
|
183
183
|
declare function hashCode(string: string): number;
|
|
184
|
-
declare function replaceWord(string: string, search: string, replace: string): string;
|
|
184
|
+
declare function replaceWord(string: string, search: string, replace: string, whitespaceOnly?: boolean): string;
|
|
185
185
|
declare function containsWord(string: string, word: string): boolean;
|
|
186
186
|
declare function containsWords(string: string, words: string[], mode: 'any' | 'all'): boolean;
|
|
187
187
|
declare function parseHtmlAttributes(string: string): Record<string, string>;
|
package/index.js
CHANGED
|
@@ -1331,8 +1331,8 @@ function hashCode(string) {
|
|
|
1331
1331
|
return hashCode
|
|
1332
1332
|
}
|
|
1333
1333
|
|
|
1334
|
-
function replaceWord(string, search, replace) {
|
|
1335
|
-
const regex = new RegExp(`\\b${search}\\b`, 'g')
|
|
1334
|
+
function replaceWord(string, search, replace, whitespaceOnly = false) {
|
|
1335
|
+
const regex = new RegExp(whitespaceOnly ? `(?<=\\s|^)${search}(?=\\s|$)` : `\\b${search}\\b`, 'g')
|
|
1336
1336
|
return string.replace(regex, replace)
|
|
1337
1337
|
}
|
|
1338
1338
|
|