corestore 7.10.0 → 7.10.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 +43 -0
- package/index.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,42 @@ store.watch(function (core) {
|
|
|
114
114
|
|
|
115
115
|
Unregister a callback used with `store.watch(callback)` so it no longer fires.
|
|
116
116
|
|
|
117
|
+
#### `const handle = store.notifyGroup(topic)`
|
|
118
|
+
|
|
119
|
+
> [!IMPORTANT]
|
|
120
|
+
> This feature is _experimental_. The API is subject to change, and everything may break.
|
|
121
|
+
|
|
122
|
+
Get a `handle` for updates from all `hypercore`s with the group `topic` set.
|
|
123
|
+
|
|
124
|
+
#### `const stream = handle.update(opts = {})`
|
|
125
|
+
|
|
126
|
+
Gets updates for the `topic` the handle is for.
|
|
127
|
+
|
|
128
|
+
`opts` includes:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
{
|
|
132
|
+
since: 0, // What timestamp to start returning updates from. Default `0` returns all updates
|
|
133
|
+
reverse: true, // Flag to return updates in reverse order. Defaults to `true` so latest returned first
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Stream returns the core's `key`:
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
for await (const key of handle.updates()) {
|
|
141
|
+
// ...
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `handle.destroy()`
|
|
146
|
+
|
|
147
|
+
Destroys and unregisters the `handle` from its `store`.
|
|
148
|
+
|
|
149
|
+
#### `handle.on('update', callback)`
|
|
150
|
+
|
|
151
|
+
Calls the callback whenever a core with the `topic` for the `handle` updates.
|
|
152
|
+
|
|
117
153
|
#### `await store.suspend()`
|
|
118
154
|
|
|
119
155
|
Suspend the underlying storage for the Corestore.
|
|
@@ -132,6 +168,13 @@ This is useful for creating deterministic key pairs that are unique to a peer.
|
|
|
132
168
|
|
|
133
169
|
Fully close this Corestore instance.
|
|
134
170
|
|
|
171
|
+
#### `store.on('group-active', (topic) => {})`
|
|
172
|
+
|
|
173
|
+
> [!IMPORTANT]
|
|
174
|
+
> This feature is _experimental_. The API is subject to change, and everything may break.
|
|
175
|
+
|
|
176
|
+
The `group-active` event emits whenever an opened Hypercore in the store updates. The `topic` is the group topic the core belongs to.
|
|
177
|
+
|
|
135
178
|
### License
|
|
136
179
|
|
|
137
180
|
MIT
|
package/index.js
CHANGED
|
@@ -350,10 +350,14 @@ class Corestore extends ReadyResource {
|
|
|
350
350
|
async suspend({ log = noop } = {}) {
|
|
351
351
|
await log('Flushing db...')
|
|
352
352
|
// If readOnly we don't need to flush
|
|
353
|
-
if (!this.storage.readOnly)
|
|
353
|
+
if (!this.storage.readOnly) {
|
|
354
|
+
await this.storage.db.flush()
|
|
355
|
+
await log('Flusing db completed')
|
|
356
|
+
}
|
|
354
357
|
if (!this.shouldSuspend) return
|
|
355
358
|
await log('Suspending db...')
|
|
356
|
-
await this.storage.suspend()
|
|
359
|
+
await this.storage.suspend({ log })
|
|
360
|
+
await log('Suspending db completed')
|
|
357
361
|
}
|
|
358
362
|
|
|
359
363
|
resume() {
|