<commit_before>
const R        = require('ramda')
const Bluebird = require('bluebird')
/**
 * type Options =
 *   { conn :: RabbitMqConnection
 *   , name :: String
 *   , durable :: Boolean
 *   , prefetch :: Int
 *   }
 */


// getContent :: Message -> String
const getContent = R.compose(
  R.tryCatch(JSON.parse, R.identity)
, (x) => x.toString()
, R.prop('content')
)



// invoker :: Function -> Message -> Status -> Promise Status
const invoker = (handler, message, Status) => {
  if (message) {
    return handler({
      command: message.properties.headers.command
    , payload: getContent(message)
    , resource: message
    }, Status)
  } 
<commit_msg>fix content parser.<commit_after>
const R        = require('ramda')
const Bluebird = require('bluebird')
/**
 * type Options =
 *   { conn :: RabbitMqConnection
 *   , name :: String
 *   , durable :: Boolean
 *   , prefetch :: Int
 *   }
 */


const parseContent = (content) => {
  try {
    return JSON.parse(content)

  } catch (e) {
    return content
  }
}

// getContent :: Message -> String
const getContent = R.compose(
  parseContent
, (x) => x.toString()
, R.prop('content')
)



// invoker :: Function -> Message -> Status -> Promise Status
const invoker = (handler, message, Status) => {
  if (message) {
    return handler({
      command: message.properties.headers.command
    , payload: getContent(message)
    , resource: message
    }, Status)
  } 

{'fraction_non_alphanumeric': 0.1543296089385475, 'fraction_numerical': 0.0, 'mean_word_length': 2.862533692722372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '1180723', 'n_tokens_mistral': 451, 'n_tokens_neox': 440, 'n_words': 111}