Comparing version 0.7.8 to 0.7.9
import fs from 'fs/promises' | ||
import path, { dirname } from 'path' | ||
import { minify } from "terser"; | ||
import { minify } from 'terser' | ||
import { execSync } from 'child_process' | ||
const currentFilePath = (new URL(import.meta.url)).pathname | ||
@@ -14,2 +14,5 @@ const __dirname = dirname(currentFilePath) | ||
source: path.join(__dirname, './src/db64.js'), | ||
sourceTSdef: path.join(__dirname, './src/db64.d.ts'), | ||
tsDefDist: path.join(__dirname, './dist/db64.d.ts'), | ||
tsDefMapDist: path.join(__dirname, './dist/db64.d.ts.map'), | ||
cjsDist: path.join(__dirname, './dist/db64.cjs'), | ||
@@ -20,11 +23,10 @@ esDist: path.join(__dirname, './dist/db64.js'), | ||
cjsMinDist: path.join(__dirname, './dist/db64-cjs.min.js'), | ||
cjsMinMapDist: path.join(__dirname, './dist/db64-cjs.min.map'), | ||
cjsMinMapDist: path.join(__dirname, './dist/db64-cjs.min.map') | ||
} | ||
const createCJS = async () => { | ||
try { | ||
const data = await fs.readFile(paths.source, 'utf8') | ||
const tsDefData = await fs.readFile(paths.sourceTSdef, 'utf8') | ||
const readmeSrc = await fs.readFile(paths.readmeSrc, 'utf8') | ||
@@ -34,6 +36,16 @@ | ||
const minifiedESData = await minify(data, { sourceMap: true }) | ||
const minifiedCJSData = await minify(insertCJSImport, { sourceMap: true }) | ||
const minifiedESData = await minify(data, { | ||
sourceMap: { | ||
url: path.basename(paths.esMinMapDist) | ||
} | ||
}) | ||
const minifiedCJSData = await minify(insertCJSImport, { | ||
sourceMap: { | ||
url: path.basename(paths.cjsMinMapDist) | ||
} | ||
}) | ||
// ES | ||
/* | ||
ES */ | ||
await fs.writeFile(paths.esDist, data, 'utf8') | ||
@@ -47,6 +59,18 @@ console.info(`Created ${paths.esDist}`) | ||
// ES Map | ||
// await fs.writeFile(paths.esMinMapDist, minifiedESData.map, 'utf8') | ||
// console.info(`Created ${paths.esMinMapDist}`) | ||
await fs.writeFile(paths.esMinMapDist, minifiedESData.map, 'utf8') | ||
console.info(`Created ${paths.esMinMapDist}`) | ||
// CJS | ||
/* | ||
TS Definitions */ | ||
await fs.writeFile(paths.tsDefDist, tsDefData, 'utf8') | ||
console.info(`Created ${paths.tsDefDist}`) | ||
// TS Definitions Map | ||
const tsc = './node_modules/.bin/tsc' | ||
execSync(`${tsc} --project tsconfig.json`, { stdio: 'inherit' }) | ||
console.info(`Created ${paths.tsDefMapDist}`) | ||
/* | ||
CJS */ | ||
await fs.writeFile(paths.cjsDist, insertCJSImport, 'utf8') | ||
@@ -60,4 +84,4 @@ console.info(`Created ${paths.cjsDist}`) | ||
// CJS Map | ||
// await fs.writeFile(paths.cjsMinMapDist, minifiedCJSData.map, 'utf8') | ||
// console.info(`Created ${paths.cjsMinMapDist}`) | ||
await fs.writeFile(paths.cjsMinMapDist, minifiedCJSData.map, 'utf8') | ||
console.info(`Created ${paths.cjsMinMapDist}`) | ||
@@ -71,3 +95,2 @@ const stats = await fs.stat(paths.esMinDist) | ||
console.info(`Created ${paths.readmeRoot}`) | ||
} catch (err) { | ||
@@ -74,0 +97,0 @@ console.error('Error:', err) |
@@ -1,1 +0,2 @@ | ||
const{isArray:isArray}=Array,connections=[],openDatabase=(e="default",t)=>new Promise(((r,o)=>{let a;try{a=window.indexedDB.open(e,1)}catch(e){o(e)}return a.onupgradeneeded=({target:e})=>{const{result:r}=e;t.forEach((e=>{if(!r.objectStoreNames.contains(e)){r.createObjectStore(e).onerror=e=>o(e.target.error)}}))},a.onsuccess=({target:e})=>{connections.push(a),r(e.result)},a.onerror=({target:e})=>o(e.result),a})),setData=async(e,t,r,o,a)=>{try{const s=e.transaction([t],"readwrite").objectStore(t);if(a){const e=isArray(o)?()=>o.map(((e,t)=>s.put(e,t))):()=>Object.entries(o).map((([e,t])=>s.put(t,e)));await Promise.all(e())}else await s.put(o,r)}catch(e){console.error(e)}return db64},getData=async(e,t,r,o)=>new Promise((a=>{const s=e.transaction([t]).objectStore(t);let n;if(o){const e={};s.openCursor().onsuccess=t=>{const o=t.target.result;o?(r.includes(o.key)&&(e[o.key]=o.value),o.continue()):a(e)}}else n=s.get(r),n.onsuccess=()=>a(n.result)})),deleteData=async(e,t,r)=>{try{const o=e.transaction([t],"readwrite").objectStore(t);o.openCursor().onsuccess=e=>{const t=e.target.result;t&&((isArray(r)?r:[r]).includes(t.key)&&t.delete(),t.continue())}}catch(e){console.error(e)}return db64},clearStore=(e,t)=>new Promise(((r,o)=>{const a=e.transaction([t],"readwrite").objectStore(t).clear();a.onsuccess=r(db64),a.onerror=e=>o(e.target.error)})),deleteDB=e=>new Promise(((t,r)=>{const o=indexedDB.deleteDatabase(e);o.onsuccess=()=>t(db64),o.onerror=({target:e})=>r(new Error(`Error deleting database: ${e.error}`)),o.onblocked=()=>{for(const t of connections)t.result.name===e&&t.result.close();deleteDB(e)}})),db64={create:async(e,t)=>isArray(t)?(await openDatabase(e,t),db64):console.error("storeNames should be an array"),use:(e,t)=>(indexedDB.open(e,1).onsuccess=r=>{r.target.result.objectStoreNames.contains(t)||console.error(`Store ${t} does not exist. You may need to manage the lifecycle of databse "${e}" if outdated.`)},{set:async(r,o)=>openDatabase(e,t).then((e=>setData(e,t,r,o))).catch(console.error),setEntries:async r=>openDatabase(e,t).then((e=>setData(e,t,null,r,"entries"))).catch(console.error),get:async r=>openDatabase(e,t).then((e=>getData(e,t,r))).catch(console.error),getEntries:async r=>openDatabase(e,t).then((e=>getData(e,t,r,"entries"))).catch(console.error),delete:async r=>openDatabase(e,t).then((e=>deleteData(e,t,r))).catch(console.error)}),clear:async(e,t)=>openDatabase(e,t).then((e=>clearStore(e,t))).catch(console.error),delete:async e=>deleteDB(e).catch(console.error)};module.exports=db64; | ||
const{isArray:isArray}=Array,connections=[],openDatabase=(e="default",t)=>new Promise(((r,o)=>{let a;try{a=window.indexedDB.open(e,1)}catch(e){o(e)}return a.onupgradeneeded=({target:e})=>{const{result:r}=e;t.forEach((e=>{if(!r.objectStoreNames.contains(e)){r.createObjectStore(e).onerror=e=>o(e.target.error)}}))},a.onsuccess=({target:e})=>{connections.push(a),r(e.result)},a.onerror=({target:e})=>o(e.result),a})),setData=async(e,t,r,o,a)=>{try{const s=e.transaction([t],"readwrite").objectStore(t);if(a){const e=isArray(o)?()=>o.map(((e,t)=>s.put(e,t))):()=>Object.entries(o).map((([e,t])=>s.put(t,e)));await Promise.all(e())}else await s.put(o,r)}catch(e){console.error(e)}return db64},getData=async(e,t,r,o)=>new Promise((a=>{const s=e.transaction([t]).objectStore(t);let n;if(o){const e={};s.openCursor().onsuccess=t=>{const o=t.target.result;o?(r.includes(o.key)&&(e[o.key]=o.value),o.continue()):a(e)}}else n=s.get(r),n.onsuccess=()=>a(n.result)})),deleteData=async(e,t,r)=>{try{const o=e.transaction([t],"readwrite").objectStore(t);o.openCursor().onsuccess=e=>{const t=e.target.result;t&&((isArray(r)?r:[r]).includes(t.key)&&t.delete(),t.continue())}}catch(e){console.error(e)}return db64},clearStore=(e,t)=>new Promise(((r,o)=>{const a=e.transaction([t],"readwrite").objectStore(t).clear();a.onsuccess=r(db64),a.onerror=e=>o(e.target.error)})),deleteDB=e=>new Promise(((t,r)=>{const o=indexedDB.deleteDatabase(e);o.onsuccess=()=>t(db64),o.onerror=({target:e})=>r(new Error(`Error deleting database: ${e.error}`)),o.onblocked=()=>{for(const t of connections)t.result.name===e&&t.result.close();deleteDB(e)}})),db64={create:async(e,t)=>isArray(t)?(await openDatabase(e,t),db64):console.error("storeNames should be an array"),use:(e,t)=>(indexedDB.open(e,1).onsuccess=r=>{r.target.result.objectStoreNames.contains(t)||console.error(`Store ${t} does not exist. You may need to manage the lifecycle of databse "${e}" if outdated.`)},{set:async(r,o)=>openDatabase(e,t).then((e=>setData(e,t,r,o))).catch(console.error),setEntries:async r=>openDatabase(e,t).then((e=>setData(e,t,null,r,"entries"))).catch(console.error),get:async r=>openDatabase(e,t).then((e=>getData(e,t,r))).catch(console.error),getEntries:async r=>openDatabase(e,t).then((e=>getData(e,t,r,"entries"))).catch(console.error),delete:async r=>openDatabase(e,t).then((e=>deleteData(e,t,r))).catch(console.error)}),clear:async(e,t)=>openDatabase(e,t).then((e=>clearStore(e,t))).catch(console.error),delete:async e=>deleteDB(e).catch(console.error)};module.exports=db64; | ||
//# sourceMappingURL=db64-cjs.min.map |
@@ -1,1 +0,2 @@ | ||
const{isArray:isArray}=Array,connections=[],openDatabase=(e="default",t)=>new Promise(((r,o)=>{let a;try{a=window.indexedDB.open(e,1)}catch(e){o(e)}return a.onupgradeneeded=({target:e})=>{const{result:r}=e;t.forEach((e=>{if(!r.objectStoreNames.contains(e)){r.createObjectStore(e).onerror=e=>o(e.target.error)}}))},a.onsuccess=({target:e})=>{connections.push(a),r(e.result)},a.onerror=({target:e})=>o(e.result),a})),setData=async(e,t,r,o,a)=>{try{const s=e.transaction([t],"readwrite").objectStore(t);if(a){const e=isArray(o)?()=>o.map(((e,t)=>s.put(e,t))):()=>Object.entries(o).map((([e,t])=>s.put(t,e)));await Promise.all(e())}else await s.put(o,r)}catch(e){console.error(e)}return db64},getData=async(e,t,r,o)=>new Promise((a=>{const s=e.transaction([t]).objectStore(t);let n;if(o){const e={};s.openCursor().onsuccess=t=>{const o=t.target.result;o?(r.includes(o.key)&&(e[o.key]=o.value),o.continue()):a(e)}}else n=s.get(r),n.onsuccess=()=>a(n.result)})),deleteData=async(e,t,r)=>{try{const o=e.transaction([t],"readwrite").objectStore(t);o.openCursor().onsuccess=e=>{const t=e.target.result;t&&((isArray(r)?r:[r]).includes(t.key)&&t.delete(),t.continue())}}catch(e){console.error(e)}return db64},clearStore=(e,t)=>new Promise(((r,o)=>{const a=e.transaction([t],"readwrite").objectStore(t).clear();a.onsuccess=r(db64),a.onerror=e=>o(e.target.error)})),deleteDB=e=>new Promise(((t,r)=>{const o=indexedDB.deleteDatabase(e);o.onsuccess=()=>t(db64),o.onerror=({target:e})=>r(new Error(`Error deleting database: ${e.error}`)),o.onblocked=()=>{for(const t of connections)t.result.name===e&&t.result.close();deleteDB(e)}})),db64={create:async(e,t)=>isArray(t)?(await openDatabase(e,t),db64):console.error("storeNames should be an array"),use:(e,t)=>(indexedDB.open(e,1).onsuccess=r=>{r.target.result.objectStoreNames.contains(t)||console.error(`Store ${t} does not exist. You may need to manage the lifecycle of databse "${e}" if outdated.`)},{set:async(r,o)=>openDatabase(e,t).then((e=>setData(e,t,r,o))).catch(console.error),setEntries:async r=>openDatabase(e,t).then((e=>setData(e,t,null,r,"entries"))).catch(console.error),get:async r=>openDatabase(e,t).then((e=>getData(e,t,r))).catch(console.error),getEntries:async r=>openDatabase(e,t).then((e=>getData(e,t,r,"entries"))).catch(console.error),delete:async r=>openDatabase(e,t).then((e=>deleteData(e,t,r))).catch(console.error)}),clear:async(e,t)=>openDatabase(e,t).then((e=>clearStore(e,t))).catch(console.error),delete:async e=>deleteDB(e).catch(console.error)};export default db64; | ||
const{isArray:isArray}=Array,connections=[],openDatabase=(e="default",t)=>new Promise(((r,o)=>{let a;try{a=window.indexedDB.open(e,1)}catch(e){o(e)}return a.onupgradeneeded=({target:e})=>{const{result:r}=e;t.forEach((e=>{if(!r.objectStoreNames.contains(e)){r.createObjectStore(e).onerror=e=>o(e.target.error)}}))},a.onsuccess=({target:e})=>{connections.push(a),r(e.result)},a.onerror=({target:e})=>o(e.result),a})),setData=async(e,t,r,o,a)=>{try{const s=e.transaction([t],"readwrite").objectStore(t);if(a){const e=isArray(o)?()=>o.map(((e,t)=>s.put(e,t))):()=>Object.entries(o).map((([e,t])=>s.put(t,e)));await Promise.all(e())}else await s.put(o,r)}catch(e){console.error(e)}return db64},getData=async(e,t,r,o)=>new Promise((a=>{const s=e.transaction([t]).objectStore(t);let n;if(o){const e={};s.openCursor().onsuccess=t=>{const o=t.target.result;o?(r.includes(o.key)&&(e[o.key]=o.value),o.continue()):a(e)}}else n=s.get(r),n.onsuccess=()=>a(n.result)})),deleteData=async(e,t,r)=>{try{const o=e.transaction([t],"readwrite").objectStore(t);o.openCursor().onsuccess=e=>{const t=e.target.result;t&&((isArray(r)?r:[r]).includes(t.key)&&t.delete(),t.continue())}}catch(e){console.error(e)}return db64},clearStore=(e,t)=>new Promise(((r,o)=>{const a=e.transaction([t],"readwrite").objectStore(t).clear();a.onsuccess=r(db64),a.onerror=e=>o(e.target.error)})),deleteDB=e=>new Promise(((t,r)=>{const o=indexedDB.deleteDatabase(e);o.onsuccess=()=>t(db64),o.onerror=({target:e})=>r(new Error(`Error deleting database: ${e.error}`)),o.onblocked=()=>{for(const t of connections)t.result.name===e&&t.result.close();deleteDB(e)}})),db64={create:async(e,t)=>isArray(t)?(await openDatabase(e,t),db64):console.error("storeNames should be an array"),use:(e,t)=>(indexedDB.open(e,1).onsuccess=r=>{r.target.result.objectStoreNames.contains(t)||console.error(`Store ${t} does not exist. You may need to manage the lifecycle of databse "${e}" if outdated.`)},{set:async(r,o)=>openDatabase(e,t).then((e=>setData(e,t,r,o))).catch(console.error),setEntries:async r=>openDatabase(e,t).then((e=>setData(e,t,null,r,"entries"))).catch(console.error),get:async r=>openDatabase(e,t).then((e=>getData(e,t,r))).catch(console.error),getEntries:async r=>openDatabase(e,t).then((e=>getData(e,t,r,"entries"))).catch(console.error),delete:async r=>openDatabase(e,t).then((e=>deleteData(e,t,r))).catch(console.error)}),clear:async(e,t)=>openDatabase(e,t).then((e=>clearStore(e,t))).catch(console.error),delete:async e=>deleteDB(e).catch(console.error)};export default db64; | ||
//# sourceMappingURL=db64.min.map |
{ | ||
"name": "db64", | ||
"version": "0.7.8", | ||
"version": "0.7.9", | ||
"description": "A Practical IndexedDB API", | ||
@@ -13,4 +13,3 @@ "main": "db64.js", | ||
"test": "./node_modules/.bin/http-server -a 127.0.0.1 -p 2222 -o", | ||
"lint": "./node_modules/.bin/eslint db64.js make-cjs.js", | ||
"lint:fix": "./node_modules/.bin/eslint --fix db64.js make-cjs.js", | ||
"lint": "./node_modules/.bin/eslint --fix ./src ./create-distribution.js", | ||
"prepublishOnly": "node create-distribution.js" | ||
@@ -40,4 +39,5 @@ }, | ||
"http-server": "^14.1.1", | ||
"terser": "^5.26.0" | ||
"terser": "^5.26.0", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -14,3 +14,3 @@ # db64 | ||
- No versioning | ||
- 2.47KB minified | ||
- 2.51KB minified | ||
@@ -17,0 +17,0 @@ E.g. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51302
16
743
8
1