diff --git a/AUTHORS b/AUTHORS index b80f42a..0385a2e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ Jason Smith Work Jason Smith maxogden +Abbey Sparrow via Google diff --git a/README.md b/README.md index 1213c28..ad962db 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,17 @@ Deploy `example-built.js` to your web site and use it from your page. ```html ``` + +## UMD + +`browser-request` is [UMD](https://github.com/umdjs/umd) wrapped, allowing you to serve it directly to the browser from wherever you store the module. + +```html + +``` + +You may also use an [AMD loader](http://requirejs.org/docs/whyamd.html) by referencing the same file in your loader [config](http://requirejs.org/docs/api.html#config). + ## License Browser Request is licensed under the Apache 2.0 license. diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 1a77c6f..51ac8b4 --- a/index.js +++ b/index.js @@ -12,6 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +// UMD HEADER START +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); + } +}(this, function () { +// UMD HEADER END + var XHR = XMLHttpRequest if (!XHR) throw new Error('missing XMLHttpRequest') request.log = { @@ -471,4 +488,7 @@ function b64_enc (data) { return enc; } -module.exports = request; + return request; +//UMD FOOTER START +})); +//UMD FOOTER END