lib/prompt-filters.js
function (input, sep, choices) {
    debug('requiredTextStartsWithListFilter(%s, %s, %s)', input, sep, (choices ? JSON.stringify(choices) : 'undefined'));
    // if we already have a list, just return it. We may
    // want to add validation that the items are in the
    // choices list
    if (_.isArray(input) && input.length > 0) return input;
    if (choices === undefined) return undefined;
    if (!_.isString(input)) return undefined;
    var inputs = input.split(new RegExp('s*\\' + sep + '\\s*'));
    // remove any empty input items
    inputs = inputs.filter(function (i) {
      return (!_.isEmpty(i));
    });
    var lcis = inputs.map(function (i) {
      return i.toLocaleLowerCase();
    });
    var retv = choices.filter(function (c) {
      var lc = c.toLocaleLowerCase();
      return (_.find(lcis, function (li) {
        return (_.startsWith(lc, li));
      }) !== undefined);
    });
    if (_.isEmpty(retv)) return undefined;
    return retv;
  }
function (input, sep, choices) {
    debug('requiredTextStartsWithListFilter(%s, %s, %s)', input, sep, (choices ? JSON.stringify(choices) : 'undefined'));
    // if we already have a list, just return it. We may
    // want to add validation that the items are in the
    // choices list
    if (_.isArray(input) && input.length > 0) return input;
    if (choices === undefined) return undefined;
    if (!_.isString(input)) return undefined;
    var inputs = input.split(new RegExp('s*\\' + sep + '\\s*'));
    // remove any empty input items
    inputs = inputs.filter(function (i) {
      return (!_.isEmpty(i));
    });
    var lcis = inputs.map(function (i) {
      return i.toLocaleLowerCase();
    });
    var retv = choices.filter(function (c) {
      var lc = c.toLocaleLowerCase();
      return (_.find(lcis, function (li) {
        return (_.startsWith(lc, li));
      }) !== undefined);
    });
    if (_.isEmpty(retv)) return undefined;
    return retv;
  }
function ( input , sep , choices ) { debug ( 'requiredTextStartsWithListFilter(%s, %s, %s)' , input , sep , ( choices ? JSON . stringify ( choices ) : 'undefined' ) ) ; // if we already have a list, just return it. We may // want to add validation that the items are in the // choices list if ( _ . isArray ( input ) && input . length > 0 ) return input ; if ( choices === undefined ) return undefined ; if ( ! _ . isString ( input ) ) return undefined ; var inputs = input . split ( new RegExp ( 's*\\' + sep + '\\s*' ) ) ; // remove any empty input items inputs = inputs . filter ( function ( i ) { return ( ! _ . isEmpty ( i ) ) ; } ) ; var lcis = inputs . map ( function ( i ) { return i . toLocaleLowerCase ( ) ; } ) ; var retv = choices . filter ( function ( c ) { var lc = c . toLocaleLowerCase ( ) ; return ( _ . find ( lcis , function ( li ) { return ( _ . startsWith ( lc , li ) ) ; } ) !== undefined ) ; } ) ; if ( _ . isEmpty ( retv ) ) return undefined ; return retv ; }
Given some input text, a separator and a list of choices, we
split the input using the separator. We remove any empty items
from the list.

We provide all choices that start-with in a case-insensitive
manner one of the inputs. We return in the order provided in
the choices list and using the case provided in the choices list.

An empty list is not allowed (undefined will be returned.)

@param input
@param sep
@param choices
@returns {(string[]|undefined)}
Given some input text a separator and a list of choices we split the input using the separator . We remove any empty items from the list .