datastore-core
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -0,1 +1,16 @@ | ||
<a name="2.0.0"></a> | ||
# [2.0.0](https://github.com/ipfs/js-datastore-core/compare/v1.1.0...v2.0.0) (2020-07-29) | ||
### Bug Fixes | ||
* remove node buffers ([#27](https://github.com/ipfs/js-datastore-core/issues/27)) ([a9786b9](https://github.com/ipfs/js-datastore-core/commit/a9786b9)) | ||
### BREAKING CHANGES | ||
* no longer uses node Buffers, only Uint8Arrays | ||
<a name="1.1.0"></a> | ||
@@ -2,0 +17,0 @@ # [1.1.0](https://github.com/ipfs/js-datastore-core/compare/v1.0.0...v1.1.0) (2020-05-07) |
@@ -1,2 +0,1 @@ | ||
/*! For license information please see index.min.js.LICENSE.txt */ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DatastoreCore=e():t.DatastoreCore=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){"use strict";const n=r(2),o=r(16),i=r(5),s=r(6),a=r(4);e.Key=n,e.MemoryDatastore=o,e.utils=i,e.Errors=s,e.Adapter=a},function(t,e,r){"use strict";const{Adapter:n,utils:o}=r(0),i=o.map;t.exports=class extends n{constructor(t,e){super(),this.child=t,this.transform=e}open(){return this.child.open()}put(t,e,r){return this.child.put(this.transform.convert(t),e,r)}get(t,e){return this.child.get(this.transform.convert(t),e)}has(t,e){return this.child.has(this.transform.convert(t),e)}delete(t,e){return this.child.delete(this.transform.convert(t),e)}batch(){const t=this.child.batch();return{put:(e,r)=>{t.put(this.transform.convert(e),r)},delete:e=>{t.delete(this.transform.convert(e))},commit:e=>t.commit(e)}}query(t,e){return i(this.child.query(t,e),t=>(t.key=this.transform.invert(t.key),t))}close(){return this.child.close()}}},function(t,e,r){"use strict";const{Buffer:n}=r(3),{nanoid:o}=r(14),i=r(15),s=n.from("/"),a=s[0];class u{constructor(t,e){if("string"==typeof t?this._buf=n.from(t):n.isBuffer(t)&&(this._buf=t),null==e&&(e=!0),e&&this.clean(),0===this._buf.length||this._buf[0]!==a)throw new Error("Invalid key")}toString(t){return this._buf.toString(t||"utf8")}toBuffer(){return this._buf}get[Symbol.toStringTag](){return"Key(".concat(this.toString(),")")}static withNamespaces(t){return new c(t.join("/"))}static random(){return new c(o().replace(/-/g,""))}clean(){for(this._buf&&0!==this._buf.length||(this._buf=n.from("/")),this._buf[0]!==a&&(this._buf=n.concat([s,this._buf]));this._buf.length>1&&this._buf[this._buf.length-1]===a;)this._buf=this._buf.slice(0,-1)}less(t){const e=this.list(),r=t.list();for(let n=0;n<e.length;n++){if(r.length<n+1)return!1;const t=e[n],o=r[n];if(t<o)return!0;if(t>o)return!1}return e.length<r.length}reverse(){return u.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const t=this.namespaces();return t[t.length-1]}list(){return this.toString().split("/").slice(1)}type(){return function(t){const e=t.split(":");if(e.length<2)return"";return e.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(t){const e=t.split(":");return e[e.length-1]}(this.baseNamespace())}instance(t){return new c(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith("/")||(t+="/"),t+=this.type(),new c(t)}parent(){const t=this.list();return 1===t.length?new c("/"):new c(t.slice(0,-1).join("/"))}child(t){return"/"===this.toString()?t:"/"===t.toString()?this:new c(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()!==this.toString()&&t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()!==this.toString()&&this.toString().startsWith(t.toString())}isTopLevel(){return 1===this.list().length}concat(...t){return u.withNamespaces([...this.namespaces(),...(e=t.map(t=>t.namespaces()),[].concat(...e))]);var e}}const c=i(u,{className:"Key",symbolName:"@ipfs/interface-datastore/key"});t.exports=c},function(t,e,r){"use strict";(function(t){var n=r(11),o=r(12),i=r(13);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return c(this,t,e,r)}function c(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=h(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|y(e,r),o=(t=a(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):h(t,e);if("Buffer"===e.type&&i(e.data))return h(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t,e){if(f(e),t=a(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function h(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return j(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return F(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(t,i+h)!==c(e,h)){l=!1;break}if(l)return i}return-1}function v(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function b(t,e,r,n){return K(j(e,t.length-r),t,r,n)}function E(t,e,r,n){return K(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function S(t,e,r,n){return E(t,e,r,n)}function C(t,e,r,n){return K(Y(e),t,r,n)}function _(t,e,r,n){return K(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,c=t[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return c(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return f(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return l(null,t)},u.allocUnsafeSlow=function(t){return l(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?x(this,0,t):d.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,n,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),c=this.slice(n,o),f=t.slice(e,r),l=0;l<a;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return E(this,t,e,r);case"latin1":case"binary":return S(this,t,e,r);case"base64":return C(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function R(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function F(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function P(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=N(t[i]);return o}function T(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function k(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function O(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function B(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,i){return i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,i){return i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUInt8=function(t,e){return e||k(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||k(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||k(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||k(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||k(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||k(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||k(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=u.isBuffer(t)?t:j(new u(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function j(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(10))},function(t,e,r){"use strict";function n(t){return new s(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var e,r;function n(e,r){try{var i=t[e](r),a=i.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(c){o("throw",c)}}function o(t,o){switch(t){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,o){return new Promise((function(i,s){var a={key:t,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function s(t){this.wrapped=t}function a(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(i.prototype[Symbol.asyncIterator]=function(){return this}),i.prototype.next=function(t){return this._invoke("next",t)},i.prototype.throw=function(t){return this._invoke("throw",t)},i.prototype.return=function(t){return this._invoke("return",t)};const{filter:u,sortAll:c,take:f,map:l}=r(5),h=r(19);t.exports=class{async open(){}async close(){}async put(t,e,r={}){}putMany(t,e={}){var r=this;return o((function*(){var o,i=!0,s=!1;try{for(var u,c,f=a(t);i=(u=yield n(f.next())).done,c=yield n(u.value),!i;i=!0){const{key:t,value:o}=c;yield n(r.put(t,o,e)),yield{key:t,value:o}}}catch(l){s=!0,o=l}finally{try{i||null==f.return||(yield n(f.return()))}finally{if(s)throw o}}}))()}async get(t,e={}){}getMany(t,e={}){var r=this;return o((function*(){var o,i=!0,s=!1;try{for(var u,c,f=a(t);i=(u=yield n(f.next())).done,c=yield n(u.value),!i;i=!0){const t=c;yield r.get(t,e)}}catch(l){s=!0,o=l}finally{try{i||null==f.return||(yield n(f.return()))}finally{if(s)throw o}}}))()}async has(t){}async delete(t,e={}){}deleteMany(t,e={}){var r=this;return o((function*(){var o,i=!0,s=!1;try{for(var u,c,f=a(t);i=(u=yield n(f.next())).done,c=yield n(u.value),!i;i=!0){const t=c;yield n(r.delete(t,e)),yield t}}catch(l){s=!0,o=l}finally{try{i||null==f.return||(yield n(f.return()))}finally{if(s)throw o}}}))()}batch(){let t=[],e=[];return{put(e,r){t.push({key:e,value:r})},delete(t){e.push(t)},commit:async r=>{await h(this.putMany(t,r)),t=[],await h(this.deleteMany(e,r)),e=[]}}}_all(t,e){return o((function*(){}))()}query(t,e){var r=this;return o((function*(){let o=r._all(t,e);if(null!=t.prefix&&(o=u(o,e=>e.key.toString().startsWith(t.prefix))),Array.isArray(t.filters)&&(o=t.filters.reduce((t,e)=>u(t,e),o)),Array.isArray(t.orders)&&(o=t.orders.reduce((t,e)=>c(t,e),o)),null!=t.offset){let e=0;o=u(o,()=>e++>=t.offset)}null!=t.limit&&(o=f(o,t.limit)),!0===t.keysOnly&&(o=l(o,t=>({key:t.key}))),yield*function(t,e){var r={},n=!1;function o(r,o){return n=!0,o=new Promise((function(e){e(t[r](o))})),{done:!1,value:e(o)}}return"function"==typeof Symbol&&Symbol.iterator&&(r[Symbol.iterator]=function(){return this}),r.next=function(t){return n?(n=!1,t):o("next",t)},"function"==typeof t.throw&&(r.throw=function(t){if(n)throw n=!1,t;return o("throw",t)}),"function"==typeof t.return&&(r.return=function(t){return n?(n=!1,t):o("return",t)}),r}(a(o),n)}))()}}},function(t,e,r){"use strict";function n(t){return new s(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var e,r;function n(e,r){try{var i=t[e](r),a=i.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(c){o("throw",c)}}function o(t,o){switch(t){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,o){return new Promise((function(i,s){var a={key:t,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function s(t){this.wrapped=t}function a(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(i.prototype[Symbol.asyncIterator]=function(){return this}),i.prototype.next=function(t){return this._invoke("next",t)},i.prototype.throw=function(t){return this._invoke("throw",t)},i.prototype.return=function(t){return this._invoke("return",t)};const u=r(17);e.filter=(t,e)=>o((function*(){var r,o=!0,i=!1;try{for(var s,u,c=a(t);o=(s=yield n(c.next())).done,u=yield n(s.value),!o;o=!0){const t=u;(yield n(e(t)))&&(yield t)}}catch(f){i=!0,r=f}finally{try{o||null==c.return||(yield n(c.return()))}finally{if(i)throw r}}}))(),e.sortAll=(t,e)=>o((function*(){let r=[];var o,i=!0,s=!1;try{for(var u,c,f=a(t);i=(u=yield n(f.next())).done,c=yield n(u.value),!i;i=!0){const t=c;r.push(t)}}catch(l){s=!0,o=l}finally{try{i||null==f.return||(yield n(f.return()))}finally{if(s)throw o}}r=yield n(e(r));for(const t of r)yield t}))(),e.take=(t,e)=>o((function*(){if(e<=0)return;let r=0;var o,i=!0,s=!1;try{for(var u,c,f=a(t);i=(u=yield n(f.next())).done,c=yield n(u.value),!i;i=!0){const t=c;if(yield t,r++,r>=e)return}}catch(l){s=!0,o=l}finally{try{i||null==f.return||(yield n(f.return()))}finally{if(s)throw o}}}))(),e.map=(t,e)=>o((function*(){var r,o=!0,i=!1;try{for(var s,u,c=a(t);o=(s=yield n(c.next())).done,u=yield n(s.value),!o;o=!0){const t=u;yield e(t)}}catch(f){i=!0,r=f}finally{try{o||null==c.return||(yield n(c.return()))}finally{if(i)throw r}}}))(),e.replaceStartWith=function(t,e){const r=new RegExp("^"+e);return t.replace(r,"")},e.tmpdir=u},function(t,e,r){"use strict";const n=r(20);t.exports.dbOpenFailedError=t=>(t=t||new Error("Cannot open database"),n(t,"ERR_DB_OPEN_FAILED")),t.exports.dbDeleteFailedError=t=>(t=t||new Error("Delete failed"),n(t,"ERR_DB_DELETE_FAILED")),t.exports.dbWriteFailedError=t=>(t=t||new Error("Write failed"),n(t,"ERR_DB_WRITE_FAILED")),t.exports.notFoundError=t=>(t=t||new Error("Not Found"),n(t,"ERR_NOT_FOUND")),t.exports.abortedError=t=>(t=t||new Error("Aborted"),n(t,"ERR_ABORTED"))},function(t,e,r){"use strict";const n=r(0).Key,o=r(22),i=e.PREFIX="/repo/flatfs/shard/",s=e.SHARDING_FN="SHARDING";e.README_FN="_README";class a{constructor(t){this.param=t}fun(t){throw new Error("implement me")}toString(){return"".concat(i,"v1/").concat(this.name,"/").concat(this.param)}}class u extends a{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="prefix"}fun(t){return(t+this._padding).slice(0,this.param)}}class c extends a{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="suffix"}fun(t){const e=this._padding+t;return e.slice(e.length-this.param)}}class f extends a{constructor(t){super(t),this._padding="".padStart(t+1,"_"),this.name="next-to-last"}fun(t){const e=this._padding+t,r=e.length-this.param-1;return e.slice(r,r+this.param)}}function l(t){if(0===(t=t.trim()).length)throw new Error("empty shard string");if(!t.startsWith(i))throw new Error("invalid or no path prefix: ".concat(t));const e=t.slice(i.length).split("/"),r=e[0];if("v1"!==r)throw new Error("expect 'v1' version, got '".concat(r,"'"));const n=e[1];if(!e[2])throw new Error("missing param");const o=parseInt(e[2],10);switch(n){case"prefix":return new u(o);case"suffix":return new c(o);case"next-to-last":return new f(o);default:throw new Error("unkown sharding function: ".concat(n))}}e.readShardFun=async(t,e)=>{const r=new n(t).child(new n(s)),o="function"==typeof e.getRaw?e.getRaw.bind(e):e.get.bind(e);return l((await o(r)||"").toString().trim())},e.readme=o,e.parseShardFun=l,e.Prefix=u,e.Suffix=c,e.NextToLast=f},function(t,e,r){t.exports=r(9)},function(t,e,r){"use strict";const n=r(1),o=r(21),i=r(23),s=r(24),a=r(29),u=r(7);e.KeytransformDatastore=n,e.ShardingDatastore=o,e.MountDatastore=i,e.TieredDatastore=s,e.NamespaceDatastore=a,e.shard=u},function(t,e,r){"use strict";var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(o){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,r){"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],u[f++]=e>>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(f(t,s,s+16383>a?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e,r){"use strict";e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=c}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=y,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[r+p]=255&s,p+=y,s/=256,c-=8);t[r+p-y]|=128*d}},function(t,e,r){"use strict";var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.random=e.urlAlphabet=e.customRandom=e.customAlphabet=e.nanoid=void 0;e.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";let n=t=>crypto.getRandomValues(new Uint8Array(t));e.random=n;let o=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*e/t.length);return()=>{let i="";for(;;){let s=r(o),a=o;for(;a--;)if(i+=t[s[a]&n]||"",i.length===+e)return i}}};e.customRandom=o;e.customAlphabet=(t,e)=>o(t,e,n);e.nanoid=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&r[t];e+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return e}},function(t,e,r){"use strict";t.exports=function(t,{className:e,symbolName:r}){const n=Symbol.for(r),o={[e]:class extends t{constructor(...t){super(...t),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return e}}}[e];return o["is".concat(e)]=t=>!(!t||!t[n]),o},t.exports.proto=function(t,{className:e,symbolName:r,withoutNew:n}){const o=Symbol.for(r),i={[e]:function(...e){if(n&&!(this instanceof i))return new i(...e);const r=t.call(this,...e)||this;return r&&!r[o]&&Object.defineProperty(r,o,{value:!0}),r}}[e];return i.prototype=Object.create(t.prototype),i.prototype.constructor=i,Object.defineProperty(i.prototype,Symbol.toStringTag,{get:()=>e}),i["is".concat(e)]=t=>!(!t||!t[o]),i}},function(t,e,r){"use strict";const n=r(2),o=r(4),i=r(6);t.exports=class extends o{constructor(){super(),this.data={}}async put(t,e){this.data[t.toString()]=e}async get(t){if(!await this.has(t))throw i.notFoundError();return this.data[t.toString()]}async has(t){return void 0!==this.data[t.toString()]}async delete(t){delete this.data[t.toString()]}*_all(){yield*Object.entries(this.data).map(([t,e])=>({key:new n(t),value:e}))}}},function(t,e,r){"use strict";const{nanoid:n}=r(18);t.exports=(t=(t=>t))=>t(n())},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.random=e.urlAlphabet=e.customRandom=e.customAlphabet=e.nanoid=void 0;e.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";let n=t=>crypto.getRandomValues(new Uint8Array(t));e.random=n;let o=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*e/t.length);return()=>{let i="";for(;;){let s=r(o),a=o;for(;a--;)if(i+=t[s[a]&n]||"",i.length===+e)return i}}};e.customRandom=o;e.customAlphabet=(t,e)=>o(t,e,n);e.nanoid=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&r[t];e+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return e}},function(t,e,r){"use strict";t.exports=async t=>{var e,r=!0,n=!1;try{for(var o,i=function(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}(t);r=(o=await i.next()).done,await o.value,!r;r=!0){}}catch(s){n=!0,e=s}finally{try{r||null==i.return||await i.return()}finally{if(n)throw e}}}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n;if(!(t instanceof Error))throw new TypeError("Please pass an Error to err-code");if("object"==typeof e?r=e:null!=e&&(t.code=e),r)for(n in r)t[n]=r[n];return t}},function(t,e,r){"use strict";const{Buffer:n}=r(3),{Adapter:o,Key:i}=r(0),s=r(7),a=r(1),u=new i(s.SHARDING_FN),c=new i(s.README_FN);class f extends o{constructor(t,e){super(),this.child=new a(t,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=e}open(){return this.child.open()}_convertKey(t){const e=t.toString();return e===u.toString()||e===c.toString()?t:new i(this.shard.fun(e)).child(t)}_invertKey(t){const e=t.toString();return e===u.toString()||e===c.toString()?t:i.withNamespaces(t.list().slice(1))}static async createOrOpen(t,e){try{await f.create(t,e)}catch(r){if(r&&"datastore exists"!==r.message)throw r}return f.open(t)}static async open(t){const e=await s.readShardFun("/",t);return new f(t,e)}static async create(t,e){if(!await t.has(u)){const r="function"==typeof t.putRaw?t.putRaw.bind(t):t.put.bind(t);return Promise.all([r(u,n.from(e.toString()+"\n")),r(c,n.from(s.readme))])}const r=(await s.readShardFun("/",t)||"").toString(),o=e.toString();if(r!==o)throw new Error("specified fun ".concat(o," does not match repo shard fun ").concat(r));throw new Error("datastore exists")}put(t,e,r){return this.child.put(t,e,r)}get(t,e){return this.child.get(t,e)}has(t,e){return this.child.has(t,e)}delete(t,e){return this.child.delete(t,e)}batch(){return this.child.batch()}query(t,e){const r={keysOnly:t.keysOnly,offset:t.offset,limit:t.limit,filters:[t=>t.key.toString()!==u.toString(),t=>t.key.toString()!==c.toString()]};if(null!=t.prefix&&r.filters.push(e=>this._invertKey(e.key).toString().startsWith(t.prefix)),null!=t.filters){const e=t.filters.map(t=>e=>t(Object.assign({},e,{key:this._invertKey(e.key)})));r.filters=r.filters.concat(e)}return null!=t.orders&&(r.orders=t.orders.map(t=>async e=>{e.forEach(t=>{t.key=this._invertKey(t.key)});const r=await t(e);return r.forEach(t=>{t.key=this._convertKey(t.key)}),r})),this.child.query(r,e)}close(){return this.child.close()}}t.exports=f},function(t,e,r){"use strict";t.exports="This is a repository of IPLD objects. Each IPLD object is in a single file,\nnamed <base32 encoding of cid>.data. Where <base32 encoding of cid> is the\n\"base32\" encoding of the CID (as specified in\nhttps://github.com/multiformats/multibase) without the 'B' prefix.\nAll the object files are placed in a tree of directories, based on a\nfunction of the CID. This is a form of sharding similar to\nthe objects directory in git repositories. Previously, we used\nprefixes, we now use the next-to-last two charters.\n func NextToLast(base32cid string) {\n nextToLastLen := 2\n offset := len(base32cid) - nextToLastLen - 1\n return str[offset : offset+nextToLastLen]\n }\nFor example, an object with a base58 CIDv1 of\n zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f\nhas a base32 CIDv1 of\n BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA\nand will be placed at\n SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data\nwith 'SC' being the last-to-next two characters and the 'B' at the\nbeginning of the CIDv1 string is the multibase prefix that is not\nstored in the filename.\n"},function(t,e,r){"use strict";function n(t){return new i(t)}function o(t){var e,r;function n(e,r){try{var s=t[e](r),a=s.value,u=a instanceof i;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):o(s.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(c){o("throw",c)}}function o(t,o){switch(t){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,o){return new Promise((function(i,s){var a={key:t,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function i(t){this.wrapped=t}function s(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(o.prototype[Symbol.asyncIterator]=function(){return this}),o.prototype.next=function(t){return this._invoke("next",t)},o.prototype.throw=function(t){return this._invoke("throw",t)},o.prototype.return=function(t){return this._invoke("return",t)};const{Adapter:a,Key:u,Errors:c,utils:{filter:f,take:l,sortAll:h,replaceStartWith:p}}=r(0),y=r(1);t.exports=class extends a{constructor(t){super(),this.mounts=t.slice()}open(){return Promise.all(this.mounts.map(t=>t.datastore.open()))}_lookup(t){for(const e of this.mounts)if(e.prefix.toString()===t.toString()||e.prefix.isAncestorOf(t)){const r=p(t.toString(),e.prefix.toString());return{datastore:e.datastore,mountpoint:e.prefix,rest:new u(r)}}}put(t,e,r){const n=this._lookup(t);if(null==n)throw c.dbWriteFailedError(new Error("No datastore mounted for this key"));return n.datastore.put(n.rest,e,r)}get(t,e){const r=this._lookup(t);if(null==r)throw c.notFoundError(new Error("No datastore mounted for this key"));return r.datastore.get(r.rest,e)}has(t,e){const r=this._lookup(t);return null!=r&&r.datastore.has(r.rest,e)}delete(t,e){const r=this._lookup(t);if(null==r)throw c.dbDeleteFailedError(new Error("No datastore mounted for this key"));return r.datastore.delete(r.rest,e)}close(){return Promise.all(this.mounts.map(t=>t.datastore.close()))}batch(){const t={},e=e=>{const r=this._lookup(e);if(null==r)throw new Error("No datastore mounted for this key");const n=r.mountpoint.toString();return null==t[n]&&(t[n]=r.datastore.batch()),{batch:t[n],rest:r.rest}};return{put:(t,r)=>{const n=e(t);n.batch.put(n.rest,r)},delete:t=>{const r=e(t);r.batch.delete(r.rest)},commit:e=>Promise.all(Object.keys(t).map(r=>t[r].commit(e)))}}query(t,e){const r=this.mounts.map(r=>{const n=new y(r.datastore,{convert:t=>{throw new Error("should never be called")},invert:t=>r.prefix.child(t)});let o;return null!=t.prefix&&(o=p(t.prefix,r.prefix.toString())),n.query({prefix:o,filters:t.filters,keysOnly:t.keysOnly},e)});let i=(a=r,(u=function*(){for(let f=0;f<a.length;f++){var t,e=!0,r=!1;try{for(var o,i,u=s(a[f]);e=(o=yield n(u.next())).done,i=yield n(o.value),!e;e=!0){const t=i;yield t}}catch(c){r=!0,t=c}finally{try{e||null==u.return||(yield n(u.return()))}finally{if(r)throw t}}}},function(){return new o(u.apply(this,arguments))})());var a,u;if(t.filters&&t.filters.forEach(t=>{i=f(i,t)}),t.orders&&t.orders.forEach(t=>{i=h(i,t)}),null!=t.offset){let e=0;i=f(i,()=>e++>=t.offset)}return null!=t.limit&&(i=l(i,t.limit)),i}}},function(t,e,r){"use strict";const{Adapter:n,Errors:o}=r(0),i=r(25)("datastore:core:tiered");t.exports=class extends n{constructor(t){super(),this.stores=t.slice()}async open(){try{await Promise.all(this.stores.map(t=>t.open()))}catch(t){throw o.dbOpenFailedError()}}async put(t,e){try{await Promise.all(this.stores.map(r=>r.put(t,e)))}catch(r){throw o.dbWriteFailedError()}}async get(t,e){for(const n of this.stores)try{const r=await n.get(t,e);if(r)return r}catch(r){i(r)}throw o.notFoundError()}async has(t,e){for(const r of this.stores)if(await r.has(t,e))return!0;return!1}async delete(t,e){try{await Promise.all(this.stores.map(r=>r.delete(t,e)))}catch(r){throw o.dbDeleteFailedError()}}async close(){await Promise.all(this.stores.map(t=>t.close()))}batch(){const t=this.stores.map(t=>t.batch());return{put:(e,r)=>{t.forEach(t=>t.put(e,r))},delete:e=>{t.forEach(t=>t.delete(e))},commit:async e=>{for(const r of t)await r.commit(e)}}}query(t,e){return this.stores[this.stores.length-1].query(t,e)}}},function(t,e,r){"use strict";(function(n){e.log=function(...t){return"object"==typeof console&&console.log&&console.log(...t)},e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(n++,"%c"===t&&(o=n))}),e.splice(o,0,r)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(r){}},e.load=function(){let t;try{t=e.storage.getItem("debug")}catch(r){}!t&&void 0!==n&&"env"in n&&(t={NODE_ENV:"production"}.DEBUG);return t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=r(27)(e);const{formatters:o}=t.exports;o.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(26))},function(t,e,r){"use strict";var n,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(t){o=a}}();var c,f=[],l=!1,h=-1;function p(){l&&c&&(l=!1,c.length?f=c.concat(f):h=-1,f.length&&y())}function y(){if(!l){var t=u(p);l=!0;for(var e=f.length;e;){for(c=f,f=[];++h<e;)c&&c[h].run();h=-1,e=f.length}c=null,l=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function g(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];f.push(new d(t,e)),1!==f.length||l||u(y)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,r){"use strict";t.exports=function(t){function e(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return n.colors[Math.abs(e)%n.colors.length]}function n(t){let r;function s(...t){if(!s.enabled)return;const e=s,o=Number(new Date),i=o-(r||o);e.diff=i,e.prev=r,e.curr=o,r=o,t[0]=n.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let a=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return r;a++;const i=n.formatters[o];if("function"==typeof i){const n=t[a];r=i.call(e,n),t.splice(a,1),a--}return r}),n.formatArgs.call(e,t),(e.log||n.log).apply(e,t)}return s.namespace=t,s.enabled=n.enabled(t),s.useColors=n.useColors(),s.color=e(t),s.destroy=o,s.extend=i,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function o(){const t=n.instances.indexOf(this);return-1!==t&&(n.instances.splice(t,1),!0)}function i(t,e){const r=n(this.namespace+(void 0===e?":":e)+t);return r.log=this.log,r}function s(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},n.disable=function(){const t=[...n.names.map(s),...n.skips.map(s).map(t=>"-"+t)].join(",");return n.enable(""),t},n.enable=function(t){let e;n.save(t),n.names=[],n.skips=[];const r=("string"==typeof t?t:"").split(/[\s,]+/),o=r.length;for(e=0;e<o;e++)r[e]&&("-"===(t=r[e].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+t.substr(1)+"$")):n.names.push(new RegExp("^"+t+"$")));for(e=0;e<n.instances.length;e++){const t=n.instances[e];t.enabled=n.enabled(t.namespace)}},n.enabled=function(t){if("*"===t[t.length-1])return!0;let e,r;for(e=0,r=n.skips.length;e<r;e++)if(n.skips[e].test(t))return!1;for(e=0,r=n.names.length;e<r;e++)if(n.names[e].test(t))return!0;return!1},n.humanize=r(28),Object.keys(t).forEach(e=>{n[e]=t[e]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=e,n.enable(n.load()),n}},function(t,e,r){"use strict";var n=1e3,o=6e4,i=60*o,s=24*i;function a(t,e,r,n){var o=e>=1.5*r;return Math.round(t/r)+" "+n+(o?"s":"")}t.exports=function(t,e){e=e||{};var r=typeof t;if("string"===r&&t.length>0)return function(t){if((t=String(t)).length>100)return;var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*i;case"minutes":case"minute":case"mins":case"min":case"m":return r*o;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===r&&isFinite(t))return e.long?function(t){var e=Math.abs(t);if(e>=s)return a(t,e,s,"day");if(e>=i)return a(t,e,i,"hour");if(e>=o)return a(t,e,o,"minute");if(e>=n)return a(t,e,n,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=s)return Math.round(t/s)+"d";if(e>=i)return Math.round(t/i)+"h";if(e>=o)return Math.round(t/o)+"m";if(e>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,r){"use strict";const n=r(0).Key,o=r(1);t.exports=class extends o{constructor(t,e){super(t,{convert:t=>e.child(t),invert(t){if("/"===e.toString())return t;if(!e.isAncestorOf(t))throw new Error("Expected prefix: (".concat(e.toString(),") in key: ").concat(t.toString()));return new n(t.toString().slice(e.toString().length),!1)}}),this.prefix=e}query(t){return t.prefix&&"/"!==this.prefix.toString()?super.query(Object.assign({},t,{prefix:this.prefix.child(new n(t.prefix)).toString()})):super.query(t)}}}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DatastoreCore=e():t.DatastoreCore=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=11)}([function(t,e,r){"use strict";const n=r(4),o=r(19),i=r(2),s=r(8),a=r(7);e.Key=n,e.MemoryDatastore=o,e.utils=i,e.Errors=s,e.Adapter=a},function(t,e,r){"use strict";const{Adapter:n,utils:o}=r(0),i=o.map;t.exports=class extends n{constructor(t,e){super(),this.child=t,this.transform=e}open(){return this.child.open()}put(t,e,r){return this.child.put(this.transform.convert(t),e,r)}get(t,e){return this.child.get(this.transform.convert(t),e)}has(t,e){return this.child.has(this.transform.convert(t),e)}delete(t,e){return this.child.delete(this.transform.convert(t),e)}batch(){const t=this.child.batch();return{put:(e,r)=>{t.put(this.transform.convert(e),r)},delete:e=>{t.delete(this.transform.convert(e))},commit:e=>t.commit(e)}}query(t,e){return i(this.child.query(t,e),t=>(t.key=this.transform.invert(t.key),t))}close(){return this.child.close()}}},function(t,e,r){"use strict";function n(t){return new s(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var e,r;function n(e,r){try{var i=t[e](r),a=i.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(c){o("throw",c)}}function o(t,o){switch(t){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,o){return new Promise((function(i,s){var a={key:t,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function s(t){this.wrapped=t}function a(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(i.prototype[Symbol.asyncIterator]=function(){return this}),i.prototype.next=function(t){return this._invoke("next",t)},i.prototype.throw=function(t){return this._invoke("throw",t)},i.prototype.return=function(t){return this._invoke("return",t)};const u=r(16),c=r(5),l=r(3);e.utf8Encoder=new c("utf8"),e.utf8Decoder=new l("utf8"),e.filter=(t,e)=>o((function*(){var r,o=!0,i=!1;try{for(var s,u,c=a(t);o=(s=yield n(c.next())).done,u=yield n(s.value),!o;o=!0){const t=u;(yield n(e(t)))&&(yield t)}}catch(l){i=!0,r=l}finally{try{o||null==c.return||(yield n(c.return()))}finally{if(i)throw r}}}))(),e.sortAll=(t,e)=>o((function*(){let r=[];var o,i=!0,s=!1;try{for(var u,c,l=a(t);i=(u=yield n(l.next())).done,c=yield n(u.value),!i;i=!0){const t=c;r.push(t)}}catch(f){s=!0,o=f}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(s)throw o}}r=yield n(e(r));for(const t of r)yield t}))(),e.take=(t,e)=>o((function*(){if(e<=0)return;let r=0;var o,i=!0,s=!1;try{for(var u,c,l=a(t);i=(u=yield n(l.next())).done,c=yield n(u.value),!i;i=!0){const t=c;if(yield t,r++,r>=e)return}}catch(f){s=!0,o=f}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(s)throw o}}}))(),e.map=(t,e)=>o((function*(){var r,o=!0,i=!1;try{for(var s,u,c=a(t);o=(s=yield n(c.next())).done,u=yield n(s.value),!o;o=!0){const t=u;yield e(t)}}catch(l){i=!0,r=l}finally{try{o||null==c.return||(yield n(c.return()))}finally{if(i)throw r}}}))(),e.replaceStartWith=function(t,e){const r=new RegExp("^"+e);return t.replace(r,"")},e.tmpdir=u},function(t,e,r){"use strict";t.exports=r(6).TextDecoder},function(t,e,r){"use strict";const{nanoid:n}=r(13),o=r(15),{utf8Encoder:i,utf8Decoder:s}=r(2),a=r(3),u=i.encode("/"),c=u[0];class l{constructor(t,e){if("string"==typeof t)this._buf=i.encode(t);else{if(!(t instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=t}if(null==e&&(e=!0),e&&this.clean(),0===this._buf.byteLength||this._buf[0]!==c)throw new Error("Invalid key")}toString(t="utf8"){return"utf8"===t||"utf-8"===t?s.decode(this._buf):new a(t).decode(this._buf)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new f(t.join("/"))}static random(){return new f(n().replace(/-/g,""))}clean(){if(this._buf&&0!==this._buf.byteLength||(this._buf=u),this._buf[0]!==c){const t=new Uint8Array(this._buf.byteLength+1);t.fill(c,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===c;)this._buf=this._buf.subarray(0,-1)}less(t){const e=this.list(),r=t.list();for(let n=0;n<e.length;n++){if(r.length<n+1)return!1;const t=e[n],o=r[n];if(t<o)return!0;if(t>o)return!1}return e.length<r.length}reverse(){return l.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const t=this.namespaces();return t[t.length-1]}list(){return this.toString().split("/").slice(1)}type(){return function(t){const e=t.split(":");if(e.length<2)return"";return e.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(t){const e=t.split(":");return e[e.length-1]}(this.baseNamespace())}instance(t){return new f(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith("/")||(t+="/"),t+=this.type(),new f(t)}parent(){const t=this.list();return 1===t.length?new f("/"):new f(t.slice(0,-1).join("/"))}child(t){return"/"===this.toString()?t:"/"===t.toString()?this:new f(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()!==this.toString()&&t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()!==this.toString()&&this.toString().startsWith(t.toString())}isTopLevel(){return 1===this.list().length}concat(...t){return l.withNamespaces([...this.namespaces(),...(e=t.map(t=>t.namespaces()),[].concat(...e))]);var e}}const f=o(l,{className:"Key",symbolName:"@ipfs/interface-datastore/key"});t.exports=f},function(t,e,r){"use strict";t.exports=r(6).TextEncoder},function(t,e,r){"use strict";"object"!=typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),t.exports=globalThis},function(t,e,r){"use strict";function n(t){return new s(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var e,r;function n(e,r){try{var i=t[e](r),a=i.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(c){o("throw",c)}}function o(t,o){switch(t){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,o){return new Promise((function(i,s){var a={key:t,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function s(t){this.wrapped=t}function a(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(i.prototype[Symbol.asyncIterator]=function(){return this}),i.prototype.next=function(t){return this._invoke("next",t)},i.prototype.throw=function(t){return this._invoke("throw",t)},i.prototype.return=function(t){return this._invoke("return",t)};const{filter:u,sortAll:c,take:l,map:f}=r(2),h=r(20);t.exports=class{async open(){}async close(){}async put(t,e,r={}){}putMany(t,e={}){var r=this;return o((function*(){var o,i=!0,s=!1;try{for(var u,c,l=a(t);i=(u=yield n(l.next())).done,c=yield n(u.value),!i;i=!0){const{key:t,value:o}=c;yield n(r.put(t,o,e)),yield{key:t,value:o}}}catch(f){s=!0,o=f}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(s)throw o}}}))()}async get(t,e={}){}getMany(t,e={}){var r=this;return o((function*(){var o,i=!0,s=!1;try{for(var u,c,l=a(t);i=(u=yield n(l.next())).done,c=yield n(u.value),!i;i=!0){const t=c;yield r.get(t,e)}}catch(f){s=!0,o=f}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(s)throw o}}}))()}async has(t){}async delete(t,e={}){}deleteMany(t,e={}){var r=this;return o((function*(){var o,i=!0,s=!1;try{for(var u,c,l=a(t);i=(u=yield n(l.next())).done,c=yield n(u.value),!i;i=!0){const t=c;yield n(r.delete(t,e)),yield t}}catch(f){s=!0,o=f}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(s)throw o}}}))()}batch(){let t=[],e=[];return{put(e,r){t.push({key:e,value:r})},delete(t){e.push(t)},commit:async r=>{await h(this.putMany(t,r)),t=[],await h(this.deleteMany(e,r)),e=[]}}}_all(t,e){return o((function*(){}))()}query(t,e){var r=this;return o((function*(){let o=r._all(t,e);if(null!=t.prefix&&(o=u(o,e=>e.key.toString().startsWith(t.prefix))),Array.isArray(t.filters)&&(o=t.filters.reduce((t,e)=>u(t,e),o)),Array.isArray(t.orders)&&(o=t.orders.reduce((t,e)=>c(t,e),o)),null!=t.offset){let e=0;o=u(o,()=>e++>=t.offset)}null!=t.limit&&(o=l(o,t.limit)),!0===t.keysOnly&&(o=f(o,t=>({key:t.key}))),yield*function(t,e){var r={},n=!1;function o(r,o){return n=!0,o=new Promise((function(e){e(t[r](o))})),{done:!1,value:e(o)}}return"function"==typeof Symbol&&Symbol.iterator&&(r[Symbol.iterator]=function(){return this}),r.next=function(t){return n?(n=!1,t):o("next",t)},"function"==typeof t.throw&&(r.throw=function(t){if(n)throw n=!1,t;return o("throw",t)}),"function"==typeof t.return&&(r.return=function(t){return n?(n=!1,t):o("return",t)}),r}(a(o),n)}))()}}},function(t,e,r){"use strict";const n=r(21);t.exports.dbOpenFailedError=t=>(t=t||new Error("Cannot open database"),n(t,"ERR_DB_OPEN_FAILED")),t.exports.dbDeleteFailedError=t=>(t=t||new Error("Delete failed"),n(t,"ERR_DB_DELETE_FAILED")),t.exports.dbWriteFailedError=t=>(t=t||new Error("Write failed"),n(t,"ERR_DB_WRITE_FAILED")),t.exports.notFoundError=t=>(t=t||new Error("Not Found"),n(t,"ERR_NOT_FOUND")),t.exports.abortedError=t=>(t=t||new Error("Aborted"),n(t,"ERR_ABORTED"))},function(t,e,r){"use strict";const n=r(0).Key,{utf8Decoder:o}=r(10),i=r(23),s=e.PREFIX="/repo/flatfs/shard/",a=e.SHARDING_FN="SHARDING";e.README_FN="_README";class u{constructor(t){this.param=t}fun(t){throw new Error("implement me")}toString(){return`${s}v1/${this.name}/${this.param}`}}class c extends u{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="prefix"}fun(t){return(t+this._padding).slice(0,this.param)}}class l extends u{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="suffix"}fun(t){const e=this._padding+t;return e.slice(e.length-this.param)}}class f extends u{constructor(t){super(t),this._padding="".padStart(t+1,"_"),this.name="next-to-last"}fun(t){const e=this._padding+t,r=e.length-this.param-1;return e.slice(r,r+this.param)}}function h(t){if(0===(t=t.trim()).length)throw new Error("empty shard string");if(!t.startsWith(s))throw new Error("invalid or no path prefix: "+t);const e=t.slice(s.length).split("/"),r=e[0];if("v1"!==r)throw new Error(`expect 'v1' version, got '${r}'`);const n=e[1];if(!e[2])throw new Error("missing param");const o=parseInt(e[2],10);switch(n){case"prefix":return new c(o);case"suffix":return new l(o);case"next-to-last":return new f(o);default:throw new Error("unkown sharding function: "+n)}}e.readShardFun=async(t,e)=>{const r=new n(t).child(new n(a)),i="function"==typeof e.getRaw?e.getRaw.bind(e):e.get.bind(e),s=await i(r);return h(o.decode(s||"").trim())},e.readme=i,e.parseShardFun=h,e.Prefix=c,e.Suffix=l,e.NextToLast=f},function(t,e,r){"use strict";const n=r(5),o=r(3);t.exports.utf8Encoder=new n("utf8"),t.exports.utf8Decoder=new o("utf8")},function(t,e,r){t.exports=r(12)},function(t,e,r){"use strict";const n=r(1),o=r(22),i=r(24),s=r(25),a=r(30),u=r(9);e.KeytransformDatastore=n,e.ShardingDatastore=o,e.MountDatastore=i,e.TieredDatastore=s,e.NamespaceDatastore=a,e.shard=u},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"urlAlphabet",{enumerable:!0,get:function(){return n.urlAlphabet}}),e.random=e.customRandom=e.customAlphabet=e.nanoid=void 0;var n=r(14);let o=t=>crypto.getRandomValues(new Uint8Array(t));e.random=o;let i=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*e/t.length);return()=>{let i="";for(;;){let s=r(o),a=o;for(;a--;)if(i+=t[s[a]&n]||"",i.length===+e)return i}}};e.customRandom=i;e.customAlphabet=(t,e)=>i(t,e,o);e.nanoid=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&r[t];e+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.urlAlphabet=void 0;e.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"},function(t,e,r){"use strict";t.exports=function(t,{className:e,symbolName:r}){const n=Symbol.for(r),o={[e]:class extends t{constructor(...t){super(...t),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return e}}}[e];return o["is"+e]=t=>!(!t||!t[n]),o},t.exports.proto=function(t,{className:e,symbolName:r,withoutNew:n}){const o=Symbol.for(r),i={[e]:function(...e){if(n&&!(this instanceof i))return new i(...e);const r=t.call(this,...e)||this;return r&&!r[o]&&Object.defineProperty(r,o,{value:!0}),r}}[e];return i.prototype=Object.create(t.prototype),i.prototype.constructor=i,Object.defineProperty(i.prototype,Symbol.toStringTag,{get:()=>e}),i["is"+e]=t=>!(!t||!t[o]),i}},function(t,e,r){"use strict";const{nanoid:n}=r(17);t.exports=(t=(t=>t))=>t(n())},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"urlAlphabet",{enumerable:!0,get:function(){return n.urlAlphabet}}),e.random=e.customRandom=e.customAlphabet=e.nanoid=void 0;var n=r(18);let o=t=>crypto.getRandomValues(new Uint8Array(t));e.random=o;let i=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*e/t.length);return()=>{let i="";for(;;){let s=r(o),a=o;for(;a--;)if(i+=t[s[a]&n]||"",i.length===+e)return i}}};e.customRandom=i;e.customAlphabet=(t,e)=>i(t,e,o);e.nanoid=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&r[t];e+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.urlAlphabet=void 0;e.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"},function(t,e,r){"use strict";const n=r(4),o=r(7),i=r(8);t.exports=class extends o{constructor(){super(),this.data={}}async put(t,e){this.data[t.toString()]=e}async get(t){if(!await this.has(t))throw i.notFoundError();return this.data[t.toString()]}async has(t){return void 0!==this.data[t.toString()]}async delete(t){delete this.data[t.toString()]}*_all(){yield*Object.entries(this.data).map(([t,e])=>({key:new n(t),value:e}))}}},function(t,e,r){"use strict";t.exports=async t=>{var e,r=!0,n=!1;try{for(var o,i=function(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}(t);r=(o=await i.next()).done,await o.value,!r;r=!0){}}catch(s){n=!0,e=s}finally{try{r||null==i.return||await i.return()}finally{if(n)throw e}}}},function(t,e,r){"use strict";function n(t,e){for(const r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}t.exports=function(t,e,r){if(!t||"string"==typeof t)throw new TypeError("Please pass an Error to err-code");r||(r={}),"object"==typeof e&&(r=e,e=void 0),null!=e&&(r.code=e);try{return n(t,r)}catch(o){r.message=t.message,r.stack=t.stack;const e=function(){};return e.prototype=Object.create(Object.getPrototypeOf(t)),n(new e,r)}}},function(t,e,r){"use strict";const{Adapter:n,Key:o}=r(0),i=r(9),s=r(1),{utf8Encoder:a}=r(10),u=new o(i.SHARDING_FN),c=new o(i.README_FN);class l extends n{constructor(t,e){super(),this.child=new s(t,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=e}open(){return this.child.open()}_convertKey(t){const e=t.toString();if(e===u.toString()||e===c.toString())return t;return new o(this.shard.fun(e)).child(t)}_invertKey(t){const e=t.toString();return e===u.toString()||e===c.toString()?t:o.withNamespaces(t.list().slice(1))}static async createOrOpen(t,e){try{await l.create(t,e)}catch(r){if(r&&"datastore exists"!==r.message)throw r}return l.open(t)}static async open(t){const e=await i.readShardFun("/",t);return new l(t,e)}static async create(t,e){if(!await t.has(u)){const r="function"==typeof t.putRaw?t.putRaw.bind(t):t.put.bind(t);return Promise.all([r(u,a.encode(e.toString()+"\n")),r(c,a.encode(i.readme))])}const r=(await i.readShardFun("/",t)||"").toString(),n=e.toString();if(r!==n)throw new Error(`specified fun ${n} does not match repo shard fun ${r}`);throw new Error("datastore exists")}put(t,e,r){return this.child.put(t,e,r)}get(t,e){return this.child.get(t,e)}has(t,e){return this.child.has(t,e)}delete(t,e){return this.child.delete(t,e)}batch(){return this.child.batch()}query(t,e){const r={keysOnly:t.keysOnly,offset:t.offset,limit:t.limit,filters:[t=>t.key.toString()!==u.toString(),t=>t.key.toString()!==c.toString()]};if(null!=t.prefix&&r.filters.push(e=>this._invertKey(e.key).toString().startsWith(t.prefix)),null!=t.filters){const e=t.filters.map(t=>e=>t(Object.assign({},e,{key:this._invertKey(e.key)})));r.filters=r.filters.concat(e)}return null!=t.orders&&(r.orders=t.orders.map(t=>async e=>{e.forEach(t=>{t.key=this._invertKey(t.key)});const r=await t(e);return r.forEach(t=>{t.key=this._convertKey(t.key)}),r})),this.child.query(r,e)}close(){return this.child.close()}}t.exports=l},function(t,e,r){"use strict";t.exports="This is a repository of IPLD objects. Each IPLD object is in a single file,\nnamed <base32 encoding of cid>.data. Where <base32 encoding of cid> is the\n\"base32\" encoding of the CID (as specified in\nhttps://github.com/multiformats/multibase) without the 'B' prefix.\nAll the object files are placed in a tree of directories, based on a\nfunction of the CID. This is a form of sharding similar to\nthe objects directory in git repositories. Previously, we used\nprefixes, we now use the next-to-last two charters.\n func NextToLast(base32cid string) {\n nextToLastLen := 2\n offset := len(base32cid) - nextToLastLen - 1\n return str[offset : offset+nextToLastLen]\n }\nFor example, an object with a base58 CIDv1 of\n zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f\nhas a base32 CIDv1 of\n BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA\nand will be placed at\n SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data\nwith 'SC' being the last-to-next two characters and the 'B' at the\nbeginning of the CIDv1 string is the multibase prefix that is not\nstored in the filename.\n"},function(t,e,r){"use strict";function n(t){return new i(t)}function o(t){var e,r;function n(e,r){try{var s=t[e](r),a=s.value,u=a instanceof i;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):o(s.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(c){o("throw",c)}}function o(t,o){switch(t){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,o){return new Promise((function(i,s){var a={key:t,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function i(t){this.wrapped=t}function s(t){var e;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(e=t[Symbol.asyncIterator]))return e.call(t);if(Symbol.iterator&&null!=(e=t[Symbol.iterator]))return e.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(o.prototype[Symbol.asyncIterator]=function(){return this}),o.prototype.next=function(t){return this._invoke("next",t)},o.prototype.throw=function(t){return this._invoke("throw",t)},o.prototype.return=function(t){return this._invoke("return",t)};const{Adapter:a,Key:u,Errors:c,utils:{filter:l,take:f,sortAll:h,replaceStartWith:d}}=r(0),p=r(1);t.exports=class extends a{constructor(t){super(),this.mounts=t.slice()}open(){return Promise.all(this.mounts.map(t=>t.datastore.open()))}_lookup(t){for(const e of this.mounts)if(e.prefix.toString()===t.toString()||e.prefix.isAncestorOf(t)){const r=d(t.toString(),e.prefix.toString());return{datastore:e.datastore,mountpoint:e.prefix,rest:new u(r)}}}put(t,e,r){const n=this._lookup(t);if(null==n)throw c.dbWriteFailedError(new Error("No datastore mounted for this key"));return n.datastore.put(n.rest,e,r)}get(t,e){const r=this._lookup(t);if(null==r)throw c.notFoundError(new Error("No datastore mounted for this key"));return r.datastore.get(r.rest,e)}has(t,e){const r=this._lookup(t);return null!=r&&r.datastore.has(r.rest,e)}delete(t,e){const r=this._lookup(t);if(null==r)throw c.dbDeleteFailedError(new Error("No datastore mounted for this key"));return r.datastore.delete(r.rest,e)}close(){return Promise.all(this.mounts.map(t=>t.datastore.close()))}batch(){const t={},e=e=>{const r=this._lookup(e);if(null==r)throw new Error("No datastore mounted for this key");const n=r.mountpoint.toString();return null==t[n]&&(t[n]=r.datastore.batch()),{batch:t[n],rest:r.rest}};return{put:(t,r)=>{const n=e(t);n.batch.put(n.rest,r)},delete:t=>{const r=e(t);r.batch.delete(r.rest)},commit:e=>Promise.all(Object.keys(t).map(r=>t[r].commit(e)))}}query(t,e){const r=this.mounts.map(r=>{const n=new p(r.datastore,{convert:t=>{throw new Error("should never be called")},invert:t=>r.prefix.child(t)});let o;return null!=t.prefix&&(o=d(t.prefix,r.prefix.toString())),n.query({prefix:o,filters:t.filters,keysOnly:t.keysOnly},e)});let i=(a=r,(u=function*(){for(let l=0;l<a.length;l++){var t,e=!0,r=!1;try{for(var o,i,u=s(a[l]);e=(o=yield n(u.next())).done,i=yield n(o.value),!e;e=!0){const t=i;yield t}}catch(c){r=!0,t=c}finally{try{e||null==u.return||(yield n(u.return()))}finally{if(r)throw t}}}},function(){return new o(u.apply(this,arguments))})());var a,u;if(t.filters&&t.filters.forEach(t=>{i=l(i,t)}),t.orders&&t.orders.forEach(t=>{i=h(i,t)}),null!=t.offset){let e=0;i=l(i,()=>e++>=t.offset)}return null!=t.limit&&(i=f(i,t.limit)),i}}},function(t,e,r){"use strict";const{Adapter:n,Errors:o}=r(0),i=r(26)("datastore:core:tiered");t.exports=class extends n{constructor(t){super(),this.stores=t.slice()}async open(){try{await Promise.all(this.stores.map(t=>t.open()))}catch(t){throw o.dbOpenFailedError()}}async put(t,e){try{await Promise.all(this.stores.map(r=>r.put(t,e)))}catch(r){throw o.dbWriteFailedError()}}async get(t,e){for(const n of this.stores)try{const r=await n.get(t,e);if(r)return r}catch(r){i(r)}throw o.notFoundError()}async has(t,e){for(const r of this.stores)if(await r.has(t,e))return!0;return!1}async delete(t,e){try{await Promise.all(this.stores.map(r=>r.delete(t,e)))}catch(r){throw o.dbDeleteFailedError()}}async close(){await Promise.all(this.stores.map(t=>t.close()))}batch(){const t=this.stores.map(t=>t.batch());return{put:(e,r)=>{t.forEach(t=>t.put(e,r))},delete:e=>{t.forEach(t=>t.delete(e))},commit:async e=>{for(const r of t)await r.commit(e)}}}query(t,e){return this.stores[this.stores.length-1].query(t,e)}}},function(t,e,r){"use strict";(function(n){e.log=function(...t){return"object"==typeof console&&console.log&&console.log(...t)},e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(n++,"%c"===t&&(o=n))}),e.splice(o,0,r)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(r){}},e.load=function(){let t;try{t=e.storage.getItem("debug")}catch(r){}!t&&void 0!==n&&"env"in n&&(t={NODE_ENV:"production"}.DEBUG);return t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=r(28)(e);const{formatters:o}=t.exports;o.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(27))},function(t,e,r){"use strict";var n,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(t){o=a}}();var c,l=[],f=!1,h=-1;function d(){f&&c&&(f=!1,c.length?l=c.concat(l):h=-1,l.length&&p())}function p(){if(!f){var t=u(d);f=!0;for(var e=l.length;e;){for(c=l,l=[];++h<e;)c&&c[h].run();h=-1,e=l.length}c=null,f=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function m(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];l.push(new y(t,e)),1!==l.length||f||u(p)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,r){"use strict";t.exports=function(t){function e(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return n.colors[Math.abs(e)%n.colors.length]}function n(t){let r;function s(...t){if(!s.enabled)return;const e=s,o=Number(new Date),i=o-(r||o);e.diff=i,e.prev=r,e.curr=o,r=o,t[0]=n.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let a=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return r;a++;const i=n.formatters[o];if("function"==typeof i){const n=t[a];r=i.call(e,n),t.splice(a,1),a--}return r}),n.formatArgs.call(e,t);(e.log||n.log).apply(e,t)}return s.namespace=t,s.enabled=n.enabled(t),s.useColors=n.useColors(),s.color=e(t),s.destroy=o,s.extend=i,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function o(){const t=n.instances.indexOf(this);return-1!==t&&(n.instances.splice(t,1),!0)}function i(t,e){const r=n(this.namespace+(void 0===e?":":e)+t);return r.log=this.log,r}function s(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},n.disable=function(){const t=[...n.names.map(s),...n.skips.map(s).map(t=>"-"+t)].join(",");return n.enable(""),t},n.enable=function(t){let e;n.save(t),n.names=[],n.skips=[];const r=("string"==typeof t?t:"").split(/[\s,]+/),o=r.length;for(e=0;e<o;e++)r[e]&&("-"===(t=r[e].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+t.substr(1)+"$")):n.names.push(new RegExp("^"+t+"$")));for(e=0;e<n.instances.length;e++){const t=n.instances[e];t.enabled=n.enabled(t.namespace)}},n.enabled=function(t){if("*"===t[t.length-1])return!0;let e,r;for(e=0,r=n.skips.length;e<r;e++)if(n.skips[e].test(t))return!1;for(e=0,r=n.names.length;e<r;e++)if(n.names[e].test(t))return!0;return!1},n.humanize=r(29),Object.keys(t).forEach(e=>{n[e]=t[e]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=e,n.enable(n.load()),n}},function(t,e,r){"use strict";var n=1e3,o=6e4,i=60*o,s=24*i;function a(t,e,r,n){var o=e>=1.5*r;return Math.round(t/r)+" "+n+(o?"s":"")}t.exports=function(t,e){e=e||{};var r=typeof t;if("string"===r&&t.length>0)return function(t){if((t=String(t)).length>100)return;var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*i;case"minutes":case"minute":case"mins":case"min":case"m":return r*o;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===r&&isFinite(t))return e.long?function(t){var e=Math.abs(t);if(e>=s)return a(t,e,s,"day");if(e>=i)return a(t,e,i,"hour");if(e>=o)return a(t,e,o,"minute");if(e>=n)return a(t,e,n,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=s)return Math.round(t/s)+"d";if(e>=i)return Math.round(t/i)+"h";if(e>=o)return Math.round(t/o)+"m";if(e>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,r){"use strict";const n=r(0).Key,o=r(1);t.exports=class extends o{constructor(t,e){super(t,{convert:t=>e.child(t),invert(t){if("/"===e.toString())return t;if(!e.isAncestorOf(t))throw new Error(`Expected prefix: (${e.toString()}) in key: ${t.toString()}`);return new n(t.toString().slice(e.toString().length),!1)}}),this.prefix=e}query(t){return t.prefix&&"/"!==this.prefix.toString()?super.query(Object.assign({},t,{prefix:this.prefix.child(new n(t.prefix)).toString()})):super.query(t)}}}])})); |
{ | ||
"name": "datastore-core", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Wrapper implmentation for interface-datastore", | ||
@@ -41,3 +41,3 @@ "leadMaintainer": "Pedro Teixeira <pedro@protocol.ai>", | ||
"devDependencies": { | ||
"aegir": "^22.0.0", | ||
"aegir": "^25.0.0", | ||
"async-iterator-all": "^1.0.0", | ||
@@ -48,5 +48,5 @@ "chai": "^4.2.0", | ||
"dependencies": { | ||
"buffer": "^5.5.0", | ||
"debug": "^4.1.1", | ||
"interface-datastore": "^1.0.2" | ||
"interface-datastore": "^2.0.0", | ||
"ipfs-utils": "^2.3.1" | ||
}, | ||
@@ -58,11 +58,12 @@ "engines": { | ||
"contributors": [ | ||
"achingbrain <alex@achingbrain.net>", | ||
"David Dias <daviddias.p@gmail.com>", | ||
"achingbrain <alex@achingbrain.net>", | ||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"Hector Sanjuan <code@hector.link>", | ||
"Zane Starr <zcstarr@zaner.attlocal.net>", | ||
"Hugo Dias <hugomrdias@gmail.com>", | ||
"Jacob Heun <jacobheun@gmail.com>", | ||
"Hugo Dias <hugomrdias@gmail.com>", | ||
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>", | ||
"Pedro Teixeira <i@pgte.me>", | ||
"Bryan Stenson <bryan.stenson@gmail.com>", | ||
"Richard Schneider <makaretu@gmail.com>", | ||
@@ -69,0 +70,0 @@ "Vasco Santos <vasco.santos@moxy.studio>" |
@@ -65,3 +65,3 @@ # js-datastore-core | ||
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) | ||
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) | ||
@@ -68,0 +68,0 @@ ## License |
@@ -5,2 +5,3 @@ /* @flow */ | ||
const Key = require('interface-datastore').Key | ||
const { utf8Decoder } = require('../src/utils') | ||
@@ -129,3 +130,3 @@ const readme = require('./shard-readme') | ||
const res = await get(key) | ||
return parseShardFun((res || '').toString().trim()) | ||
return parseShardFun(utf8Decoder.decode(res || '').trim()) | ||
} | ||
@@ -132,0 +133,0 @@ |
'use strict' | ||
const { Buffer } = require('buffer') | ||
const { Adapter, Key } = require('interface-datastore') | ||
const sh = require('./shard') | ||
const KeytransformStore = require('./keytransform') | ||
const { utf8Encoder } = require('../src/utils') | ||
@@ -68,4 +68,4 @@ const shardKey = new Key(sh.SHARDING_FN) | ||
const put = typeof store.putRaw === 'function' ? store.putRaw.bind(store) : store.put.bind(store) | ||
return Promise.all([put(shardKey, Buffer.from(shard.toString() + '\n')), | ||
put(shardReadmeKey, Buffer.from(sh.readme))]) | ||
return Promise.all([put(shardKey, utf8Encoder.encode(shard.toString() + '\n')), | ||
put(shardReadmeKey, utf8Encoder.encode(sh.readme))]) | ||
} | ||
@@ -72,0 +72,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
0
100
589
0
58263
+ Addedipfs-utils@^2.3.1
+ Added@achingbrain/electron-fetch@1.7.2(transitive)
+ Addedany-signal@2.1.2(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedinterface-datastore@2.0.1(transitive)
+ Addedipfs-utils@4.0.1(transitive)
+ Addediso-url@1.2.1(transitive)
+ Addedit-glob@0.0.10(transitive)
+ Addednative-abort-controller@0.0.31.0.4(transitive)
+ Addednative-fetch@2.0.1(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
- Removedbuffer@^5.5.0
- Removedinterface-datastore@1.0.4(transitive)
Updatedinterface-datastore@^2.0.0