diff --git a/lib/defaults/index.js b/lib/defaults/index.js index d7ed025..da3db72 100644 --- a/lib/defaults/index.js +++ b/lib/defaults/index.js @@ -13,12 +13,28 @@ var DEFAULT_CONTENT_TYPE = { 'Content-Type': 'application/x-www-form-urlencoded' }; +/** + * If the headers object is not undefined and the Content-Type property of the headers object + * is undefined, then set the Content-Type property of the headers object to the value passed + * in + * + * @param {Object} headers - The headers object that will be sent to the server. + * @param {any} value - The value of the Content-Type header. + * + * @returns {void} + */ function setContentTypeIfUnset(headers, value) { if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { headers['Content-Type'] = value; } } +/** + * If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP + * adapter + * + * @returns {Function} + */ function getDefaultAdapter() { var adapter; if (typeof XMLHttpRequest !== 'undefined') { @@ -31,6 +47,16 @@ function getDefaultAdapter() { return adapter; } +/** + * It takes a string, tries to parse it, and if it fails, it returns the stringified version + * of the input + * + * @param {any} rawValue - The value to be stringified. + * @param {Function} parser - A function that parses a string into a JavaScript object. + * @param {Function} encoder - A function that takes a value and returns a string. + * + * @returns {string} A stringified version of the rawValue. + */ function stringifySafely(rawValue, parser, encoder) { if (utils.isString(rawValue)) { try {