@visactor/vquery 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/db/duckDb.d.ts +28 -0
- package/dist/db/indexedDb.d.ts +11 -0
- package/dist/index.cjs +218 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +184 -0
- package/package.json +38 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 VisActor
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# VQuery
|
@@ -0,0 +1,28 @@
|
|
1
|
+
export declare class DuckDB {
|
2
|
+
private db;
|
3
|
+
private connection;
|
4
|
+
constructor();
|
5
|
+
/**
|
6
|
+
* @description 初始化 DuckDB 实例
|
7
|
+
*/
|
8
|
+
instantiate: () => Promise<void>;
|
9
|
+
/**
|
10
|
+
* @description 释放 DuckDB 实例
|
11
|
+
*/
|
12
|
+
close: () => Promise<void>;
|
13
|
+
/**
|
14
|
+
* 注册文件到 DuckDB 实例
|
15
|
+
* @param fileName 文件名
|
16
|
+
* @param source 文件内容
|
17
|
+
*/
|
18
|
+
registerFile: <T extends string | ArrayBuffer | Uint8Array | Blob>(fileName: string, source: T) => Promise<void>;
|
19
|
+
/**
|
20
|
+
* @description 执行 SQL 查询
|
21
|
+
* @param sql SQL 语句
|
22
|
+
* @returns 查询结果
|
23
|
+
*/
|
24
|
+
query: (sql: string) => Promise<{
|
25
|
+
dataset: any[];
|
26
|
+
table: any;
|
27
|
+
}>;
|
28
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export declare class IndexedDB {
|
2
|
+
private db;
|
3
|
+
private dbName;
|
4
|
+
private storeName;
|
5
|
+
constructor(dbName: string);
|
6
|
+
open: () => Promise<void>;
|
7
|
+
close: () => void;
|
8
|
+
writeFile: (fileName: string, data: Blob) => Promise<void>;
|
9
|
+
readFile: (fileName: string) => Promise<Blob | null>;
|
10
|
+
listFiles: () => Promise<string[]>;
|
11
|
+
}
|
package/dist/index.cjs
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __webpack_require__ = {};
|
3
|
+
(()=>{
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
6
|
+
enumerable: true,
|
7
|
+
get: definition[key]
|
8
|
+
});
|
9
|
+
};
|
10
|
+
})();
|
11
|
+
(()=>{
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
13
|
+
})();
|
14
|
+
(()=>{
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
17
|
+
value: 'Module'
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
20
|
+
value: true
|
21
|
+
});
|
22
|
+
};
|
23
|
+
})();
|
24
|
+
var __webpack_exports__ = {};
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
27
|
+
VQuery: ()=>VQuery
|
28
|
+
});
|
29
|
+
const duckdb_wasm_namespaceObject = require("@duckdb/duckdb-wasm");
|
30
|
+
class DuckDB {
|
31
|
+
db = null;
|
32
|
+
connection = null;
|
33
|
+
constructor(){}
|
34
|
+
instantiate = async ()=>{
|
35
|
+
const JSDELIVR_BUNDLES = (0, duckdb_wasm_namespaceObject.getJsDelivrBundles)();
|
36
|
+
const bundle = await (0, duckdb_wasm_namespaceObject.selectBundle)(JSDELIVR_BUNDLES);
|
37
|
+
const worker_url = URL.createObjectURL(new Blob([
|
38
|
+
`importScripts("${bundle.mainWorker}");`
|
39
|
+
], {
|
40
|
+
type: "text/javascript"
|
41
|
+
}));
|
42
|
+
const worker = new Worker(worker_url);
|
43
|
+
const logger = new duckdb_wasm_namespaceObject.ConsoleLogger();
|
44
|
+
this.db = new duckdb_wasm_namespaceObject.AsyncDuckDB(logger, worker);
|
45
|
+
await this.db.instantiate(bundle.mainModule, bundle.pthreadWorker);
|
46
|
+
URL.revokeObjectURL(worker_url);
|
47
|
+
this.connection = await this.db.connect();
|
48
|
+
};
|
49
|
+
close = async ()=>{
|
50
|
+
if (this.connection) {
|
51
|
+
await this.connection.close();
|
52
|
+
this.connection = null;
|
53
|
+
}
|
54
|
+
if (this.db) {
|
55
|
+
await this.db.terminate();
|
56
|
+
this.db = null;
|
57
|
+
}
|
58
|
+
};
|
59
|
+
registerFile = async (fileName, source)=>{
|
60
|
+
if (!this.db) throw new Error('db is null');
|
61
|
+
let uint8Array;
|
62
|
+
if ('string' == typeof source) {
|
63
|
+
const response = await fetch(source);
|
64
|
+
const buffer = await response.arrayBuffer();
|
65
|
+
uint8Array = new Uint8Array(buffer);
|
66
|
+
} else if (source instanceof Blob) {
|
67
|
+
const buffer = await source.arrayBuffer();
|
68
|
+
uint8Array = new Uint8Array(buffer);
|
69
|
+
} else if (source instanceof ArrayBuffer) uint8Array = new Uint8Array(source);
|
70
|
+
else if (source instanceof Uint8Array) uint8Array = source;
|
71
|
+
else throw new Error('Unsupported source type');
|
72
|
+
await this.db.registerFileBuffer(fileName, uint8Array);
|
73
|
+
};
|
74
|
+
query = async (sql)=>{
|
75
|
+
if (!this.connection) throw new Error('connection is null');
|
76
|
+
const table = await this.connection.query(sql);
|
77
|
+
const dataset = table.toArray().map((row)=>row.toJSON());
|
78
|
+
return {
|
79
|
+
dataset,
|
80
|
+
table
|
81
|
+
};
|
82
|
+
};
|
83
|
+
}
|
84
|
+
class IndexedDB {
|
85
|
+
db = null;
|
86
|
+
dbName;
|
87
|
+
storeName = 'files';
|
88
|
+
constructor(dbName){
|
89
|
+
this.dbName = dbName;
|
90
|
+
}
|
91
|
+
open = ()=>new Promise((resolve, reject)=>{
|
92
|
+
const request = indexedDB.open(this.dbName, 1);
|
93
|
+
request.onupgradeneeded = (event)=>{
|
94
|
+
const db = event.target.result;
|
95
|
+
if (!db.objectStoreNames.contains(this.storeName)) db.createObjectStore(this.storeName, {
|
96
|
+
keyPath: 'name'
|
97
|
+
});
|
98
|
+
};
|
99
|
+
request.onsuccess = (event)=>{
|
100
|
+
this.db = event.target.result;
|
101
|
+
resolve();
|
102
|
+
};
|
103
|
+
request.onerror = (event)=>{
|
104
|
+
reject(event.target.error);
|
105
|
+
};
|
106
|
+
});
|
107
|
+
close = ()=>{
|
108
|
+
if (this.db) {
|
109
|
+
this.db.close();
|
110
|
+
this.db = null;
|
111
|
+
}
|
112
|
+
};
|
113
|
+
writeFile = (fileName, data)=>new Promise((resolve, reject)=>{
|
114
|
+
if (!this.db) return reject('DB is not open');
|
115
|
+
const transaction = this.db.transaction([
|
116
|
+
this.storeName
|
117
|
+
], 'readwrite');
|
118
|
+
const store = transaction.objectStore(this.storeName);
|
119
|
+
const request = store.put({
|
120
|
+
name: fileName,
|
121
|
+
data
|
122
|
+
});
|
123
|
+
request.onsuccess = ()=>{
|
124
|
+
resolve();
|
125
|
+
};
|
126
|
+
request.onerror = (event)=>{
|
127
|
+
reject(event.target.error);
|
128
|
+
};
|
129
|
+
});
|
130
|
+
readFile = (fileName)=>new Promise((resolve, reject)=>{
|
131
|
+
if (!this.db) return reject('DB is not open');
|
132
|
+
const transaction = this.db.transaction([
|
133
|
+
this.storeName
|
134
|
+
], 'readonly');
|
135
|
+
const store = transaction.objectStore(this.storeName);
|
136
|
+
const request = store.get(fileName);
|
137
|
+
request.onsuccess = (event)=>{
|
138
|
+
const result = event.target.result;
|
139
|
+
result ? resolve(result.data) : resolve(null);
|
140
|
+
};
|
141
|
+
request.onerror = (event)=>{
|
142
|
+
reject(event.target.error);
|
143
|
+
};
|
144
|
+
});
|
145
|
+
listFiles = ()=>new Promise((resolve, reject)=>{
|
146
|
+
if (!this.db) return reject('DB is not open');
|
147
|
+
const transaction = this.db.transaction([
|
148
|
+
this.storeName
|
149
|
+
], 'readonly');
|
150
|
+
const store = transaction.objectStore(this.storeName);
|
151
|
+
const request = store.getAllKeys();
|
152
|
+
request.onsuccess = (event)=>{
|
153
|
+
const keys = event.target.result;
|
154
|
+
resolve(keys);
|
155
|
+
};
|
156
|
+
request.onerror = (event)=>{
|
157
|
+
reject(event.target.error);
|
158
|
+
};
|
159
|
+
});
|
160
|
+
}
|
161
|
+
class VQuery {
|
162
|
+
duckDB;
|
163
|
+
indexedDB;
|
164
|
+
constructor(dbName = 'vquery'){
|
165
|
+
this.duckDB = new DuckDB();
|
166
|
+
this.indexedDB = new IndexedDB(dbName);
|
167
|
+
}
|
168
|
+
instantiate = async ()=>{
|
169
|
+
await this.duckDB.instantiate();
|
170
|
+
await this.indexedDB.open();
|
171
|
+
};
|
172
|
+
close = async ()=>{
|
173
|
+
await this.duckDB.close();
|
174
|
+
this.indexedDB.close();
|
175
|
+
};
|
176
|
+
registerFile = async (fileName, source)=>{
|
177
|
+
let blob;
|
178
|
+
if ('string' == typeof source) {
|
179
|
+
const response = await fetch(source);
|
180
|
+
blob = await response.blob();
|
181
|
+
} else if (source instanceof ArrayBuffer) blob = new Blob([
|
182
|
+
source
|
183
|
+
]);
|
184
|
+
else if (source instanceof Uint8Array) blob = new Blob([
|
185
|
+
source.slice()
|
186
|
+
]);
|
187
|
+
else if (source instanceof Blob) blob = source;
|
188
|
+
else throw new Error('Unsupported source type');
|
189
|
+
await this.indexedDB.writeFile(fileName, blob);
|
190
|
+
await this.duckDB.registerFile(fileName, blob);
|
191
|
+
};
|
192
|
+
loadFile = async (fileName)=>{
|
193
|
+
const blob = await this.indexedDB.readFile(fileName);
|
194
|
+
if (blob) await this.duckDB.registerFile(fileName, blob);
|
195
|
+
else throw new Error(`File ${fileName} not found in IndexedDB`);
|
196
|
+
};
|
197
|
+
listFiles = ()=>this.indexedDB.listFiles();
|
198
|
+
query = async (sql)=>{
|
199
|
+
const start = performance?.now?.()?.toFixed(3) ?? Date.now().toFixed(3);
|
200
|
+
const result = await this.duckDB.query(sql);
|
201
|
+
const end = performance?.now?.()?.toFixed(3) ?? Date.now().toFixed(3);
|
202
|
+
return {
|
203
|
+
...result,
|
204
|
+
performance: {
|
205
|
+
startAt: start,
|
206
|
+
endAt: end,
|
207
|
+
duration: Number(end) - Number(start)
|
208
|
+
}
|
209
|
+
};
|
210
|
+
};
|
211
|
+
}
|
212
|
+
exports.VQuery = __webpack_exports__.VQuery;
|
213
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
214
|
+
"VQuery"
|
215
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
216
|
+
Object.defineProperty(exports, '__esModule', {
|
217
|
+
value: true
|
218
|
+
});
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
export declare class VQuery {
|
2
|
+
private duckDB;
|
3
|
+
private indexedDB;
|
4
|
+
constructor(dbName?: string);
|
5
|
+
/**
|
6
|
+
* @description 初始化数据库
|
7
|
+
*/
|
8
|
+
instantiate: () => Promise<void>;
|
9
|
+
/**
|
10
|
+
* @description 关闭数据库
|
11
|
+
*/
|
12
|
+
close: () => Promise<void>;
|
13
|
+
/**
|
14
|
+
* @description 注册文件
|
15
|
+
* @param fileName 文件名
|
16
|
+
* @param source 文件内容
|
17
|
+
*/
|
18
|
+
registerFile: (fileName: string, source: string | ArrayBuffer | Uint8Array | Blob) => Promise<void>;
|
19
|
+
/**
|
20
|
+
* @description 从 IndexedDB 读取文件并注册到 DuckDB
|
21
|
+
* @param fileName 文件名
|
22
|
+
*/
|
23
|
+
loadFile: (fileName: string) => Promise<void>;
|
24
|
+
/**
|
25
|
+
* @description 列出 IndexedDB 中的所有文件
|
26
|
+
*/
|
27
|
+
listFiles: () => Promise<string[]>;
|
28
|
+
/**
|
29
|
+
* @description 执行 SQL 查询
|
30
|
+
* @param sql SQL 语句
|
31
|
+
*/
|
32
|
+
query: (sql: string) => Promise<{
|
33
|
+
performance: {
|
34
|
+
startAt: string;
|
35
|
+
endAt: string;
|
36
|
+
duration: number;
|
37
|
+
};
|
38
|
+
dataset: any[];
|
39
|
+
table: any;
|
40
|
+
}>;
|
41
|
+
}
|
package/dist/index.js
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
import { AsyncDuckDB, ConsoleLogger, getJsDelivrBundles, selectBundle } from "@duckdb/duckdb-wasm";
|
2
|
+
class DuckDB {
|
3
|
+
db = null;
|
4
|
+
connection = null;
|
5
|
+
constructor(){}
|
6
|
+
instantiate = async ()=>{
|
7
|
+
const JSDELIVR_BUNDLES = getJsDelivrBundles();
|
8
|
+
const bundle = await selectBundle(JSDELIVR_BUNDLES);
|
9
|
+
const worker_url = URL.createObjectURL(new Blob([
|
10
|
+
`importScripts("${bundle.mainWorker}");`
|
11
|
+
], {
|
12
|
+
type: "text/javascript"
|
13
|
+
}));
|
14
|
+
const worker = new Worker(worker_url);
|
15
|
+
const logger = new ConsoleLogger();
|
16
|
+
this.db = new AsyncDuckDB(logger, worker);
|
17
|
+
await this.db.instantiate(bundle.mainModule, bundle.pthreadWorker);
|
18
|
+
URL.revokeObjectURL(worker_url);
|
19
|
+
this.connection = await this.db.connect();
|
20
|
+
};
|
21
|
+
close = async ()=>{
|
22
|
+
if (this.connection) {
|
23
|
+
await this.connection.close();
|
24
|
+
this.connection = null;
|
25
|
+
}
|
26
|
+
if (this.db) {
|
27
|
+
await this.db.terminate();
|
28
|
+
this.db = null;
|
29
|
+
}
|
30
|
+
};
|
31
|
+
registerFile = async (fileName, source)=>{
|
32
|
+
if (!this.db) throw new Error('db is null');
|
33
|
+
let uint8Array;
|
34
|
+
if ('string' == typeof source) {
|
35
|
+
const response = await fetch(source);
|
36
|
+
const buffer = await response.arrayBuffer();
|
37
|
+
uint8Array = new Uint8Array(buffer);
|
38
|
+
} else if (source instanceof Blob) {
|
39
|
+
const buffer = await source.arrayBuffer();
|
40
|
+
uint8Array = new Uint8Array(buffer);
|
41
|
+
} else if (source instanceof ArrayBuffer) uint8Array = new Uint8Array(source);
|
42
|
+
else if (source instanceof Uint8Array) uint8Array = source;
|
43
|
+
else throw new Error('Unsupported source type');
|
44
|
+
await this.db.registerFileBuffer(fileName, uint8Array);
|
45
|
+
};
|
46
|
+
query = async (sql)=>{
|
47
|
+
if (!this.connection) throw new Error('connection is null');
|
48
|
+
const table = await this.connection.query(sql);
|
49
|
+
const dataset = table.toArray().map((row)=>row.toJSON());
|
50
|
+
return {
|
51
|
+
dataset,
|
52
|
+
table
|
53
|
+
};
|
54
|
+
};
|
55
|
+
}
|
56
|
+
class IndexedDB {
|
57
|
+
db = null;
|
58
|
+
dbName;
|
59
|
+
storeName = 'files';
|
60
|
+
constructor(dbName){
|
61
|
+
this.dbName = dbName;
|
62
|
+
}
|
63
|
+
open = ()=>new Promise((resolve, reject)=>{
|
64
|
+
const request = indexedDB.open(this.dbName, 1);
|
65
|
+
request.onupgradeneeded = (event)=>{
|
66
|
+
const db = event.target.result;
|
67
|
+
if (!db.objectStoreNames.contains(this.storeName)) db.createObjectStore(this.storeName, {
|
68
|
+
keyPath: 'name'
|
69
|
+
});
|
70
|
+
};
|
71
|
+
request.onsuccess = (event)=>{
|
72
|
+
this.db = event.target.result;
|
73
|
+
resolve();
|
74
|
+
};
|
75
|
+
request.onerror = (event)=>{
|
76
|
+
reject(event.target.error);
|
77
|
+
};
|
78
|
+
});
|
79
|
+
close = ()=>{
|
80
|
+
if (this.db) {
|
81
|
+
this.db.close();
|
82
|
+
this.db = null;
|
83
|
+
}
|
84
|
+
};
|
85
|
+
writeFile = (fileName, data)=>new Promise((resolve, reject)=>{
|
86
|
+
if (!this.db) return reject('DB is not open');
|
87
|
+
const transaction = this.db.transaction([
|
88
|
+
this.storeName
|
89
|
+
], 'readwrite');
|
90
|
+
const store = transaction.objectStore(this.storeName);
|
91
|
+
const request = store.put({
|
92
|
+
name: fileName,
|
93
|
+
data
|
94
|
+
});
|
95
|
+
request.onsuccess = ()=>{
|
96
|
+
resolve();
|
97
|
+
};
|
98
|
+
request.onerror = (event)=>{
|
99
|
+
reject(event.target.error);
|
100
|
+
};
|
101
|
+
});
|
102
|
+
readFile = (fileName)=>new Promise((resolve, reject)=>{
|
103
|
+
if (!this.db) return reject('DB is not open');
|
104
|
+
const transaction = this.db.transaction([
|
105
|
+
this.storeName
|
106
|
+
], 'readonly');
|
107
|
+
const store = transaction.objectStore(this.storeName);
|
108
|
+
const request = store.get(fileName);
|
109
|
+
request.onsuccess = (event)=>{
|
110
|
+
const result = event.target.result;
|
111
|
+
result ? resolve(result.data) : resolve(null);
|
112
|
+
};
|
113
|
+
request.onerror = (event)=>{
|
114
|
+
reject(event.target.error);
|
115
|
+
};
|
116
|
+
});
|
117
|
+
listFiles = ()=>new Promise((resolve, reject)=>{
|
118
|
+
if (!this.db) return reject('DB is not open');
|
119
|
+
const transaction = this.db.transaction([
|
120
|
+
this.storeName
|
121
|
+
], 'readonly');
|
122
|
+
const store = transaction.objectStore(this.storeName);
|
123
|
+
const request = store.getAllKeys();
|
124
|
+
request.onsuccess = (event)=>{
|
125
|
+
const keys = event.target.result;
|
126
|
+
resolve(keys);
|
127
|
+
};
|
128
|
+
request.onerror = (event)=>{
|
129
|
+
reject(event.target.error);
|
130
|
+
};
|
131
|
+
});
|
132
|
+
}
|
133
|
+
class VQuery {
|
134
|
+
duckDB;
|
135
|
+
indexedDB;
|
136
|
+
constructor(dbName = 'vquery'){
|
137
|
+
this.duckDB = new DuckDB();
|
138
|
+
this.indexedDB = new IndexedDB(dbName);
|
139
|
+
}
|
140
|
+
instantiate = async ()=>{
|
141
|
+
await this.duckDB.instantiate();
|
142
|
+
await this.indexedDB.open();
|
143
|
+
};
|
144
|
+
close = async ()=>{
|
145
|
+
await this.duckDB.close();
|
146
|
+
this.indexedDB.close();
|
147
|
+
};
|
148
|
+
registerFile = async (fileName, source)=>{
|
149
|
+
let blob;
|
150
|
+
if ('string' == typeof source) {
|
151
|
+
const response = await fetch(source);
|
152
|
+
blob = await response.blob();
|
153
|
+
} else if (source instanceof ArrayBuffer) blob = new Blob([
|
154
|
+
source
|
155
|
+
]);
|
156
|
+
else if (source instanceof Uint8Array) blob = new Blob([
|
157
|
+
source.slice()
|
158
|
+
]);
|
159
|
+
else if (source instanceof Blob) blob = source;
|
160
|
+
else throw new Error('Unsupported source type');
|
161
|
+
await this.indexedDB.writeFile(fileName, blob);
|
162
|
+
await this.duckDB.registerFile(fileName, blob);
|
163
|
+
};
|
164
|
+
loadFile = async (fileName)=>{
|
165
|
+
const blob = await this.indexedDB.readFile(fileName);
|
166
|
+
if (blob) await this.duckDB.registerFile(fileName, blob);
|
167
|
+
else throw new Error(`File ${fileName} not found in IndexedDB`);
|
168
|
+
};
|
169
|
+
listFiles = ()=>this.indexedDB.listFiles();
|
170
|
+
query = async (sql)=>{
|
171
|
+
const start = performance?.now?.()?.toFixed(3) ?? Date.now().toFixed(3);
|
172
|
+
const result = await this.duckDB.query(sql);
|
173
|
+
const end = performance?.now?.()?.toFixed(3) ?? Date.now().toFixed(3);
|
174
|
+
return {
|
175
|
+
...result,
|
176
|
+
performance: {
|
177
|
+
startAt: start,
|
178
|
+
endAt: end,
|
179
|
+
duration: Number(end) - Number(start)
|
180
|
+
}
|
181
|
+
};
|
182
|
+
};
|
183
|
+
}
|
184
|
+
export { VQuery };
|
package/package.json
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"name": "@visactor/vquery",
|
3
|
+
"version": "0.1.28",
|
4
|
+
"type": "module",
|
5
|
+
"exports": {
|
6
|
+
".": {
|
7
|
+
"types": "./dist/index.d.ts",
|
8
|
+
"import": "./dist/index.js",
|
9
|
+
"require": "./dist/index.cjs"
|
10
|
+
}
|
11
|
+
},
|
12
|
+
"main": "./dist/index.cjs",
|
13
|
+
"types": "./dist/index.d.ts",
|
14
|
+
"files": [
|
15
|
+
"dist"
|
16
|
+
],
|
17
|
+
"dependencies": {
|
18
|
+
"@duckdb/duckdb-wasm": "latest"
|
19
|
+
},
|
20
|
+
"devDependencies": {
|
21
|
+
"@eslint/js": "^9.35.0",
|
22
|
+
"@rslib/core": "^0.15.1",
|
23
|
+
"@rstest/core": "^0.5.1",
|
24
|
+
"@types/node": "^22.18.10",
|
25
|
+
"@rstest/coverage-istanbul": "^0.0.2",
|
26
|
+
"eslint": "^9.35.0",
|
27
|
+
"globals": "^16.3.0",
|
28
|
+
"typescript": "^5.9.3",
|
29
|
+
"typescript-eslint": "^8.43.0"
|
30
|
+
},
|
31
|
+
"scripts": {
|
32
|
+
"build": "rslib build",
|
33
|
+
"dev": "rslib build --watch",
|
34
|
+
"lint": "eslint .",
|
35
|
+
"test": "rstest",
|
36
|
+
"type-check": "tsc --noEmit"
|
37
|
+
}
|
38
|
+
}
|