Sha256: dcdd3440b1e46d9bf700320b3f00a4f479f490fc8811450481c0168dc5e3d6f2

Contents?: true

Size: 814 Bytes

Versions: 64

Compression:

Stored size: 814 Bytes

Contents

'use strict';
var _ = require('lodash');


/**
 * Choice object
 * Normalize input as choice object
 * @constructor
 * @param {String|Object} val  Choice value. If an object is passed, it should contains
 *                             at least one of `value` or `name` property
 */

var Choice = module.exports = function (val, answers) {
  // Don't process Choice and Separator object
  if (val instanceof Choice || val.type === 'separator') {
    return val;
  }

  if (_.isString(val)) {
    this.name = val;
    this.value = val;
  } else {
    _.extend(this, val, {
      name: val.name || val.value,
      value: val.hasOwnProperty('value') ? val.value : val.name
    });
  }

  if (_.isFunction(val.disabled)) {
    this.disabled = val.disabled(answers);
  } else {
    this.disabled = val.disabled;
  }
};

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.3.1 node_modules/bower/node_modules/inquirer/lib/objects/choice.js
trusty-festivity-extension-2.3.0 node_modules/bower/node_modules/inquirer/lib/objects/choice.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/inquirer/lib/objects/choice.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/inquirer/lib/objects/choice.js