Ohm-Management - Projektarbeit B-ME
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.

utils.js 780B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var _ = require('lodash');
  3. var { from, of } = require('rxjs');
  4. var runAsync = require('run-async');
  5. /**
  6. * Resolve a question property value if it is passed as a function.
  7. * This method will overwrite the property on the question object with the received value.
  8. * @param {Object} question - Question object
  9. * @param {String} prop - Property to fetch name
  10. * @param {Object} answers - Answers object
  11. * @return {Rx.Observable} - Observable emitting once value is known
  12. */
  13. exports.fetchAsyncQuestionProperty = function(question, prop, answers) {
  14. if (!_.isFunction(question[prop])) {
  15. return of(question);
  16. }
  17. return from(
  18. runAsync(question[prop])(answers).then(value => {
  19. question[prop] = value;
  20. return question;
  21. })
  22. );
  23. };