@fireproof/core 0.5.3 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Cloudless database for apps, the browser, and IPFS",
5
5
  "main": "dist/src/fireproof.js",
6
6
  "module": "dist/src/fireproof.mjs",
package/src/db-index.js CHANGED
@@ -244,7 +244,7 @@ export class DbIndex {
244
244
  let removeByIdIndexEntries = []
245
245
  await loadIndex(blocks, this.indexById, idIndexOpts)
246
246
  await loadIndex(blocks, this.indexByKey, dbIndexOpts)
247
- console.log('head', this.dbHead, this.indexById)
247
+ // console.log('head', this.dbHead, this.indexById)
248
248
  if (this.indexById.root) {
249
249
  const oldChangeEntries = await this.indexById.root.getMany(result.rows.map(({ key }) => key))
250
250
  oldIndexEntries = oldChangeEntries.result.map((key) => ({ key, del: true }))
@@ -293,13 +293,18 @@ async function bulkIndex (blocks, inIndex, indexEntries, opts) {
293
293
  inIndex.root = await load({ cid, get: getBlock, ...dbIndexOpts })
294
294
  }
295
295
  const { root, blocks: newBlocks } = await inIndex.root.bulk(indexEntries)
296
- returnRootBlock = await root.block
297
- returnNode = root
298
- for await (const block of newBlocks) {
299
- await putBlock(block.cid, block.bytes)
296
+ if (root) {
297
+ returnRootBlock = await root.block
298
+ returnNode = root
299
+ for await (const block of newBlocks) {
300
+ await putBlock(block.cid, block.bytes)
301
+ }
302
+ await putBlock(returnRootBlock.cid, returnRootBlock.bytes)
303
+ return { root: returnNode, cid: returnRootBlock.cid }
304
+ } else {
305
+ // throw new Error('test for index after delete')
306
+ return { root: null, cid: null }
300
307
  }
301
- await putBlock(returnRootBlock.cid, returnRootBlock.bytes)
302
- return { root: returnNode, cid: returnRootBlock.cid }
303
308
  }
304
309
 
305
310
  async function loadIndex (blocks, index, indexOpts) {
package/src/listener.js CHANGED
@@ -41,9 +41,9 @@ export class Listener {
41
41
  * @returns {Function} A function to unsubscribe from the topic.
42
42
  * @memberof Listener
43
43
  * @instance
44
- * @param {any} since
44
+ * @param {any} [since] - clock to flush from on launch
45
45
  */
46
- on (topic, subscriber, since) {
46
+ on (topic, subscriber, since = undefined) {
47
47
  const listOfTopicSubscribers = getTopicList(this.subcribers, topic)
48
48
  listOfTopicSubscribers.push(subscriber)
49
49
  if (typeof since !== 'undefined') {