<commit_before>var Emitter  = require('../util/Emitter')
var set      = require('../object/set')
var get      = require('../object/get')
var has      = require('../object/has')
var omit     = require('../object/omit')
var kindOf   = require('../lang/kindOf')
var isOr     = require('../lang/isOr')
var toFlags  = require('../string/toFlags')
var objVisit = require('./visit')

function Base () {
  Emitter.call(this)
  this.cache = {}
  this.options = this.cache.options = {}
}

Emitter(Base.prototype)

Base.prototype.set       = setter
Base.prototype.get       = getter
Base.prototype.has       = hasit
Base.prototype.del       = removeit
Base.prototype.option    = option
Base.prototype.enable    = enable
Base.prototype.disable   = disable
Base.prototype.isEnabled = enabled
Base.prototype.isDisabled = disabled
Base.prototype.isTrue    = isTrue
Base.prototype.isFalse   = isFalse
Base.prototype.isBoolean = isBoolean
Base.prototype.hasOption = hasOption
Base.prototype.flags     = flags
Base.prototype.visit     = visitor

// sets 'value' to 'key' of the cache
function setter (key, value) {
  if (arguments.length === 1 && typeof key === 'object') this.visit('set', key, value)
  else set(this.cache, key, value)
  this.emit('set', key, value)
  return this
}

// gets the cached value for 'key' or entire cache
function getter (key) {
  return key ? get(this.cache, key) : this.cache
}

// checks if a cached value for 'key exists'
function hasit (key) {
  if (key.indexOf('.') === -1) return this.cache.hasOwnProperty(key)
  return has(this.cache, key)
}

// remove 'keys' from the cache. if no value specified, the entire cache is reset
function removeit (key) {
  this.cache = key ? omit(this.cache, key) : {}
  this.emit('del', key)
  return this
}

function option (key, val) {
  if (arguments.length === 1 && kindOf(key) === 'string') {
    if (key.indexOf('.') === -1) return this.options[key]

    return get(this.options, key)
  }

  if (isOr(kindOf(key), 'object', 'array')) {
    return this.visit('option', [].slice.call(arguments))
  }

  set(this.options, key, val)
  this.emit('option', key, val)
  return this
}

function enable (key) {
  return this.option(key, true)
}

function disable (key) {
  this.option(key, false)
}

function enabled (key) {
  return Boolean(this.options[key])
}

function disabled (key) {
  return !Boolean(this.options[key])
}

function isTrue (key) {
  return this.options[key] === true
}

function isFalse (key) {
  return this.options[key] === false
}

function isBoolean (key) {
  return typeof this.options[key] === 'boolean'
}

function hasOption (key) {
  if (key.indexOf('.') === -1) return this.options.hasOwnProperty(key)
  return has(this.options, key)
}

function flags (keys) {
  keys = keys || Object.keys(this.options)
  return toFlags(this.options, keys)
}

function visitor (method, target) {
  objVisit(this, method, target)
  return this
}

module.exports = Base
<commit_msg>minor edits cache/app.js<commit_after>var Emitter  = require('../util/Emitter')
var set      = require('../object/set')
var get      = require('../object/get')
var has      = require('../object/has')
var omit     = require('../object/omit')
var kindOf   = require('../lang/kindOf')
var isOr     = require('../lang/isOr')
var toFlags  = require('../string/toFlags')
var visit    = require('./visit')

function App () {
  Emitter.call(this)
  this.cache = {}
  this.options = this.cache.options = {}
}

Emitter(App.prototype)

App.prototype.set       = setter
App.prototype.get       = getter
App.prototype.has       = hasit
App.prototype.del       = removeit
App.prototype.option    = option
App.prototype.enable    = enable
App.prototype.disable   = disable
App.prototype.isEnabled = enabled
App.prototype.isDisabled = disabled
App.prototype.isTrue    = isTrue
App.prototype.isFalse   = isFalse
App.prototype.isBoolean = isBoolean
App.prototype.hasOption = hasOption
App.prototype.flags     = flags
App.prototype.vis       = visitor

// sets 'value' to 'key' of the cache
function setter (key, value) {
  if (arguments.length === 1 && typeof key === 'object') this.vis('set', key, value)
  else set(this.cache, key, value)
  this.emit('set', key, value)
  return this
}

// gets the cached value for 'key' or entire cache
function getter (key) {
  return key ? get(this.cache, key) : this.cache
}

// checks if a cached value for 'key exists'
function hasit (key) {
  if (key.indexOf('.') === -1) return this.cache.hasOwnProperty(key)
  return has(this.cache, key)
}

// remove 'keys' from the cache. if no value specified, the entire cache is reset
function removeit (key) {
  this.cache = key ? omit(this.cache, key) : {}
  this.emit('del', key)
  return this
}

function option (key, val) {
  if (arguments.length === 1 && kindOf(key) === 'string') {
    if (key.indexOf('.') === -1) return this.options[key]

    return get(this.options, key)
  }

  if (isOr(kindOf(key), 'object', 'array')) {
    return this.vis('option', [].slice.call(arguments))
  }

  set(this.options, key, val)
  this.emit('option', key, val)
  return this
}

function enable (key) {
  return this.option(key, true)
}

function disable (key) {
  this.option(key, false)
}

function enabled (key) {
  return Boolean(this.options[key])
}

function disabled (key) {
  return !Boolean(this.options[key])
}

function isTrue (key) {
  return this.options[key] === true
}

function isFalse (key) {
  return this.options[key] === false
}

function isBoolean (key) {
  return typeof this.options[key] === 'boolean'
}

function hasOption (key) {
  if (key.indexOf('.') === -1) return this.options.hasOwnProperty(key)
  return has(this.options, key)
}

function flags (keys) {
  keys = keys || Object.keys(this.options)
  return toFlags(this.options, keys)
}

function visitor (method, target) {
  visit(this, method, target)
  return this
}

module.exports = App

{'fraction_non_alphanumeric': 0.15554799183117768, 'fraction_numerical': 0.0017018379850238256, 'mean_word_length': 3.541731066460587, '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': '3989074', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1928, 'n_words': 516}