corestore 6.3.0 → 6.4.1
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.
- package/README.md +12 -2
- package/index.js +2 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Corestore
|
|
2
2
|
|
|
3
|
+
### [See the full API docs at docs.holepunch.to](https://docs.holepunch.to/building-blocks/corestore)
|
|
4
|
+
|
|
3
5
|
Corestore is a Hypercore factory that makes it easier to manage large collections of named Hypercores.
|
|
4
6
|
|
|
5
7
|
Corestore provides:
|
|
6
8
|
1. __Key Derivation__ - All writable Hypercore keys are derived from a single master key and a user-provided name.
|
|
7
9
|
2. __Session Handling__ - If a single Hypercore is loaded multiple times through the `get` method, the underlying resources will only be opened once (using Hypercore 10's new session feature). Once all sessions are closed, the resources will be released.
|
|
8
10
|
3. __Storage Management__ - Hypercores can be stored in any random-access-storage instance, where they will be keyed by their discovery keys.
|
|
9
|
-
4. __Namespacing__ - You can share a single Corestore instance between multiple applications or components without worrying about naming collisions by creating "namespaces" (e.g. `corestore.namespace('my-app').get({ name: 'main' })
|
|
11
|
+
4. __Namespacing__ - You can share a single Corestore instance between multiple applications or components without worrying about naming collisions by creating "namespaces" (e.g. `corestore.namespace('my-app').get({ name: 'main' })`)
|
|
10
12
|
|
|
11
13
|
### Installation
|
|
12
14
|
`npm install corestore`
|
|
@@ -43,7 +45,7 @@ Corestore replicates in an "all-to-all" fashion, meaning that when replication b
|
|
|
43
45
|
|
|
44
46
|
If the remote side dynamically adds a new Hypercore to the replication stream, Corestore will load and replicate that core if possible.
|
|
45
47
|
|
|
46
|
-
Using [Hyperswarm](https://github.com/
|
|
48
|
+
Using [Hyperswarm](https://github.com/holepunchto/hyperswarm) you can easily replicate corestores
|
|
47
49
|
|
|
48
50
|
``` js
|
|
49
51
|
const swarm = new Hyperswarm()
|
|
@@ -79,6 +81,14 @@ Useful when an application wants to accept an optional Corestore, but needs to m
|
|
|
79
81
|
}
|
|
80
82
|
```
|
|
81
83
|
|
|
84
|
+
#### `store.on('core-open', core)`
|
|
85
|
+
Emitted when the first session for a core is opened.
|
|
86
|
+
|
|
87
|
+
*Note: This core may close at any time, so treat it as a weak reference*
|
|
88
|
+
|
|
89
|
+
#### `store.on('core-close', core)`
|
|
90
|
+
Emitted when the last session for a core is closed.
|
|
91
|
+
|
|
82
92
|
### License
|
|
83
93
|
MIT
|
|
84
94
|
|
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
|
+
"version": "6.4.1",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/
|
|
11
|
+
"url": "git+https://github.com/holepunchto/corestore.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"corestore"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"author": "Andrew Osheroff <andrewosh@gmail.com>",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/holepunchto/corestore/issues"
|
|
20
20
|
},
|
|
21
|
-
"homepage": "https://github.com/
|
|
21
|
+
"homepage": "https://github.com/holepunchto/corestore#readme",
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
24
24
|
"lib/**.js"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"hypercore": "^10.5.3",
|
|
34
34
|
"hypercore-crypto": "^3.2.1",
|
|
35
35
|
"safety-catch": "^1.0.1",
|
|
36
|
-
"sodium-universal": "^
|
|
36
|
+
"sodium-universal": "^4.0.0",
|
|
37
37
|
"xache": "^1.1.0"
|
|
38
38
|
}
|
|
39
39
|
}
|