Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minisearch

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minisearch - npm Package Compare versions

Comparing version 5.0.0-beta2 to 5.0.0-beta3

9

CHANGELOG.md

@@ -5,3 +5,3 @@ # Changelog

# v5.0.0-beta2
# v5.0.0-beta3

@@ -21,2 +21,9 @@ This is a beta release of `v5.0.0`. The main change is an improved scoring

- [breaking change] auto suggestions now default to `combineWith: 'AND'`
instead of `'OR'`, requiring all the query terms to match. The old defaults
can be replicated by passing a new `autoSuggestOptions` option to the
constructor, with value `{ autoSuggestOptions: { combineWith: 'OR' } }`.
- Possibility to set the default auto suggest options in the constructor.
- Remove redundant fields in the index data. This also changes the

@@ -23,0 +30,0 @@ serialization format, but serialized indexes created with `v4.x.y` are still

@@ -406,2 +406,7 @@ declare type LeafType = '' & {

searchOptions?: SearchOptions;
/**
* Default auto suggest options (see the [[SearchOptions]] type and the
* [[MiniSearch.autoSuggest]] method for details)
*/
autoSuggestOptions?: SearchOptions;
};

@@ -415,2 +420,3 @@ declare type OptionsWithDefaults<T = any> = Options<T> & {

searchOptions: SearchOptionsWithDefaults;
autoSuggestOptions: SearchOptions;
};

@@ -828,2 +834,9 @@ /**

*
* By default, it uses the same options used for search, except that by
* default it performs prefix search on the last term of the query, and
* combine terms with `'AND'` (requiring all query terms to match). Custom
* options can be passed as a second argument. Defaults can be changed upon
* calling the `MiniSearch` constructor, by passing a `autoSuggestOptions`
* option.
*
* ### Basic usage:

@@ -873,3 +886,4 @@ *

* are the same as for the `search` method, except that by default prefix
* search is performed on the last term in the query.
* search is performed on the last term in the query, and terms are combined
* with `'AND'`.
* @return A sorted array of suggestions sorted by relevance score.

@@ -876,0 +890,0 @@ */

2

package.json
{
"name": "minisearch",
"version": "5.0.0-beta2",
"version": "5.0.0-beta3",
"description": "Tiny but powerful full-text search engine for browser and Node",

@@ -5,0 +5,0 @@ "main": "dist/umd/index.js",

@@ -1101,3 +1101,3 @@ /* eslint-env jest */

const results = ms.autoSuggest('nostra vi')
expect(results.map(({ suggestion }) => suggestion)).toEqual(['nostra vita', 'vita'])
expect(results.map(({ suggestion }) => suggestion)).toEqual(['nostra vita'])
})

@@ -1132,2 +1132,22 @@

})
it('respects the custom defaults set in the constructor', () => {
const ms = new MiniSearch({
fields: ['title', 'text'],
autoSuggestOptions: { combineWith: 'OR', fuzzy: true }
})
ms.addAll(documents)
const results = ms.autoSuggest('nosta vi')
expect(results.map(({ suggestion }) => suggestion)).toEqual(['nostra vita', 'vita'])
})
it('applies the default search options if not overridden by the auto suggest defaults', () => {
const ms = new MiniSearch({
fields: ['title', 'text'],
searchOptions: { combineWith: 'OR', fuzzy: true }
})
ms.addAll(documents)
const results = ms.autoSuggest('nosta vi')
expect(results.map(({ suggestion }) => suggestion)).toEqual(['nostra vita'])
})
})

@@ -1134,0 +1154,0 @@

@@ -184,3 +184,9 @@ import SearchableMap from './SearchableMap/SearchableMap'

*/
searchOptions?: SearchOptions
searchOptions?: SearchOptions,
/**
* Default auto suggest options (see the [[SearchOptions]] type and the
* [[MiniSearch.autoSuggest]] method for details)
*/
autoSuggestOptions?: SearchOptions
}

@@ -199,3 +205,5 @@

searchOptions: SearchOptionsWithDefaults
searchOptions: SearchOptionsWithDefaults,
autoSuggestOptions: SearchOptions
}

@@ -451,3 +459,4 @@

...options,
searchOptions: { ...defaultSearchOptions, ...(options.searchOptions || {}) }
searchOptions: { ...defaultSearchOptions, ...(options.searchOptions || {}) },
autoSuggestOptions: { ...defaultAutoSuggestOptions, ...(options.autoSuggestOptions || {}) }
}

@@ -801,2 +810,9 @@

*
* By default, it uses the same options used for search, except that by
* default it performs prefix search on the last term of the query, and
* combine terms with `'AND'` (requiring all query terms to match). Custom
* options can be passed as a second argument. Defaults can be changed upon
* calling the `MiniSearch` constructor, by passing a `autoSuggestOptions`
* option.
*
* ### Basic usage:

@@ -846,7 +862,8 @@ *

* are the same as for the `search` method, except that by default prefix
* search is performed on the last term in the query.
* search is performed on the last term in the query, and terms are combined
* with `'AND'`.
* @return A sorted array of suggestions sorted by relevance score.
*/
autoSuggest (queryString: string, options: SearchOptions = {}): Suggestion[] {
options = { ...defaultAutoSuggestOptions, ...options }
options = { ...this._options.autoSuggestOptions, ...options }

@@ -1408,2 +1425,3 @@ const suggestions: Map<string, Omit<Suggestion, 'suggestion'> & { count: number }> = new Map()

const defaultAutoSuggestOptions = {
combineWith: AND,
prefix: (term: string, i: number, terms: string[]): boolean =>

@@ -1410,0 +1428,0 @@ i === terms.length - 1

Sorry, the diff of this file is not supported yet

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

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc