StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
54 lines
1.1 KiB
4 years ago
|
'use strict';
|
||
|
|
||
|
var utils = require('../utils/');
|
||
|
|
||
|
/**
|
||
|
* Base interface class other can inherits from
|
||
|
*/
|
||
|
|
||
|
var UI = module.exports = function(opt) {
|
||
|
// Instantiate the Readline interface
|
||
|
// @Note: Don't reassign if already present (allow test to override the Stream)
|
||
|
if (!this.rl) {
|
||
|
this.rl = utils.readlineFacade.createInterface(utils.extend({
|
||
|
terminal: true
|
||
|
}, opt));
|
||
|
}
|
||
|
|
||
|
this.rl.resume();
|
||
|
this.onForceClose = this.onForceClose.bind(this);
|
||
|
|
||
|
// Make sure new prompt start on a newline when closing
|
||
|
this.rl.on('SIGINT', this.onForceClose);
|
||
|
process.on('exit', this.onForceClose);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Handle the ^C exit
|
||
|
* @return {null}
|
||
|
*/
|
||
|
|
||
|
UI.prototype.onForceClose = function() {
|
||
|
this.close();
|
||
|
console.log('\n'); // Line return
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Close the interface and cleanup listeners
|
||
|
*/
|
||
|
|
||
|
UI.prototype.close = function() {
|
||
|
// Remove events listeners
|
||
|
this.rl.removeListener('SIGINT', this.onForceClose);
|
||
|
process.removeListener('exit', this.onForceClose);
|
||
|
|
||
|
// Restore prompt functionnalities
|
||
|
this.rl.output.unmute();
|
||
|
|
||
|
// Close the readline
|
||
|
this.rl.output.end();
|
||
|
this.rl.pause();
|
||
|
this.rl.close();
|
||
|
this.rl = null;
|
||
|
};
|