From 2d93e6f14a5ba976f87b71202bc4e011e38ee823 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Sat, 31 Dec 2022 12:22:38 +0100 Subject: chore: turn on padding-line-between-statements (#1691) --- src/modules/datatype/index.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/modules/datatype') diff --git a/src/modules/datatype/index.ts b/src/modules/datatype/index.ts index f9c2bac6..f62d3a68 100644 --- a/src/modules/datatype/index.ts +++ b/src/modules/datatype/index.ts @@ -11,6 +11,7 @@ export class DatatypeModule { if (name === 'constructor' || typeof this[name] !== 'function') { continue; } + this[name] = this[name].bind(this); } } @@ -211,14 +212,17 @@ export class DatatypeModule { probability: options, }; } + const { probability = 0.5 } = options; if (probability <= 0) { return false; } + if (probability >= 1) { // This check is required to avoid returning false when float() returns 1 return true; } + return this.faker.number.float() < probability; } -- cgit v1.2.3