@fireproof/core 0.7.2-dev.3 → 0.7.2-dev.5

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/dist/database.js CHANGED
@@ -59,7 +59,7 @@ export class Database {
59
59
  clock: {
60
60
  byId: byId ? parseCID(byId) : null,
61
61
  byKey: byKey ? parseCID(byKey) : null,
62
- db: (db && db.length > 0) ? db.map(c => parseCID(c)) : null
62
+ db: db && db.length > 0 ? db.map(c => parseCID(c)) : null
63
63
  },
64
64
  code,
65
65
  name
@@ -124,6 +124,12 @@ export class Database {
124
124
  await this.ready;
125
125
  await this.notifyListeners({ _reset: true, _clock: this.clockToJSON() });
126
126
  }
127
+ async compact() {
128
+ if (this.name && this.blocks.valet) {
129
+ await this.blocks.valet.compact(this.clock);
130
+ await this.blocks.valet.saveHeader(this.toHeader());
131
+ }
132
+ }
127
133
  /**
128
134
  * Returns the changes made to the Fireproof instance since the specified event.
129
135
  * @function changesSince
package/dist/prolly.js CHANGED
@@ -99,11 +99,11 @@ const makeGetAndPutBlock = inBlocks => {
99
99
  // const mblocks = new MemoryBlockstore()
100
100
  // const blocks = new MultiBlockFetcher(mblocks, inBlocks)
101
101
  const { getBlock, cids } = makeGetBlock(inBlocks);
102
- const put = inBlocks.put.bind(inBlocks);
102
+ // const put = inBlocks.put.bind(inBlocks)
103
103
  const bigPut = async (block, additions) => {
104
104
  // console.log('bigPut', block.cid.toString())
105
105
  const { cid, bytes } = block;
106
- put(cid, bytes);
106
+ inBlocks.put(cid, bytes);
107
107
  // mblocks.putSync(cid, bytes)
108
108
  if (additions) {
109
109
  additions.set(cid.toString(), block);
@@ -14,6 +14,7 @@ declare class Valet {
14
14
  secondary: any;
15
15
  ready: Promise<any[]>;
16
16
  saveHeader(header: any): Promise<any>;
17
+ compact(clock: any): Promise<void>;
17
18
  /**
18
19
  * Group the blocks into a car and write it to the valet.
19
20
  * @param {import('./blockstore.js').InnerBlockstore} innerBlockstore
@@ -198,6 +199,7 @@ declare class Database {
198
199
  * @instance
199
200
  */
200
201
  notifyReset(): Promise<void>;
202
+ compact(): Promise<void>;
201
203
  /**
202
204
  * Returns the changes made to the Fireproof instance since the specified event.
203
205
  * @function changesSince