<commit_before>import {isString, isObject} from 'lodash'

export default reformatResult

function reformatResult(result, {description, key} = {}) {
  /* eslint complexity:[2, 6] */
  if (isString(result)) {
    return {type: 'error', message: result}
  } else if (isObject(result)) {
    if (result.error) {
      return {type: 'error', message: result.error}
    } else if (result.warning) {
      return {type: 'warning', message: result.warning}
    }
  }
  throw new Error([<commit_msg>style(reformat-result): use 'isPlainObject' as opposed to 'isObject'<commit_after>import {isString, isPlainObject} from 'lodash'

export default reformatResult

function reformatResult(result, {description, key} = {}) {
  /* eslint complexity:[2, 6] */
  if (isString(result)) {
    return {type: 'error', message: result}
  } else if (isPlainObject(result)) {
    if (result.error) {
      return {type: 'error', message: result.error}
    } else if (result.warning) {
      return {type: 'warning', message: result.warning}
    }
  }
  throw new Error([
{'fraction_non_alphanumeric': 0.14736842105263157, 'fraction_numerical': 0.003827751196172249, 'mean_word_length': 3.980952380952381, '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': '2964644', 'n_tokens_mistral': 339, 'n_tokens_neox': 334, 'n_words': 91}