AMD/requirejs support, encapsulate function and expose to window/requirejs/node