Skip to content

Commit d63d809

Browse files
V5.1.3 (#623)
* added EVENTS endpoint that emits a 'ready' event immediately after initialisation * version bump * fixed stale cache bug when IMPORTing * update deps
1 parent dadba8e commit d63d809

11 files changed

+83
-23
lines changed
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

dist/search-index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "search-index",
3-
"version": "5.0.0",
3+
"version": "5.1.3",
44
"description": "A network resilient, persistent full-text search library for the browser and Node.js",
55
"keywords": [
66
"search",
@@ -75,7 +75,7 @@
7575
"dependencies": {
7676
"browser-level": "^1.0.1",
7777
"classic-level": "^1.4.1",
78-
"fergies-inverted-index": "13.0.0",
78+
"fergies-inverted-index": "^13.1.1",
7979
"lru-cache": "11.0.0",
8080
"ngraminator": "3.0.2",
8181
"p-queue": "8.0.1",

src/SearchIndex.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class SearchIndex {
5252
tokenizer: defaultPipeline,
5353
...ops
5454
}
55+
5556
this.INDEX = new InvertedIndex({
5657
...ops,
5758
// isLeaf must be like so and is not a user defined option
@@ -65,6 +66,10 @@ export class SearchIndex {
6566
item === null
6667
)
6768
})
69+
70+
// event bus
71+
this.EVENTS = this.INDEX.EVENTS
72+
6873
// Now that constructor is not async- not sure where this should be called...
6974
this._CACHE = new LRUCache({ max: ops.cacheLength })
7075
this.r = new Reader(ops, this._CACHE, this.INDEX)
@@ -236,7 +241,7 @@ export class SearchIndex {
236241
* // you can them import like so:
237242
* await IMPORT(index)
238243
*/
239-
IMPORT = index => this.INDEX.IMPORT(index)
244+
IMPORT = index => this.w.IMPORT(index)
240245

241246
/**
242247
* find out when index was last updated

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const packageVersion = "5.0.0"
1+
export const packageVersion = "5.1.3"

test/src/EVENT-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import test from 'tape'
2+
import { SearchIndex } from 'search-index'
3+
4+
const sandbox = 'test/sandbox/'
5+
const indexName = sandbox + 'EVENTS'
6+
const global = {}
7+
8+
test('create a search index and listen to the "ready" event', t => {
9+
t.plan(2)
10+
t.ok((global[indexName] = new SearchIndex({ name: indexName })), !undefined)
11+
global[indexName].EVENTS.on('ready', () => t.pass('ready event emitted'))
12+
})

0 commit comments

Comments
 (0)