Skip to content

Commit fbf93b4

Browse files
committed
bump lunr to 2.3.9
1 parent 8ece6d8 commit fbf93b4

File tree

1 file changed

+67
-76
lines changed

1 file changed

+67
-76
lines changed

source/_static/js/lunr.js

Lines changed: 67 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.5
3-
* Copyright (C) 2018 Oliver Nightingale
2+
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9
3+
* Copyright (C) 2020 Oliver Nightingale
44
* @license MIT
55
*/
66

@@ -54,10 +54,10 @@ var lunr = function (config) {
5454
return builder.build()
5555
}
5656

57-
lunr.version = "2.3.5"
57+
lunr.version = "2.3.9"
5858
/*!
5959
* lunr.utils
60-
* Copyright (C) 2018 Oliver Nightingale
60+
* Copyright (C) 2020 Oliver Nightingale
6161
*/
6262

6363
/**
@@ -177,7 +177,7 @@ lunr.FieldRef.prototype.toString = function () {
177177
}
178178
/*!
179179
* lunr.Set
180-
* Copyright (C) 2018 Oliver Nightingale
180+
* Copyright (C) 2020 Oliver Nightingale
181181
*/
182182

183183
/**
@@ -211,8 +211,8 @@ lunr.Set.complete = {
211211
return other
212212
},
213213

214-
union: function (other) {
215-
return other
214+
union: function () {
215+
return this
216216
},
217217

218218
contains: function () {
@@ -389,7 +389,7 @@ lunr.Token.prototype.clone = function (fn) {
389389
}
390390
/*!
391391
* lunr.tokenizer
392-
* Copyright (C) 2018 Oliver Nightingale
392+
* Copyright (C) 2020 Oliver Nightingale
393393
*/
394394

395395
/**
@@ -424,7 +424,7 @@ lunr.tokenizer = function (obj, metadata) {
424424
})
425425
}
426426

427-
var str = obj.toString().trim().toLowerCase(),
427+
var str = obj.toString().toLowerCase(),
428428
len = str.length,
429429
tokens = []
430430

@@ -465,7 +465,7 @@ lunr.tokenizer = function (obj, metadata) {
465465
lunr.tokenizer.separator = /[\s\-]+/
466466
/*!
467467
* lunr.Pipeline
468-
* Copyright (C) 2018 Oliver Nightingale
468+
* Copyright (C) 2020 Oliver Nightingale
469469
*/
470470

471471
/**
@@ -509,8 +509,8 @@ lunr.Pipeline.registeredFunctions = Object.create(null)
509509
* or mutate (or add) metadata for a given token.
510510
*
511511
* A pipeline function can indicate that the passed token should be discarded by returning
512-
* null. This token will not be passed to any downstream pipeline functions and will not be
513-
* added to the index.
512+
* null, undefined or an empty string. This token will not be passed to any downstream pipeline
513+
* functions and will not be added to the index.
514514
*
515515
* Multiple tokens can be returned by returning an array of tokens. Each token will be passed
516516
* to any downstream pipeline functions and all will returned tokens will be added to the index.
@@ -673,7 +673,7 @@ lunr.Pipeline.prototype.run = function (tokens) {
673673
for (var j = 0; j < tokens.length; j++) {
674674
var result = fn(tokens[j], j, tokens)
675675

676-
if (result === void 0 || result === '') continue
676+
if (result === null || result === void 0 || result === '') continue
677677

678678
if (Array.isArray(result)) {
679679
for (var k = 0; k < result.length; k++) {
@@ -732,7 +732,7 @@ lunr.Pipeline.prototype.toJSON = function () {
732732
}
733733
/*!
734734
* lunr.Vector
735-
* Copyright (C) 2018 Oliver Nightingale
735+
* Copyright (C) 2020 Oliver Nightingale
736736
*/
737737

738738
/**
@@ -929,7 +929,7 @@ lunr.Vector.prototype.toJSON = function () {
929929
/* eslint-disable */
930930
/*!
931931
* lunr.stemmer
932-
* Copyright (C) 2018 Oliver Nightingale
932+
* Copyright (C) 2020 Oliver Nightingale
933933
* Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
934934
*/
935935

@@ -1151,7 +1151,7 @@ lunr.stemmer = (function(){
11511151
lunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')
11521152
/*!
11531153
* lunr.stopWordFilter
1154-
* Copyright (C) 2018 Oliver Nightingale
1154+
* Copyright (C) 2020 Oliver Nightingale
11551155
*/
11561156

11571157
/**
@@ -1316,7 +1316,7 @@ lunr.stopWordFilter = lunr.generateStopWordFilter([
13161316
lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')
13171317
/*!
13181318
* lunr.trimmer
1319-
* Copyright (C) 2018 Oliver Nightingale
1319+
* Copyright (C) 2020 Oliver Nightingale
13201320
*/
13211321

13221322
/**
@@ -1343,7 +1343,7 @@ lunr.trimmer = function (token) {
13431343
lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')
13441344
/*!
13451345
* lunr.TokenSet
1346-
* Copyright (C) 2018 Oliver Nightingale
1346+
* Copyright (C) 2020 Oliver Nightingale
13471347
*/
13481348

13491349
/**
@@ -1469,41 +1469,49 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
14691469
})
14701470
}
14711471

1472+
if (frame.editsRemaining == 0) {
1473+
continue
1474+
}
1475+
1476+
// insertion
1477+
if ("*" in frame.node.edges) {
1478+
var insertionNode = frame.node.edges["*"]
1479+
} else {
1480+
var insertionNode = new lunr.TokenSet
1481+
frame.node.edges["*"] = insertionNode
1482+
}
1483+
1484+
if (frame.str.length == 0) {
1485+
insertionNode.final = true
1486+
}
1487+
1488+
stack.push({
1489+
node: insertionNode,
1490+
editsRemaining: frame.editsRemaining - 1,
1491+
str: frame.str
1492+
})
1493+
14721494
// deletion
14731495
// can only do a deletion if we have enough edits remaining
14741496
// and if there are characters left to delete in the string
1475-
if (frame.editsRemaining > 0 && frame.str.length > 1) {
1476-
var char = frame.str.charAt(1),
1477-
deletionNode
1478-
1479-
if (char in frame.node.edges) {
1480-
deletionNode = frame.node.edges[char]
1481-
} else {
1482-
deletionNode = new lunr.TokenSet
1483-
frame.node.edges[char] = deletionNode
1484-
}
1485-
1486-
if (frame.str.length <= 2) {
1487-
deletionNode.final = true
1488-
} else {
1489-
stack.push({
1490-
node: deletionNode,
1491-
editsRemaining: frame.editsRemaining - 1,
1492-
str: frame.str.slice(2)
1493-
})
1494-
}
1497+
if (frame.str.length > 1) {
1498+
stack.push({
1499+
node: frame.node,
1500+
editsRemaining: frame.editsRemaining - 1,
1501+
str: frame.str.slice(1)
1502+
})
14951503
}
14961504

14971505
// deletion
14981506
// just removing the last character from the str
1499-
if (frame.editsRemaining > 0 && frame.str.length == 1) {
1507+
if (frame.str.length == 1) {
15001508
frame.node.final = true
15011509
}
15021510

15031511
// substitution
15041512
// can only do a substitution if we have enough edits remaining
15051513
// and if there are characters left to substitute
1506-
if (frame.editsRemaining > 0 && frame.str.length >= 1) {
1514+
if (frame.str.length >= 1) {
15071515
if ("*" in frame.node.edges) {
15081516
var substitutionNode = frame.node.edges["*"]
15091517
} else {
@@ -1513,40 +1521,19 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
15131521

15141522
if (frame.str.length == 1) {
15151523
substitutionNode.final = true
1516-
} else {
1517-
stack.push({
1518-
node: substitutionNode,
1519-
editsRemaining: frame.editsRemaining - 1,
1520-
str: frame.str.slice(1)
1521-
})
1522-
}
1523-
}
1524-
1525-
// insertion
1526-
// can only do insertion if there are edits remaining
1527-
if (frame.editsRemaining > 0) {
1528-
if ("*" in frame.node.edges) {
1529-
var insertionNode = frame.node.edges["*"]
1530-
} else {
1531-
var insertionNode = new lunr.TokenSet
1532-
frame.node.edges["*"] = insertionNode
15331524
}
15341525

1535-
if (frame.str.length == 0) {
1536-
insertionNode.final = true
1537-
} else {
1538-
stack.push({
1539-
node: insertionNode,
1540-
editsRemaining: frame.editsRemaining - 1,
1541-
str: frame.str
1542-
})
1543-
}
1526+
stack.push({
1527+
node: substitutionNode,
1528+
editsRemaining: frame.editsRemaining - 1,
1529+
str: frame.str.slice(1)
1530+
})
15441531
}
15451532

15461533
// transposition
15471534
// can only do a transposition if there are edits remaining
15481535
// and there are enough characters to transpose
1549-
if (frame.editsRemaining > 0 && frame.str.length > 1) {
1536+
if (frame.str.length > 1) {
15501537
var charA = frame.str.charAt(0),
15511538
charB = frame.str.charAt(1),
15521539
transposeNode
@@ -1560,13 +1547,13 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
15601547

15611548
if (frame.str.length == 1) {
15621549
transposeNode.final = true
1563-
} else {
1564-
stack.push({
1565-
node: transposeNode,
1566-
editsRemaining: frame.editsRemaining - 1,
1567-
str: charA + frame.str.slice(2)
1568-
})
15691550
}
1551+
1552+
stack.push({
1553+
node: transposeNode,
1554+
editsRemaining: frame.editsRemaining - 1,
1555+
str: charA + frame.str.slice(2)
1556+
})
15701557
}
15711558
}
15721559

@@ -1619,6 +1606,10 @@ lunr.TokenSet.fromString = function (str) {
16191606
* Converts this TokenSet into an array of strings
16201607
* contained within the TokenSet.
16211608
*
1609+
* This is not intended to be used on a TokenSet that
1610+
* contains wildcards, in these cases the results are
1611+
* undefined and are likely to cause an infinite loop.
1612+
*
16221613
* @returns {string[]}
16231614
*/
16241615
lunr.TokenSet.prototype.toArray = function () {
@@ -1836,7 +1827,7 @@ lunr.TokenSet.Builder.prototype.minimize = function (downTo) {
18361827
}
18371828
/*!
18381829
* lunr.Index
1839-
* Copyright (C) 2018 Oliver Nightingale
1830+
* Copyright (C) 2020 Oliver Nightingale
18401831
*/
18411832

18421833
/**
@@ -2003,7 +1994,7 @@ lunr.Index.prototype.query = function (fn) {
20031994
*/
20041995
var clause = query.clauses[i],
20051996
terms = null,
2006-
clauseMatches = lunr.Set.complete
1997+
clauseMatches = lunr.Set.empty
20071998

20081999
if (clause.usePipeline) {
20092000
terms = this.pipeline.runString(clause.term, {
@@ -2328,7 +2319,7 @@ lunr.Index.load = function (serializedIndex) {
23282319
}
23292320
/*!
23302321
* lunr.Builder
2331-
* Copyright (C) 2018 Oliver Nightingale
2322+
* Copyright (C) 2020 Oliver Nightingale
23322323
*/
23332324

23342325
/**

0 commit comments

Comments
 (0)