corestore 6.3.0 → 6.4.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/README.md +8 -0
  2. package/index.js +2 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -79,6 +79,14 @@ Useful when an application wants to accept an optional Corestore, but needs to m
79
79
  }
80
80
  ```
81
81
 
82
+ #### `store.on('core-open', core)`
83
+ Emitted when the first session for a core is opened.
84
+
85
+ *Note: This core may close at any time, so treat it as a weak reference*
86
+
87
+ #### `store.on('core-close', core)`
88
+ Emitted when the last session for a core is closed.
89
+
82
90
  ### License
83
91
  MIT
84
92
 
package/index.js CHANGED
@@ -201,6 +201,7 @@ module.exports = class Corestore extends EventEmitter {
201
201
  this.cores.set(id, core)
202
202
  core.ready().then(() => {
203
203
  if (core.closing) return // extra safety here as ready is a tick after open
204
+ this.emit('core-open', core)
204
205
  for (const { stream } of this._replicationStreams) {
205
206
  core.replicate(stream, { session: true })
206
207
  }
@@ -208,6 +209,7 @@ module.exports = class Corestore extends EventEmitter {
208
209
  this.cores.delete(id)
209
210
  })
210
211
  core.once('close', () => {
212
+ this.emit('core-close', core)
211
213
  this.cores.delete(id)
212
214
  })
213
215
  core.on('conflict', (len, fork, proof) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {