2016-01-10 04:18:14 -08:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-10 04:57:08 -08:00
|
|
|
const parser={
|
|
|
|
parse : parseDataEvents,
|
|
|
|
format : formatData,
|
|
|
|
delimiter : '\f'
|
|
|
|
};
|
2015-09-27 03:32:14 -07:00
|
|
|
|
|
|
|
function formatData(message){
|
2016-03-16 02:46:10 -07:00
|
|
|
if(!message.data && message.data!==false && message.data!==0){
|
2015-09-27 03:32:14 -07:00
|
|
|
message.data={};
|
|
|
|
}
|
|
|
|
if(message.data['_maxListeners']){
|
|
|
|
message.data={};
|
|
|
|
}
|
|
|
|
|
|
|
|
message=message.JSON+parser.delimiter;
|
|
|
|
return message;
|
2016-01-10 04:18:14 -08:00
|
|
|
}
|
2014-02-22 01:13:31 -08:00
|
|
|
|
|
|
|
function parseDataEvents(data){
|
2016-01-10 04:18:14 -08:00
|
|
|
let events=data.split(parser.delimiter);
|
2014-02-22 01:13:31 -08:00
|
|
|
events.pop();
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
2015-09-27 03:32:14 -07:00
|
|
|
module.exports=parser;
|