@fireproof/core 0.5.3 → 0.5.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.
@@ -1,4 +1,5 @@
1
1
  import * as multiformats from 'multiformats';
2
+ import { CID } from 'multiformats';
2
3
 
3
4
  /**
4
5
  * Represents an DbIndex for a Fireproof database.
@@ -318,9 +319,9 @@ declare class Listener {
318
319
  * @returns {Function} A function to unsubscribe from the topic.
319
320
  * @memberof Listener
320
321
  * @instance
321
- * @param {any} since
322
+ * @param {any} [since] - clock to flush from on launch
322
323
  */
323
- on(topic: string, subscriber: Function, since: any): Function;
324
+ on(topic: string, subscriber: Function, since?: any): Function;
324
325
  /**
325
326
  * @typedef {import('./db-index').ChangeEvent} ChangeEvent
326
327
  */
@@ -9541,15 +9541,7 @@ var _polyfillNode_events = /*#__PURE__*/Object.freeze({
9541
9541
 
9542
9542
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
9543
9543
 
9544
- var streamBrowser;
9545
- var hasRequiredStreamBrowser;
9546
-
9547
- function requireStreamBrowser () {
9548
- if (hasRequiredStreamBrowser) return streamBrowser;
9549
- hasRequiredStreamBrowser = 1;
9550
- streamBrowser = require$$0$1.EventEmitter;
9551
- return streamBrowser;
9552
- }
9544
+ var streamBrowser = require$$0$1.EventEmitter;
9553
9545
 
9554
9546
  // shim for using process in browser
9555
9547
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
@@ -9692,7 +9684,7 @@ var argv = [];
9692
9684
  var version$2 = ''; // empty string to avoid regexp issues
9693
9685
  var versions = {};
9694
9686
  var release = {};
9695
- var config = {};
9687
+ var config$1 = {};
9696
9688
 
9697
9689
  function noop$2() {}
9698
9690
 
@@ -9769,7 +9761,7 @@ var browser$1$1 = {
9769
9761
  hrtime: hrtime,
9770
9762
  platform: platform,
9771
9763
  release: release,
9772
- config: config,
9764
+ config: config$1,
9773
9765
  uptime: uptime
9774
9766
  };
9775
9767
 
@@ -9850,11 +9842,11 @@ function format(f) {
9850
9842
  // Mark that a method should not be used.
9851
9843
  // Returns a modified function which warns once by default.
9852
9844
  // If --no-deprecation is set, then it is a no-op.
9853
- function deprecate$1(fn, msg) {
9845
+ function deprecate$2(fn, msg) {
9854
9846
  // Allow for deprecating things in the process of starting up.
9855
9847
  if (isUndefined(global$1.process)) {
9856
9848
  return function() {
9857
- return deprecate$1(fn, msg).apply(this, arguments);
9849
+ return deprecate$2(fn, msg).apply(this, arguments);
9858
9850
  };
9859
9851
  }
9860
9852
 
@@ -10463,7 +10455,7 @@ var _polyfillNode_util = {
10463
10455
  isBoolean: isBoolean,
10464
10456
  isArray: isArray,
10465
10457
  inspect: inspect,
10466
- deprecate: deprecate$1,
10458
+ deprecate: deprecate$2,
10467
10459
  format: format,
10468
10460
  debuglog: debuglog,
10469
10461
  promisify: promisify,
@@ -10476,7 +10468,7 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
10476
10468
  callbackify: callbackify,
10477
10469
  debuglog: debuglog,
10478
10470
  default: _polyfillNode_util,
10479
- deprecate: deprecate$1,
10471
+ deprecate: deprecate$2,
10480
10472
  format: format,
10481
10473
  inherits: inherits$w,
10482
10474
  inspect: inspect,
@@ -10664,108 +10656,99 @@ function requireBuffer_list () {
10664
10656
  return buffer_list;
10665
10657
  }
10666
10658
 
10667
- var destroy_1;
10668
- var hasRequiredDestroy;
10669
-
10670
- function requireDestroy () {
10671
- if (hasRequiredDestroy) return destroy_1;
10672
- hasRequiredDestroy = 1;
10673
-
10674
- // undocumented cb() API, needed for core, not for public API
10675
- function destroy(err, cb) {
10676
- const readableDestroyed = this._readableState && this._readableState.destroyed;
10677
- const writableDestroyed = this._writableState && this._writableState.destroyed;
10678
- if (readableDestroyed || writableDestroyed) {
10679
- if (cb) {
10680
- cb(err);
10681
- } else if (err) {
10682
- if (!this._writableState) {
10683
- process.nextTick(emitErrorNT, this, err);
10684
- } else if (!this._writableState.errorEmitted) {
10685
- this._writableState.errorEmitted = true;
10686
- process.nextTick(emitErrorNT, this, err);
10687
- }
10688
- }
10689
- return this;
10690
- }
10659
+ // undocumented cb() API, needed for core, not for public API
10660
+ function destroy(err, cb) {
10661
+ const readableDestroyed = this._readableState && this._readableState.destroyed;
10662
+ const writableDestroyed = this._writableState && this._writableState.destroyed;
10663
+ if (readableDestroyed || writableDestroyed) {
10664
+ if (cb) {
10665
+ cb(err);
10666
+ } else if (err) {
10667
+ if (!this._writableState) {
10668
+ process.nextTick(emitErrorNT, this, err);
10669
+ } else if (!this._writableState.errorEmitted) {
10670
+ this._writableState.errorEmitted = true;
10671
+ process.nextTick(emitErrorNT, this, err);
10672
+ }
10673
+ }
10674
+ return this;
10675
+ }
10691
10676
 
10692
- // we set destroyed to true before firing error callbacks in order
10693
- // to make it re-entrance safe in case destroy() is called within callbacks
10677
+ // we set destroyed to true before firing error callbacks in order
10678
+ // to make it re-entrance safe in case destroy() is called within callbacks
10694
10679
 
10695
- if (this._readableState) {
10696
- this._readableState.destroyed = true;
10697
- }
10680
+ if (this._readableState) {
10681
+ this._readableState.destroyed = true;
10682
+ }
10698
10683
 
10699
- // if this is a duplex stream mark the writable part as destroyed as well
10700
- if (this._writableState) {
10701
- this._writableState.destroyed = true;
10702
- }
10703
- this._destroy(err || null, err => {
10704
- if (!cb && err) {
10705
- if (!this._writableState) {
10706
- process.nextTick(emitErrorAndCloseNT, this, err);
10707
- } else if (!this._writableState.errorEmitted) {
10708
- this._writableState.errorEmitted = true;
10709
- process.nextTick(emitErrorAndCloseNT, this, err);
10710
- } else {
10711
- process.nextTick(emitCloseNT, this);
10712
- }
10713
- } else if (cb) {
10714
- process.nextTick(emitCloseNT, this);
10715
- cb(err);
10716
- } else {
10717
- process.nextTick(emitCloseNT, this);
10718
- }
10719
- });
10720
- return this;
10721
- }
10722
- function emitErrorAndCloseNT(self, err) {
10723
- emitErrorNT(self, err);
10724
- emitCloseNT(self);
10725
- }
10726
- function emitCloseNT(self) {
10727
- if (self._writableState && !self._writableState.emitClose) return;
10728
- if (self._readableState && !self._readableState.emitClose) return;
10729
- self.emit('close');
10730
- }
10731
- function undestroy() {
10732
- if (this._readableState) {
10733
- this._readableState.destroyed = false;
10734
- this._readableState.reading = false;
10735
- this._readableState.ended = false;
10736
- this._readableState.endEmitted = false;
10737
- }
10738
- if (this._writableState) {
10739
- this._writableState.destroyed = false;
10740
- this._writableState.ended = false;
10741
- this._writableState.ending = false;
10742
- this._writableState.finalCalled = false;
10743
- this._writableState.prefinished = false;
10744
- this._writableState.finished = false;
10745
- this._writableState.errorEmitted = false;
10746
- }
10747
- }
10748
- function emitErrorNT(self, err) {
10749
- self.emit('error', err);
10750
- }
10751
- function errorOrDestroy(stream, err) {
10752
- // We have tests that rely on errors being emitted
10753
- // in the same tick, so changing this is semver major.
10754
- // For now when you opt-in to autoDestroy we allow
10755
- // the error to be emitted nextTick. In a future
10756
- // semver major update we should change the default to this.
10757
-
10758
- const rState = stream._readableState;
10759
- const wState = stream._writableState;
10760
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10761
- }
10762
- destroy_1 = {
10763
- destroy,
10764
- undestroy,
10765
- errorOrDestroy
10766
- };
10767
- return destroy_1;
10684
+ // if this is a duplex stream mark the writable part as destroyed as well
10685
+ if (this._writableState) {
10686
+ this._writableState.destroyed = true;
10687
+ }
10688
+ this._destroy(err || null, err => {
10689
+ if (!cb && err) {
10690
+ if (!this._writableState) {
10691
+ process.nextTick(emitErrorAndCloseNT, this, err);
10692
+ } else if (!this._writableState.errorEmitted) {
10693
+ this._writableState.errorEmitted = true;
10694
+ process.nextTick(emitErrorAndCloseNT, this, err);
10695
+ } else {
10696
+ process.nextTick(emitCloseNT, this);
10697
+ }
10698
+ } else if (cb) {
10699
+ process.nextTick(emitCloseNT, this);
10700
+ cb(err);
10701
+ } else {
10702
+ process.nextTick(emitCloseNT, this);
10703
+ }
10704
+ });
10705
+ return this;
10706
+ }
10707
+ function emitErrorAndCloseNT(self, err) {
10708
+ emitErrorNT(self, err);
10709
+ emitCloseNT(self);
10710
+ }
10711
+ function emitCloseNT(self) {
10712
+ if (self._writableState && !self._writableState.emitClose) return;
10713
+ if (self._readableState && !self._readableState.emitClose) return;
10714
+ self.emit('close');
10715
+ }
10716
+ function undestroy() {
10717
+ if (this._readableState) {
10718
+ this._readableState.destroyed = false;
10719
+ this._readableState.reading = false;
10720
+ this._readableState.ended = false;
10721
+ this._readableState.endEmitted = false;
10722
+ }
10723
+ if (this._writableState) {
10724
+ this._writableState.destroyed = false;
10725
+ this._writableState.ended = false;
10726
+ this._writableState.ending = false;
10727
+ this._writableState.finalCalled = false;
10728
+ this._writableState.prefinished = false;
10729
+ this._writableState.finished = false;
10730
+ this._writableState.errorEmitted = false;
10731
+ }
10732
+ }
10733
+ function emitErrorNT(self, err) {
10734
+ self.emit('error', err);
10768
10735
  }
10736
+ function errorOrDestroy(stream, err) {
10737
+ // We have tests that rely on errors being emitted
10738
+ // in the same tick, so changing this is semver major.
10739
+ // For now when you opt-in to autoDestroy we allow
10740
+ // the error to be emitted nextTick. In a future
10741
+ // semver major update we should change the default to this.
10742
+
10743
+ const rState = stream._readableState;
10744
+ const wState = stream._writableState;
10745
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
10746
+ }
10747
+ var destroy_1 = {
10748
+ destroy,
10749
+ undestroy,
10750
+ errorOrDestroy
10751
+ };
10769
10752
 
10770
10753
  var errorsBrowser = {};
10771
10754
 
@@ -10895,109 +10878,92 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
10895
10878
  createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
10896
10879
  errorsBrowser.codes = codes;
10897
10880
 
10898
- var state;
10899
- var hasRequiredState;
10900
-
10901
- function requireState () {
10902
- if (hasRequiredState) return state;
10903
- hasRequiredState = 1;
10904
-
10905
- const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
10906
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
10907
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
10908
- }
10909
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
10910
- const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
10911
- if (hwm != null) {
10912
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
10913
- const name = isDuplex ? duplexKey : 'highWaterMark';
10914
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
10915
- }
10916
- return Math.floor(hwm);
10917
- }
10918
-
10919
- // Default value
10920
- return state.objectMode ? 16 : 16 * 1024;
10921
- }
10922
- state = {
10923
- getHighWaterMark
10924
- };
10925
- return state;
10881
+ const ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
10882
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
10883
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
10926
10884
  }
10885
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
10886
+ const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
10887
+ if (hwm != null) {
10888
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
10889
+ const name = isDuplex ? duplexKey : 'highWaterMark';
10890
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
10891
+ }
10892
+ return Math.floor(hwm);
10893
+ }
10927
10894
 
10928
- var browser$a;
10929
- var hasRequiredBrowser$3;
10895
+ // Default value
10896
+ return state.objectMode ? 16 : 16 * 1024;
10897
+ }
10898
+ var state = {
10899
+ getHighWaterMark
10900
+ };
10930
10901
 
10931
- function requireBrowser$3 () {
10932
- if (hasRequiredBrowser$3) return browser$a;
10933
- hasRequiredBrowser$3 = 1;
10934
- /**
10935
- * Module exports.
10936
- */
10902
+ /**
10903
+ * Module exports.
10904
+ */
10937
10905
 
10938
- browser$a = deprecate;
10906
+ var browser$a = deprecate$1;
10939
10907
 
10940
- /**
10941
- * Mark that a method should not be used.
10942
- * Returns a modified function which warns once by default.
10943
- *
10944
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10945
- *
10946
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10947
- * will throw an Error when invoked.
10948
- *
10949
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10950
- * will invoke `console.trace()` instead of `console.error()`.
10951
- *
10952
- * @param {Function} fn - the function to deprecate
10953
- * @param {String} msg - the string to print to the console when `fn` is invoked
10954
- * @returns {Function} a new "deprecated" version of `fn`
10955
- * @api public
10956
- */
10908
+ /**
10909
+ * Mark that a method should not be used.
10910
+ * Returns a modified function which warns once by default.
10911
+ *
10912
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10913
+ *
10914
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10915
+ * will throw an Error when invoked.
10916
+ *
10917
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10918
+ * will invoke `console.trace()` instead of `console.error()`.
10919
+ *
10920
+ * @param {Function} fn - the function to deprecate
10921
+ * @param {String} msg - the string to print to the console when `fn` is invoked
10922
+ * @returns {Function} a new "deprecated" version of `fn`
10923
+ * @api public
10924
+ */
10957
10925
 
10958
- function deprecate (fn, msg) {
10959
- if (config('noDeprecation')) {
10960
- return fn;
10961
- }
10926
+ function deprecate$1 (fn, msg) {
10927
+ if (config('noDeprecation')) {
10928
+ return fn;
10929
+ }
10962
10930
 
10963
- var warned = false;
10964
- function deprecated() {
10965
- if (!warned) {
10966
- if (config('throwDeprecation')) {
10967
- throw new Error(msg);
10968
- } else if (config('traceDeprecation')) {
10969
- console.trace(msg);
10970
- } else {
10971
- console.warn(msg);
10972
- }
10973
- warned = true;
10974
- }
10975
- return fn.apply(this, arguments);
10976
- }
10931
+ var warned = false;
10932
+ function deprecated() {
10933
+ if (!warned) {
10934
+ if (config('throwDeprecation')) {
10935
+ throw new Error(msg);
10936
+ } else if (config('traceDeprecation')) {
10937
+ console.trace(msg);
10938
+ } else {
10939
+ console.warn(msg);
10940
+ }
10941
+ warned = true;
10942
+ }
10943
+ return fn.apply(this, arguments);
10944
+ }
10977
10945
 
10978
- return deprecated;
10979
- }
10946
+ return deprecated;
10947
+ }
10980
10948
 
10981
- /**
10982
- * Checks `localStorage` for boolean values for the given `name`.
10983
- *
10984
- * @param {String} name
10985
- * @returns {Boolean}
10986
- * @api private
10987
- */
10949
+ /**
10950
+ * Checks `localStorage` for boolean values for the given `name`.
10951
+ *
10952
+ * @param {String} name
10953
+ * @returns {Boolean}
10954
+ * @api private
10955
+ */
10988
10956
 
10989
- function config (name) {
10990
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
10991
- try {
10992
- if (!commonjsGlobal.localStorage) return false;
10993
- } catch (_) {
10994
- return false;
10995
- }
10996
- var val = commonjsGlobal.localStorage[name];
10997
- if (null == val) return false;
10998
- return String(val).toLowerCase() === 'true';
10999
- }
11000
- return browser$a;
10957
+ function config (name) {
10958
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
10959
+ try {
10960
+ if (!commonjsGlobal.localStorage) return false;
10961
+ } catch (_) {
10962
+ return false;
10963
+ }
10964
+ var val = commonjsGlobal.localStorage[name];
10965
+ if (null == val) return false;
10966
+ return String(val).toLowerCase() === 'true';
11001
10967
  }
11002
10968
 
11003
10969
  var _stream_writable;
@@ -11028,12 +10994,12 @@ function require_stream_writable () {
11028
10994
 
11029
10995
  /*<replacement>*/
11030
10996
  const internalUtil = {
11031
- deprecate: requireBrowser$3()
10997
+ deprecate: browser$a
11032
10998
  };
11033
10999
  /*</replacement>*/
11034
11000
 
11035
11001
  /*<replacement>*/
11036
- var Stream = requireStreamBrowser();
11002
+ var Stream = streamBrowser;
11037
11003
  /*</replacement>*/
11038
11004
 
11039
11005
  const Buffer = require$$0$2.Buffer;
@@ -11044,8 +11010,8 @@ function require_stream_writable () {
11044
11010
  function _isUint8Array(obj) {
11045
11011
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
11046
11012
  }
11047
- const destroyImpl = requireDestroy();
11048
- const _require = requireState(),
11013
+ const destroyImpl = destroy_1;
11014
+ const _require = state,
11049
11015
  getHighWaterMark = _require.getHighWaterMark;
11050
11016
  const _require$codes = errorsBrowser.codes,
11051
11017
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -12239,7 +12205,7 @@ function require_stream_readable () {
12239
12205
  /*</replacement>*/
12240
12206
 
12241
12207
  /*<replacement>*/
12242
- var Stream = requireStreamBrowser();
12208
+ var Stream = streamBrowser;
12243
12209
  /*</replacement>*/
12244
12210
 
12245
12211
  const Buffer = require$$0$2.Buffer;
@@ -12262,8 +12228,8 @@ function require_stream_readable () {
12262
12228
  /*</replacement>*/
12263
12229
 
12264
12230
  const BufferList = requireBuffer_list();
12265
- const destroyImpl = requireDestroy();
12266
- const _require = requireState(),
12231
+ const destroyImpl = destroy_1;
12232
+ const _require = state,
12267
12233
  getHighWaterMark = _require.getHighWaterMark;
12268
12234
  const _require$codes = errorsBrowser.codes,
12269
12235
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
@@ -15629,7 +15595,7 @@ function WriteReq(chunk, encoding, cb) {
15629
15595
 
15630
15596
  function WritableState(options, stream) {
15631
15597
  Object.defineProperty(this, 'buffer', {
15632
- get: deprecate$1(function () {
15598
+ get: deprecate$2(function () {
15633
15599
  return this.getBuffer();
15634
15600
  }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
15635
15601
  });
@@ -38029,6 +37995,7 @@ function localSet (key, value) {
38029
37995
  }
38030
37996
 
38031
37997
  // @ts-nocheck
37998
+ const parseCID = cid => (typeof cid === 'string' ? CID$1.parse(cid) : cid);
38032
37999
 
38033
38000
  /**
38034
38001
  * @class Fireproof
@@ -38418,9 +38385,9 @@ class Listener {
38418
38385
  * @returns {Function} A function to unsubscribe from the topic.
38419
38386
  * @memberof Listener
38420
38387
  * @instance
38421
- * @param {any} since
38388
+ * @param {any} [since] - clock to flush from on launch
38422
38389
  */
38423
- on (topic, subscriber, since) {
38390
+ on (topic, subscriber, since = undefined) {
38424
38391
  const listOfTopicSubscribers = getTopicList(this.subcribers, topic);
38425
38392
  listOfTopicSubscribers.push(subscriber);
38426
38393
  if (typeof since !== 'undefined') {
@@ -38835,7 +38802,7 @@ class DbIndex {
38835
38802
  let removeByIdIndexEntries = [];
38836
38803
  await loadIndex(blocks, this.indexById, idIndexOpts);
38837
38804
  await loadIndex(blocks, this.indexByKey, dbIndexOpts);
38838
- console.log('head', this.dbHead, this.indexById);
38805
+ // console.log('head', this.dbHead, this.indexById)
38839
38806
  if (this.indexById.root) {
38840
38807
  const oldChangeEntries = await this.indexById.root.getMany(result.rows.map(({ key }) => key));
38841
38808
  oldIndexEntries = oldChangeEntries.result.map((key) => ({ key, del: true }));
@@ -38884,13 +38851,18 @@ async function bulkIndex (blocks, inIndex, indexEntries, opts) {
38884
38851
  inIndex.root = await load({ cid, get: getBlock, ...dbIndexOpts });
38885
38852
  }
38886
38853
  const { root, blocks: newBlocks } = await inIndex.root.bulk(indexEntries);
38887
- returnRootBlock = await root.block;
38888
- returnNode = root;
38889
- for await (const block of newBlocks) {
38890
- await putBlock(block.cid, block.bytes);
38854
+ if (root) {
38855
+ returnRootBlock = await root.block;
38856
+ returnNode = root;
38857
+ for await (const block of newBlocks) {
38858
+ await putBlock(block.cid, block.bytes);
38859
+ }
38860
+ await putBlock(returnRootBlock.cid, returnRootBlock.bytes);
38861
+ return { root: returnNode, cid: returnRootBlock.cid }
38862
+ } else {
38863
+ // throw new Error('test for index after delete')
38864
+ return { root: null, cid: null }
38891
38865
  }
38892
- await putBlock(returnRootBlock.cid, returnRootBlock.bytes);
38893
- return { root: returnNode, cid: returnRootBlock.cid }
38894
38866
  }
38895
38867
 
38896
38868
  async function loadIndex (blocks, index, indexOpts) {
@@ -38927,8 +38899,6 @@ async function doIndexQuery (blocks, indexByKey, query = {}) {
38927
38899
  }
38928
38900
  }
38929
38901
 
38930
- const parseCID = cid => (typeof cid === 'string' ? CID$1.parse(cid) : cid);
38931
-
38932
38902
  class Fireproof {
38933
38903
  /**
38934
38904
  * @function storage
@@ -39012,7 +38982,7 @@ class Fireproof {
39012
38982
  const allCIDs = await database.allCIDs();
39013
38983
  const blocks = database.blocks;
39014
38984
 
39015
- const rootCid = CID$1.parse(allCIDs[allCIDs.length - 1]);
38985
+ const rootCid = parseCID(allCIDs[allCIDs.length - 1]);
39016
38986
  if (typeof key === 'undefined') {
39017
38987
  key = blocks.valet?.getKeyMaterial();
39018
38988
  }
@@ -39030,7 +39000,9 @@ class Fireproof {
39030
39000
  allCIDs.map(async c => {
39031
39001
  const b = await blocks.get(c);
39032
39002
  // console.log('block', b)
39033
- if (typeof b.cid === 'string') { b.cid = CID$1.parse(b.cid); }
39003
+ if (typeof b.cid === 'string') {
39004
+ b.cid = parseCID(b.cid);
39005
+ }
39034
39006
  // if (b.bytes.constructor.name === 'Buffer') console.log('conver vbuff')
39035
39007
  return b
39036
39008
  })