umd wrapper. solves #1204

This adds support for commonjs/amdjs. See #1204 for more info.