prompt-choices
Advanced tools
Comparing version 0.3.0 to 0.3.2
@@ -20,6 +20,8 @@ 'use strict'; | ||
function Choices(choices, answers) { | ||
choices = choices || []; | ||
if (utils.isObject(choices) && choices.isChoices) { | ||
return choices; | ||
} | ||
utils.define(this, 'isChoices', true); | ||
utils.define(this, 'answers', answers || {}); | ||
this.original = choices.slice(); | ||
this.original = utils.arrayify(choices).slice(); | ||
this.keymap = {}; | ||
@@ -26,0 +28,0 @@ this.items = []; |
@@ -37,3 +37,3 @@ 'use strict'; | ||
this.value = choice.hasOwnProperty('value') ? choice.value : choice.name; | ||
this.short = choice.short || choice.name; | ||
this.short = this.alias = (choice.short || choice.name); | ||
@@ -40,0 +40,0 @@ if (typeof choice.disabled === 'function') { |
{ | ||
"name": "prompt-choices", | ||
"description": "Create an array of multiple choice objects for use in prompts.", | ||
"version": "0.3.0", | ||
"version": "0.3.2", | ||
"homepage": "https://github.com/enquirer/prompt-choices", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
@@ -37,3 +37,3 @@ # prompt-choices [![NPM version](https://img.shields.io/npm/v/prompt-choices.svg?style=flat)](https://www.npmjs.com/package/prompt-choices) [![NPM downloads](https://img.shields.io/npm/dm/prompt-choices.svg?style=flat)](https://npmjs.org/package/prompt-choices) [![Build Status](https://img.shields.io/travis/enquirer/prompt-choices.svg?style=flat)](https://travis-ci.org/enquirer/prompt-choices) | ||
### [.addChoices](index.js#L42) | ||
### [.addChoices](index.js#L44) | ||
@@ -52,3 +52,3 @@ Add an array of normalized `choice` objects to the `choices` array. This method is called in the constructor, but it can also be used to add choices after instantiation. | ||
### [.choice](index.js#L75) | ||
### [.choice](index.js#L77) | ||
@@ -68,3 +68,3 @@ Create a new `Choice` object. | ||
### [.separator](index.js#L90) | ||
### [.separator](index.js#L92) | ||
@@ -84,3 +84,3 @@ Create a new `Separator` object. See [choices-separator](https://github.com/enquirer/choices-separator) for more details. | ||
### [.getChoice](index.js#L105) | ||
### [.getChoice](index.js#L107) | ||
@@ -100,3 +100,3 @@ Get a non-separator choice from the collection. | ||
### [.getIndex](index.js#L125) | ||
### [.getIndex](index.js#L127) | ||
@@ -116,3 +116,3 @@ Get the index of a non-separator choice from the collection. | ||
### [.get](index.js#L146) | ||
### [.get](index.js#L148) | ||
@@ -132,3 +132,3 @@ Get the choice or separator object at the specified index. | ||
### [.enable](index.js#L163) | ||
### [.enable](index.js#L165) | ||
@@ -147,3 +147,3 @@ Enable the choice at the given `idx`. | ||
### [.disable](index.js#L178) | ||
### [.disable](index.js#L180) | ||
@@ -162,3 +162,3 @@ Disable the choice at the given `idx`. | ||
### [.toggleChoices](index.js#L193) | ||
### [.toggleChoices](index.js#L195) | ||
@@ -177,3 +177,3 @@ Enable the choice at the given `index`, and disable all other choices. | ||
### [.toggleChoice](index.js#L208) | ||
### [.toggleChoice](index.js#L210) | ||
@@ -192,3 +192,3 @@ Toggle the choice at the given `idx`. | ||
### [.where](index.js#L222) | ||
### [.where](index.js#L224) | ||
@@ -202,3 +202,3 @@ Return choices that return truthy based on the given `val`. | ||
### [.pluck](index.js#L257) | ||
### [.pluck](index.js#L259) | ||
@@ -212,15 +212,15 @@ Pluck an object with the specified key from the choices collection. | ||
### [.length](index.js#L300) | ||
### [.length](index.js#L302) | ||
Getter for getting the length of the collection. | ||
### [.realChoices](index.js#L315) | ||
### [.realChoices](index.js#L317) | ||
Getter for getting all non-separator choices from the collection. | ||
### [.realLength](index.js#L338) | ||
### [.realLength](index.js#L340) | ||
Getter for getting the length of the collection excluding non-separator choices. | ||
### [.Separator](index.js#L358) | ||
### [.Separator](index.js#L360) | ||
@@ -227,0 +227,0 @@ Create a new `Separator` object. See [choices-separator](https://github.com/enquirer/choices-separator) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18734
388