<commit_before>/*
 * Project: Tyval
 * Version: 1.0.0
 * Author: delvedor
 * Twitter: @delvedor
 * License: MIT
 * GitHub: https://github.com/delvedor/Tyval
 */

'use strict'

// Tyval Constructor
function tyval (variable, planned) {
  return new tyval.Init(variable, planned)
}

tyval.prototype = {
  // Checks if the variable is a string
  isString: function () {
    this.check &= this.type === 'string'
    return this.plan()
  },

  // Checks if the variable is a number
  isNumber: function () {
    this.check &= this.type === 'number'
    return this.plan()
  },

  // Checks if the variable is null
  isNull: function () {
    this.check &= this.type === 'null'
    return this.plan()
  },

  // Checks if the variable is undefined
  isUndefined: function () {
    this.check &= this.type === 'undefined'
    return this.plan()
  },

  // Checks if the variable is a boolean
  isBoolean: function () {
    this.check &= this.type === 'boolean'
    return this.plan()
  },

  // Checks if the variable is an object
  isObject: function () {
    this.check &= this.type === 'object'
    return this.plan()
  },

  // Checks if the variable is a function
  isFunction: function () {
    this.check &= this.type === 'function'
    return this.plan()
  },

  // Checks if the variable is lower than the passed max value
  max: function (max = 0) {
    switch (this.type) {
      case 'number':
        this.check &= this.variable <= max
        break
      case 'string':
        this.check &= this.variable.length <= max
        break
      default:
        this.check = false
    }
    return this.plan()
  },

  // Checks if the variable is higher than the passed min value
  min: function (min = 0) {
    switch (this.type) {
      case 'number':
        this.check &= this.variable >= min
        break<commit_msg>Added alphanum and regex<commit_after>/*
 * Project: Tyval
 * Version: 1.0.0
 * Author: delvedor
 * Twitter: @delvedor
 * License: MIT
 * GitHub: https://github.com/delvedor/Tyval
 */

'use strict'

// Tyval Constructor
function tyval (variable, planned) {
  return new tyval.Init(variable, planned)
}

tyval.prototype = {
  // Checks if the variable is a string
  isString: function () {
    this.check &= this.type === 'string'
    return this.plan()
  },

  // Checks if the variable is a number
  isNumber: function () {
    this.check &= this.type === 'number'
    return this.plan()
  },

  // Checks if the variable is null
  isNull: function () {
    this.check &= this.type === 'null'
    return this.plan()
  },

  // Checks if the variable is undefined
  isUndefined: function () {
    this.check &= this.type === 'undefined'
    return this.plan()
  },

  // Checks if the variable is a boolean
  isBoolean: function () {
    this.check &= this.type === 'boolean'
    return this.plan()
  },

  // Checks if the variable is an object
  isObject: function () {
    this.check &= this.type === 'object'
    return this.plan()
  },

  // Checks if the variable is a function
  isFunction: function () {
    this.check &= this.type === 'function'
    return this.plan()
  },

  // Checks if the string is alphanumeric
  alphanum: function () {
    const reg = /((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+[0-9a-z]+$/i
    this.check &= reg.test(this.variable)
    return this.plan()
  },

  // Tests the regex passed as input
  regex: function (reg) {
    this.check &= reg.test(this.variable)
    return this.plan()
  },

  // Checks if the variable is lower than the passed max value
  max: function (max = 0) {
    switch (this.type) {
      case 'number':
        this.check &= this.variable <= max
        break
      case 'string':
        this.check &= this.variable.length <= max
        break
      default:
        this.check = false
    }
    return this.plan()
  },

  // Checks if the variable is higher than the passed min value
  min: function (min = 0) {
    switch (this.type) {
      case 'number':
        this.check &= this.variable >= min
        break
{'fraction_non_alphanumeric': 0.13945918878317476, 'fraction_numerical': 0.00400600901352028, 'mean_word_length': 2.420376712328767, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6280992', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1248, 'n_words': 388}