Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / inquirer / lib / utils / utils.js
1 'use strict';
2 var _ = {
3   isFunction: require('lodash/isFunction'),
4 };
5 var { from, of } = require('rxjs');
6 var 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
17 exports.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 };