hypercore-storage 1.2.2 → 1.3.0

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.
Files changed (3) hide show
  1. package/index.js +9 -1
  2. package/lib/view.js +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -29,9 +29,14 @@ class Atom {
29
29
  this.db = db
30
30
  this.view = new View()
31
31
  this.flushing = false
32
+ this.preflushes = []
32
33
  this.flushes = []
33
34
  }
34
35
 
36
+ onpreflush (fn) {
37
+ this.preflushes.push(fn)
38
+ }
39
+
35
40
  onflush (fn) {
36
41
  this.flushes.push(fn)
37
42
  }
@@ -41,11 +46,14 @@ class Atom {
41
46
  this.flushing = true
42
47
 
43
48
  try {
49
+ let len = this.preflushes.length
50
+ for (let i = 0; i < len; i++) this.preflushes[i]()
51
+
44
52
  await View.flush(this.view.changes, this.db)
45
53
  this.view.reset()
46
54
 
47
55
  const promises = []
48
- const len = this.flushes.length // in case of reentry
56
+ len = this.flushes.length // in case of reentry
49
57
  for (let i = 0; i < len; i++) promises.push(this.flushes[i]())
50
58
 
51
59
  await Promise.all(promises)
package/lib/view.js CHANGED
@@ -209,7 +209,7 @@ class View {
209
209
 
210
210
  reset () {
211
211
  this.indexed = 0
212
- this.snap = this.map = this.changes = this.cleared = null
212
+ this.snap = this.map = this.changes = this.cleared = this.overlay = null
213
213
  }
214
214
 
215
215
  iterator (db, start, end, reverse) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",