src/default-middleware.js
function parsePayload (message) {
  const messageParts = message && message.match(/^([^:]+)(?::(.*))?/)
  if (!messageParts) return {
    topic: undefined,
    data:  undefined
  }

  const topic = messageParts[1]
  let   data = messageParts[2]

  if (data) {
    try {
      data = JSON.parse(data)
    } catch (error) {
      data = undefined
    }
  }

  return {
    topic,
    data
  }
}
function parsePayload (message) {
  const messageParts = message && message.match(/^([^:]+)(?::(.*))?/)
  if (!messageParts) return {
    topic: undefined,
    data:  undefined
  }

  const topic = messageParts[1]
  let   data = messageParts[2]

  if (data) {
    try {
      data = JSON.parse(data)
    } catch (error) {
      data = undefined
    }
  }

  return {
    topic,
    data
  }
}
function parsePayload ( message ) { const messageParts = message && message . match ( / ^([^:]+)(?::(.*))? / ) if ( ! messageParts ) return { topic : undefined , data : undefined } const topic = messageParts [ 1 ] let data = messageParts [ 2 ] if ( data ) { try { data = JSON . parse ( data ) } catch ( error ) { data = undefined } } return { topic , data } }
parse a string in the format `topic[:data]`, where `data` is valid JSON

@param  {[type]} message a string in the format topic[:data], e.g.
`nextPage` or `gotoPage:{"pageNumber":2}`
@return {[type]} { topic, data }
parse a string in the format topic [ : data ] where data is valid JSON