Skip to content

Commit

Permalink
chore: move fake function out of class
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Jan 14, 2022
1 parent b433a8f commit fefb540
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/vehicle.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Faker } from '.';
import type { Fake } from './fake';

export class Vehicle {
fake: Fake['fake'];
let fake: Fake['fake'];

export class Vehicle {
constructor(private readonly faker: Faker) {
this.fake = faker.fake;
fake = faker.fake;

// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Vehicle.prototype)) {
Expand Down Expand Up @@ -72,16 +72,16 @@ export class Vehicle {
*
* @method faker.vehicle.vehicle
*/
vehicle() {
return this.fake('{{vehicle.manufacturer}} {{vehicle.model}}');
vehicle(): string {
return fake('{{vehicle.manufacturer}} {{vehicle.model}}');
}

/**
* manufacturer
*
* @method faker.vehicle.manufacturer
*/
manufacturer() {
manufacturer(): string {
return this.faker.random.arrayElement(
this.faker.definitions.vehicle.manufacturer
);
Expand All @@ -92,7 +92,7 @@ export class Vehicle {
*
* @method faker.vehicle.model
*/
model() {
model(): string {
return this.faker.random.arrayElement(this.faker.definitions.vehicle.model);
}

Expand All @@ -101,7 +101,7 @@ export class Vehicle {
*
* @method faker.vehicle.type
*/
type() {
type(): string {
return this.faker.random.arrayElement(this.faker.definitions.vehicle.type);
}

Expand All @@ -110,7 +110,7 @@ export class Vehicle {
*
* @method faker.vehicle.fuel
*/
fuel() {
fuel(): string {
return this.faker.random.arrayElement(this.faker.definitions.vehicle.fuel);
}

Expand All @@ -119,7 +119,7 @@ export class Vehicle {
*
* @method faker.vehicle.vin
*/
vin() {
vin(): string {
const bannedChars = ['o', 'i', 'q'];
return (
this.faker.random.alphaNumeric(10, { bannedChars: bannedChars }) +
Expand All @@ -139,16 +139,16 @@ export class Vehicle {
*
* @method faker.vehicle.color
*/
color() {
return this.fake('{{commerce.color}}');
color(): string {
return fake('{{commerce.color}}');
}

/**
* vrm
*
* @method faker.vehicle.vrm
*/
vrm() {
vrm(): string {
return (
this.faker.random.alpha({ count: 2, upcase: true }) +
this.faker.datatype.number({ min: 0, max: 9 }) +
Expand All @@ -162,7 +162,7 @@ export class Vehicle {
*
* @method faker.vehicle.bicycle
*/
bicycle() {
bicycle(): string {
return this.faker.random.arrayElement(
this.faker.definitions.vehicle.bicycle_type
);
Expand Down

0 comments on commit fefb540

Please sign in to comment.