CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
transformData.js29 linesDownload Raw Back to core
1'use strict';2 3import utils from '../utils.js';4import defaults from '../defaults/index.js';5import AxiosHeaders from '../core/AxiosHeaders.js';6 7/**8 * Transform the data for a request or a response9 *10 * @param {Array|Function} fns A single function or Array of functions11 * @param {?Object} response The response object12 *13 * @returns {*} The resulting transformed data14 */15export default function transformData(fns, response) {16  const config = this || defaults;17  const context = response || config;18  const headers = AxiosHeaders.from(context.headers);19  let data = context.data;20 21  utils.forEach(fns, function transform(fn) {22    data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);23  });24 25  headers.normalize();26 27  return data;28}29