@live-change/db 0.8.24 → 0.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -209,14 +209,14 @@ class WriteQueue {
209
209
  }
210
210
 
211
211
  async update(operations, options) {
212
- const first = this.operations.length == 0
212
+ const first = this.operations.length === 0
213
213
  this.operations.push({ operations, options })
214
214
  //console.log("QUEUE UPDATE", this.id, this.operations, "FIRST", first)
215
215
  if(first) {
216
216
  if(this.writePromise) {
217
217
  //console.log("GOT WRITE PROMISE")
218
218
  this.updatePromise = this.writePromise.then(async written => {
219
- if(this.operations.length == 0) return
219
+ if(this.operations.length === 0) return
220
220
  //console.log("VALUE WRITTEN -> DOING NEXT UPDATE", this.id, this.operations)
221
221
  let value = JSON.parse(JSON.stringify(this.writeValue))
222
222
  for(const { operations, options } of this.operations) {
@@ -236,7 +236,7 @@ class WriteQueue {
236
236
  this.updatePromise = this.readPromise.then(async readed => {
237
237
  this.readPromise = null
238
238
  //console.log("VALUE READED -> DOING UPDATE", this.id, this.operations)
239
- if(this.operations.length == 0) return
239
+ if(this.operations.length === 0) return
240
240
  let value = JSON.parse(JSON.stringify(readed))
241
241
  for(const { operations, options } of this.operations) {
242
242
  //console.log("UPDATE OPS", operations, "OPTIONS", options)
package/lib/Log.js CHANGED
@@ -13,21 +13,25 @@ class Log {
13
13
  this.lastId = 0
14
14
  }
15
15
 
16
- put(log) {
16
+ async put(log) {
17
17
  const now = Date.now()
18
- if(now == this.lastTime) {
18
+ if(now === this.lastTime) {
19
19
  this.lastId ++
20
20
  } else {
21
21
  this.lastId = 0
22
22
  this.lastTime = now
23
23
  }
24
24
  const id = ((''+this.lastTime).padStart(16, '0'))+':'+((''+this.lastId).padStart(6, '0'))
25
- this.data.put({ ...log, id, timestamp: this.lastTime })
25
+ await this.data.put({ ...log, id, timestamp: this.lastTime })
26
26
  return id
27
27
  }
28
28
 
29
- putOld(log) {
30
- this.data.put(log)
29
+ async putOld(log) {
30
+ await this.data.put(log)
31
+ }
32
+
33
+ async clear(before) {
34
+ await this.data.rangeDelete({ lt: before })
31
35
  }
32
36
 
33
37
  objectGet(key) {
package/lib/OpLogger.js CHANGED
@@ -31,7 +31,7 @@ class OpLogger {
31
31
  async put(object) {
32
32
  if(typeof object.id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`)
33
33
  let res = await this.store.put(object)
34
- if(JSON.stringify(object) == JSON.stringify(res)) return res
34
+ if(JSON.stringify(object) === JSON.stringify(res)) return res
35
35
  for(let output of this.outputs) output({ type: 'put', object, oldObject: res })
36
36
  return res
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/db",
3
- "version": "0.8.24",
3
+ "version": "0.8.27",
4
4
  "description": "Database with observable data for live queries",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  "type": "module",
23
23
  "homepage": "https://github.com/live-change/live-change-stack",
24
24
  "devDependencies": {
25
- "@live-change/db-store-level": "^0.8.24",
26
- "@live-change/db-store-lmdb": "^0.8.24",
25
+ "@live-change/db-store-level": "^0.8.27",
26
+ "@live-change/db-store-lmdb": "^0.8.27",
27
27
  "minimist": ">=1.2.3",
28
28
  "next-tick": "^1.1.0",
29
29
  "rimraf": "^5.0.5",
@@ -32,9 +32,9 @@
32
32
  "websocket-extensions": ">=0.1.4"
33
33
  },
34
34
  "dependencies": {
35
- "@live-change/dao": "^0.8.24",
35
+ "@live-change/dao": "^0.8.27",
36
36
  "get-random-values": "^1.2.2",
37
37
  "node-interval-tree": "^1.3.3"
38
38
  },
39
- "gitHead": "63e942caccbcb1c9bfbd1a3ef1d097124514c5a7"
39
+ "gitHead": "9a84f91121fb5fc2c9fd2acb9a7e5a0a952d611e"
40
40
  }