<commit_before>'use strict'
var Base = require('../base')
var wrapfilter = require('../util/wrapfilter')
var isArrayLike = require('../util/is/arraylike')

function plain (filter, parseValue) {
  var input = this._input
  if (input !== void 0) {
    if (input instanceof Base) {
      return 'reference [' + input.path + ']'
    } else {
      return parseValue
       ? this.val
       : input
    }
  }
  var obj = {}
  this.each(function (property, key) {
    obj[key] = property instanceof Base
      ? (property.plain
        ? property.plain(filter, parseValue)
        : plain.call(property, filter, parseValue)
      )
      : property
  }, wrapfilter(filter))
  return isArrayLike(obj)
}

exports.define = {
  /**
   * Convert a `Base` object into a plain JSON object
   * @memberOf Base#
   * @param {function} filter function
   * @return {object} Caller converted to standard JSON
   */
  plain: plain
}
<commit_msg>fix for plain with normal objects in between<commit_after>'use strict'
var Base = require('../base')
var wrapfilter = require('../util/wrapfilter')
var isArrayLike = require('../util/is/arraylike')

function plain (filter, parseValue) {
  var input = this._input
  if (input !== void 0) {
    if (input instanceof Base) {
      return 'reference [' + input.path + ']'
    } else {
      return parseValue
        ? this.val
        : input
    }
  }
  var obj = {}
  this.each(function (property, key) {
    obj[key] = property instanceof Base
      ? plainBase(property, filter, parseValue)
      : plainNonBase(property, filter, parseValue)
  }, wrapfilter(filter))
  return isArrayLike(obj)
}

exports.define = {
  /**
   * Convert a `Base` object into a plain JSON object
   * @memberOf Base#
   * @param {function} filter function
   * @return {object} Caller converted to standard JSON
   */
  plain: plain
}

function plainBase (target, filter, parseValue) {
  return target.plain
    ? target.plain(filter, parseValue)
    : plain.call(target, filter, parseValue)
}

function plainNonBase (target, filter, parseValue) {
  if (target instanceof Object) {
    let result = (target instanceof Array) ? [] : {}
    for (let key in target) {
      let value = target[key]
      if (value instanceof Base) {
        result[key] = plainBase(value, filter, parseValue)
      } else {
        result[key] = plainNonBase(value, filter, parseValue)
      }
    }
    return result
  } else {
    return target
  }
}

{'fraction_non_alphanumeric': 0.12535845964768538, 'fraction_numerical': 0.0008193363375665711, 'mean_word_length': 2.839622641509434, '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': '2930637', 'n_tokens_mistral': 739, 'n_tokens_neox': 734, 'n_words': 214}