From eb66de57ceb630c83059308d469d1483f89ab726 Mon Sep 17 00:00:00 2001 From: axross Date: Tue, 14 Oct 2014 14:40:03 +0900 Subject: [PATCH] Add browserify support --- fetch.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fetch.js b/fetch.js index a5452e0a..ca8adb33 100644 --- a/fetch.js +++ b/fetch.js @@ -3,6 +3,8 @@ if (window.fetch) { return + } else if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports) { + // Do continue } function Headers(headers) { @@ -185,6 +187,14 @@ Body.call(Response.prototype) + if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports) { + module.exports = function (url, options) { + return new Request(url, options).fetch() + } + + return + } + window.fetch = function (url, options) { return new Request(url, options).fetch() }