CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
axios.js90 linesDownload Raw Back to lib
1'use strict';2 3import utils from './utils.js';4import bind from './helpers/bind.js';5import Axios from './core/Axios.js';6import mergeConfig from './core/mergeConfig.js';7import defaults from './defaults/index.js';8import formDataToJSON from './helpers/formDataToJSON.js';9import CanceledError from './cancel/CanceledError.js';10import CancelToken from './cancel/CancelToken.js';11import isCancel from './cancel/isCancel.js';12import {VERSION} from './env/data.js';13import toFormData from './helpers/toFormData.js';14import AxiosError from './core/AxiosError.js';15import spread from './helpers/spread.js';16import isAxiosError from './helpers/isAxiosError.js';17import AxiosHeaders from "./core/AxiosHeaders.js";18import adapters from './adapters/adapters.js';19import HttpStatusCode from './helpers/HttpStatusCode.js';20 21/**22 * Create an instance of Axios23 *24 * @param {Object} defaultConfig The default config for the instance25 *26 * @returns {Axios} A new instance of Axios27 */28function createInstance(defaultConfig) {29  const context = new Axios(defaultConfig);30  const instance = bind(Axios.prototype.request, context);31 32  // Copy axios.prototype to instance33  utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});34 35  // Copy context to instance36  utils.extend(instance, context, null, {allOwnKeys: true});37 38  // Factory for creating new instances39  instance.create = function create(instanceConfig) {40    return createInstance(mergeConfig(defaultConfig, instanceConfig));41  };42 43  return instance;44}45 46// Create the default instance to be exported47const axios = createInstance(defaults);48 49// Expose Axios class to allow class inheritance50axios.Axios = Axios;51 52// Expose Cancel & CancelToken53axios.CanceledError = CanceledError;54axios.CancelToken = CancelToken;55axios.isCancel = isCancel;56axios.VERSION = VERSION;57axios.toFormData = toFormData;58 59// Expose AxiosError class60axios.AxiosError = AxiosError;61 62// alias for CanceledError for backward compatibility63axios.Cancel = axios.CanceledError;64 65// Expose all/spread66axios.all = function all(promises) {67  return Promise.all(promises);68};69 70axios.spread = spread;71 72// Expose isAxiosError73axios.isAxiosError = isAxiosError;74 75// Expose mergeConfig76axios.mergeConfig = mergeConfig;77 78axios.AxiosHeaders = AxiosHeaders;79 80axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);81 82axios.getAdapter = adapters.getAdapter;83 84axios.HttpStatusCode = HttpStatusCode;85 86axios.default = axios;87 88// this module should only have a default export89export default axios90