Updated for usability as Node.js module and NPM.