Rewrite coffee to js

- tests
- lib