tinybase 1.0.4 → 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.
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),s=(e,t)=>e.every(((n,s)=>0==s||t(e[s-1],n)<=0)),o=(e,t)=>e.sort(t),d=(e,t)=>e.forEach(t),i=e=>e.length,r=e=>0==i(e),l=e=>e.slice(1),c=e=>null==e,a=(e,t,n)=>c(e)?n?.():t(e),f=(e,t)=>e?.has(t)??!1,u=e=>c(e)||0==(e=>e.size)(e),p=e=>e.clear(),g=(e,t)=>e?.forEach(t),h=(e,t)=>e?.delete(t),I=e=>new Map(e),y=e=>[...e?.keys()??[]],x=(e,t)=>e?.get(t),b=(e,t)=>g(e,((e,n)=>t(n,e))),w=(e,t,n)=>c(n)?(h(e,t),e):e?.set(t,n),S=(e,t,n,s)=>(f(e,t)||(s?.(n),e.set(t,n)),x(e,t)),v=e=>new Set(e),L=(e,t)=>e?.add(t),T=(e,s)=>t(e)==n?t=>t(e):e??(()=>s??""),R=(e,t)=>e<t?-1:1,j=(e,t,n)=>i(n)<2?L(r(n)?e:S(e,n[0],v()),t):j(S(e,n[0],I()),t,l(n)),M=e=>{const t=(n,s,...o)=>a(n,(n=>r(o)?e(n,s):d([o[0],null],(e=>t(x(n,e),s,...l(o))))));return t},k=Object.freeze,m=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=I(),n=I(),[r,l,S,m,z,D,E,O,_]=((e,t,n)=>{const s=e.hasRow,o=I(),i=I(),r=I(),l=I(),u=I(),h=t=>a(x(u,t),(n=>{g(n,e.delListener),w(u,t)})),S=e=>{w(o,e),w(i,e),w(r,e),w(l,e),h(e)};return[()=>e,()=>y(o),e=>f(i,e),e=>x(o,e),e=>x(i,e),(e,t)=>w(i,e,t),(a,y,S,L,T)=>{const R=I(),j=I();w(o,a,y),f(i,a)||(w(i,a,t()),w(r,a,I()),w(l,a,I()));const M=x(r,a),k=x(l,a),m=t=>{const o=n=>e.getCell(y,t,n),d=x(M,t),i=s(y,t)?n(L(o,t)):void 0;if(d!=i&&w(R,t,[d,i]),!c(T)){const e=x(k,t),n=s(y,t)?T(o,t):void 0;e!=n&&w(j,t,n)}},z=e=>{S((()=>{g(R,(([,e],t)=>w(M,t,e))),g(j,((e,t)=>w(k,t,e)))}),R,j,M,k,e),p(R),p(j)};b(M,m),e.hasTable(y)&&d(e.getRowIds(y),(e=>{f(M,e)||m(e)})),z(!0),h(a),w(u,a,v([e.addRowListener(y,null,((e,t,n)=>m(n))),e.addTableListener(y,(()=>z()))]))},S,()=>b(u,S)]})(e,I,(e=>c(e)?"":e+"")),[B,C,P]=(e=>{let t,n=0;const s=[],o=I();return[(d,i,r=[])=>{t??=e();const l=s.pop()??""+n++;return w(o,l,[d,i,r]),j(i,l,r),l},(e,n=[],...s)=>M(g)(e,(e=>a(x(o,e),(([e])=>e(t,...n,...s)))),...n),e=>a(x(o,e),(([,t,n])=>(M(h)(t,e,...n),w(o,e),i(s)<1e3&&s.push(e),n)),(()=>[])),(e,n,s)=>a(x(o,e),(([e,,o])=>{const r=(...l)=>{const a=i(l);a==i(o)?e(t,...l,...s(l)):c(o[a])?d(n[a](...l),(e=>r(...l,e))):r(...l,o[a])};r()}))]})((()=>W)),W={setIndexDefinition:(e,d,i,r,l,p=R)=>{const y=c(l)?void 0:([e],[t])=>l(e,t);return E(e,d,((d,i,l,S,T,R)=>{let j=0;const M=v(),k=v(),m=z(e);if(g(i,(([e,t],n)=>{c(e)||(L(M,e),a(x(m,e),(t=>{h(t,n),u(t)&&(w(m,e),j=1)}))),c(t)||(L(M,t),f(m,t)||(w(m,t,v()),j=1),L(x(m,t),n),c(r)||L(k,t))})),d(),u(T)||(R?b(m,(e=>L(k,e))):b(l,(e=>a(x(S,e),(e=>L(k,e))))),g(k,(e=>{const t=(t,n)=>p(x(T,t),x(T,n),e),n=[...x(m,e)];s(n,t)||(w(m,e,v(o(n,t))),L(M,e))}))),(j||R)&&!c(y)){const t=[...m];s(t,y)||(D(e,I(o(t,y))),j=1)}j&&C(t,[e]),g(M,(t=>C(n,[e,t])))}),T(i),a(r,T)),W},delIndexDefinition:e=>(O(e),W),getStore:r,getIndexIds:l,hasIndex:S,hasSlice:(e,t)=>f(z(e),t),getTableId:m,getSliceIds:e=>y(z(e)),getSliceRowIds:(e,t)=>[...x(z(e),t)?.values()??[]],addSliceIdsListener:(e,n)=>B(n,t,[e]),addSliceRowIdsListener:(e,t,s)=>B(s,n,[e,t]),delListener:e=>(P(e),W),destroy:_,getListenerStats:()=>({})};return k(W)}));e.createIndexes=m,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseIndexes={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),s=(e,t)=>e.every(((n,s)=>0==s||t(e[s-1],n)<=0)),o=(e,t)=>e.sort(t),d=(e,t)=>e.forEach(t),r=e=>e.length,i=e=>0==r(e),c=e=>e.slice(1),l=e=>null==e,a=(e,t,n)=>l(e)?n?.():t(e),f=(e,t)=>e?.has(t)??!1,u=e=>l(e)||0==(e=>e.size)(e),h=e=>e.clear(),p=(e,t)=>e?.forEach(t),I=(e,t)=>e?.delete(t),g=e=>new Map(e),x=e=>[...e?.keys()??[]],y=(e,t)=>e?.get(t),S=(e,t)=>p(e,((e,n)=>t(n,e))),b=(e,t,n)=>l(n)?(I(e,t),e):e?.set(t,n),w=(e,t,n,s)=>(f(e,t)||(s?.(n),e.set(t,n)),y(e,t)),v=e=>new Set(e),L=(e,t)=>e?.add(t),T=(e,s)=>t(e)==n?t=>t(e):e??(()=>s??""),E=(e,t)=>e<t?-1:1,R=(e,t,n)=>r(n)<2?L(i(n)?e:w(e,n[0],v()),t):R(w(e,n[0],g()),t,c(n)),j=e=>{const t=(n,s,...o)=>a(n,(n=>i(o)?e(n,s):d([o[0],null],(e=>t(y(n,e),s,...c(o))))));return t},M=Object.freeze,k=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=g(),n=g(),[i,c,w,k,m,z,C,D,O,_]=((e,t,n)=>{const s=e.hasRow,o=g(),r=g(),i=g(),c=g(),u=g(),I=t=>a(y(u,t),(n=>{p(n,e.delListener),b(u,t)})),w=e=>{b(o,e),b(r,e),b(i,e),b(c,e),I(e)};return[()=>e,()=>x(o),e=>S(r,e),e=>f(r,e),e=>y(o,e),e=>y(r,e),(e,t)=>b(r,e,t),(a,x,w,L,T)=>{const E=g(),R=g();b(o,a,x),f(r,a)||(b(r,a,t()),b(i,a,g()),b(c,a,g()));const j=y(i,a),M=y(c,a),k=t=>{const o=n=>e.getCell(x,t,n),d=y(j,t),r=s(x,t)?n(L(o,t)):void 0;if(d!=r&&b(E,t,[d,r]),!l(T)){const e=y(M,t),n=s(x,t)?T(o,t):void 0;e!=n&&b(R,t,n)}},m=e=>{w((()=>{p(E,(([,e],t)=>b(j,t,e))),p(R,((e,t)=>b(M,t,e)))}),E,R,j,M,e),h(E),h(R)};S(j,k),e.hasTable(x)&&d(e.getRowIds(x),(e=>{f(j,e)||k(e)})),m(!0),I(a),b(u,a,v([e.addRowListener(x,null,((e,t,n)=>k(n))),e.addTableListener(x,(()=>m()))]))},w,()=>S(u,w)]})(e,g,(e=>l(e)?"":e+"")),[B,P,W]=(e=>{let t,n=0;const s=[],o=g();return[(d,r,i=[])=>{t??=e();const c=s.pop()??""+n++;return b(o,c,[d,r,i]),R(r,c,i),c},(e,n=[],...s)=>j(p)(e,(e=>a(y(o,e),(([e])=>e(t,...n,...s)))),...n),e=>a(y(o,e),(([,t,n])=>(j(I)(t,e,...n),b(o,e),r(s)<1e3&&s.push(e),n)),(()=>[])),(e,n,s)=>a(y(o,e),(([e,,o])=>{const i=(...c)=>{const a=r(c);a==r(o)?e(t,...c,...s(c)):l(o[a])?d(n[a](...c),(e=>i(...c,e))):i(...c,o[a])};i()}))]})((()=>A)),q=(t,n,s)=>{const o=m(t);p(s,((t,s)=>n(s,(n=>p(t,(t=>n(t,(n=>e.forEachCell(o,t,n)))))))))},A={setIndexDefinition:(e,d,r,i,c,h=E)=>{const x=l(c)?void 0:([e],[t])=>c(e,t);return D(e,d,((d,r,c,w,T,E)=>{let R=0;const j=v(),M=v(),k=z(e);if(p(r,(([e,t],n)=>{l(e)||(L(j,e),a(y(k,e),(t=>{I(t,n),u(t)&&(b(k,e),R=1)}))),l(t)||(L(j,t),f(k,t)||(b(k,t,v()),R=1),L(y(k,t),n),l(i)||L(M,t))})),d(),u(T)||(E?S(k,(e=>L(M,e))):S(c,(e=>a(y(w,e),(e=>L(M,e))))),p(M,(e=>{const t=(t,n)=>h(y(T,t),y(T,n),e),n=[...y(k,e)];s(n,t)||(b(k,e,v(o(n,t))),L(j,e))}))),(R||E)&&!l(x)){const t=[...k];s(t,x)||(C(e,g(o(t,x))),R=1)}R&&P(t,[e]),p(j,(t=>P(n,[e,t])))}),T(r),a(i,T)),A},delIndexDefinition:e=>(O(e),A),getStore:i,getIndexIds:c,forEachIndex:e=>w(((t,n)=>e(t,(e=>q(t,e,n))))),forEachSlice:(e,t)=>q(e,t,z(e)),hasIndex:k,hasSlice:(e,t)=>f(z(e),t),getTableId:m,getSliceIds:e=>x(z(e)),getSliceRowIds:(e,t)=>[...y(z(e),t)?.values()??[]],addSliceIdsListener:(e,n)=>B(n,t,[e]),addSliceRowIdsListener:(e,t,s)=>B(s,n,[e,t]),delListener:e=>(W(e),A),destroy:_,getListenerStats:()=>({})};return M(A)}));e.createIndexes=k,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseIndexes={});
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s=t(""),n=t(t),i=(e,t)=>e.forEach(t),o=e=>c(e,((e,t)=>e+t),0),r=e=>e.length,d=e=>0==r(e),c=(e,t,s)=>e.reduce(t,s),a=e=>e.slice(1),l=Math.max,u=Math.min,f=isFinite,h=e=>null==e,p=(e,t,s)=>h(e)?s?.():t(e),v=()=>{},g=e=>e.size,M=(e,t)=>e?.has(t)??!1,y=e=>e.clear(),b=(e,t)=>e?.forEach(t),m=(e,t)=>e?.delete(t),w=e=>new Map(e),L=(e,t)=>e?.get(t),T=(e,t)=>b(e,((e,s)=>t(s,e))),x=(e,t,s)=>h(s)?(m(e,t),e):e?.set(t,s),j=(e,t,s,n)=>(M(e,t)||(n?.(s),e.set(t,s)),L(e,t)),I=e=>new Set(e),R=(e,n)=>t(e)==s?t=>t(e):e??(()=>n??""),S=(e,t,s)=>r(s)<2?((e,t)=>e?.add(t))(d(s)?e:j(e,s[0],I()),t):S(j(e,s[0],w()),t,a(s)),k=e=>{const t=(s,n,...o)=>p(s,(s=>d(o)?e(s,n):i([o[0],null],(e=>t(L(s,e),n,...a(o))))));return t},z=Object.freeze,D=w([["avg",[(e,t)=>o(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>l(...e),(e,t)=>l(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:l(t,e)]],["min",[e=>u(...e),(e,t)=>u(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:u(t,e)]],["sum",[e=>o(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),E=(e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))})((e=>{const s=w(),[o,d,c,a,l,u,j,E,N]=((e,t,s)=>{const n=e.hasRow,o=w(),r=w(),d=w(),c=w(),a=w(),l=t=>p(L(a,t),(s=>{b(s,e.delListener),x(a,t)})),u=e=>{x(o,e),x(r,e),x(d,e),x(c,e),l(e)};return[()=>e,()=>[...o?.keys()??[]],e=>M(r,e),e=>L(o,e),e=>L(r,e),(e,t)=>x(r,e,t),(u,f,p,v,g)=>{const m=w(),j=w();x(o,u,f),M(r,u)||(x(r,u,t()),x(d,u,w()),x(c,u,w()));const R=L(d,u),S=L(c,u),k=t=>{const i=s=>e.getCell(f,t,s),o=L(R,t),r=n(f,t)?s(v(i,t)):void 0;if(o!=r&&x(m,t,[o,r]),!h(g)){const e=L(S,t),s=n(f,t)?g(i,t):void 0;e!=s&&x(j,t,s)}},z=e=>{p((()=>{b(m,(([,e],t)=>x(R,t,e))),b(j,((e,t)=>x(S,t,e)))}),m,j,R,S,e),y(m),y(j)};T(R,k),e.hasTable(f)&&i(e.getRowIds(f),(e=>{M(R,e)||k(e)})),z(!0),l(u),x(a,u,I([e.addRowListener(f,null,((e,t,s)=>k(s))),e.addTableListener(f,(()=>z()))]))},u,()=>T(a,u)]})(e,v,(e=>isNaN(e)||h(e)||!0===e||!1===e||""===e?void 0:1*e)),[O,_,B]=(e=>{let t,s=0;const n=[],o=w();return[(i,r,d=[])=>{t??=e();const c=n.pop()??""+s++;return x(o,c,[i,r,d]),S(r,c,d),c},(e,s=[],...n)=>k(b)(e,(e=>p(L(o,e),(([e])=>e(t,...s,...n)))),...s),e=>p(L(o,e),(([,t,s])=>(k(m)(t,e,...s),x(o,e),r(n)<1e3&&n.push(e),s)),(()=>[])),(e,s,n)=>p(L(o,e),(([e,,o])=>{const d=(...c)=>{const a=r(c);a==r(o)?e(t,...c,...n(c)):h(o[a])?i(s[a](...c),(e=>d(...c,e))):d(...c,o[a])};d()}))]})((()=>C)),C={setMetricDefinition:(e,i,o,r,d,c,a)=>{const p=t(o)==n?[o,d,c,a]:L(D,o)??L(D,"sum");return j(e,i,((t,n,i,o,r,d)=>{let c=l(e),a=g(o);const[v,M,y,m]=p;var w;d=d||h(c),b(n,(([e,t])=>{d||(c=h(e)?M?.(c,t,a++):h(t)?y?.(c,e,a--):m?.(c,t,e,a)),d=d||h(c)})),t(),h(w=o)||0==g(w)?c=void 0:d&&(c=v((e=>[...e?.values()??[]])(o),g(o))),f(c)||(c=void 0);const L=l(e);c!=L&&(u(e,c),_(s,[e],c,L))}),R(r,1)),C},delMetricDefinition:e=>(E(e),C),getStore:o,getMetricIds:d,hasMetric:c,getTableId:a,getMetric:l,addMetricListener:(e,t)=>O(t,s,[e]),delListener:e=>(B(e),C),destroy:N,getListenerStats:()=>({})};return z(C)}));e.createMetrics=E,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseMetrics={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s=t(""),n=t(t),i=(e,t)=>e.forEach(t),o=e=>d(e,((e,t)=>e+t),0),r=e=>e.length,c=e=>0==r(e),d=(e,t,s)=>e.reduce(t,s),a=e=>e.slice(1),l=Math.max,u=Math.min,f=isFinite,h=e=>null==e,p=(e,t,s)=>h(e)?s?.():t(e),v=()=>{},M=e=>e.size,g=(e,t)=>e?.has(t)??!1,y=e=>e.clear(),b=(e,t)=>e?.forEach(t),m=(e,t)=>e?.delete(t),w=e=>new Map(e),L=(e,t)=>e?.get(t),T=(e,t)=>b(e,((e,s)=>t(s,e))),x=(e,t,s)=>h(s)?(m(e,t),e):e?.set(t,s),j=(e,t,s,n)=>(g(e,t)||(n?.(s),e.set(t,s)),L(e,t)),E=e=>new Set(e),I=(e,n)=>t(e)==s?t=>t(e):e??(()=>n??""),R=(e,t,s)=>r(s)<2?((e,t)=>e?.add(t))(c(s)?e:j(e,s[0],E()),t):R(j(e,s[0],w()),t,a(s)),S=e=>{const t=(s,n,...o)=>p(s,(s=>c(o)?e(s,n):i([o[0],null],(e=>t(L(s,e),n,...a(o))))));return t},k=Object.freeze,z=w([["avg",[(e,t)=>o(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>l(...e),(e,t)=>l(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:l(t,e)]],["min",[e=>u(...e),(e,t)=>u(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:u(t,e)]],["sum",[e=>o(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),D=(e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))})((e=>{const s=w(),[o,c,d,a,l,u,j,D,N,O]=((e,t,s)=>{const n=e.hasRow,o=w(),r=w(),c=w(),d=w(),a=w(),l=t=>p(L(a,t),(s=>{b(s,e.delListener),x(a,t)})),u=e=>{x(o,e),x(r,e),x(c,e),x(d,e),l(e)};return[()=>e,()=>[...o?.keys()??[]],e=>T(r,e),e=>g(r,e),e=>L(o,e),e=>L(r,e),(e,t)=>x(r,e,t),(u,f,p,v,M)=>{const m=w(),j=w();x(o,u,f),g(r,u)||(x(r,u,t()),x(c,u,w()),x(d,u,w()));const I=L(c,u),R=L(d,u),S=t=>{const i=s=>e.getCell(f,t,s),o=L(I,t),r=n(f,t)?s(v(i,t)):void 0;if(o!=r&&x(m,t,[o,r]),!h(M)){const e=L(R,t),s=n(f,t)?M(i,t):void 0;e!=s&&x(j,t,s)}},k=e=>{p((()=>{b(m,(([,e],t)=>x(I,t,e))),b(j,((e,t)=>x(R,t,e)))}),m,j,I,R,e),y(m),y(j)};T(I,S),e.hasTable(f)&&i(e.getRowIds(f),(e=>{g(I,e)||S(e)})),k(!0),l(u),x(a,u,E([e.addRowListener(f,null,((e,t,s)=>S(s))),e.addTableListener(f,(()=>k()))]))},u,()=>T(a,u)]})(e,v,(e=>isNaN(e)||h(e)||!0===e||!1===e||""===e?void 0:1*e)),[_,B,C]=(e=>{let t,s=0;const n=[],o=w();return[(i,r,c=[])=>{t??=e();const d=n.pop()??""+s++;return x(o,d,[i,r,c]),R(r,d,c),d},(e,s=[],...n)=>S(b)(e,(e=>p(L(o,e),(([e])=>e(t,...s,...n)))),...s),e=>p(L(o,e),(([,t,s])=>(S(m)(t,e,...s),x(o,e),r(n)<1e3&&n.push(e),s)),(()=>[])),(e,s,n)=>p(L(o,e),(([e,,o])=>{const c=(...d)=>{const a=r(d);a==r(o)?e(t,...d,...n(d)):h(o[a])?i(s[a](...d),(e=>c(...d,e))):c(...d,o[a])};c()}))]})((()=>F)),F={setMetricDefinition:(e,i,o,r,c,d,a)=>{const l=t(o)==n?[o,c,d,a]:L(z,o)??L(z,"sum");return D(e,i,((t,n,i,o,r,c)=>{let d=u(e),a=M(o);const[p,v,g,y]=l;var m;c=c||h(d),b(n,(([e,t])=>{c||(d=h(e)?v?.(d,t,a++):h(t)?g?.(d,e,a--):y?.(d,t,e,a)),c=c||h(d)})),t(),h(m=o)||0==M(m)?d=void 0:c&&(d=p((e=>[...e?.values()??[]])(o),M(o))),f(d)||(d=void 0);const w=u(e);d!=w&&(j(e,d),B(s,[e],d,w))}),I(r,1)),F},delMetricDefinition:e=>(N(e),F),getStore:o,getMetricIds:c,forEachMetric:d,hasMetric:a,getTableId:l,getMetric:u,addMetricListener:(e,t)=>_(t,s,[e]),delListener:e=>(C(e),F),destroy:O,getListenerStats:()=>({})};return k(F)}));e.createMetrics=D,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseMetrics={});
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s=t(""),n=(e,t)=>e.forEach(t),o=e=>e.length,i=e=>0==o(e),d=e=>e.slice(1),a=e=>null==e,l=(e,t,s)=>a(e)?s?.():t(e),r=(e,t)=>e?.has(t)??!1,c=e=>[...e?.values()??[]],f=e=>e.clear(),u=(e,t)=>e?.forEach(t),p=(e,t)=>e?.delete(t),h=e=>new Map(e),R=(e,t)=>e?.get(t),g=(e,t)=>u(e,((e,s)=>t(s,e))),L=(e,t,s)=>a(s)?(p(e,t),e):e?.set(t,s),w=(e,t,s,n)=>(r(e,t)||(n?.(s),e.set(t,s)),R(e,t)),I=e=>new Set(e),b=(e,t)=>e?.add(t),y=(e,n)=>t(e)==s?t=>t(e):e??(()=>n??""),v=(e,t,s)=>o(s)<2?b(i(s)?e:w(e,s[0],I()),t):v(w(e,s[0],h()),t,d(s)),T=e=>{const t=(s,o,...a)=>l(s,(s=>i(a)?e(s,o):n([a[0],null],(e=>t(R(s,e),o,...d(a))))));return t},m=Object.freeze,k=(e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))})((e=>{const t=h(),s=h(),i=h(),d=h(),[w,k,j,x,M,S,z,D,E]=((e,t,s)=>{const o=e.hasRow,i=h(),d=h(),c=h(),p=h(),w=h(),b=t=>l(R(w,t),(s=>{u(s,e.delListener),L(w,t)})),y=e=>{L(i,e),L(d,e),L(c,e),L(p,e),b(e)};return[()=>e,()=>[...i?.keys()??[]],e=>r(d,e),e=>R(i,e),e=>R(d,e),(e,t)=>L(d,e,t),(l,y,v,T,m)=>{const k=h(),j=h();L(i,l,y),r(d,l)||(L(d,l,t()),L(c,l,h()),L(p,l,h()));const x=R(c,l),M=R(p,l),S=t=>{const n=s=>e.getCell(y,t,s),i=R(x,t),d=o(y,t)?s(T(n,t)):void 0;if(i!=d&&L(k,t,[i,d]),!a(m)){const e=R(M,t),s=o(y,t)?m(n,t):void 0;e!=s&&L(j,t,s)}},z=e=>{v((()=>{u(k,(([,e],t)=>L(x,t,e))),u(j,((e,t)=>L(M,t,e)))}),k,j,x,M,e),f(k),f(j)};g(x,S),e.hasTable(y)&&n(e.getRowIds(y),(e=>{r(x,e)||S(e)})),z(!0),b(l),L(w,l,I([e.addRowListener(y,null,((e,t,s)=>S(s))),e.addTableListener(y,(()=>z()))]))},y,()=>g(w,y)]})(e,(()=>[h(),h(),h(),h()]),(e=>a(e)?void 0:e+"")),[O,_,B]=(e=>{let t,s=0;const i=[],d=h();return[(n,o,a=[])=>{t??=e();const l=i.pop()??""+s++;return L(d,l,[n,o,a]),v(o,l,a),l},(e,s=[],...n)=>T(u)(e,(e=>l(R(d,e),(([e])=>e(t,...s,...n)))),...s),e=>l(R(d,e),(([,t,s])=>(T(p)(t,e,...s),L(d,e),o(i)<1e3&&i.push(e),s)),(()=>[])),(e,s,i)=>l(R(d,e),(([e,,d])=>{const l=(...r)=>{const c=o(r);c==o(d)?e(t,...r,...i(r)):a(d[c])?n(s[c](...r),(e=>l(...r,e))):l(...r,d[c])};l()}))]})((()=>q)),C=(e,t,s)=>l(M(e),(([n,,o])=>{if(!r(o,t)){const i=I();if(x(e)!=W(e))b(i,t);else{let e=t;for(;!a(e)&&!r(i,e);)b(i,e),e=R(n,e)}if(s)return i;L(o,t,i)}return R(o,t)})),P=(e,t)=>l(M(e),(([,,e])=>L(e,t))),W=e=>R(t,e),q={setRelationshipDefinition:(e,n,o,c)=>(L(t,e,o),z(e,n,((t,n)=>{const o=I(),c=I(),f=I(),[h,w]=M(e);u(n,(([t,s],n)=>{a(t)||(b(c,t),l(R(w,t),(e=>{var s;p(e,n),(a(s=e)||0==(e=>e.size)(s))&&L(w,t)}))),a(s)||(b(c,s),r(w,s)||L(w,s,I()),b(R(w,s),n)),b(o,n),L(h,n,s),g(R(d,e),(t=>{r(C(e,t),n)&&b(f,t)}))})),t(),u(o,(t=>_(s,[e,t]))),u(c,(t=>_(i,[e,t]))),u(f,(t=>{P(e,t),_(d,[e,t])}))}),y(c)),q),delRelationshipDefinition:e=>(L(t,e),D(e),q),getStore:w,getRelationshipIds:k,hasRelationship:j,getLocalTableId:x,getRemoteTableId:W,getRemoteRowId:(e,t)=>R(M(e)?.[0],t),getLocalRowIds:(e,t)=>c(R(M(e)?.[1],t)),getLinkedRowIds:(e,t)=>a(M(e))?[t]:c(C(e,t,!0)),addRemoteRowIdListener:(e,t,n)=>O(n,s,[e,t]),addLocalRowIdsListener:(e,t,s)=>O(s,i,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(C(e,t),O(s,d,[e,t])),delListener:e=>(P(...B(e)),q),destroy:E,getListenerStats:()=>({})};return m(q)}));e.createRelationships=k,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseRelationships={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,o=t(""),s=(e,t)=>e.forEach(t),n=e=>e.length,i=e=>0==n(e),a=e=>e.slice(1),d=e=>null==e,r=(e,t,o)=>d(e)?o?.():t(e),l=(e,t)=>e?.has(t)??!1,c=e=>[...e?.values()??[]],f=e=>e.clear(),h=(e,t)=>e?.forEach(t),p=(e,t)=>e?.delete(t),u=e=>new Map(e),R=(e,t)=>e?.get(t),g=(e,t)=>h(e,((e,o)=>t(o,e))),w=(e,t,o)=>d(o)?(p(e,t),e):e?.set(t,o),L=(e,t,o,s)=>(l(e,t)||(s?.(o),e.set(t,o)),R(e,t)),I=e=>new Set(e),b=(e,t)=>e?.add(t),y=(e,s)=>t(e)==o?t=>t(e):e??(()=>s??""),v=(e,t,o)=>n(o)<2?b(i(o)?e:L(e,o[0],I()),t):v(L(e,o[0],u()),t,a(o)),T=e=>{const t=(o,n,...d)=>r(o,(o=>i(d)?e(o,n):s([d[0],null],(e=>t(R(o,e),n,...a(d))))));return t},m=Object.freeze,k=(e=>{const t=new WeakMap;return o=>(t.has(o)||t.set(o,e(o)),t.get(o))})((e=>{const t=u(),o=u(),i=u(),a=u(),[L,k,E,j,x,M,S,z,D,O]=((e,t,o)=>{const n=e.hasRow,i=u(),a=u(),c=u(),p=u(),L=u(),b=t=>r(R(L,t),(o=>{h(o,e.delListener),w(L,t)})),y=e=>{w(i,e),w(a,e),w(c,e),w(p,e),b(e)};return[()=>e,()=>[...i?.keys()??[]],e=>g(a,e),e=>l(a,e),e=>R(i,e),e=>R(a,e),(e,t)=>w(a,e,t),(r,y,v,T,m)=>{const k=u(),E=u();w(i,r,y),l(a,r)||(w(a,r,t()),w(c,r,u()),w(p,r,u()));const j=R(c,r),x=R(p,r),M=t=>{const s=o=>e.getCell(y,t,o),i=R(j,t),a=n(y,t)?o(T(s,t)):void 0;if(i!=a&&w(k,t,[i,a]),!d(m)){const e=R(x,t),o=n(y,t)?m(s,t):void 0;e!=o&&w(E,t,o)}},S=e=>{v((()=>{h(k,(([,e],t)=>w(j,t,e))),h(E,((e,t)=>w(x,t,e)))}),k,E,j,x,e),f(k),f(E)};g(j,M),e.hasTable(y)&&s(e.getRowIds(y),(e=>{l(j,e)||M(e)})),S(!0),b(r),w(L,r,I([e.addRowListener(y,null,((e,t,o)=>M(o))),e.addTableListener(y,(()=>S()))]))},y,()=>g(L,y)]})(e,(()=>[u(),u(),u(),u()]),(e=>d(e)?void 0:e+"")),[_,B,C]=(e=>{let t,o=0;const i=[],a=u();return[(s,n,d=[])=>{t??=e();const r=i.pop()??""+o++;return w(a,r,[s,n,d]),v(n,r,d),r},(e,o=[],...s)=>T(h)(e,(e=>r(R(a,e),(([e])=>e(t,...o,...s)))),...o),e=>r(R(a,e),(([,t,o])=>(T(p)(t,e,...o),w(a,e),n(i)<1e3&&i.push(e),o)),(()=>[])),(e,o,i)=>r(R(a,e),(([e,,a])=>{const r=(...l)=>{const c=n(l);c==n(a)?e(t,...l,...i(l)):d(a[c])?s(o[c](...l),(e=>r(...l,e))):r(...l,a[c])};r()}))]})((()=>A)),P=(e,t,o)=>r(M(e),(([s,,n])=>{if(!l(n,t)){const i=I();if(x(e)!=q(e))b(i,t);else{let e=t;for(;!d(e)&&!l(i,e);)b(i,e),e=R(s,e)}if(o)return i;w(n,t,i)}return R(n,t)})),W=(e,t)=>r(M(e),(([,,e])=>w(e,t))),q=e=>R(t,e),A={setRelationshipDefinition:(e,s,n,c)=>(w(t,e,n),z(e,s,((t,s)=>{const n=I(),c=I(),f=I(),[u,L]=M(e);h(s,(([t,o],s)=>{d(t)||(b(c,t),r(R(L,t),(e=>{var o;p(e,s),(d(o=e)||0==(e=>e.size)(o))&&w(L,t)}))),d(o)||(b(c,o),l(L,o)||w(L,o,I()),b(R(L,o),s)),b(n,s),w(u,s,o),g(R(a,e),(t=>{l(P(e,t),s)&&b(f,t)}))})),t(),h(n,(t=>B(o,[e,t]))),h(c,(t=>B(i,[e,t]))),h(f,(t=>{W(e,t),B(a,[e,t])}))}),y(c)),A),delRelationshipDefinition:e=>(w(t,e),D(e),A),getStore:L,getRelationshipIds:k,forEachRelationship:t=>E((o=>t(o,(t=>e.forEachRow(x(o),t))))),hasRelationship:j,getLocalTableId:x,getRemoteTableId:q,getRemoteRowId:(e,t)=>R(M(e)?.[0],t),getLocalRowIds:(e,t)=>c(R(M(e)?.[1],t)),getLinkedRowIds:(e,t)=>d(M(e))?[t]:c(P(e,t,!0)),addRemoteRowIdListener:(e,t,s)=>_(s,o,[e,t]),addLocalRowIdsListener:(e,t,o)=>_(o,i,[e,t]),addLinkedRowIdsListener:(e,t,o)=>(P(e,t),_(o,a,[e,t])),delListener:e=>(W(...C(e)),A),destroy:O,getListenerStats:()=>({})};return m(A)}));e.createRelationships=k,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseRelationships={});
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t){"use strict";const s=e=>typeof e,n="",o=s(n),r=s(!0),a=s(0),i=s(s),d="type",l="default",c="utf8",u=(e,t)=>e.includes(t),f=(e,t)=>e.every(((s,n)=>0==n||t(e[n-1],s)<=0)),h=(e,t)=>e.sort(t),g=(e,t)=>e.forEach(t),p=e=>w(e,((e,t)=>e+t),0),L=e=>e.length,v=e=>0==L(e),w=(e,t,s)=>e.reduce(t,s),y=e=>e.slice(1),I=e=>JSON.stringify(e,((e,t)=>m(t,Map)?w([...t],((e,[t,s])=>(e[t]=s,e)),{}):t)),S=JSON.parse,R=Math.max,T=Math.min,b=isFinite,m=(e,t)=>e instanceof t,C=e=>null==e,k=(e,t,s)=>C(e)?s?.():t(e),M=e=>e==o||e==r,x=e=>s(e)==i,A=()=>{},E=e=>e.size,P=(e,t)=>e?.has(t)??!1,D=e=>C(e)||0==E(e),J=e=>[...e?.values()??[]],F=e=>e.clear(),O=(e,t)=>e?.forEach(t),j=(e,t)=>e?.delete(t),z=e=>new Map(e),N=(e=z)=>[e(),e()],B=e=>[...e?.keys()??[]],_=(e,t)=>e?.get(t),q=(e,t)=>O(e,((e,s)=>t(s,e))),H=(e,t,s)=>C(s)?(j(e,t),e):e?.set(t,s),W=(e,t,s,n)=>(P(e,t)||(n?.(s),e.set(t,s)),_(e,t)),G=(e,t)=>{const s={},n=t??(e=>e);return O(e,((e,t)=>s[t]=n(e))),s},K=(e,t)=>{const s=z(),n=t??(e=>e);return O(e,((e,t)=>s.set(t,n(e)))),s},Q=e=>new Set(e),U=(e,t)=>e?.add(t),V=(e,t,s)=>{const n=e.hasRow,o=z(),r=z(),a=z(),i=z(),d=z(),l=t=>k(_(d,t),(s=>{O(s,e.delListener),H(d,t)})),c=e=>{H(o,e),H(r,e),H(a,e),H(i,e),l(e)};return[()=>e,()=>B(o),e=>P(r,e),e=>_(o,e),e=>_(r,e),(e,t)=>H(r,e,t),(c,u,f,h,p)=>{const L=z(),v=z();H(o,c,u),P(r,c)||(H(r,c,t()),H(a,c,z()),H(i,c,z()));const w=_(a,c),y=_(i,c),I=t=>{const o=s=>e.getCell(u,t,s),r=_(w,t),a=n(u,t)?s(h(o,t)):void 0;if(r!=a&&H(L,t,[r,a]),!C(p)){const e=_(y,t),s=n(u,t)?p(o,t):void 0;e!=s&&H(v,t,s)}},S=e=>{f((()=>{O(L,(([,e],t)=>H(w,t,e))),O(v,((e,t)=>H(y,t,e)))}),L,v,w,y,e),F(L),F(v)};q(w,I),e.hasTable(u)&&g(e.getRowIds(u),(e=>{P(w,e)||I(e)})),S(!0),l(c),H(d,c,Q([e.addRowListener(u,null,((e,t,s)=>I(s))),e.addTableListener(u,(()=>S()))]))},c,()=>q(d,c)]},X=(e,t)=>s(e)==o?t=>t(e):e??(()=>t??n),Y=e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))},Z=(e,t,s)=>L(s)<2?U(v(s)?e:W(e,s[0],Q()),t):Z(W(e,s[0],z()),t,y(s)),$=e=>{const t=(s,n,...o)=>k(s,(s=>v(o)?e(s,n):g([o[0],null],(e=>t(_(s,e),n,...y(o))))));return t},ee=e=>{let t,s=0;const n=[],o=z();return[(r,a,i=[])=>{t??=e();const d=n.pop()??""+s++;return H(o,d,[r,a,i]),Z(a,d,i),d},(e,s=[],...n)=>$(O)(e,(e=>k(_(o,e),(([e])=>e(t,...s,...n)))),...s),e=>k(_(o,e),(([,t,s])=>($(j)(t,e,...s),H(o,e),L(n)<1e3&&n.push(e),s)),(()=>[])),(e,s,n)=>k(_(o,e),(([e,,o])=>{const r=(...a)=>{const i=L(a);i==L(o)?e(t,...a,...n(a)):C(o[i])?g(s[i](...a),(e=>r(...a,e))):r(...a,o[i])};r()}))]},te=Object,se=te.keys,ne=te.isFrozen,oe=te.freeze,re=(e,t)=>!C(((e,t)=>k(e,(e=>e[t])))(e,t)),ae=(e,t)=>delete e[t],ie=(e,t)=>g(te.entries(e),(([e,s])=>t(s,e))),de=Y((e=>{let t,s,n,o=100,r=z(),a=1;const i=Q(),d=z(),[l,c,f]=ee((()=>j)),h=z(),p=z(),w=[],y=[],I=(t,s)=>{a=0,e.transaction((()=>O(_(h,s),((s,n)=>O(s,((s,o)=>O(s,((s,r)=>C(s[t])?e.delCell(n,o,r,!0):e.setCell(n,o,r,s[t]))))))))),a=1},S=e=>{H(h,e),H(p,e),c(d,[e])},R=(e,t)=>g(((e,t)=>e.splice(0,t))(e,t??L(e)),S),T=()=>R(w,L(w)-o),b=e.addCellListener(null,null,null,((e,s,o,i,d,l)=>{if(a){k(t,(()=>{w.push(t),T(),R(y),t=void 0,n=1}));const e=W(r,s,z()),a=W(e,o,z()),c=W(a,i,[void 0,void 0],(e=>e[0]=l));c[1]=d,c[0]===c[1]&&D(H(a,i))&&D(H(e,o))&&D(H(r,s))&&(t=w.pop(),n=1),A()}})),m=(e="")=>(C(t)&&(t=""+s++,H(h,t,r),J(t,e),r=z(),n=1),t),M=()=>{v(w)||(y.unshift(m()),I(0,t),t=w.pop(),n=1)},x=()=>{v(y)||(w.push(t),t=y.shift(),I(1,t),n=1)},A=()=>{n&&(c(i),n=0)},E=e=>{const t=m(e);return A(),t},J=(e,t)=>(F(e)&&_(p,e)!==t&&(H(p,e,t),c(d,[e])),j),F=e=>P(h,e),j={setSize:e=>(o=e,T(),j),addCheckpoint:E,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...w],t,[...y]],hasCheckpoint:F,getCheckpoint:e=>_(p,e),goBackward:()=>(M(),A(),j),goForward:()=>(x(),A(),j),goTo:e=>{const s=u(w,e)?M:u(y,e)?x:null;for(;!C(s)&&e!=t;)s();return A(),j},addCheckpointIdsListener:e=>l(e,i),addCheckpointListener:(e,t)=>l(t,d,[e]),delListener:e=>(f(e),j),clear:()=>(R(w),R(y),C(t)||S(t),t=void 0,s=0,E(),j),destroy:()=>{e.delListener(b)},getListenerStats:()=>({})};return oe(j.clear())})),le=(e,t)=>e<t?-1:1,ce=Y((e=>{const t=z(),s=z(),[o,r,a,i,d,l,c,u,g]=V(e,z,(e=>C(e)?n:e+n)),[p,L,v]=ee((()=>w)),w={setIndexDefinition:(e,n,o,r,a,i=le)=>{const u=C(a)?void 0:([e],[t])=>a(e,t);return c(e,n,((n,o,a,c,g,p)=>{let v=0;const w=Q(),y=Q(),I=d(e);if(O(o,(([e,t],s)=>{C(e)||(U(w,e),k(_(I,e),(t=>{j(t,s),D(t)&&(H(I,e),v=1)}))),C(t)||(U(w,t),P(I,t)||(H(I,t,Q()),v=1),U(_(I,t),s),C(r)||U(y,t))})),n(),D(g)||(p?q(I,(e=>U(y,e))):q(a,(e=>k(_(c,e),(e=>U(y,e))))),O(y,(e=>{const t=(t,s)=>i(_(g,t),_(g,s),e),s=[..._(I,e)];f(s,t)||(H(I,e,Q(h(s,t))),U(w,e))}))),(v||p)&&!C(u)){const t=[...I];f(t,u)||(l(e,z(h(t,u))),v=1)}v&&L(t,[e]),O(w,(t=>L(s,[e,t])))}),X(o),k(r,X)),w},delIndexDefinition:e=>(u(e),w),getStore:o,getIndexIds:r,hasIndex:a,hasSlice:(e,t)=>P(d(e),t),getTableId:i,getSliceIds:e=>B(d(e)),getSliceRowIds:(e,t)=>J(_(d(e),t)),addSliceIdsListener:(e,s)=>p(s,t,[e]),addSliceRowIdsListener:(e,t,n)=>p(n,s,[e,t]),delListener:e=>(v(e),w),destroy:g,getListenerStats:()=>({})};return oe(w)})),ue=z([["avg",[(e,t)=>p(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>R(...e),(e,t)=>R(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:R(t,e)]],["min",[e=>T(...e),(e,t)=>T(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:T(t,e)]],["sum",[e=>p(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),fe=Y((e=>{const t=z(),[s,o,r,a,i,d,l,c,u]=V(e,A,(e=>isNaN(e)||C(e)||!0===e||!1===e||e===n?void 0:1*e)),[f,h,g]=ee((()=>p)),p={setMetricDefinition:(e,s,n,o,r,a,c)=>{const u=x(n)?[n,r,a,c]:_(ue,n)??_(ue,"sum");return l(e,s,((s,n,o,r,a,l)=>{let c=i(e),f=E(r);const[g,p,L,v]=u;l=l||C(c),O(n,(([e,t])=>{l||(c=C(e)?p?.(c,t,f++):C(t)?L?.(c,e,f--):v?.(c,t,e,f)),l=l||C(c)})),s(),D(r)?c=void 0:l&&(c=g(J(r),E(r))),b(c)||(c=void 0);const w=i(e);c!=w&&(d(e,c),h(t,[e],c,w))}),X(o,1)),p},delMetricDefinition:e=>(c(e),p),getStore:s,getMetricIds:o,hasMetric:r,getTableId:a,getMetric:i,addMetricListener:(e,s)=>f(s,t,[e]),delListener:e=>(g(e),p),destroy:u,getListenerStats:()=>({})};return oe(p)})),he=(e,t,s,n,o)=>{let r,a=0;const i={load:async s=>{if(2!=a){a=1;const n=await t();C(n)||""==n?e.setTables(s):e.setJson(n),a=0}return i},startAutoLoad:async e=>(i.stopAutoLoad(),await i.load(e),n(i.load),i),stopAutoLoad:()=>(o(),i),save:async()=>(1!=a&&(a=2,await s(e.getJson()),a=0),i),startAutoSave:async()=>(await i.stopAutoSave().save(),r=e.addTablesListener((()=>i.save())),i),stopAutoSave:()=>(k(r,e.delListener),i),getStore:()=>e,destroy:()=>i.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return oe(i)},ge="storage",pe=globalThis.window,Le=(e,t,s)=>{let n;return he(e,(async()=>s.getItem(t)),(async e=>s.setItem(t,e)),(e=>{n=n=>{n.storageArea===s&&n.key===t&&e()},pe.addEventListener(ge,n)}),(()=>{pe.removeEventListener(ge,n),n=void 0}))},ve=e=>e.headers.get("ETag"),we=Y((e=>{const t=z(),s=z(),o=z(),r=z(),[a,i,d,l,c,u,f,h,g]=V(e,(()=>[z(),z(),z(),z()]),(e=>C(e)?void 0:e+n)),[p,L,v]=ee((()=>S)),w=(e,t,s)=>k(c(e),(([n,,o])=>{if(!P(o,t)){const r=Q();if(l(e)!=I(e))U(r,t);else{let e=t;for(;!C(e)&&!P(r,e);)U(r,e),e=_(n,e)}if(s)return r;H(o,t,r)}return _(o,t)})),y=(e,t)=>k(c(e),(([,,e])=>H(e,t))),I=e=>_(t,e),S={setRelationshipDefinition:(e,n,a,i)=>(H(t,e,a),f(e,n,((t,n)=>{const a=Q(),i=Q(),d=Q(),[l,u]=c(e);O(n,(([t,s],n)=>{C(t)||(U(i,t),k(_(u,t),(e=>{j(e,n),D(e)&&H(u,t)}))),C(s)||(U(i,s),P(u,s)||H(u,s,Q()),U(_(u,s),n)),U(a,n),H(l,n,s),q(_(r,e),(t=>{P(w(e,t),n)&&U(d,t)}))})),t(),O(a,(t=>L(s,[e,t]))),O(i,(t=>L(o,[e,t]))),O(d,(t=>{y(e,t),L(r,[e,t])}))}),X(i)),S),delRelationshipDefinition:e=>(H(t,e),h(e),S),getStore:a,getRelationshipIds:i,hasRelationship:d,getLocalTableId:l,getRemoteTableId:I,getRemoteRowId:(e,t)=>_(c(e)?.[0],t),getLocalRowIds:(e,t)=>J(_(c(e)?.[1],t)),getLinkedRowIds:(e,t)=>C(c(e))?[t]:J(w(e,t,!0)),addRemoteRowIdListener:(e,t,n)=>p(n,s,[e,t]),addLocalRowIdsListener:(e,t,s)=>p(s,o,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(w(e,t),p(s,r,[e,t])),delListener:e=>(y(...v(e)),S),destroy:g,getListenerStats:()=>({})};return oe(S)})),ye=(e,t,s,n=H)=>{const o=(r=B(e),a=e=>!re(t,e),r.filter(a));var r,a;return g(se(t),(n=>s(e,n,t[n]))),g(o,(t=>n(e,t))),e},Ie=e=>{const t=s(e);return M(t)||t==a&&b(e)?t:void 0},Se=(e,t)=>!(C(e)||!(e=>m(e,te)&&e.constructor==te)(e)||ne(e)||(ie(e,((s,n)=>{t(s,n)||ae(e,n)})),(e=>v(se(e)))(e))),Re=(e,t,s)=>H(e,t,_(e,t)==-s?void 0:s);e.createCheckpoints=de,e.createCustomPersister=he,e.createFilePersister=(e,s)=>{let n;return he(e,(async()=>{try{return await t.promises.readFile(s,c)}catch{}}),(async e=>{try{await t.promises.writeFile(s,e,c)}catch{}}),(e=>{n=t.watch(s,e)}),(()=>{n?.close(),n=void 0}))},e.createIndexes=ce,e.createLocalPersister=(e,t)=>Le(e,t,localStorage),e.createMetrics=fe,e.createRelationships=we,e.createRemotePersister=(e,t,s,n)=>{let o,r;return he(e,(async()=>{const e=await fetch(t);return r=ve(e),e.text()}),(async e=>await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:e})),(e=>{o=setInterval((async()=>{const s=await fetch(t,{method:"HEAD"}),n=ve(s);C(r)||C(n)||n==r||(r=n,e())}),1e3*n)}),(()=>{k(o,clearInterval),o=void 0}))},e.createSessionPersister=(e,t)=>Le(e,t,sessionStorage),e.createStore=()=>{let e,t=0,s=0;const n=z(),o=z(),r=z(),i=z(),c=z(),f=z(),h=z(),p=N(Q),L=N(Q),v=N(),w=N(),y=N(),R=N(),T=N(),[b,m,A,E]=ee((()=>Ee)),J=(t,s)=>(!e||P(c,s))&&Se(t,(e=>j(s,e))),j=(e,t,s)=>Se(s?t:V(t,e),((s,n)=>k(U(e,n,s),(e=>(t[n]=e,!0)),(()=>!1)))),U=(t,s,n)=>e?k(_(_(c,t),s),(e=>Ie(n)!=e.type?e.default:n)):C(Ie(n))?void 0:n,V=(e,t)=>(k(_(f,t),(t=>ie(t,((t,s)=>{re(e,s)||(e[s]=t)})))),e),X=e=>ye(c,e,((e,t,s)=>{const n={};ye(W(c,t,z()),s,((e,t,s)=>{H(e,t,s),k(s.default,(e=>n[t]=e))})),H(f,t,n)}),((e,t)=>{H(c,t),H(f,t)})),Y=e=>ye(h,e,((e,t,s)=>Z(t,s)),((e,t)=>ce(t))),Z=(e,t)=>ye(W(h,e,z(),(()=>he(e,1))),t,((t,s,n)=>$(e,t,s,n)),((t,s)=>ue(e,t,s))),$=(e,t,s,n,o)=>ye(W(t,s,z(),(()=>ge(e,s,1))),n,((t,n,o)=>te(e,s,t,n,o)),((n,r)=>fe(e,t,s,n,r,o))),te=(e,t,s,n,o)=>{P(s,n)||pe(e,t,n,1);const r=_(s,n);o!==r&&(Le(e,t,n,r),H(s,n,o))},se=(e,t,s)=>Ae((()=>$(e,le(e),t,s))),ne=(e,t,s,n,o)=>k(_(t,s),(t=>te(e,s,t,n,o)),(()=>$(e,t,s,V({[n]:o},e)))),de=e=>{const s=""+t++;return P(e,s)?de(e):s},le=e=>_(h,e)??Z(e,{}),ce=e=>Z(e,{}),ue=(e,t,s)=>$(e,t,s,{},!0),fe=(e,t,s,n,o,r)=>{const a=_(f,e)?.[o];if(!C(a)&&!r)return te(e,s,n,o,a);const i=t=>{Le(e,s,t,_(n,t)),pe(e,s,t,-1),H(n,t)};C(a)?i(o):q(n,i),D(n)&&(ge(e,s,-1),D(H(t,s))&&(he(e,-1),H(h,e)))},he=(e,t)=>Re(n,e,t),ge=(e,t,s)=>Re(W(o,e,z()),t,s),pe=(e,t,s,n)=>Re(W(W(r,e,z()),t,z()),s,n),Le=(e,t,s,n)=>W(W(W(i,e,z()),t,z()),s,n),ve=(e,t,s)=>{const n=_(_(i,e),t),o=ke(e,t,s);return P(n,s)?[!0,_(n,s),o]:[!1,o,o]},we=e=>{const t=D(R[e])&&D(w[e])&&D(L[e]),s=D(T[e])&&D(y[e])&&D(v[e])&&D(p[e]);if(t&&s)return;const a=e?[K(n),K(o,K),K(r,(e=>K(e,K))),K(i,(e=>K(e,K)))]:[n,o,r,i];if(t||(O(a[2],((t,s)=>O(t,((t,n)=>{D(t)||m(R[e],[s,n])})))),O(a[1],((t,s)=>{D(t)||m(w[e],[s])})),D(a[0])||m(L[e])),!s){let t;O(a[3],((s,n)=>{let o;O(s,((s,r)=>{let a;O(s,((s,i)=>{const d=ke(n,r,i);d!==s&&(m(T[e],[n,r,i],d,s,ve),t=o=a=1)})),a&&m(y[e],[n,r],ve)})),o&&m(v[e],[n],ve)})),t&&m(p[e],[],ve)}},Te=()=>G(h,(e=>G(e,G))),be=()=>B(h),me=e=>B(_(h,e)),Ce=(e,t)=>B(_(_(h,e),t)),ke=(e,t,s)=>_(_(_(h,e),t),s),Me=e=>((e=>Se(e,J))(e)&&Ae((()=>Y(e))),Ee),xe=()=>(Ae((()=>Y({}))),Ee),Ae=e=>{if(-1==s)return;s++;const t=e();return s--,0==s&&(s=1,we(1),s=-1,we(0),s=0,g([i,n,o,r],F)),t},Ee={getTables:Te,getTableIds:be,getTable:e=>G(_(h,e),G),getRowIds:me,getRow:(e,t)=>G(_(_(h,e),t)),getCellIds:Ce,getCell:ke,hasTables:()=>!D(h),hasTable:e=>P(h,e),hasRow:(e,t)=>P(_(h,e),t),hasCell:(e,t,s)=>P(_(_(h,e),t),s),getJson:()=>I(h),getSchemaJson:()=>I(c),setTables:Me,setTable:(e,t)=>(J(t,e)&&Ae((()=>Z(e,t))),Ee),setRow:(e,t,s)=>(j(e,s)&&se(e,t,s),Ee),addRow:(e,t)=>{let s;return j(e,t)&&(s=de(_(h,e)),se(e,s,t)),s},setPartialRow:(e,t,s)=>(j(e,s,1)&&Ae((()=>{const n=le(e);ie(s,((s,o)=>ne(e,n,t,o,s)))})),Ee),setCell:(e,t,s,n)=>(k(U(e,s,x(n)?n(ke(e,t,s)):n),(n=>Ae((()=>ne(e,le(e),t,s,n))))),Ee),setJson:e=>{try{"{}"===e?xe():Me(S(e))}catch{}return Ee},setSchema:t=>{if((e=(e=>Se(e,(e=>Se(e,(e=>{if(!Se(e,((e,t)=>u([d,l],t))))return!1;const t=e.type;return!(!M(t)&&t!=a||(Ie(e.default)!=t&&ae(e,l),0))})))))(t))&&(X(t),!D(h))){const e=Te();xe(),Me(e)}return Ee},delTables:xe,delTable:e=>(P(h,e)&&Ae((()=>ce(e))),Ee),delRow:(e,t)=>(k(_(h,e),(s=>{P(s,t)&&Ae((()=>ue(e,s,t)))})),Ee),delCell:(e,t,s,n)=>(k(_(h,e),(o=>k(_(o,t),(r=>{P(r,s)&&Ae((()=>fe(e,o,t,r,s,n)))})))),Ee),delSchema:()=>(X({}),e=!1,Ee),transaction:Ae,forEachTable:e=>O(h,((t,s)=>e(s,(e=>O(t,((t,s)=>e(s,(e=>q(t,e))))))))),forEachRow:(e,t)=>O(_(h,e),((e,s)=>t(s,(t=>q(e,t))))),forEachCell:(e,t,s)=>q(_(_(h,e),t),s),addTablesListener:(e,t)=>b(e,p[t?1:0]),addTableIdsListener:(e,t)=>b(e,L[t?1:0]),addTableListener:(e,t,s)=>b(t,v[s?1:0],[e]),addRowIdsListener:(e,t,s)=>b(t,w[s?1:0],[e]),addRowListener:(e,t,s,n)=>b(s,y[n?1:0],[e,t]),addCellIdsListener:(e,t,s,n)=>b(s,R[n?1:0],[e,t]),addCellListener:(e,t,s,n,o)=>b(n,T[o?1:0],[e,t,s]),callListener:e=>(E(e,[be,me,Ce],(e=>C(e[2])?[]:[,,].fill(ke(...e)))),Ee),delListener:e=>(A(e),Ee),getListenerStats:()=>({})};return oe(Ee)},e.defaultSorter=le,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs")):"function"==typeof define&&define.amd?define(["exports","fs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={},e.fs);
1
+ var e,t;e=this,t=function(e,t){"use strict";const s=e=>typeof e,o="",n=s(o),r=s(!0),a=s(0),i=s(s),d="type",l="default",c="utf8",u=(e,t)=>e.includes(t),f=(e,t)=>e.every(((s,o)=>0==o||t(e[o-1],s)<=0)),h=(e,t)=>e.sort(t),g=(e,t)=>e.forEach(t),p=e=>v(e,((e,t)=>e+t),0),L=e=>e.length,w=e=>0==L(e),v=(e,t,s)=>e.reduce(t,s),y=e=>e.slice(1),I=e=>JSON.stringify(e,((e,t)=>C(t,Map)?v([...t],((e,[t,s])=>(e[t]=s,e)),{}):t)),S=JSON.parse,R=Math.max,T=Math.min,b=isFinite,C=(e,t)=>e instanceof t,m=e=>null==e,k=(e,t,s)=>m(e)?s?.():t(e),E=e=>e==n||e==r,M=e=>s(e)==i,x=()=>{},A=e=>e.size,P=(e,t)=>e?.has(t)??!1,D=e=>m(e)||0==A(e),J=e=>[...e?.values()??[]],F=e=>e.clear(),O=(e,t)=>e?.forEach(t),j=(e,t)=>e?.delete(t),z=e=>new Map(e),N=(e=z)=>[e(),e()],B=e=>[...e?.keys()??[]],_=(e,t)=>e?.get(t),q=(e,t)=>O(e,((e,s)=>t(s,e))),H=(e,t,s)=>m(s)?(j(e,t),e):e?.set(t,s),W=(e,t,s,o)=>(P(e,t)||(o?.(s),e.set(t,s)),_(e,t)),G=(e,t)=>{const s={},o=t??(e=>e);return O(e,((e,t)=>s[t]=o(e))),s},K=(e,t)=>{const s=z(),o=t??(e=>e);return O(e,((e,t)=>s.set(t,o(e)))),s},Q=e=>new Set(e),U=(e,t)=>e?.add(t),V=(e,t,s)=>{const o=e.hasRow,n=z(),r=z(),a=z(),i=z(),d=z(),l=t=>k(_(d,t),(s=>{O(s,e.delListener),H(d,t)})),c=e=>{H(n,e),H(r,e),H(a,e),H(i,e),l(e)};return[()=>e,()=>B(n),e=>q(r,e),e=>P(r,e),e=>_(n,e),e=>_(r,e),(e,t)=>H(r,e,t),(c,u,f,h,p)=>{const L=z(),w=z();H(n,c,u),P(r,c)||(H(r,c,t()),H(a,c,z()),H(i,c,z()));const v=_(a,c),y=_(i,c),I=t=>{const n=s=>e.getCell(u,t,s),r=_(v,t),a=o(u,t)?s(h(n,t)):void 0;if(r!=a&&H(L,t,[r,a]),!m(p)){const e=_(y,t),s=o(u,t)?p(n,t):void 0;e!=s&&H(w,t,s)}},S=e=>{f((()=>{O(L,(([,e],t)=>H(v,t,e))),O(w,((e,t)=>H(y,t,e)))}),L,w,v,y,e),F(L),F(w)};q(v,I),e.hasTable(u)&&g(e.getRowIds(u),(e=>{P(v,e)||I(e)})),S(!0),l(c),H(d,c,Q([e.addRowListener(u,null,((e,t,s)=>I(s))),e.addTableListener(u,(()=>S()))]))},c,()=>q(d,c)]},X=(e,t)=>s(e)==n?t=>t(e):e??(()=>t??o),Y=e=>{const t=new WeakMap;return s=>(t.has(s)||t.set(s,e(s)),t.get(s))},Z=(e,t,s)=>L(s)<2?U(w(s)?e:W(e,s[0],Q()),t):Z(W(e,s[0],z()),t,y(s)),$=e=>{const t=(s,o,...n)=>k(s,(s=>w(n)?e(s,o):g([n[0],null],(e=>t(_(s,e),o,...y(n))))));return t},ee=e=>{let t,s=0;const o=[],n=z();return[(r,a,i=[])=>{t??=e();const d=o.pop()??""+s++;return H(n,d,[r,a,i]),Z(a,d,i),d},(e,s=[],...o)=>$(O)(e,(e=>k(_(n,e),(([e])=>e(t,...s,...o)))),...s),e=>k(_(n,e),(([,t,s])=>($(j)(t,e,...s),H(n,e),L(o)<1e3&&o.push(e),s)),(()=>[])),(e,s,o)=>k(_(n,e),(([e,,n])=>{const r=(...a)=>{const i=L(a);i==L(n)?e(t,...a,...o(a)):m(n[i])?g(s[i](...a),(e=>r(...a,e))):r(...a,n[i])};r()}))]},te=Object,se=te.keys,oe=te.isFrozen,ne=te.freeze,re=(e,t)=>!m(((e,t)=>k(e,(e=>e[t])))(e,t)),ae=(e,t)=>delete e[t],ie=(e,t)=>g(te.entries(e),(([e,s])=>t(s,e))),de=Y((e=>{let t,s,o,n=100,r=z(),a=1;const i=Q(),d=z(),[l,c,f]=ee((()=>j)),h=z(),p=z(),v=[],y=[],I=(t,s)=>{a=0,e.transaction((()=>O(_(h,s),((s,o)=>O(s,((s,n)=>O(s,((s,r)=>m(s[t])?e.delCell(o,n,r,!0):e.setCell(o,n,r,s[t]))))))))),a=1},S=e=>{H(h,e),H(p,e),c(d,[e])},R=(e,t)=>g(((e,t)=>e.splice(0,t))(e,t??L(e)),S),T=()=>R(v,L(v)-n),b=e.addCellListener(null,null,null,((e,s,n,i,d,l)=>{if(a){k(t,(()=>{v.push(t),T(),R(y),t=void 0,o=1}));const e=W(r,s,z()),a=W(e,n,z()),c=W(a,i,[void 0,void 0],(e=>e[0]=l));c[1]=d,c[0]===c[1]&&D(H(a,i))&&D(H(e,n))&&D(H(r,s))&&(t=v.pop(),o=1),x()}})),C=(e="")=>(m(t)&&(t=""+s++,H(h,t,r),J(t,e),r=z(),o=1),t),E=()=>{w(v)||(y.unshift(C()),I(0,t),t=v.pop(),o=1)},M=()=>{w(y)||(v.push(t),t=y.shift(),I(1,t),o=1)},x=()=>{o&&(c(i),o=0)},A=e=>{const t=C(e);return x(),t},J=(e,t)=>(F(e)&&_(p,e)!==t&&(H(p,e,t),c(d,[e])),j),F=e=>P(h,e),j={setSize:e=>(n=e,T(),j),addCheckpoint:A,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...v],t,[...y]],forEachCheckpoint:e=>q(p,e),hasCheckpoint:F,getCheckpoint:e=>_(p,e),goBackward:()=>(E(),x(),j),goForward:()=>(M(),x(),j),goTo:e=>{const s=u(v,e)?E:u(y,e)?M:null;for(;!m(s)&&e!=t;)s();return x(),j},addCheckpointIdsListener:e=>l(e,i),addCheckpointListener:(e,t)=>l(t,d,[e]),delListener:e=>(f(e),j),clear:()=>(R(v),R(y),m(t)||S(t),t=void 0,s=0,A(),j),destroy:()=>{e.delListener(b)},getListenerStats:()=>({})};return ne(j.clear())})),le=(e,t)=>e<t?-1:1,ce=Y((e=>{const t=z(),s=z(),[n,r,a,i,d,l,c,u,g,p]=V(e,z,(e=>m(e)?o:e+o)),[L,w,v]=ee((()=>I)),y=(t,s,o)=>{const n=d(t);O(o,((t,o)=>s(o,(s=>O(t,(t=>s(t,(s=>e.forEachCell(n,t,s)))))))))},I={setIndexDefinition:(e,o,n,r,a,i=le)=>{const d=m(a)?void 0:([e],[t])=>a(e,t);return u(e,o,((o,n,a,u,g,p)=>{let L=0;const v=Q(),y=Q(),I=l(e);if(O(n,(([e,t],s)=>{m(e)||(U(v,e),k(_(I,e),(t=>{j(t,s),D(t)&&(H(I,e),L=1)}))),m(t)||(U(v,t),P(I,t)||(H(I,t,Q()),L=1),U(_(I,t),s),m(r)||U(y,t))})),o(),D(g)||(p?q(I,(e=>U(y,e))):q(a,(e=>k(_(u,e),(e=>U(y,e))))),O(y,(e=>{const t=(t,s)=>i(_(g,t),_(g,s),e),s=[..._(I,e)];f(s,t)||(H(I,e,Q(h(s,t))),U(v,e))}))),(L||p)&&!m(d)){const t=[...I];f(t,d)||(c(e,z(h(t,d))),L=1)}L&&w(t,[e]),O(v,(t=>w(s,[e,t])))}),X(n),k(r,X)),I},delIndexDefinition:e=>(g(e),I),getStore:n,getIndexIds:r,forEachIndex:e=>a(((t,s)=>e(t,(e=>y(t,e,s))))),forEachSlice:(e,t)=>y(e,t,l(e)),hasIndex:i,hasSlice:(e,t)=>P(l(e),t),getTableId:d,getSliceIds:e=>B(l(e)),getSliceRowIds:(e,t)=>J(_(l(e),t)),addSliceIdsListener:(e,s)=>L(s,t,[e]),addSliceRowIdsListener:(e,t,o)=>L(o,s,[e,t]),delListener:e=>(v(e),I),destroy:p,getListenerStats:()=>({})};return ne(I)})),ue=z([["avg",[(e,t)=>p(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,o)=>e+(t-s)/o]],["max",[e=>R(...e),(e,t)=>R(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:R(t,e)]],["min",[e=>T(...e),(e,t)=>T(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:T(t,e)]],["sum",[e=>p(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),fe=Y((e=>{const t=z(),[s,n,r,a,i,d,l,c,u,f]=V(e,x,(e=>isNaN(e)||m(e)||!0===e||!1===e||e===o?void 0:1*e)),[h,g,p]=ee((()=>L)),L={setMetricDefinition:(e,s,o,n,r,a,i)=>{const u=M(o)?[o,r,a,i]:_(ue,o)??_(ue,"sum");return c(e,s,((s,o,n,r,a,i)=>{let c=d(e),f=A(r);const[h,p,L,w]=u;i=i||m(c),O(o,(([e,t])=>{i||(c=m(e)?p?.(c,t,f++):m(t)?L?.(c,e,f--):w?.(c,t,e,f)),i=i||m(c)})),s(),D(r)?c=void 0:i&&(c=h(J(r),A(r))),b(c)||(c=void 0);const v=d(e);c!=v&&(l(e,c),g(t,[e],c,v))}),X(n,1)),L},delMetricDefinition:e=>(u(e),L),getStore:s,getMetricIds:n,forEachMetric:r,hasMetric:a,getTableId:i,getMetric:d,addMetricListener:(e,s)=>h(s,t,[e]),delListener:e=>(p(e),L),destroy:f,getListenerStats:()=>({})};return ne(L)})),he=(e,t,s,o,n)=>{let r,a=0;const i={load:async s=>{if(2!=a){a=1;const o=await t();m(o)||""==o?e.setTables(s):e.setJson(o),a=0}return i},startAutoLoad:async e=>(i.stopAutoLoad(),await i.load(e),o(i.load),i),stopAutoLoad:()=>(n(),i),save:async()=>(1!=a&&(a=2,await s(e.getJson()),a=0),i),startAutoSave:async()=>(await i.stopAutoSave().save(),r=e.addTablesListener((()=>i.save())),i),stopAutoSave:()=>(k(r,e.delListener),i),getStore:()=>e,destroy:()=>i.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return ne(i)},ge="storage",pe=globalThis.window,Le=(e,t,s)=>{let o;return he(e,(async()=>s.getItem(t)),(async e=>s.setItem(t,e)),(e=>{o=o=>{o.storageArea===s&&o.key===t&&e()},pe.addEventListener(ge,o)}),(()=>{pe.removeEventListener(ge,o),o=void 0}))},we=e=>e.headers.get("ETag"),ve=Y((e=>{const t=z(),s=z(),n=z(),r=z(),[a,i,d,l,c,u,f,h,g,p]=V(e,(()=>[z(),z(),z(),z()]),(e=>m(e)?void 0:e+o)),[L,w,v]=ee((()=>R)),y=(e,t,s)=>k(u(e),(([o,,n])=>{if(!P(n,t)){const r=Q();if(c(e)!=S(e))U(r,t);else{let e=t;for(;!m(e)&&!P(r,e);)U(r,e),e=_(o,e)}if(s)return r;H(n,t,r)}return _(n,t)})),I=(e,t)=>k(u(e),(([,,e])=>H(e,t))),S=e=>_(t,e),R={setRelationshipDefinition:(e,o,a,i)=>(H(t,e,a),h(e,o,((t,o)=>{const a=Q(),i=Q(),d=Q(),[l,c]=u(e);O(o,(([t,s],o)=>{m(t)||(U(i,t),k(_(c,t),(e=>{j(e,o),D(e)&&H(c,t)}))),m(s)||(U(i,s),P(c,s)||H(c,s,Q()),U(_(c,s),o)),U(a,o),H(l,o,s),q(_(r,e),(t=>{P(y(e,t),o)&&U(d,t)}))})),t(),O(a,(t=>w(s,[e,t]))),O(i,(t=>w(n,[e,t]))),O(d,(t=>{I(e,t),w(r,[e,t])}))}),X(i)),R),delRelationshipDefinition:e=>(H(t,e),g(e),R),getStore:a,getRelationshipIds:i,forEachRelationship:t=>d((s=>t(s,(t=>e.forEachRow(c(s),t))))),hasRelationship:l,getLocalTableId:c,getRemoteTableId:S,getRemoteRowId:(e,t)=>_(u(e)?.[0],t),getLocalRowIds:(e,t)=>J(_(u(e)?.[1],t)),getLinkedRowIds:(e,t)=>m(u(e))?[t]:J(y(e,t,!0)),addRemoteRowIdListener:(e,t,o)=>L(o,s,[e,t]),addLocalRowIdsListener:(e,t,s)=>L(s,n,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(y(e,t),L(s,r,[e,t])),delListener:e=>(I(...v(e)),R),destroy:p,getListenerStats:()=>({})};return ne(R)})),ye=(e,t,s,o=H)=>{const n=(r=B(e),a=e=>!re(t,e),r.filter(a));var r,a;return g(se(t),(o=>s(e,o,t[o]))),g(n,(t=>o(e,t))),e},Ie=e=>{const t=s(e);return E(t)||t==a&&b(e)?t:void 0},Se=(e,t)=>!(m(e)||!(e=>C(e,te)&&e.constructor==te)(e)||oe(e)||(ie(e,((s,o)=>{t(s,o)||ae(e,o)})),(e=>w(se(e)))(e))),Re=(e,t,s)=>H(e,t,_(e,t)==-s?void 0:s);e.createCheckpoints=de,e.createCustomPersister=he,e.createFilePersister=(e,s)=>{let o;return he(e,(async()=>{try{return await t.promises.readFile(s,c)}catch{}}),(async e=>{try{await t.promises.writeFile(s,e,c)}catch{}}),(e=>{o=t.watch(s,e)}),(()=>{o?.close(),o=void 0}))},e.createIndexes=ce,e.createLocalPersister=(e,t)=>Le(e,t,localStorage),e.createMetrics=fe,e.createRelationships=ve,e.createRemotePersister=(e,t,s,o)=>{let n,r;return he(e,(async()=>{const e=await fetch(t);return r=we(e),e.text()}),(async e=>await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:e})),(e=>{n=setInterval((async()=>{const s=await fetch(t,{method:"HEAD"}),o=we(s);m(r)||m(o)||o==r||(r=o,e())}),1e3*o)}),(()=>{k(n,clearInterval),n=void 0}))},e.createSessionPersister=(e,t)=>Le(e,t,sessionStorage),e.createStore=()=>{let e,t=0,s=0;const o=z(),n=z(),r=z(),i=z(),c=z(),f=z(),h=z(),p=N(Q),L=N(Q),w=N(),v=N(),y=N(),R=N(),T=N(),[b,C,x,A]=ee((()=>Ae)),J=(t,s)=>(!e||P(c,s))&&Se(t,(e=>j(s,e))),j=(e,t,s)=>Se(s?t:V(t,e),((s,o)=>k(U(e,o,s),(e=>(t[o]=e,!0)),(()=>!1)))),U=(t,s,o)=>e?k(_(_(c,t),s),(e=>Ie(o)!=e.type?e.default:o)):m(Ie(o))?void 0:o,V=(e,t)=>(k(_(f,t),(t=>ie(t,((t,s)=>{re(e,s)||(e[s]=t)})))),e),X=e=>ye(c,e,((e,t,s)=>{const o={};ye(W(c,t,z()),s,((e,t,s)=>{H(e,t,s),k(s.default,(e=>o[t]=e))})),H(f,t,o)}),((e,t)=>{H(c,t),H(f,t)})),Y=e=>ye(h,e,((e,t,s)=>Z(t,s)),((e,t)=>ce(t))),Z=(e,t)=>ye(W(h,e,z(),(()=>he(e,1))),t,((t,s,o)=>$(e,t,s,o)),((t,s)=>ue(e,t,s))),$=(e,t,s,o,n)=>ye(W(t,s,z(),(()=>ge(e,s,1))),o,((t,o,n)=>te(e,s,t,o,n)),((o,r)=>fe(e,t,s,o,r,n))),te=(e,t,s,o,n)=>{P(s,o)||pe(e,t,o,1);const r=_(s,o);n!==r&&(Le(e,t,o,r),H(s,o,n))},se=(e,t,s)=>xe((()=>$(e,le(e),t,s))),oe=(e,t,s,o,n)=>k(_(t,s),(t=>te(e,s,t,o,n)),(()=>$(e,t,s,V({[o]:n},e)))),de=e=>{const s=""+t++;return P(e,s)?de(e):s},le=e=>_(h,e)??Z(e,{}),ce=e=>Z(e,{}),ue=(e,t,s)=>$(e,t,s,{},!0),fe=(e,t,s,o,n,r)=>{const a=_(f,e)?.[n];if(!m(a)&&!r)return te(e,s,o,n,a);const i=t=>{Le(e,s,t,_(o,t)),pe(e,s,t,-1),H(o,t)};m(a)?i(n):q(o,i),D(o)&&(ge(e,s,-1),D(H(t,s))&&(he(e,-1),H(h,e)))},he=(e,t)=>Re(o,e,t),ge=(e,t,s)=>Re(W(n,e,z()),t,s),pe=(e,t,s,o)=>Re(W(W(r,e,z()),t,z()),s,o),Le=(e,t,s,o)=>W(W(W(i,e,z()),t,z()),s,o),we=(e,t,s)=>{const o=_(_(i,e),t),n=ke(e,t,s);return P(o,s)?[!0,_(o,s),n]:[!1,n,n]},ve=e=>{const t=D(R[e])&&D(v[e])&&D(L[e]),s=D(T[e])&&D(y[e])&&D(w[e])&&D(p[e]);if(t&&s)return;const a=e?[K(o),K(n,K),K(r,(e=>K(e,K))),K(i,(e=>K(e,K)))]:[o,n,r,i];if(t||(O(a[2],((t,s)=>O(t,((t,o)=>{D(t)||C(R[e],[s,o])})))),O(a[1],((t,s)=>{D(t)||C(v[e],[s])})),D(a[0])||C(L[e])),!s){let t;O(a[3],((s,o)=>{let n;O(s,((s,r)=>{let a;O(s,((s,i)=>{const d=ke(o,r,i);d!==s&&(C(T[e],[o,r,i],d,s,we),t=n=a=1)})),a&&C(y[e],[o,r],we)})),n&&C(w[e],[o],we)})),t&&C(p[e],[],we)}},Te=()=>G(h,(e=>G(e,G))),be=()=>B(h),Ce=e=>B(_(h,e)),me=(e,t)=>B(_(_(h,e),t)),ke=(e,t,s)=>_(_(_(h,e),t),s),Ee=e=>((e=>Se(e,J))(e)&&xe((()=>Y(e))),Ae),Me=()=>(xe((()=>Y({}))),Ae),xe=e=>{if(-1==s)return;s++;const t=e();return s--,0==s&&(s=1,ve(1),s=-1,ve(0),s=0,g([i,o,n,r],F)),t},Ae={getTables:Te,getTableIds:be,getTable:e=>G(_(h,e),G),getRowIds:Ce,getRow:(e,t)=>G(_(_(h,e),t)),getCellIds:me,getCell:ke,hasTables:()=>!D(h),hasTable:e=>P(h,e),hasRow:(e,t)=>P(_(h,e),t),hasCell:(e,t,s)=>P(_(_(h,e),t),s),getJson:()=>I(h),getSchemaJson:()=>I(c),setTables:Ee,setTable:(e,t)=>(J(t,e)&&xe((()=>Z(e,t))),Ae),setRow:(e,t,s)=>(j(e,s)&&se(e,t,s),Ae),addRow:(e,t)=>{let s;return j(e,t)&&(s=de(_(h,e)),se(e,s,t)),s},setPartialRow:(e,t,s)=>(j(e,s,1)&&xe((()=>{const o=le(e);ie(s,((s,n)=>oe(e,o,t,n,s)))})),Ae),setCell:(e,t,s,o)=>(k(U(e,s,M(o)?o(ke(e,t,s)):o),(o=>xe((()=>oe(e,le(e),t,s,o))))),Ae),setJson:e=>{try{"{}"===e?Me():Ee(S(e))}catch{}return Ae},setSchema:t=>{if((e=(e=>Se(e,(e=>Se(e,(e=>{if(!Se(e,((e,t)=>u([d,l],t))))return!1;const t=e.type;return!(!E(t)&&t!=a||(Ie(e.default)!=t&&ae(e,l),0))})))))(t))&&(X(t),!D(h))){const e=Te();Me(),Ee(e)}return Ae},delTables:Me,delTable:e=>(P(h,e)&&xe((()=>ce(e))),Ae),delRow:(e,t)=>(k(_(h,e),(s=>{P(s,t)&&xe((()=>ue(e,s,t)))})),Ae),delCell:(e,t,s,o)=>(k(_(h,e),(n=>k(_(n,t),(r=>{P(r,s)&&xe((()=>fe(e,n,t,r,s,o)))})))),Ae),delSchema:()=>(X({}),e=!1,Ae),transaction:xe,forEachTable:e=>O(h,((t,s)=>e(s,(e=>O(t,((t,s)=>e(s,(e=>q(t,e))))))))),forEachRow:(e,t)=>O(_(h,e),((e,s)=>t(s,(t=>q(e,t))))),forEachCell:(e,t,s)=>q(_(_(h,e),t),s),addTablesListener:(e,t)=>b(e,p[t?1:0]),addTableIdsListener:(e,t)=>b(e,L[t?1:0]),addTableListener:(e,t,s)=>b(t,w[s?1:0],[e]),addRowIdsListener:(e,t,s)=>b(t,v[s?1:0],[e]),addRowListener:(e,t,s,o)=>b(s,y[o?1:0],[e,t]),addCellIdsListener:(e,t,s,o)=>b(s,R[o?1:0],[e,t]),addCellListener:(e,t,s,o,n)=>b(o,T[n?1:0],[e,t,s]),callListener:e=>(A(e,[be,Ce,me],(e=>m(e[2])?[]:[,,].fill(ke(...e)))),Ae),delListener:e=>(x(e),Ae),getListenerStats:()=>({})};return ne(Ae)},e.defaultSorter=le,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs")):"function"==typeof define&&define.amd?define(["exports","fs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={},e.fs);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -56,8 +56,8 @@
56
56
  },
57
57
  "devDependencies": {
58
58
  "@babel/cli": "^7.16.8",
59
- "@babel/core": "^7.16.7",
60
- "@babel/preset-env": "^7.16.8",
59
+ "@babel/core": "^7.16.10",
60
+ "@babel/preset-env": "^7.16.11",
61
61
  "@babel/preset-react": "^7.16.7",
62
62
  "@babel/preset-typescript": "^7.16.7",
63
63
  "@rollup/plugin-replace": "^3.0.1",
@@ -79,12 +79,12 @@
79
79
  "babel-jest": "^27.4.6",
80
80
  "babel-preset-minify": "^0.5.1",
81
81
  "country-flag-emoji-json": "^2.0.0",
82
- "cspell": "^5.15.2",
83
- "esbuild": "^0.14.11",
82
+ "cspell": "^5.16.0",
83
+ "esbuild": "^0.14.12",
84
84
  "eslint": "^8.7.0",
85
85
  "eslint-config-prettier": "^8.3.0",
86
86
  "eslint-plugin-jest": "^25.7.0",
87
- "eslint-plugin-jsdoc": "^37.6.1",
87
+ "eslint-plugin-jsdoc": "^37.6.2",
88
88
  "eslint-plugin-react": "^7.28.0",
89
89
  "eslint-plugin-react-hooks": "^4.3.0",
90
90
  "gulp": "^4.0.2",
@@ -107,7 +107,7 @@
107
107
  "tinydocs": "^0.1.10",
108
108
  "tmp": "^0.2.1",
109
109
  "ts-unused-exports": "^7.0.3",
110
- "typescript": "4.5.4"
110
+ "typescript": "4.5.5"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "react": "^17.0.2"
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="a-javascript-library-for-structured-state">A JavaScript library for <em>structured state</em>.</h2><p>Using plain old JavaScript objects to manage data gets old very quickly. It&#x27;s error-prone, tricky to track changes efficiently, and easy to mistakenly incur performance costs.</p><p><em>TinyBase is a smarter way to structure your application state:</em></p><ul><li>Familiar concepts of <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>, and <a href="#apply-schemas-to-tables">schematization</a> to model your data domain.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so you only spend cycles on the data that changes.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#configure-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state! - out of the box.</li><li>Easily <a href="#persist-data-to-browser-file-or-server">sync your data</a> to local or remote storage, and use <a href="#call-react-hooks-to-bind-to-data">idiomatic bindings</a> to your React UI.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">2.6kB - 5.6kB</a> when compressed, and has zero dependencies. And of course it&#x27;s <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>. Other <a href="https://tinybase.org/guides/faq/">FAQs</a>?</p></section><hr><p><a id="start" href="https://tinybase.org/guides/the-basics/getting-started">Get started</a></p><p><a href="https://tinybase.org/demos">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="set-and-get-tables-rows-and-cells">Set and get tables, rows, and cells.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a>, or <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values by their <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a>. And of course you can easily get the values back out again.</p><p>Read more about setting and changing data in <a href="https://tinybase.org/guides/the-basics">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="a-javascript-library-for-structured-state">A JavaScript library for <em>structured state</em>.</h2><p>Using plain old JavaScript objects to manage data gets old very quickly. It&#x27;s error-prone, tricky to track changes efficiently, and easy to mistakenly incur performance costs.</p><p><em>TinyBase is a smarter way to structure your application state:</em></p><ul><li>Familiar concepts of <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>, and <a href="#apply-schemas-to-tables">schematization</a> to model your data domain.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so you only spend cycles on the data that changes.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#configure-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state! - out of the box.</li><li>Easily <a href="#persist-data-to-browser-file-or-server">sync your data</a> to local or remote storage, and use <a href="#call-react-hooks-to-bind-to-data">idiomatic bindings</a> to your React UI.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">2.6kB - 5.7kB</a> when compressed, and has zero dependencies. And of course it&#x27;s <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>. Other <a href="https://tinybase.org/guides/faq/">FAQs</a>?</p></section><hr><p><a id="start" href="https://tinybase.org/guides/the-basics/getting-started">Get started</a></p><p><a href="https://tinybase.org/demos">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="set-and-get-tables-rows-and-cells">Set and get tables, rows, and cells.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a>, or <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values by their <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a>. And of course you can easily get the values back out again.</p><p>Read more about setting and changing data in <a href="https://tinybase.org/guides/the-basics">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()
@@ -192,4 +192,4 @@ console.log(store.getCell('pets', 'felix', 'sold'));
192
192
  // -> false
193
193
  ```
194
194
 
195
- <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>2.6kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>5.6kB</em>. The <code>ui-react</code> adaptor is just another <em>2.6kB</em>, and everything is fast.</p><p>Life&#x27;s easy when you have zero dependencies.</p><p>Read more about how TinyBase is structured in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store">store</a></th><td>2.6kB</td><td>5.9kB</td><td>23.9kB</td><td>87.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes">indexes</a></th><td>1.5kB</td><td>3.0kB</td><td>13.2kB</td><td>29.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics">metrics</a></th><td>1.5kB</td><td>3.0kB</td><td>12.4kB</td><td>27.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships">relationships</a></th><td>1.5kB</td><td>3.1kB</td><td>14.4kB</td><td>39.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints">checkpoints</a></th><td>1.3kB</td><td>2.4kB</td><td>10.1kB</td><td>31.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters">persisters</a></th><td>0.8kB</td><td>1.6kB</td><td>4.9kB</td><td>26.7kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/tinybase">tinybase</a></th><td>5.6kB</td><td>13.1kB</td><td>54.3kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible to get up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>937</td><td>937</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,026</td><td>1,026</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>370</td><td>370</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>341</td><td>341</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">1,721</td></tr><tr><th class="right">Assertions</th><td colspan="3">7,991</td></tr></tbody></table></div><hr><p><a id="start" href="https://tinybase.org/guides/the-basics/getting-started">Get started</a></p><p><a href="https://tinybase.org/demos">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a> and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/issues">Issues</a> and <a href="https://github.com/tinyplex/tinybase/releases">release notes</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a></li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/1.0.4">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was an interesting exercise in API design, minification, and documentation. It&#x27;s not <a href="https://www.linkedin.com/in/jamespearce">my day job</a>, but I do intend to maintain it, so please provide feedback. I could not have done this without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it!</p></section>
195
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>2.6kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>5.7kB</em>. The <code>ui-react</code> adaptor is just another <em>2.6kB</em>, and everything is fast.</p><p>Life&#x27;s easy when you have zero dependencies.</p><p>Read more about how TinyBase is structured in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store">store</a></th><td>2.6kB</td><td>5.9kB</td><td>23.9kB</td><td>87.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes">indexes</a></th><td>1.6kB</td><td>3.2kB</td><td>14.0kB</td><td>32.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics">metrics</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>29.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships">relationships</a></th><td>1.6kB</td><td>3.2kB</td><td>14.7kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints">checkpoints</a></th><td>1.3kB</td><td>2.5kB</td><td>10.3kB</td><td>33.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters">persisters</a></th><td>0.8kB</td><td>1.6kB</td><td>4.9kB</td><td>26.7kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/tinybase">tinybase</a></th><td>5.7kB</td><td>13.4kB</td><td>55.6kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible to get up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>957</td><td>957</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,047</td><td>1,047</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>384</td><td>384</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>341</td><td>341</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">1,731</td></tr><tr><th class="right">Assertions</th><td colspan="3">8,036</td></tr></tbody></table></div><hr><p><a id="start" href="https://tinybase.org/guides/the-basics/getting-started">Get started</a></p><p><a href="https://tinybase.org/demos">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a> and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/issues">Issues</a> and <a href="https://github.com/tinyplex/tinybase/releases">release notes</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a></li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/1.0.5">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was an interesting exercise in API design, minification, and documentation. It&#x27;s not <a href="https://www.linkedin.com/in/jamespearce">my day job</a>, but I do intend to maintain it, so please provide feedback. I could not have done this without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it!</p></section>