@duckdb/node-api 1.2.1-alpha.16 → 1.2.2-alpha.18
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/README.md +223 -28
- package/lib/DuckDBAppender.d.ts +2 -2
- package/lib/DuckDBAppender.js +4 -4
- package/lib/DuckDBConnection.d.ts +4 -4
- package/lib/DuckDBConnection.js +10 -6
- package/lib/DuckDBDataChunk.d.ts +12 -4
- package/lib/DuckDBDataChunk.js +64 -6
- package/lib/DuckDBInstance.d.ts +2 -0
- package/lib/DuckDBInstance.js +9 -9
- package/lib/DuckDBInstanceCache.d.ts +8 -0
- package/lib/DuckDBInstanceCache.js +28 -0
- package/lib/DuckDBResult.d.ts +15 -1
- package/lib/DuckDBResult.js +62 -9
- package/lib/DuckDBResultReader.d.ts +15 -1
- package/lib/DuckDBResultReader.js +42 -5
- package/lib/DuckDBType.d.ts +9 -0
- package/lib/DuckDBType.js +61 -0
- package/lib/DuckDBValueConverter.d.ts +1 -3
- package/lib/DuckDBValueConverters.d.ts +47 -0
- package/lib/DuckDBValueConverters.js +214 -0
- package/lib/JS.d.ts +3 -0
- package/lib/JS.js +2 -0
- package/lib/JSDuckDBValueConverter.d.ts +3 -0
- package/lib/JSDuckDBValueConverter.js +46 -0
- package/lib/Json.d.ts +3 -0
- package/lib/Json.js +2 -0
- package/lib/JsonDuckDBValueConverter.d.ts +3 -0
- package/lib/JsonDuckDBValueConverter.js +46 -0
- package/lib/conversion/stringFromBlob.d.ts +2 -0
- package/lib/conversion/stringFromBlob.js +28 -2
- package/lib/convertColumnsFromChunks.d.ts +1 -1
- package/lib/convertColumnsFromChunks.js +1 -1
- package/lib/convertColumnsObjectFromChunks.d.ts +1 -1
- package/lib/convertColumnsObjectFromChunks.js +1 -1
- package/lib/convertRowObjectsFromChunks.d.ts +1 -1
- package/lib/convertRowObjectsFromChunks.js +1 -1
- package/lib/convertRowsFromChunks.d.ts +1 -1
- package/lib/createConfig.d.ts +2 -0
- package/lib/createConfig.js +19 -0
- package/lib/createDuckDBValueConverter.d.ts +3 -0
- package/lib/createDuckDBValueConverter.js +15 -0
- package/lib/duckdb.d.ts +8 -3
- package/lib/duckdb.js +10 -5
- package/lib/getColumnsFromChunks.js +2 -8
- package/lib/getColumnsObjectFromChunks.js +2 -11
- package/lib/getRowObjectsFromChunks.js +1 -8
- package/lib/getRowsFromChunks.js +1 -1
- package/lib/values/DuckDBBitValue.d.ts +1 -1
- package/lib/values/DuckDBBitValue.js +13 -2
- package/lib/values/DuckDBDateValue.d.ts +1 -1
- package/lib/values/DuckDBDateValue.js +5 -2
- package/lib/values/DuckDBDecimalValue.d.ts +1 -1
- package/lib/values/DuckDBDecimalValue.js +3 -0
- package/lib/values/DuckDBTimeValue.d.ts +1 -1
- package/lib/values/DuckDBTimeValue.js +5 -2
- package/lib/values/DuckDBTimestampTZValue.d.ts +1 -1
- package/lib/values/DuckDBTimestampTZValue.js +5 -2
- package/lib/values/DuckDBTimestampValue.d.ts +1 -1
- package/lib/values/DuckDBTimestampValue.js +5 -2
- package/package.json +2 -2
- package/lib/DuckDBValueToJsonConverter.d.ts +0 -10
- package/lib/DuckDBValueToJsonConverter.js +0 -101
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unsupportedConverter = unsupportedConverter;
|
|
4
|
+
exports.nullConverter = nullConverter;
|
|
5
|
+
exports.booleanFromValue = booleanFromValue;
|
|
6
|
+
exports.numberFromValue = numberFromValue;
|
|
7
|
+
exports.jsonNumberFromValue = jsonNumberFromValue;
|
|
8
|
+
exports.bigintFromBigIntValue = bigintFromBigIntValue;
|
|
9
|
+
exports.stringFromValue = stringFromValue;
|
|
10
|
+
exports.bytesFromBlobValue = bytesFromBlobValue;
|
|
11
|
+
exports.bytesFromBitValue = bytesFromBitValue;
|
|
12
|
+
exports.dateFromDateValue = dateFromDateValue;
|
|
13
|
+
exports.bigintFromTimeValue = bigintFromTimeValue;
|
|
14
|
+
exports.dateFromTimestampValue = dateFromTimestampValue;
|
|
15
|
+
exports.dateFromTimestampSecondsValue = dateFromTimestampSecondsValue;
|
|
16
|
+
exports.dateFromTimestampMillisecondsValue = dateFromTimestampMillisecondsValue;
|
|
17
|
+
exports.dateFromTimestampNanosecondsValue = dateFromTimestampNanosecondsValue;
|
|
18
|
+
exports.objectFromTimeTZValue = objectFromTimeTZValue;
|
|
19
|
+
exports.dateFromTimestampTZValue = dateFromTimestampTZValue;
|
|
20
|
+
exports.objectFromIntervalValue = objectFromIntervalValue;
|
|
21
|
+
exports.jsonObjectFromIntervalValue = jsonObjectFromIntervalValue;
|
|
22
|
+
exports.doubleFromDecimalValue = doubleFromDecimalValue;
|
|
23
|
+
exports.arrayFromListValue = arrayFromListValue;
|
|
24
|
+
exports.objectFromStructValue = objectFromStructValue;
|
|
25
|
+
exports.objectArrayFromMapValue = objectArrayFromMapValue;
|
|
26
|
+
exports.arrayFromArrayValue = arrayFromArrayValue;
|
|
27
|
+
exports.objectFromUnionValue = objectFromUnionValue;
|
|
28
|
+
const DuckDBType_1 = require("./DuckDBType");
|
|
29
|
+
const values_1 = require("./values");
|
|
30
|
+
const MIN_DATE_DAYS = -100000000;
|
|
31
|
+
const MAX_DATE_DAYS = 100000000;
|
|
32
|
+
// -8640000000000
|
|
33
|
+
const MIN_DATE_MILLIS = -8640000000000000;
|
|
34
|
+
const MAX_DATE_MILLIS = 8640000000000000;
|
|
35
|
+
const MILLS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
36
|
+
function unsupportedConverter(_, type) {
|
|
37
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
38
|
+
}
|
|
39
|
+
function nullConverter(_) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function booleanFromValue(value) {
|
|
43
|
+
return Boolean(value);
|
|
44
|
+
}
|
|
45
|
+
function numberFromValue(value) {
|
|
46
|
+
return Number(value);
|
|
47
|
+
}
|
|
48
|
+
function jsonNumberFromValue(value) {
|
|
49
|
+
if (Number.isFinite(value)) {
|
|
50
|
+
return Number(value);
|
|
51
|
+
}
|
|
52
|
+
return String(value);
|
|
53
|
+
}
|
|
54
|
+
function bigintFromBigIntValue(value, type) {
|
|
55
|
+
if (typeof value === 'bigint') {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Expected bigint value for type ${type}`);
|
|
59
|
+
}
|
|
60
|
+
function stringFromValue(value) {
|
|
61
|
+
return String(value);
|
|
62
|
+
}
|
|
63
|
+
function bytesFromBlobValue(value) {
|
|
64
|
+
if (value instanceof values_1.DuckDBBlobValue) {
|
|
65
|
+
return value.bytes;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`Expected DuckDBBlobValue`);
|
|
68
|
+
}
|
|
69
|
+
function bytesFromBitValue(value) {
|
|
70
|
+
if (value instanceof values_1.DuckDBBitValue) {
|
|
71
|
+
return value.data;
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`Expected DuckDBBitValue`);
|
|
74
|
+
}
|
|
75
|
+
function dateFromDateValue(value) {
|
|
76
|
+
if (value instanceof values_1.DuckDBDateValue) {
|
|
77
|
+
if (MIN_DATE_DAYS <= value.days && value.days <= MAX_DATE_DAYS) {
|
|
78
|
+
return new Date(value.days * MILLS_PER_DAY);
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`DATE value out of range for JS Date: ${value.days} days`);
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`Expected DuckDBDateValue`);
|
|
83
|
+
}
|
|
84
|
+
function bigintFromTimeValue(value) {
|
|
85
|
+
if (value instanceof values_1.DuckDBTimeValue) {
|
|
86
|
+
return value.micros;
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`Expected DuckDBTimeValue`);
|
|
89
|
+
}
|
|
90
|
+
function dateFromTimestampValue(value) {
|
|
91
|
+
if (value instanceof values_1.DuckDBTimestampValue) {
|
|
92
|
+
const millis = value.micros / 1000n;
|
|
93
|
+
if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
|
|
94
|
+
return new Date(Number(millis));
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`TIMESTAMP value out of range for JS Date: ${value.micros} micros`);
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Expected DuckDBTimestampValue`);
|
|
99
|
+
}
|
|
100
|
+
function dateFromTimestampSecondsValue(value) {
|
|
101
|
+
if (value instanceof values_1.DuckDBTimestampSecondsValue) {
|
|
102
|
+
const millis = value.seconds * 1000n;
|
|
103
|
+
if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
|
|
104
|
+
return new Date(Number(millis));
|
|
105
|
+
}
|
|
106
|
+
throw new Error(`TIMESTAMP_S value out of range for JS Date: ${value.seconds} seconds`);
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`Expected DuckDBTimestampSecondsValue`);
|
|
109
|
+
}
|
|
110
|
+
function dateFromTimestampMillisecondsValue(value) {
|
|
111
|
+
if (value instanceof values_1.DuckDBTimestampMillisecondsValue) {
|
|
112
|
+
const millis = value.millis;
|
|
113
|
+
if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
|
|
114
|
+
return new Date(Number(millis));
|
|
115
|
+
}
|
|
116
|
+
throw new Error(`TIMESTAMP_MS value out of range for JS Date: ${value.millis} millis`);
|
|
117
|
+
}
|
|
118
|
+
throw new Error(`Expected DuckDBTimestampMillisecondsValue`);
|
|
119
|
+
}
|
|
120
|
+
function dateFromTimestampNanosecondsValue(value) {
|
|
121
|
+
if (value instanceof values_1.DuckDBTimestampNanosecondsValue) {
|
|
122
|
+
const millis = value.nanos / 1000000n;
|
|
123
|
+
if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
|
|
124
|
+
return new Date(Number(millis));
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`TIMESTAMP_NS value out of range for JS Date: ${value.nanos} nanos`);
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`Expected DuckDBTimestampNanosecondsValue`);
|
|
129
|
+
}
|
|
130
|
+
function objectFromTimeTZValue(value) {
|
|
131
|
+
if (value instanceof values_1.DuckDBTimeTZValue) {
|
|
132
|
+
return {
|
|
133
|
+
micros: value.micros,
|
|
134
|
+
offset: value.offset,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`Expected DuckDBTimeTZValue`);
|
|
138
|
+
}
|
|
139
|
+
function dateFromTimestampTZValue(value) {
|
|
140
|
+
if (value instanceof values_1.DuckDBTimestampTZValue) {
|
|
141
|
+
const millis = value.micros / 1000n;
|
|
142
|
+
if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
|
|
143
|
+
return new Date(Number(millis));
|
|
144
|
+
}
|
|
145
|
+
throw new Error(`TIMESTAMPTZ value out of range for JS Date: ${value.micros} micros`);
|
|
146
|
+
}
|
|
147
|
+
throw new Error(`Expected DuckDBTimestampTZValue`);
|
|
148
|
+
}
|
|
149
|
+
function objectFromIntervalValue(value) {
|
|
150
|
+
if (value instanceof values_1.DuckDBIntervalValue) {
|
|
151
|
+
return {
|
|
152
|
+
months: value.months,
|
|
153
|
+
days: value.days,
|
|
154
|
+
micros: value.micros,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
throw new Error(`Expected DuckDBIntervalValue`);
|
|
158
|
+
}
|
|
159
|
+
function jsonObjectFromIntervalValue(value) {
|
|
160
|
+
if (value instanceof values_1.DuckDBIntervalValue) {
|
|
161
|
+
return {
|
|
162
|
+
months: value.months,
|
|
163
|
+
days: value.days,
|
|
164
|
+
micros: String(value.micros),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
throw new Error(`Expected DuckDBIntervalValue`);
|
|
168
|
+
}
|
|
169
|
+
function doubleFromDecimalValue(value) {
|
|
170
|
+
if (value instanceof values_1.DuckDBDecimalValue) {
|
|
171
|
+
return value.toDouble();
|
|
172
|
+
}
|
|
173
|
+
throw new Error(`Expected DuckDBDecimalValue`);
|
|
174
|
+
}
|
|
175
|
+
function arrayFromListValue(value, type, converter) {
|
|
176
|
+
if (value instanceof values_1.DuckDBListValue && type instanceof DuckDBType_1.DuckDBListType) {
|
|
177
|
+
return value.items.map((v) => converter(v, type.valueType, converter));
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`Expected DuckDBListValue and DuckDBListType`);
|
|
180
|
+
}
|
|
181
|
+
function objectFromStructValue(value, type, converter) {
|
|
182
|
+
if (value instanceof values_1.DuckDBStructValue && type instanceof DuckDBType_1.DuckDBStructType) {
|
|
183
|
+
const result = {};
|
|
184
|
+
for (const key in value.entries) {
|
|
185
|
+
result[key] = converter(value.entries[key], type.typeForEntry(key), converter);
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
throw new Error(`Expected DuckDBStructValue and DuckDBStructType`);
|
|
190
|
+
}
|
|
191
|
+
function objectArrayFromMapValue(value, type, converter) {
|
|
192
|
+
if (value instanceof values_1.DuckDBMapValue && type instanceof DuckDBType_1.DuckDBMapType) {
|
|
193
|
+
return value.entries.map((entry) => ({
|
|
194
|
+
key: converter(entry.key, type.keyType, converter),
|
|
195
|
+
value: converter(entry.value, type.valueType, converter),
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
throw new Error(`Expected DuckDBMapValue and DuckDBMapType`);
|
|
199
|
+
}
|
|
200
|
+
function arrayFromArrayValue(value, type, converter) {
|
|
201
|
+
if (value instanceof values_1.DuckDBArrayValue && type instanceof DuckDBType_1.DuckDBArrayType) {
|
|
202
|
+
return value.items.map((v) => converter(v, type.valueType, converter));
|
|
203
|
+
}
|
|
204
|
+
throw new Error(`Expected DuckDBArrayValue and DuckDBArrayType`);
|
|
205
|
+
}
|
|
206
|
+
function objectFromUnionValue(value, type, converter) {
|
|
207
|
+
if (value instanceof values_1.DuckDBUnionValue && type instanceof DuckDBType_1.DuckDBUnionType) {
|
|
208
|
+
return {
|
|
209
|
+
tag: value.tag,
|
|
210
|
+
value: converter(value.value, type.memberTypeForTag(value.tag), converter),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
throw new Error(`Expected DuckDBUnionValue and DuckDBUnionType`);
|
|
214
|
+
}
|
package/lib/JS.d.ts
ADDED
package/lib/JS.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSDuckDBValueConverter = void 0;
|
|
4
|
+
const createDuckDBValueConverter_1 = require("./createDuckDBValueConverter");
|
|
5
|
+
const DuckDBTypeId_1 = require("./DuckDBTypeId");
|
|
6
|
+
const DuckDBValueConverters_1 = require("./DuckDBValueConverters");
|
|
7
|
+
const JSConvertersByTypeId = {
|
|
8
|
+
[DuckDBTypeId_1.DuckDBTypeId.INVALID]: DuckDBValueConverters_1.unsupportedConverter,
|
|
9
|
+
[DuckDBTypeId_1.DuckDBTypeId.BOOLEAN]: DuckDBValueConverters_1.booleanFromValue,
|
|
10
|
+
[DuckDBTypeId_1.DuckDBTypeId.TINYINT]: DuckDBValueConverters_1.numberFromValue,
|
|
11
|
+
[DuckDBTypeId_1.DuckDBTypeId.SMALLINT]: DuckDBValueConverters_1.numberFromValue,
|
|
12
|
+
[DuckDBTypeId_1.DuckDBTypeId.INTEGER]: DuckDBValueConverters_1.numberFromValue,
|
|
13
|
+
[DuckDBTypeId_1.DuckDBTypeId.BIGINT]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
14
|
+
[DuckDBTypeId_1.DuckDBTypeId.UTINYINT]: DuckDBValueConverters_1.numberFromValue,
|
|
15
|
+
[DuckDBTypeId_1.DuckDBTypeId.USMALLINT]: DuckDBValueConverters_1.numberFromValue,
|
|
16
|
+
[DuckDBTypeId_1.DuckDBTypeId.UINTEGER]: DuckDBValueConverters_1.numberFromValue,
|
|
17
|
+
[DuckDBTypeId_1.DuckDBTypeId.UBIGINT]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
18
|
+
[DuckDBTypeId_1.DuckDBTypeId.FLOAT]: DuckDBValueConverters_1.numberFromValue,
|
|
19
|
+
[DuckDBTypeId_1.DuckDBTypeId.DOUBLE]: DuckDBValueConverters_1.numberFromValue,
|
|
20
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP]: DuckDBValueConverters_1.dateFromTimestampValue,
|
|
21
|
+
[DuckDBTypeId_1.DuckDBTypeId.DATE]: DuckDBValueConverters_1.dateFromDateValue,
|
|
22
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIME]: DuckDBValueConverters_1.bigintFromTimeValue,
|
|
23
|
+
[DuckDBTypeId_1.DuckDBTypeId.INTERVAL]: DuckDBValueConverters_1.objectFromIntervalValue,
|
|
24
|
+
[DuckDBTypeId_1.DuckDBTypeId.HUGEINT]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
25
|
+
[DuckDBTypeId_1.DuckDBTypeId.UHUGEINT]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
26
|
+
[DuckDBTypeId_1.DuckDBTypeId.VARCHAR]: DuckDBValueConverters_1.stringFromValue,
|
|
27
|
+
[DuckDBTypeId_1.DuckDBTypeId.BLOB]: DuckDBValueConverters_1.bytesFromBlobValue,
|
|
28
|
+
[DuckDBTypeId_1.DuckDBTypeId.DECIMAL]: DuckDBValueConverters_1.doubleFromDecimalValue,
|
|
29
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S]: DuckDBValueConverters_1.dateFromTimestampSecondsValue,
|
|
30
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS]: DuckDBValueConverters_1.dateFromTimestampMillisecondsValue,
|
|
31
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS]: DuckDBValueConverters_1.dateFromTimestampNanosecondsValue,
|
|
32
|
+
[DuckDBTypeId_1.DuckDBTypeId.ENUM]: DuckDBValueConverters_1.stringFromValue,
|
|
33
|
+
[DuckDBTypeId_1.DuckDBTypeId.LIST]: DuckDBValueConverters_1.arrayFromListValue,
|
|
34
|
+
[DuckDBTypeId_1.DuckDBTypeId.STRUCT]: DuckDBValueConverters_1.objectFromStructValue,
|
|
35
|
+
[DuckDBTypeId_1.DuckDBTypeId.MAP]: DuckDBValueConverters_1.objectArrayFromMapValue,
|
|
36
|
+
[DuckDBTypeId_1.DuckDBTypeId.ARRAY]: DuckDBValueConverters_1.arrayFromArrayValue,
|
|
37
|
+
[DuckDBTypeId_1.DuckDBTypeId.UUID]: DuckDBValueConverters_1.stringFromValue,
|
|
38
|
+
[DuckDBTypeId_1.DuckDBTypeId.UNION]: DuckDBValueConverters_1.objectFromUnionValue,
|
|
39
|
+
[DuckDBTypeId_1.DuckDBTypeId.BIT]: DuckDBValueConverters_1.bytesFromBitValue,
|
|
40
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIME_TZ]: DuckDBValueConverters_1.objectFromTimeTZValue,
|
|
41
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ]: DuckDBValueConverters_1.dateFromTimestampTZValue,
|
|
42
|
+
[DuckDBTypeId_1.DuckDBTypeId.ANY]: DuckDBValueConverters_1.unsupportedConverter,
|
|
43
|
+
[DuckDBTypeId_1.DuckDBTypeId.VARINT]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
44
|
+
[DuckDBTypeId_1.DuckDBTypeId.SQLNULL]: DuckDBValueConverters_1.nullConverter,
|
|
45
|
+
};
|
|
46
|
+
exports.JSDuckDBValueConverter = (0, createDuckDBValueConverter_1.createDuckDBValueConverter)(JSConvertersByTypeId);
|
package/lib/Json.d.ts
ADDED
package/lib/Json.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonDuckDBValueConverter = void 0;
|
|
4
|
+
const createDuckDBValueConverter_1 = require("./createDuckDBValueConverter");
|
|
5
|
+
const DuckDBTypeId_1 = require("./DuckDBTypeId");
|
|
6
|
+
const DuckDBValueConverters_1 = require("./DuckDBValueConverters");
|
|
7
|
+
const JsonConvertersByTypeId = {
|
|
8
|
+
[DuckDBTypeId_1.DuckDBTypeId.INVALID]: DuckDBValueConverters_1.unsupportedConverter,
|
|
9
|
+
[DuckDBTypeId_1.DuckDBTypeId.BOOLEAN]: DuckDBValueConverters_1.booleanFromValue,
|
|
10
|
+
[DuckDBTypeId_1.DuckDBTypeId.TINYINT]: DuckDBValueConverters_1.numberFromValue,
|
|
11
|
+
[DuckDBTypeId_1.DuckDBTypeId.SMALLINT]: DuckDBValueConverters_1.numberFromValue,
|
|
12
|
+
[DuckDBTypeId_1.DuckDBTypeId.INTEGER]: DuckDBValueConverters_1.numberFromValue,
|
|
13
|
+
[DuckDBTypeId_1.DuckDBTypeId.BIGINT]: DuckDBValueConverters_1.stringFromValue,
|
|
14
|
+
[DuckDBTypeId_1.DuckDBTypeId.UTINYINT]: DuckDBValueConverters_1.numberFromValue,
|
|
15
|
+
[DuckDBTypeId_1.DuckDBTypeId.USMALLINT]: DuckDBValueConverters_1.numberFromValue,
|
|
16
|
+
[DuckDBTypeId_1.DuckDBTypeId.UINTEGER]: DuckDBValueConverters_1.numberFromValue,
|
|
17
|
+
[DuckDBTypeId_1.DuckDBTypeId.UBIGINT]: DuckDBValueConverters_1.stringFromValue,
|
|
18
|
+
[DuckDBTypeId_1.DuckDBTypeId.FLOAT]: DuckDBValueConverters_1.jsonNumberFromValue,
|
|
19
|
+
[DuckDBTypeId_1.DuckDBTypeId.DOUBLE]: DuckDBValueConverters_1.jsonNumberFromValue,
|
|
20
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP]: DuckDBValueConverters_1.stringFromValue,
|
|
21
|
+
[DuckDBTypeId_1.DuckDBTypeId.DATE]: DuckDBValueConverters_1.stringFromValue,
|
|
22
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIME]: DuckDBValueConverters_1.stringFromValue,
|
|
23
|
+
[DuckDBTypeId_1.DuckDBTypeId.INTERVAL]: DuckDBValueConverters_1.jsonObjectFromIntervalValue,
|
|
24
|
+
[DuckDBTypeId_1.DuckDBTypeId.HUGEINT]: DuckDBValueConverters_1.stringFromValue,
|
|
25
|
+
[DuckDBTypeId_1.DuckDBTypeId.UHUGEINT]: DuckDBValueConverters_1.stringFromValue,
|
|
26
|
+
[DuckDBTypeId_1.DuckDBTypeId.VARCHAR]: DuckDBValueConverters_1.stringFromValue,
|
|
27
|
+
[DuckDBTypeId_1.DuckDBTypeId.BLOB]: DuckDBValueConverters_1.stringFromValue,
|
|
28
|
+
[DuckDBTypeId_1.DuckDBTypeId.DECIMAL]: DuckDBValueConverters_1.stringFromValue,
|
|
29
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S]: DuckDBValueConverters_1.stringFromValue,
|
|
30
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS]: DuckDBValueConverters_1.stringFromValue,
|
|
31
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS]: DuckDBValueConverters_1.stringFromValue,
|
|
32
|
+
[DuckDBTypeId_1.DuckDBTypeId.ENUM]: DuckDBValueConverters_1.stringFromValue,
|
|
33
|
+
[DuckDBTypeId_1.DuckDBTypeId.LIST]: DuckDBValueConverters_1.arrayFromListValue,
|
|
34
|
+
[DuckDBTypeId_1.DuckDBTypeId.STRUCT]: DuckDBValueConverters_1.objectFromStructValue,
|
|
35
|
+
[DuckDBTypeId_1.DuckDBTypeId.MAP]: DuckDBValueConverters_1.objectArrayFromMapValue,
|
|
36
|
+
[DuckDBTypeId_1.DuckDBTypeId.ARRAY]: DuckDBValueConverters_1.arrayFromArrayValue,
|
|
37
|
+
[DuckDBTypeId_1.DuckDBTypeId.UUID]: DuckDBValueConverters_1.stringFromValue,
|
|
38
|
+
[DuckDBTypeId_1.DuckDBTypeId.UNION]: DuckDBValueConverters_1.objectFromUnionValue,
|
|
39
|
+
[DuckDBTypeId_1.DuckDBTypeId.BIT]: DuckDBValueConverters_1.stringFromValue,
|
|
40
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIME_TZ]: DuckDBValueConverters_1.stringFromValue,
|
|
41
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ]: DuckDBValueConverters_1.stringFromValue,
|
|
42
|
+
[DuckDBTypeId_1.DuckDBTypeId.ANY]: DuckDBValueConverters_1.unsupportedConverter,
|
|
43
|
+
[DuckDBTypeId_1.DuckDBTypeId.VARINT]: DuckDBValueConverters_1.stringFromValue,
|
|
44
|
+
[DuckDBTypeId_1.DuckDBTypeId.SQLNULL]: DuckDBValueConverters_1.nullConverter,
|
|
45
|
+
};
|
|
46
|
+
exports.JsonDuckDBValueConverter = (0, createDuckDBValueConverter_1.createDuckDBValueConverter)(JsonConvertersByTypeId);
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/** Matches BLOB-to-VARCHAR conversion behavior of DuckDB. */
|
|
2
2
|
export declare function stringFromBlob(bytes: Uint8Array): string;
|
|
3
|
+
export declare function stringFromBlobStringConcat(bytes: Uint8Array): string;
|
|
4
|
+
export declare function stringFromBlobArrayJoin(bytes: Uint8Array): string;
|
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stringFromBlob = stringFromBlob;
|
|
4
|
+
exports.stringFromBlobStringConcat = stringFromBlobStringConcat;
|
|
5
|
+
exports.stringFromBlobArrayJoin = stringFromBlobArrayJoin;
|
|
4
6
|
/** Matches BLOB-to-VARCHAR conversion behavior of DuckDB. */
|
|
5
7
|
function stringFromBlob(bytes) {
|
|
8
|
+
// String concatenation appears to be faster for this function at smaller sizes.
|
|
9
|
+
// Threshold of (2^16) experimentally determined on a MacBook Pro (M2 Max).
|
|
10
|
+
// See stringFromBlob.bench.ts.
|
|
11
|
+
if (bytes.length <= 65536) {
|
|
12
|
+
return stringFromBlobStringConcat(bytes);
|
|
13
|
+
}
|
|
14
|
+
return stringFromBlobArrayJoin(bytes);
|
|
15
|
+
}
|
|
16
|
+
function stringFromBlobStringConcat(bytes) {
|
|
17
|
+
let byteString = '';
|
|
18
|
+
for (const byte of bytes) {
|
|
19
|
+
if (byte <= 0x1f ||
|
|
20
|
+
byte === 0x22 /* double quote */ ||
|
|
21
|
+
byte === 0x27 /* single quote */ ||
|
|
22
|
+
byte >= 0x7f) {
|
|
23
|
+
byteString += `\\x${byte.toString(16).toUpperCase().padStart(2, '0')}`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
byteString += String.fromCharCode(byte);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return byteString;
|
|
30
|
+
}
|
|
31
|
+
function stringFromBlobArrayJoin(bytes) {
|
|
6
32
|
const byteStrings = [];
|
|
7
33
|
for (const byte of bytes) {
|
|
8
34
|
if (byte <= 0x1f ||
|
|
9
|
-
byte === 0x22 /*
|
|
10
|
-
byte === 0x27 /*
|
|
35
|
+
byte === 0x22 /* double quote */ ||
|
|
36
|
+
byte === 0x27 /* single quote */ ||
|
|
11
37
|
byte >= 0x7f) {
|
|
12
38
|
byteStrings.push(`\\x${byte.toString(16).toUpperCase().padStart(2, '0')}`);
|
|
13
39
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
2
2
|
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
3
|
-
export declare function convertColumnsFromChunks<T>(chunks: readonly DuckDBDataChunk[], converter: DuckDBValueConverter<T>): T[][];
|
|
3
|
+
export declare function convertColumnsFromChunks<T>(chunks: readonly DuckDBDataChunk[], converter: DuckDBValueConverter<T>): (T | null)[][];
|
|
@@ -9,7 +9,7 @@ function convertColumnsFromChunks(chunks, converter) {
|
|
|
9
9
|
for (let chunkIndex = 1; chunkIndex < chunks.length; chunkIndex++) {
|
|
10
10
|
for (let columnIndex = 0; columnIndex < convertedColumns.length; columnIndex++) {
|
|
11
11
|
const chunk = chunks[chunkIndex];
|
|
12
|
-
chunk.visitColumnValues(columnIndex, (value, _rowIndex, _columnIndex, type) => convertedColumns[columnIndex].push(converter
|
|
12
|
+
chunk.visitColumnValues(columnIndex, (value, _rowIndex, _columnIndex, type) => convertedColumns[columnIndex].push(converter(value, type, converter)));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
return convertedColumns;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
2
2
|
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
3
|
-
export declare function convertColumnsObjectFromChunks<T>(chunks: readonly DuckDBDataChunk[], columnNames: readonly string[], converter: DuckDBValueConverter<T>): Record<string, T[]>;
|
|
3
|
+
export declare function convertColumnsObjectFromChunks<T>(chunks: readonly DuckDBDataChunk[], columnNames: readonly string[], converter: DuckDBValueConverter<T>): Record<string, (T | null)[]>;
|
|
@@ -12,7 +12,7 @@ function convertColumnsObjectFromChunks(chunks, columnNames, converter) {
|
|
|
12
12
|
const columnCount = chunks[0].columnCount;
|
|
13
13
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
14
14
|
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
15
|
-
chunks[chunkIndex].visitColumnValues(columnIndex, (value, _rowIndex, _columnIndex, type) => convertedColumnsObject[columnNames[columnIndex]].push(converter
|
|
15
|
+
chunks[chunkIndex].visitColumnValues(columnIndex, (value, _rowIndex, _columnIndex, type) => convertedColumnsObject[columnNames[columnIndex]].push(converter(value, type, converter)));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
return convertedColumnsObject;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
2
2
|
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
3
|
-
export declare function convertRowObjectsFromChunks<T>(chunks: readonly DuckDBDataChunk[], columnNames: readonly string[], converter: DuckDBValueConverter<T>): Record<string, T>[];
|
|
3
|
+
export declare function convertRowObjectsFromChunks<T>(chunks: readonly DuckDBDataChunk[], columnNames: readonly string[], converter: DuckDBValueConverter<T>): Record<string, T | null>[];
|
|
@@ -8,7 +8,7 @@ function convertRowObjectsFromChunks(chunks, columnNames, converter) {
|
|
|
8
8
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
9
9
|
const rowObject = {};
|
|
10
10
|
chunk.visitRowValues(rowIndex, (value, _rowIndex, columnIndex, type) => {
|
|
11
|
-
rowObject[columnNames[columnIndex]] = converter
|
|
11
|
+
rowObject[columnNames[columnIndex]] = converter(value, type, converter);
|
|
12
12
|
});
|
|
13
13
|
rowObjects.push(rowObject);
|
|
14
14
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
2
2
|
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
3
|
-
export declare function convertRowsFromChunks<T>(chunks: readonly DuckDBDataChunk[], converter: DuckDBValueConverter<T>): T[][];
|
|
3
|
+
export declare function convertRowsFromChunks<T>(chunks: readonly DuckDBDataChunk[], converter: DuckDBValueConverter<T>): (T | null)[][];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createConfig = createConfig;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
|
+
function createConfig(options) {
|
|
9
|
+
const config = node_bindings_1.default.create_config();
|
|
10
|
+
// Set the default duckdb_api value for the api. Can be overridden.
|
|
11
|
+
node_bindings_1.default.set_config(config, 'duckdb_api', 'node-neo-api');
|
|
12
|
+
if (options) {
|
|
13
|
+
for (const optionName in options) {
|
|
14
|
+
const optionValue = String(options[optionName]);
|
|
15
|
+
node_bindings_1.default.set_config(config, optionName, optionValue);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDuckDBValueConverter = createDuckDBValueConverter;
|
|
4
|
+
function createDuckDBValueConverter(convertersByTypeId) {
|
|
5
|
+
return (value, type, converter) => {
|
|
6
|
+
if (value == null) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const converterForTypeId = convertersByTypeId[type.typeId];
|
|
10
|
+
if (!converterForTypeId) {
|
|
11
|
+
throw new Error(`No converter for typeId: ${type.typeId}`);
|
|
12
|
+
}
|
|
13
|
+
return converterForTypeId(value, type, converter);
|
|
14
|
+
};
|
|
15
|
+
}
|
package/lib/duckdb.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { double_to_hugeint, double_to_uhugeint, hugeint_to_double, uhugeint_to_double } from '@duckdb/node-bindings';
|
|
2
|
+
export * from './configurationOptionDescriptions';
|
|
3
|
+
export * from './createDuckDBValueConverter';
|
|
2
4
|
export * from './DuckDBAppender';
|
|
3
5
|
export * from './DuckDBConnection';
|
|
4
6
|
export * from './DuckDBDataChunk';
|
|
@@ -12,10 +14,13 @@ export * from './DuckDBResult';
|
|
|
12
14
|
export * from './DuckDBType';
|
|
13
15
|
export * from './DuckDBTypeId';
|
|
14
16
|
export * from './DuckDBValueConverter';
|
|
15
|
-
export * from './
|
|
17
|
+
export * from './DuckDBValueConverters';
|
|
16
18
|
export * from './DuckDBVector';
|
|
17
|
-
export * from './configurationOptionDescriptions';
|
|
18
19
|
export * from './enums';
|
|
20
|
+
export * from './JS';
|
|
21
|
+
export * from './JSDuckDBValueConverter';
|
|
22
|
+
export * from './Json';
|
|
23
|
+
export * from './JsonDuckDBValueConverter';
|
|
19
24
|
export * from './sql';
|
|
20
25
|
export * from './values';
|
|
21
26
|
export * from './version';
|
package/lib/duckdb.js
CHANGED
|
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.uhugeint_to_double = exports.hugeint_to_double = exports.double_to_uhugeint = exports.double_to_hugeint = void 0;
|
|
18
18
|
var node_bindings_1 = require("@duckdb/node-bindings");
|
|
19
|
-
Object.defineProperty(exports, "hugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.hugeint_to_double; } });
|
|
20
19
|
Object.defineProperty(exports, "double_to_hugeint", { enumerable: true, get: function () { return node_bindings_1.double_to_hugeint; } });
|
|
21
|
-
Object.defineProperty(exports, "uhugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.uhugeint_to_double; } });
|
|
22
20
|
Object.defineProperty(exports, "double_to_uhugeint", { enumerable: true, get: function () { return node_bindings_1.double_to_uhugeint; } });
|
|
21
|
+
Object.defineProperty(exports, "hugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.hugeint_to_double; } });
|
|
22
|
+
Object.defineProperty(exports, "uhugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.uhugeint_to_double; } });
|
|
23
|
+
__exportStar(require("./configurationOptionDescriptions"), exports);
|
|
24
|
+
__exportStar(require("./createDuckDBValueConverter"), exports);
|
|
23
25
|
__exportStar(require("./DuckDBAppender"), exports);
|
|
24
26
|
__exportStar(require("./DuckDBConnection"), exports);
|
|
25
27
|
__exportStar(require("./DuckDBDataChunk"), exports);
|
|
@@ -33,10 +35,13 @@ __exportStar(require("./DuckDBResult"), exports);
|
|
|
33
35
|
__exportStar(require("./DuckDBType"), exports);
|
|
34
36
|
__exportStar(require("./DuckDBTypeId"), exports);
|
|
35
37
|
__exportStar(require("./DuckDBValueConverter"), exports);
|
|
36
|
-
__exportStar(require("./
|
|
38
|
+
__exportStar(require("./DuckDBValueConverters"), exports);
|
|
37
39
|
__exportStar(require("./DuckDBVector"), exports);
|
|
38
|
-
__exportStar(require("./configurationOptionDescriptions"), exports);
|
|
39
40
|
__exportStar(require("./enums"), exports);
|
|
41
|
+
__exportStar(require("./JS"), exports);
|
|
42
|
+
__exportStar(require("./JSDuckDBValueConverter"), exports);
|
|
43
|
+
__exportStar(require("./Json"), exports);
|
|
44
|
+
__exportStar(require("./JsonDuckDBValueConverter"), exports);
|
|
40
45
|
__exportStar(require("./sql"), exports);
|
|
41
46
|
__exportStar(require("./values"), exports);
|
|
42
47
|
__exportStar(require("./version"), exports);
|
|
@@ -3,14 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getColumnsFromChunks = getColumnsFromChunks;
|
|
4
4
|
function getColumnsFromChunks(chunks) {
|
|
5
5
|
const columns = [];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
chunks[0].visitColumns((column) => columns.push(column));
|
|
10
|
-
for (let chunkIndex = 1; chunkIndex < chunks.length; chunkIndex++) {
|
|
11
|
-
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
12
|
-
chunks[chunkIndex].visitColumnValues(columnIndex, (value) => columns[columnIndex].push(value));
|
|
13
|
-
}
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
chunk.appendToColumns(columns);
|
|
14
8
|
}
|
|
15
9
|
return columns;
|
|
16
10
|
}
|
|
@@ -3,17 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getColumnsObjectFromChunks = getColumnsObjectFromChunks;
|
|
4
4
|
function getColumnsObjectFromChunks(chunks, columnNames) {
|
|
5
5
|
const columnsObject = {};
|
|
6
|
-
for (const
|
|
7
|
-
columnsObject
|
|
8
|
-
}
|
|
9
|
-
if (chunks.length === 0) {
|
|
10
|
-
return columnsObject;
|
|
11
|
-
}
|
|
12
|
-
const columnCount = chunks[0].columnCount;
|
|
13
|
-
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
14
|
-
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
15
|
-
chunks[chunkIndex].visitColumnValues(columnIndex, (value) => columnsObject[columnNames[columnIndex]].push(value));
|
|
16
|
-
}
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
chunk.appendToColumnsObject(columnNames, columnsObject);
|
|
17
8
|
}
|
|
18
9
|
return columnsObject;
|
|
19
10
|
}
|
|
@@ -4,14 +4,7 @@ exports.getRowObjectsFromChunks = getRowObjectsFromChunks;
|
|
|
4
4
|
function getRowObjectsFromChunks(chunks, columnNames) {
|
|
5
5
|
const rowObjects = [];
|
|
6
6
|
for (const chunk of chunks) {
|
|
7
|
-
|
|
8
|
-
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
9
|
-
const rowObject = {};
|
|
10
|
-
chunk.visitRowValues(rowIndex, (value, _, columnIndex) => {
|
|
11
|
-
rowObject[columnNames[columnIndex]] = value;
|
|
12
|
-
});
|
|
13
|
-
rowObjects.push(rowObject);
|
|
14
|
-
}
|
|
7
|
+
chunk.appendToRowObjects(columnNames, rowObjects);
|
|
15
8
|
}
|
|
16
9
|
return rowObjects;
|
|
17
10
|
}
|
package/lib/getRowsFromChunks.js
CHANGED
|
@@ -13,4 +13,4 @@ export declare class DuckDBBitValue {
|
|
|
13
13
|
static fromBools(bools: readonly boolean[]): DuckDBBitValue;
|
|
14
14
|
static fromLengthAndPredicate(length: number, predicate: (index: number) => boolean): DuckDBBitValue;
|
|
15
15
|
}
|
|
16
|
-
export declare function bitValue(
|
|
16
|
+
export declare function bitValue(input: string | readonly boolean[] | readonly number[]): DuckDBBitValue;
|
|
@@ -87,6 +87,17 @@ class DuckDBBitValue {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
exports.DuckDBBitValue = DuckDBBitValue;
|
|
90
|
-
function bitValue(
|
|
91
|
-
|
|
90
|
+
function bitValue(input) {
|
|
91
|
+
if (typeof input === 'string') {
|
|
92
|
+
return DuckDBBitValue.fromString(input);
|
|
93
|
+
}
|
|
94
|
+
if (input.length > 0) {
|
|
95
|
+
if (typeof input[0] === 'boolean') {
|
|
96
|
+
return DuckDBBitValue.fromBools(input);
|
|
97
|
+
}
|
|
98
|
+
else if (typeof input[0] === 'number') {
|
|
99
|
+
return DuckDBBitValue.fromBits(input);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return DuckDBBitValue.fromLengthAndPredicate(0, _ => false);
|
|
92
103
|
}
|