-
-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0420f11
commit cde84f1
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { Faker } from '.'; | ||
|
||
export class Music { | ||
constructor(private readonly faker: Faker) { | ||
// Bind `this` so namespaced is working correctly | ||
for (const name of Object.getOwnPropertyNames(Music.prototype)) { | ||
if (name === 'constructor' || typeof this[name] !== 'function') { | ||
continue; | ||
} | ||
this[name] = this[name].bind(this); | ||
} | ||
|
||
// TODO @Shinigami92 2022-01-12: We should find a better strategy as assigning this property to a function | ||
// @ts-expect-error | ||
this.genre.schema = { | ||
description: 'Generates a genre.', | ||
sampleResults: ['Rock', 'Metal', 'Pop'], | ||
}; | ||
} | ||
|
||
/** | ||
* genre | ||
* | ||
* @method faker.music.genre | ||
*/ | ||
genre(): string { | ||
return this.faker.random.arrayElement(this.faker.definitions.music.genre); | ||
} | ||
} |