From c26505322535a6ceec3cea469df78c2bc3cf6f43 Mon Sep 17 00:00:00 2001 From: Nick Bottomley Date: Sun, 14 Sep 2014 14:20:40 -0700 Subject: [PATCH 1/2] add 'browser' field to package.json for browserify --- axios.js | 1284 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 + 2 files changed, 1287 insertions(+) create mode 100644 axios.js diff --git a/axios.js b/axios.js new file mode 100644 index 0000000..cd33519 --- /dev/null +++ b/axios.js @@ -0,0 +1,1284 @@ +!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.axios=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 200 && request.status < 300 + ? resolve + : reject)( + response.data, + response.status, + response.headers, + response.config + ); + + // Clean up request + request = null; + } + }; + + // Add xsrf header + var xsrfValue = urlIsSameOrigin(config.url) + ? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) + : undefined; + if (xsrfValue) { + headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue; + } + + // Add headers to the request + utils.forEach(headers, function (val, key) { + // Remove Content-Type if data is undefined + if (!data && key.toLowerCase() === 'content-type') { + delete headers[key]; + } + // Otherwise add header to the request + else { + request.setRequestHeader(key, val); + } + }); + + // Add withCredentials to request if needed + if (config.withCredentials) { + request.withCredentials = true; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + if (request.responseType !== 'json') { + throw e; + } + } + } + + // Send the request + request.send(data); +}; +},{"./../buildUrl":4,"./../cookies":5,"./../defaults":6,"./../parseHeaders":7,"./../transformData":9,"./../urlIsSameOrigin":10,"./../utils":11}],3:[function(_dereq_,module,exports){ +(function (process){ +var Promise = _dereq_('es6-promise').Promise; +var defaults = _dereq_('./defaults'); +var utils = _dereq_('./utils'); +var spread = _dereq_('./spread'); + +var axios = module.exports = function axios(config) { + config = utils.merge({ + method: 'get', + transformRequest: defaults.transformRequest, + transformResponse: defaults.transformResponse + }, config); + + // Don't allow overriding defaults.withCredentials + config.withCredentials = config.withCredentials || defaults.withCredentials; + + var promise = new Promise(function (resolve, reject) { + try { + // For browsers use XHR adapter + if (typeof window !== 'undefined') { + _dereq_('./adapters/xhr')(resolve, reject, config); + } + // For node use HTTP adapter + else if (typeof process !== 'undefined') { + _dereq_('./adapters/http')(resolve, reject, config); + } + } catch (e) { + reject(e); + } + }); + + // Provide alias for success + promise.success = function success(fn) { + promise.then(function(response) { + fn(response); + }); + return promise; + }; + + // Provide alias for error + promise.error = function error(fn) { + promise.then(null, function(response) { + fn(response); + }); + return promise; + }; + + return promise; +}; + +// Expose defaults +axios.defaults = defaults; + +// Expose all/spread +axios.all = Promise.all; +axios.spread = spread; + +// Provide aliases for supported request methods +createShortMethods('delete', 'get', 'head'); +createShortMethodsWithData('post', 'put', 'patch'); + +function createShortMethods() { + utils.forEach(arguments, function (method) { + axios[method] = function (url, config) { + return axios(utils.merge(config || {}, { + method: method, + url: url + })); + }; + }); +} + +function createShortMethodsWithData() { + utils.forEach(arguments, function (method) { + axios[method] = function (url, data, config) { + return axios(utils.merge(config || {}, { + method: method, + url: url, + data: data + })); + }; + }); +} +}).call(this,_dereq_("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js")) +},{"./adapters/http":2,"./adapters/xhr":2,"./defaults":6,"./spread":8,"./utils":11,"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":22,"es6-promise":12}],4:[function(_dereq_,module,exports){ +'use strict'; + +var utils = _dereq_('./utils'); + +function encode(val) { + return encodeURIComponent(val). + replace(/%40/gi, '@'). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'); +} + +module.exports = function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + utils.forEach(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!utils.isArray(val)) { + val = [val]; + } + + utils.forEach(val, function (v) { + if (utils.isDate(v)) { + v = v.toISOString(); + } + else if (utils.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; +}; +},{"./utils":11}],5:[function(_dereq_,module,exports){ +'use strict'; + +var utils = _dereq_('./utils'); + +module.exports = { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils.isString(path)) { + cookie.push('path=' + path); + } + + if (utils.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } +}; +},{"./utils":11}],6:[function(_dereq_,module,exports){ +'use strict'; + +var utils = _dereq_('./utils'); + +var JSON_START = /^\s*(\[|\{[^\{])/; +var JSON_END = /[\}\]]\s*$/; +var PROTECTION_PREFIX = /^\)\]\}',?\n/; +var CONTENT_TYPE_APPLICATION_JSON = { + 'Content-Type': 'application/json;charset=utf-8' +}; + +module.exports = { + transformRequest: [function (data) { + return utils.isObject(data) && + !utils.isFile(data) && + !utils.isBlob(data) ? + JSON.stringify(data) : null; + }], + + transformResponse: [function (data) { + if (typeof data === 'string') { + data = data.replace(PROTECTION_PREFIX, ''); + if (JSON_START.test(data) && JSON_END.test(data)) { + data = JSON.parse(data); + } + } + return data; + }], + + headers: { + common: { + 'Accept': 'application/json, text/plain, */*' + }, + patch: utils.merge(CONTENT_TYPE_APPLICATION_JSON), + post: utils.merge(CONTENT_TYPE_APPLICATION_JSON), + put: utils.merge(CONTENT_TYPE_APPLICATION_JSON) + }, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN' +}; +},{"./utils":11}],7:[function(_dereq_,module,exports){ +'use strict'; + +var utils = _dereq_('./utils'); + +/** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ +module.exports = function parseHeaders(headers) { + var parsed = {}, key, val, i; + + if (!headers) return parsed; + + utils.forEach(headers.split('\n'), function(line) { + i = line.indexOf(':'); + key = utils.trim(line.substr(0, i)).toLowerCase(); + val = utils.trim(line.substr(i + 1)); + + if (key) { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + }); + + return parsed; +}; +},{"./utils":11}],8:[function(_dereq_,module,exports){ +/** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} + */ +module.exports = function spread(callback) { + return function (arr) { + callback.apply(null, arr); + }; +}; +},{}],9:[function(_dereq_,module,exports){ +'use strict'; + +var utils = _dereq_('./utils'); + +/** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ +module.exports = function transformData(data, headers, fns) { + utils.forEach(fns, function (fn) { + data = fn(data, headers); + }); + + return data; +}; +},{"./utils":11}],10:[function(_dereq_,module,exports){ +'use strict'; + +var msie = /(msie|trident)/i.test(navigator.userAgent); +var utils = _dereq_('./utils'); +var urlParsingNode = document.createElement('a'); +var originUrl = urlResolve(window.location.href); + +/** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ +function urlResolve(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') + ? urlParsingNode.pathname + : '/' + urlParsingNode.pathname + }; +} + +/** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestUrl The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ +module.exports = function urlIsSameOrigin(requestUrl) { + var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl; + return (parsed.protocol === originUrl.protocol && + parsed.host === originUrl.host); +}; +},{"./utils":11}],11:[function(_dereq_,module,exports){ +// utils is a library of generic helper functions non-specific to axios + +var toString = Object.prototype.toString; + +/** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ +function isArray(val) { + return toString.call(val) === '[object Array]'; +} + +/** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ +function isString(val) { + return typeof val === 'string'; +} + +/** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ +function isNumber(val) { + return typeof val === 'number'; +} + +/** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ +function isObject(val) { + return val !== null && typeof val === 'object'; +} + +/** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ +function isDate(val) { + return toString.call(val) === '[object Date]'; +} + +/** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ +function isFile(val) { + return toString.call(val) === '[object File]'; +} + +/** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ +function isBlob(val) { + return toString.call(val) === '[object Blob]'; +} + +/** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ +function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); +} + +/** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array or arguments callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ +function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Check if obj is array-like + var isArray = obj.constructor === Array || typeof obj.callee === 'function'; + + // Force an array if not already something iterable + if (typeof obj !== 'object' && !isArray) { + obj = [obj]; + } + + // Iterate over array values + if (isArray) { + for (var i=0, l=obj.length; i 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('process-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +function noop() {} + +process.on = noop; +process.once = noop; +process.off = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +} + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; + +},{}]},{},[1]) +(1) +}); \ No newline at end of file diff --git a/package.json b/package.json index 1a653b8..6d03b5e 100644 --- a/package.json +++ b/package.json @@ -43,5 +43,8 @@ "grunt-update-json": "^0.1.3", "grunt-contrib-nodeunit": "^0.4.1", "grunt-banner": "^0.2.3" + }, + "browser": { + "./lib/adapters/http.js": "./lib/adapters/xhr.js" } } From d0bdde4ce3660c00e2444ff5f96be190275b3a44 Mon Sep 17 00:00:00 2001 From: Nick Bottomley Date: Sun, 14 Sep 2014 14:21:12 -0700 Subject: [PATCH 2/2] remove browserified file --- axios.js | 1284 ------------------------------------------------------ 1 file changed, 1284 deletions(-) delete mode 100644 axios.js diff --git a/axios.js b/axios.js deleted file mode 100644 index cd33519..0000000 --- a/axios.js +++ /dev/null @@ -1,1284 +0,0 @@ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.axios=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 200 && request.status < 300 - ? resolve - : reject)( - response.data, - response.status, - response.headers, - response.config - ); - - // Clean up request - request = null; - } - }; - - // Add xsrf header - var xsrfValue = urlIsSameOrigin(config.url) - ? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) - : undefined; - if (xsrfValue) { - headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue; - } - - // Add headers to the request - utils.forEach(headers, function (val, key) { - // Remove Content-Type if data is undefined - if (!data && key.toLowerCase() === 'content-type') { - delete headers[key]; - } - // Otherwise add header to the request - else { - request.setRequestHeader(key, val); - } - }); - - // Add withCredentials to request if needed - if (config.withCredentials) { - request.withCredentials = true; - } - - // Add responseType to request if needed - if (config.responseType) { - try { - request.responseType = config.responseType; - } catch (e) { - if (request.responseType !== 'json') { - throw e; - } - } - } - - // Send the request - request.send(data); -}; -},{"./../buildUrl":4,"./../cookies":5,"./../defaults":6,"./../parseHeaders":7,"./../transformData":9,"./../urlIsSameOrigin":10,"./../utils":11}],3:[function(_dereq_,module,exports){ -(function (process){ -var Promise = _dereq_('es6-promise').Promise; -var defaults = _dereq_('./defaults'); -var utils = _dereq_('./utils'); -var spread = _dereq_('./spread'); - -var axios = module.exports = function axios(config) { - config = utils.merge({ - method: 'get', - transformRequest: defaults.transformRequest, - transformResponse: defaults.transformResponse - }, config); - - // Don't allow overriding defaults.withCredentials - config.withCredentials = config.withCredentials || defaults.withCredentials; - - var promise = new Promise(function (resolve, reject) { - try { - // For browsers use XHR adapter - if (typeof window !== 'undefined') { - _dereq_('./adapters/xhr')(resolve, reject, config); - } - // For node use HTTP adapter - else if (typeof process !== 'undefined') { - _dereq_('./adapters/http')(resolve, reject, config); - } - } catch (e) { - reject(e); - } - }); - - // Provide alias for success - promise.success = function success(fn) { - promise.then(function(response) { - fn(response); - }); - return promise; - }; - - // Provide alias for error - promise.error = function error(fn) { - promise.then(null, function(response) { - fn(response); - }); - return promise; - }; - - return promise; -}; - -// Expose defaults -axios.defaults = defaults; - -// Expose all/spread -axios.all = Promise.all; -axios.spread = spread; - -// Provide aliases for supported request methods -createShortMethods('delete', 'get', 'head'); -createShortMethodsWithData('post', 'put', 'patch'); - -function createShortMethods() { - utils.forEach(arguments, function (method) { - axios[method] = function (url, config) { - return axios(utils.merge(config || {}, { - method: method, - url: url - })); - }; - }); -} - -function createShortMethodsWithData() { - utils.forEach(arguments, function (method) { - axios[method] = function (url, data, config) { - return axios(utils.merge(config || {}, { - method: method, - url: url, - data: data - })); - }; - }); -} -}).call(this,_dereq_("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js")) -},{"./adapters/http":2,"./adapters/xhr":2,"./defaults":6,"./spread":8,"./utils":11,"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":22,"es6-promise":12}],4:[function(_dereq_,module,exports){ -'use strict'; - -var utils = _dereq_('./utils'); - -function encode(val) { - return encodeURIComponent(val). - replace(/%40/gi, '@'). - replace(/%3A/gi, ':'). - replace(/%24/g, '$'). - replace(/%2C/gi, ','). - replace(/%20/g, '+'); -} - -module.exports = function buildUrl(url, params) { - if (!params) { - return url; - } - - var parts = []; - - utils.forEach(params, function (val, key) { - if (val === null || typeof val === 'undefined') { - return; - } - if (!utils.isArray(val)) { - val = [val]; - } - - utils.forEach(val, function (v) { - if (utils.isDate(v)) { - v = v.toISOString(); - } - else if (utils.isObject(v)) { - v = JSON.stringify(v); - } - parts.push(encode(key) + '=' + encode(v)); - }); - }); - - if (parts.length > 0) { - url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); - } - - return url; -}; -},{"./utils":11}],5:[function(_dereq_,module,exports){ -'use strict'; - -var utils = _dereq_('./utils'); - -module.exports = { - write: function write(name, value, expires, path, domain, secure) { - var cookie = []; - cookie.push(name + '=' + encodeURIComponent(value)); - - if (utils.isNumber(expires)) { - cookie.push('expires=' + new Date(expires).toGMTString()); - } - - if (utils.isString(path)) { - cookie.push('path=' + path); - } - - if (utils.isString(domain)) { - cookie.push('domain=' + domain); - } - - if (secure === true) { - cookie.push('secure'); - } - - document.cookie = cookie.join('; '); - }, - - read: function read(name) { - var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); - return (match ? decodeURIComponent(match[3]) : null); - }, - - remove: function remove(name) { - this.write(name, '', Date.now() - 86400000); - } -}; -},{"./utils":11}],6:[function(_dereq_,module,exports){ -'use strict'; - -var utils = _dereq_('./utils'); - -var JSON_START = /^\s*(\[|\{[^\{])/; -var JSON_END = /[\}\]]\s*$/; -var PROTECTION_PREFIX = /^\)\]\}',?\n/; -var CONTENT_TYPE_APPLICATION_JSON = { - 'Content-Type': 'application/json;charset=utf-8' -}; - -module.exports = { - transformRequest: [function (data) { - return utils.isObject(data) && - !utils.isFile(data) && - !utils.isBlob(data) ? - JSON.stringify(data) : null; - }], - - transformResponse: [function (data) { - if (typeof data === 'string') { - data = data.replace(PROTECTION_PREFIX, ''); - if (JSON_START.test(data) && JSON_END.test(data)) { - data = JSON.parse(data); - } - } - return data; - }], - - headers: { - common: { - 'Accept': 'application/json, text/plain, */*' - }, - patch: utils.merge(CONTENT_TYPE_APPLICATION_JSON), - post: utils.merge(CONTENT_TYPE_APPLICATION_JSON), - put: utils.merge(CONTENT_TYPE_APPLICATION_JSON) - }, - - xsrfCookieName: 'XSRF-TOKEN', - xsrfHeaderName: 'X-XSRF-TOKEN' -}; -},{"./utils":11}],7:[function(_dereq_,module,exports){ -'use strict'; - -var utils = _dereq_('./utils'); - -/** - * Parse headers into an object - * - * ``` - * Date: Wed, 27 Aug 2014 08:58:49 GMT - * Content-Type: application/json - * Connection: keep-alive - * Transfer-Encoding: chunked - * ``` - * - * @param {String} headers Headers needing to be parsed - * @returns {Object} Headers parsed into an object - */ -module.exports = function parseHeaders(headers) { - var parsed = {}, key, val, i; - - if (!headers) return parsed; - - utils.forEach(headers.split('\n'), function(line) { - i = line.indexOf(':'); - key = utils.trim(line.substr(0, i)).toLowerCase(); - val = utils.trim(line.substr(i + 1)); - - if (key) { - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; - } - }); - - return parsed; -}; -},{"./utils":11}],8:[function(_dereq_,module,exports){ -/** - * Syntactic sugar for invoking a function and expanding an array for arguments. - * - * Common use case would be to use `Function.prototype.apply`. - * - * ```js - * function f(x, y, z) {} - * var args = [1, 2, 3]; - * f.apply(null, args); - * ``` - * - * With `spread` this example can be re-written. - * - * ```js - * spread(function(x, y, z) {})([1, 2, 3]); - * ``` - * - * @param {Function} callback - * @returns {Function} - */ -module.exports = function spread(callback) { - return function (arr) { - callback.apply(null, arr); - }; -}; -},{}],9:[function(_dereq_,module,exports){ -'use strict'; - -var utils = _dereq_('./utils'); - -/** - * Transform the data for a request or a response - * - * @param {Object|String} data The data to be transformed - * @param {Array} headers The headers for the request or response - * @param {Array|Function} fns A single function or Array of functions - * @returns {*} The resulting transformed data - */ -module.exports = function transformData(data, headers, fns) { - utils.forEach(fns, function (fn) { - data = fn(data, headers); - }); - - return data; -}; -},{"./utils":11}],10:[function(_dereq_,module,exports){ -'use strict'; - -var msie = /(msie|trident)/i.test(navigator.userAgent); -var utils = _dereq_('./utils'); -var urlParsingNode = document.createElement('a'); -var originUrl = urlResolve(window.location.href); - -/** - * Parse a URL to discover it's components - * - * @param {String} url The URL to be parsed - * @returns {Object} - */ -function urlResolve(url) { - var href = url; - - if (msie) { - // IE needs attribute set twice to normalize properties - urlParsingNode.setAttribute('href', href); - href = urlParsingNode.href; - } - - urlParsingNode.setAttribute('href', href); - - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils - return { - href: urlParsingNode.href, - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', - host: urlParsingNode.host, - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', - hostname: urlParsingNode.hostname, - port: urlParsingNode.port, - pathname: (urlParsingNode.pathname.charAt(0) === '/') - ? urlParsingNode.pathname - : '/' + urlParsingNode.pathname - }; -} - -/** - * Determine if a URL shares the same origin as the current location - * - * @param {String} requestUrl The URL to test - * @returns {boolean} True if URL shares the same origin, otherwise false - */ -module.exports = function urlIsSameOrigin(requestUrl) { - var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl; - return (parsed.protocol === originUrl.protocol && - parsed.host === originUrl.host); -}; -},{"./utils":11}],11:[function(_dereq_,module,exports){ -// utils is a library of generic helper functions non-specific to axios - -var toString = Object.prototype.toString; - -/** - * Determine if a value is an Array - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an Array, otherwise false - */ -function isArray(val) { - return toString.call(val) === '[object Array]'; -} - -/** - * Determine if a value is a String - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a String, otherwise false - */ -function isString(val) { - return typeof val === 'string'; -} - -/** - * Determine if a value is a Number - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Number, otherwise false - */ -function isNumber(val) { - return typeof val === 'number'; -} - -/** - * Determine if a value is an Object - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an Object, otherwise false - */ -function isObject(val) { - return val !== null && typeof val === 'object'; -} - -/** - * Determine if a value is a Date - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Date, otherwise false - */ -function isDate(val) { - return toString.call(val) === '[object Date]'; -} - -/** - * Determine if a value is a File - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a File, otherwise false - */ -function isFile(val) { - return toString.call(val) === '[object File]'; -} - -/** - * Determine if a value is a Blob - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Blob, otherwise false - */ -function isBlob(val) { - return toString.call(val) === '[object Blob]'; -} - -/** - * Trim excess whitespace off the beginning and end of a string - * - * @param {String} str The String to trim - * @returns {String} The String freed of excess whitespace - */ -function trim(str) { - return str.replace(/^\s*/, '').replace(/\s*$/, ''); -} - -/** - * Iterate over an Array or an Object invoking a function for each item. - * - * If `obj` is an Array or arguments callback will be called passing - * the value, index, and complete array for each item. - * - * If 'obj' is an Object callback will be called passing - * the value, key, and complete object for each property. - * - * @param {Object|Array} obj The object to iterate - * @param {Function} fn The callback to invoke for each item - */ -function forEach(obj, fn) { - // Don't bother if no value provided - if (obj === null || typeof obj === 'undefined') { - return; - } - - // Check if obj is array-like - var isArray = obj.constructor === Array || typeof obj.callee === 'function'; - - // Force an array if not already something iterable - if (typeof obj !== 'object' && !isArray) { - obj = [obj]; - } - - // Iterate over array values - if (isArray) { - for (var i=0, l=obj.length; i 0) { - var fn = queue.shift(); - fn(); - } - } - }, true); - - return function nextTick(fn) { - queue.push(fn); - window.postMessage('process-tick', '*'); - }; - } - - return function nextTick(fn) { - setTimeout(fn, 0); - }; -})(); - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; - -function noop() {} - -process.on = noop; -process.once = noop; -process.off = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -} - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; - -},{}]},{},[1]) -(1) -}); \ No newline at end of file