a nodejs-compatible refactoring

made the module nodejs-compatible, moved all browser-specific staff to a separate files