All files / lib axios.js

90.91% Statements 20/22
100% Branches 0/0
33.33% Functions 1/3
90.91% Lines 20/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54    1x 1x 1x 1x 1x                 1x 1x     1x     1x   1x       1x     1x     1x         1x 1x 1x     1x     1x   1x     1x  
'use strict';
 
var utils = require('./utils');
var bind = require('./helpers/bind');
var Axios = require('./core/Axios');
var mergeConfig = require('./core/mergeConfig');
var defaults = require('./defaults');
 
/**
 * Create an instance of Axios
 *
 * @param {Object} defaultConfig The default config for the instance
 * @return {Axios} A new instance of Axios
 */
function createInstance(defaultConfig) {
  var context = new Axios(defaultConfig);
  var instance = bind(Axios.prototype.request, context);
 
  // Copy axios.prototype to instance
  utils.extend(instance, Axios.prototype, context);
 
  // Copy context to instance
  utils.extend(instance, context);
 
  return instance;
}
 
// Create the default instance to be exported
var axios = createInstance(defaults);
 
// Expose Axios class to allow class inheritance
axios.Axios = Axios;
 
// Factory for creating new instances
axios.create = function create(instanceConfig) {
  return createInstance(mergeConfig(axios.defaults, instanceConfig));
};
 
// Expose Cancel & CancelToken
axios.Cancel = require('./cancel/Cancel');
axios.CancelToken = require('./cancel/CancelToken');
axios.isCancel = require('./cancel/isCancel');
 
// Expose all/spread
axios.all = function all(promises) {
  return Promise.all(promises);
};
axios.spread = require('./helpers/spread');
 
module.exports = axios;
 
// Allow use of default import syntax in TypeScript
module.exports.default = axios;