Add UMD support

Based on https://github.com/umdjs/umd/blob/master/returnExports.js, this method
plays nicely with commonjs-in-the-browser environments like Browserify
as well as AMD loader systems. It prefers these modules systems over
attaching to the global window object, which it uses as a fallback.