<commit_before>const
  _ = require('lodash'),
  compare = require('../private/compare'),
  Omissions = require('../model/Omissions'),
  Nest = require('../model/Nest')

function trampoline  (fn) {

  while (typeof fn === 'function'){
    fn = fn()
  }

  return fn

}

function inspectNest(omissions, baseObj, prop){

  //we split it because prop is of the form: 'parent.child.grandchild'
  const nestName = prop.split('.').pop();

  //get the nested Object
  const nestedObj = _.get(baseObj, prop)

  //check for strings
  return checkForString(omissions, baseObj, nestedObj, omissions.nests.find((nest) => nest.root === nestName))

}

function checkForString(omissions, baseObj, nestedObj, parentNest) {

  parentNest ? console.log(`parentName: ${parentNest.root}`) : null

  _.forEach(nestedObj, (val, key) => {
    if(typeof val === 'string' && parentNest === null){
      omissions.addProp(key)
    } else if(typeof val === 'string' && parentNest) {
      parentNest.addProp(key)
    } else {
      console.log(`key is: ${key}`)
      const nest = new Nest(key)
      nest.setFullRoot(omissions.getKeyWithRoot(key))
      parentNest ? parentNest.addChild(nest) : null
      omissions.addInspectProp(omissions.getKeyWithRoot(key), nest)
    }
  })

  //if there are more props to inspect, inspect those props
  if(omissions.inspectProps.length > 0){
    const prop = omissions.inspectProps.shift()
    omissions.setInspectRoot(prop)
    return inspectNest(omissions, baseObj, prop)
  }

  return true

}


// baseobject, name of baseobject language, name of translation language, translation object
module.exports = (baseObj, baseName, transBaseName, translationObj) => {

  let omissions = new Omissions(baseName)
  omissions.setInspectRoot('')

  trampoline(checkForString(omissions, baseObj, baseObj, null))


  console.log('------ FINISHED INSPECTING---------');

  console.log('------ FINISHED COMPARING --------');

  console.log(JSON.stringify(omissions.nests,null,4))

  console.log(omissions.props)

  console.log(omissions.inspectProps);<commit_msg>- utilise properties of the omissions object as opposed to passing on arguments<commit_after>const
  _ = require('lodash'),
  compare = require('../private/compare'),
  Omissions = require('../model/Omissions'),
  Nest = require('../model/Nest')

function trampoline  (fn) {

  while (typeof fn === 'function'){
    fn = fn()
  }

  return fn

}

function inspectNest(omissions, baseObj){

  //we split it because prop is of the form: 'parent.child.grandchild'
  const prop = omissions.inspectRoot
  const nestName = prop.split('.').pop();

  //get the nested Object
  const nestedObj = _.get(baseObj, prop)

  //check for strings
  return checkForString(omissions, baseObj, nestedObj, omissions.nests.find((nest) => nest.root === nestName))

}

function checkForString(omissions, baseObj, nestedObj, parentNest) {

  parentNest ? console.log(`parentName: ${parentNest.root}`) : null

  _.forEach(nestedObj, (val, key) => {
    if(typeof val === 'string' && parentNest === null){
      omissions.addProp(key)
    } else if(typeof val === 'string' && parentNest) {
      parentNest.addProp(key)
    } else {
      console.log(`key is: ${key}`)
      const nest = new Nest(key)
      nest.setFullRoot(omissions.getKeyWithRoot(key))
      parentNest ? parentNest.addChild(nest) : null
      omissions.addInspectProp(omissions.getKeyWithRoot(key), nest)
    }
  })

  //if there are more props to inspect, inspect those props
  if(omissions.inspectProps.length > 0){
    const prop = omissions.inspectProps.shift()
    omissions.setInspectRoot(prop)
    return inspectNest(omissions, baseObj)
  }

  return true

}


// baseobject, name of baseobject language, name of translation language, translation object
module.exports = (baseObj, baseName, transBaseName, translationObj) => {

  let omissions = new Omissions(baseName)
  omissions.setInspectRoot('')

  trampoline(checkForString(omissions, baseObj, baseObj, null))


  console.log('------ FINISHED INSPECTING---------');

  console.log('------ FINISHED COMPARING --------');

  console.log(JSON.stringify(omissions.nests,null,4))

  console.log(omissions.props)

  console.log(omissions.inspectProps);
{'fraction_non_alphanumeric': 0.1463125444628883, 'fraction_numerical': 0.0009485416172634575, 'mean_word_length': 3.7553551296505074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2051846', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1308, 'n_words': 308}