diff options
| author | Shinigami <[email protected]> | 2022-12-31 12:22:38 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-31 12:22:38 +0100 |
| commit | 2d93e6f14a5ba976f87b71202bc4e011e38ee823 (patch) | |
| tree | 09c569ac0aa920ba090667a938f67416134dca26 /src/modules/datatype | |
| parent | e296ff2d4f6f1aa56fe7c80722257bd0b316b30a (diff) | |
| download | faker-2d93e6f14a5ba976f87b71202bc4e011e38ee823.tar.xz faker-2d93e6f14a5ba976f87b71202bc4e011e38ee823.zip | |
chore: turn on padding-line-between-statements (#1691)
Diffstat (limited to 'src/modules/datatype')
| -rw-r--r-- | src/modules/datatype/index.ts | 4 |
1 files changed, 4 insertions, 0 deletions
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; } |
