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.4.6 to 0.4.7

5

cjs/index.js

@@ -41,6 +41,3 @@ 'use strict';

'init',
assign(
{library: base + '/init.js'},
assign({dist: base}, options)
)
assign({dist: base, library: base + '/init.js'}, options)
).then(() => ({

@@ -47,0 +44,0 @@ all: query('all'),

2

dist/index.js

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

const{assign:e}=Object,t="function"==typeof importScripts,r=t?".":import.meta.url.replace(/\/[^/]*$/,""),o=r=>new Promise(((o,n)=>{const s=()=>{const e=self.module.exports;delete self.exports,self.module=void 0,o(e)};if(self.exports={},self.module={exports:exports},t)importScripts(r),s();else{const{head:t}=document;e(t.appendChild(document.createElement("script")),{onload(){t.removeChild(this),s()},onerror:n,src:r})}}));const n=new WeakMap,s=(e,...t)=>{const{t:r,v:o}=((e,t)=>{const r=[e[0]],o=[];for(let n=0,s=0,c=0,{length:a}=t;s<a;s++)t[s]instanceof l?r[n]+=t[s].v+e[s+1]:(o[c++]=s,r[++n]=e[s+1]);return{t:r,v:o}})(e,t),s=n.get(e)||n.set(e,{}).get(e);return(s[r]||(s[r]=[r])).concat(o.map((e=>t[e])))};function l(e){this.v=e}const c=(e,t)=>(r,...o)=>new Promise(((n,l)=>{r.some(u)&&l(a(new Error("SQLITE_ERROR: SQL injection hazard")));const[c,...i]=s(r,...o);e[t](c.join("?"),i,((e,t)=>{e?l(e):n(t)}))})),a=e=>(e.code="SQLITE_ERROR",e),i=(e,...t)=>new l(function(e){for(var t=e[0],r=1,o=arguments.length;r<o;r++)t+=arguments[r]+e[r];return t}(e,...t)),u=e=>e.includes("?");function p(e){return{all:c(e,"all"),get:c(e,"get"),query:c(e,"run"),raw:i}}const d=(t,r=1)=>new Promise(((o,n)=>{e(indexedDB.open(t,r),{onupgradeneeded({target:{result:t,transaction:r}}){t.objectStoreNames.contains("sqlite")||t.createObjectStore("sqlite").createIndex("buffer","buffer",{unique:!0}),e(r,{oncomplete(){o(t)}})},onsuccess({target:{result:e}}){o(e)},onerror:n})})),m=(t={})=>new Promise(((n,s)=>{const l=t.dist||r;o(l+"/sql-wasm.js").then((({default:r})=>{Promise.all([d(t.name||"sqlite-worker"),r({locateFile:e=>l+"/"+e})]).then((([r,{Database:o}])=>{const l=e=>r.transaction(["sqlite"],e).objectStore("sqlite");e(l("readonly").get("buffer"),{onsuccess(){let r=Promise.resolve();const{result:s}=this,c=new o(s||t.database||new Uint8Array(0)),a=()=>{r=r.then((()=>new Promise(((r,o)=>{const n=c.export();e(l("readwrite").put(n,"buffer").transaction,{oncomplete(){r(),t.update&&t.update(n)},onabort:o,onerror:o})}))))};s||a();const{all:i,get:u,query:d,raw:m}=p({all(e,t,r){try{const o=c.exec(e,t),n=[];o.forEach(f,n),r(null,n)}catch(e){r(e)}},get(e,t,r){try{const o=c.exec(e+" LIMIT 1",t),n=[];o.forEach(f,n),r(null,n.shift()||null)}catch(e){r(e)}},run(e,t,r){try{r(null,c.run(e,t))}catch(e){r(e)}}});let h=0;n({all:i,get:u,raw:m,query(e){return/\b(?:INSERT|DELETE|UPDATE)\b/i.test(e[0])&&(clearTimeout(h),h=setTimeout(a,t.timeout||250)),d.apply(this,arguments)}})},onerror:s})}),s)}))}));function f({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 h=new Map;let w=0;function g(t){const{credentials:o}=t,n=t.dist||r,s=t.worker||n+"/worker.js",l=e=>(t,...r)=>c(e,{template:t,values:r}),c=(e,t)=>new Promise(((r,o)=>{const n=w++;h.set(n,{resolve:r,reject:o}),a.postMessage({id:n,action:e,options:t})})),a=e(new Worker(/^(?:\.|\/)/.test(s)?s:(e=>URL.createObjectURL(new Blob([`importScripts('${e}')`],{type:"text/javascript"})))(s),{credentials:o}),{onmessage({data:{id:e,result:t,error:r}}){const{resolve:o,reject:n}=h.get(e);h.delete(e),r?n(r):o(t)}});return c("init",e({library:n+"/init.js"},e({dist:n},t))).then((()=>({all:l("all"),get:l("get"),query:l("query")})))}export{g as SQLiteWorker,m as init};
const{assign:e}=Object,t="function"==typeof importScripts,r=t?".":import.meta.url.replace(/\/[^/]*$/,""),o=r=>new Promise(((o,n)=>{const s=()=>{const e=self.module.exports;delete self.exports,self.module=void 0,o(e)};if(self.exports={},self.module={exports:exports},t)importScripts(r),s();else{const{head:t}=document;e(t.appendChild(document.createElement("script")),{onload(){t.removeChild(this),s()},onerror:n,src:r})}}));const n=new WeakMap,s=(e,...t)=>{const{t:r,v:o}=((e,t)=>{const r=[e[0]],o=[];for(let n=0,s=0,c=0,{length:a}=t;s<a;s++)t[s]instanceof l?r[n]+=t[s].v+e[s+1]:(o[c++]=s,r[++n]=e[s+1]);return{t:r,v:o}})(e,t),s=n.get(e)||n.set(e,{}).get(e);return(s[r]||(s[r]=[r])).concat(o.map((e=>t[e])))};function l(e){this.v=e}const c=(e,t)=>(r,...o)=>new Promise(((n,l)=>{r.some(u)&&l(a(new Error("SQLITE_ERROR: SQL injection hazard")));const[c,...i]=s(r,...o);e[t](c.join("?"),i,((e,t)=>{e?l(e):n(t)}))})),a=e=>(e.code="SQLITE_ERROR",e),i=(e,...t)=>new l(function(e){for(var t=e[0],r=1,o=arguments.length;r<o;r++)t+=arguments[r]+e[r];return t}(e,...t)),u=e=>e.includes("?");function p(e){return{all:c(e,"all"),get:c(e,"get"),query:c(e,"run"),raw:i}}const d=(t,r=1)=>new Promise(((o,n)=>{e(indexedDB.open(t,r),{onupgradeneeded({target:{result:t,transaction:r}}){t.objectStoreNames.contains("sqlite")||t.createObjectStore("sqlite").createIndex("buffer","buffer",{unique:!0}),e(r,{oncomplete(){o(t)}})},onsuccess({target:{result:e}}){o(e)},onerror:n})})),m=(t={})=>new Promise(((n,s)=>{const l=t.dist||r;o(l+"/sql-wasm.js").then((({default:r})=>{Promise.all([d(t.name||"sqlite-worker"),r({locateFile:e=>l+"/"+e})]).then((([r,{Database:o}])=>{const l=e=>r.transaction(["sqlite"],e).objectStore("sqlite");e(l("readonly").get("buffer"),{onsuccess(){let r=Promise.resolve();const{result:s}=this,c=new o(s||t.database||new Uint8Array(0)),a=()=>{r=r.then((()=>new Promise(((r,o)=>{const n=c.export();e(l("readwrite").put(n,"buffer").transaction,{oncomplete(){r(),t.update&&t.update(n)},onabort:o,onerror:o})}))))};s||a();const{all:i,get:u,query:d,raw:m}=p({all(e,t,r){try{const o=c.exec(e,t),n=[];o.forEach(f,n),r(null,n)}catch(e){r(e)}},get(e,t,r){try{const o=c.exec(e+" LIMIT 1",t),n=[];o.forEach(f,n),r(null,n.shift()||null)}catch(e){r(e)}},run(e,t,r){try{r(null,c.run(e,t))}catch(e){r(e)}}});let h=0;n({all:i,get:u,raw:m,query(e){return/\b(?:INSERT|DELETE|UPDATE)\b/i.test(e[0])&&(clearTimeout(h),h=setTimeout(a,t.timeout||250)),d.apply(this,arguments)}})},onerror:s})}),s)}))}));function f({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 h=new Map;let w=0;function g(t){const{credentials:o}=t,n=t.dist||r,s=t.worker||n+"/worker.js",l=e=>(t,...r)=>c(e,{template:t,values:r}),c=(e,t)=>new Promise(((r,o)=>{const n=w++;h.set(n,{resolve:r,reject:o}),a.postMessage({id:n,action:e,options:t})})),a=e(new Worker(/^(?:\.|\/)/.test(s)?s:(e=>URL.createObjectURL(new Blob([`importScripts('${e}')`],{type:"text/javascript"})))(s),{credentials:o}),{onmessage({data:{id:e,result:t,error:r}}){const{resolve:o,reject:n}=h.get(e);h.delete(e),r?n(r):o(t)}});return c("init",e({dist:n,library:n+"/init.js"},t)).then((()=>({all:l("all"),get:l("get"),query:l("query")})))}export{g as SQLiteWorker,m as init};

@@ -38,6 +38,3 @@ import {assign, dist} from './utils.js';

'init',
assign(
{library: base + '/init.js'},
assign({dist: base}, options)
)
assign({dist: base, library: base + '/init.js'}, options)
).then(() => ({

@@ -44,0 +41,0 @@ all: query('all'),

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

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

@@ -26,3 +26,6 @@ # sqlite-worker

SQLiteWorker({name: 'my-db'}).then(async ({all, get, query}) => {
SQLiteWorker({
dist: '//unpkg.com/sqlite-worker/dist',
name: 'my-db'
}).then(async ({all, get, query}) => {
await query`CREATE TABLE IF NOT EXISTS todos (id INTEGER PRIMARY KEY, value TEXT)`;

@@ -81,3 +84,2 @@ const {total} = await get`SELECT COUNT(id) as total FROM todos`;

sqliteWorker({
// **IMPORTANT**
dist: '/js/sqlite-worker/dist',

@@ -84,0 +86,0 @@ name: 'my-db'

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