/**
- * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.3
- * Copyright (C) 2018 Oliver Nightingale
+ * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.8
+ * Copyright (C) 2019 Oliver Nightingale
* @license MIT
*/
return builder.build()
}
-lunr.version = "2.3.3"
+lunr.version = "2.3.8"
/*!
* lunr.utils
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
}
/*!
* lunr.Set
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
}
/*!
* lunr.tokenizer
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
})
}
- var str = obj.toString().trim().toLowerCase(),
+ var str = obj.toString().toLowerCase(),
len = str.length,
tokens = []
lunr.tokenizer.separator = /[\s\-]+/
/*!
* lunr.Pipeline
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
* or mutate (or add) metadata for a given token.
*
* A pipeline function can indicate that the passed token should be discarded by returning
- * null. This token will not be passed to any downstream pipeline functions and will not be
- * added to the index.
+ * null, undefined or an empty string. This token will not be passed to any downstream pipeline
+ * functions and will not be added to the index.
*
* Multiple tokens can be returned by returning an array of tokens. Each token will be passed
* to any downstream pipeline functions and all will returned tokens will be added to the index.
for (var j = 0; j < tokens.length; j++) {
var result = fn(tokens[j], j, tokens)
- if (result === void 0 || result === '') continue
+ if (result === null || result === void 0 || result === '') continue
- if (result instanceof Array) {
+ if (Array.isArray(result)) {
for (var k = 0; k < result.length; k++) {
memo.push(result[k])
}
}
/*!
* lunr.Vector
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
/* eslint-disable */
/*!
* lunr.stemmer
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
* Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
*/
lunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')
/*!
* lunr.stopWordFilter
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')
/*!
* lunr.trimmer
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')
/*!
* lunr.TokenSet
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
if (frame.str.length == 1) {
noEditNode.final = true
- } else {
- stack.push({
- node: noEditNode,
- editsRemaining: frame.editsRemaining,
- str: frame.str.slice(1)
- })
}
+
+ stack.push({
+ node: noEditNode,
+ editsRemaining: frame.editsRemaining,
+ str: frame.str.slice(1)
+ })
+ }
+
+ if (frame.editsRemaining == 0) {
+ continue
+ }
+
+ // insertion
+ if ("*" in frame.node.edges) {
+ var insertionNode = frame.node.edges["*"]
+ } else {
+ var insertionNode = new lunr.TokenSet
+ frame.node.edges["*"] = insertionNode
+ }
+
+ if (frame.str.length == 0) {
+ insertionNode.final = true
}
+ stack.push({
+ node: insertionNode,
+ editsRemaining: frame.editsRemaining - 1,
+ str: frame.str
+ })
+
// deletion
// can only do a deletion if we have enough edits remaining
// and if there are characters left to delete in the string
- if (frame.editsRemaining > 0 && frame.str.length > 1) {
- var char = frame.str.charAt(1),
- deletionNode
-
- if (char in frame.node.edges) {
- deletionNode = frame.node.edges[char]
- } else {
- deletionNode = new lunr.TokenSet
- frame.node.edges[char] = deletionNode
- }
-
- if (frame.str.length <= 2) {
- deletionNode.final = true
- } else {
- stack.push({
- node: deletionNode,
- editsRemaining: frame.editsRemaining - 1,
- str: frame.str.slice(2)
- })
- }
+ if (frame.str.length > 1) {
+ stack.push({
+ node: frame.node,
+ editsRemaining: frame.editsRemaining - 1,
+ str: frame.str.slice(1)
+ })
}
// deletion
// just removing the last character from the str
- if (frame.editsRemaining > 0 && frame.str.length == 1) {
+ if (frame.str.length == 1) {
frame.node.final = true
}
// substitution
// can only do a substitution if we have enough edits remaining
// and if there are characters left to substitute
- if (frame.editsRemaining > 0 && frame.str.length >= 1) {
+ if (frame.str.length >= 1) {
if ("*" in frame.node.edges) {
var substitutionNode = frame.node.edges["*"]
} else {
if (frame.str.length == 1) {
substitutionNode.final = true
- } else {
- stack.push({
- node: substitutionNode,
- editsRemaining: frame.editsRemaining - 1,
- str: frame.str.slice(1)
- })
- }
- }
-
- // insertion
- // can only do insertion if there are edits remaining
- if (frame.editsRemaining > 0) {
- if ("*" in frame.node.edges) {
- var insertionNode = frame.node.edges["*"]
- } else {
- var insertionNode = new lunr.TokenSet
- frame.node.edges["*"] = insertionNode
}
- if (frame.str.length == 0) {
- insertionNode.final = true
- } else {
- stack.push({
- node: insertionNode,
- editsRemaining: frame.editsRemaining - 1,
- str: frame.str
- })
- }
+ stack.push({
+ node: substitutionNode,
+ editsRemaining: frame.editsRemaining - 1,
+ str: frame.str.slice(1)
+ })
}
// transposition
// can only do a transposition if there are edits remaining
// and there are enough characters to transpose
- if (frame.editsRemaining > 0 && frame.str.length > 1) {
+ if (frame.str.length > 1) {
var charA = frame.str.charAt(0),
charB = frame.str.charAt(1),
transposeNode
if (frame.str.length == 1) {
transposeNode.final = true
- } else {
- stack.push({
- node: transposeNode,
- editsRemaining: frame.editsRemaining - 1,
- str: charA + frame.str.slice(2)
- })
}
+
+ stack.push({
+ node: transposeNode,
+ editsRemaining: frame.editsRemaining - 1,
+ str: charA + frame.str.slice(2)
+ })
}
}
* Converts this TokenSet into an array of strings
* contained within the TokenSet.
*
+ * This is not intended to be used on a TokenSet that
+ * contains wildcards, in these cases the results are
+ * undefined and are likely to cause an infinite loop.
+ *
* @returns {string[]}
*/
lunr.TokenSet.prototype.toArray = function () {
}
/*!
* lunr.Index
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**
var attrs = {},
fieldVectors = {},
serializedVectors = serializedIndex.fieldVectors,
- invertedIndex = {},
+ invertedIndex = Object.create(null),
serializedInvertedIndex = serializedIndex.invertedIndex,
tokenSetBuilder = new lunr.TokenSet.Builder,
pipeline = lunr.Pipeline.load(serializedIndex.pipeline)
}
/*!
* lunr.Builder
- * Copyright (C) 2018 Oliver Nightingale
+ * Copyright (C) 2019 Oliver Nightingale
*/
/**