UNPKG

@electric-sql/pglite

Version:

PGlite is a WASM Postgres build packaged into a TypeScript client library that enables you to run Postgres in the browser, Node.js and Bun, with no need to install any other dependencies. It is only 3.7mb gzipped.

2 lines 916 B
import{a as u,h as y,j as c}from"./chunk-JOTQFPBW.js";import{j as f}from"./chunk-QY3QWFKW.js";f();async function v(s,e,r,n){if(!r||r.length===0)return e;n=n??s;let t=[];try{await s.execProtocol(c.parse({text:e}),{syncToFs:!1}),t.push(...(await s.execProtocol(c.describe({type:"S"}),{syncToFs:!1})).messages)}finally{t.push(...(await s.execProtocol(c.sync(),{syncToFs:!1})).messages)}let a=y(t),i=e.replace(/\$([0-9]+)/g,(d,l)=>"%"+l+"L");return(await n.query(`SELECT format($1, ${r.map((d,l)=>`$${l+2}`).join(", ")}) as query`,[i,...r],{paramTypes:[u,...a]})).rows[0].query}function x(s){let e,r=!1,n=async()=>{if(!e){r=!1;return}r=!0;let{args:t,resolve:a,reject:i}=e;e=void 0;try{let o=await s(...t);a(o)}catch(o){i(o)}finally{n()}};return async(...t)=>{e&&e.resolve(void 0);let a=new Promise((i,o)=>{e={args:t,resolve:i,reject:o}});return r||n(),a}}export{v as a,x as b}; //# sourceMappingURL=chunk-VC7SUH2R.js.map