@sqlrooms/duckdb 0.0.2 → 0.0.3
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/dist/arrow-utils.d.ts +8 -0
- package/dist/arrow-utils.d.ts.map +1 -0
- package/dist/arrow-utils.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +19 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
/**
|
|
3
|
+
* Converts an Arrow table to a JSON-compatible array of objects
|
|
4
|
+
* @see https://duckdb.org/docs/api/wasm/query.html#arrow-table-to-json
|
|
5
|
+
* @see https://github.com/apache/arrow/issues/37856
|
|
6
|
+
*/
|
|
7
|
+
export declare function arrowTableToJson(table: arrow.Table): Record<string, unknown>[];
|
|
8
|
+
//# sourceMappingURL=arrow-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-utils.d.ts","sourceRoot":"","sources":["../src/arrow-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAQ3B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an Arrow table to a JSON-compatible array of objects
|
|
3
|
+
* @see https://duckdb.org/docs/api/wasm/query.html#arrow-table-to-json
|
|
4
|
+
* @see https://github.com/apache/arrow/issues/37856
|
|
5
|
+
*/
|
|
6
|
+
export function arrowTableToJson(table) {
|
|
7
|
+
return table.toArray().map((row) => Object.fromEntries(Object.entries(row).map(([key, value]) => {
|
|
8
|
+
return [key, convertValue(value)];
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
function convertValue(value) {
|
|
12
|
+
if (typeof value === 'bigint') {
|
|
13
|
+
if (value >= Number.MIN_SAFE_INTEGER && value <= Number.MAX_SAFE_INTEGER) {
|
|
14
|
+
return Number(value);
|
|
15
|
+
}
|
|
16
|
+
return String(value);
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === 'number') {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
return String(value);
|
|
22
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/duckdb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"private": false,
|
|
9
|
+
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/sqlrooms/sqlrooms.git"
|
|
14
|
+
},
|
|
9
15
|
"files": [
|
|
10
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/__tests__"
|
|
11
18
|
],
|
|
12
19
|
"publishConfig": {
|
|
13
20
|
"access": "public"
|
|
@@ -16,12 +23,20 @@
|
|
|
16
23
|
"@duckdb/duckdb-wasm": "^1.29.0",
|
|
17
24
|
"apache-arrow": "^18.1.0"
|
|
18
25
|
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@sqlrooms/jest-config": "0.0.3",
|
|
28
|
+
"@types/jest": "^29.5.12",
|
|
29
|
+
"jest": "^29.7.0",
|
|
30
|
+
"ts-jest": "^29.1.2"
|
|
31
|
+
},
|
|
19
32
|
"scripts": {
|
|
20
33
|
"dev": "tsc -w",
|
|
21
34
|
"build": "tsc",
|
|
22
35
|
"lint": "eslint .",
|
|
23
36
|
"typecheck": "tsc --noEmit",
|
|
24
|
-
"typedoc": "typedoc"
|
|
37
|
+
"typedoc": "typedoc",
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"test:watch": "jest --watch"
|
|
25
40
|
},
|
|
26
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "4269a3efdb5a903cb2498c126e9c36683b3bbae0"
|
|
27
42
|
}
|