Socket
Socket
Sign inDemoInstall

interface-datastore

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interface-datastore - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

src/adapter.js

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="1.0.2"></a>
## [1.0.2](https://github.com/ipfs/interface-datastore/compare/v1.0.1...v1.0.2) (2020-05-07)
### Features
* add adapter ([4223581](https://github.com/ipfs/interface-datastore/commit/4223581))
<a name="1.0.1"></a>

@@ -2,0 +12,0 @@ ## [1.0.1](https://github.com/ipfs/interface-datastore/compare/v1.0.0...v1.0.1) (2020-05-07)

2

dist/index.min.js
/*! For license information please see index.min.js.LICENSE.txt */
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.InterfaceDatastore=r():t.InterfaceDatastore=r()}(window,(function(){return function(t){var r={};function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(n,o,function(r){return t[r]}.bind(null,o));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=3)}([function(t,r,e){"use strict";const{Buffer:n}=e(5),{nanoid:o}=e(10),i=e(11),u=n.from("/"),s=u[0];class a{constructor(t,r){if("string"==typeof t?this._buf=n.from(t):n.isBuffer(t)&&(this._buf=t),null==r&&(r=!0),r&&this.clean(),0===this._buf.length||this._buf[0]!==s)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 f(t.join("/"))}static random(){return new f(o().replace(/-/g,""))}clean(){for(this._buf&&0!==this._buf.length||(this._buf=n.from("/")),this._buf[0]!==s&&(this._buf=n.concat([u,this._buf]));this._buf.length>1&&this._buf[this._buf.length-1]===s;)this._buf=this._buf.slice(0,-1)}less(t){const r=this.list(),e=t.list();for(let n=0;n<r.length;n++){if(e.length<n+1)return!1;const t=r[n],o=e[n];if(t<o)return!0;if(t>o)return!1}return r.length<e.length}reverse(){return a.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 r=t.split(":");if(r.length<2)return"";return r.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(t){const r=t.split(":");return r[r.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 a.withNamespaces([...this.namespaces(),...(r=t.map(t=>t.namespaces()),[].concat(...r))]);var r}}const f=i(a,{className:"Key",symbolName:"@ipfs/interface-datastore/key"});t.exports=f},function(t,r,e){"use strict";function n(t){return new u(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var r,e;function n(r,e){try{var i=t[r](e),s=i.value,a=s instanceof u;Promise.resolve(a?s.wrapped:s).then((function(t){a?n("return"===r?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(f){o("throw",f)}}function o(t,o){switch(t){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):e=null}this._invoke=function(t,o){return new Promise((function(i,u){var s={key:t,arg:o,resolve:i,reject:u,next:null};e?e=e.next=s:(r=e=s,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function u(t){this.wrapped=t}function s(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.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 a=e(13);r.filter=(t,r)=>o((function*(){var e,o=!0,i=!1;try{for(var u,a,f=s(t);o=(u=yield n(f.next())).done,a=yield n(u.value),!o;o=!0){const t=a;(yield n(r(t)))&&(yield t)}}catch(h){i=!0,e=h}finally{try{o||null==f.return||(yield n(f.return()))}finally{if(i)throw e}}}))(),r.sortAll=(t,r)=>o((function*(){let e=[];var o,i=!0,u=!1;try{for(var a,f,h=s(t);i=(a=yield n(h.next())).done,f=yield n(a.value),!i;i=!0){const t=f;e.push(t)}}catch(l){u=!0,o=l}finally{try{i||null==h.return||(yield n(h.return()))}finally{if(u)throw o}}e=yield n(r(e));for(const t of e)yield t}))(),r.take=(t,r)=>o((function*(){if(r<=0)return;let e=0;var o,i=!0,u=!1;try{for(var a,f,h=s(t);i=(a=yield n(h.next())).done,f=yield n(a.value),!i;i=!0){const t=f;if(yield t,e++,e>=r)return}}catch(l){u=!0,o=l}finally{try{i||null==h.return||(yield n(h.return()))}finally{if(u)throw o}}}))(),r.map=(t,r)=>o((function*(){var e,o=!0,i=!1;try{for(var u,a,f=s(t);o=(u=yield n(f.next())).done,a=yield n(u.value),!o;o=!0){const t=a;yield r(t)}}catch(h){i=!0,e=h}finally{try{o||null==f.return||(yield n(f.return()))}finally{if(i)throw e}}}))(),r.replaceStartWith=function(t,r){const e=new RegExp("^"+r);return t.replace(e,"")},r.tmpdir=a},function(t,r,e){"use strict";const n=e(15);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,r,e){t.exports=e(4)},function(t,r,e){"use strict";const n=e(0),o=e(12),i=e(1),u=e(2);r.Key=n,r.MemoryDatastore=o,r.utils=i,r.Errors=u},function(t,r,e){"use strict";(function(t){var n=e(7),o=e(8),i=e(9);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,r){if(u()<r)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=a.prototype:(null===t&&(t=new a(r)),t.length=r),t}function a(t,r,e){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return f(this,t,r,e)}function f(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n);a.TYPED_ARRAY_SUPPORT?(t=r).__proto__=a.prototype:t=c(t,r);return t}(t,r,e,n):"string"==typeof r?function(t,r,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|y(r,e),o=(t=s(t,n)).write(r,e);o!==n&&(t=t.slice(0,o));return t}(t,r,e):function(t,r){if(a.isBuffer(r)){var e=0|p(r.length);return 0===(t=s(t,e)).length||r.copy(t,0,0,e),t}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(n=r.length)!=n?s(t,0):c(t,r);if("Buffer"===r.type&&i(r.data))return c(t,r.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function h(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,r){if(h(r),t=s(t,r<0?0:0|p(r)),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function c(t,r){var e=r.length<0?0:0|p(r.length);t=s(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function p(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function y(t,r){if(a.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 e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return F(t).length;default:if(n)return j(t).length;r=(""+r).toLowerCase(),n=!0}}function g(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,r,e);case"utf8":case"utf-8":return P(this,r,e);case"ascii":return T(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function w(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=a.from(r,n)),a.isBuffer(r))return 0===r.length?-1:v(t,r,e,n,o);if("number"==typeof r)return r&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):v(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,r,e,n,o){var i,u=1,s=t.length,a=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u=2,s/=2,a/=2,e/=2}function f(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(o){var h=-1;for(i=e;i<s;i++)if(f(t,i)===f(r,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===a)return h*u}else-1!==h&&(i-=i-h),h=-1}else for(e+a>s&&(e=s-a),i=e;i>=0;i--){for(var l=!0,c=0;c<a;c++)if(f(t,i+c)!==f(r,c)){l=!1;break}if(l)return i}return-1}function b(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n))>o&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u<n;++u){var s=parseInt(r.substr(2*u,2),16);if(isNaN(s))return u;t[e+u]=s}return u}function m(t,r,e,n){return z(j(r,t.length-e),t,e,n)}function E(t,r,e,n){return z(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function _(t,r,e,n){return E(t,r,e,n)}function A(t,r,e,n){return z(F(r),t,e,n)}function S(t,r,e,n){return z(function(t,r){for(var e,n,o,i=[],u=0;u<t.length&&!((r-=2)<0);++u)e=t.charCodeAt(u),n=e>>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function R(t,r,e){return 0===r&&e===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(r,e))}function P(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i,u,s,a,f=t[o],h=null,l=f>239?4:f>223?3:f>191?2:1;if(o+l<=e)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(h=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&f)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(h=a)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var r=t.length;if(r<=4096)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return e}(n)}r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50,a.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(r){return!1}}(),r.kMaxLength=u(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,r,e){return f(null,t,r,e)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,r,e){return function(t,r,e,n){return h(r),r<=0?s(t,r):void 0!==e?"string"==typeof n?s(t,r).fill(e,n):s(t,r).fill(e):s(t,r)}(null,t,r,e)},a.allocUnsafe=function(t){return l(null,t)},a.allocUnsafeSlow=function(t){return l(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,r){if(!a.isBuffer(t)||!a.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);o<i;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return e<n?-1:n<e?1:0},a.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}},a.concat=function(t,r){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var n=a.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(n,o),o+=u.length}return n},a.byteLength=y,a.prototype._isBuffer=!0,a.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 r=0;r<t;r+=2)d(this,r,r+1);return this},a.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 r=0;r<t;r+=4)d(this,r,r+3),d(this,r+1,r+2);return this},a.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 r=0;r<t;r+=8)d(this,r,r+7),d(this,r+1,r+6),d(this,r+2,r+5),d(this,r+3,r+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?P(this,0,t):g.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,r,e,n,o){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(i,u),f=this.slice(n,o),h=t.slice(r,e),l=0;l<s;++l)if(f[l]!==h[l]){i=f[l],u=h[l];break}return i<u?-1:u<i?1:0},a.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},a.prototype.indexOf=function(t,r,e){return w(this,t,r,e,!0)},a.prototype.lastIndexOf=function(t,r,e){return w(this,t,r,e,!1)},a.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return m(this,t,r,e);case"ascii":return E(this,t,r,e);case"latin1":case"binary":return _(this,t,r,e);case"base64":return A(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(127&t[o]);return n}function B(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=N(t[i]);return o}function U(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function I(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function O(t,r,e,n,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function M(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function Y(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>8*(n?o:3-o)&255}function k(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function D(t,r,e,n,i){return i||k(t,0,e,4),o.write(t,r,e,n,23,4),e+4}function L(t,r,e,n,i){return i||k(t,0,e,8),o.write(t,r,e,n,52,8),e+8}a.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),a.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=a.prototype;else{var o=r-t;e=new a(o,void 0);for(var i=0;i<o;++i)e[i]=this[i+t]}return e},a.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},a.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},a.prototype.readUInt8=function(t,r){return r||I(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,r){return r||I(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,r){return r||I(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,r){return r||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,r){return r||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*r)),n},a.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},a.prototype.readInt8=function(t,r){return r||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,r){r||I(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},a.prototype.readInt16BE=function(t,r){r||I(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},a.prototype.readInt32LE=function(t,r){return r||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,r){return r||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,r){return r||I(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,r){return r||I(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,r){return r||I(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,r){return r||I(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||O(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=t/o&255;return r+e},a.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||O(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;--o>=0&&(i*=256);)this[r+o]=t/i&255;return r+e},a.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},a.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},a.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},a.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):Y(this,t,r,!0),r+4},a.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Y(this,t,r,!1),r+4},a.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);O(this,t,r,e,o-1,-o)}var i=0,u=1,s=0;for(this[r]=255&t;++i<e&&(u*=256);)t<0&&0===s&&0!==this[r+i-1]&&(s=1),this[r+i]=(t/u>>0)-s&255;return r+e},a.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);O(this,t,r,e,o-1,-o)}var i=e-1,u=1,s=0;for(this[r+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[r+i+1]&&(s=1),this[r+i]=(t/u>>0)-s&255;return r+e},a.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},a.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},a.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},a.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Y(this,t,r,!0),r+4},a.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Y(this,t,r,!1),r+4},a.prototype.writeFloatLE=function(t,r,e){return D(this,t,r,!0,e)},a.prototype.writeFloatBE=function(t,r,e){return D(this,t,r,!1,e)},a.prototype.writeDoubleLE=function(t,r,e){return L(this,t,r,!0,e)},a.prototype.writeDoubleBE=function(t,r,e){return L(this,t,r,!1,e)},a.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=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-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&e<r&&r<n)for(o=i-1;o>=0;--o)t[o+r]=this[o+e];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},a.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=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&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;var i;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i<e;++i)this[i]=t;else{var u=a.isBuffer(t)?t:j(new a(t,n).toString()),s=u.length;for(i=0;i<e-r;++i)this[i+r]=u[i%s]}return this};var C=/[^+\/0-9A-Za-z-_]/g;function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function j(t,r){var e;r=r||1/0;for(var n=t.length,o=null,i=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(C,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}}).call(this,e(6))},function(t,r,e){"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,r,e){"use strict";r.byteLength=function(t){var r=f(t),e=r[0],n=r[1];return 3*(e+n)/4-n},r.toByteArray=function(t){var r,e,n=f(t),u=n[0],s=n[1],a=new i(function(t,r,e){return 3*(r+e)/4-e}(0,u,s)),h=0,l=s>0?u-4:u;for(e=0;e<l;e+=4)r=o[t.charCodeAt(e)]<<18|o[t.charCodeAt(e+1)]<<12|o[t.charCodeAt(e+2)]<<6|o[t.charCodeAt(e+3)],a[h++]=r>>16&255,a[h++]=r>>8&255,a[h++]=255&r;2===s&&(r=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,a[h++]=255&r);1===s&&(r=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,a[h++]=r>>8&255,a[h++]=255&r);return a},r.fromByteArray=function(t){for(var r,e=t.length,o=e%3,i=[],u=0,s=e-o;u<s;u+=16383)i.push(h(t,u,u+16383>s?s:u+16383));1===o?(r=t[e-1],i.push(n[r>>2]+n[r<<4&63]+"==")):2===o&&(r=(t[e-2]<<8)+t[e-1],i.push(n[r>>10]+n[r>>4&63]+n[r<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s<a;++s)n[s]=u[s],o[u.charCodeAt(s)]=s;function f(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function h(t,r,e){for(var o,i,u=[],s=r;s<e;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),u.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,r,e){"use strict";r.read=function(t,r,e,n,o){var i,u,s=8*o-n-1,a=(1<<s)-1,f=a>>1,h=-7,l=e?o-1:0,c=e?-1:1,p=t[r+l];for(l+=c,i=p&(1<<-h)-1,p>>=-h,h+=s;h>0;i=256*i+t[r+l],l+=c,h-=8);for(u=i&(1<<-h)-1,i>>=-h,h+=n;h>0;u=256*u+t[r+l],l+=c,h-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,n),i-=f}return(p?-1:1)*u*Math.pow(2,i-n)},r.write=function(t,r,e,n,o,i){var u,s,a,f=8*i-o-1,h=(1<<f)-1,l=h>>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,u=h):(u=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-u))<1&&(u--,a*=2),(r+=u+l>=1?c/a:c*Math.pow(2,1-l))*a>=2&&(u++,a/=2),u+l>=h?(s=0,u=h):u+l>=1?(s=(r*a-1)*Math.pow(2,o),u+=l):(s=r*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;t[e+p]=255&s,p+=y,s/=256,o-=8);for(u=u<<o|s,f+=o;f>0;t[e+p]=255&u,p+=y,u/=256,f-=8);t[e+p-y]|=128*g}},function(t,r,e){"use strict";var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.random=r.urlAlphabet=r.customRandom=r.customAlphabet=r.nanoid=void 0;r.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";let n=t=>crypto.getRandomValues(new Uint8Array(t));r.random=n;let o=(t,r,e)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length);return()=>{let i="";for(;;){let u=e(o),s=o;for(;s--;)if(i+=t[u[s]&n]||"",i.length===+r)return i}}};r.customRandom=o;r.customAlphabet=(t,r)=>o(t,r,n);r.nanoid=(t=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&e[t];r+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return r}},function(t,r,e){"use strict";t.exports=function(t,{className:r,symbolName:e}){const n=Symbol.for(e),o={[r]:class extends t{constructor(...t){super(...t),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return r}}}[r];return o["is".concat(r)]=t=>!(!t||!t[n]),o},t.exports.proto=function(t,{className:r,symbolName:e,withoutNew:n}){const o=Symbol.for(e),i={[r]:function(...r){if(n&&!(this instanceof i))return new i(...r);const e=t.call(this,...r)||this;return e&&!e[o]&&Object.defineProperty(e,o,{value:!0}),e}}[r];return i.prototype=Object.create(t.prototype),i.prototype.constructor=i,Object.defineProperty(i.prototype,Symbol.toStringTag,{get:()=>r}),i["is".concat(r)]=t=>!(!t||!t[o]),i}},function(t,r,e){"use strict";function n(t,r){var e={},n=!1;function o(e,o){return n=!0,o=new Promise((function(r){r(t[e](o))})),{done:!1,value:r(o)}}return"function"==typeof Symbol&&Symbol.iterator&&(e[Symbol.iterator]=function(){return this}),e.next=function(t){return n?(n=!1,t):o("next",t)},"function"==typeof t.throw&&(e.throw=function(t){if(n)throw n=!1,t;return o("throw",t)}),"function"==typeof t.return&&(e.return=function(t){return n?(n=!1,t):o("return",t)}),e}function o(t){return new s(t)}function i(t){return function(){return new u(t.apply(this,arguments))}}function u(t){var r,e;function n(r,e){try{var i=t[r](e),u=i.value,a=u instanceof s;Promise.resolve(a?u.wrapped:u).then((function(t){a?n("return"===r?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(f){o("throw",f)}}function o(t,o){switch(t){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):e=null}this._invoke=function(t,o){return new Promise((function(i,u){var s={key:t,arg:o,resolve:i,reject:u,next:null};e?e=e.next=s:(r=e=s,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function s(t){this.wrapped=t}function a(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.call(t)}throw new TypeError("Object is not async iterable")}"function"==typeof Symbol&&Symbol.asyncIterator&&(u.prototype[Symbol.asyncIterator]=function(){return this}),u.prototype.next=function(t){return this._invoke("next",t)},u.prototype.throw=function(t){return this._invoke("throw",t)},u.prototype.return=function(t){return this._invoke("return",t)};const{filter:f,sortAll:h,take:l,map:c}=e(1),p=e(0),y=e(2);function g(t){if(t&&t.aborted)throw Error.abortedError()}t.exports=class{constructor(){this.data={}}async open(){}async put(t,r){this.data[t.toString()]=r}putMany(t,r={}){var e=this;return i((function*(){g(r.signal);var n,i=!0,u=!1;try{for(var s,f,h=a(t);i=(s=yield o(h.next())).done,f=yield o(s.value),!i;i=!0){const{key:t,value:n}=f;g(r.signal),yield o(e.put(t,n)),yield{key:t,value:n}}}catch(l){u=!0,n=l}finally{try{i||null==h.return||(yield o(h.return()))}finally{if(u)throw n}}}))()}async get(t){if(!await this.has(t))throw y.notFoundError();return this.data[t.toString()]}getMany(t,r={}){var e=this;return i((function*(){g(r.signal);var n,i=!0,u=!1;try{for(var s,f,h=a(t);i=(s=yield o(h.next())).done,f=yield o(s.value),!i;i=!0){const t=f;g(r.signal),yield e.get(t)}}catch(l){u=!0,n=l}finally{try{i||null==h.return||(yield o(h.return()))}finally{if(u)throw n}}}))()}async has(t){return void 0!==this.data[t.toString()]}async delete(t){delete this.data[t.toString()]}deleteMany(t,r={}){var e=this;return i((function*(){g(r.signal);var n,i=!0,u=!1;try{for(var s,f,h=a(t);i=(s=yield o(h.next())).done,f=yield o(s.value),!i;i=!0){const t=f;g(r.signal),yield o(e.delete(t)),yield t}}catch(l){u=!0,n=l}finally{try{i||null==h.return||(yield o(h.return()))}finally{if(u)throw n}}}))()}batch(){let t=[],r=[];const e=this;return{put(r,e){t.push({key:r,value:e})},delete(t){r.push(t)},commit:u=>i((function*(){yield*n(a(e.putMany(t,u)),o),t=[],yield*n(a(e.deleteMany(r,u)),o),r=[]}))()}}query(t){let r=Object.entries(this.data);if(r=c(r,t=>({key:new p(t[0]),value:t[1]})),null!=t.prefix&&(r=f(r,r=>r.key.toString().startsWith(t.prefix))),Array.isArray(t.filters)&&(r=t.filters.reduce((t,r)=>f(t,r),r)),Array.isArray(t.orders)&&(r=t.orders.reduce((t,r)=>h(t,r),r)),null!=t.offset){let e=0;r=f(r,()=>e++>=t.offset)}return null!=t.limit&&(r=l(r,t.limit)),!0===t.keysOnly&&(r=c(r,t=>({key:t.key}))),r}async close(){}}},function(t,r,e){"use strict";const{nanoid:n}=e(14);t.exports=(t=(t=>t))=>t(n())},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.random=r.urlAlphabet=r.customRandom=r.customAlphabet=r.nanoid=void 0;r.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";let n=t=>crypto.getRandomValues(new Uint8Array(t));r.random=n;let o=(t,r,e)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length);return()=>{let i="";for(;;){let u=e(o),s=o;for(;s--;)if(i+=t[u[s]&n]||"",i.length===+r)return i}}};r.customRandom=o;r.customAlphabet=(t,r)=>o(t,r,n);r.nanoid=(t=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&e[t];r+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return r}},function(t,r,e){"use strict";t.exports=function(t,r,e){var n;if(!(t instanceof Error))throw new TypeError("Please pass an Error to err-code");if("object"==typeof r?e=r:null!=r&&(t.code=r),e)for(n in e)t[n]=e[n];return t}}])}));
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.InterfaceDatastore=r():t.InterfaceDatastore=r()}(window,(function(){return function(t){var r={};function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(n,o,function(r){return t[r]}.bind(null,o));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=4)}([function(t,r,e){"use strict";const{Buffer:n}=e(6),{nanoid:o}=e(11),i=e(12),u=n.from("/"),s=u[0];class a{constructor(t,r){if("string"==typeof t?this._buf=n.from(t):n.isBuffer(t)&&(this._buf=t),null==r&&(r=!0),r&&this.clean(),0===this._buf.length||this._buf[0]!==s)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 f(t.join("/"))}static random(){return new f(o().replace(/-/g,""))}clean(){for(this._buf&&0!==this._buf.length||(this._buf=n.from("/")),this._buf[0]!==s&&(this._buf=n.concat([u,this._buf]));this._buf.length>1&&this._buf[this._buf.length-1]===s;)this._buf=this._buf.slice(0,-1)}less(t){const r=this.list(),e=t.list();for(let n=0;n<r.length;n++){if(e.length<n+1)return!1;const t=r[n],o=e[n];if(t<o)return!0;if(t>o)return!1}return r.length<e.length}reverse(){return a.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 r=t.split(":");if(r.length<2)return"";return r.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(t){const r=t.split(":");return r[r.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 a.withNamespaces([...this.namespaces(),...(r=t.map(t=>t.namespaces()),[].concat(...r))]);var r}}const f=i(a,{className:"Key",symbolName:"@ipfs/interface-datastore/key"});t.exports=f},function(t,r,e){"use strict";function n(t){return new u(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var r,e;function n(r,e){try{var i=t[r](e),s=i.value,a=s instanceof u;Promise.resolve(a?s.wrapped:s).then((function(t){a?n("return"===r?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(f){o("throw",f)}}function o(t,o){switch(t){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):e=null}this._invoke=function(t,o){return new Promise((function(i,u){var s={key:t,arg:o,resolve:i,reject:u,next:null};e?e=e.next=s:(r=e=s,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function u(t){this.wrapped=t}function s(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.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:a,sortAll:f,take:l,map:h}=e(2),c=e(16);t.exports=class{async open(){}async close(){}async put(t,r,e={}){}putMany(t,r={}){var e=this;return o((function*(){var o,i=!0,u=!1;try{for(var a,f,l=s(t);i=(a=yield n(l.next())).done,f=yield n(a.value),!i;i=!0){const{key:t,value:o}=f;yield n(e.put(t,o,r)),yield{key:t,value:o}}}catch(h){u=!0,o=h}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(u)throw o}}}))()}async get(t,r={}){}getMany(t,r={}){var e=this;return o((function*(){var o,i=!0,u=!1;try{for(var a,f,l=s(t);i=(a=yield n(l.next())).done,f=yield n(a.value),!i;i=!0){const t=f;yield e.get(t,r)}}catch(h){u=!0,o=h}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(u)throw o}}}))()}async has(t){}async delete(t,r={}){}deleteMany(t,r={}){var e=this;return o((function*(){var o,i=!0,u=!1;try{for(var a,f,l=s(t);i=(a=yield n(l.next())).done,f=yield n(a.value),!i;i=!0){const t=f;yield n(e.delete(t,r)),yield t}}catch(h){u=!0,o=h}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(u)throw o}}}))()}batch(){let t=[],r=[];return{put(r,e){t.push({key:r,value:e})},delete(t){r.push(t)},commit:async e=>{await c(this.putMany(t,e)),t=[],await c(this.deleteMany(r,e)),r=[]}}}_all(t,r){return o((function*(){}))()}query(t,r){var e=this;return o((function*(){let o=e._all(t,r);if(null!=t.prefix&&(o=a(o,r=>r.key.toString().startsWith(t.prefix))),Array.isArray(t.filters)&&(o=t.filters.reduce((t,r)=>a(t,r),o)),Array.isArray(t.orders)&&(o=t.orders.reduce((t,r)=>f(t,r),o)),null!=t.offset){let r=0;o=a(o,()=>r++>=t.offset)}null!=t.limit&&(o=l(o,t.limit)),!0===t.keysOnly&&(o=h(o,t=>({key:t.key}))),yield*function(t,r){var e={},n=!1;function o(e,o){return n=!0,o=new Promise((function(r){r(t[e](o))})),{done:!1,value:r(o)}}return"function"==typeof Symbol&&Symbol.iterator&&(e[Symbol.iterator]=function(){return this}),e.next=function(t){return n?(n=!1,t):o("next",t)},"function"==typeof t.throw&&(e.throw=function(t){if(n)throw n=!1,t;return o("throw",t)}),"function"==typeof t.return&&(e.return=function(t){return n?(n=!1,t):o("return",t)}),e}(s(o),n)}))()}}},function(t,r,e){"use strict";function n(t){return new u(t)}function o(t){return function(){return new i(t.apply(this,arguments))}}function i(t){var r,e;function n(r,e){try{var i=t[r](e),s=i.value,a=s instanceof u;Promise.resolve(a?s.wrapped:s).then((function(t){a?n("return"===r?"return":"next",t):o(i.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(f){o("throw",f)}}function o(t,o){switch(t){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):e=null}this._invoke=function(t,o){return new Promise((function(i,u){var s={key:t,arg:o,resolve:i,reject:u,next:null};e?e=e.next=s:(r=e=s,n(t,o))}))},"function"!=typeof t.return&&(this.return=void 0)}function u(t){this.wrapped=t}function s(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.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 a=e(14);r.filter=(t,r)=>o((function*(){var e,o=!0,i=!1;try{for(var u,a,f=s(t);o=(u=yield n(f.next())).done,a=yield n(u.value),!o;o=!0){const t=a;(yield n(r(t)))&&(yield t)}}catch(l){i=!0,e=l}finally{try{o||null==f.return||(yield n(f.return()))}finally{if(i)throw e}}}))(),r.sortAll=(t,r)=>o((function*(){let e=[];var o,i=!0,u=!1;try{for(var a,f,l=s(t);i=(a=yield n(l.next())).done,f=yield n(a.value),!i;i=!0){const t=f;e.push(t)}}catch(h){u=!0,o=h}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(u)throw o}}e=yield n(r(e));for(const t of e)yield t}))(),r.take=(t,r)=>o((function*(){if(r<=0)return;let e=0;var o,i=!0,u=!1;try{for(var a,f,l=s(t);i=(a=yield n(l.next())).done,f=yield n(a.value),!i;i=!0){const t=f;if(yield t,e++,e>=r)return}}catch(h){u=!0,o=h}finally{try{i||null==l.return||(yield n(l.return()))}finally{if(u)throw o}}}))(),r.map=(t,r)=>o((function*(){var e,o=!0,i=!1;try{for(var u,a,f=s(t);o=(u=yield n(f.next())).done,a=yield n(u.value),!o;o=!0){const t=a;yield r(t)}}catch(l){i=!0,e=l}finally{try{o||null==f.return||(yield n(f.return()))}finally{if(i)throw e}}}))(),r.replaceStartWith=function(t,r){const e=new RegExp("^"+r);return t.replace(e,"")},r.tmpdir=a},function(t,r,e){"use strict";const n=e(17);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,r,e){t.exports=e(5)},function(t,r,e){"use strict";const n=e(0),o=e(13),i=e(2),u=e(3),s=e(1);r.Key=n,r.MemoryDatastore=o,r.utils=i,r.Errors=u,r.Adapter=s},function(t,r,e){"use strict";(function(t){var n=e(8),o=e(9),i=e(10);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,r){if(u()<r)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=a.prototype:(null===t&&(t=new a(r)),t.length=r),t}function a(t,r,e){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return h(this,t)}return f(this,t,r,e)}function f(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n);a.TYPED_ARRAY_SUPPORT?(t=r).__proto__=a.prototype:t=c(t,r);return t}(t,r,e,n):"string"==typeof r?function(t,r,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|y(r,e),o=(t=s(t,n)).write(r,e);o!==n&&(t=t.slice(0,o));return t}(t,r,e):function(t,r){if(a.isBuffer(r)){var e=0|p(r.length);return 0===(t=s(t,e)).length||r.copy(t,0,0,e),t}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(n=r.length)!=n?s(t,0):c(t,r);if("Buffer"===r.type&&i(r.data))return c(t,r.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function l(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 h(t,r){if(l(r),t=s(t,r<0?0:0|p(r)),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function c(t,r){var e=r.length<0?0:0|p(r.length);t=s(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function p(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function y(t,r){if(a.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 e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return F(t).length;default:if(n)return N(t).length;r=(""+r).toLowerCase(),n=!0}}function g(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,r,e);case"utf8":case"utf-8":return P(this,r,e);case"ascii":return T(this,r,e);case"latin1":case"binary":return x(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function w(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=a.from(r,n)),a.isBuffer(r))return 0===r.length?-1:v(t,r,e,n,o);if("number"==typeof r)return r&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):v(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,r,e,n,o){var i,u=1,s=t.length,a=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u=2,s/=2,a/=2,e/=2}function f(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(o){var l=-1;for(i=e;i<s;i++)if(f(t,i)===f(r,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===a)return l*u}else-1!==l&&(i-=i-l),l=-1}else for(e+a>s&&(e=s-a),i=e;i>=0;i--){for(var h=!0,c=0;c<a;c++)if(f(t,i+c)!==f(r,c)){h=!1;break}if(h)return i}return-1}function b(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n))>o&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u<n;++u){var s=parseInt(r.substr(2*u,2),16);if(isNaN(s))return u;t[e+u]=s}return u}function m(t,r,e,n){return z(N(r,t.length-e),t,e,n)}function E(t,r,e,n){return z(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function _(t,r,e,n){return E(t,r,e,n)}function A(t,r,e,n){return z(F(r),t,e,n)}function S(t,r,e,n){return z(function(t,r){for(var e,n,o,i=[],u=0;u<t.length&&!((r-=2)<0);++u)e=t.charCodeAt(u),n=e>>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function R(t,r,e){return 0===r&&e===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(r,e))}function P(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i,u,s,a,f=t[o],l=null,h=f>239?4:f>223?3:f>191?2:1;if(o+h<=e)switch(h){case 1:f<128&&(l=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(l=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&f)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(l=a)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=h}return function(t){var r=t.length;if(r<=4096)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return e}(n)}r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50,a.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(r){return!1}}(),r.kMaxLength=u(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,r,e){return f(null,t,r,e)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,r,e){return function(t,r,e,n){return l(r),r<=0?s(t,r):void 0!==e?"string"==typeof n?s(t,r).fill(e,n):s(t,r).fill(e):s(t,r)}(null,t,r,e)},a.allocUnsafe=function(t){return h(null,t)},a.allocUnsafeSlow=function(t){return h(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,r){if(!a.isBuffer(t)||!a.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);o<i;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return e<n?-1:n<e?1:0},a.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}},a.concat=function(t,r){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var n=a.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(n,o),o+=u.length}return n},a.byteLength=y,a.prototype._isBuffer=!0,a.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 r=0;r<t;r+=2)d(this,r,r+1);return this},a.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 r=0;r<t;r+=4)d(this,r,r+3),d(this,r+1,r+2);return this},a.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 r=0;r<t;r+=8)d(this,r,r+7),d(this,r+1,r+6),d(this,r+2,r+5),d(this,r+3,r+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?P(this,0,t):g.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,r,e,n,o){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(i,u),f=this.slice(n,o),l=t.slice(r,e),h=0;h<s;++h)if(f[h]!==l[h]){i=f[h],u=l[h];break}return i<u?-1:u<i?1:0},a.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},a.prototype.indexOf=function(t,r,e){return w(this,t,r,e,!0)},a.prototype.lastIndexOf=function(t,r,e){return w(this,t,r,e,!1)},a.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return m(this,t,r,e);case"ascii":return E(this,t,r,e);case"latin1":case"binary":return _(this,t,r,e);case"base64":return A(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(127&t[o]);return n}function x(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function B(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=j(t[i]);return o}function U(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function I(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function O(t,r,e,n,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function M(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function Y(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>8*(n?o:3-o)&255}function k(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function D(t,r,e,n,i){return i||k(t,0,e,4),o.write(t,r,e,n,23,4),e+4}function L(t,r,e,n,i){return i||k(t,0,e,8),o.write(t,r,e,n,52,8),e+8}a.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),a.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=a.prototype;else{var o=r-t;e=new a(o,void 0);for(var i=0;i<o;++i)e[i]=this[i+t]}return e},a.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},a.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},a.prototype.readUInt8=function(t,r){return r||I(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,r){return r||I(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,r){return r||I(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,r){return r||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,r){return r||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*r)),n},a.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||I(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},a.prototype.readInt8=function(t,r){return r||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,r){r||I(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},a.prototype.readInt16BE=function(t,r){r||I(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},a.prototype.readInt32LE=function(t,r){return r||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,r){return r||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,r){return r||I(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,r){return r||I(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,r){return r||I(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,r){return r||I(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||O(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=t/o&255;return r+e},a.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||O(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;--o>=0&&(i*=256);)this[r+o]=t/i&255;return r+e},a.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},a.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},a.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},a.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):Y(this,t,r,!0),r+4},a.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Y(this,t,r,!1),r+4},a.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);O(this,t,r,e,o-1,-o)}var i=0,u=1,s=0;for(this[r]=255&t;++i<e&&(u*=256);)t<0&&0===s&&0!==this[r+i-1]&&(s=1),this[r+i]=(t/u>>0)-s&255;return r+e},a.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);O(this,t,r,e,o-1,-o)}var i=e-1,u=1,s=0;for(this[r+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[r+i+1]&&(s=1),this[r+i]=(t/u>>0)-s&255;return r+e},a.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},a.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):M(this,t,r,!0),r+2},a.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):M(this,t,r,!1),r+2},a.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Y(this,t,r,!0),r+4},a.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||O(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Y(this,t,r,!1),r+4},a.prototype.writeFloatLE=function(t,r,e){return D(this,t,r,!0,e)},a.prototype.writeFloatBE=function(t,r,e){return D(this,t,r,!1,e)},a.prototype.writeDoubleLE=function(t,r,e){return L(this,t,r,!0,e)},a.prototype.writeDoubleBE=function(t,r,e){return L(this,t,r,!1,e)},a.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=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-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&e<r&&r<n)for(o=i-1;o>=0;--o)t[o+r]=this[o+e];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},a.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=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&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;var i;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i<e;++i)this[i]=t;else{var u=a.isBuffer(t)?t:N(new a(t,n).toString()),s=u.length;for(i=0;i<e-r;++i)this[i+r]=u[i%s]}return this};var C=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function N(t,r){var e;r=r||1/0;for(var n=t.length,o=null,i=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(C,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}}).call(this,e(7))},function(t,r,e){"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,r,e){"use strict";r.byteLength=function(t){var r=f(t),e=r[0],n=r[1];return 3*(e+n)/4-n},r.toByteArray=function(t){var r,e,n=f(t),u=n[0],s=n[1],a=new i(function(t,r,e){return 3*(r+e)/4-e}(0,u,s)),l=0,h=s>0?u-4:u;for(e=0;e<h;e+=4)r=o[t.charCodeAt(e)]<<18|o[t.charCodeAt(e+1)]<<12|o[t.charCodeAt(e+2)]<<6|o[t.charCodeAt(e+3)],a[l++]=r>>16&255,a[l++]=r>>8&255,a[l++]=255&r;2===s&&(r=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,a[l++]=255&r);1===s&&(r=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,a[l++]=r>>8&255,a[l++]=255&r);return a},r.fromByteArray=function(t){for(var r,e=t.length,o=e%3,i=[],u=0,s=e-o;u<s;u+=16383)i.push(l(t,u,u+16383>s?s:u+16383));1===o?(r=t[e-1],i.push(n[r>>2]+n[r<<4&63]+"==")):2===o&&(r=(t[e-2]<<8)+t[e-1],i.push(n[r>>10]+n[r>>4&63]+n[r<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s<a;++s)n[s]=u[s],o[u.charCodeAt(s)]=s;function f(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function l(t,r,e){for(var o,i,u=[],s=r;s<e;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),u.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,r,e){"use strict";r.read=function(t,r,e,n,o){var i,u,s=8*o-n-1,a=(1<<s)-1,f=a>>1,l=-7,h=e?o-1:0,c=e?-1:1,p=t[r+h];for(h+=c,i=p&(1<<-l)-1,p>>=-l,l+=s;l>0;i=256*i+t[r+h],h+=c,l-=8);for(u=i&(1<<-l)-1,i>>=-l,l+=n;l>0;u=256*u+t[r+h],h+=c,l-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,n),i-=f}return(p?-1:1)*u*Math.pow(2,i-n)},r.write=function(t,r,e,n,o,i){var u,s,a,f=8*i-o-1,l=(1<<f)-1,h=l>>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,u=l):(u=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-u))<1&&(u--,a*=2),(r+=u+h>=1?c/a:c*Math.pow(2,1-h))*a>=2&&(u++,a/=2),u+h>=l?(s=0,u=l):u+h>=1?(s=(r*a-1)*Math.pow(2,o),u+=h):(s=r*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[e+p]=255&s,p+=y,s/=256,o-=8);for(u=u<<o|s,f+=o;f>0;t[e+p]=255&u,p+=y,u/=256,f-=8);t[e+p-y]|=128*g}},function(t,r,e){"use strict";var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.random=r.urlAlphabet=r.customRandom=r.customAlphabet=r.nanoid=void 0;r.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";let n=t=>crypto.getRandomValues(new Uint8Array(t));r.random=n;let o=(t,r,e)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length);return()=>{let i="";for(;;){let u=e(o),s=o;for(;s--;)if(i+=t[u[s]&n]||"",i.length===+r)return i}}};r.customRandom=o;r.customAlphabet=(t,r)=>o(t,r,n);r.nanoid=(t=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&e[t];r+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return r}},function(t,r,e){"use strict";t.exports=function(t,{className:r,symbolName:e}){const n=Symbol.for(e),o={[r]:class extends t{constructor(...t){super(...t),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return r}}}[r];return o["is".concat(r)]=t=>!(!t||!t[n]),o},t.exports.proto=function(t,{className:r,symbolName:e,withoutNew:n}){const o=Symbol.for(e),i={[r]:function(...r){if(n&&!(this instanceof i))return new i(...r);const e=t.call(this,...r)||this;return e&&!e[o]&&Object.defineProperty(e,o,{value:!0}),e}}[r];return i.prototype=Object.create(t.prototype),i.prototype.constructor=i,Object.defineProperty(i.prototype,Symbol.toStringTag,{get:()=>r}),i["is".concat(r)]=t=>!(!t||!t[o]),i}},function(t,r,e){"use strict";const n=e(0),o=e(1),i=e(3);t.exports=class extends o{constructor(){super(),this.data={}}async put(t,r){this.data[t.toString()]=r}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,r])=>({key:new n(t),value:r}))}}},function(t,r,e){"use strict";const{nanoid:n}=e(15);t.exports=(t=(t=>t))=>t(n())},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.random=r.urlAlphabet=r.customRandom=r.customAlphabet=r.nanoid=void 0;r.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";let n=t=>crypto.getRandomValues(new Uint8Array(t));r.random=n;let o=(t,r,e)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length);return()=>{let i="";for(;;){let u=e(o),s=o;for(;s--;)if(i+=t[u[s]&n]||"",i.length===+r)return i}}};r.customRandom=o;r.customAlphabet=(t,r)=>o(t,r,n);r.nanoid=(t=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&e[t];r+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return r}},function(t,r,e){"use strict";t.exports=async t=>{var r,e=!0,n=!1;try{for(var o,i=function(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.call(t)}throw new TypeError("Object is not async iterable")}(t);e=(o=await i.next()).done,await o.value,!e;e=!0){}}catch(u){n=!0,r=u}finally{try{e||null==i.return||await i.return()}finally{if(n)throw r}}}},function(t,r,e){"use strict";t.exports=function(t,r,e){var n;if(!(t instanceof Error))throw new TypeError("Please pass an Error to err-code");if("object"==typeof r?e=r:null!=r&&(t.code=r),e)for(n in e)t[n]=e[n];return t}}])}));
{
"name": "interface-datastore",
"version": "1.0.1",
"version": "1.0.2",
"description": "datastore interface",

@@ -36,3 +36,3 @@ "leadMaintainer": "Alex Potsides <alex.potsides@protocol.ai>",

"devDependencies": {
"aegir": "^21.10.2",
"aegir": "^22.0.0",
"chai": "^4.1.2",

@@ -45,3 +45,3 @@ "dirty-chai": "^2.0.1"

"err-code": "^2.0.0",
"ipfs-utils": "^1.2.3",
"ipfs-utils": "^2.2.2",
"iso-random-stream": "^1.1.1",

@@ -57,4 +57,4 @@ "it-all": "^1.0.2",

"contributors": [
"achingbrain <alex@achingbrain.net>",
"David Dias <daviddias.p@gmail.com>",
"achingbrain <alex@achingbrain.net>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",

@@ -61,0 +61,0 @@ "Juan Batiz-Benet <juan@benet.ai>",

@@ -23,2 +23,3 @@ # interface-datastore <!-- omit in toc -->

- [Implementations](#implementations)
- [Adapter](#adapter)
- [Install](#install)

@@ -58,3 +59,3 @@ - [Usage](#usage)

- [`delete(key)`](#deletekey)
- [`commit([options])` -> `AsyncIterator<?>`](#commitoptions---asynciterator)
- [`commit([options])` -> `Promise<void>`](#commitoptions---promisevoid)
- [Arguments](#arguments-8)

@@ -93,2 +94,28 @@ - [Example](#example-9)

## Adapter
An adapter is made available to make implementing your own datastore easier:
```javascript
const { Adapter } = require('interface-datastore')
class MyDatastore extends Adapter {
constructor () {
super()
}
async put (key, val) {
// your implementation here
}
async get (key) {
// your implementation here
}
// etc...
}
```
See the [MemoryDatastore](./src/memory.js) for an example of how it is used.
## Install

@@ -391,3 +418,3 @@

#### `commit([options])` -> `AsyncIterator<?>`
#### `commit([options])` -> `Promise<void>`

@@ -411,9 +438,3 @@ Write all queued operations to the underyling store. The batch object should not be used after calling this.

for await (const res of batch.commit()) {
if (res.key) {
console.info('put', res.key)
} else {
console.info('del', res)
}
}
await batch.commit()
```

@@ -420,0 +441,0 @@

@@ -7,2 +7,3 @@ 'use strict'

const Errors = require('./errors')
const Adapter = require('./adapter')

@@ -13,1 +14,2 @@ exports.Key = Key

exports.Errors = Errors
exports.Adapter = Adapter
'use strict'
const { filter, sortAll, take, map } = require('./utils')
const Key = require('./key')
const Adapter = require('./adapter')

@@ -9,15 +9,9 @@ // Errors

function throwIfAborted (signal) {
if (signal && signal.aborted) {
throw Error.abortedError()
}
}
class MemoryDatastore extends Adapter {
constructor () {
super()
class MemoryDatastore {
constructor () {
this.data = {}
}
async open () {}
async put (key, val) { // eslint-disable-line require-await

@@ -27,12 +21,2 @@ this.data[key.toString()] = val

async * putMany (source, options = {}) {
throwIfAborted(options.signal)
for await (const { key, value } of source) {
throwIfAborted(options.signal)
await this.put(key, value)
yield { key, value }
}
}
async get (key) {

@@ -44,11 +28,2 @@ const exists = await this.has(key)

async * getMany (source, options = {}) {
throwIfAborted(options.signal)
for await (const key of source) {
throwIfAborted(options.signal)
yield this.get(key)
}
}
async has (key) { // eslint-disable-line require-await

@@ -62,70 +37,8 @@ return this.data[key.toString()] !== undefined

async * deleteMany (source, options = {}) {
throwIfAborted(options.signal)
for await (const key of source) {
throwIfAborted(options.signal)
await this.delete(key)
yield key
}
* _all () {
yield * Object.entries(this.data)
.map(([key, value]) => ({ key: new Key(key), value }))
}
batch () {
let puts = []
let dels = []
const self = this
return {
put (key, value) {
puts.push({ key, value })
},
delete (key) {
dels.push(key)
},
async * commit (options) { // eslint-disable-line require-await
yield * self.putMany(puts, options)
puts = []
yield * self.deleteMany(dels, options)
dels = []
}
}
}
query (q) {
let it = Object.entries(this.data)
it = map(it, entry => ({ key: new Key(entry[0]), value: entry[1] }))
if (q.prefix != null) {
it = filter(it, e => e.key.toString().startsWith(q.prefix))
}
if (Array.isArray(q.filters)) {
it = q.filters.reduce((it, f) => filter(it, f), it)
}
if (Array.isArray(q.orders)) {
it = q.orders.reduce((it, f) => sortAll(it, f), it)
}
if (q.offset != null) {
let i = 0
it = filter(it, () => i++ >= q.offset)
}
if (q.limit != null) {
it = take(it, q.limit)
}
if (q.keysOnly === true) {
it = map(it, e => ({ key: e.key }))
}
return it
}
async close () {}
}
module.exports = MemoryDatastore

@@ -235,3 +235,3 @@ /* eslint-env mocha */

b.delete(new Key('/z/old'))
await drain(b.commit())
await b.commit()

@@ -254,3 +254,3 @@ const keys = ['/a/one', '/q/two', '/q/three', '/z/old']

await drain(b.commit())
await b.commit()

@@ -321,3 +321,3 @@ const total = async iterable => {

return drain(b.commit())
return b.commit()
})

@@ -324,0 +324,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc