aboutsummaryrefslogtreecommitdiff
path: root/src/modules/helpers
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-12-31 12:22:38 +0100
committerGitHub <[email protected]>2022-12-31 12:22:38 +0100
commit2d93e6f14a5ba976f87b71202bc4e011e38ee823 (patch)
tree09c569ac0aa920ba090667a938f67416134dca26 /src/modules/helpers
parente296ff2d4f6f1aa56fe7c80722257bd0b316b30a (diff)
downloadfaker-2d93e6f14a5ba976f87b71202bc4e011e38ee823.tar.xz
faker-2d93e6f14a5ba976f87b71202bc4e011e38ee823.zip
chore: turn on padding-line-between-statements (#1691)
Diffstat (limited to 'src/modules/helpers')
-rw-r--r--src/modules/helpers/index.ts13
-rw-r--r--src/modules/helpers/luhn-check.ts2
-rw-r--r--src/modules/helpers/unique.ts1
3 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts
index a1a845cd..3bdc2f68 100644
--- a/src/modules/helpers/index.ts
+++ b/src/modules/helpers/index.ts
@@ -14,6 +14,7 @@ export class HelpersModule {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
+
this[name] = this[name].bind(this);
}
}
@@ -65,6 +66,7 @@ export class HelpersModule {
str += string.charAt(i);
}
}
+
return str;
}
@@ -130,6 +132,7 @@ export class HelpersModule {
str += string.charAt(i);
}
}
+
return str;
}
@@ -199,6 +202,7 @@ export class HelpersModule {
max = min;
min = tmp;
}
+
repetitions = this.faker.number.int({ min, max });
string =
string.slice(0, token.index) +
@@ -206,6 +210,7 @@ export class HelpersModule {
string.slice(token.index + token[0].length);
token = string.match(RANGE_REP_REG);
}
+
// Deal with repeat `{num}`
token = string.match(REP_REG);
while (token != null) {
@@ -229,12 +234,14 @@ export class HelpersModule {
max = min;
min = tmp;
}
+
string =
string.slice(0, token.index) +
this.faker.number.int({ min, max }).toString() +
string.slice(token.index + token[0].length);
token = string.match(RANGE_REG);
}
+
return string;
}
@@ -320,6 +327,7 @@ export class HelpersModule {
const array = Array.from(set);
return this.shuffle(array).splice(0, length);
}
+
const set = new Set<T>();
try {
if (typeof source === 'function') {
@@ -330,6 +338,7 @@ export class HelpersModule {
} catch {
// Ignore
}
+
return Array.from(set);
}
@@ -356,6 +365,7 @@ export class HelpersModule {
if (str == null) {
return '';
}
+
for (const p in data) {
const re = new RegExp(`{{${p}}}`, 'g');
const value = data[p];
@@ -365,6 +375,7 @@ export class HelpersModule {
str = str.replace(re, value);
}
}
+
return str;
}
@@ -390,6 +401,7 @@ export class HelpersModule {
if (this.faker.datatype.boolean(options)) {
return callback();
}
+
return undefined;
}
@@ -740,6 +752,7 @@ export class HelpersModule {
if (typeof numberOrRange === 'number') {
return numberOrRange;
}
+
return this.faker.number.int(numberOrRange);
}
diff --git a/src/modules/helpers/luhn-check.ts b/src/modules/helpers/luhn-check.ts
index 9cfcc577..7d841878 100644
--- a/src/modules/helpers/luhn-check.ts
+++ b/src/modules/helpers/luhn-check.ts
@@ -35,8 +35,10 @@ function luhnChecksum(str: string): number {
n = (n % 10) + 1;
}
}
+
sum += n;
alternate = !alternate;
}
+
return sum % 10;
}
diff --git a/src/modules/helpers/unique.ts b/src/modules/helpers/unique.ts
index 31fddec8..fd240c2f 100644
--- a/src/modules/helpers/unique.ts
+++ b/src/modules/helpers/unique.ts
@@ -28,6 +28,7 @@ function defaultCompare(
if (obj[key] === undefined) {
return -1;
}
+
return 0;
}