<commit_before>'use strict';
/**
 *  index.js - <NAME> 2014-10-10
 *  Party Line subsystem interface library file.
 *  @author <NAME>
 *  @version 1.0.0
 *  @license MIT. Read LICENSE for more information.
 *  @fileOverview Main library file.
 */

/**
 * Module dependencies.
 */

/**
 * Constructor for PartyLineSub
 */
function PartyLineSub() {
    var self = this;

    self.worker_id = "";
    self.bus_id = "";
    self.listen_context = [];
    self.packet_handlers = [];
    self.input_stream = require('JSONStream').parse();
    process.stdin.pipe(self.input_stream);

    /**
     *  Outputs a single packet to stdout stream.
     *  Defined inside of block because function is needed immediately.
     */
    self.send = function(transmit_packet) {
        console.log(JSON.stringify(transmit_packet));
    };
}

var partylinesub = module.exports = exports = new PartyLineSub;

/**
 * Sends to the bus what contexts this subsystem wants to listen to.
 * Accepts no parameters because the context should be set to
 * self.listen_context array.
 */
PartyLineSub.prototype.sendSetListenerContext = function(){
    var self = this;
    var setContextPacket = {
        context: "bus",<commit_msg>Added a outbound buffer.<commit_after>'use strict';
/**
 *  index.js - <NAME> 2014-10-10
 *  Party Line subsystem interface library file.
 *  @author <NAME>
 *  @version 1.0.0
 *  @license MIT. Read LICENSE for more information.
 *  @fileOverview Main library file.
 */

/**
 * Module dependencies.
 */

/**
 * Constructor for PartyLineSub
 */
function PartyLineSub() {
    var self = this;

    self.worker_id = "";
    self.bus_id = "";
    self.listen_context = [];
    self.packet_handlers = [];
    self.input_stream = require('JSONStream').parse();
    process.stdin.pipe(self.input_stream);
    self.outbound_packets = [];
    self.sending_state = false;

    /**
     *  Outputs a single packet to stdout stream.
     *  Defined inside of block because function is needed immediately.
     */
    self.send = function(transmit_packet) {
        self.outbound_packets.push(transmit_packet);
        
        //already running send in a different thread.
        if (self.sending_state) return;
        
        //set state high this thread is going to send.
        self.sending_state = true; 
        
        //keep sending till we run out of packets
        while(self.outbound_packets.length > 0) {
            var packet = self.outbound_packets.pop();
            console.log(JSON.stringify(packet));
        }
        
        //set state low this thread is finished.
        self.sending_state = false;
    };
}

var partylinesub = module.exports = exports = new PartyLineSub;

/**
 * Sends to the bus what contexts this subsystem wants to listen to.
 * Accepts no parameters because the context should be set to
 * self.listen_context array.
 */
PartyLineSub.prototype.sendSetListenerContext = function(){
    var self = this;
    var setContextPacket = {
        context: "bus",
{'fraction_non_alphanumeric': 0.11151919866444074, 'fraction_numerical': 0.007679465776293823, 'mean_word_length': 2.6805896805896805, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2674991', 'n_tokens_mistral': 900, 'n_tokens_neox': 868, 'n_words': 251}