src/inquirer-extensions/searchable-list.js
/**
 * Function for rendering list choices
 * @param  {Number} pointer Position of the pointer
 * @return {String}         Rendered content
 */
Function for rendering list choices
@param  {Number} pointer Position of the pointer
@return {String}         Rendered content
Function for rendering list choices @param { Number } pointer Position of the pointer @return { String } Rendered content
function listRender(pointer) {
  var output = "";
  var separatorOffset = 0;
  var term = this.searchTerm;
  var regex = term && new RegExp(term, 'gi');
  var searchResult = this.choices.filter(function (item) {
    delete item.searchIndex;
    if (typeof item.name === 'undefined') return true;
    return !term || regex.test(item.name);
  });
  this.total = searchResult.length;
  searchResult.forEach(function (choice, i) {
    choice.searchIndex = i;
    if (choice.type === "separator") {
      separatorOffset++;
      output += "  " + choice + "\n";
      return;
    }
    var isSelected = (i - separatorOffset === pointer);
    var line = (isSelected ? utils.getPointer() + " " : "  ") + choice.name;
    if (isSelected) {
      line = chalk.cyan(line);
    }
    output += line + " \n";
  }.bind(this));
  return output.replace(/\n$/, "");
}
function listRender ( pointer ) { var output = "" ; var separatorOffset = 0 ; var term = this . searchTerm ; var regex = term && new RegExp ( term , 'gi' ) ; var searchResult = this . choices . filter ( function ( item ) { delete item . searchIndex ; if ( typeof item . name === 'undefined' ) return true ; return ! term || regex . test ( item . name ) ; } ) ; this . total = searchResult . length ; searchResult . forEach ( function ( choice , i ) { choice . searchIndex = i ; if ( choice . type === "separator" ) { separatorOffset ++ ; output += "  " + choice + "\n" ; return ; } var isSelected = ( i - separatorOffset === pointer ) ; var line = ( isSelected ? utils . getPointer ( ) + " " : "  " ) + choice . name ; if ( isSelected ) { line = chalk . cyan ( line ) ; } output += line + " \n" ; } . bind ( this ) ) ; return output . replace ( / \n$ / , "" ) ; }
Function for rendering list choices
 @param  {Number} pointer Position of the pointer
 @return {String}         Rendered content
Function for rendering list choices @param { Number } pointer Position of the pointer @return { String } Rendered content