insite-config 2.2.0 → 2.2.1
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/dist/index.js +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function I(){}function M(o,c=0,l={}){let{leading:r=!1,trailing:s=!0}=l,{maxWait:f=1/0}=l,p,h,y,e,i,n,t,u,a=async()=>{let w=Date.now();w>=y?(p=void 0,y=void 0,clearTimeout(h),typeof t=="function"&&await t(),m.resolve(u),m.promise.isResolved=!0,n=r):(clearTimeout(p),p=setTimeout(a,y-w))},x=Number.isFinite(f)?()=>{t===g&&(t=!1),g(),h=setTimeout(x,f)}:null;async function g(){return u=await o.apply(e,i)}r&&typeof r=="boolean"&&(r=g),n=r,s&&typeof s=="boolean"&&(s=g),t=s;let m=Object.assign(function(...w){return i=w,e=this,y=Date.now()+c,t=s,m.promise.isResolved&&(m.promise=Object.assign(new Promise(k=>{m.resolve=k,typeof n=="function"&&(n(),n=!1,t===g&&(t=!1)),p||(p=setTimeout(a,c),x&&(h=setTimeout(x,f)))}),{isResolved:!1})),m.promise},{callback:o,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:I,run:g,clear:async w=>{clearTimeout(p),p=void 0,clearTimeout(h),m.promise.isResolved=!0,m.resolve(w?await g():u)}});return m}M.noop=Object.assign(()=>{},{callback:I,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:I,run:I,clear:I});function O(o){for(let c in o)return!1;return!0}function C(o,c,l,r,s=!0){return Array.isArray(o)&&(o=o.length),typeof r!="string"&&(s=r??!0,r=l),(s?`${o}\xA0`:"")+C.raw(o,c,l,r)}C.raw=(o,c,l,r=l)=>{o=Math.abs(o);let s=o%10,f=o%100;return s===1&&f!==11?c:s>=2&&s<=4&&!(f>=12&&f<=15)?l:r};function b(o,c){let l={};for(let r of c)r in o&&(l[r]=o[r]);return l}function j(o){return Object.entries(o)}function T(o){return Object.fromEntries(o)}var d="_u",v=Symbol("updatedAt");var S=class extends Error{constructor(c){super(`Unknown Config item "${c}"`)}name="UnknownConfigItemError"},$;async function wo(o,c,l){if(!$){let r=new Map,s=await o.ensure("config",l),f={addListener(e,i,n){let t=this[e];if(t)n&&i.call(t,t,{...t}),r.get(t)?.add(i)??r.set(t,new Set([i]));else throw new S(e)},removeListener(e,i){let n=this[e];if(n)r.get(n)?.delete(i);else throw new S(e)},async update(e,{[v]:i,...n}){let t=this[e];if(d in n&&delete n[d],t){if(!O(n)&&(!i||t[d]<i)){let u={};for(let[a,x]of Object.entries(n))a in t&&t[a]!==x&&(u[a]=x);if(!O(u)){i||(Object.assign(u,{[d]:Date.now()}),s.updateOne({_id:e},{$set:u}));let a=b(t,Object.keys(u));Object.assign(t,u);for(let x of r.get(t)??[])await x.call(t,u,a)}}return t}throw new S(e)}};f.on=f.addListener,f.off=f.removeListener,$=f;let p=new Map((await s.find().toArray()).map(({_id:e,...i})=>[e,i])),h=new Map,y=Date.now();for(let[e,i]of Object.entries(c)){let n=p.get(e),t={...T(j(i).map(([u,a])=>[u,n?.[u]??a])),[d]:n?.[d]??y};f[e]=t,h.set(e,t)}await s.bulkWrite([...[...h].map(([e,i])=>({replaceOne:{filter:{_id:e},replacement:{_id:e,...i},upsert:!0}})),...[...p.keys()].filter(e=>!c[e]).map(e=>({deleteOne:{filter:{_id:e}}}))]),s.onChange(e=>{switch(e.operationType){case"update":case"replace":{let{_id:i,[d]:n=Date.now(),...t}=e.operationType==="replace"?e.fullDocument:e.updateDescription.updatedFields;f.update(e.documentKey._id,{...t,[v]:n})}}})}return $}export{S as UnknownConfigItemError,wo as init};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insite-config",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "inSite config",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
|
-
"packageManager": "bun@1.2.
|
|
8
|
+
"packageManager": "bun@1.2.5",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
11
|
"build": "bun .conveyer.js",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nesvet/n": "^1.1.
|
|
26
|
-
"insite-db": "^2.2.
|
|
25
|
+
"@nesvet/n": "^1.1.26",
|
|
26
|
+
"insite-db": "^2.2.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@nesvet/conveyer": "^2.
|
|
29
|
+
"@nesvet/conveyer": "^2.5.0",
|
|
30
30
|
"@nesvet/eslint-config": "^2.0.48",
|
|
31
|
-
"@types/node": "^22.13.
|
|
32
|
-
"typescript": "^5.
|
|
31
|
+
"@types/node": "^22.13.10",
|
|
32
|
+
"typescript": "^5.8.2"
|
|
33
33
|
}
|
|
34
34
|
}
|