<commit_before>var $ = window.$ = window.jQuery = require('jquery');
require('typeahead.js');
const debounce = require('lodash.debounce');
const getData = require('./get-data');

module.exports = function () {
  let currentRequestId = null;

  $('#searchbox [type=search]').typeahead({
    minLength: 3,
    highlight: true
  }, {
    name: 'suggestions',
    source: debounce((q, onData, onAsyncData) => {
      const requestId = currentRequestId = Date.now();
      const url = `/autocomplete?q=${encodeURIComponent(q)}`;
      const opts = { headers: { Accept: 'application/vnd.api+json' } };

      getData(url, opts, (results) => {
        if (requestId !== currentRequestId) {
          return console.warn('Ignoring autocomplete response', requestId, results);
        }<commit_msg>Fix the tests<commit_after>var $ = window.$ = window.jQuery = require('jquery');
require('typeahead.js');
const debounce = require('lodash.debounce');
const getData = require('./get-data');

module.exports = function () {
  let currentRequestId = null;

  $('#searchbox [type=search]').typeahead({
    minLength: 3,
    highlight: true
  }, {
    name: 'suggestions',
    source: debounce((q, onData, onAsyncData) => {
      const requestId = currentRequestId = Date.now();
      const url = `/autocomplete?q=${encodeURIComponent(q)}`;
      const opts = { headers: { Accept: 'application/vnd.api+json' } };

      getData(url, opts, (err, results) => {
        if (err) {
          // No need to feedback - not mission critical
          return console.error('Failed to autocomplete', err);
        }

        if (requestId !== currentRequestId) {
          return console.warn('Ignoring autocomplete response', requestId, results);
        }
{'fraction_non_alphanumeric': 0.15762124711316397, 'fraction_numerical': 0.0011547344110854503, 'mean_word_length': 3.3652392947103276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4789093', 'n_tokens_mistral': 526, 'n_tokens_neox': 506, 'n_words': 121}