saebekassebil / teoria

Javascript taught Music Theory
http://saebekassebil.github.io/teoria
MIT License
1.32k stars 114 forks source link

Convert Teoria to a node module compatible library #77

Closed danigb closed 9 years ago

danigb commented 9 years ago

Hello, thanks for your library! This is my first pull request, so be kind.

What I did: split the code in valid node modules so you can require all the library require('teoria') or just some parts of it require ('teoria/scale')

The required files are vector.js and interval.js. Notes (note.js) depend of both. Scales (scale.js) and Chords (chord.js) depend on note.js. One caveat of this dependency line is that, by default, Note objects doesn't implement TeoriaNote.scale and TeoriaNote.chord.

There's a facade object (index.js) that implements those methods, so if you require the library using require('teoria') the API will be exactly the same as before. Also in the the dist file, TeoriaNote has exactly the same API as before.

I modified the tests (and added some new) that works with the new module system. I've keep the original tests inside test-dist and run then against the distribution file to check the compatibility.

Also notice that the distribution file is now in the repo, so no need to build it.

I have more ideas to keep the library more modular (different scales, more method granularity), but I think this can be the base version we can discuss about.

Un saludo, Dani

danigb commented 9 years ago

The code can be vastly improved. I will open an issue insted.