Socket
Socket
Sign inDemoInstall

lunr

Package Overview
Dependencies
0
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0-alpha.2 to 2.1.0

4

lib/index.js

@@ -63,2 +63,6 @@ /*!

*
* To escape special characters the backslash character '\' can be used, this allows searches to include
* characters that would normally be considered modifiers, e.g. `foo\~2` will search for a term "foo~2" instead
* of attempting to apply a boost of 2 to the search term "foo".
*
* @typedef {string} lunr.Index~QueryString

@@ -65,0 +69,0 @@ * @example <caption>Simple single term query</caption>

11

lib/query_parser.js

@@ -50,3 +50,8 @@ lunr.QueryParser = function (str, query) {

default:
var errorMessage = "expected either a field or a term, found " + lexeme.type + " with value '" + lexeme.str + "'"
var errorMessage = "expected either a field or a term, found " + lexeme.type
if (lexeme.str.length >= 1) {
errorMessage += " with value '" + lexeme.str + "'"
}
throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)

@@ -64,3 +69,3 @@ }

if (parser.query.allFields.indexOf(lexeme.str) == -1) {
var possibleFields = parser.query.allFields.map(function (f) { return "'" + f + "'" }).join(),
var possibleFields = parser.query.allFields.map(function (f) { return "'" + f + "'" }).join(', '),
errorMessage = "unrecognised field '" + lexeme.str + "', possible fields: " + possibleFields

@@ -84,3 +89,3 @@

default:
var errorMessage = "expecting a field, found '" + nextLexeme.type + "'"
var errorMessage = "expecting term, found '" + nextLexeme.type + "'"
throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)

@@ -87,0 +92,0 @@ }

@@ -17,2 +17,25 @@ /**

/**
* Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause.
*
* This allows wildcards to be added to the beginning and end of a term without having to manually do any string
* concatenation.
*
* The wildcard constants can be bitwise combined to select both leading and trailing wildcards.
*
* @constant
* @default
* @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour
* @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists
* @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists
* @see lunr.Query~Clause
* @see lunr.Query#clause
* @see lunr.Query#term
* @example <caption>query term with trailing wildcard</caption>
* query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })
* @example <caption>query term with leading and trailing wildcard</caption>
* query.term('foo', {
* wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING
* })
*/
lunr.Query.wildcard = new String ("*")

@@ -29,5 +52,6 @@ lunr.Query.wildcard.NONE = 0

* @property {string[]} fields - The fields in an index this clause should be matched against.
* @property {number} boost - Any boost that should be applied when matching this clause.
* @property {number} [boost=1] - Any boost that should be applied when matching this clause.
* @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.
* @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.
* @property {number} [wildcard=0] - Whether the term should have wildcards appended or prepended.
*/

@@ -42,2 +66,3 @@

* @param {lunr.Query~Clause} clause - The clause to add to this query.
* @see lunr.Query~Clause
* @returns {lunr.Query}

@@ -82,2 +107,12 @@ */

* @returns {lunr.Query}
* @see lunr.Query#clause
* @see lunr.Query~Clause
* @example <caption>adding a single term to a query</caption>
* query.term("foo")
* @example <caption>adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard</caption>
* query.term("foo", {
* fields: ["title"],
* boost: 10,
* wildcard: lunr.Query.wildcard.TRAILING
* })
*/

@@ -84,0 +119,0 @@ lunr.Query.prototype.term = function (term, options) {

{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "2.1.0-alpha.2",
"version": "2.1.0",
"author": "Oliver Nightingale",

@@ -6,0 +6,0 @@ "keywords": ["search"],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc