in assets/js/lunr/lunr.js [1775:1813]
lunr.TokenSet.Builder.prototype.insert = function (word) {
var node,
commonPrefix = 0
if (word < this.previousWord) {
throw new Error ("Out of order word insertion")
}
for (var i = 0; i < word.length && i < this.previousWord.length; i++) {
if (word[i] != this.previousWord[i]) break
commonPrefix++
}
this.minimize(commonPrefix)
if (this.uncheckedNodes.length == 0) {
node = this.root
} else {
node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child
}
for (var i = commonPrefix; i < word.length; i++) {
var nextNode = new lunr.TokenSet,
char = word[i]
node.edges[char] = nextNode
this.uncheckedNodes.push({
parent: node,
char: char,
child: nextNode
})
node = nextNode
}
node.final = true
this.previousWord = word
}