minisearch
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -5,2 +5,8 @@ # Changelog | ||
# v3.0.1 | ||
- [fix] Fix type signature of `removeAll` to allow calling it with no | ||
arguments. Also, throw a more informative error if called with a falsey | ||
value. Thanks to [https://github.com/nilclass](@nilclass). | ||
# v3.0.0 | ||
@@ -7,0 +13,0 @@ |
@@ -618,3 +618,3 @@ /*! ***************************************************************************** | ||
* // id field, that is always stored and returned) | ||
* const miniSearch = MiniSearch.new({ | ||
* const miniSearch = new MiniSearch({ | ||
* fields: ['title', 'text'], | ||
@@ -834,3 +834,9 @@ * storeFields: ['title', 'category'] | ||
var _this = this; | ||
if (arguments.length === 0) { | ||
if (documents) { | ||
documents.forEach(function (document) { return _this.remove(document); }); | ||
} | ||
else if (arguments.length > 0) { | ||
throw new Error('Expected documents to be present. Omit the argument to remove all documents.'); | ||
} | ||
else { | ||
this._index = new SearchableMap(); | ||
@@ -844,5 +850,2 @@ this._documentCount = 0; | ||
} | ||
else { | ||
documents.forEach(function (document) { return _this.remove(document); }); | ||
} | ||
}; | ||
@@ -849,0 +852,0 @@ /** |
@@ -618,3 +618,3 @@ /*! ***************************************************************************** | ||
* // id field, that is always stored and returned) | ||
* const miniSearch = MiniSearch.new({ | ||
* const miniSearch = new MiniSearch({ | ||
* fields: ['title', 'text'], | ||
@@ -834,3 +834,9 @@ * storeFields: ['title', 'category'] | ||
var _this = this; | ||
if (arguments.length === 0) { | ||
if (documents) { | ||
documents.forEach(function (document) { return _this.remove(document); }); | ||
} | ||
else if (arguments.length > 0) { | ||
throw new Error('Expected documents to be present. Omit the argument to remove all documents.'); | ||
} | ||
else { | ||
this._index = new SearchableMap(); | ||
@@ -844,5 +850,2 @@ this._documentCount = 0; | ||
} | ||
else { | ||
documents.forEach(function (document) { return _this.remove(document); }); | ||
} | ||
}; | ||
@@ -849,0 +852,0 @@ /** |
@@ -495,3 +495,3 @@ declare type RadixTree<T> = { | ||
* // id field, that is always stored and returned) | ||
* const miniSearch = MiniSearch.new({ | ||
* const miniSearch = new MiniSearch({ | ||
* fields: ['title', 'text'], | ||
@@ -645,3 +645,3 @@ * storeFields: ['title', 'category'] | ||
*/ | ||
removeAll(documents: T[]): void; | ||
removeAll(documents?: T[]): void; | ||
/** | ||
@@ -648,0 +648,0 @@ * Search for documents matching the given search query. |
@@ -624,3 +624,3 @@ (function (global, factory) { | ||
* // id field, that is always stored and returned) | ||
* const miniSearch = MiniSearch.new({ | ||
* const miniSearch = new MiniSearch({ | ||
* fields: ['title', 'text'], | ||
@@ -840,3 +840,9 @@ * storeFields: ['title', 'category'] | ||
var _this = this; | ||
if (arguments.length === 0) { | ||
if (documents) { | ||
documents.forEach(function (document) { return _this.remove(document); }); | ||
} | ||
else if (arguments.length > 0) { | ||
throw new Error('Expected documents to be present. Omit the argument to remove all documents.'); | ||
} | ||
else { | ||
this._index = new SearchableMap(); | ||
@@ -850,5 +856,2 @@ this._documentCount = 0; | ||
} | ||
else { | ||
documents.forEach(function (document) { return _this.remove(document); }); | ||
} | ||
}; | ||
@@ -855,0 +858,0 @@ /** |
{ | ||
"name": "minisearch", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Tiny but powerful full-text search engine for browser and Node", | ||
@@ -78,3 +78,4 @@ "main": "dist/umd/index.js", | ||
"build-minified": "MINIFY=true yarn build", | ||
"build-docs": "typedoc --options typedoc.json", | ||
"build-docs": "typedoc --options typedoc.json && touch docs/.nojekyll && yarn build-examples", | ||
"build-examples": "cd examples && yarn build && cd ../", | ||
"lint": "eslint 'src/**/*.{js,ts}'", | ||
@@ -81,0 +82,0 @@ "lintfix": "eslint --fix 'src/**/*.{js,ts}'", |
@@ -6,3 +6,5 @@ # MiniSearch | ||
[![Minzipped Size](https://badgen.net/bundlephobia/minzip/minisearch)](https://bundlephobia.com/result?p=minisearch) | ||
[![](https://data.jsdelivr.com/v1/package/npm/minisearch/badge?style=rounded)](https://www.jsdelivr.com/package/npm/minisearch) | ||
[![npm](https://img.shields.io/npm/v/minisearch?color=%23ff00dd)](https://www.npmjs.com/package/minisearch) | ||
[![npm downloads](https://img.shields.io/npm/dw/minisearch)](https://www.npmjs.com/package/minisearch) | ||
[![types](https://img.shields.io/npm/types/minisearch)](https://lucaong.github.io/minisearch/classes/_minisearch_.minisearch.html) | ||
@@ -16,4 +18,5 @@ `MiniSearch` is a tiny but powerful in-memory fulltext search engine written in | ||
Find the complete [documentation and API reference | ||
here](https://lucaong.github.io/minisearch), and more background about | ||
`MiniSearch`, including a comparison with other similar libraries, in [this blog | ||
here](https://lucaong.github.io/minisearch/classes/_minisearch_.minisearch.html), | ||
and more background about `MiniSearch`, including a comparison with other | ||
similar libraries, in [this blog | ||
post](https://lucaongaro.eu/blog/2019/01/30/minisearch-client-side-fulltext-search-engine.html). | ||
@@ -78,6 +81,6 @@ | ||
Alternatively, if you prefer to use a `<script>` tag, you can require MiniSearch | ||
from a CDN: | ||
[from a CDN](https://www.jsdelivr.com/package/npm/minisearch): | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/minisearch@2.6.0/dist/umd/index.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/minisearch@3.0.1/dist/umd/index.min.js"></script> | ||
``` | ||
@@ -320,3 +323,4 @@ | ||
Refer to the [API documentation](https://lucaong.github.io/minisearch/) | ||
Refer to the [API | ||
documentation](https://lucaong.github.io/minisearch/classes/_minisearch_.minisearch.html) | ||
for details about configuration options and methods. | ||
@@ -323,0 +327,0 @@ |
@@ -373,2 +373,9 @@ /* eslint-env jest */ | ||
}) | ||
it('raises an error if called with a falsey argument', () => { | ||
expect(() => { ms.removeAll(null) }).toThrowError() | ||
expect(() => { ms.removeAll(undefined) }).toThrowError() | ||
expect(() => { ms.removeAll(false) }).toThrowError() | ||
expect(() => { ms.removeAll([]) }).not.toThrowError() | ||
}) | ||
}) | ||
@@ -375,0 +382,0 @@ |
@@ -318,3 +318,3 @@ import SearchableMap from './SearchableMap/SearchableMap' | ||
* // id field, that is always stored and returned) | ||
* const miniSearch = MiniSearch.new({ | ||
* const miniSearch = new MiniSearch({ | ||
* fields: ['title', 'text'], | ||
@@ -560,4 +560,8 @@ * storeFields: ['title', 'category'] | ||
*/ | ||
removeAll (documents: T[]): void { | ||
if (arguments.length === 0) { | ||
removeAll (documents?: T[]): void { | ||
if (documents) { | ||
documents.forEach(document => this.remove(document)) | ||
} else if (arguments.length > 0) { | ||
throw new Error('Expected documents to be present. Omit the argument to remove all documents.') | ||
} else { | ||
this._index = new SearchableMap() | ||
@@ -570,4 +574,2 @@ this._documentCount = 0 | ||
this._nextId = 0 | ||
} else { | ||
documents.forEach(document => this.remove(document)) | ||
} | ||
@@ -574,0 +576,0 @@ } |
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 not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
607589
9350
341
0