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

@kikko-land/electron-better-sqlite3-backend

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kikko-land/electron-better-sqlite3-backend - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

11

CHANGELOG.md
# @kikko-land/electron-better-sqlite3-backend
## 0.2.0
### Minor Changes
- 174767c: Rename kikko to core
### Patch Changes
- Updated dependencies [174767c]
- @kikko-land/kikko@0.2.0
## 0.1.1

@@ -4,0 +15,0 @@

2

dist/electron-better-sqlite3-backend/src/electronBetterSqlite3Backend.d.ts

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

import { IDbBackend } from "@kikko-land/core";
import { IDbBackend } from "@kikko-land/kikko";
declare global {

@@ -3,0 +3,0 @@ interface Window {

{
"name": "@kikko-land/electron-better-sqlite3-backend",
"version": "0.1.1",
"version": "0.2.0",
"author": "Sergey Popov",

@@ -61,3 +61,3 @@ "license": "MIT",

"dependencies": {
"@kikko-land/core": "^0.1.1",
"@kikko-land/kikko": "^0.2.0",
"@kikko-land/sql": "^0.1.1",

@@ -64,0 +64,0 @@ "@kikko-land/sql.js": "^1.6.8",

@@ -1,6 +0,8 @@

import { IDbBackend, IQuery, IQueryResult } from "@kikko-land/core";
import { IDbBackend, IQuery, IQueryResult } from "@kikko-land/kikko";
declare global {
interface Window {
sqliteDb: (path: string) => Promise<{
sqliteDb: (
path: string
) => Promise<{
close: (callback?: (err: Error | null) => void) => void;

@@ -11,4 +13,4 @@ all: (

params: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) => any[];
) => // eslint-disable-next-line @typescript-eslint/no-explicit-any
any[];
}>;

@@ -19,64 +21,63 @@ }

export type ValueType<T> = T extends Promise<infer U> ? U : T;
export const electronBetterSqlite3Backend =
(path: (dbName: string) => string): IDbBackend =>
({ dbName, stopped$ }) => {
let db: ValueType<ReturnType<typeof window.sqliteDb>> | undefined =
undefined;
export const electronBetterSqlite3Backend = (
path: (dbName: string) => string
): IDbBackend => ({ dbName, stopped$ }) => {
let db: ValueType<ReturnType<typeof window.sqliteDb>> | undefined = undefined;
return {
async initialize() {
db = await window.sqliteDb(path(dbName));
return {
async initialize() {
db = await window.sqliteDb(path(dbName));
stopped$.subscribe(() => {
if (!db) {
console.error("Failed to stop DB‚Äö it is not initialized");
stopped$.subscribe(() => {
if (!db) {
console.error("Failed to stop DB‚Äö it is not initialized");
return;
}
db.close();
});
},
async execQueries(
queries: IQuery[],
opts: {
log: {
suppress: boolean;
transactionId?: string;
};
return;
}
) {
if (!db) {
throw new Error(
`Failed to run queries: ${queries
.map((q) => q.text)
.join(" ")}, db not initialized`
);
}
db.close();
});
},
async execQueries(
queries: IQuery[],
opts: {
log: {
suppress: boolean;
transactionId?: string;
};
}
) {
if (!db) {
throw new Error(
`Failed to run queries: ${queries
.map((q) => q.text)
.join(" ")}, db not initialized`
);
}
const result: IQueryResult[] = [];
const result: IQueryResult[] = [];
for (const q of queries) {
const startTime = performance.now();
for (const q of queries) {
const startTime = performance.now();
result.push(db.all(q.text, q.values));
result.push(db.all(q.text, q.values));
const end = performance.now();
const end = performance.now();
if (!opts.log.suppress) {
console.info(
`[${dbName}]${
opts.log.transactionId
? `[tr_id=${opts.log.transactionId.slice(0, 6)}]`
: ""
} ` +
queries.map((q) => q.text).join(" ") +
" Time: " +
((end - startTime) / 1000).toFixed(4)
);
}
if (!opts.log.suppress) {
console.info(
`[${dbName}]${
opts.log.transactionId
? `[tr_id=${opts.log.transactionId.slice(0, 6)}]`
: ""
} ` +
queries.map((q) => q.text).join(" ") +
" Time: " +
((end - startTime) / 1000).toFixed(4)
);
}
}
return result;
},
};
return result;
},
};
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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