function addOrReplace(topic, message){
  if(_.isEmpty(_.findWhere(dataStruct, {topic: topic}))){
    // Entry does not exist
    dataStruct.push({topic: topic, message: message});
    console.log('added new entry:       ', topic, message);
  } else {
    // update entry
    var index = _.findLastIndex(dataStruct, {topic: topic});
    dataStruct[index] = {topic: topic, message: message};
    console.log('updated existing entry:', topic, message);
  }
}
/**
 * add a topic and its message to dataStruct or replace existing entry
 *
 * @param topic string
 * @param message string
 */
add a topic and its message to dataStruct or replace existing entry
@param topic string
@param message string
add a topic and its message to dataStruct or replace existing entry @param topic string @param message string
function addOrReplace(topic, message){
  if(_.isEmpty(_.findWhere(dataStruct, {topic: topic}))){
    dataStruct.push({topic: topic, message: message});
    console.log('added new entry:       ', topic, message);
  } else {
    var index = _.findLastIndex(dataStruct, {topic: topic});
    dataStruct[index] = {topic: topic, message: message};
    console.log('updated existing entry:', topic, message);
  }
}
function addOrReplace ( topic , message ) { if ( _ . isEmpty ( _ . findWhere ( dataStruct , { topic : topic } ) ) ) { dataStruct . push ( { topic : topic , message : message } ) ; console . log ( 'added new entry:       ' , topic , message ) ; } else { var index = _ . findLastIndex ( dataStruct , { topic : topic } ) ; dataStruct [ index ] = { topic : topic , message : message } ; console . log ( 'updated existing entry:' , topic , message ) ; } }
add a topic and its message to dataStruct or replace existing entry
 @param topic string
 @param message string
add a topic and its message to dataStruct or replace existing entry @param topic string @param message string
// Entry does not exist // update entry