node-ipc/entities/EventParser.js
2017-04-15 22:17:25 -07:00

32 lines
567 B
JavaScript

'use strict';
const Defaults = require('./Defaults.js');
class Parser{
constructor(config){
if(!config){
config=new Defaults;
}
this.delimiter=config.delimiter;
}
format(message){
if(!message.data && message.data!==false && message.data!==0){
message.data={};
}
if(message.data['_maxListeners']){
message.data={};
}
message=message.JSON+this.delimiter;
return message;
}
parse(data){
let events=data.split(this.delimiter);
events.pop();
return events;
}
}
module.exports=Parser;