<commit_before>var lnklib = require('../build/Release/lnklib.node');

module.exports = {
	load: lnklib.load,
	unload: lnklib.unload
};<commit_msg>Added class interfacing for the exported library<commit_after>var lnklib = require('../build/Release/lnklib.node');

function LibraryModule()
{
	this.id = undefined;
	this.filepath = undefined;
	this.functions = [];
	
	if(arguments.length > 0) {
		this.load.apply(this, arguments);
	}
}

LibraryModule.prototype.load = function(filepath) {
	if(this.id) {
		this.close();
	}
	this.id = lnklib.load(filepath);
	this.filepath = filepath;
};

LibraryModule.prototype.close = function() {
	if(this.id) {
		for(var i in this.functions) {
			lnklib.clearFunction(this.functions[i].id);
		}
		
		return lnklib.unload(this.id);
	}
	return false;
};

LibraryModule.prototype._getLinkId = function(identifier) {
	for(var i in this.functions) {
		if(this.functions[i].identifier == identifier) {
			return this.functions[i].id;
		}
	}
	return 0;
};

LibraryModule.prototype.linkFunction = function(identifier) {
	var id = this._getLinkId(identifier);
	if(id === 0) {
		id = lnklib.getFunction(this.id, identifier);
	
		this.functions.push({
			id: id,
			identifier: identifier
		});
	}
	
	return function() {
		console.log('TODO: Call function');
	}
};

module.exports = LibraryModule;
{'fraction_non_alphanumeric': 0.1553030303030303, 'fraction_numerical': 0.0022727272727272726, 'mean_word_length': 4.200787401574803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1618656', 'n_tokens_mistral': 505, 'n_tokens_neox': 465, 'n_words': 82}