Make this work as a NodeJS module

The code added at the bottom of buckets.js will enable it to be used as a module in NodeJS. The if statement ensures the rest of the export code will be completely ignore if run in the browser.