corestore 6.5.1 → 6.5.2

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 (2) hide show
  1. package/index.js +10 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -35,6 +35,7 @@ module.exports = class Corestore extends EventEmitter {
35
35
  this._overwrite = opts.overwrite === true
36
36
 
37
37
  this._sessions = new Set() // sessions for THIS namespace
38
+ this._rootStoreSessions = new Set()
38
39
 
39
40
  this._findingPeersCount = 0
40
41
  this._findingPeers = []
@@ -63,6 +64,11 @@ module.exports = class Corestore extends EventEmitter {
63
64
 
64
65
  _emitCore (name, core) {
65
66
  this.emit(name, core)
67
+ for (const session of this._root._rootStoreSessions) {
68
+ if (session !== this) {
69
+ session.emit(name, core)
70
+ }
71
+ }
66
72
  if (this !== this._root) this._root.emit(name, core)
67
73
  }
68
74
 
@@ -320,12 +326,14 @@ module.exports = class Corestore extends EventEmitter {
320
326
  }
321
327
 
322
328
  session (opts) {
323
- return new Corestore(this.storage, {
329
+ const session = new Corestore(this.storage, {
324
330
  namespace: this._namespace,
325
331
  cache: this.cache,
326
332
  _root: this._root,
327
333
  ...opts
328
334
  })
335
+ if (this === this._root) this._rootStoreSessions.add(session)
336
+ return session
329
337
  }
330
338
 
331
339
  _closeNamespace () {
@@ -357,6 +365,7 @@ module.exports = class Corestore extends EventEmitter {
357
365
 
358
366
  async _close () {
359
367
  await this._opening
368
+ this._root._rootStoreSessions.delete(this)
360
369
  await this._closeNamespace()
361
370
  if (this._root === this) {
362
371
  await this._closePrimaryNamespace()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.5.1",
3
+ "version": "6.5.2",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {