mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-20 08:52:59 +00:00
2 lines
999 B
JavaScript
2 lines
999 B
JavaScript
import{y as b,a5 as w,z as m,s as q,M as z}from "./scheduler.f5cfe514.js";const a=[];function x(s, u){return{subscribe:A(s,u).subscribe}}function A(s, u=b){let t;const r=new Set;function o(n){if(q(s,n)&&(s=n,t)){const i=!a.length;for(const e of r)e[1](),a.push(e,s);if(i){for(let e=0; e<a.length; e+=2)a[e][0](a[e+1]);a.length=0}}}function f(n){o(n(s))}function l(n, i=b){const e=[n,i];return r.add(e),r.size===1&&(t=u(o,f)||b),n(s),()=>{r.delete(e),r.size===0&&t&&(t(),t=null)}}return{set:o,update:f,subscribe:l}}function E(s, u, t){const r=!Array.isArray(s),o=r?[s]:s;if(!o.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const f=u.length<2;return x(t,(l, n)=>{let i=!1;const e=[];let d=0,p=b;const g=()=>{if(d)return;p();const c=u(r?e[0]:e,l,n);f?l(c):p=z(c)?c:b},h=o.map((c, y)=>w(c, _=>{e[y]=_,d&=~(1<<y),i&&g()},()=>{d|=1<<y}));return i=!0,g(),function(){m(h),p(),i=!1}})}function M(s){return{subscribe:s.subscribe.bind(s)}}export{E as d,M as r,A as w};
|