index.js
function ask(questions) {
  "use strict";
  let answers = {};
  let i = 0;

  return new Promise(function(resolve, reject) {
    function askQuestion(item) {
      let key = item.key;
      let msg = item.msg;
      let fn = fnList[item.fn];
      if (!key) {
        throw new Error('A value for `key` must be defined for question '+i);
      }
      if (!msg) {
        throw new Error('A value for `msg` must be defined for question '+i);
      }
      if (!fn) {
        throw new Error('A value for `fn` must be "prompt", "confirm", or "multiline" for question '+i);
      }

      if (fn) {
        fn(msg, key, answers).then(
          function() {
            next();
          }
        );
      }
    }

    function next() {
      if (i < questions.length) {
        var question = questions[i];
        i++;
        askQuestion(question);
      }
      else {
        resolve(answers);
      }
    }

    next();
  });
}
function ask(questions) {
  "use strict";
  let answers = {};
  let i = 0;

  return new Promise(function(resolve, reject) {
    function askQuestion(item) {
      let key = item.key;
      let msg = item.msg;
      let fn = fnList[item.fn];
      if (!key) {
        throw new Error('A value for `key` must be defined for question '+i);
      }
      if (!msg) {
        throw new Error('A value for `msg` must be defined for question '+i);
      }
      if (!fn) {
        throw new Error('A value for `fn` must be "prompt", "confirm", or "multiline" for question '+i);
      }

      if (fn) {
        fn(msg, key, answers).then(
          function() {
            next();
          }
        );
      }
    }

    function next() {
      if (i < questions.length) {
        var question = questions[i];
        i++;
        askQuestion(question);
      }
      else {
        resolve(answers);
      }
    }

    next();
  });
}
Public functions