<commit_before>(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof module === 'object' && module.exports) {
    module.exports = factory();
  } else {
    root['isval'] = factory();
  }
})(this, function() {
  return function isval(value, type) {
    if (arguments.length === 2 && typeof type === 'undefined') {
      type = 'undefined';
    } else if (isNaN_(type)) {
      type = 'NaN';
    }

    function isNaN_(num) {
      if (typeof Number.isNaN === 'function') {
        return Number.isNaN(num);
      } else if (typeof isNaN === 'function') {
        return isNaN(num);
      } else {
        return num !== num;
      }
    }

    function isObject(obj) {
      return typeof value === 'object' && value !== null;
    }

    function constructorType(constructor) {
      return constructor.name.toLowerCase();
    }

    function isGenerator(obj) {
      return obj &&
        typeof obj.next === 'function' &&
        typeof obj.throw === 'function'
    }

    function isGeneratorFunction(fn) {
      return typeof fn === 'function' &&
        fn.constructor &&
        fn.constructor.name === 'GeneratorFunction'
    }

    switch (type) {
      case 'boolean':
      case 'function':
      case 'string':
        return typeof value === type;

      case 'number':
        return typeof value === type && !isNaN(value);

      case Number:
        if (isNaN_(value)) { return false; }
      // fall through
      case String:
      case Boolean:
        return typeof value === constructorType(type);

      case Object:
      case 'object':
        return isObject(value);

      case 'array':
        return Array.isArray(value);

      case 'regex':
      case 'regexp':
        return value instanceof RegExp;

      case 'date':
        return value instanceof Date;

      case 'null':
      case null:
        return value === null;

      case 'undefined':
        return typeof value === 'undefined';

      case 'NaN':
        return isNaN_(value);

      case 'arguments':
        if (isObject(value)) {
          return (typeof value.callee === 'function')
            || (/arguments/i).test(value.toString());
        }
        return false;

      case 'integer':
        return isval(value, 'number') && value % 1 === 0;

      case 'generator':
        return isGenerator(value);

      case 'generator*':
        return isGeneratorFunction(value);

      default:
        return (typeof type === 'function')
          ? value instanceof type
          : value;
    }
  };
});
<commit_msg>browsers isNaN is not the same function as Number.isNaN<commit_after>(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof module === 'object' && module.exports) {
    module.exports = factory();
  } else {
    root['isval'] = factory();
  }
})(this, function() {
  return function isval(value, type) {
    if (arguments.length === 2 && typeof type === 'undefined') {
      type = 'undefined';
    } else if (isNaN_(type)) {
      type = 'NaN';
    }

    function isNaN_(num) {
      if (typeof Number.isNaN === 'function') {
        return Number.isNaN(num);
      } else {
        return num !== num;
      }
    }

    function isObject(obj) {
      return typeof value === 'object' && value !== null;
    }

    function constructorType(constructor) {
      return constructor.name.toLowerCase();
    }

    function isGenerator(obj) {
      return obj &&
        typeof obj.next === 'function' &&
        typeof obj.throw === 'function'
    }

    function isGeneratorFunction(fn) {
      return typeof fn === 'function' &&
        fn.constructor &&
        fn.constructor.name === 'GeneratorFunction'
    }

    switch (type) {
      case 'boolean':
      case 'function':
      case 'string':
        return typeof value === type;

      case 'number':
        return typeof value === type && !isNaN(value);

      case Number:
        if (isNaN_(value)) { return false; }
      // fall through
      case String:
      case Boolean:
        return typeof value === constructorType(type);

      case Object:
      case 'object':
        return isObject(value);

      case 'array':
        return Array.isArray(value);

      case 'regex':
      case 'regexp':
        return value instanceof RegExp;

      case 'date':
        return value instanceof Date;

      case 'null':
      case null:
        return value === null;

      case 'undefined':
        return typeof value === 'undefined';

      case 'NaN':
        return isNaN_(value);

      case 'arguments':
        if (isObject(value)) {
          return (typeof value.callee === 'function')
            || (/arguments/i).test(value.toString());
        }
        return false;

      case 'integer':
        return isval(value, 'number') && value % 1 === 0;

      case 'generator':
        return isGenerator(value);

      case 'generator*':
        return isGeneratorFunction(value);

      default:
        return (typeof type === 'function')
          ? value instanceof type
          : value;
    }
  };
});

{'fraction_non_alphanumeric': 0.13824615982889366, 'fraction_numerical': 0.00116663426015944, 'mean_word_length': 2.080239520958084, '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': '2506357', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1392, 'n_words': 401}