Music Genres: My Second NPM Package
Gavi Schneider
Posted on May 23, 2020
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:
- getAllGenres()
- getRandomGenre()
- 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.
Example
const musicGenres = require("music-genres");
musicGenres.getAllGenres();
// Returns all genres - an object holding genres
musicGenres.getRandomGenre();
// Returns random genre - an array holding sub-genres
musicGenres.getRandomSubgenre();
// Returns random sub-genre - a string
You can install the package here: https://www.npmjs.com/package/music-genres
I’d love any and all feedback. Say hi on twitter @gschnei.
Posted on May 23, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.