Remove trailing whitespace.
Add CommonJS export for Node.js
Also 'window' does not exist in Node, so in it's place pass 'this' which is the global object in Node, and the window in the browser.