123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- lunr.Store = function () {
- this.store = {}
- this.length = 0
- }
- lunr.Store.load = function (serialisedData) {
- var store = new this
- store.length = serialisedData.length
- store.store = Object.keys(serialisedData.store).reduce(function (memo, key) {
- memo[key] = lunr.SortedSet.load(serialisedData.store[key])
- return memo
- }, {})
- return store
- }
- lunr.Store.prototype.set = function (id, tokens) {
- if (!this.has(id)) this.length++
- this.store[id] = tokens
- }
- lunr.Store.prototype.get = function (id) {
- return this.store[id]
- }
- lunr.Store.prototype.has = function (id) {
- return id in this.store
- }
- lunr.Store.prototype.remove = function (id) {
- if (!this.has(id)) return
- delete this.store[id]
- this.length--
- }
- lunr.Store.prototype.toJSON = function () {
- return {
- store: this.store,
- length: this.length
- }
- }
|