diff options
| author | Jeremy Hofer <[email protected]> | 2024-04-29 05:24:45 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-29 11:24:45 +0200 |
| commit | f6827505712f48e448d4d4ef2dc3198e6967bbad (patch) | |
| tree | eb5b438a1675c1fe40142189493c757e97664ab7 /src/modules | |
| parent | 91a4d3d17ebc3fc4733344670349e4a1c69ce813 (diff) | |
| download | faker-f6827505712f48e448d4d4ef2dc3198e6967bbad.tar.xz faker-f6827505712f48e448d4d4ef2dc3198e6967bbad.zip | |
feat(music): add album and artist methods (#2620)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/music/index.ts | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/modules/music/index.ts b/src/modules/music/index.ts index 332b4530..e3d56715 100644 --- a/src/modules/music/index.ts +++ b/src/modules/music/index.ts @@ -5,10 +5,44 @@ import { ModuleBase } from '../../internal/module-base'; * * ### Overview * - * Generate a random music genre with [`genre()`](https://fakerjs.dev/api/music.html#genre) or song name with [`songName()`](https://fakerjs.dev/api/music.html#songname). Both may be localized. + * Generate random music content. + * + * For a random album name, use [`album()`](https://fakerjs.dev/api/music.html#album). + * + * For a random artist, use [`artist()`](https://fakerjs.dev/api/music.html#artist). + * + * For a random genre, use [`genre()`](https://fakerjs.dev/api/music.html#genre). + * + * For a random song name, [`songName()`](https://fakerjs.dev/api/music.html#songname). + * + * All data types may be localized. */ export class MusicModule extends ModuleBase { /** + * Returns a random album name. + * + * @example + * faker.music.album() // '1989' + * + * @since 9.0.0 + */ + album(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.music.album); + } + + /** + * Returns a random artist name. + * + * @example + * faker.music.artist() // 'The Beatles' + * + * @since 9.0.0 + */ + artist(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.music.artist); + } + + /** * Returns a random music genre. * * @example |
