<commit_before>import * as most from 'most'
import { clone } from 'lodash'
import shortid from 'shortid'

shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%^')

module.exports = function ajax(namespace, db) {
  return function createRequest(request) {

    request = clone(request)

    request = {
      id: shortid.generate(),
      url: request.url,
      headers: request.headers ? request.headers : {},
      labels: request.labels ? request.labels : [request.url],
      method: request.method,
      createdAt: new Date().getTime(), // db.get('/time/ms'),
      readyState: 0,
      maxAttempts: 3,
      attempts: 0,
      patch: request.patch
    }

    if (request.patch === true) {
      request.headers['content-type'] = 'application/json'
    }

    /**
     * Check if there is a current ajax pending on this <commit_msg>Add ajax data in requests.<commit_after>import * as most from 'most'
import { clone } from 'lodash'
import shortid from 'shortid'

shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%^')

module.exports = function ajax(namespace, db) {
  return function createRequest(request) {

    request = clone(request)

    request = {
      id: shortid.generate(),
      url: request.url,
      headers: request.headers ? request.headers : {},
      labels: request.labels ? request.labels : [request.url],
      method: request.method,
      createdAt: new Date().getTime(), // db.get('/time/ms'),
      readyState: 0,
      maxAttempts: 3,
      attempts: 0,
      patch: request.patch,
      data: request.data
    }

    if (request.patch === true) {
      request.headers['content-type'] = 'application/json'
    }

    /**
     * Check if there is a current ajax pending on this 
{'fraction_non_alphanumeric': 0.12507042253521128, 'fraction_numerical': 0.014647887323943662, 'mean_word_length': 3.064073226544622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4845871', 'n_tokens_mistral': 585, 'n_tokens_neox': 543, 'n_words': 134}