DEV Community


Music Genres: My Second NPM Package

Gavi Schneider
Metal 🤘🏻, Beer 🍺 & Programming 💻 Full time concert goer 🎸 Computer Science student 🎓
Originally published at Medium on ・1 min read

In case you haven’t already noticed, I love music. Not the way everyone says they do, I actually love it. So after yesterdays SLAAAYER rush, I quickly dove into my next music-related NPM project: Music Genres.

The package is simple: install and require it, and then you’ll have access to three functions:

  1. getAllGenres()
  2. getRandomGenre()
  3. getRandomSubgenre()

The first will return all the stored genres and sub-genres (of which there are currently 13 and 222, respectively) in a JavaScript Object. The second will Return a random genre, an array holding sub-genres. Lastly, the third will return a random sub-genre, which is a string.


const musicGenres = require("music-genres");

// Returns all genres - an object holding genres

// Returns random genre - an array holding sub-genres

// Returns random sub-genre - a string
Enter fullscreen mode Exit fullscreen mode

You can install the package here:

I’d love any and all feedback. Say hi on twitter @gschnei.

Discussion (1)

kaanguru profile image
cem kaan kosali

Why don't you try to port it to DENO?

Forem Open with the Forem app