1
1
/**
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
4
4
* @license MIT
5
5
*/
6
6
@@ -54,10 +54,10 @@ var lunr = function (config) {
54
54
return builder . build ( )
55
55
}
56
56
57
- lunr . version = "2.3.5 "
57
+ lunr . version = "2.3.9 "
58
58
/*!
59
59
* lunr.utils
60
- * Copyright (C) 2018 Oliver Nightingale
60
+ * Copyright (C) 2020 Oliver Nightingale
61
61
*/
62
62
63
63
/**
@@ -177,7 +177,7 @@ lunr.FieldRef.prototype.toString = function () {
177
177
}
178
178
/*!
179
179
* lunr.Set
180
- * Copyright (C) 2018 Oliver Nightingale
180
+ * Copyright (C) 2020 Oliver Nightingale
181
181
*/
182
182
183
183
/**
@@ -211,8 +211,8 @@ lunr.Set.complete = {
211
211
return other
212
212
} ,
213
213
214
- union : function ( other ) {
215
- return other
214
+ union : function ( ) {
215
+ return this
216
216
} ,
217
217
218
218
contains : function ( ) {
@@ -389,7 +389,7 @@ lunr.Token.prototype.clone = function (fn) {
389
389
}
390
390
/*!
391
391
* lunr.tokenizer
392
- * Copyright (C) 2018 Oliver Nightingale
392
+ * Copyright (C) 2020 Oliver Nightingale
393
393
*/
394
394
395
395
/**
@@ -424,7 +424,7 @@ lunr.tokenizer = function (obj, metadata) {
424
424
} )
425
425
}
426
426
427
- var str = obj . toString ( ) . trim ( ) . toLowerCase ( ) ,
427
+ var str = obj . toString ( ) . toLowerCase ( ) ,
428
428
len = str . length ,
429
429
tokens = [ ]
430
430
@@ -465,7 +465,7 @@ lunr.tokenizer = function (obj, metadata) {
465
465
lunr . tokenizer . separator = / [ \s \- ] + /
466
466
/*!
467
467
* lunr.Pipeline
468
- * Copyright (C) 2018 Oliver Nightingale
468
+ * Copyright (C) 2020 Oliver Nightingale
469
469
*/
470
470
471
471
/**
@@ -509,8 +509,8 @@ lunr.Pipeline.registeredFunctions = Object.create(null)
509
509
* or mutate (or add) metadata for a given token.
510
510
*
511
511
* 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.
514
514
*
515
515
* Multiple tokens can be returned by returning an array of tokens. Each token will be passed
516
516
* 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) {
673
673
for ( var j = 0 ; j < tokens . length ; j ++ ) {
674
674
var result = fn ( tokens [ j ] , j , tokens )
675
675
676
- if ( result === void 0 || result === '' ) continue
676
+ if ( result === null || result === void 0 || result === '' ) continue
677
677
678
678
if ( Array . isArray ( result ) ) {
679
679
for ( var k = 0 ; k < result . length ; k ++ ) {
@@ -732,7 +732,7 @@ lunr.Pipeline.prototype.toJSON = function () {
732
732
}
733
733
/*!
734
734
* lunr.Vector
735
- * Copyright (C) 2018 Oliver Nightingale
735
+ * Copyright (C) 2020 Oliver Nightingale
736
736
*/
737
737
738
738
/**
@@ -929,7 +929,7 @@ lunr.Vector.prototype.toJSON = function () {
929
929
/* eslint-disable */
930
930
/*!
931
931
* lunr.stemmer
932
- * Copyright (C) 2018 Oliver Nightingale
932
+ * Copyright (C) 2020 Oliver Nightingale
933
933
* Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
934
934
*/
935
935
@@ -1151,7 +1151,7 @@ lunr.stemmer = (function(){
1151
1151
lunr . Pipeline . registerFunction ( lunr . stemmer , 'stemmer' )
1152
1152
/*!
1153
1153
* lunr.stopWordFilter
1154
- * Copyright (C) 2018 Oliver Nightingale
1154
+ * Copyright (C) 2020 Oliver Nightingale
1155
1155
*/
1156
1156
1157
1157
/**
@@ -1316,7 +1316,7 @@ lunr.stopWordFilter = lunr.generateStopWordFilter([
1316
1316
lunr . Pipeline . registerFunction ( lunr . stopWordFilter , 'stopWordFilter' )
1317
1317
/*!
1318
1318
* lunr.trimmer
1319
- * Copyright (C) 2018 Oliver Nightingale
1319
+ * Copyright (C) 2020 Oliver Nightingale
1320
1320
*/
1321
1321
1322
1322
/**
@@ -1343,7 +1343,7 @@ lunr.trimmer = function (token) {
1343
1343
lunr . Pipeline . registerFunction ( lunr . trimmer , 'trimmer' )
1344
1344
/*!
1345
1345
* lunr.TokenSet
1346
- * Copyright (C) 2018 Oliver Nightingale
1346
+ * Copyright (C) 2020 Oliver Nightingale
1347
1347
*/
1348
1348
1349
1349
/**
@@ -1469,41 +1469,49 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
1469
1469
} )
1470
1470
}
1471
1471
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
+
1472
1494
// deletion
1473
1495
// can only do a deletion if we have enough edits remaining
1474
1496
// 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
+ } )
1495
1503
}
1496
1504
1497
1505
// deletion
1498
1506
// just removing the last character from the str
1499
- if ( frame . editsRemaining > 0 && frame . str . length == 1 ) {
1507
+ if ( frame . str . length == 1 ) {
1500
1508
frame . node . final = true
1501
1509
}
1502
1510
1503
1511
// substitution
1504
1512
// can only do a substitution if we have enough edits remaining
1505
1513
// and if there are characters left to substitute
1506
- if ( frame . editsRemaining > 0 && frame . str . length >= 1 ) {
1514
+ if ( frame . str . length >= 1 ) {
1507
1515
if ( "*" in frame . node . edges ) {
1508
1516
var substitutionNode = frame . node . edges [ "*" ]
1509
1517
} else {
@@ -1513,40 +1521,19 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
1513
1521
1514
1522
if ( frame . str . length == 1 ) {
1515
1523
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
1533
1524
}
1534
1525
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
+ } )
1544
1531
}
1545
1532
1546
1533
// transposition
1547
1534
// can only do a transposition if there are edits remaining
1548
1535
// and there are enough characters to transpose
1549
- if ( frame . editsRemaining > 0 && frame . str . length > 1 ) {
1536
+ if ( frame . str . length > 1 ) {
1550
1537
var charA = frame . str . charAt ( 0 ) ,
1551
1538
charB = frame . str . charAt ( 1 ) ,
1552
1539
transposeNode
@@ -1560,13 +1547,13 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
1560
1547
1561
1548
if ( frame . str . length == 1 ) {
1562
1549
transposeNode . final = true
1563
- } else {
1564
- stack . push ( {
1565
- node : transposeNode ,
1566
- editsRemaining : frame . editsRemaining - 1 ,
1567
- str : charA + frame . str . slice ( 2 )
1568
- } )
1569
1550
}
1551
+
1552
+ stack . push ( {
1553
+ node : transposeNode ,
1554
+ editsRemaining : frame . editsRemaining - 1 ,
1555
+ str : charA + frame . str . slice ( 2 )
1556
+ } )
1570
1557
}
1571
1558
}
1572
1559
@@ -1619,6 +1606,10 @@ lunr.TokenSet.fromString = function (str) {
1619
1606
* Converts this TokenSet into an array of strings
1620
1607
* contained within the TokenSet.
1621
1608
*
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
+ *
1622
1613
* @returns {string[] }
1623
1614
*/
1624
1615
lunr . TokenSet . prototype . toArray = function ( ) {
@@ -1836,7 +1827,7 @@ lunr.TokenSet.Builder.prototype.minimize = function (downTo) {
1836
1827
}
1837
1828
/*!
1838
1829
* lunr.Index
1839
- * Copyright (C) 2018 Oliver Nightingale
1830
+ * Copyright (C) 2020 Oliver Nightingale
1840
1831
*/
1841
1832
1842
1833
/**
@@ -2003,7 +1994,7 @@ lunr.Index.prototype.query = function (fn) {
2003
1994
*/
2004
1995
var clause = query . clauses [ i ] ,
2005
1996
terms = null ,
2006
- clauseMatches = lunr . Set . complete
1997
+ clauseMatches = lunr . Set . empty
2007
1998
2008
1999
if ( clause . usePipeline ) {
2009
2000
terms = this . pipeline . runString ( clause . term , {
@@ -2328,7 +2319,7 @@ lunr.Index.load = function (serializedIndex) {
2328
2319
}
2329
2320
/*!
2330
2321
* lunr.Builder
2331
- * Copyright (C) 2018 Oliver Nightingale
2322
+ * Copyright (C) 2020 Oliver Nightingale
2332
2323
*/
2333
2324
2334
2325
/**
0 commit comments