node-ipc/entities/EventParser.js

33 lines
567 B
JavaScript
Raw Permalink Normal View History

2016-01-10 23:18:14 +11:00
'use strict';
const Defaults = require('./Defaults.js');
2017-04-16 14:13:15 +10:00
class Parser{
constructor(config){
if(!config){
config=new Defaults;
}
this.delimiter=config.delimiter;
2017-04-16 14:13:15 +10:00
}
format(message){
2016-03-16 20:46:10 +11:00
if(!message.data && message.data!==false && message.data!==0){
message.data={};
}
if(message.data['_maxListeners']){
message.data={};
}
message=message.JSON+this.delimiter;
return message;
2017-04-16 14:13:15 +10:00
}
2014-02-22 20:13:31 +11:00
parse(data){
let events=data.split(this.delimiter);
2014-02-22 20:13:31 +11:00
events.pop();
return events;
2017-04-16 14:13:15 +10:00
}
2014-02-22 20:13:31 +11:00
}
2017-04-16 14:13:15 +10:00
module.exports=Parser;