Moving index into TypeScript for testability.
Moved the logic into index.ts, it works (in Chrome at least).