<commit_before>/**
 * Pico-ajax library main module
 *
 * @global Object
 * @exports {Object} picoAjax
 */

import { parseJson, parseUrl } from './helpers';
import { browserRequest } from './browser';
import { serverRequest } from './server';

 /**
  * Known HTTP request methods
  */
const REQUEST_METHODS = [
  'CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT',
];

/**
 * Default request options
 */
const DEFAULT_OPTIONS = {
  async: true,
  body: undefined,
  headers: {},
  onprogress: null,
  password: <PASSWORD>,
  responseType: '',
  timeout: 0,
  username: undefined,
  withCredetials: undefined,
};

/**
 * Universal request
 *
 * @param {string} method HTTP method
 * @param {string} url Url
 * @param {Object} [customOptions] request options
 * @returns {Promise}
 */
function request(method, url, customOptions = {}) {
  // Merge user definded request options with default ones
  const options = Object.assign(DEFAULT_OPTIONS, customOptions);

  return (typeof global !== 'undefined') && (typeof window === 'undefined')
    ? serverRequest(method, url, options)
    : browserRequest(method, url, options)
}

/**
 * Generate request methods
 */
const picoAjax = REQUEST_METHODS.reduce(
  (result, method) => {
    result[method.toLowerCase()] = (...args) => request(method, ...args);
    return result;
  },
  {}
);

export default picoAjax;
<commit_msg>Fix default options typo<commit_after>/**
 * Pico-ajax library main module
 *
 * @global Object
 * @exports {Object} picoAjax
 */

import { parseJson, parseUrl } from './helpers';
import { browserRequest } from './browser';
import { serverRequest } from './server';

 /**
  * Known HTTP request methods
  */
const REQUEST_METHODS = [
  'CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT',
];

/**
 * Default request options
 */
const DEFAULT_OPTIONS = {
  async: true,
  body: undefined,
  headers: {},
  onprogress: null,
  password: <PASSWORD>,
  responseType: '',
  timeout: 0,
  username: undefined,
  withCredentials: undefined,
};

/**
 * Universal request
 *
 * @param {string} method HTTP method
 * @param {string} url Url
 * @param {Object} [customOptions] request options
 * @returns {Promise}
 */
function request(method, url, customOptions = {}) {
  // Merge user definded request options with default ones
  const options = Object.assign(DEFAULT_OPTIONS, customOptions);

  return (typeof global !== 'undefined') && (typeof window === 'undefined')
    ? serverRequest(method, url, options)
    : browserRequest(method, url, options)
}

/**
 * Generate request methods
 */
const picoAjax = REQUEST_METHODS.reduce(
  (result, method) => {
    result[method.toLowerCase()] = (...args) => request(method, ...args);
    return result;
  },
  {}
);

export default picoAjax;

{'fraction_non_alphanumeric': 0.1563845050215208, 'fraction_numerical': 0.0007173601147776184, 'mean_word_length': 3.9275618374558303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4495342', 'n_tokens_mistral': 853, 'n_tokens_neox': 853, 'n_words': 247}