w-orm-lmdb 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,10 +12,12 @@ An operator for lmdb in nodejs.
12
12
  To view documentation or get support, visit [docs](https://yuda-lyu.github.io/w-orm-lmdb/WOrm.html).
13
13
 
14
14
  ## Installation
15
+
15
16
  ### Using npm(ES6 module):
16
17
  ```alias
17
18
  npm i w-orm-lmdb
18
19
  ```
20
+
19
21
  #### Example for collection
20
22
  > **Link:** [[dev source code](https://github.com/yuda-lyu/w-orm-lmdb/blob/master/g-basic.mjs)]
21
23
  ```alias
@@ -65,6 +67,14 @@ let rsm = [
65
67
  },
66
68
  ]
67
69
 
70
+ let rsa = [
71
+ {
72
+ id: 'id-rosemary',
73
+ name: 'rosemary',
74
+ value: 654.321,
75
+ },
76
+ ]
77
+
68
78
  async function test() {
69
79
 
70
80
  //wo
@@ -128,6 +138,15 @@ async function test() {
128
138
  // let sr = await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
129
139
  // console.log('selectReg', sr)
130
140
 
141
+ //save
142
+ await wo.save(rsa, { autoInsert: true })
143
+ .then(function(msg) {
144
+ console.log('save then', msg)
145
+ })
146
+ .catch(function(msg) {
147
+ console.log('save catch', msg)
148
+ })
149
+
131
150
  //del
132
151
  let d = ss.filter(function(v) {
133
152
  return v.name === 'kettle'
@@ -182,6 +201,8 @@ test()
182
201
  // value: 123.456
183
202
  // }
184
203
  // ]
204
+ // change save
205
+ // save then [ { n: 1, nModified: 1, ok: 1 } ]
185
206
  // change del
186
207
  // del then [ { n: 1, nDeleted: 1, ok: 1 } ]
187
208
  ```
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * req-mingo v1.0.3
2
+ * req-mingo v1.0.5
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
6
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("mingo")):"function"==typeof define&&define.amd?define(["mingo"],o):(e="undefined"!=typeof globalThis?globalThis:e||self)["req-mingo"]=o(e.mingo)}(this,(function(e){"use strict";function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}return o(e)}));
6
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("mingo")):"function"==typeof define&&define.amd?define(["mingo"],o):(e="undefined"!=typeof globalThis?globalThis:e||self)["req-mingo"]=o(e.mingo)}(this,function(e){"use strict";function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}return o(e)});
7
7
  //# sourceMappingURL=req-mingo.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"req-mingo.umd.js","sources":["../src/reqMingo.js"],"sourcesContent":null,"names":["require$$0"],"mappings":";;;;;4XAAYA"}
1
+ {"version":3,"file":"req-mingo.umd.js","sources":["../src/reqMingo.js"],"sourcesContent":null,"names":["require$$0"],"mappings":";;;;;2XAAYA"}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * w-orm-lmdb v1.0.3
2
+ * w-orm-lmdb v1.0.5
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lmdb"),require("mingo")):"function"==typeof define&&define.amd?define(["lmdb","mingo"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-lmdb"]=e(t.lmdb,t.mingo)}(this,(function(t,e){"use strict";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n=r(e),o=Object.prototype;function u(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||o)}function i(t,e){return function(r){return t(e(r))}}var c=i(Object.keys,Object),a=Object.prototype.hasOwnProperty;function f(t){if(!u(t))return c(t);var e=[];for(var r in Object(t))a.call(t,r)&&"constructor"!=r&&e.push(r);return e}var l="object"==typeof global&&global&&global.Object===Object&&global,s="object"==typeof self&&self&&self.Object===Object&&self,p=l||s||Function("return this")(),v=p.Symbol,b=Object.prototype,y=b.hasOwnProperty,h=b.toString,d=v?v.toStringTag:void 0;var j=Object.prototype.toString;var g=v?v.toStringTag:void 0;function _(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=y.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return j.call(t)}(t)}function w(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function m(t){if(!w(t))return!1;var e=_(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var O,A=p["__core-js_shared__"],x=(O=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"";var S=Function.prototype.toString;function P(t){if(null!=t){try{return S.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var k=/^\[object .+?Constructor\]$/,z=Function.prototype,E=Object.prototype,I=z.toString,$=E.hasOwnProperty,F=RegExp("^"+I.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U(t){return!(!w(t)||(e=t,x&&x in e))&&(m(t)?F:k).test(P(t));var e}function M(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return U(r)?r:void 0}var D=M(p,"DataView"),N=M(p,"Map"),T=M(p,"Promise"),C=M(p,"Set"),L=M(p,"WeakMap"),R="[object Map]",B="[object Promise]",q="[object Set]",V="[object WeakMap]",W="[object DataView]",G=P(D),Q=P(N),J=P(T),H=P(C),K=P(L),X=_;(D&&X(new D(new ArrayBuffer(1)))!=W||N&&X(new N)!=R||T&&X(T.resolve())!=B||C&&X(new C)!=q||L&&X(new L)!=V)&&(X=function(t){var e=_(t),r="[object Object]"==e?t.constructor:void 0,n=r?P(r):"";if(n)switch(n){case G:return W;case Q:return R;case J:return B;case H:return q;case K:return V}return e});var Y=X;function Z(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function tt(t){return null!=t&&Z(t.length)&&!m(t)}var et=Array.isArray;function rt(t){return null!=t&&"object"==typeof t}function nt(t){return function(e){return null==e?void 0:e[t]}}var ot=nt("length"),ut=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var it="\\ud800-\\udfff",ct="["+it+"]",at="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",ft="\\ud83c[\\udffb-\\udfff]",lt="[^"+it+"]",st="(?:\\ud83c[\\udde6-\\uddff]){2}",pt="[\\ud800-\\udbff][\\udc00-\\udfff]",vt="(?:"+at+"|"+ft+")"+"?",bt="[\\ufe0e\\ufe0f]?",yt=bt+vt+("(?:\\u200d(?:"+[lt,st,pt].join("|")+")"+bt+vt+")*"),ht="(?:"+[lt+at+"?",at,st,pt,ct].join("|")+")",dt=RegExp(ft+"(?="+ft+")|"+ht+yt,"g");function jt(t){return function(t){return ut.test(t)}(t)?function(t){for(var e=dt.lastIndex=0;dt.test(t);)++e;return e}(t):ot(t)}function gt(t){if(null==t)return 0;if(tt(t))return"string"==typeof(e=t)||!et(e)&&rt(e)&&"[object String]"==_(e)?jt(t):t.length;var e,r=Y(t);return"[object Map]"==r||"[object Set]"==r?t.size:f(t).length}function _t(t){return"symbol"==typeof t||rt(t)&&"[object Symbol]"==_(t)}var wt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,mt=/^\w*$/;function Ot(t,e){if(et(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!_t(t))||(mt.test(t)||!wt.test(t)||null!=e&&t in Object(e))}var At=M(Object,"create");var xt=Object.prototype.hasOwnProperty;var St=Object.prototype.hasOwnProperty;function Pt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function kt(t,e){return t===e||t!=t&&e!=e}function zt(t,e){for(var r=t.length;r--;)if(kt(t[r][0],e))return r;return-1}Pt.prototype.clear=function(){this.__data__=At?At(null):{},this.size=0},Pt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Pt.prototype.get=function(t){var e=this.__data__;if(At){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return xt.call(e,t)?e[t]:void 0},Pt.prototype.has=function(t){var e=this.__data__;return At?void 0!==e[t]:St.call(e,t)},Pt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=At&&void 0===e?"__lodash_hash_undefined__":e,this};var Et=Array.prototype.splice;function It(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function $t(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Ft(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}It.prototype.clear=function(){this.__data__=[],this.size=0},It.prototype.delete=function(t){var e=this.__data__,r=zt(e,t);return!(r<0)&&(r==e.length-1?e.pop():Et.call(e,r,1),--this.size,!0)},It.prototype.get=function(t){var e=this.__data__,r=zt(e,t);return r<0?void 0:e[r][1]},It.prototype.has=function(t){return zt(this.__data__,t)>-1},It.prototype.set=function(t,e){var r=this.__data__,n=zt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Ft.prototype.clear=function(){this.size=0,this.__data__={hash:new Pt,map:new(N||It),string:new Pt}},Ft.prototype.delete=function(t){var e=$t(this,t).delete(t);return this.size-=e?1:0,e},Ft.prototype.get=function(t){return $t(this,t).get(t)},Ft.prototype.has=function(t){return $t(this,t).has(t)},Ft.prototype.set=function(t,e){var r=$t(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Ut(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],u=r.cache;if(u.has(o))return u.get(o);var i=t.apply(this,n);return r.cache=u.set(o,i)||u,i};return r.cache=new(Ut.Cache||Ft),r}Ut.Cache=Ft;var Mt,Dt,Nt,Tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ct=/\\(\\)?/g,Lt=(Mt=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Tt,(function(t,r,n,o){e.push(n?o.replace(Ct,"$1"):r||t)})),e},Dt=Ut(Mt,(function(t){return 500===Nt.size&&Nt.clear(),t})),Nt=Dt.cache,Dt),Rt=Lt;function Bt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var qt=v?v.prototype:void 0,Vt=qt?qt.toString:void 0;function Wt(t){if("string"==typeof t)return t;if(et(t))return Bt(t,Wt)+"";if(_t(t))return Vt?Vt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Gt(t){return null==t?"":Wt(t)}function Qt(t,e){return et(t)?t:Ot(t,e)?[t]:Rt(Gt(t))}function Jt(t){if("string"==typeof t||_t(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Ht(t,e){for(var r=0,n=(e=Qt(e,t)).length;null!=t&&r<n;)t=t[Jt(e[r++])];return r&&r==n?t:void 0}function Kt(t,e,r){var n=null==t?void 0:Ht(t,e);return void 0===n?r:n}function Xt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var Yt,Zt=function(t,e,r){for(var n=-1,o=Object(t),u=r(t),i=u.length;i--;){var c=u[Yt?i:++n];if(!1===e(o[c],c,o))break}return t};function te(t){return rt(t)&&"[object Arguments]"==_(t)}var ee=Object.prototype,re=ee.hasOwnProperty,ne=ee.propertyIsEnumerable,oe=te(function(){return arguments}())?te:function(t){return rt(t)&&re.call(t,"callee")&&!ne.call(t,"callee")},ue=oe;var ie="object"==typeof exports&&exports&&!exports.nodeType&&exports,ce=ie&&"object"==typeof module&&module&&!module.nodeType&&module,ae=ce&&ce.exports===ie?p.Buffer:void 0,fe=(ae?ae.isBuffer:void 0)||function(){return!1},le=/^(?:0|[1-9]\d*)$/;function se(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&le.test(t))&&t>-1&&t%1==0&&t<e}var pe={};function ve(t){return function(e){return t(e)}}pe["[object Float32Array]"]=pe["[object Float64Array]"]=pe["[object Int8Array]"]=pe["[object Int16Array]"]=pe["[object Int32Array]"]=pe["[object Uint8Array]"]=pe["[object Uint8ClampedArray]"]=pe["[object Uint16Array]"]=pe["[object Uint32Array]"]=!0,pe["[object Arguments]"]=pe["[object Array]"]=pe["[object ArrayBuffer]"]=pe["[object Boolean]"]=pe["[object DataView]"]=pe["[object Date]"]=pe["[object Error]"]=pe["[object Function]"]=pe["[object Map]"]=pe["[object Number]"]=pe["[object Object]"]=pe["[object RegExp]"]=pe["[object Set]"]=pe["[object String]"]=pe["[object WeakMap]"]=!1;var be="object"==typeof exports&&exports&&!exports.nodeType&&exports,ye=be&&"object"==typeof module&&module&&!module.nodeType&&module,he=ye&&ye.exports===be&&l.process,de=function(){try{var t=ye&&ye.require&&ye.require("util").types;return t||he&&he.binding&&he.binding("util")}catch(t){}}(),je=de&&de.isTypedArray,ge=je?ve(je):function(t){return rt(t)&&Z(t.length)&&!!pe[_(t)]},_e=Object.prototype.hasOwnProperty;function we(t,e){var r=et(t),n=!r&&ue(t),o=!r&&!n&&fe(t),u=!r&&!n&&!o&&ge(t),i=r||n||o||u,c=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=c.length;for(var f in t)!e&&!_e.call(t,f)||i&&("length"==f||o&&("offset"==f||"parent"==f)||u&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||se(f,a))||c.push(f);return c}function me(t){return tt(t)?we(t):f(t)}var Oe=function(t,e){return function(r,n){if(null==r)return r;if(!tt(r))return t(r,n);for(var o=r.length,u=e?o:-1,i=Object(r);(e?u--:++u<o)&&!1!==n(i[u],u,i););return r}}((function(t,e){return t&&Zt(t,e,me)})),Ae=Oe;function xe(t){return t}function Se(t,e){var r;return(et(t)?Xt:Ae)(t,"function"==typeof(r=e)?r:xe)}function Pe(t){var e=this.__data__=new It(t);this.size=e.size}Pe.prototype.clear=function(){this.__data__=new It,this.size=0},Pe.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Pe.prototype.get=function(t){return this.__data__.get(t)},Pe.prototype.has=function(t){return this.__data__.has(t)},Pe.prototype.set=function(t,e){var r=this.__data__;if(r instanceof It){var n=r.__data__;if(!N||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ft(n)}return r.set(t,e),this.size=r.size,this};function ke(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Ft;++e<r;)this.add(t[e])}function ze(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Ee(t,e){return t.has(e)}ke.prototype.add=ke.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ke.prototype.has=function(t){return this.__data__.has(t)};function Ie(t,e,r,n,o,u){var i=1&r,c=t.length,a=e.length;if(c!=a&&!(i&&a>c))return!1;var f=u.get(t),l=u.get(e);if(f&&l)return f==e&&l==t;var s=-1,p=!0,v=2&r?new ke:void 0;for(u.set(t,e),u.set(e,t);++s<c;){var b=t[s],y=e[s];if(n)var h=i?n(y,b,s,e,t,u):n(b,y,s,t,e,u);if(void 0!==h){if(h)continue;p=!1;break}if(v){if(!ze(e,(function(t,e){if(!Ee(v,e)&&(b===t||o(b,t,r,n,u)))return v.push(e)}))){p=!1;break}}else if(b!==y&&!o(b,y,r,n,u)){p=!1;break}}return u.delete(t),u.delete(e),p}var $e=p.Uint8Array;function Fe(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function Ue(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Me=v?v.prototype:void 0,De=Me?Me.valueOf:void 0;function Ne(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function Te(t,e,r){var n=e(t);return et(t)?n:Ne(n,r(t))}function Ce(){return[]}var Le=Object.prototype.propertyIsEnumerable,Re=Object.getOwnPropertySymbols,Be=Re?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,u=[];++r<n;){var i=t[r];e(i,r,t)&&(u[o++]=i)}return u}(Re(t),(function(e){return Le.call(t,e)})))}:Ce,qe=Be;function Ve(t){return Te(t,me,qe)}var We=Object.prototype.hasOwnProperty;var Ge="[object Arguments]",Qe="[object Array]",Je="[object Object]",He=Object.prototype.hasOwnProperty;function Ke(t,e,r,n,o,u){var i=et(t),c=et(e),a=i?Qe:Y(t),f=c?Qe:Y(e),l=(a=a==Ge?Je:a)==Je,s=(f=f==Ge?Je:f)==Je,p=a==f;if(p&&fe(t)){if(!fe(e))return!1;i=!0,l=!1}if(p&&!l)return u||(u=new Pe),i||ge(t)?Ie(t,e,r,n,o,u):function(t,e,r,n,o,u,i){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!u(new $e(t),new $e(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return kt(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var c=Fe;case"[object Set]":var a=1&n;if(c||(c=Ue),t.size!=e.size&&!a)return!1;var f=i.get(t);if(f)return f==e;n|=2,i.set(t,e);var l=Ie(c(t),c(e),n,o,u,i);return i.delete(t),l;case"[object Symbol]":if(De)return De.call(t)==De.call(e)}return!1}(t,e,a,r,n,o,u);if(!(1&r)){var v=l&&He.call(t,"__wrapped__"),b=s&&He.call(e,"__wrapped__");if(v||b){var y=v?t.value():t,h=b?e.value():e;return u||(u=new Pe),o(y,h,r,n,u)}}return!!p&&(u||(u=new Pe),function(t,e,r,n,o,u){var i=1&r,c=Ve(t),a=c.length;if(a!=Ve(e).length&&!i)return!1;for(var f=a;f--;){var l=c[f];if(!(i?l in e:We.call(e,l)))return!1}var s=u.get(t),p=u.get(e);if(s&&p)return s==e&&p==t;var v=!0;u.set(t,e),u.set(e,t);for(var b=i;++f<a;){var y=t[l=c[f]],h=e[l];if(n)var d=i?n(h,y,l,e,t,u):n(y,h,l,t,e,u);if(!(void 0===d?y===h||o(y,h,r,n,u):d)){v=!1;break}b||(b="constructor"==l)}if(v&&!b){var j=t.constructor,g=e.constructor;j==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof j&&j instanceof j&&"function"==typeof g&&g instanceof g||(v=!1)}return u.delete(t),u.delete(e),v}(t,e,r,n,o,u))}function Xe(t,e,r,n,o){return t===e||(null==t||null==e||!rt(t)&&!rt(e)?t!=t&&e!=e:Ke(t,e,r,n,Xe,o))}function Ye(t){return t==t&&!w(t)}function Ze(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function tr(t){var e=function(t){for(var e=me(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,Ye(o)]}return e}(t);return 1==e.length&&e[0][2]?Ze(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,u=o,i=!n;if(null==t)return!u;for(t=Object(t);o--;){var c=r[o];if(i&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<u;){var a=(c=r[o])[0],f=t[a],l=c[1];if(i&&c[2]){if(void 0===f&&!(a in t))return!1}else{var s=new Pe;if(n)var p=n(f,l,a,t,e,s);if(!(void 0===p?Xe(l,f,3,n,s):p))return!1}}return!0}(r,t,e)}}function er(t,e){return null!=t&&e in Object(t)}function rr(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=Qt(e,t)).length,u=!1;++n<o;){var i=Jt(e[n]);if(!(u=null!=t&&r(t,i)))break;t=t[i]}return u||++n!=o?u:!!(o=null==t?0:t.length)&&Z(o)&&se(i,o)&&(et(t)||ue(t))}(t,e,er)}function nr(t){return Ot(t)?nt(Jt(t)):function(t){return function(e){return Ht(e,t)}}(t)}function or(t){return"function"==typeof t?t:null==t?xe:"object"==typeof t?et(t)?(e=t[0],r=t[1],Ot(e)&&Ye(r)?Ze(Jt(e),r):function(t){var n=Kt(t,e);return void 0===n&&n===r?rr(t,e):Xe(r,n,3)}):tr(t):nr(t);var e,r}function ur(t,e){var r=-1,n=tt(t)?Array(t.length):[];return Ae(t,(function(t,o,u){n[++r]=e(t,o,u)})),n}function ir(t,e){return(et(t)?Bt:ur)(t,or(e))}var cr=function(){try{var t=M(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),ar=cr;function fr(t,e,r){"__proto__"==e&&ar?ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function lr(t,e,r){(void 0!==r&&!kt(t[e],r)||void 0===r&&!(e in t))&&fr(t,e,r)}var sr="object"==typeof exports&&exports&&!exports.nodeType&&exports,pr=sr&&"object"==typeof module&&module&&!module.nodeType&&module,vr=pr&&pr.exports===sr?p.Buffer:void 0,br=vr?vr.allocUnsafe:void 0;function yr(t,e){if(e)return t.slice();var r=t.length,n=br?br(r):new t.constructor(r);return t.copy(n),n}function hr(t){var e=new t.constructor(t.byteLength);return new $e(e).set(new $e(t)),e}function dr(t,e){var r=e?hr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function jr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var gr=Object.create,_r=function(){function t(){}return function(e){if(!w(e))return{};if(gr)return gr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),wr=_r,mr=i(Object.getPrototypeOf,Object);function Or(t){return"function"!=typeof t.constructor||u(t)?{}:wr(mr(t))}var Ar=Function.prototype,xr=Object.prototype,Sr=Ar.toString,Pr=xr.hasOwnProperty,kr=Sr.call(Object);function zr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Er=Object.prototype.hasOwnProperty;function Ir(t,e,r){var n=t[e];Er.call(t,e)&&kt(n,r)&&(void 0!==r||e in t)||fr(t,e,r)}function $r(t,e,r,n){var o=!r;r||(r={});for(var u=-1,i=e.length;++u<i;){var c=e[u],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?fr(r,c,a):Ir(r,c,a)}return r}var Fr=Object.prototype.hasOwnProperty;function Ur(t){if(!w(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=u(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Mr(t){return tt(t)?we(t,!0):Ur(t)}function Dr(t,e,r,n,o,u,i){var c=zr(t,r),a=zr(e,r),f=i.get(a);if(f)lr(t,r,f);else{var l,s=u?u(c,a,r+"",t,e,i):void 0,p=void 0===s;if(p){var v=et(a),b=!v&&fe(a),y=!v&&!b&&ge(a);s=a,v||b||y?et(c)?s=c:rt(l=c)&&tt(l)?s=jr(c):b?(p=!1,s=yr(a,!0)):y?(p=!1,s=dr(a,!0)):s=[]:function(t){if(!rt(t)||"[object Object]"!=_(t))return!1;var e=mr(t);if(null===e)return!0;var r=Pr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Sr.call(r)==kr}(a)||ue(a)?(s=c,ue(c)?s=function(t){return $r(t,Mr(t))}(c):w(c)&&!m(c)||(s=Or(a))):p=!1}p&&(i.set(a,s),o(s,a,n,u,i),i.delete(a)),lr(t,r,s)}}function Nr(t,e,r,n,o){t!==e&&Zt(e,(function(u,i){if(o||(o=new Pe),w(u))Dr(t,e,i,r,Nr,n,o);else{var c=n?n(zr(t,i),u,i+"",t,e,o):void 0;void 0===c&&(c=u),lr(t,i,c)}}),Mr)}var Tr=Math.max;var Cr=ar?function(t,e){return ar(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:xe,Lr=Cr,Rr=Date.now;var Br=function(t){var e=0,r=0;return function(){var n=Rr(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Lr),qr=Br;function Vr(t,e){return qr(function(t,e,r){return e=Tr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,u=Tr(n.length-e,0),i=Array(u);++o<u;)i[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(i),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}(t,e,xe),t+"")}var Wr,Gr=(Wr=function(t,e,r){Nr(t,e,r)},Vr((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,u=n>2?e[2]:void 0;for(o=Wr.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,e,r){if(!w(r))return!1;var n=typeof e;return!!("number"==n?tt(r)&&se(e,r.length):"string"==n&&e in r)&&kt(r[e],t)}(e[0],e[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var i=e[r];i&&Wr(t,i,r,o)}return t})));var Qr=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Ne(e,qe(t)),t=mr(t);return e}:Ce,Jr=Qr;function Hr(t){return Te(t,Mr,Jr)}var Kr=Object.prototype.hasOwnProperty;var Xr=/\w*$/;var Yr=v?v.prototype:void 0,Zr=Yr?Yr.valueOf:void 0;function tn(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return hr(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?hr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return dr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Xr.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Zr?Object(Zr.call(n)):{}}}var en=de&&de.isMap,rn=en?ve(en):function(t){return rt(t)&&"[object Map]"==Y(t)};var nn=de&&de.isSet,on=nn?ve(nn):function(t){return rt(t)&&"[object Set]"==Y(t)},un="[object Arguments]",cn="[object Function]",an="[object Object]",fn={};function ln(t,e,r,n,o,u){var i,c=1&e,a=2&e,f=4&e;if(r&&(i=o?r(t,n,o,u):r(t)),void 0!==i)return i;if(!w(t))return t;var l=et(t);if(l){if(i=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Kr.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return jr(t,i)}else{var s=Y(t),p=s==cn||"[object GeneratorFunction]"==s;if(fe(t))return yr(t,c);if(s==an||s==un||p&&!o){if(i=a||p?{}:Or(t),!c)return a?function(t,e){return $r(t,Jr(t),e)}(t,function(t,e){return t&&$r(e,Mr(e),t)}(i,t)):function(t,e){return $r(t,qe(t),e)}(t,function(t,e){return t&&$r(e,me(e),t)}(i,t))}else{if(!fn[s])return o?t:{};i=tn(t,s,c)}}u||(u=new Pe);var v=u.get(t);if(v)return v;u.set(t,i),on(t)?t.forEach((function(n){i.add(ln(n,e,r,n,t,u))})):rn(t)&&t.forEach((function(n,o){i.set(o,ln(n,e,r,o,t,u))}));var b=l?void 0:(f?a?Hr:Ve:a?Mr:me)(t);return Xt(b||t,(function(n,o){b&&(n=t[o=n]),Ir(i,o,ln(n,e,r,o,t,u))})),i}fn[un]=fn["[object Array]"]=fn["[object ArrayBuffer]"]=fn["[object DataView]"]=fn["[object Boolean]"]=fn["[object Date]"]=fn["[object Float32Array]"]=fn["[object Float64Array]"]=fn["[object Int8Array]"]=fn["[object Int16Array]"]=fn["[object Int32Array]"]=fn["[object Map]"]=fn["[object Number]"]=fn[an]=fn["[object RegExp]"]=fn["[object Set]"]=fn["[object String]"]=fn["[object Symbol]"]=fn["[object Uint8Array]"]=fn["[object Uint8ClampedArray]"]=fn["[object Uint16Array]"]=fn["[object Uint32Array]"]=!0,fn["[object Error]"]=fn[cn]=fn["[object WeakMap]"]=!1;function sn(t){return ln(t,5)}function pn(t){return"[object String]"===Object.prototype.toString.call(t)}function vn(t){return!(!pn(t)||""===t)}function bn(t){return"[object Array]"===Object.prototype.toString.call(t)}function yn(t){return"[object Object]"===Object.prototype.toString.call(t)}function hn(t){return t!=t}function dn(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(yn(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!pn(t)||""!==t)}(t)||(!!function(t){return!!bn(t)&&0===t.length}(t)||!!hn(t)))))}function jn(t){return!!bn(t)&&(0!==t.length&&(1!==t.length||!dn(t[0])))}function gn(t){if(yn(t)){for(let e in t)return!0;return!1}return!1}function _n(t){let e=!1;if(vn(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(hn(t))return!1;e=!0}return e}var wn={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function u(t,e,n,u,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var c=new o(n,u||t,i),a=r?r+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),c.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},c.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,u=n.length,i=new Array(u);o<u;o++)i[o]=n[o].fn;return i},c.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},c.prototype.emit=function(t,e,n,o,u,i){var c=r?r+t:t;if(!this._events[c])return!1;var a,f,l=this._events[c],s=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),s){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,u),!0;case 6:return l.fn.call(l.context,e,n,o,u,i),!0}for(f=1,a=new Array(s-1);f<s;f++)a[f-1]=arguments[f];l.fn.apply(l.context,a)}else{var p,v=l.length;for(f=0;f<v;f++)switch(l[f].once&&this.removeListener(t,l[f].fn,void 0,!0),s){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,e);break;case 3:l[f].fn.call(l[f].context,e,n);break;case 4:l[f].fn.call(l[f].context,e,n,o);break;default:if(!a)for(p=1,a=new Array(s-1);p<s;p++)a[p-1]=arguments[p];l[f].fn.apply(l[f].context,a)}}return!0},c.prototype.on=function(t,e,r){return u(this,t,e,r,!1)},c.prototype.once=function(t,e,r){return u(this,t,e,r,!0)},c.prototype.removeListener=function(t,e,n,o){var u=r?r+t:t;if(!this._events[u])return this;if(!e)return i(this,u),this;var c=this._events[u];if(c.fn)c.fn!==e||o&&!c.once||n&&c.context!==n||i(this,u);else{for(var a=0,f=[],l=c.length;a<l;a++)(c[a].fn!==e||o&&!c[a].once||n&&c[a].context!==n)&&f.push(c[a]);f.length?this._events[u]=1===f.length?f[0]:f:i(this,u)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&i(this,e)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t.exports=c}(wn);var mn=r(wn.exports);const On=[];for(let t=0;t<256;++t)On.push((t+256).toString(16).slice(1));let An;const xn=new Uint8Array(16);function Sn(){if(!An){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");An=crypto.getRandomValues.bind(crypto)}return An(xn)}const Pn={};function kn(t,e,r){let n;if(t)n=zn(t.random??t.rng?.()??Sn(),t.msecs,t.seq,e,r);else{const t=Date.now(),o=Sn();!function(t,e,r){t.msecs??=-1/0,t.seq??=0,e>t.msecs?(t.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],t.msecs=e):(t.seq=t.seq+1|0,0===t.seq&&t.msecs++)}(Pn,t,o),n=zn(o,Pn.msecs,Pn.seq,e,r)}return e??function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(On[t[e+0]]+On[t[e+1]]+On[t[e+2]]+On[t[e+3]]+"-"+On[t[e+4]]+On[t[e+5]]+"-"+On[t[e+6]]+On[t[e+7]]+"-"+On[t[e+8]]+On[t[e+9]]+"-"+On[t[e+10]]+On[t[e+11]]+On[t[e+12]]+On[t[e+13]]+On[t[e+14]]+On[t[e+15]]).toLowerCase()}(n)}function zn(t,e,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(t.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(o<0||o+16>n.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else n=new Uint8Array(16),o=0;return e??=Date.now(),r??=127*t[6]<<24|t[7]<<16|t[8]<<8|t[9],n[o++]=e/1099511627776&255,n[o++]=e/4294967296&255,n[o++]=e/16777216&255,n[o++]=e/65536&255,n[o++]=e/256&255,n[o++]=255&e,n[o++]=112|r>>>28&15,n[o++]=r>>>20&255,n[o++]=128|r>>>14&63,n[o++]=r>>>6&255,n[o++]=r<<2&255|3&t[10],n[o++]=t[11],n[o++]=t[12],n[o++]=t[13],n[o++]=t[14],n[o++]=t[15],n}function En(){return kn()}var In=/\s/;var $n=/^\s+/;function Fn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&In.test(t.charAt(e)););return e}(t)+1).replace($n,""):t}var Un=/^[-+]0x[0-9a-f]+$/i,Mn=/^0b[01]+$/i,Dn=/^0o[0-7]+$/i,Nn=parseInt;function Tn(t){if("number"==typeof t)return t;if(_t(t))return NaN;if(w(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=w(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Fn(t);var r=Mn.test(t);return r||Dn.test(t)?Nn(t.slice(2),r?2:8):Un.test(t)?NaN:+t}var Cn=1/0;function Ln(t){return t?(t=Tn(t))===Cn||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function Rn(t){var e=Ln(t),r=e%1;return e==e?r?e-r:e:0}function Bn(t,e,r){var n=null==t?0:t.length;return n?function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var u=Array(o);++n<o;)u[n]=t[n+e];return u}(t,(e=r||void 0===e?1:Rn(e))<0?0:e,n):[]}function qn(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}function Vn(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function Wn(t,e){let r=qn();if(!bn(t)&&!yn(t))return r.reject("rs is not an array or object"),r;let n=!1;if(yn(t)){n=!0;let e=[];Se(t,((t,r)=>{e.push({k:r,v:t})})),t=e}Vn(e)||(e=function(t){return t});let o=-1,u=[];return t.reduce((function(t,r){return t.then((function(t){u.push(t),o+=1;let i=o,c=r;return n&&(i=r.k,c=r.v),Vn(e)?e(c,i):c}))}),Promise.resolve()).then((function(t){u.push(t),u=Bn(u),r.resolve(u)})).catch((function(t){r.reject(t)})),r}function Gn(t){if(!_n(t))return 0;return Ln(t)}function Qn(t){return!!_n(t)&&(t=Gn(t),"number"==typeof(e=t)&&e==Rn(e));var e}var Jn=p.isFinite,Hn=Math.min;var Kn=function(t){var e=Math[t];return function(t,r){if(t=Tn(t),(r=null==r?0:Hn(Rn(r),292))&&Jn(t)){var n=(Gt(t)+"e").split("e");return+((n=(Gt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Xn=Kn;function Yn(t){if(!Qn(t))return!1;let e=function(t){if(!_n(t))return 0;t=Gn(t);let e=Xn(t);return"0"===String(e)?0:e}(t)>0;return e}async function Zn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,n=qn();if(!Vn(t))return n.reject("waitfunction需輸入函數f"),n;let o=async()=>{let e=t();return function(t){let e,r=Object.prototype.toString.call(t);if(e="[object Promise]"===r,e)return!0;if("[object Function]"!==r)return!1;try{e="function"!=typeof t.subscribe&&"function"==typeof t.then}catch(t){}return e}(e)&&(e=await e),e};if(r=await o(),!0===r)return n.resolve(),n;let u=Kt(e,"attemptNum",null);Yn(u)||(u=200);let i=Kt(e,"timeInterval",null);Yn(i)||(i=1e3);let c=0,a=setInterval((async()=>{c+=1,r=await o(),!0===r&&(clearInterval(a),n.resolve()),c>u&&(clearInterval(a),n.reject(`exceeded attemptNum[${u}]`))}),i);return n}return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=Kt(e,"url");vn(r)||(r="./_db");let o=Kt(e,"db");vn(o)||(o="worm");let u=Kt(e,"cl");vn(u)||(u="test");let i=`${r}/${o}/${u}`,c=t.open({path:i,compression:!0,useVersions:!0}),a=new mn,f=async()=>{await Zn((()=>("closed"===c.status&&console.log(`client.status[${c.status}], level is closed`),"open"===c.status)));let t=[];for await(let{value:e}of c.getRange())t.push(e);return t},l=async t=>{let e=null;try{e=await c.get(t)}catch(t){}return e};async function s(t){let e=!1;if(!gn(t)&&!jn(t))return{n:0,nInserted:0,ok:1};t=sn(t);let r=null;try{bn(t)||(t=[t]);let e=gt(t=ir(t,(function(t){return vn(t.id)||(t.id=En()),t}))),n=0;for(let e of t){gn(await l(e.id))||(await c.put(e.id,e),n++)}r={n:e,nInserted:n,ok:1},a.emit("change","insert",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}return a.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{let o=await f();if(gn(t)){r=new n.Query(t).find(o).all()}else r=o;bn(r)||(e=!0,r=`can not select by find[${JSON.stringify(t)}]`)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},a.insert=s,a.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!1;if(!gn(t)&&!jn(t))return[];t=sn(t);let n=Kt(e,"autoInsert",!0),o=null;try{bn(t)||(t=[t]),t=ir(t,(function(t){return vn(t.id)||(t.id=En()),t})),o=await Wn(t,(async t=>{let e=null,r=await l(t.id);return gn(r)&&(Xe(t,r)||(await c.put(t.id,Gr(r,t)),e={update:!0})),e=gn(e)?{n:1,nModified:1,ok:1}:{n:0,nModified:0,ok:1},n&&0===e.n&&(e=await s(t)),e})),a.emit("change","save",t,o)}catch(t){r=!0,o=t}return r?Promise.reject(o):o},a.del=async function(t){let e=!1;if(!gn(t)&&!jn(t))return[];t=sn(t);let r=null;try{bn(t)||(t=[t]),r=await Wn(t,(async t=>{let e=null;if(vn(Kt(t,"id",""))){gn(await l(t.id))?(await c.del(t.id),e={n:1,nDeleted:1,ok:1}):e={n:1,nDeleted:0,ok:1}}else e={n:1,nDeleted:0,ok:0};return e})),a.emit("change","del",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},a.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{let e=await f(),i=gt(e),l=0;if(gn(t)){let r=new n.Query(t).find(e).all();if(l=gt(r),0===l);else if(i===l)for(let t of e)await c.del(t.id);else{let t={};Se(r,((e,r)=>{t[e.id]={k:r,v:e}}));for(let r of e)o=t,u=r.id,yn(o)&&(vn(u)||_n(u))&&u in o&&await c.del(r.id)}}else{l=i;for(let t of e)await c.del(t.id)}r={n:i,nDeleted:l,ok:1},a.emit("change","delAll",null,r)}catch(t){e=!0,r=t}var o,u;return e?Promise.reject(r):r},a}}));
6
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lmdb"),require("mingo")):"function"==typeof define&&define.amd?define(["lmdb","mingo"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-lmdb"]=e(t.lmdb,t.mingo)}(this,function(t,e){"use strict";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n=r(e),o=Object.prototype;function u(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||o)}function i(t,e){return function(r){return t(e(r))}}var c=i(Object.keys,Object),a=Object.prototype.hasOwnProperty;function f(t){if(!u(t))return c(t);var e=[];for(var r in Object(t))a.call(t,r)&&"constructor"!=r&&e.push(r);return e}var l="object"==typeof global&&global&&global.Object===Object&&global,s="object"==typeof self&&self&&self.Object===Object&&self,p=l||s||Function("return this")(),v=p.Symbol,b=Object.prototype,y=b.hasOwnProperty,h=b.toString,d=v?v.toStringTag:void 0;var j=Object.prototype.toString;var g=v?v.toStringTag:void 0;function _(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=y.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return j.call(t)}(t)}function w(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function m(t){if(!w(t))return!1;var e=_(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var O,A=p["__core-js_shared__"],x=(O=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"";var S=Function.prototype.toString;function P(t){if(null!=t){try{return S.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var k=/^\[object .+?Constructor\]$/,z=Function.prototype,E=Object.prototype,I=z.toString,$=E.hasOwnProperty,F=RegExp("^"+I.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U(t){return!(!w(t)||(e=t,x&&x in e))&&(m(t)?F:k).test(P(t));var e}function M(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return U(r)?r:void 0}var D=M(p,"DataView"),N=M(p,"Map"),T=M(p,"Promise"),C=M(p,"Set"),L=M(p,"WeakMap"),B="[object Map]",R="[object Promise]",q="[object Set]",V="[object WeakMap]",W="[object DataView]",G=P(D),Q=P(N),J=P(T),H=P(C),K=P(L),X=_;(D&&X(new D(new ArrayBuffer(1)))!=W||N&&X(new N)!=B||T&&X(T.resolve())!=R||C&&X(new C)!=q||L&&X(new L)!=V)&&(X=function(t){var e=_(t),r="[object Object]"==e?t.constructor:void 0,n=r?P(r):"";if(n)switch(n){case G:return W;case Q:return B;case J:return R;case H:return q;case K:return V}return e});var Y=X;function Z(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function tt(t){return null!=t&&Z(t.length)&&!m(t)}var et=Array.isArray;function rt(t){return null!=t&&"object"==typeof t}function nt(t){return function(e){return null==e?void 0:e[t]}}var ot=nt("length"),ut=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var it="\\ud800-\\udfff",ct="["+it+"]",at="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",ft="\\ud83c[\\udffb-\\udfff]",lt="[^"+it+"]",st="(?:\\ud83c[\\udde6-\\uddff]){2}",pt="[\\ud800-\\udbff][\\udc00-\\udfff]",vt="(?:"+at+"|"+ft+")"+"?",bt="[\\ufe0e\\ufe0f]?",yt=bt+vt+("(?:\\u200d(?:"+[lt,st,pt].join("|")+")"+bt+vt+")*"),ht="(?:"+[lt+at+"?",at,st,pt,ct].join("|")+")",dt=RegExp(ft+"(?="+ft+")|"+ht+yt,"g");function jt(t){return function(t){return ut.test(t)}(t)?function(t){for(var e=dt.lastIndex=0;dt.test(t);)++e;return e}(t):ot(t)}function gt(t){if(null==t)return 0;if(tt(t))return"string"==typeof(e=t)||!et(e)&&rt(e)&&"[object String]"==_(e)?jt(t):t.length;var e,r=Y(t);return"[object Map]"==r||"[object Set]"==r?t.size:f(t).length}function _t(t){return"symbol"==typeof t||rt(t)&&"[object Symbol]"==_(t)}var wt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,mt=/^\w*$/;function Ot(t,e){if(et(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!_t(t))||(mt.test(t)||!wt.test(t)||null!=e&&t in Object(e))}var At=M(Object,"create");var xt=Object.prototype.hasOwnProperty;var St=Object.prototype.hasOwnProperty;function Pt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function kt(t,e){return t===e||t!=t&&e!=e}function zt(t,e){for(var r=t.length;r--;)if(kt(t[r][0],e))return r;return-1}Pt.prototype.clear=function(){this.__data__=At?At(null):{},this.size=0},Pt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Pt.prototype.get=function(t){var e=this.__data__;if(At){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return xt.call(e,t)?e[t]:void 0},Pt.prototype.has=function(t){var e=this.__data__;return At?void 0!==e[t]:St.call(e,t)},Pt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=At&&void 0===e?"__lodash_hash_undefined__":e,this};var Et=Array.prototype.splice;function It(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function $t(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Ft(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}It.prototype.clear=function(){this.__data__=[],this.size=0},It.prototype.delete=function(t){var e=this.__data__,r=zt(e,t);return!(r<0)&&(r==e.length-1?e.pop():Et.call(e,r,1),--this.size,!0)},It.prototype.get=function(t){var e=this.__data__,r=zt(e,t);return r<0?void 0:e[r][1]},It.prototype.has=function(t){return zt(this.__data__,t)>-1},It.prototype.set=function(t,e){var r=this.__data__,n=zt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Ft.prototype.clear=function(){this.size=0,this.__data__={hash:new Pt,map:new(N||It),string:new Pt}},Ft.prototype.delete=function(t){var e=$t(this,t).delete(t);return this.size-=e?1:0,e},Ft.prototype.get=function(t){return $t(this,t).get(t)},Ft.prototype.has=function(t){return $t(this,t).has(t)},Ft.prototype.set=function(t,e){var r=$t(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Ut(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],u=r.cache;if(u.has(o))return u.get(o);var i=t.apply(this,n);return r.cache=u.set(o,i)||u,i};return r.cache=new(Ut.Cache||Ft),r}Ut.Cache=Ft;var Mt,Dt,Nt,Tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ct=/\\(\\)?/g,Lt=(Mt=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Tt,function(t,r,n,o){e.push(n?o.replace(Ct,"$1"):r||t)}),e},Dt=Ut(Mt,function(t){return 500===Nt.size&&Nt.clear(),t}),Nt=Dt.cache,Dt),Bt=Lt;function Rt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var qt=v?v.prototype:void 0,Vt=qt?qt.toString:void 0;function Wt(t){if("string"==typeof t)return t;if(et(t))return Rt(t,Wt)+"";if(_t(t))return Vt?Vt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Gt(t){return null==t?"":Wt(t)}function Qt(t,e){return et(t)?t:Ot(t,e)?[t]:Bt(Gt(t))}function Jt(t){if("string"==typeof t||_t(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Ht(t,e){for(var r=0,n=(e=Qt(e,t)).length;null!=t&&r<n;)t=t[Jt(e[r++])];return r&&r==n?t:void 0}function Kt(t,e,r){var n=null==t?void 0:Ht(t,e);return void 0===n?r:n}function Xt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var Yt,Zt=function(t,e,r){for(var n=-1,o=Object(t),u=r(t),i=u.length;i--;){var c=u[Yt?i:++n];if(!1===e(o[c],c,o))break}return t};function te(t){return rt(t)&&"[object Arguments]"==_(t)}var ee=Object.prototype,re=ee.hasOwnProperty,ne=ee.propertyIsEnumerable,oe=te(function(){return arguments}())?te:function(t){return rt(t)&&re.call(t,"callee")&&!ne.call(t,"callee")},ue=oe;var ie="object"==typeof exports&&exports&&!exports.nodeType&&exports,ce=ie&&"object"==typeof module&&module&&!module.nodeType&&module,ae=ce&&ce.exports===ie?p.Buffer:void 0,fe=(ae?ae.isBuffer:void 0)||function(){return!1},le=/^(?:0|[1-9]\d*)$/;function se(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&le.test(t))&&t>-1&&t%1==0&&t<e}var pe={};function ve(t){return function(e){return t(e)}}pe["[object Float32Array]"]=pe["[object Float64Array]"]=pe["[object Int8Array]"]=pe["[object Int16Array]"]=pe["[object Int32Array]"]=pe["[object Uint8Array]"]=pe["[object Uint8ClampedArray]"]=pe["[object Uint16Array]"]=pe["[object Uint32Array]"]=!0,pe["[object Arguments]"]=pe["[object Array]"]=pe["[object ArrayBuffer]"]=pe["[object Boolean]"]=pe["[object DataView]"]=pe["[object Date]"]=pe["[object Error]"]=pe["[object Function]"]=pe["[object Map]"]=pe["[object Number]"]=pe["[object Object]"]=pe["[object RegExp]"]=pe["[object Set]"]=pe["[object String]"]=pe["[object WeakMap]"]=!1;var be="object"==typeof exports&&exports&&!exports.nodeType&&exports,ye=be&&"object"==typeof module&&module&&!module.nodeType&&module,he=ye&&ye.exports===be&&l.process,de=function(){try{var t=ye&&ye.require&&ye.require("util").types;return t||he&&he.binding&&he.binding("util")}catch(t){}}(),je=de&&de.isTypedArray,ge=je?ve(je):function(t){return rt(t)&&Z(t.length)&&!!pe[_(t)]},_e=Object.prototype.hasOwnProperty;function we(t,e){var r=et(t),n=!r&&ue(t),o=!r&&!n&&fe(t),u=!r&&!n&&!o&&ge(t),i=r||n||o||u,c=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=c.length;for(var f in t)!e&&!_e.call(t,f)||i&&("length"==f||o&&("offset"==f||"parent"==f)||u&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||se(f,a))||c.push(f);return c}function me(t){return tt(t)?we(t):f(t)}var Oe=function(t,e){return function(r,n){if(null==r)return r;if(!tt(r))return t(r,n);for(var o=r.length,u=e?o:-1,i=Object(r);(e?u--:++u<o)&&!1!==n(i[u],u,i););return r}}(function(t,e){return t&&Zt(t,e,me)}),Ae=Oe;function xe(t){return t}function Se(t,e){var r;return(et(t)?Xt:Ae)(t,"function"==typeof(r=e)?r:xe)}function Pe(t){var e=this.__data__=new It(t);this.size=e.size}Pe.prototype.clear=function(){this.__data__=new It,this.size=0},Pe.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Pe.prototype.get=function(t){return this.__data__.get(t)},Pe.prototype.has=function(t){return this.__data__.has(t)},Pe.prototype.set=function(t,e){var r=this.__data__;if(r instanceof It){var n=r.__data__;if(!N||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ft(n)}return r.set(t,e),this.size=r.size,this};function ke(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Ft;++e<r;)this.add(t[e])}function ze(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Ee(t,e){return t.has(e)}ke.prototype.add=ke.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ke.prototype.has=function(t){return this.__data__.has(t)};function Ie(t,e,r,n,o,u){var i=1&r,c=t.length,a=e.length;if(c!=a&&!(i&&a>c))return!1;var f=u.get(t),l=u.get(e);if(f&&l)return f==e&&l==t;var s=-1,p=!0,v=2&r?new ke:void 0;for(u.set(t,e),u.set(e,t);++s<c;){var b=t[s],y=e[s];if(n)var h=i?n(y,b,s,e,t,u):n(b,y,s,t,e,u);if(void 0!==h){if(h)continue;p=!1;break}if(v){if(!ze(e,function(t,e){if(!Ee(v,e)&&(b===t||o(b,t,r,n,u)))return v.push(e)})){p=!1;break}}else if(b!==y&&!o(b,y,r,n,u)){p=!1;break}}return u.delete(t),u.delete(e),p}var $e=p.Uint8Array;function Fe(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Ue(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Me=v?v.prototype:void 0,De=Me?Me.valueOf:void 0;function Ne(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function Te(t,e,r){var n=e(t);return et(t)?n:Ne(n,r(t))}function Ce(){return[]}var Le=Object.prototype.propertyIsEnumerable,Be=Object.getOwnPropertySymbols,Re=Be?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,u=[];++r<n;){var i=t[r];e(i,r,t)&&(u[o++]=i)}return u}(Be(t),function(e){return Le.call(t,e)}))}:Ce,qe=Re;function Ve(t){return Te(t,me,qe)}var We=Object.prototype.hasOwnProperty;var Ge="[object Arguments]",Qe="[object Array]",Je="[object Object]",He=Object.prototype.hasOwnProperty;function Ke(t,e,r,n,o,u){var i=et(t),c=et(e),a=i?Qe:Y(t),f=c?Qe:Y(e),l=(a=a==Ge?Je:a)==Je,s=(f=f==Ge?Je:f)==Je,p=a==f;if(p&&fe(t)){if(!fe(e))return!1;i=!0,l=!1}if(p&&!l)return u||(u=new Pe),i||ge(t)?Ie(t,e,r,n,o,u):function(t,e,r,n,o,u,i){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!u(new $e(t),new $e(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return kt(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var c=Fe;case"[object Set]":var a=1&n;if(c||(c=Ue),t.size!=e.size&&!a)return!1;var f=i.get(t);if(f)return f==e;n|=2,i.set(t,e);var l=Ie(c(t),c(e),n,o,u,i);return i.delete(t),l;case"[object Symbol]":if(De)return De.call(t)==De.call(e)}return!1}(t,e,a,r,n,o,u);if(!(1&r)){var v=l&&He.call(t,"__wrapped__"),b=s&&He.call(e,"__wrapped__");if(v||b){var y=v?t.value():t,h=b?e.value():e;return u||(u=new Pe),o(y,h,r,n,u)}}return!!p&&(u||(u=new Pe),function(t,e,r,n,o,u){var i=1&r,c=Ve(t),a=c.length;if(a!=Ve(e).length&&!i)return!1;for(var f=a;f--;){var l=c[f];if(!(i?l in e:We.call(e,l)))return!1}var s=u.get(t),p=u.get(e);if(s&&p)return s==e&&p==t;var v=!0;u.set(t,e),u.set(e,t);for(var b=i;++f<a;){var y=t[l=c[f]],h=e[l];if(n)var d=i?n(h,y,l,e,t,u):n(y,h,l,t,e,u);if(!(void 0===d?y===h||o(y,h,r,n,u):d)){v=!1;break}b||(b="constructor"==l)}if(v&&!b){var j=t.constructor,g=e.constructor;j==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof j&&j instanceof j&&"function"==typeof g&&g instanceof g||(v=!1)}return u.delete(t),u.delete(e),v}(t,e,r,n,o,u))}function Xe(t,e,r,n,o){return t===e||(null==t||null==e||!rt(t)&&!rt(e)?t!=t&&e!=e:Ke(t,e,r,n,Xe,o))}function Ye(t){return t==t&&!w(t)}function Ze(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function tr(t){var e=function(t){for(var e=me(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,Ye(o)]}return e}(t);return 1==e.length&&e[0][2]?Ze(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,u=o,i=!n;if(null==t)return!u;for(t=Object(t);o--;){var c=r[o];if(i&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<u;){var a=(c=r[o])[0],f=t[a],l=c[1];if(i&&c[2]){if(void 0===f&&!(a in t))return!1}else{var s=new Pe;if(n)var p=n(f,l,a,t,e,s);if(!(void 0===p?Xe(l,f,3,n,s):p))return!1}}return!0}(r,t,e)}}function er(t,e){return null!=t&&e in Object(t)}function rr(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=Qt(e,t)).length,u=!1;++n<o;){var i=Jt(e[n]);if(!(u=null!=t&&r(t,i)))break;t=t[i]}return u||++n!=o?u:!!(o=null==t?0:t.length)&&Z(o)&&se(i,o)&&(et(t)||ue(t))}(t,e,er)}function nr(t){return Ot(t)?nt(Jt(t)):function(t){return function(e){return Ht(e,t)}}(t)}function or(t){return"function"==typeof t?t:null==t?xe:"object"==typeof t?et(t)?(e=t[0],r=t[1],Ot(e)&&Ye(r)?Ze(Jt(e),r):function(t){var n=Kt(t,e);return void 0===n&&n===r?rr(t,e):Xe(r,n,3)}):tr(t):nr(t);var e,r}function ur(t,e){var r=-1,n=tt(t)?Array(t.length):[];return Ae(t,function(t,o,u){n[++r]=e(t,o,u)}),n}function ir(t,e){return(et(t)?Rt:ur)(t,or(e))}var cr=function(){try{var t=M(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),ar=cr;function fr(t,e,r){"__proto__"==e&&ar?ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function lr(t,e,r){(void 0!==r&&!kt(t[e],r)||void 0===r&&!(e in t))&&fr(t,e,r)}var sr="object"==typeof exports&&exports&&!exports.nodeType&&exports,pr=sr&&"object"==typeof module&&module&&!module.nodeType&&module,vr=pr&&pr.exports===sr?p.Buffer:void 0,br=vr?vr.allocUnsafe:void 0;function yr(t,e){if(e)return t.slice();var r=t.length,n=br?br(r):new t.constructor(r);return t.copy(n),n}function hr(t){var e=new t.constructor(t.byteLength);return new $e(e).set(new $e(t)),e}function dr(t,e){var r=e?hr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function jr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var gr=Object.create,_r=function(){function t(){}return function(e){if(!w(e))return{};if(gr)return gr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),wr=_r,mr=i(Object.getPrototypeOf,Object);function Or(t){return"function"!=typeof t.constructor||u(t)?{}:wr(mr(t))}var Ar=Function.prototype,xr=Object.prototype,Sr=Ar.toString,Pr=xr.hasOwnProperty,kr=Sr.call(Object);function zr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Er=Object.prototype.hasOwnProperty;function Ir(t,e,r){var n=t[e];Er.call(t,e)&&kt(n,r)&&(void 0!==r||e in t)||fr(t,e,r)}function $r(t,e,r,n){var o=!r;r||(r={});for(var u=-1,i=e.length;++u<i;){var c=e[u],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?fr(r,c,a):Ir(r,c,a)}return r}var Fr=Object.prototype.hasOwnProperty;function Ur(t){if(!w(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=u(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Mr(t){return tt(t)?we(t,!0):Ur(t)}function Dr(t,e,r,n,o,u,i){var c=zr(t,r),a=zr(e,r),f=i.get(a);if(f)lr(t,r,f);else{var l,s=u?u(c,a,r+"",t,e,i):void 0,p=void 0===s;if(p){var v=et(a),b=!v&&fe(a),y=!v&&!b&&ge(a);s=a,v||b||y?et(c)?s=c:rt(l=c)&&tt(l)?s=jr(c):b?(p=!1,s=yr(a,!0)):y?(p=!1,s=dr(a,!0)):s=[]:function(t){if(!rt(t)||"[object Object]"!=_(t))return!1;var e=mr(t);if(null===e)return!0;var r=Pr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Sr.call(r)==kr}(a)||ue(a)?(s=c,ue(c)?s=function(t){return $r(t,Mr(t))}(c):w(c)&&!m(c)||(s=Or(a))):p=!1}p&&(i.set(a,s),o(s,a,n,u,i),i.delete(a)),lr(t,r,s)}}function Nr(t,e,r,n,o){t!==e&&Zt(e,function(u,i){if(o||(o=new Pe),w(u))Dr(t,e,i,r,Nr,n,o);else{var c=n?n(zr(t,i),u,i+"",t,e,o):void 0;void 0===c&&(c=u),lr(t,i,c)}},Mr)}var Tr=Math.max;var Cr=ar?function(t,e){return ar(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:xe,Lr=Cr,Br=Date.now;var Rr=function(t){var e=0,r=0;return function(){var n=Br(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Lr),qr=Rr;function Vr(t,e){return qr(function(t,e,r){return e=Tr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,u=Tr(n.length-e,0),i=Array(u);++o<u;)i[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(i),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}(t,e,xe),t+"")}var Wr,Gr=(Wr=function(t,e,r){Nr(t,e,r)},Vr(function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,u=n>2?e[2]:void 0;for(o=Wr.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,e,r){if(!w(r))return!1;var n=typeof e;return!!("number"==n?tt(r)&&se(e,r.length):"string"==n&&e in r)&&kt(r[e],t)}(e[0],e[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var i=e[r];i&&Wr(t,i,r,o)}return t}));var Qr=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Ne(e,qe(t)),t=mr(t);return e}:Ce,Jr=Qr;function Hr(t){return Te(t,Mr,Jr)}var Kr=Object.prototype.hasOwnProperty;var Xr=/\w*$/;var Yr=v?v.prototype:void 0,Zr=Yr?Yr.valueOf:void 0;function tn(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return hr(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?hr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return dr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Xr.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Zr?Object(Zr.call(n)):{}}}var en=de&&de.isMap,rn=en?ve(en):function(t){return rt(t)&&"[object Map]"==Y(t)};var nn=de&&de.isSet,on=nn?ve(nn):function(t){return rt(t)&&"[object Set]"==Y(t)},un="[object Arguments]",cn="[object Function]",an="[object Object]",fn={};function ln(t,e,r,n,o,u){var i,c=1&e,a=2&e,f=4&e;if(r&&(i=o?r(t,n,o,u):r(t)),void 0!==i)return i;if(!w(t))return t;var l=et(t);if(l){if(i=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Kr.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return jr(t,i)}else{var s=Y(t),p=s==cn||"[object GeneratorFunction]"==s;if(fe(t))return yr(t,c);if(s==an||s==un||p&&!o){if(i=a||p?{}:Or(t),!c)return a?function(t,e){return $r(t,Jr(t),e)}(t,function(t,e){return t&&$r(e,Mr(e),t)}(i,t)):function(t,e){return $r(t,qe(t),e)}(t,function(t,e){return t&&$r(e,me(e),t)}(i,t))}else{if(!fn[s])return o?t:{};i=tn(t,s,c)}}u||(u=new Pe);var v=u.get(t);if(v)return v;u.set(t,i),on(t)?t.forEach(function(n){i.add(ln(n,e,r,n,t,u))}):rn(t)&&t.forEach(function(n,o){i.set(o,ln(n,e,r,o,t,u))});var b=l?void 0:(f?a?Hr:Ve:a?Mr:me)(t);return Xt(b||t,function(n,o){b&&(n=t[o=n]),Ir(i,o,ln(n,e,r,o,t,u))}),i}fn[un]=fn["[object Array]"]=fn["[object ArrayBuffer]"]=fn["[object DataView]"]=fn["[object Boolean]"]=fn["[object Date]"]=fn["[object Float32Array]"]=fn["[object Float64Array]"]=fn["[object Int8Array]"]=fn["[object Int16Array]"]=fn["[object Int32Array]"]=fn["[object Map]"]=fn["[object Number]"]=fn[an]=fn["[object RegExp]"]=fn["[object Set]"]=fn["[object String]"]=fn["[object Symbol]"]=fn["[object Uint8Array]"]=fn["[object Uint8ClampedArray]"]=fn["[object Uint16Array]"]=fn["[object Uint32Array]"]=!0,fn["[object Error]"]=fn[cn]=fn["[object WeakMap]"]=!1;function sn(t){return ln(t,5)}function pn(t){return"[object String]"===Object.prototype.toString.call(t)}function vn(t){return!(!pn(t)||""===t)}function bn(t){return"[object Array]"===Object.prototype.toString.call(t)}function yn(t){return"[object Object]"===Object.prototype.toString.call(t)}function hn(t){return t!=t}function dn(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(yn(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!pn(t)||""!==t)}(t)||(!!function(t){return!!bn(t)&&0===t.length}(t)||!!hn(t)))))}function jn(t){return!!bn(t)&&(0!==t.length&&(1!==t.length||!dn(t[0])))}function gn(t){if(yn(t)){for(let e in t)return!0;return!1}return!1}function _n(t){let e=!1;if(vn(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(hn(t))return!1;e=!0}return e}function wn(t,e){return!!yn(t)&&(!(!vn(e)&&!_n(e))&&e in t)}var mn={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function u(t,e,n,u,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var c=new o(n,u||t,i),a=r?r+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0===--t._eventsCount?t._events=new n:delete t._events[e]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),c.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},c.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,u=n.length,i=new Array(u);o<u;o++)i[o]=n[o].fn;return i},c.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},c.prototype.emit=function(t,e,n,o,u,i){var c=r?r+t:t;if(!this._events[c])return!1;var a,f,l=this._events[c],s=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),s){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,u),!0;case 6:return l.fn.call(l.context,e,n,o,u,i),!0}for(f=1,a=new Array(s-1);f<s;f++)a[f-1]=arguments[f];l.fn.apply(l.context,a)}else{var p,v=l.length;for(f=0;f<v;f++)switch(l[f].once&&this.removeListener(t,l[f].fn,void 0,!0),s){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,e);break;case 3:l[f].fn.call(l[f].context,e,n);break;case 4:l[f].fn.call(l[f].context,e,n,o);break;default:if(!a)for(p=1,a=new Array(s-1);p<s;p++)a[p-1]=arguments[p];l[f].fn.apply(l[f].context,a)}}return!0},c.prototype.on=function(t,e,r){return u(this,t,e,r,!1)},c.prototype.once=function(t,e,r){return u(this,t,e,r,!0)},c.prototype.removeListener=function(t,e,n,o){var u=r?r+t:t;if(!this._events[u])return this;if(!e)return i(this,u),this;var c=this._events[u];if(c.fn)c.fn!==e||o&&!c.once||n&&c.context!==n||i(this,u);else{for(var a=0,f=[],l=c.length;a<l;a++)(c[a].fn!==e||o&&!c[a].once||n&&c[a].context!==n)&&f.push(c[a]);f.length?this._events[u]=1===f.length?f[0]:f:i(this,u)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&i(this,e)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t.exports=c}(mn);var On=r(mn.exports);const An=[];for(let t=0;t<256;++t)An.push((t+256).toString(16).slice(1));const xn=new Uint8Array(16);function Sn(){return crypto.getRandomValues(xn)}const Pn={};function kn(t,e,r){let n;if(t)n=zn(t.random??t.rng?.()??Sn(),t.msecs,t.seq,e,r);else{const t=Date.now(),o=Sn();!function(t,e,r){t.msecs??=-1/0,t.seq??=0,e>t.msecs?(t.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],t.msecs=e):(t.seq=t.seq+1|0,0===t.seq&&t.msecs++)}(Pn,t,o),n=zn(o,Pn.msecs,Pn.seq,e,r)}return e??function(t,e=0){return(An[t[e+0]]+An[t[e+1]]+An[t[e+2]]+An[t[e+3]]+"-"+An[t[e+4]]+An[t[e+5]]+"-"+An[t[e+6]]+An[t[e+7]]+"-"+An[t[e+8]]+An[t[e+9]]+"-"+An[t[e+10]]+An[t[e+11]]+An[t[e+12]]+An[t[e+13]]+An[t[e+14]]+An[t[e+15]]).toLowerCase()}(n)}function zn(t,e,r,n,o=0){if(t.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(o<0||o+16>n.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else n=new Uint8Array(16),o=0;return e??=Date.now(),r??=127*t[6]<<24|t[7]<<16|t[8]<<8|t[9],n[o++]=e/1099511627776&255,n[o++]=e/4294967296&255,n[o++]=e/16777216&255,n[o++]=e/65536&255,n[o++]=e/256&255,n[o++]=255&e,n[o++]=112|r>>>28&15,n[o++]=r>>>20&255,n[o++]=128|r>>>14&63,n[o++]=r>>>6&255,n[o++]=r<<2&255|3&t[10],n[o++]=t[11],n[o++]=t[12],n[o++]=t[13],n[o++]=t[14],n[o++]=t[15],n}function En(){return kn()}var In=/\s/;var $n=/^\s+/;function Fn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&In.test(t.charAt(e)););return e}(t)+1).replace($n,""):t}var Un=/^[-+]0x[0-9a-f]+$/i,Mn=/^0b[01]+$/i,Dn=/^0o[0-7]+$/i,Nn=parseInt;function Tn(t){if("number"==typeof t)return t;if(_t(t))return NaN;if(w(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=w(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Fn(t);var r=Mn.test(t);return r||Dn.test(t)?Nn(t.slice(2),r?2:8):Un.test(t)?NaN:+t}var Cn=1/0;function Ln(t){return t?(t=Tn(t))===Cn||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function Bn(t){var e=Ln(t),r=e%1;return e==e?r?e-r:e:0}function Rn(t,e,r){var n=null==t?0:t.length;return n?function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var u=Array(o);++n<o;)u[n]=t[n+e];return u}(t,(e=r||void 0===e?1:Bn(e))<0?0:e,n):[]}function qn(){let t,e,r=new Promise(function(){t=arguments[0],e=arguments[1]});return r.resolve=t,r.reject=e,r}function Vn(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function Wn(t,e){let r=qn();if(!bn(t)&&!yn(t))return r.reject("rs is not an array or object"),r;let n=!1;if(yn(t)){n=!0;let e=[];Se(t,(t,r)=>{e.push({k:r,v:t})}),t=e}Vn(e)||(e=function(t){return t});let o=-1,u=[];return t.reduce(function(t,r){return t.then(function(t){u.push(t),o+=1;let i=o,c=r;return n&&(i=r.k,c=r.v),Vn(e)?e(c,i):c})},Promise.resolve()).then(function(t){u.push(t),u=Rn(u),r.resolve(u)}).catch(function(t){r.reject(t)}),r}function Gn(t){if(!_n(t))return 0;return Ln(t)}function Qn(t){return!!_n(t)&&(t=Gn(t),"number"==typeof(e=t)&&e==Bn(e));var e}var Jn=p.isFinite,Hn=Math.min;var Kn=function(t){var e=Math[t];return function(t,r){if(t=Tn(t),(r=null==r?0:Hn(Bn(r),292))&&Jn(t)){var n=(Gt(t)+"e").split("e");return+((n=(Gt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Xn=Kn;function Yn(t){if(!Qn(t))return!1;let e=function(t){if(!_n(t))return 0;t=Gn(t);let e=Xn(t);return"0"===String(e)?0:e}(t)>0;return e}async function Zn(t,e={}){let r=null,n=qn();if(!Vn(t))return n.reject("waitfunction需輸入函數f"),n;let o=async()=>{let e=t();return function(t){let e,r=Object.prototype.toString.call(t);if(e="[object Promise]"===r,e)return!0;if("[object Function]"!==r)return!1;try{e="function"!=typeof t.subscribe&&"function"==typeof t.then}catch(t){}return e}(e)&&(e=await e),e};if(r=await o(),!0===r)return n.resolve(),n;let u=Kt(e,"attemptNum",null);Yn(u)||(u=200);let i=Kt(e,"timeInterval",null);Yn(i)||(i=1e3);let c=0,a=setInterval(async()=>{c+=1,r=await o(),!0===r&&(clearInterval(a),n.resolve()),c>u&&(clearInterval(a),n.reject(`exceeded attemptNum[${u}]`))},i);return n}return function(e={}){let r=null,o=Kt(e,"url");vn(o)||(o="./_db");let u=Kt(e,"db");vn(u)||(u="worm");let i=Kt(e,"cl");vn(i)||(i="test");let c=`${o}/${u}/${i}`,a=t.open({path:c,compression:!0,useVersions:!0}),f=new On,l=async()=>{if(bn(r))return sn(r);await Zn(()=>("closed"===a.status&&console.log(`client.status[${a.status}], level is closed`),"open"===a.status));let t=[];for await(let{value:e}of a.getRange())t.push(e);return r=t,sn(t)},s=async t=>{let e=null;try{e=await a.get(t)}catch(t){}return e};async function p(t){let e=!1;if(!gn(t)&&!jn(t))return{n:0,nInserted:0,ok:1};t=sn(t);let n=null;try{bn(t)||(t=[t]);let e=gt(t=ir(t,function(t){return vn(t.id)||(t.id=En()),t})),r=0;for(let e of t){gn(await s(e.id))||(await a.put(e.id,e),r++)}n={n:e,nInserted:r,ok:1}}catch(t){e=!0,n=t}if(r=null,!e)try{f.emit("change","insert",t,n)}catch(t){console.log(t)}return e?Promise.reject(n):n}return f.select=async function(t={}){let e=!1,r=null;try{let o=await l();if(gn(t)){r=new n.Query(t).find(o).all()}else r=o;bn(r)||(e=!0,r=`can not select by find[${JSON.stringify(t)}]`)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},f.insert=p,f.save=async function(t,e={}){let n=!1;if(!gn(t)&&!jn(t))return[];t=sn(t);let o=Kt(e,"autoInsert",!0),u=null;try{bn(t)||(t=[t]),t=ir(t,function(t){return vn(t.id)||(t.id=En()),t}),u=await Wn(t,async t=>{let e=null,r=await s(t.id),n=gn(r);return n&&(Xe(t,r)||(await a.put(t.id,Gr(r,t)),e={update:!0})),e=gn(e)?{n:1,nModified:1,ok:1}:{n:0,nModified:0,ok:1},o&&0===e.n&&!n&&(e=await p(t)),e})}catch(t){n=!0,u=t}if(r=null,!n)try{f.emit("change","save",t,u)}catch(t){console.log(t)}return n?Promise.reject(u):u},f.del=async function(t){let e=!1;if(!gn(t)&&!jn(t))return[];t=sn(t);let n=null;try{bn(t)||(t=[t]),n=await Wn(t,async t=>{let e=null;if(vn(Kt(t,"id",""))){gn(await s(t.id))?(await a.del(t.id),e={n:1,nDeleted:1,ok:1}):e={n:1,nDeleted:0,ok:1}}else e={n:1,nDeleted:0,ok:0};return e})}catch(t){e=!0,n=t}if(r=null,!e)try{f.emit("change","del",t,n)}catch(t){console.log(t)}return e?Promise.reject(n):n},f.delAll=async function(t={}){let e=!1,o=null;try{let e=await l(),r=gt(e),u=0;if(gn(t)){let o=new n.Query(t).find(e).all();if(u=gt(o),0===u);else if(r===u)for(let t of e)await a.del(t.id);else{let t={};Se(o,(e,r)=>{t[e.id]={k:r,v:e}});for(let r of e)wn(t,r.id)&&await a.del(r.id)}}else{u=r;for(let t of e)await a.del(t.id)}o={n:r,nDeleted:u,ok:1}}catch(t){e=!0,o=t}if(r=null,!e)try{f.emit("change","delAll",null,o)}catch(t){console.log(t)}return e?Promise.reject(o):o},f}});
7
7
  //# sourceMappingURL=w-orm-lmdb.umd.js.map