<commit_before>var fs = require('fs');
var SyncFP = require('./SyncFP');
var TaskFP = require('./TaskFP');
var FlowerPowerApi = require('../node-flower-power-cloud/FlowerPowerCloud');
var util = require('util');
var async = require('async');
var EventEmitter = require('events');
var clc = require('cli-color');
var Chance = require('chance');
var chance = new Chance();

function FlowerBridge(url) {
	EventEmitter.call(this);
	this._state = 'off';
	this.user = null;
	this.api = new FlowerPowerApi(url);
	this.q = null;
	this.initBridge();
};

util.inherits(FlowerBridge, EventEmitter);

FlowerBridge.prototype.initBridge = function() {
	var self = this;

	self.q = async.queue(function(task, callbackNext) {
		if (!task.user) {
			self.getUser(function (err, user) {
				if (err) return callbackNext(err);
				else {
					task.user = user;
					self.do(task, callbackNext);
				}
			});
		}
		else self.do(task, callbackNext);
	}, 1);<commit_msg>Add emit end when drain called<commit_after>var fs = require('fs');
var SyncFP = require('./SyncFP');
var TaskFP = require('./TaskFP');
var FlowerPowerApi = require('../node-flower-power-cloud/FlowerPowerCloud');
var util = require('util');
var async = require('async');
var EventEmitter = require('events');
var clc = require('cli-color');
var Chance = require('chance');
var chance = new Chance();

function FlowerBridge(url) {
	EventEmitter.call(this);
	this._state = 'off';
	this.user = null;
	this.api = new FlowerPowerApi(url);
	this.q = null;
	this.initBridge();
};

util.inherits(FlowerBridge, EventEmitter);

FlowerBridge.prototype.initBridge = function() {
	var self = this;

	self.q = async.queue(function(task, callbackNext) {
		if (!task.user) {
			self.getUser(function (err, user) {
				if (err) return callbackNext(err);
				else {
					task.user = user;
					self.do(task, callbackNext);
				}
			});
		}
		else self.do(task, callbackNext);
	}, 1);
	self.q.drain = function() {
		self.emit('end');
	}
{'fraction_non_alphanumeric': 0.17150127226463105, 'fraction_numerical': 0.0010178117048346056, 'mean_word_length': 4.327913279132791, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3470635', 'n_tokens_mistral': 728, 'n_tokens_neox': 664, 'n_words': 151}