Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sqlite-worker

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlite-worker - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

cjs/loader.js

4

cjs/init.js

@@ -54,7 +54,3 @@ 'use strict';

assign(store('readwrite').put(uint8array, keyPath).transaction, {
onsuccess() {
console.log('SUCCESS');
},
oncomplete() {
console.log('COMPLETE');
resolve();

@@ -61,0 +57,0 @@ if (options.update)

@@ -20,3 +20,2 @@ 'use strict';

case 'init':
console.log(options.library);
if (!db)

@@ -23,0 +22,0 @@ db = import(options.library).then(({init}) => init(options));

@@ -1,1 +0,1 @@

const e=new WeakMap,t=(t,...o)=>{const{t:n,v:s}=((e,t)=>{const o=[e[0]],n=[];for(let s=0,l=0,a=0,{length:c}=t;l<c;l++)t[l]instanceof r?o[s]+=t[l].v+e[l+1]:(n[a++]=l,o[++s]=e[l+1]);return{t:o,v:n}})(t,o),l=e.get(t)||e.set(t,{}).get(t);return(l[n]||(l[n]=[n])).concat(s.map((e=>o[e])))};function r(e){this.v=e}const o=(e,r)=>(o,...s)=>new Promise(((a,c)=>{o.some(l)&&c(n(new Error("SQLITE_ERROR: SQL injection hazard")));const[i,...u]=t(o,...s);e[r](i.join("?"),u,((e,t)=>{e?c(e):a(t)}))})),n=e=>(e.code="SQLITE_ERROR",e),s=(e,...t)=>new r(function(e){for(var t=e[0],r=1,o=arguments.length;r<o;r++)t+=arguments[r]+e[r];return t}(e,...t)),l=e=>e.includes("?");function a(e){return{all:o(e,"all"),get:o(e,"get"),query:o(e,"run"),raw:s}}const{assign:c}=Object,i=(e,t=1)=>new Promise(((r,o)=>{c(indexedDB.open(e,t),{onupgradeneeded({target:{result:e,transaction:t}}){e.objectStoreNames.contains("sqlite")||e.createObjectStore("sqlite").createIndex("buffer","buffer",{unique:!0}),c(t,{oncomplete(){r(e)}})},onsuccess({target:{result:e}}){r(e)},onerror:o})})),u=(e={})=>new Promise(((t,r)=>{const{url:o}=import.meta,n=e.dir||o.slice(0,o.lastIndexOf("/"))+"/../dist";self.exports={},self.module={exports:exports},import(n+"/sql-wasm.js").then((()=>{const o=self.module.exports;delete self.exports,Promise.all([i(e.name||"sqlite-worker"),o({locateFile:e=>n+"/"+e})]).then((([o,{Database:n}])=>{const s=e=>o.transaction(["sqlite"],e).objectStore("sqlite");c(s("readonly").get("buffer"),{onsuccess(){let r=Promise.resolve();const{result:o}=this,l=new n(o||e.database||new Uint8Array(0)),i=()=>{r=r.then((()=>new Promise(((t,r)=>{const o=l.export();c(s("readwrite").put(o,"buffer").transaction,{onsuccess(){console.log("SUCCESS")},oncomplete(){console.log("COMPLETE"),t(),e.update&&e.update(o)},onabort:r,onerror:r})}))))};o||i();const{all:u,get:f,query:p,raw:d}=a({all(e,t,r){try{const o=l.exec(e,t),n=[];o.forEach(m,n),r(null,n)}catch(e){r(e)}},get(e,t,r){try{const o=l.exec(e+" LIMIT 1",t),n=[];o.forEach(m,n),r(null,n.shift()||null)}catch(e){r(e)}},run(e,t,r){try{r(null,l.run(e,t))}catch(e){r(e)}}});let g=0;t({all:u,get:f,raw:d,query(t){return/\b(?:INSERT|DELETE|UPDATE)\b/i.test(t[0])&&(clearTimeout(g),g=setTimeout(i,e.timeout||250)),p.apply(this,arguments)}})},onerror:r})}),r)}))}));function m({columns:e,values:t}){for(let{length:r}=t,o=0;o<r;o++){const r=t[o],n={};for(let{length:t}=e,o=0;o<t;o++)n[e[o]]=r[o];this.push(n)}}const{assign:f}=Object,p=new Map;let d=0;function g(e){const t=import.meta.url,r=e=>(t,...r)=>o(e,{template:t,values:r}),o=(e,t)=>new Promise(((r,o)=>{const s=d++;p.set(s,{resolve:r,reject:o}),n.postMessage({id:s,action:e,options:t})})),n=f(new Worker(e.worker||t.slice(0,t.lastIndexOf("/"))+"/worker.js",{type:"module"}),{onmessage({data:{id:e,result:t,error:r}}){const{resolve:o,reject:n}=p.get(e);p.delete(e),r?n(r):o(t)}});return o("init",f({library:t},e)).then((()=>({all:r("all"),get:r("get"),query:r("query")})))}export{g as SQLiteWorker,u as init};
const e=new WeakMap,t=(t,...n)=>{const{t:o,v:s}=((e,t)=>{const n=[e[0]],o=[];for(let s=0,l=0,a=0,{length:c}=t;l<c;l++)t[l]instanceof r?n[s]+=t[l].v+e[l+1]:(o[a++]=l,n[++s]=e[l+1]);return{t:n,v:o}})(t,n),l=e.get(t)||e.set(t,{}).get(t);return(l[o]||(l[o]=[o])).concat(s.map((e=>n[e])))};function r(e){this.v=e}const n=(e,r)=>(n,...s)=>new Promise(((a,c)=>{n.some(l)&&c(o(new Error("SQLITE_ERROR: SQL injection hazard")));const[i,...u]=t(n,...s);e[r](i.join("?"),u,((e,t)=>{e?c(e):a(t)}))})),o=e=>(e.code="SQLITE_ERROR",e),s=(e,...t)=>new r(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(e,...t)),l=e=>e.includes("?");function a(e){return{all:n(e,"all"),get:n(e,"get"),query:n(e,"run"),raw:s}}const{assign:c}=Object,i=(e,t=1)=>new Promise(((r,n)=>{c(indexedDB.open(e,t),{onupgradeneeded({target:{result:e,transaction:t}}){e.objectStoreNames.contains("sqlite")||e.createObjectStore("sqlite").createIndex("buffer","buffer",{unique:!0}),c(t,{oncomplete(){r(e)}})},onsuccess({target:{result:e}}){r(e)},onerror:n})})),u=(e={})=>new Promise(((t,r)=>{const{url:n}=import.meta,o=e.dir||n.slice(0,n.lastIndexOf("/"))+"/../dist";self.exports={},self.module={exports:exports},import(o+"/sql-wasm.js").then((()=>{const n=self.module.exports;delete self.exports,Promise.all([i(e.name||"sqlite-worker"),n({locateFile:e=>o+"/"+e})]).then((([n,{Database:o}])=>{const s=e=>n.transaction(["sqlite"],e).objectStore("sqlite");c(s("readonly").get("buffer"),{onsuccess(){let r=Promise.resolve();const{result:n}=this,l=new o(n||e.database||new Uint8Array(0)),i=()=>{r=r.then((()=>new Promise(((t,r)=>{const n=l.export();c(s("readwrite").put(n,"buffer").transaction,{oncomplete(){t(),e.update&&e.update(n)},onabort:r,onerror:r})}))))};n||i();const{all:u,get:f,query:p,raw:d}=a({all(e,t,r){try{const n=l.exec(e,t),o=[];n.forEach(m,o),r(null,o)}catch(e){r(e)}},get(e,t,r){try{const n=l.exec(e+" LIMIT 1",t),o=[];n.forEach(m,o),r(null,o.shift()||null)}catch(e){r(e)}},run(e,t,r){try{r(null,l.run(e,t))}catch(e){r(e)}}});let g=0;t({all:u,get:f,raw:d,query(t){return/\b(?:INSERT|DELETE|UPDATE)\b/i.test(t[0])&&(clearTimeout(g),g=setTimeout(i,e.timeout||250)),p.apply(this,arguments)}})},onerror:r})}),r)}))}));function m({columns:e,values:t}){for(let{length:r}=t,n=0;n<r;n++){const r=t[n],o={};for(let{length:t}=e,n=0;n<t;n++)o[e[n]]=r[n];this.push(o)}}const{assign:f}=Object,p=new Map;let d=0;function g(e){const t=import.meta.url,r=e=>(t,...r)=>n(e,{template:t,values:r}),n=(e,t)=>new Promise(((r,n)=>{const s=d++;p.set(s,{resolve:r,reject:n}),o.postMessage({id:s,action:e,options:t})})),o=f(new Worker(e.worker||t.slice(0,t.lastIndexOf("/"))+"/worker.js",{type:"module"}),{onmessage({data:{id:e,result:t,error:r}}){const{resolve:n,reject:o}=p.get(e);p.delete(e),r?o(r):n(t)}});return n("init",f({library:t},e)).then((()=>({all:r("all"),get:r("get"),query:r("query")})))}export{g as SQLiteWorker,u as init};

@@ -1,1 +0,1 @@

let e=null;const s=(e,s,t,{template:r,values:a})=>{e.then((e=>{e[s].apply(null,[r].concat(a)).then((e=>{postMessage({id:t,result:e})}),(({message:e})=>{postMessage({id:t,error:e})}))}))};addEventListener("message",(({data:{id:t,action:r,options:a}})=>{switch(r){case"init":return console.log(a.library),e||(e=import(a.library).then((({init:e})=>e(a)))),e.then((()=>postMessage({id:t,result:"OK"})),(({message:e})=>postMessage({id:t,error:e})));case"all":return s(e,"all",t,a);case"get":return s(e,"get",t,a);case"query":return s(e,"query",t,a)}}));
let e=null;const t=(e,t,s,{template:a,values:r})=>{e.then((e=>{e[t].apply(null,[a].concat(r)).then((e=>{postMessage({id:s,result:e})}),(({message:e})=>{postMessage({id:s,error:e})}))}))};addEventListener("message",(({data:{id:s,action:a,options:r}})=>{switch(a){case"init":return e||(e=import(r.library).then((({init:e})=>e(r)))),e.then((()=>postMessage({id:s,result:"OK"})),(({message:e})=>postMessage({id:s,error:e})));case"all":return t(e,"all",s,r);case"get":return t(e,"get",s,r);case"query":return t(e,"query",s,r)}}));

@@ -19,3 +19,2 @@ let db = null;

case 'init':
console.log(options.library);
if (!db)

@@ -22,0 +21,0 @@ db = import(options.library).then(({init}) => init(options));

{
"name": "sqlite-worker",
"version": "0.3.2",
"version": "0.3.3",
"description": "A simple, and persistent, SQLite database for Web and Workers",

@@ -5,0 +5,0 @@ "main": "./cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc