lib/prompt-filters.js
function (input, map) {
    // TODO(bwavell): write tests
    debug('chooseOneMapStartsWithFilter(%s, %s)', input, JSON.stringify(map));
    if (input === true) return undefined;
    var retv;
    if (_.isString(input)) {
      if (input === '') return undefined;
      var ilc = input.toLocaleLowerCase();
      _.forOwn(map, function (value, key) {
        var kit = key.toLocaleLowerCase();
        var vit = value.toLocaleLowerCase();
        if (_.startsWith(kit, ilc)) retv = retv || value;
        if (kit === ilc) retv = value;
        if (vit === ilc) retv = value;
      });
    }
    return retv;
  }
function (input, map) {
    // TODO(bwavell): write tests
    debug('chooseOneMapStartsWithFilter(%s, %s)', input, JSON.stringify(map));
    if (input === true) return undefined;
    var retv;
    if (_.isString(input)) {
      if (input === '') return undefined;
      var ilc = input.toLocaleLowerCase();
      _.forOwn(map, function (value, key) {
        var kit = key.toLocaleLowerCase();
        var vit = value.toLocaleLowerCase();
        if (_.startsWith(kit, ilc)) retv = retv || value;
        if (kit === ilc) retv = value;
        if (vit === ilc) retv = value;
      });
    }
    return retv;
  }
function ( input , map ) { // TODO(bwavell): write tests debug ( 'chooseOneMapStartsWithFilter(%s, %s)' , input , JSON . stringify ( map ) ) ; if ( input === true ) return undefined ; var retv ; if ( _ . isString ( input ) ) { if ( input === '' ) return undefined ; var ilc = input . toLocaleLowerCase ( ) ; _ . forOwn ( map , function ( value , key ) { var kit = key . toLocaleLowerCase ( ) ; var vit = value . toLocaleLowerCase ( ) ; if ( _ . startsWith ( kit , ilc ) ) retv = retv || value ; if ( kit === ilc ) retv = value ; if ( vit === ilc ) retv = value ; } ) ; } return retv ; }
Check if any keys in the map start with the input in a case insensitive
manner. Will return the value from the map rather than the user input so
the map can control the final case. If there is an exact case insensitive
match to a value, the value will be returned.

NOTE 1: The map may not contain, undefined, null or the empty string.
NOTE 2: If there are multiple partial matches, the first one wins.
NOTE 3: If there is an exact match, it will be returned even if there is
a prior partial match.
NOTE 4: If there are multiple exact matches (e.g. duplicate values) then
the last exact match will be returned.

@param {(string|boolean|undefined|null)} input
@param {Object.<string, string>} map
@returns {(string|undefined)}
Check if any keys in the map start with the input in a case insensitive manner . Will return the value from the map rather than the user input so the map can control the final case . If there is an exact case insensitive match to a value the value will be returned .