dolphindb 2.0.532 → 2.0.601
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/browser.d.ts +8 -1
- package/browser.js +62 -1
- package/browser.js.map +1 -1
- package/docs.en.json +858 -129
- package/docs.zh.json +3080 -256
- package/index.d.ts +3 -0
- package/index.js +61 -0
- package/index.js.map +1 -1
- package/language.d.ts +1 -1
- package/language.js +5 -2
- package/language.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -229,7 +229,10 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
229
229
|
deep?: boolean;
|
|
230
230
|
}): T;
|
|
231
231
|
}
|
|
232
|
+
/** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
232
233
|
export declare function format(type: DdbType, value: DdbValue, le: boolean, options: InspectOptions): string;
|
|
234
|
+
/** formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
235
|
+
export declare function formati(obj: DdbObj<DdbVectorValue>, index: number, options: InspectOptions): string;
|
|
233
236
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
234
237
|
constructor();
|
|
235
238
|
}
|
package/index.js
CHANGED
|
@@ -1179,6 +1179,7 @@ export class DdbObj {
|
|
|
1179
1179
|
return obj;
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
|
+
/** Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
1182
1183
|
export function format(type, value, le, options) {
|
|
1183
1184
|
switch (type) {
|
|
1184
1185
|
case DdbType.bool:
|
|
@@ -1364,6 +1365,66 @@ export function format(type, value, le, options) {
|
|
|
1364
1365
|
return inspect(value, options);
|
|
1365
1366
|
}
|
|
1366
1367
|
}
|
|
1368
|
+
/** formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
1369
|
+
export function formati(obj, index, options) {
|
|
1370
|
+
if (64 <= obj.type && obj.type < 128) { // array vector
|
|
1371
|
+
// 因为 array vector 目前只支持:Logical, Integral(不包括 INT128, COMPRESS 类型), Floating, Temporal
|
|
1372
|
+
// 都对应 TypedArray 中的一格,所以 lengths.length 等于 block 中的 row 的个数
|
|
1373
|
+
// av = array(INT[], 0, 5)
|
|
1374
|
+
// append!(av, [1..1])
|
|
1375
|
+
// append!(av, [1..70000])
|
|
1376
|
+
// append!(av, [1..1])
|
|
1377
|
+
// append!(av, [1..500])
|
|
1378
|
+
// ...
|
|
1379
|
+
// av
|
|
1380
|
+
const _type = obj.type - 64;
|
|
1381
|
+
let offset = 0;
|
|
1382
|
+
for (const { lengths, data, rows } of obj.value) {
|
|
1383
|
+
let acc_len = 0;
|
|
1384
|
+
if (offset + rows <= index) {
|
|
1385
|
+
offset += rows;
|
|
1386
|
+
continue; // 跳过这个 block
|
|
1387
|
+
}
|
|
1388
|
+
for (const length of lengths) {
|
|
1389
|
+
if (offset < index) {
|
|
1390
|
+
offset++;
|
|
1391
|
+
acc_len += length;
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
const limit = 10;
|
|
1395
|
+
let items = new Array(Math.min(limit, length));
|
|
1396
|
+
for (let i = 0; i < items.length; i++)
|
|
1397
|
+
items[i] = format(_type, data[acc_len + i], obj.le, options);
|
|
1398
|
+
return (items.join(', ') + (length > limit ? ', ...' : '')).bracket('square');
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
switch (obj.type) {
|
|
1403
|
+
case DdbType.string:
|
|
1404
|
+
case DdbType.symbol:
|
|
1405
|
+
return obj.value[index];
|
|
1406
|
+
case DdbType.symbol_extended: {
|
|
1407
|
+
const { base, data } = obj.value;
|
|
1408
|
+
return base[data[index]];
|
|
1409
|
+
}
|
|
1410
|
+
case DdbType.uuid:
|
|
1411
|
+
case DdbType.int128:
|
|
1412
|
+
case DdbType.ipaddr:
|
|
1413
|
+
return format(obj.type, obj.value.subarray(16 * index, 16 * (index + 1)), obj.le, options);
|
|
1414
|
+
case DdbType.blob: {
|
|
1415
|
+
const value = obj.value[index];
|
|
1416
|
+
return value.length > 100 ?
|
|
1417
|
+
DdbObj.dec.decode(value.subarray(0, 98)) + '…'
|
|
1418
|
+
:
|
|
1419
|
+
DdbObj.dec.decode(value);
|
|
1420
|
+
}
|
|
1421
|
+
case DdbType.complex:
|
|
1422
|
+
case DdbType.point:
|
|
1423
|
+
return format(obj.type, obj.value.subarray(2 * index, 2 * (index + 1)), obj.le, options);
|
|
1424
|
+
default:
|
|
1425
|
+
return format(obj.type, obj.value[index], obj.le, options);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1367
1428
|
export class DdbVoid extends DdbObj {
|
|
1368
1429
|
constructor() {
|
|
1369
1430
|
super({
|