aboutsummaryrefslogtreecommitdiff
path: root/src/modules/helpers
diff options
context:
space:
mode:
authorShinigami <[email protected]>2024-02-18 23:56:40 +0100
committerGitHub <[email protected]>2024-02-18 23:56:40 +0100
commit52b8992cbf960e001336d59b83c610845ff35860 (patch)
treec71db76f3f955a74be4cbcbaa56df77375cb4531 /src/modules/helpers
parentec5609b18c79ea9fc8183ae78e917801e6a8a3f4 (diff)
downloadfaker-52b8992cbf960e001336d59b83c610845ff35860.tar.xz
faker-52b8992cbf960e001336d59b83c610845ff35860.zip
infra(unicorn): prefer-string-replace-all (#2653)
Diffstat (limited to 'src/modules/helpers')
-rw-r--r--src/modules/helpers/index.ts8
-rw-r--r--src/modules/helpers/luhn-check.ts2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts
index 635b3e09..73728f78 100644
--- a/src/modules/helpers/index.ts
+++ b/src/modules/helpers/index.ts
@@ -228,9 +228,9 @@ export class SimpleHelpersModule extends SimpleModuleBase {
slugify(string: string = ''): string {
return string
.normalize('NFKD') //for example è decomposes to as e + ̀
- .replace(/[\u0300-\u036F]/g, '') // removes combining marks
- .replace(/ /g, '-') // replaces spaces with hyphens
- .replace(/[^\w.-]+/g, ''); // removes all non-word characters except for dots and hyphens
+ .replaceAll(/[\u0300-\u036F]/g, '') // removes combining marks
+ .replaceAll(' ', '-') // replaces spaces with hyphens
+ .replaceAll(/[^\w.-]+/g, ''); // removes all non-word characters except for dots and hyphens
}
/**
@@ -797,7 +797,7 @@ export class SimpleHelpersModule extends SimpleModuleBase {
let value = data[p];
if (typeof value === 'string') {
// escape $, source: https://stackoverflow.com/a/6969486/6897682
- value = value.replace(/\$/g, '$$$$');
+ value = value.replaceAll('$', '$$$$');
str = str.replace(re, value);
} else {
str = str.replace(re, value);
diff --git a/src/modules/helpers/luhn-check.ts b/src/modules/helpers/luhn-check.ts
index 42fbe1a5..fd7d54cc 100644
--- a/src/modules/helpers/luhn-check.ts
+++ b/src/modules/helpers/luhn-check.ts
@@ -24,7 +24,7 @@ export function luhnCheckValue(str: string): number {
* @param str The string to generate the checksum for.
*/
function luhnChecksum(str: string): number {
- str = str.replace(/[\s-]/g, '');
+ str = str.replaceAll(/[\s-]/g, '');
let sum = 0;
let alternate = false;
for (let i = str.length - 1; i >= 0; i--) {