dolphindb 3.0.0 → 3.0.1
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 +59 -35
- package/README.zh.md +50 -28
- package/browser.d.ts +1 -2
- package/browser.js +11 -6
- package/browser.js.map +1 -1
- package/eslint.config.d.ts +2 -0
- package/eslint.config.js.map +1 -0
- package/i18n/dict.json +2 -2
- package/index.d.ts +1 -2
- package/index.js +11 -6
- package/index.js.map +1 -1
- package/package.json +5 -9
- package/shared/constants.d.ts +1 -0
- package/shared/constants.js +1 -0
- package/shared/constants.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.config.js","sourceRoot":"","sources":["eslint.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,iDAAiD;AACjD,eAAe,CAAC,YAAY,CAAC,CAAA","sourcesContent":["import { xlint_config } from 'xshell/xlint.js'\n\n// eslint-disable-next-line no-restricted-exports\nexport default [xlint_config]\n"]}
|
package/i18n/dict.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"this.form 必须是 DdbForm.dict, 否则不能调用 to_dict 转换为 js object": {
|
|
12
12
|
"en": "this.form must be DdbForm.dict, otherwise to_dict cannot be called to convert to js object"
|
|
13
13
|
},
|
|
14
|
-
"当前只支持自动转换 dict<string, any> 为 js object": {
|
|
15
|
-
"en": "currently api only supports automatic conversion of dict<string, any> to js object"
|
|
14
|
+
"当前只支持自动转换 dict<string, any | ...dictables> 为 js object": {
|
|
15
|
+
"en": "currently api only supports automatic conversion of dict<string, any | ...dictables> to js object"
|
|
16
16
|
},
|
|
17
17
|
"deep = true 时必须设置 strip = true": {
|
|
18
18
|
"en": "strip = true must be set when deep = true"
|
package/index.d.ts
CHANGED
|
@@ -162,8 +162,7 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
|
|
|
162
162
|
to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
|
|
163
163
|
/** 将 dict<string, any> 自动转换为 js object (Record<string, any>) Automatically convert dict<string, any> to js object (Record<string, any>)
|
|
164
164
|
- options?:
|
|
165
|
-
- strip?: `false` 是否将
|
|
166
|
-
Whether to directly extract and strip the value in DdbObj as the value of js object (discard the rest of the information in DdbObj, only keep the value)
|
|
165
|
+
- strip?: `false` 是否将 dict<string, any> 中的 value 直接提取、剥离出来作为 js object 的 value (丢弃 DdbObj 中的其余信息,只保留 value)
|
|
167
166
|
- deep?: `false` 是否递归转换
|
|
168
167
|
Whether to convert recursively
|
|
169
168
|
*/
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { t } from './i18n/index.js';
|
|
|
9
9
|
import { DdbDecimal128Serializor } from './data-types/decimal-128.js';
|
|
10
10
|
import { BigInt128Array } from './shared/bigint-128-array.js';
|
|
11
11
|
import { is_decimal_type, is_decimal_null_value, get_duration_unit } from './shared/utils.js';
|
|
12
|
-
import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType } from './shared/constants.js';
|
|
12
|
+
import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType, dictables } from './shared/constants.js';
|
|
13
13
|
export * from './shared/constants.js';
|
|
14
14
|
// Simulate other TypedArray behavior in nodejs
|
|
15
15
|
BigInt128Array.prototype[inspect.custom] = function () {
|
|
@@ -1256,15 +1256,20 @@ export class DdbObj {
|
|
|
1256
1256
|
to_dict({ strip, deep, } = {}) {
|
|
1257
1257
|
assert(this.form === DdbForm.dict, t('this.form 必须是 DdbForm.dict, 否则不能调用 to_dict 转换为 js object'));
|
|
1258
1258
|
const [{ value: keys, type: key_type }, { value: values, type: value_type }] = this.value;
|
|
1259
|
-
assert(key_type === DdbType.string && value_type
|
|
1259
|
+
assert(key_type === DdbType.string && dictables.has(value_type), t('当前只支持自动转换 dict<string, any | ...dictables> 为 js object'));
|
|
1260
1260
|
assert(!(deep && !strip), t('deep = true 时必须设置 strip = true'));
|
|
1261
1261
|
let obj = {};
|
|
1262
1262
|
for (let i = 0; i < this.rows; i++) {
|
|
1263
|
-
|
|
1264
|
-
if (
|
|
1265
|
-
|
|
1263
|
+
const key = keys[i];
|
|
1264
|
+
if (value_type === DdbType.any) {
|
|
1265
|
+
let value = values[i];
|
|
1266
|
+
if (deep && value.form === DdbForm.dict)
|
|
1267
|
+
obj[key] = value.to_dict({ strip, deep });
|
|
1268
|
+
else
|
|
1269
|
+
obj[key] = strip ? value.value : value;
|
|
1270
|
+
}
|
|
1266
1271
|
else
|
|
1267
|
-
obj[
|
|
1272
|
+
obj[key] = values[i];
|
|
1268
1273
|
}
|
|
1269
1274
|
return obj;
|
|
1270
1275
|
}
|