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.
 
 
 
 
StackGenVis/frontend/node_modules/inquirer2/lib/utils/async.js

44 lines
1.3 KiB

'use strict';
var utils = require('./');
/**
* Create an oversable returning the result of a function runned in sync or async mode.
* @param {Function} func Function to run
* @return {utils.rx.Observable} Observable emitting when value is known
*/
exports.createObservableFromAsync = function(func) {
return utils.rx.Observable.defer(function() {
return utils.rx.Observable.create(function(obs) {
utils.runAsync(func, function(value) {
obs.onNext(value);
obs.onCompleted();
});
});
});
};
/**
* Resolve a question property value if it is passed as a function.
* This method will overwrite the property on the question object with the received value.
* @param {Object} question - Question object
* @param {String} prop - Property to fetch name
* @param {Object} answers - Answers object
* @...rest {Mixed} rest - Arguments to pass to `func`
* @return {utils.rx.Obsersable} - Observable emitting once value is known
*/
exports.fetchAsyncQuestionProperty = function(question, prop, answers) {
if (typeof question[prop] !== 'function') {
return utils.rx.Observable.return(question);
}
return exports.createObservableFromAsync(function() {
var done = this.async();
utils.runAsync(question[prop], function(value) {
question[prop] = value;
done(question);
}, answers);
});
};