<commit_before>import intValue from '../system/intValue';
import {options} from './options';

var lvlTests = [
  function(level) {return level === 0;},
  function(level, min, max) {return isNaN(min) && isNaN(max);},
  function(level, min, max) {return isNaN(min) && level <= max;},
  function(level, min, max) {return min <= level && isNaN(max);},
  function(level, min, max) {return min <= level && level <= max;}
];

function doLvlFilter(_settings, data) {
  var min = options.fshMinLvl;
  var max = options.fshMaxLvl;
  var level = intValue(data[1]); // use data for the level column
  for (var i = 0; i < lvlTests.length; i += 1) {
    if (lvlTests[i](level, min, max)) {return true;}
  }
  return false;
}

export function lvlFilter() { // jQuery
  /* Custom filtering function which will search
  data in column 2 between two values */
  $.fn.dataTable.ext.search.push(doLvlFilter);
}

export function typeFilter() { // jQuery
  $.fn.dataTable.ext.search.push(
    function(_settings, _row, _index, data) {
      return !options.checkedElements ||
        options.checkedElements[data.type];
    }
  );
}

function testSetId(data) {
  return options.checkedElements['-1'] &&
    data.stats && data.stats.set_id !== '-1';
}

export function setFilter() { // jQuery
  $.fn.dataTable.ext.search.push(
    function(_settings, _row, _index, data) {
      return !options.checkedElements ||
        !options.checkedElements['-1'] ||
        testSetId(data);
    }
  );
}

export function rarityFilter() { // jQuery
  $.fn.dataTable.ext.search.push(
    function(_settings, _row, _index, data) {
      var rarity = (parseInt(data.rarity, 10) + 100).toString();
      return !options.checkedElements ||
        options.checkedElements[rarity];
    }
  );
}<commit_msg>inventory API update<commit_after>import intValue from '../system/intValue';
import {options} from './options';

var lvlTests = [
  function(level) {return level === 0;},
  function(level, min, max) {return isNaN(min) && isNaN(max);},
  function(level, min, max) {return isNaN(min) && level <= max;},
  function(level, min, max) {return min <= level && isNaN(max);},
  function(level, min, max) {return min <= level && level <= max;}
];

function doLvlFilter(_settings, data) {
  var min = options.fshMinLvl;
  var max = options.fshMaxLvl;
  var level = intValue(data[1]); // use data for the level column
  for (var i = 0; i < lvlTests.length; i += 1) {
    if (lvlTests[i](level, min, max)) {return true;}
  }
  return false;
}

export function lvlFilter() { // jQuery
  /* Custom filtering function which will search
  data in column 2 between two values */
  $.fn.dataTable.ext.search.push(doLvlFilter);
}

export function typeFilter() { // jQuery
  $.fn.dataTable.ext.search.push(
    function(_settings, _row, _index, data) {
      return !options.checkedElements ||
        options.checkedElements[data.type];
    }
  );
}

function testSetId(data) {
  return options.checkedElements['-1'] &&
    data.stats && data.stats.set_id !== -1;
}

export function setFilter() { // jQuery
  $.fn.dataTable.ext.search.push(
    function(_settings, _row, _index, data) {
      return !options.checkedElements ||
        !options.checkedElements['-1'] ||
        testSetId(data);
    }
  );
}

export function rarityFilter() { // jQuery
  $.fn.dataTable.ext.search.push(
    function(_settings, _row, _index, data) {
      var rarity = (parseInt(data.rarity, 10) + 100).toString();
      return !options.checkedElements ||
        options.checkedElements[rarity];
    }
  );
}
{'fraction_non_alphanumeric': 0.1583262651964942, 'fraction_numerical': 0.0073508623126943735, 'mean_word_length': 3.4841571609632447, 'pattern_counts': {'":': 0, '<': 13, '<?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': '6793585', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1148, 'n_words': 288}