aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorLeyla Jähnig <[email protected]>2022-10-16 23:26:46 +0200
committerGitHub <[email protected]>2022-10-16 23:26:46 +0200
commitdac6be39fec509965e850ae1a47770c9224196f5 (patch)
treee801a061242a9e62df84025127c362ab1c7e9c49 /src/modules
parent20f2236265467feb095cce5b5735bbadc07b9696 (diff)
downloadfaker-dac6be39fec509965e850ae1a47770c9224196f5.tar.xz
faker-dac6be39fec509965e850ae1a47770c9224196f5.zip
feat(location)!: `latitude`/`longitude` returns number (#1064)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/address/index.ts40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/modules/address/index.ts b/src/modules/address/index.ts
index 6221b551..4d484651 100644
--- a/src/modules/address/index.ts
+++ b/src/modules/address/index.ts
@@ -260,19 +260,18 @@ export class AddressModule {
* @param precision The number of decimal points of precision for the latitude. Defaults to `4`.
*
* @example
- * faker.address.latitude() // '-30.9501'
- * faker.address.latitude(10, -10, 5) // '2.68452'
+ * faker.address.latitude() // -30.9501
+ * faker.address.latitude(10, -10, 5) // 2.68452
*
* @since 2.0.1
*/
- latitude(max: number = 90, min: number = -90, precision: number = 4): string {
- return this.faker.datatype
- .number({
- min,
- max,
- precision: parseFloat(`${(0.0).toPrecision(precision)}1`),
- })
- .toFixed(precision);
+ // TODO @xDivisionByZerox 2022-06-12 this signature should probably be an object for easier maintainability
+ latitude(max: number = 90, min: number = -90, precision: number = 4): number {
+ return this.faker.datatype.number({
+ min,
+ max,
+ precision: parseFloat(`${(0.0).toPrecision(precision)}1`),
+ });
}
/**
@@ -283,23 +282,22 @@ export class AddressModule {
* @param precision The number of decimal points of precision for the longitude. Defaults to `4`.
*
* @example
- * faker.address.longitude() // '-154.0226'
- * faker.address.longitude(10, -10, 5) // '-4.03620'
+ * faker.address.longitude() // -154.0226
+ * faker.address.longitude(10, -10, 5) // -4.03620
*
* @since 2.0.1
*/
+ // TODO @xDivisionByZerox 2022-06-12 this signature should probably be an object for easier maintainability
longitude(
max: number = 180,
min: number = -180,
precision: number = 4
- ): string {
- return this.faker.datatype
- .number({
- max: max,
- min: min,
- precision: parseFloat(`${(0.0).toPrecision(precision)}1`),
- })
- .toFixed(precision);
+ ): number {
+ return this.faker.datatype.number({
+ max: max,
+ min: min,
+ precision: parseFloat(`${(0.0).toPrecision(precision)}1`),
+ });
}
/**
@@ -396,7 +394,7 @@ export class AddressModule {
): [latitude: number, longitude: number] {
// If there is no coordinate, the best we can do is return a random GPS coordinate.
if (coordinate === undefined) {
- return [parseFloat(this.latitude()), parseFloat(this.longitude())];
+ return [this.latitude(), this.longitude()];
}
const angleRadians = this.faker.datatype.float({