UNPKG

tinybase

Version:

A reactive data store and sync engine.

2 lines (1 loc) 846 B
const e=e=>typeof e,t=e(""),o=e(!0),r=e(0),n="type",s="default",l=e=>(t,o,r)=>e(t)?r?.():o(t),c=e=>null==e,p=l(c),u=l(e=>void 0===e),a=Object,f=e=>a.getPrototypeOf(e),y=a.entries,i=a.keys,h=a.freeze,b=(e=[])=>a.fromEntries(e),d=(e,t)=>((e,t)=>e.forEach(t))(y(e),([e,o])=>t(o,e)),m=(e,t,o)=>[{[n]:e?.type},t??e?.spec?.[s],o||e?.spec?.nullable||!1],g=e=>e?.fields,v=()=>((e,l)=>{const y=l=>{const[c,p,a]=e(l),f=c?.type;if(f!==t&&f!==r&&f!==o)return;const y={[n]:f};return u(p,e=>{y[s]=e}),a&&(y.allowNull=!0),y};return h({toTablesSchema:e=>{const t=b();return d(e,(e,o)=>{const r=b();var n;u(l(e),e=>d(e,(e,t)=>u(y(e),e=>{r[t]=e}))),(e=>!c(e)&&p(f(e),e=>e==a.prototype||c(f(e)),()=>!0))(n=r)&&0==(e=>i(e).length)(n)||(t[o]=r)}),t},toValuesSchema:e=>{const t=b();return d(e,(e,o)=>u(y(e),e=>{t[o]=e})),t}})})(m,g);export{v as createYupSchematizer};