source: trip-planner-front/node_modules/inquirer/lib/utils/utils.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 819 bytes
Line 
1'use strict';
2const _ = {
3 isFunction: require('lodash/isFunction'),
4};
5const { from, of } = require('rxjs');
6const runAsync = require('run-async');
7
8/**
9 * Resolve a question property value if it is passed as a function.
10 * This method will overwrite the property on the question object with the received value.
11 * @param {Object} question - Question object
12 * @param {String} prop - Property to fetch name
13 * @param {Object} answers - Answers object
14 * @return {Rx.Observable} - Observable emitting once value is known
15 */
16
17exports.fetchAsyncQuestionProperty = function (question, prop, answers) {
18 if (!_.isFunction(question[prop])) {
19 return of(question);
20 }
21
22 return from(
23 runAsync(question[prop])(answers).then((value) => {
24 question[prop] = value;
25 return question;
26 })
27 );
28};
Note: See TracBrowser for help on using the repository browser.