convert to a common node/broswer compatibility practice

http://www.matteoagosti.com/blog/2013/02/24/writing-javascript-modules-for-both-browser-and-node/