corestore 6.8.2 → 6.8.4

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/README.md +1 -1
  2. package/index.js +32 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Corestore
2
2
 
3
- ### [See the full API docs at docs.holepunch.to](https://docs.holepunch.to/building-blocks/corestore)
3
+ ### [See the full API docs at docs.holepunch.to](https://docs.holepunch.to/helpers/corestore)
4
4
 
5
5
  Corestore is a Hypercore factory that makes it easier to manage large collections of named Hypercores.
6
6
 
package/index.js CHANGED
@@ -47,6 +47,37 @@ module.exports = class Corestore extends ReadyResource {
47
47
  this.ready().catch(safetyCatch)
48
48
  }
49
49
 
50
+ // for now just release the lock...
51
+ async suspend () {
52
+ if (this._root !== this) return this._root.suspend()
53
+
54
+ await this.ready()
55
+
56
+ if (this._keyStorage !== null) {
57
+ await new Promise((resolve, reject) => {
58
+ this._keyStorage.suspend((err) => {
59
+ if (err) return reject(err)
60
+ resolve()
61
+ })
62
+ })
63
+ }
64
+ }
65
+
66
+ async resume () {
67
+ if (this._root !== this) return this._root.resume()
68
+
69
+ await this.ready()
70
+
71
+ if (this._keyStorage !== null) {
72
+ await new Promise((resolve, reject) => {
73
+ this._keyStorage.open((err) => {
74
+ if (err) return reject(err)
75
+ resolve()
76
+ })
77
+ })
78
+ }
79
+ }
80
+
50
81
  findingPeers () {
51
82
  let done = false
52
83
  this._incFindingPeers()
@@ -266,7 +297,7 @@ module.exports = class Corestore extends ReadyResource {
266
297
  }
267
298
 
268
299
  get (opts = {}) {
269
- if (this._root.closing) throw new Error('The corestore is closed')
300
+ if (this.closing || this._root.closing) throw new Error('The corestore is closed')
270
301
  opts = validateGetOptions(opts)
271
302
 
272
303
  if (opts.cache !== false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.8.2",
3
+ "version": "6.8.4",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {