Skip to content

Commit

Permalink
chore: rewrite locial or assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Feb 5, 2022
1 parent 8cde9d9 commit a7fdb02
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ export class Address {
if (coordinate === undefined) {
return [this.faker.address.latitude(), this.faker.address.longitude()];
}
radius ||= 10.0;
isMetric ||= false;
radius = radius || 10.0;
isMetric = isMetric || false;

// TODO: implement either a gaussian/uniform distribution of points in circular region.
// Possibly include param to function that allows user to choose between distributions.
Expand Down
2 changes: 1 addition & 1 deletion src/finance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Finance {
* @param length
*/
account(length?: number): string {
length ||= 8;
length = length || 8;
let template = '';

for (let i = 0; i < length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class Helpers {
return o || [];
}

o ||= ['a', 'b', 'c'] as unknown as T[];
o = o || (['a', 'b', 'c'] as unknown as T[]);
for (let x: T, j: number, i = o.length - 1; i > 0; --i) {
j = this.faker.datatype.number(i);
x = o[i];
Expand Down
4 changes: 2 additions & 2 deletions src/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class Image {
randomize?: boolean,
https?: boolean
): string {
width ||= 640;
height ||= 480;
width = width || 640;
height = height || 480;
let protocol = 'http://';
if (typeof https !== 'undefined' && https === true) {
protocol = 'https://';
Expand Down
4 changes: 2 additions & 2 deletions src/image_providers/lorempicsum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export class LoremPicsum {
blur?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
seed?: string
): string {
width ||= 640;
height ||= 480;
width = width || 640;
height = height || 480;

let url = 'https://picsum.photos';

Expand Down
4 changes: 2 additions & 2 deletions src/image_providers/lorempixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export class Lorempixel {
category?: string,
randomize?: boolean
): string {
width ||= 640;
height ||= 480;
width = width || 640;
height = height || 480;

let url = `https://lorempixel.com/${width}/${height}`;
if (typeof category !== 'undefined') {
Expand Down
4 changes: 2 additions & 2 deletions src/image_providers/unsplash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export class Unsplash {
category?: string,
keyword?: string
): string {
width ||= 640;
height ||= 480;
width = width || 640;
height = height || 480;

let url = 'https://source.unsplash.com';

Expand Down
14 changes: 8 additions & 6 deletions src/internet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ export class Internet {
* @param provider
*/
email(firstName?: string, lastName?: string, provider?: string): string {
provider ||= this.faker.random.arrayElement(
this.faker.definitions.internet.free_email
);
provider =
provider ||
this.faker.random.arrayElement(
this.faker.definitions.internet.free_email
);
return (
this.faker.helpers.slugify(
this.faker.internet.userName(firstName, lastName)
Expand Down Expand Up @@ -234,8 +236,8 @@ export class Internet {
*/
userName(firstName?: string, lastName?: string): string {
let result: string;
firstName ||= this.faker.name.firstName();
lastName ||= this.faker.name.lastName();
firstName = firstName || this.faker.name.firstName();
lastName = lastName || this.faker.name.lastName();
switch (this.faker.datatype.number(2)) {
case 0:
result = `${firstName}${this.faker.datatype.number(99)}`;
Expand Down Expand Up @@ -481,7 +483,7 @@ export class Internet {
pattern?: RegExp,
prefix?: string
): string {
len ||= 15;
len = len || 15;
if (typeof memorable === 'undefined') {
memorable = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ export class Name {
gender = this.faker.datatype.number(1);
}

firstName ||= this.faker.name.firstName(gender);
lastName ||= this.faker.name.lastName(gender);
firstName = firstName || this.faker.name.firstName(gender);
lastName = lastName || this.faker.name.lastName(gender);

switch (r) {
case 0:
Expand Down
2 changes: 1 addition & 1 deletion src/unique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Unique {
compare?: (obj: Record<string, string>, key: string) => 0 | -1;
}
): string {
opts ||= {};
opts = opts || {};
opts.startTime = new Date().getTime();
if (typeof opts.maxTime !== 'number') {
opts.maxTime = this.maxTime;
Expand Down

0 comments on commit a7fdb02

Please sign in to comment.