Make AMD and CommonJS compatible

Just as the title says. I'm about to use your script in Node but needed it to be exported.