dist/jst9.js
function addWord(word) {

    var branch = this.root;
    var stopSearchOnCurrentBranch = false;
    var newNode;

    while (!stopSearchOnCurrentBranch) {
      var wordContainsThePrefix = false;
      var isCase3 = false;
      var case2Result;

      //Looks for how branch it should follow
      for (var b in branch.branches) {

        //Case 1: current node prefix == `word`
        if(this._tryCase1(branch, word, b)) {
          return;
        }

        //Case 2: `word` begins with current node prefix to add
        //Cuts the word and goes to the next branch
        case2Result = this._tryCase2(branch, word, b);
        if(case2Result) {
          word = case2Result.word;
          branch = case2Result.branch;
          wordContainsThePrefix = true;
          break;
        }

        //Case 3: current node prefix begins with part of or whole `word`
        if(this._tryCase3(branch, word, b)) {
          isCase3 = stopSearchOnCurrentBranch = wordContainsThePrefix = true;
          break;
        }
      }

      //Case 4: current node prefix doesn't have intersection with `word`
      if(this._tryCase4(branch, word, wordContainsThePrefix)) {
        stopSearchOnCurrentBranch = true;
      }
    }
  }
function addWord(word) {

    var branch = this.root;
    var stopSearchOnCurrentBranch = false;
    var newNode;

    while (!stopSearchOnCurrentBranch) {
      var wordContainsThePrefix = false;
      var isCase3 = false;
      var case2Result;

      //Looks for how branch it should follow
      for (var b in branch.branches) {

        //Case 1: current node prefix == `word`
        if(this._tryCase1(branch, word, b)) {
          return;
        }

        //Case 2: `word` begins with current node prefix to add
        //Cuts the word and goes to the next branch
        case2Result = this._tryCase2(branch, word, b);
        if(case2Result) {
          word = case2Result.word;
          branch = case2Result.branch;
          wordContainsThePrefix = true;
          break;
        }

        //Case 3: current node prefix begins with part of or whole `word`
        if(this._tryCase3(branch, word, b)) {
          isCase3 = stopSearchOnCurrentBranch = wordContainsThePrefix = true;
          break;
        }
      }

      //Case 4: current node prefix doesn't have intersection with `word`
      if(this._tryCase4(branch, word, wordContainsThePrefix)) {
        stopSearchOnCurrentBranch = true;
      }
    }
  }
function addWord ( word ) { var branch = this . root ; var stopSearchOnCurrentBranch = false ; var newNode ; while ( ! stopSearchOnCurrentBranch ) { var wordContainsThePrefix = false ; var isCase3 = false ; var case2Result ; //Looks for how branch it should follow for ( var b in branch . branches ) { //Case 1: current node prefix == `word` if ( this . _tryCase1 ( branch , word , b ) ) { return ; } //Case 2: `word` begins with current node prefix to add //Cuts the word and goes to the next branch case2Result = this . _tryCase2 ( branch , word , b ) ; if ( case2Result ) { word = case2Result . word ; branch = case2Result . branch ; wordContainsThePrefix = true ; break ; } //Case 3: current node prefix begins with part of or whole `word` if ( this . _tryCase3 ( branch , word , b ) ) { isCase3 = stopSearchOnCurrentBranch = wordContainsThePrefix = true ; break ; } } //Case 4: current node prefix doesn't have intersection with `word` if ( this . _tryCase4 ( branch , word , wordContainsThePrefix ) ) { stopSearchOnCurrentBranch = true ; } } }
Add a new word to the tree
@param {String} word Word to be added to the tree
Add a new word to the tree