w-orm-lowdb 1.0.1 → 1.0.3
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 +71 -49
- package/dist/w-orm-lowdb.umd.js +2 -2
- package/dist/w-orm-lowdb.umd.js.map +1 -1
- package/docs/WOrmLowdb.html +42 -42
- package/docs/WOrmLowdb.mjs.html +77 -14
- package/docs/index.html +2 -2
- package/g-basic.mjs +17 -29
- package/package.json +5 -5
- package/script.txt +4 -4
- package/src/WOrmLowdb.mjs +75 -12
- package/test/basic.test.mjs +18 -43
- package/toolg/gDistRollup.mjs +2 -0
- package/db.json +0 -14
- package/g.mjs +0 -24
package/README.md
CHANGED
|
@@ -19,7 +19,11 @@ npm i w-orm-lowdb
|
|
|
19
19
|
#### Example
|
|
20
20
|
> **Link:** [[dev source code](https://github.com/yuda-lyu/w-orm-lowdblob/master/g-basic.mjs)]
|
|
21
21
|
```alias
|
|
22
|
-
import
|
|
22
|
+
import WOrm from './src/WOrmLowdb.mjs'
|
|
23
|
+
//import WOrm from './dist/w-orm-lowdb.umd.js'
|
|
24
|
+
// import w from 'wsemi'
|
|
25
|
+
|
|
26
|
+
// w.fsDeleteFile('./db.json')
|
|
23
27
|
|
|
24
28
|
let opt = {
|
|
25
29
|
url: './db.json',
|
|
@@ -30,15 +34,18 @@ let opt = {
|
|
|
30
34
|
let rs = [
|
|
31
35
|
{
|
|
32
36
|
id: 'id-peter',
|
|
33
|
-
name: 'peter'
|
|
37
|
+
name: 'peter',
|
|
38
|
+
value: 123,
|
|
34
39
|
},
|
|
35
40
|
{
|
|
36
41
|
id: 'id-rosemary',
|
|
37
|
-
name: 'rosemary'
|
|
42
|
+
name: 'rosemary',
|
|
43
|
+
value: 123.456,
|
|
38
44
|
},
|
|
39
45
|
{
|
|
40
46
|
id: '',
|
|
41
|
-
name: 'kettle'
|
|
47
|
+
name: 'kettle',
|
|
48
|
+
value: 456,
|
|
42
49
|
},
|
|
43
50
|
]
|
|
44
51
|
|
|
@@ -59,104 +66,119 @@ let rsm = [
|
|
|
59
66
|
|
|
60
67
|
async function test() {
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
let w = wo(opt)
|
|
65
|
-
|
|
69
|
+
//wo
|
|
70
|
+
let wo = WOrm(opt)
|
|
66
71
|
|
|
67
72
|
//on
|
|
68
|
-
|
|
73
|
+
wo.on('change', function(mode, data, res) {
|
|
69
74
|
console.log('change', mode)
|
|
70
75
|
})
|
|
71
76
|
|
|
72
|
-
|
|
73
77
|
//delAll
|
|
74
|
-
await
|
|
78
|
+
await wo.delAll()
|
|
75
79
|
.then(function(msg) {
|
|
76
80
|
console.log('delAll then', msg)
|
|
77
81
|
})
|
|
78
82
|
.catch(function(msg) {
|
|
79
83
|
console.log('delAll catch', msg)
|
|
80
84
|
})
|
|
81
|
-
// => delAll then { n: 2, nDeleted: 2, ok: 1 }
|
|
82
|
-
|
|
83
85
|
|
|
84
86
|
//insert
|
|
85
|
-
await
|
|
87
|
+
await wo.insert(rs)
|
|
86
88
|
.then(function(msg) {
|
|
87
89
|
console.log('insert then', msg)
|
|
88
90
|
})
|
|
89
91
|
.catch(function(msg) {
|
|
90
92
|
console.log('insert catch', msg)
|
|
91
93
|
})
|
|
92
|
-
// => insert then { n: 3, nInserted: 3, ok: 1 }
|
|
93
|
-
|
|
94
94
|
|
|
95
95
|
//save
|
|
96
|
-
await
|
|
96
|
+
await wo.save(rsm, { autoInsert: false })
|
|
97
97
|
.then(function(msg) {
|
|
98
98
|
console.log('save then', msg)
|
|
99
99
|
})
|
|
100
100
|
.catch(function(msg) {
|
|
101
101
|
console.log('save catch', msg)
|
|
102
102
|
})
|
|
103
|
-
// => save then [
|
|
104
|
-
// { n: 1, nModified: 1, ok: 1 },
|
|
105
|
-
// { n: 1, nModified: 1, ok: 1 },
|
|
106
|
-
// { n: 0, nModified: 0, ok: 1 }, //autoInsert=false
|
|
107
|
-
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
108
|
-
// ]
|
|
109
|
-
|
|
110
103
|
|
|
111
104
|
//select all
|
|
112
|
-
let ss = await
|
|
105
|
+
let ss = await wo.select()
|
|
113
106
|
console.log('select all', ss)
|
|
114
|
-
// => select all [
|
|
115
|
-
// { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
116
|
-
// { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
|
|
117
|
-
// { id: '{random id}', name: 'kettle', value: 456 },
|
|
118
|
-
// { id: '{random id}', name: 'kettle(modify)' } //autoInsert=true
|
|
119
|
-
// ]
|
|
120
|
-
|
|
121
107
|
|
|
122
108
|
//select
|
|
123
|
-
let so = await
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
let so = await wo.select({ id: 'id-rosemary' })
|
|
110
|
+
console.log('select', so)
|
|
126
111
|
|
|
127
112
|
//select by $and, $gt, $lt
|
|
128
|
-
let spa = await
|
|
129
|
-
|
|
130
|
-
|
|
113
|
+
let spa = await wo.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
|
|
114
|
+
console.log('select by $and, $gt, $lt', spa)
|
|
131
115
|
|
|
132
116
|
//select by $or, $gte, $lte
|
|
133
|
-
let spb = await
|
|
134
|
-
|
|
135
|
-
|
|
117
|
+
let spb = await wo.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
|
|
118
|
+
console.log('select by $or, $gte, $lte', spb)
|
|
136
119
|
|
|
137
120
|
//select by $or, $and, $ne, $in, $nin
|
|
138
|
-
let spc = await
|
|
121
|
+
let spc = await wo.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
|
|
139
122
|
console.log('select by $or, $and, $ne, $in, $nin', spc)
|
|
140
|
-
// => select [
|
|
141
|
-
// { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
|
|
142
|
-
// { id: '{random id}', name: 'kettle', value: 456 }
|
|
143
|
-
// ]
|
|
144
123
|
|
|
124
|
+
// //select by regex //mingo不支援regex
|
|
125
|
+
// let sr = await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
|
|
126
|
+
// console.log('selectReg', sr)
|
|
145
127
|
|
|
146
128
|
//del
|
|
147
129
|
let d = ss.filter(function(v) {
|
|
148
130
|
return v.name === 'kettle'
|
|
149
131
|
})
|
|
150
|
-
|
|
132
|
+
await wo.del(d)
|
|
151
133
|
.then(function(msg) {
|
|
152
134
|
console.log('del then', msg)
|
|
153
135
|
})
|
|
154
136
|
.catch(function(msg) {
|
|
155
137
|
console.log('del catch', msg)
|
|
156
138
|
})
|
|
157
|
-
// => del then [ { n: 1, nDeleted: 1, ok: 1 } ]
|
|
158
|
-
|
|
159
139
|
|
|
160
140
|
}
|
|
161
141
|
test()
|
|
142
|
+
// change delAll
|
|
143
|
+
// delAll then { n: 2, nDeleted: 2, ok: 1 }
|
|
144
|
+
// change insert
|
|
145
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
146
|
+
// change save
|
|
147
|
+
// save then [
|
|
148
|
+
// { n: 1, nModified: 1, ok: 1 },
|
|
149
|
+
// { n: 1, nModified: 1, ok: 1 },
|
|
150
|
+
// { n: 0, nModified: 0, ok: 1 }
|
|
151
|
+
// ]
|
|
152
|
+
// select all [
|
|
153
|
+
// { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
154
|
+
// { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
|
|
155
|
+
// {
|
|
156
|
+
// id: {random id},
|
|
157
|
+
// name: 'kettle',
|
|
158
|
+
// value: 456
|
|
159
|
+
// }
|
|
160
|
+
// ]
|
|
161
|
+
// select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
|
|
162
|
+
// select by $and, $gt, $lt [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
|
|
163
|
+
// select by $or, $gte, $lte [
|
|
164
|
+
// {
|
|
165
|
+
// id: {random id},
|
|
166
|
+
// name: 'kettle',
|
|
167
|
+
// value: 456
|
|
168
|
+
// }
|
|
169
|
+
// ]
|
|
170
|
+
// select by $or, $and, $ne, $in, $nin [
|
|
171
|
+
// {
|
|
172
|
+
// id: 'id-rosemary',
|
|
173
|
+
// name: 'rosemary(modify)',
|
|
174
|
+
// value: 123.456
|
|
175
|
+
// },
|
|
176
|
+
// {
|
|
177
|
+
// id: {random id},
|
|
178
|
+
// name: 'kettle',
|
|
179
|
+
// value: 456
|
|
180
|
+
// }
|
|
181
|
+
// ]
|
|
182
|
+
// change del
|
|
183
|
+
// del then [ { n: 1, nDeleted: 1, ok: 1 } ]
|
|
162
184
|
```
|
package/dist/w-orm-lowdb.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* w-orm-lowdb v1.0.
|
|
2
|
+
* w-orm-lowdb v1.0.3
|
|
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("events"),require("node:fs"),require("node:fs/promises"),require("node:path"),require("node:url"),require("mingo")):"function"==typeof define&&define.amd?define(["events","node:fs","node:fs/promises","node:path","node:url","mingo"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-lowdb"]=e(t.events,null,t.promises,t.path,t.node_url,t.mingo)}(this,(function(t,e,r,n,o,i){"use strict";class u{adapter;data;constructor(t,e){!function(t,e){if(void 0===t)throw new Error("lowdb: missing adapter");if(void 0===e)throw new Error("lowdb: missing default data")}(t,e),this.adapter=t,this.data=e}async read(){const t=await this.adapter.read();t&&(this.data=t)}async write(){this.data&&await this.adapter.write(this.data)}async update(t){t(this.data),await this.write()}}class a{#t;#e;#r=!1;#n=null;#o=null;#i=null;#u=null;#a(t){return this.#u=t,this.#i||=new Promise(((t,e)=>{this.#o=[t,e]})),new Promise(((t,e)=>{var r;null===(r=this.#i)||void 0===r||r.then(t).catch(e)}))}async#c(t){this.#r=!0;try{var e;await r.writeFile(this.#e,t,"utf-8"),await async function(t,e,r){for(let n=0;n<e;n++)try{return await t()}catch(t){if(!(n<e-1))throw t;await new Promise((t=>setTimeout(t,r)))}}((async()=>{await r.rename(this.#e,this.#t)}),10,100),null===(e=this.#n)||void 0===e||e[0]()}catch(t){var n;if(t instanceof Error)null===(n=this.#n)||void 0===n||n[1](t);throw t}finally{if(this.#r=!1,this.#n=this.#o,this.#o=this.#i=null,null!==this.#u){const t=this.#u;this.#u=null,await this.write(t)}}}constructor(t){this.#t=t,this.#e=function(t){const e=t instanceof URL?o.fileURLToPath(t):t.toString();return n.join(n.dirname(e),`.${n.basename(e)}.tmp`)}(t)}async write(t){return this.#r?this.#a(t):this.#c(t)}}class c{#t;#f;constructor(t){this.#t=t,this.#f=new a(t)}async read(){let t;try{t=await r.readFile(this.#t,"utf-8")}catch(t){if("ENOENT"===t.code)return null;throw t}return t}write(t){return this.#f.write(t)}}class f{#l;#s;#v;constructor(t,e){let{parse:r,stringify:n}=e;this.#l=new c(t),this.#s=r,this.#v=n}async read(){const t=await this.#l.read();return null===t?null:this.#s(t)}write(t){return this.#l.write(this.#v(t))}}class l extends f{constructor(t){super(t,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}}var s=Array.isArray,v="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,d=v||p||Function("return this")(),h=d.Symbol,b=Object.prototype,y=b.hasOwnProperty,j=b.toString,g=h?h.toStringTag:void 0;var _=Object.prototype.toString;var w=h?h.toStringTag:void 0;function m(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":w&&w in Object(t)?function(t){var e=y.call(t,g),r=t[g];try{t[g]=void 0;var n=!0}catch(t){}var o=j.call(t);return n&&(e?t[g]=r:delete t[g]),o}(t):function(t){return _.call(t)}(t)}function O(t){return null!=t&&"object"==typeof t}function A(t){return"symbol"==typeof t||O(t)&&"[object Symbol]"==m(t)}var x=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/;function P(t,e){if(s(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!A(t))||(S.test(t)||!x.test(t)||null!=e&&t in Object(e))}function k(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function z(t){if(!k(t))return!1;var e=m(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var E,F=d["__core-js_shared__"],D=(E=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var M=Function.prototype.toString;function I(t){if(null!=t){try{return M.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var N=/^\[object .+?Constructor\]$/,U=Function.prototype,T=Object.prototype,$=U.toString,B=T.hasOwnProperty,R=RegExp("^"+$.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function L(t){return!(!k(t)||(e=t,D&&D in e))&&(z(t)?R:N).test(I(t));var e}function q(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return L(r)?r:void 0}var C=q(Object,"create");var V=Object.prototype.hasOwnProperty;var W=Object.prototype.hasOwnProperty;function G(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 J(t,e){return t===e||t!=t&&e!=e}function Q(t,e){for(var r=t.length;r--;)if(J(t[r][0],e))return r;return-1}G.prototype.clear=function(){this.__data__=C?C(null):{},this.size=0},G.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},G.prototype.get=function(t){var e=this.__data__;if(C){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return V.call(e,t)?e[t]:void 0},G.prototype.has=function(t){var e=this.__data__;return C?void 0!==e[t]:W.call(e,t)},G.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=C&&void 0===e?"__lodash_hash_undefined__":e,this};var H=Array.prototype.splice;function K(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])}}K.prototype.clear=function(){this.__data__=[],this.size=0},K.prototype.delete=function(t){var e=this.__data__,r=Q(e,t);return!(r<0)&&(r==e.length-1?e.pop():H.call(e,r,1),--this.size,!0)},K.prototype.get=function(t){var e=this.__data__,r=Q(e,t);return r<0?void 0:e[r][1]},K.prototype.has=function(t){return Q(this.__data__,t)>-1},K.prototype.set=function(t,e){var r=this.__data__,n=Q(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var X=q(d,"Map");function Y(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 Z(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])}}Z.prototype.clear=function(){this.size=0,this.__data__={hash:new G,map:new(X||K),string:new G}},Z.prototype.delete=function(t){var e=Y(this,t).delete(t);return this.size-=e?1:0,e},Z.prototype.get=function(t){return Y(this,t).get(t)},Z.prototype.has=function(t){return Y(this,t).has(t)},Z.prototype.set=function(t,e){var r=Y(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function tt(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],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(tt.Cache||Z),r}tt.Cache=Z;var et,rt,nt,ot=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/\\(\\)?/g,ut=(et=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ot,(function(t,r,n,o){e.push(n?o.replace(it,"$1"):r||t)})),e},rt=tt(et,(function(t){return 500===nt.size&&nt.clear(),t})),nt=rt.cache,rt),at=ut;function ct(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 ft=h?h.prototype:void 0,lt=ft?ft.toString:void 0;function st(t){if("string"==typeof t)return t;if(s(t))return ct(t,st)+"";if(A(t))return lt?lt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function vt(t){return null==t?"":st(t)}function pt(t,e){return s(t)?t:P(t,e)?[t]:at(vt(t))}function dt(t){if("string"==typeof t||A(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=pt(e,t)).length;null!=t&&r<n;)t=t[dt(e[r++])];return r&&r==n?t:void 0}function bt(t,e,r){var n=null==t?void 0:ht(t,e);return void 0===n?r:n}function yt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var jt,gt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var a=i[jt?u:++n];if(!1===e(o[a],a,o))break}return t};function _t(t){return O(t)&&"[object Arguments]"==m(t)}var wt=Object.prototype,mt=wt.hasOwnProperty,Ot=wt.propertyIsEnumerable,At=_t(function(){return arguments}())?_t:function(t){return O(t)&&mt.call(t,"callee")&&!Ot.call(t,"callee")},xt=At;var St="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pt=St&&"object"==typeof module&&module&&!module.nodeType&&module,kt=Pt&&Pt.exports===St?d.Buffer:void 0,zt=(kt?kt.isBuffer:void 0)||function(){return!1},Et=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Et.test(t))&&t>-1&&t%1==0&&t<e}function Dt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Mt={};function It(t){return function(e){return t(e)}}Mt["[object Float32Array]"]=Mt["[object Float64Array]"]=Mt["[object Int8Array]"]=Mt["[object Int16Array]"]=Mt["[object Int32Array]"]=Mt["[object Uint8Array]"]=Mt["[object Uint8ClampedArray]"]=Mt["[object Uint16Array]"]=Mt["[object Uint32Array]"]=!0,Mt["[object Arguments]"]=Mt["[object Array]"]=Mt["[object ArrayBuffer]"]=Mt["[object Boolean]"]=Mt["[object DataView]"]=Mt["[object Date]"]=Mt["[object Error]"]=Mt["[object Function]"]=Mt["[object Map]"]=Mt["[object Number]"]=Mt["[object Object]"]=Mt["[object RegExp]"]=Mt["[object Set]"]=Mt["[object String]"]=Mt["[object WeakMap]"]=!1;var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ut=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=Ut&&Ut.exports===Nt&&v.process,$t=function(){try{var t=Ut&&Ut.require&&Ut.require("util").types;return t||Tt&&Tt.binding&&Tt.binding("util")}catch(t){}}(),Bt=$t&&$t.isTypedArray,Rt=Bt?It(Bt):function(t){return O(t)&&Dt(t.length)&&!!Mt[m(t)]},Lt=Object.prototype.hasOwnProperty;function qt(t,e){var r=s(t),n=!r&&xt(t),o=!r&&!n&&zt(t),i=!r&&!n&&!o&&Rt(t),u=r||n||o||i,a=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var f in t)!e&&!Lt.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||Ft(f,c))||a.push(f);return a}var Ct=Object.prototype;function Vt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ct)}function Wt(t,e){return function(r){return t(e(r))}}var Gt=Wt(Object.keys,Object),Jt=Object.prototype.hasOwnProperty;function Qt(t){if(!Vt(t))return Gt(t);var e=[];for(var r in Object(t))Jt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Ht(t){return null!=t&&Dt(t.length)&&!z(t)}function Kt(t){return Ht(t)?qt(t):Qt(t)}var Xt=function(t,e){return function(r,n){if(null==r)return r;if(!Ht(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}((function(t,e){return t&>(t,e,Kt)})),Yt=Xt;function Zt(t){return t}function te(t,e){var r;return(s(t)?yt:Yt)(t,"function"==typeof(r=e)?r:Zt)}function ee(t){var e=this.__data__=new K(t);this.size=e.size}ee.prototype.clear=function(){this.__data__=new K,this.size=0},ee.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ee.prototype.get=function(t){return this.__data__.get(t)},ee.prototype.has=function(t){return this.__data__.has(t)},ee.prototype.set=function(t,e){var r=this.__data__;if(r instanceof K){var n=r.__data__;if(!X||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Z(n)}return r.set(t,e),this.size=r.size,this};function re(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Z;++e<r;)this.add(t[e])}function ne(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 oe(t,e){return t.has(e)}re.prototype.add=re.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},re.prototype.has=function(t){return this.__data__.has(t)};function ie(t,e,r,n,o,i){var u=1&r,a=t.length,c=e.length;if(a!=c&&!(u&&c>a))return!1;var f=i.get(t),l=i.get(e);if(f&&l)return f==e&&l==t;var s=-1,v=!0,p=2&r?new re:void 0;for(i.set(t,e),i.set(e,t);++s<a;){var d=t[s],h=e[s];if(n)var b=u?n(h,d,s,e,t,i):n(d,h,s,t,e,i);if(void 0!==b){if(b)continue;v=!1;break}if(p){if(!ne(e,(function(t,e){if(!oe(p,e)&&(d===t||o(d,t,r,n,i)))return p.push(e)}))){v=!1;break}}else if(d!==h&&!o(d,h,r,n,i)){v=!1;break}}return i.delete(t),i.delete(e),v}var ue=d.Uint8Array;function ae(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function ce(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var fe=h?h.prototype:void 0,le=fe?fe.valueOf:void 0;function se(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function ve(t,e,r){var n=e(t);return s(t)?n:se(n,r(t))}function pe(){return[]}var de=Object.prototype.propertyIsEnumerable,he=Object.getOwnPropertySymbols,be=he?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}(he(t),(function(e){return de.call(t,e)})))}:pe,ye=be;function je(t){return ve(t,Kt,ye)}var ge=Object.prototype.hasOwnProperty;var _e=q(d,"DataView"),we=q(d,"Promise"),me=q(d,"Set"),Oe=q(d,"WeakMap"),Ae="[object Map]",xe="[object Promise]",Se="[object Set]",Pe="[object WeakMap]",ke="[object DataView]",ze=I(_e),Ee=I(X),Fe=I(we),De=I(me),Me=I(Oe),Ie=m;(_e&&Ie(new _e(new ArrayBuffer(1)))!=ke||X&&Ie(new X)!=Ae||we&&Ie(we.resolve())!=xe||me&&Ie(new me)!=Se||Oe&&Ie(new Oe)!=Pe)&&(Ie=function(t){var e=m(t),r="[object Object]"==e?t.constructor:void 0,n=r?I(r):"";if(n)switch(n){case ze:return ke;case Ee:return Ae;case Fe:return xe;case De:return Se;case Me:return Pe}return e});var Ne=Ie,Ue="[object Arguments]",Te="[object Array]",$e="[object Object]",Be=Object.prototype.hasOwnProperty;function Re(t,e,r,n,o,i){var u=s(t),a=s(e),c=u?Te:Ne(t),f=a?Te:Ne(e),l=(c=c==Ue?$e:c)==$e,v=(f=f==Ue?$e:f)==$e,p=c==f;if(p&&zt(t)){if(!zt(e))return!1;u=!0,l=!1}if(p&&!l)return i||(i=new ee),u||Rt(t)?ie(t,e,r,n,o,i):function(t,e,r,n,o,i,u){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||!i(new ue(t),new ue(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return J(+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 a=ae;case"[object Set]":var c=1&n;if(a||(a=ce),t.size!=e.size&&!c)return!1;var f=u.get(t);if(f)return f==e;n|=2,u.set(t,e);var l=ie(a(t),a(e),n,o,i,u);return u.delete(t),l;case"[object Symbol]":if(le)return le.call(t)==le.call(e)}return!1}(t,e,c,r,n,o,i);if(!(1&r)){var d=l&&Be.call(t,"__wrapped__"),h=v&&Be.call(e,"__wrapped__");if(d||h){var b=d?t.value():t,y=h?e.value():e;return i||(i=new ee),o(b,y,r,n,i)}}return!!p&&(i||(i=new ee),function(t,e,r,n,o,i){var u=1&r,a=je(t),c=a.length;if(c!=je(e).length&&!u)return!1;for(var f=c;f--;){var l=a[f];if(!(u?l in e:ge.call(e,l)))return!1}var s=i.get(t),v=i.get(e);if(s&&v)return s==e&&v==t;var p=!0;i.set(t,e),i.set(e,t);for(var d=u;++f<c;){var h=t[l=a[f]],b=e[l];if(n)var y=u?n(b,h,l,e,t,i):n(h,b,l,t,e,i);if(!(void 0===y?h===b||o(h,b,r,n,i):y)){p=!1;break}d||(d="constructor"==l)}if(p&&!d){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||(p=!1)}return i.delete(t),i.delete(e),p}(t,e,r,n,o,i))}function Le(t,e,r,n,o){return t===e||(null==t||null==e||!O(t)&&!O(e)?t!=t&&e!=e:Re(t,e,r,n,Le,o))}function qe(t){return t==t&&!k(t)}function Ce(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Ve(t){var e=function(t){for(var e=Kt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,qe(o)]}return e}(t);return 1==e.length&&e[0][2]?Ce(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=r[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){var c=(a=r[o])[0],f=t[c],l=a[1];if(u&&a[2]){if(void 0===f&&!(c in t))return!1}else{var s=new ee;if(n)var v=n(f,l,c,t,e,s);if(!(void 0===v?Le(l,f,3,n,s):v))return!1}}return!0}(r,t,e)}}function We(t,e){return null!=t&&e in Object(t)}function Ge(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=pt(e,t)).length,i=!1;++n<o;){var u=dt(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&Dt(o)&&Ft(u,o)&&(s(t)||xt(t))}(t,e,We)}function Je(t){return function(e){return null==e?void 0:e[t]}}function Qe(t){return P(t)?Je(dt(t)):function(t){return function(e){return ht(e,t)}}(t)}function He(t){return"function"==typeof t?t:null==t?Zt:"object"==typeof t?s(t)?function(t,e){return P(t)&&qe(e)?Ce(dt(t),e):function(r){var n=bt(r,t);return void 0===n&&n===e?Ge(r,t):Le(e,n,3)}}(t[0],t[1]):Ve(t):Qe(t)}function Ke(t,e){var r=-1,n=Ht(t)?Array(t.length):[];return Yt(t,(function(t,o,i){n[++r]=e(t,o,i)})),n}function Xe(t,e){return(s(t)?ct:Ke)(t,He(e))}var Ye=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ze=Ye;function tr(t,e,r){"__proto__"==e&&Ze?Ze(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function er(t,e,r){(void 0!==r&&!J(t[e],r)||void 0===r&&!(e in t))&&tr(t,e,r)}var rr="object"==typeof exports&&exports&&!exports.nodeType&&exports,nr=rr&&"object"==typeof module&&module&&!module.nodeType&&module,or=nr&&nr.exports===rr?d.Buffer:void 0,ir=or?or.allocUnsafe:void 0;function ur(t,e){if(e)return t.slice();var r=t.length,n=ir?ir(r):new t.constructor(r);return t.copy(n),n}function ar(t){var e=new t.constructor(t.byteLength);return new ue(e).set(new ue(t)),e}function cr(t,e){var r=e?ar(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function fr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var lr=Object.create,sr=function(){function t(){}return function(e){if(!k(e))return{};if(lr)return lr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),vr=sr,pr=Wt(Object.getPrototypeOf,Object);function dr(t){return"function"!=typeof t.constructor||Vt(t)?{}:vr(pr(t))}var hr=Function.prototype,br=Object.prototype,yr=hr.toString,jr=br.hasOwnProperty,gr=yr.call(Object);function _r(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var wr=Object.prototype.hasOwnProperty;function mr(t,e,r){var n=t[e];wr.call(t,e)&&J(n,r)&&(void 0!==r||e in t)||tr(t,e,r)}function Or(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?tr(r,a,c):mr(r,a,c)}return r}var Ar=Object.prototype.hasOwnProperty;function xr(t){if(!k(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Vt(t),r=[];for(var n in t)("constructor"!=n||!e&&Ar.call(t,n))&&r.push(n);return r}function Sr(t){return Ht(t)?qt(t,!0):xr(t)}function Pr(t,e,r,n,o,i,u){var a=_r(t,r),c=_r(e,r),f=u.get(c);if(f)er(t,r,f);else{var l,v=i?i(a,c,r+"",t,e,u):void 0,p=void 0===v;if(p){var d=s(c),h=!d&&zt(c),b=!d&&!h&&Rt(c);v=c,d||h||b?s(a)?v=a:O(l=a)&&Ht(l)?v=fr(a):h?(p=!1,v=ur(c,!0)):b?(p=!1,v=cr(c,!0)):v=[]:function(t){if(!O(t)||"[object Object]"!=m(t))return!1;var e=pr(t);if(null===e)return!0;var r=jr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&yr.call(r)==gr}(c)||xt(c)?(v=a,xt(a)?v=function(t){return Or(t,Sr(t))}(a):k(a)&&!z(a)||(v=dr(c))):p=!1}p&&(u.set(c,v),o(v,c,n,i,u),u.delete(c)),er(t,r,v)}}function kr(t,e,r,n,o){t!==e&>(e,(function(i,u){if(o||(o=new ee),k(i))Pr(t,e,u,r,kr,n,o);else{var a=n?n(_r(t,u),i,u+"",t,e,o):void 0;void 0===a&&(a=i),er(t,u,a)}}),Sr)}var zr=Math.max;function Er(t,e,r){return e=zr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=zr(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(u),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,a)}}var Fr=Ze?function(t,e){return Ze(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:Zt,Dr=Fr,Mr=Date.now;var Ir=function(t){var e=0,r=0;return function(){var n=Mr(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Dr),Nr=Ir;var Ur,Tr=(Ur=function(t,e,r){kr(t,e,r)},function(t,e){return Nr(Er(t,e,Zt),t+"")}((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ur.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!k(r))return!1;var n=typeof e;return!!("number"==n?Ht(r)&&Ft(e,r.length):"string"==n&&e in r)&&J(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&Ur(t,u,r,o)}return t}))),$r=Tr;var Br=Je("length"),Rr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Lr="\\ud800-\\udfff",qr="["+Lr+"]",Cr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Vr="\\ud83c[\\udffb-\\udfff]",Wr="[^"+Lr+"]",Gr="(?:\\ud83c[\\udde6-\\uddff]){2}",Jr="[\\ud800-\\udbff][\\udc00-\\udfff]",Qr="(?:"+Cr+"|"+Vr+")"+"?",Hr="[\\ufe0e\\ufe0f]?",Kr=Hr+Qr+("(?:\\u200d(?:"+[Wr,Gr,Jr].join("|")+")"+Hr+Qr+")*"),Xr="(?:"+[Wr+Cr+"?",Cr,Gr,Jr,qr].join("|")+")",Yr=RegExp(Vr+"(?="+Vr+")|"+Xr+Kr,"g");function Zr(t){return function(t){return Rr.test(t)}(t)?function(t){for(var e=Yr.lastIndex=0;Yr.test(t);)++e;return e}(t):Br(t)}function tn(t){if(null==t)return 0;if(Ht(t))return"string"==typeof(e=t)||!s(e)&&O(e)&&"[object String]"==m(e)?Zr(t):t.length;var e,r=Ne(t);return"[object Map]"==r||"[object Set]"==r?t.size:Qt(t).length}var en=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)se(e,ye(t)),t=pr(t);return e}:pe,rn=en;function nn(t){return ve(t,Sr,rn)}var on=Object.prototype.hasOwnProperty;var un=/\w*$/;var an=h?h.prototype:void 0,cn=an?an.valueOf:void 0;function fn(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return ar(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?ar(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 cr(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,un.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,cn?Object(cn.call(n)):{}}}var ln=$t&&$t.isMap,sn=ln?It(ln):function(t){return O(t)&&"[object Map]"==Ne(t)};var vn=$t&&$t.isSet,pn=vn?It(vn):function(t){return O(t)&&"[object Set]"==Ne(t)},dn="[object Arguments]",hn="[object Function]",bn="[object Object]",yn={};function jn(t,e,r,n,o,i){var u,a=1&e,c=2&e,f=4&e;if(r&&(u=o?r(t,n,o,i):r(t)),void 0!==u)return u;if(!k(t))return t;var l=s(t);if(l){if(u=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&on.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return fr(t,u)}else{var v=Ne(t),p=v==hn||"[object GeneratorFunction]"==v;if(zt(t))return ur(t,a);if(v==bn||v==dn||p&&!o){if(u=c||p?{}:dr(t),!a)return c?function(t,e){return Or(t,rn(t),e)}(t,function(t,e){return t&&Or(e,Sr(e),t)}(u,t)):function(t,e){return Or(t,ye(t),e)}(t,function(t,e){return t&&Or(e,Kt(e),t)}(u,t))}else{if(!yn[v])return o?t:{};u=fn(t,v,a)}}i||(i=new ee);var d=i.get(t);if(d)return d;i.set(t,u),pn(t)?t.forEach((function(n){u.add(jn(n,e,r,n,t,i))})):sn(t)&&t.forEach((function(n,o){u.set(o,jn(n,e,r,o,t,i))}));var h=l?void 0:(f?c?nn:je:c?Sr:Kt)(t);return yt(h||t,(function(n,o){h&&(n=t[o=n]),mr(u,o,jn(n,e,r,o,t,i))})),u}yn[dn]=yn["[object Array]"]=yn["[object ArrayBuffer]"]=yn["[object DataView]"]=yn["[object Boolean]"]=yn["[object Date]"]=yn["[object Float32Array]"]=yn["[object Float64Array]"]=yn["[object Int8Array]"]=yn["[object Int16Array]"]=yn["[object Int32Array]"]=yn["[object Map]"]=yn["[object Number]"]=yn[bn]=yn["[object RegExp]"]=yn["[object Set]"]=yn["[object String]"]=yn["[object Symbol]"]=yn["[object Uint8Array]"]=yn["[object Uint8ClampedArray]"]=yn["[object Uint16Array]"]=yn["[object Uint32Array]"]=!0,yn["[object Error]"]=yn[hn]=yn["[object WeakMap]"]=!1;function gn(t){return jn(t,5)}var _n=/\s/;var wn=/^\s+/;function mn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&_n.test(t.charAt(e)););return e}(t)+1).replace(wn,""):t}var On=/^[-+]0x[0-9a-f]+$/i,An=/^0b[01]+$/i,xn=/^0o[0-7]+$/i,Sn=parseInt;function Pn(t){if("number"==typeof t)return t;if(A(t))return NaN;if(k(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=k(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=mn(t);var r=An.test(t);return r||xn.test(t)?Sn(t.slice(2),r?2:8):On.test(t)?NaN:+t}var kn=1/0;function zn(t){return t?(t=Pn(t))===kn||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function En(t){var e=zn(t),r=e%1;return e==e?r?e-r:e:0}function Fn(t){return"[object String]"===Object.prototype.toString.call(t)}function Dn(t){return!(!Fn(t)||""===t)}function Mn(t){return t!=t}function In(t){let e=!1;if(Dn(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Mn(t))return!1;e=!0}return e}function Nn(t){if(!In(t))return 0;return zn(t)}function Un(t){return!!In(t)&&(t=Nn(t),"number"==typeof(e=t)&&e==En(e));var e}var Tn=d.isFinite,$n=Math.min;var Bn=function(t){var e=Math[t];return function(t,r){if(t=Pn(t),(r=null==r?0:$n(En(r),292))&&Tn(t)){var n=(vt(t)+"e").split("e");return+((n=(vt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Rn=Bn;function Ln(t){if(!In(t))return 0;t=Nn(t);let e=Rn(t);return"0"===String(e)?0:e}let qn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Cn=qn.length;function Vn(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];var r;t=Un(r=t)&&Ln(r)>0?Ln(t):32;for(let r=0;r<t;r++)e[r]=qn[0|Math.random()*Cn];return e.join("")}function Wn(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 i=Array(o);++n<o;)i[n]=t[n+e];return i}function Gn(t){return"[object Array]"===Object.prototype.toString.call(t)}function Jn(t){return"[object Object]"===Object.prototype.toString.call(t)}function Qn(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function Hn(t,e){let r=function(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}();if(!Gn(t)&&!Jn(t))return r.reject("rs is not an array or object"),r;let n=!1;if(Jn(t)){n=!0;let e=[];te(t,((t,r)=>{e.push({k:r,v:t})})),t=e}Qn(e)||(e=function(t){return t});let o=-1,i=[];return t.reduce((function(t,r){return t.then((function(t){i.push(t),o+=1;let u=o,a=r;return n&&(u=r.k,a=r.v),Qn(e)?e(a,u):a}))}),Promise.resolve()).then((function(t){var e,n,o,u;i.push(t),u=null==(e=i)?0:e.length,i=u?Wn(e,(n=o||void 0===n?1:En(n))<0?0:n,u):[],r.resolve(i)})).catch((function(t){r.reject(t)})),r}function Kn(t){if(Jn(t)){for(let e in t)return!0;return!1}return!1}function Xn(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(Jn(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!Fn(t)||""!==t)}(t)||(!!function(t){return!!Gn(t)&&0===t.length}(t)||!!Mn(t)))))}function Yn(t){return!!Gn(t)&&(0!==t.length&&(1!==t.length||!Xn(t[0])))}function Zn(t,e){return!!Jn(t)&&(!(!Dn(e)&&!In(e))&&e in t)}function to(t,e){return null==(t=function(t,e){return e.length<2?t:ht(t,Wn(e,0,-1))}(t,e=pt(e,t)))||delete t[dt((r=e,n=null==r?0:r.length,n?r[n-1]:void 0))];var r,n}var eo=Array.prototype.splice;function ro(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=A(t),u=void 0!==e,a=null===e,c=e==e,f=A(e);if(!a&&!f&&!i&&t>e||i&&u&&c&&!a&&!f||n&&u&&c||!r&&c||!o)return 1;if(!n&&!i&&!f&&t<e||f&&r&&o&&!n&&!i||a&&r&&o||!u&&o||!c)return-1}return 0}var no=h?h.isConcatSpreadable:void 0;function oo(t){return s(t)||xt(t)||!!(no&&t&&t[no])}function io(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=oo),o||(o=[]);++i<u;){var a=t[i];e>0&&r(a)?e>1?io(a,e-1,r,n,o):se(o,a):n||(o[o.length]=a)}return o}function uo(t){return(null==t?0:t.length)?io(t,1):[]}var ao=function(t){return Nr(Er(t,void 0,uo),t+"")}((function(t,e){var r=null==t?0:t.length,n=function(t,e){for(var r=-1,n=e.length,o=Array(n),i=null==t;++r<n;)o[r]=i?void 0:bt(t,e[r]);return o}(t,e);return function(t,e){for(var r=t?e.length:0,n=r-1;r--;){var o=e[r];if(r==n||o!==i){var i=o;Ft(o)?eo.call(t,o,1):to(t,o)}}}(t,ct(e,(function(t){return Ft(t,r)?+t:t})).sort(ro)),n})),co=ao;function fo(t,e){if(!Yn(t))return[];var r;if(Un(r=e)&&Ln(r)>=0&&(e=[e]),!Yn(e))return t;e=Xe(e,(t=>Ln(t)));let n=gn(t);return co(n,e),n}return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=bt(e,"url");Dn(r)||(r="./db.json");let n=bt(e,"db");Dn(n)||(n="worm");let o=bt(e,"cl");Dn(o)||(o="test");let a=`${n}:${o}`,c=new l(r),f=new u(c,{});Zn(f.data,a)||(f.data[a]=[]);let s=new t.EventEmitter;async function v(t){let e=!1;if(!Kn(t)&&!Yn(t))return Promise.reject("data is not an effective object or array");t=gn(t);let r=null;try{Gn(t)||(t=[t]),t=Xe(t,(function(t){return Dn(t.id)||(t.id=Vn()),t})),await f.read();let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=tn(t),o=0,i=!1;te(t,(t=>{Zn(e,t.id)||(f.data[a].push(t),o++,i=!0)})),i&&await f.write(),r={n:n,nInserted:o,ok:1},s.emit("change","insert",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}return s.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{if(await f.read(),Kn(t)){r=new i.Query(t).find(f.data[a]).all()}else r=f.data[a]}catch(t){e=!0,r=t}return e?Promise.reject(r):r},s.insert=v,s.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!1;if(!Kn(t)&&!Yn(t))return Promise.reject("data is not an effective object or array");t=gn(t);let n=bt(e,"autoInsert",!0),o=null;try{Gn(t)||(t=[t]),t=Xe(t,(function(t){return Dn(t.id)||(t.id=Vn()),t})),await f.read();let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let r=!1;o=await Hn(t,(async t=>{let o=null,i=bt(t,"id",""),u=bt(e,i,null);var c,l;return Kn(u)&&(c=t,l=u.v,Le(c,l)||(f.data[a][u.k]=$r(f.data[a][u.k],t),o={update:!0},r=!0)),o=Kn(o)?{n:1,nModified:1,ok:1}:{n:0,nModified:0,ok:1},n&&0===o.n&&(o=await v(t)),o})),r&&await f.write(),s.emit("change","save",t,o)}catch(t){r=!0,o=t}return r?Promise.reject(o):o},s.del=async function(t){let e=!1;if(!Kn(t)&&!Yn(t))return Promise.reject("data is not an effective object or array");t=gn(t);let r=null;try{Gn(t)||(t=[t]),await f.read();let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=[],o=!1;r=await Hn(t,(async t=>{let r=null,i=bt(t,"id","");if(Dn(i)){let t=bt(e,i,null);Kn(t)?(n.push(t.k),o=!0,r={n:1,nDeleted:1,ok:1}):r={n:1,nDeleted:0,ok:1}}else r={n:1,nDeleted:0,ok:0};return r})),o&&(f.data[a]=fo(f.data[a],n)),o&&await f.write(),s.emit("change","del",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},s.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{await f.read();let e=tn(f.data[a]),n=0,o=!1;if(Kn(t)){let r=new i.Query(t).find(f.data[a]).all();if(n=tn(r),0===n);else if(e===n)f.data[a]=[],o=!0;else{let t={};te(r,((e,r)=>{t[e.id]={k:r,v:e}}));let e=[];te(f.data[a],((r,n)=>{Zn(t,r.id)||e.push(r)})),f.data[a]=e,o=!0}}else n=e,f.data[a]=[],o=!0;o&&await f.write(),r={n:e,nDeleted:n,ok:1},s.emit("change","delAll",null,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},s}}));
|
|
6
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("events"),require("lowdb"),require("node:fs"),require("node:fs/promises"),require("node:path"),require("node:url"),require("mingo")):"function"==typeof define&&define.amd?define(["events","lowdb","node:fs","node:fs/promises","node:path","node:url","mingo"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-lowdb"]=e(t.events,t.lowdb,null,t.promises,t.path,t.node_url,t.mingo)}(this,(function(t,e,r,n,o,i,u){"use strict";class a{#t;#e;#r=!1;#n=null;#o=null;#i=null;#u=null;#a(t){return this.#u=t,this.#i||=new Promise(((t,e)=>{this.#o=[t,e]})),new Promise(((t,e)=>{var r;null===(r=this.#i)||void 0===r||r.then(t).catch(e)}))}async#c(t){this.#r=!0;try{var e;await n.writeFile(this.#e,t,"utf-8"),await async function(t,e,r){for(let n=0;n<e;n++)try{return await t()}catch(t){if(!(n<e-1))throw t;await new Promise((t=>setTimeout(t,r)))}}((async()=>{await n.rename(this.#e,this.#t)}),10,100),null===(e=this.#n)||void 0===e||e[0]()}catch(t){var r;if(t instanceof Error)null===(r=this.#n)||void 0===r||r[1](t);throw t}finally{if(this.#r=!1,this.#n=this.#o,this.#o=this.#i=null,null!==this.#u){const t=this.#u;this.#u=null,await this.write(t)}}}constructor(t){this.#t=t,this.#e=function(t){const e=t instanceof URL?i.fileURLToPath(t):t.toString();return o.join(o.dirname(e),`.${o.basename(e)}.tmp`)}(t)}async write(t){return this.#r?this.#a(t):this.#c(t)}}class c{#t;#f;constructor(t){this.#t=t,this.#f=new a(t)}async read(){let t;try{t=await n.readFile(this.#t,"utf-8")}catch(t){if("ENOENT"===t.code)return null;throw t}return t}write(t){return this.#f.write(t)}}class f{#l;#s;#v;constructor(t,e){let{parse:r,stringify:n}=e;this.#l=new c(t),this.#s=r,this.#v=n}async read(){const t=await this.#l.read();return null===t?null:this.#s(t)}write(t){return this.#l.write(this.#v(t))}}class l extends f{constructor(t){super(t,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}}var s=Array.isArray,v="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,d=v||p||Function("return this")(),h=d.Symbol,y=Object.prototype,b=y.hasOwnProperty,j=y.toString,g=h?h.toStringTag:void 0;var w=Object.prototype.toString;var _=h?h.toStringTag:void 0;function m(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=b.call(t,g),r=t[g];try{t[g]=void 0;var n=!0}catch(t){}var o=j.call(t);return n&&(e?t[g]=r:delete t[g]),o}(t):function(t){return w.call(t)}(t)}function O(t){return null!=t&&"object"==typeof t}function A(t){return"symbol"==typeof t||O(t)&&"[object Symbol]"==m(t)}var x=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/;function P(t,e){if(s(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!A(t))||(S.test(t)||!x.test(t)||null!=e&&t in Object(e))}function k(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function z(t){if(!k(t))return!1;var e=m(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var F,E=d["__core-js_shared__"],I=(F=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+F:"";var D=Function.prototype.toString;function N(t){if(null!=t){try{return D.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var M=/^\[object .+?Constructor\]$/,U=Function.prototype,$=Object.prototype,T=U.toString,B=$.hasOwnProperty,L=RegExp("^"+T.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function R(t){return!(!k(t)||(e=t,I&&I in e))&&(z(t)?L:M).test(N(t));var e}function q(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return R(r)?r:void 0}var C=q(Object,"create");var V=Object.prototype.hasOwnProperty;var W=Object.prototype.hasOwnProperty;function G(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 J(t,e){return t===e||t!=t&&e!=e}function Q(t,e){for(var r=t.length;r--;)if(J(t[r][0],e))return r;return-1}G.prototype.clear=function(){this.__data__=C?C(null):{},this.size=0},G.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},G.prototype.get=function(t){var e=this.__data__;if(C){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return V.call(e,t)?e[t]:void 0},G.prototype.has=function(t){var e=this.__data__;return C?void 0!==e[t]:W.call(e,t)},G.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=C&&void 0===e?"__lodash_hash_undefined__":e,this};var H=Array.prototype.splice;function K(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])}}K.prototype.clear=function(){this.__data__=[],this.size=0},K.prototype.delete=function(t){var e=this.__data__,r=Q(e,t);return!(r<0)&&(r==e.length-1?e.pop():H.call(e,r,1),--this.size,!0)},K.prototype.get=function(t){var e=this.__data__,r=Q(e,t);return r<0?void 0:e[r][1]},K.prototype.has=function(t){return Q(this.__data__,t)>-1},K.prototype.set=function(t,e){var r=this.__data__,n=Q(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var X=q(d,"Map");function Y(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 Z(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])}}Z.prototype.clear=function(){this.size=0,this.__data__={hash:new G,map:new(X||K),string:new G}},Z.prototype.delete=function(t){var e=Y(this,t).delete(t);return this.size-=e?1:0,e},Z.prototype.get=function(t){return Y(this,t).get(t)},Z.prototype.has=function(t){return Y(this,t).has(t)},Z.prototype.set=function(t,e){var r=Y(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function tt(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],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(tt.Cache||Z),r}tt.Cache=Z;var et,rt,nt,ot=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/\\(\\)?/g,ut=(et=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ot,(function(t,r,n,o){e.push(n?o.replace(it,"$1"):r||t)})),e},rt=tt(et,(function(t){return 500===nt.size&&nt.clear(),t})),nt=rt.cache,rt),at=ut;function ct(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 ft=h?h.prototype:void 0,lt=ft?ft.toString:void 0;function st(t){if("string"==typeof t)return t;if(s(t))return ct(t,st)+"";if(A(t))return lt?lt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function vt(t){return null==t?"":st(t)}function pt(t,e){return s(t)?t:P(t,e)?[t]:at(vt(t))}function dt(t){if("string"==typeof t||A(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=pt(e,t)).length;null!=t&&r<n;)t=t[dt(e[r++])];return r&&r==n?t:void 0}function yt(t,e,r){var n=null==t?void 0:ht(t,e);return void 0===n?r:n}function bt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var jt,gt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var a=i[jt?u:++n];if(!1===e(o[a],a,o))break}return t};function wt(t){return O(t)&&"[object Arguments]"==m(t)}var _t=Object.prototype,mt=_t.hasOwnProperty,Ot=_t.propertyIsEnumerable,At=wt(function(){return arguments}())?wt:function(t){return O(t)&&mt.call(t,"callee")&&!Ot.call(t,"callee")},xt=At;var St="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pt=St&&"object"==typeof module&&module&&!module.nodeType&&module,kt=Pt&&Pt.exports===St?d.Buffer:void 0,zt=(kt?kt.isBuffer:void 0)||function(){return!1},Ft=/^(?:0|[1-9]\d*)$/;function Et(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Ft.test(t))&&t>-1&&t%1==0&&t<e}function It(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Dt={};function Nt(t){return function(e){return t(e)}}Dt["[object Float32Array]"]=Dt["[object Float64Array]"]=Dt["[object Int8Array]"]=Dt["[object Int16Array]"]=Dt["[object Int32Array]"]=Dt["[object Uint8Array]"]=Dt["[object Uint8ClampedArray]"]=Dt["[object Uint16Array]"]=Dt["[object Uint32Array]"]=!0,Dt["[object Arguments]"]=Dt["[object Array]"]=Dt["[object ArrayBuffer]"]=Dt["[object Boolean]"]=Dt["[object DataView]"]=Dt["[object Date]"]=Dt["[object Error]"]=Dt["[object Function]"]=Dt["[object Map]"]=Dt["[object Number]"]=Dt["[object Object]"]=Dt["[object RegExp]"]=Dt["[object Set]"]=Dt["[object String]"]=Dt["[object WeakMap]"]=!1;var Mt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ut=Mt&&"object"==typeof module&&module&&!module.nodeType&&module,$t=Ut&&Ut.exports===Mt&&v.process,Tt=function(){try{var t=Ut&&Ut.require&&Ut.require("util").types;return t||$t&&$t.binding&&$t.binding("util")}catch(t){}}(),Bt=Tt&&Tt.isTypedArray,Lt=Bt?Nt(Bt):function(t){return O(t)&&It(t.length)&&!!Dt[m(t)]},Rt=Object.prototype.hasOwnProperty;function qt(t,e){var r=s(t),n=!r&&xt(t),o=!r&&!n&&zt(t),i=!r&&!n&&!o&&Lt(t),u=r||n||o||i,a=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var f in t)!e&&!Rt.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||Et(f,c))||a.push(f);return a}var Ct=Object.prototype;function Vt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ct)}function Wt(t,e){return function(r){return t(e(r))}}var Gt=Wt(Object.keys,Object),Jt=Object.prototype.hasOwnProperty;function Qt(t){if(!Vt(t))return Gt(t);var e=[];for(var r in Object(t))Jt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Ht(t){return null!=t&&It(t.length)&&!z(t)}function Kt(t){return Ht(t)?qt(t):Qt(t)}var Xt=function(t,e){return function(r,n){if(null==r)return r;if(!Ht(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}((function(t,e){return t&>(t,e,Kt)})),Yt=Xt;function Zt(t){return t}function te(t,e){var r;return(s(t)?bt:Yt)(t,"function"==typeof(r=e)?r:Zt)}function ee(t){var e=this.__data__=new K(t);this.size=e.size}ee.prototype.clear=function(){this.__data__=new K,this.size=0},ee.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ee.prototype.get=function(t){return this.__data__.get(t)},ee.prototype.has=function(t){return this.__data__.has(t)},ee.prototype.set=function(t,e){var r=this.__data__;if(r instanceof K){var n=r.__data__;if(!X||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Z(n)}return r.set(t,e),this.size=r.size,this};function re(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Z;++e<r;)this.add(t[e])}function ne(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 oe(t,e){return t.has(e)}re.prototype.add=re.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},re.prototype.has=function(t){return this.__data__.has(t)};function ie(t,e,r,n,o,i){var u=1&r,a=t.length,c=e.length;if(a!=c&&!(u&&c>a))return!1;var f=i.get(t),l=i.get(e);if(f&&l)return f==e&&l==t;var s=-1,v=!0,p=2&r?new re:void 0;for(i.set(t,e),i.set(e,t);++s<a;){var d=t[s],h=e[s];if(n)var y=u?n(h,d,s,e,t,i):n(d,h,s,t,e,i);if(void 0!==y){if(y)continue;v=!1;break}if(p){if(!ne(e,(function(t,e){if(!oe(p,e)&&(d===t||o(d,t,r,n,i)))return p.push(e)}))){v=!1;break}}else if(d!==h&&!o(d,h,r,n,i)){v=!1;break}}return i.delete(t),i.delete(e),v}var ue=d.Uint8Array;function ae(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function ce(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var fe=h?h.prototype:void 0,le=fe?fe.valueOf:void 0;function se(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function ve(t,e,r){var n=e(t);return s(t)?n:se(n,r(t))}function pe(){return[]}var de=Object.prototype.propertyIsEnumerable,he=Object.getOwnPropertySymbols,ye=he?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}(he(t),(function(e){return de.call(t,e)})))}:pe,be=ye;function je(t){return ve(t,Kt,be)}var ge=Object.prototype.hasOwnProperty;var we=q(d,"DataView"),_e=q(d,"Promise"),me=q(d,"Set"),Oe=q(d,"WeakMap"),Ae="[object Map]",xe="[object Promise]",Se="[object Set]",Pe="[object WeakMap]",ke="[object DataView]",ze=N(we),Fe=N(X),Ee=N(_e),Ie=N(me),De=N(Oe),Ne=m;(we&&Ne(new we(new ArrayBuffer(1)))!=ke||X&&Ne(new X)!=Ae||_e&&Ne(_e.resolve())!=xe||me&&Ne(new me)!=Se||Oe&&Ne(new Oe)!=Pe)&&(Ne=function(t){var e=m(t),r="[object Object]"==e?t.constructor:void 0,n=r?N(r):"";if(n)switch(n){case ze:return ke;case Fe:return Ae;case Ee:return xe;case Ie:return Se;case De:return Pe}return e});var Me=Ne,Ue="[object Arguments]",$e="[object Array]",Te="[object Object]",Be=Object.prototype.hasOwnProperty;function Le(t,e,r,n,o,i){var u=s(t),a=s(e),c=u?$e:Me(t),f=a?$e:Me(e),l=(c=c==Ue?Te:c)==Te,v=(f=f==Ue?Te:f)==Te,p=c==f;if(p&&zt(t)){if(!zt(e))return!1;u=!0,l=!1}if(p&&!l)return i||(i=new ee),u||Lt(t)?ie(t,e,r,n,o,i):function(t,e,r,n,o,i,u){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||!i(new ue(t),new ue(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return J(+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 a=ae;case"[object Set]":var c=1&n;if(a||(a=ce),t.size!=e.size&&!c)return!1;var f=u.get(t);if(f)return f==e;n|=2,u.set(t,e);var l=ie(a(t),a(e),n,o,i,u);return u.delete(t),l;case"[object Symbol]":if(le)return le.call(t)==le.call(e)}return!1}(t,e,c,r,n,o,i);if(!(1&r)){var d=l&&Be.call(t,"__wrapped__"),h=v&&Be.call(e,"__wrapped__");if(d||h){var y=d?t.value():t,b=h?e.value():e;return i||(i=new ee),o(y,b,r,n,i)}}return!!p&&(i||(i=new ee),function(t,e,r,n,o,i){var u=1&r,a=je(t),c=a.length;if(c!=je(e).length&&!u)return!1;for(var f=c;f--;){var l=a[f];if(!(u?l in e:ge.call(e,l)))return!1}var s=i.get(t),v=i.get(e);if(s&&v)return s==e&&v==t;var p=!0;i.set(t,e),i.set(e,t);for(var d=u;++f<c;){var h=t[l=a[f]],y=e[l];if(n)var b=u?n(y,h,l,e,t,i):n(h,y,l,t,e,i);if(!(void 0===b?h===y||o(h,y,r,n,i):b)){p=!1;break}d||(d="constructor"==l)}if(p&&!d){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||(p=!1)}return i.delete(t),i.delete(e),p}(t,e,r,n,o,i))}function Re(t,e,r,n,o){return t===e||(null==t||null==e||!O(t)&&!O(e)?t!=t&&e!=e:Le(t,e,r,n,Re,o))}function qe(t){return t==t&&!k(t)}function Ce(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Ve(t){var e=function(t){for(var e=Kt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,qe(o)]}return e}(t);return 1==e.length&&e[0][2]?Ce(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=r[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){var c=(a=r[o])[0],f=t[c],l=a[1];if(u&&a[2]){if(void 0===f&&!(c in t))return!1}else{var s=new ee;if(n)var v=n(f,l,c,t,e,s);if(!(void 0===v?Re(l,f,3,n,s):v))return!1}}return!0}(r,t,e)}}function We(t,e){return null!=t&&e in Object(t)}function Ge(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=pt(e,t)).length,i=!1;++n<o;){var u=dt(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&It(o)&&Et(u,o)&&(s(t)||xt(t))}(t,e,We)}function Je(t){return function(e){return null==e?void 0:e[t]}}function Qe(t){return P(t)?Je(dt(t)):function(t){return function(e){return ht(e,t)}}(t)}function He(t){return"function"==typeof t?t:null==t?Zt:"object"==typeof t?s(t)?function(t,e){return P(t)&&qe(e)?Ce(dt(t),e):function(r){var n=yt(r,t);return void 0===n&&n===e?Ge(r,t):Re(e,n,3)}}(t[0],t[1]):Ve(t):Qe(t)}function Ke(t,e){var r=-1,n=Ht(t)?Array(t.length):[];return Yt(t,(function(t,o,i){n[++r]=e(t,o,i)})),n}function Xe(t,e){return(s(t)?ct:Ke)(t,He(e))}var Ye=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ze=Ye;function tr(t,e,r){"__proto__"==e&&Ze?Ze(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function er(t,e,r){(void 0!==r&&!J(t[e],r)||void 0===r&&!(e in t))&&tr(t,e,r)}var rr="object"==typeof exports&&exports&&!exports.nodeType&&exports,nr=rr&&"object"==typeof module&&module&&!module.nodeType&&module,or=nr&&nr.exports===rr?d.Buffer:void 0,ir=or?or.allocUnsafe:void 0;function ur(t,e){if(e)return t.slice();var r=t.length,n=ir?ir(r):new t.constructor(r);return t.copy(n),n}function ar(t){var e=new t.constructor(t.byteLength);return new ue(e).set(new ue(t)),e}function cr(t,e){var r=e?ar(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function fr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var lr=Object.create,sr=function(){function t(){}return function(e){if(!k(e))return{};if(lr)return lr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),vr=sr,pr=Wt(Object.getPrototypeOf,Object);function dr(t){return"function"!=typeof t.constructor||Vt(t)?{}:vr(pr(t))}var hr=Function.prototype,yr=Object.prototype,br=hr.toString,jr=yr.hasOwnProperty,gr=br.call(Object);function wr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var _r=Object.prototype.hasOwnProperty;function mr(t,e,r){var n=t[e];_r.call(t,e)&&J(n,r)&&(void 0!==r||e in t)||tr(t,e,r)}function Or(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?tr(r,a,c):mr(r,a,c)}return r}var Ar=Object.prototype.hasOwnProperty;function xr(t){if(!k(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Vt(t),r=[];for(var n in t)("constructor"!=n||!e&&Ar.call(t,n))&&r.push(n);return r}function Sr(t){return Ht(t)?qt(t,!0):xr(t)}function Pr(t,e,r,n,o,i,u){var a=wr(t,r),c=wr(e,r),f=u.get(c);if(f)er(t,r,f);else{var l,v=i?i(a,c,r+"",t,e,u):void 0,p=void 0===v;if(p){var d=s(c),h=!d&&zt(c),y=!d&&!h&&Lt(c);v=c,d||h||y?s(a)?v=a:O(l=a)&&Ht(l)?v=fr(a):h?(p=!1,v=ur(c,!0)):y?(p=!1,v=cr(c,!0)):v=[]:function(t){if(!O(t)||"[object Object]"!=m(t))return!1;var e=pr(t);if(null===e)return!0;var r=jr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&br.call(r)==gr}(c)||xt(c)?(v=a,xt(a)?v=function(t){return Or(t,Sr(t))}(a):k(a)&&!z(a)||(v=dr(c))):p=!1}p&&(u.set(c,v),o(v,c,n,i,u),u.delete(c)),er(t,r,v)}}function kr(t,e,r,n,o){t!==e&>(e,(function(i,u){if(o||(o=new ee),k(i))Pr(t,e,u,r,kr,n,o);else{var a=n?n(wr(t,u),i,u+"",t,e,o):void 0;void 0===a&&(a=i),er(t,u,a)}}),Sr)}var zr=Math.max;function Fr(t,e,r){return e=zr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=zr(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(u),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,a)}}var Er=Ze?function(t,e){return Ze(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:Zt,Ir=Er,Dr=Date.now;var Nr=function(t){var e=0,r=0;return function(){var n=Dr(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Ir),Mr=Nr;var Ur,$r=(Ur=function(t,e,r){kr(t,e,r)},function(t,e){return Mr(Fr(t,e,Zt),t+"")}((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ur.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!k(r))return!1;var n=typeof e;return!!("number"==n?Ht(r)&&Et(e,r.length):"string"==n&&e in r)&&J(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&Ur(t,u,r,o)}return t}))),Tr=$r;var Br=Je("length"),Lr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Rr="\\ud800-\\udfff",qr="["+Rr+"]",Cr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Vr="\\ud83c[\\udffb-\\udfff]",Wr="[^"+Rr+"]",Gr="(?:\\ud83c[\\udde6-\\uddff]){2}",Jr="[\\ud800-\\udbff][\\udc00-\\udfff]",Qr="(?:"+Cr+"|"+Vr+")"+"?",Hr="[\\ufe0e\\ufe0f]?",Kr=Hr+Qr+("(?:\\u200d(?:"+[Wr,Gr,Jr].join("|")+")"+Hr+Qr+")*"),Xr="(?:"+[Wr+Cr+"?",Cr,Gr,Jr,qr].join("|")+")",Yr=RegExp(Vr+"(?="+Vr+")|"+Xr+Kr,"g");function Zr(t){return function(t){return Lr.test(t)}(t)?function(t){for(var e=Yr.lastIndex=0;Yr.test(t);)++e;return e}(t):Br(t)}function tn(t){if(null==t)return 0;if(Ht(t))return"string"==typeof(e=t)||!s(e)&&O(e)&&"[object String]"==m(e)?Zr(t):t.length;var e,r=Me(t);return"[object Map]"==r||"[object Set]"==r?t.size:Qt(t).length}var en=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)se(e,be(t)),t=pr(t);return e}:pe,rn=en;function nn(t){return ve(t,Sr,rn)}var on=Object.prototype.hasOwnProperty;var un=/\w*$/;var an=h?h.prototype:void 0,cn=an?an.valueOf:void 0;function fn(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return ar(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?ar(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 cr(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,un.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,cn?Object(cn.call(n)):{}}}var ln=Tt&&Tt.isMap,sn=ln?Nt(ln):function(t){return O(t)&&"[object Map]"==Me(t)};var vn=Tt&&Tt.isSet,pn=vn?Nt(vn):function(t){return O(t)&&"[object Set]"==Me(t)},dn="[object Arguments]",hn="[object Function]",yn="[object Object]",bn={};function jn(t,e,r,n,o,i){var u,a=1&e,c=2&e,f=4&e;if(r&&(u=o?r(t,n,o,i):r(t)),void 0!==u)return u;if(!k(t))return t;var l=s(t);if(l){if(u=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&on.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return fr(t,u)}else{var v=Me(t),p=v==hn||"[object GeneratorFunction]"==v;if(zt(t))return ur(t,a);if(v==yn||v==dn||p&&!o){if(u=c||p?{}:dr(t),!a)return c?function(t,e){return Or(t,rn(t),e)}(t,function(t,e){return t&&Or(e,Sr(e),t)}(u,t)):function(t,e){return Or(t,be(t),e)}(t,function(t,e){return t&&Or(e,Kt(e),t)}(u,t))}else{if(!bn[v])return o?t:{};u=fn(t,v,a)}}i||(i=new ee);var d=i.get(t);if(d)return d;i.set(t,u),pn(t)?t.forEach((function(n){u.add(jn(n,e,r,n,t,i))})):sn(t)&&t.forEach((function(n,o){u.set(o,jn(n,e,r,o,t,i))}));var h=l?void 0:(f?c?nn:je:c?Sr:Kt)(t);return bt(h||t,(function(n,o){h&&(n=t[o=n]),mr(u,o,jn(n,e,r,o,t,i))})),u}bn[dn]=bn["[object Array]"]=bn["[object ArrayBuffer]"]=bn["[object DataView]"]=bn["[object Boolean]"]=bn["[object Date]"]=bn["[object Float32Array]"]=bn["[object Float64Array]"]=bn["[object Int8Array]"]=bn["[object Int16Array]"]=bn["[object Int32Array]"]=bn["[object Map]"]=bn["[object Number]"]=bn[yn]=bn["[object RegExp]"]=bn["[object Set]"]=bn["[object String]"]=bn["[object Symbol]"]=bn["[object Uint8Array]"]=bn["[object Uint8ClampedArray]"]=bn["[object Uint16Array]"]=bn["[object Uint32Array]"]=!0,bn["[object Error]"]=bn[hn]=bn["[object WeakMap]"]=!1;function gn(t){return jn(t,5)}var wn=/\s/;var _n=/^\s+/;function mn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&wn.test(t.charAt(e)););return e}(t)+1).replace(_n,""):t}var On=/^[-+]0x[0-9a-f]+$/i,An=/^0b[01]+$/i,xn=/^0o[0-7]+$/i,Sn=parseInt;function Pn(t){if("number"==typeof t)return t;if(A(t))return NaN;if(k(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=k(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=mn(t);var r=An.test(t);return r||xn.test(t)?Sn(t.slice(2),r?2:8):On.test(t)?NaN:+t}var kn=1/0;function zn(t){return t?(t=Pn(t))===kn||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function Fn(t){var e=zn(t),r=e%1;return e==e?r?e-r:e:0}function En(t){return"[object String]"===Object.prototype.toString.call(t)}function In(t){return!(!En(t)||""===t)}function Dn(t){return t!=t}function Nn(t){let e=!1;if(In(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Dn(t))return!1;e=!0}return e}function Mn(t){if(!Nn(t))return 0;return zn(t)}function Un(t){return!!Nn(t)&&(t=Mn(t),"number"==typeof(e=t)&&e==Fn(e));var e}var $n=d.isFinite,Tn=Math.min;var Bn=function(t){var e=Math[t];return function(t,r){if(t=Pn(t),(r=null==r?0:Tn(Fn(r),292))&&$n(t)){var n=(vt(t)+"e").split("e");return+((n=(vt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Ln=Bn;function Rn(t){if(!Nn(t))return 0;t=Mn(t);let e=Ln(t);return"0"===String(e)?0:e}function qn(t){if(!Un(t))return!1;return Rn(t)>0}let Cn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Vn=Cn.length;function Wn(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];t=qn(t)?Rn(t):32;for(let r=0;r<t;r++)e[r]=Cn[0|Math.random()*Vn];return e.join("")}function Gn(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 i=Array(o);++n<o;)i[n]=t[n+e];return i}function Jn(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}function Qn(t){return"[object Array]"===Object.prototype.toString.call(t)}function Hn(t){return"[object Object]"===Object.prototype.toString.call(t)}function Kn(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function Xn(t,e){let r=Jn();if(!Qn(t)&&!Hn(t))return r.reject("rs is not an array or object"),r;let n=!1;if(Hn(t)){n=!0;let e=[];te(t,((t,r)=>{e.push({k:r,v:t})})),t=e}Kn(e)||(e=function(t){return t});let o=-1,i=[];return t.reduce((function(t,r){return t.then((function(t){i.push(t),o+=1;let u=o,a=r;return n&&(u=r.k,a=r.v),Kn(e)?e(a,u):a}))}),Promise.resolve()).then((function(t){var e,n,o,u;i.push(t),u=null==(e=i)?0:e.length,i=u?Gn(e,(n=o||void 0===n?1:Fn(n))<0?0:n,u):[],r.resolve(i)})).catch((function(t){r.reject(t)})),r}function Yn(t){if(Hn(t)){for(let e in t)return!0;return!1}return!1}function Zn(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(Hn(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!En(t)||""!==t)}(t)||(!!function(t){return!!Qn(t)&&0===t.length}(t)||!!Dn(t)))))}function to(t){return!!Qn(t)&&(0!==t.length&&(1!==t.length||!Zn(t[0])))}function eo(t,e){return!!Hn(t)&&(!(!In(e)&&!Nn(e))&&e in t)}function ro(t,e){return null==(t=function(t,e){return e.length<2?t:ht(t,Gn(e,0,-1))}(t,e=pt(e,t)))||delete t[dt((r=e,n=null==r?0:r.length,n?r[n-1]:void 0))];var r,n}var no=Array.prototype.splice;function oo(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=A(t),u=void 0!==e,a=null===e,c=e==e,f=A(e);if(!a&&!f&&!i&&t>e||i&&u&&c&&!a&&!f||n&&u&&c||!r&&c||!o)return 1;if(!n&&!i&&!f&&t<e||f&&r&&o&&!n&&!i||a&&r&&o||!u&&o||!c)return-1}return 0}var io=h?h.isConcatSpreadable:void 0;function uo(t){return s(t)||xt(t)||!!(io&&t&&t[io])}function ao(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=uo),o||(o=[]);++i<u;){var a=t[i];e>0&&r(a)?e>1?ao(a,e-1,r,n,o):se(o,a):n||(o[o.length]=a)}return o}function co(t){return(null==t?0:t.length)?ao(t,1):[]}var fo=function(t){return Mr(Fr(t,void 0,co),t+"")}((function(t,e){var r=null==t?0:t.length,n=function(t,e){for(var r=-1,n=e.length,o=Array(n),i=null==t;++r<n;)o[r]=i?void 0:yt(t,e[r]);return o}(t,e);return function(t,e){for(var r=t?e.length:0,n=r-1;r--;){var o=e[r];if(r==n||o!==i){var i=o;Et(o)?no.call(t,o,1):ro(t,o)}}}(t,ct(e,(function(t){return Et(t,r)?+t:t})).sort(oo)),n})),lo=fo;function so(t,e){if(!to(t))return[];var r;if(Un(r=e)&&Rn(r)>=0&&(e=[e]),!to(e))return t;e=Xe(e,(t=>Rn(t)));let n=gn(t);return lo(n,e),n}async function vo(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,n=Jn();if(!Kn(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 i=yt(e,"attemptNum",null);qn(i)||(i=200);let u=yt(e,"timeInterval",null);qn(u)||(u=1e3);let a=0,c=setInterval((async()=>{a+=1,r=await o(),!0===r&&(clearInterval(c),n.resolve()),a>i&&(clearInterval(c),n.reject(`exceeded attemptNum[${i}]`))}),u);return n}let po=!1;return function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=yt(r,"url");In(n)||(n="./db.json");let o=yt(r,"db");In(o)||(o="worm");let i=yt(r,"cl");In(i)||(i="test");let a=`${o}:${i}`,c=new l(n),f=new e.Low(c,{}),s=new t.EventEmitter;async function v(t){let e=!1;if(!Yn(t)&&!to(t))return Promise.reject("data is not an effective object or array");t=gn(t);let r=null;try{Qn(t)||(t=[t]),t=Xe(t,(function(t){return In(t.id)||(t.id=Wn()),t})),await f.read(),eo(f.data,a)||(f.data[a]=[]);let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=tn(t),o=0,i=!1;te(t,(t=>{eo(e,t.id)||(f.data[a].push(t),o++,i=!0)})),i&&await f.write(),r={n:n,nInserted:o,ok:1},s.emit("change","insert",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}async function p(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!1;if(!Yn(t)&&!to(t))return Promise.reject("data is not an effective object or array");t=gn(t);let n=yt(e,"autoInsert",!0),o=null;try{Qn(t)||(t=[t]),t=Xe(t,(function(t){return In(t.id)||(t.id=Wn()),t})),await f.read(),eo(f.data,a)||(f.data[a]=[]);let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let r=!1;o=await Xn(t,(async t=>{let o=null,i=yt(e,t.id,null);var u,c;return Yn(i)&&(u=t,c=i.v,Re(u,c)||(f.data[a][i.k]=Tr(f.data[a][i.k],t),o={update:!0},r=!0)),o=Yn(o)?{n:1,nModified:1,ok:1}:{n:0,nModified:0,ok:1},n&&0===o.n&&(o=await v(t)),o})),r&&await f.write(),s.emit("change","save",t,o)}catch(t){r=!0,o=t}return r?Promise.reject(o):o}return s.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return po&&await vo((()=>!po)),po=!0,await async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{await f.read(),eo(f.data,a)||(f.data[a]=[]),r=Yn(t)?new u.Query(t).find(f.data[a]).all():f.data[a]}catch(t){e=!0,r=t}return e?Promise.reject(r):r}(t).finally((()=>{po=!1}))},s.insert=async function(t){return po&&await vo((()=>!po)),po=!0,await v(t).finally((()=>{po=!1}))},s.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return po&&await vo((()=>!po)),po=!0,await p(t,e).finally((()=>{po=!1}))},s.del=async function(t){return po&&await vo((()=>!po)),po=!0,await async function(t){let e=!1;if(!Yn(t)&&!to(t))return Promise.reject("data is not an effective object or array");t=gn(t);let r=null;try{Qn(t)||(t=[t]),await f.read(),eo(f.data,a)||(f.data[a]=[]);let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=[],o=!1;r=await Xn(t,(async t=>{let r=null,i=yt(t,"id","");if(In(i)){let t=yt(e,i,null);Yn(t)?(n.push(t.k),o=!0,r={n:1,nDeleted:1,ok:1}):r={n:1,nDeleted:0,ok:1}}else r={n:1,nDeleted:0,ok:0};return r})),o&&(f.data[a]=so(f.data[a],n)),o&&await f.write(),s.emit("change","del",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}(t).finally((()=>{po=!1}))},s.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return po&&await vo((()=>!po)),po=!0,await async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{await f.read(),eo(f.data,a)||(f.data[a]=[]);let e=tn(f.data[a]),n=0,o=!1;if(Yn(t)){let r=new u.Query(t).find(f.data[a]).all();if(n=tn(r),0===n);else if(e===n)f.data[a]=[],o=!0;else{let t={};te(r,((e,r)=>{t[e.id]={k:r,v:e}}));let e=[];te(f.data[a],((r,n)=>{eo(t,r.id)||e.push(r)})),f.data[a]=e,o=!0}}else n=e,f.data[a]=[],o=!0;o&&await f.write(),r={n:e,nDeleted:n,ok:1},s.emit("change","delAll",null,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}(t).finally((()=>{po=!1}))},s}}));
|
|
7
7
|
//# sourceMappingURL=w-orm-lowdb.umd.js.map
|