Skip to content

Commit

Permalink
Improve SEarchableMap docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaong committed Oct 30, 2023
1 parent 197dec3 commit 46692a2
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 85 deletions.
48 changes: 24 additions & 24 deletions docs/classes/MiniSearch.MiniSearch.html

Large diffs are not rendered by default.

63 changes: 32 additions & 31 deletions docs/classes/SearchableMap_SearchableMap.SearchableMap.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
JavaScript. It is respectful of resources, and it can comfortably run both in
Node and in the browser.</p>
<p>Try out the <a href="https://lucaong.github.io/minisearch/demo/">demo application</a>.</p>
<p>Find the complete <a href="https://lucaong.github.io/minisearch/classes/_minisearch_.minisearch.html">documentation and API reference
<p>Find the complete <a href="https://lucaong.github.io/minisearch/classes/MiniSearch.MiniSearch.html">documentation and API reference
here</a>,
and more background about <code>MiniSearch</code>, including a comparison with other
similar libraries, in <a href="https://lucaongaro.eu/blog/2019/01/30/minisearch-client-side-fulltext-search-engine.html">this blog
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/MiniSearch.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>MiniSearch | MiniSearch</title><meta name="description" content="Documentation for MiniSearch"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">MiniSearch</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">MiniSearch</a></li><li><a href="MiniSearch.html">MiniSearch</a></li></ul><h1>Module MiniSearch</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/lucaong/minisearch/blob/0ad6579/src/MiniSearch.ts#L1">MiniSearch.ts:1</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><h3 class="tsd-index-heading uppercase">Index</h3><section class="tsd-index-section"><h3 class="tsd-index-heading">Classes</h3><div class="tsd-index-list"><a href="../classes/MiniSearch.MiniSearch.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Mini<wbr/>Search</span></a>
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>MiniSearch | MiniSearch</title><meta name="description" content="Documentation for MiniSearch"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">MiniSearch</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">MiniSearch</a></li><li><a href="MiniSearch.html">MiniSearch</a></li></ul><h1>Module MiniSearch</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/lucaong/minisearch/blob/197dec3/src/MiniSearch.ts#L1">MiniSearch.ts:1</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><h3 class="tsd-index-heading uppercase">Index</h3><section class="tsd-index-section"><h3 class="tsd-index-heading">Classes</h3><div class="tsd-index-list"><a href="../classes/MiniSearch.MiniSearch.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Mini<wbr/>Search</span></a>
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Type Aliases</h3><div class="tsd-index-list"><a href="../types/MiniSearch.AutoVacuumOptions.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Auto<wbr/>Vacuum<wbr/>Options</span></a>
<a href="../types/MiniSearch.BM25Params.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>BM25<wbr/>Params</span></a>
<a href="../types/MiniSearch.MatchInfo.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Match<wbr/>Info</span></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/SearchableMap_SearchableMap.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.AutoVacuumOptions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.BM25Params.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.MatchInfo.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.Options.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.Query.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.QueryCombination.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.SearchOptions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.SearchResult.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.Suggestion.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.VacuumConditions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.VacuumOptions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/MiniSearch.Wildcard.html

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions src/SearchableMap/SearchableMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { RadixTree, Entry, Path } from './types'
* A class implementing the same interface as a standard JavaScript
* [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
* with string keys, but adding support for efficiently searching entries with
* prefix or fuzzy search. This class is used internally by [[MiniSearch]] as
* the inverted index data structure. The implementation is a radix tree
* prefix or fuzzy search. This class is used internally by {@link MiniSearch}
* as the inverted index data structure. The implementation is a radix tree
* (compressed prefix tree).
*
* Since this class can be of general utility beyond _MiniSearch_, it is
Expand All @@ -32,8 +32,9 @@ export default class SearchableMap<T = any> {

/**
* The constructor is normally called without arguments, creating an empty
* map. In order to create a [[SearchableMap]] from an iterable or from an
* object, check [[SearchableMap.from]] and [[SearchableMap.fromObject]].
* map. In order to create a {@link SearchableMap} from an iterable or from an
* object, check {@link SearchableMap.from} and {@link
* SearchableMap.fromObject}.
*
* The constructor arguments are for internal use, when creating derived
* mutable views of a map at a prefix.
Expand All @@ -44,8 +45,8 @@ export default class SearchableMap<T = any> {
}

/**
* Creates and returns a mutable view of this [[SearchableMap]], containing only
* entries that share the given prefix.
* Creates and returns a mutable view of this {@link SearchableMap},
* containing only entries that share the given prefix.
*
* ### Usage:
*
Expand All @@ -69,7 +70,8 @@ export default class SearchableMap<T = any> {
* ```
*
* @param prefix The prefix
* @return A [[SearchableMap]] representing a mutable view of the original Map at the given prefix
* @return A {@link SearchableMap} representing a mutable view of the original
* Map at the given prefix
*/
atPrefix (prefix: string): SearchableMap<T> {
if (!prefix.startsWith(this._prefix)) { throw new Error('Mismatched prefix') }
Expand Down Expand Up @@ -191,7 +193,7 @@ export default class SearchableMap<T = any> {
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set
* @param key Key to set
* @param value Value to associate to the key
* @return The [[SearchableMap]] itself, to allow chaining
* @return The {@link SearchableMap} itself, to allow chaining
*/
set (key: string, value: T): SearchableMap<T> {
if (typeof key !== 'string') { throw new Error('key must be a string') }
Expand Down Expand Up @@ -233,7 +235,7 @@ export default class SearchableMap<T = any> {
*
* @param key The key to update
* @param fn The function used to compute the new value from the current one
* @return The [[SearchableMap]] itself, to allow chaining
* @return The {@link SearchableMap} itself, to allow chaining
*/
update (key: string, fn: (value: T | undefined) => T): SearchableMap<T> {
if (typeof key !== 'string') { throw new Error('key must be a string') }
Expand Down Expand Up @@ -288,10 +290,10 @@ export default class SearchableMap<T = any> {
}

/**
* Creates a [[SearchableMap]] from an `Iterable` of entries
* Creates a {@link SearchableMap} from an `Iterable` of entries
*
* @param entries Entries to be inserted in the [[SearchableMap]]
* @return A new [[SearchableMap]] with the given entries
* @param entries Entries to be inserted in the {@link SearchableMap}
* @return A new {@link SearchableMap} with the given entries
*/
static from<T = any> (entries: Iterable<Entry<T>> | Entry<T>[]) {
const tree = new SearchableMap()
Expand All @@ -302,10 +304,10 @@ export default class SearchableMap<T = any> {
}

/**
* Creates a [[SearchableMap]] from the iterable properties of a JavaScript object
* Creates a {@link SearchableMap} from the iterable properties of a JavaScript object
*
* @param object Object of entries for the [[SearchableMap]]
* @return A new [[SearchableMap]] with the given entries
* @param object Object of entries for the {@link SearchableMap}
* @return A new {@link SearchableMap} with the given entries
*/
static fromObject<T = any> (object: { [key: string]: T }) {
return SearchableMap.from<T>(Object.entries(object))
Expand Down

0 comments on commit 46692a2

Please sign in to comment.