dolphindb 2.0.963 → 2.0.964

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.
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug Current TS File",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "runtimeExecutable": "node",
9
+ "runtimeArgs": ["./node_modules/ts-node/dist/bin-esm.js"],
10
+ "args": ["${file}"],
11
+ "cwd": "${workspaceRoot}",
12
+ "internalConsoleOptions": "openOnSessionStart",
13
+ "skipFiles": ["<node_internals>/**", "node_modules/**"]
14
+ }
15
+ ]
16
+ }
package/browser.d.ts CHANGED
@@ -1,92 +1,11 @@
1
1
  import 'xshell/prototype.browser.js';
2
2
  import { Lock } from 'xshell/utils.browser.js';
3
3
  import { type WebSocketConnectionError } from 'xshell/net.browser.js';
4
- export declare enum DdbForm {
5
- scalar = 0,
6
- vector = 1,
7
- pair = 2,
8
- matrix = 3,
9
- set = 4,
10
- dict = 5,
11
- table = 6,
12
- chart = 7,
13
- /** 结点内部通信可能会使用,调用函数执行脚本一般不会返回这种类型
14
- Node internal communication may be used, calling function execution script generally does not return this type */
15
- chunk = 8,
16
- /** sysobj */
17
- object = 9
18
- }
19
- /** DolphinDB DataType
20
- 对应的 array vector 类型为 64 + 基本类型 The corresponding array vector type is 64 + base type
21
- 对应的 extended 类型为 128 + 基本类型 The corresponding extended type is 128 + base type
22
- */
23
- export declare enum DdbType {
24
- void = 0,
25
- bool = 1,
26
- char = 2,
27
- short = 3,
28
- int = 4,
29
- long = 5,
30
- date = 6,
31
- month = 7,
32
- time = 8,
33
- minute = 9,
34
- second = 10,
35
- datetime = 11,
36
- timestamp = 12,
37
- nanotime = 13,
38
- nanotimestamp = 14,
39
- float = 15,
40
- double = 16,
41
- symbol = 17,
42
- string = 18,
43
- uuid = 19,
44
- functiondef = 20,
45
- handle = 21,
46
- code = 22,
47
- datasource = 23,
48
- resource = 24,
49
- any = 25,
50
- compress = 26,
51
- dict = 27,
52
- datehour = 28,
53
- ipaddr = 30,
54
- int128 = 31,
55
- blob = 32,
56
- complex = 34,
57
- point = 35,
58
- duration = 36,
59
- decimal32 = 37,
60
- decimal64 = 38,
61
- decimal128 = 39,
62
- object = 40,
63
- pynone = 41,
64
- symbol_extended = 145
65
- }
66
- export declare enum DdbFunctionType {
67
- SystemFunc = 0,
68
- SystemProc = 1,
69
- OperatorFunc = 2,
70
- UserDefinedFunc = 3,
71
- PartialFunc = 4,
72
- DynamicFunc = 5,
73
- PiecewiseFunc = 6,
74
- JitFunc = 7,
75
- JitPartialFunc = 8
76
- }
77
- export declare enum DdbDurationUnit {
78
- ns = 0,
79
- us = 1,
80
- ms = 2,
81
- s = 3,
82
- m = 4,
83
- H = 5,
84
- d = 6,
85
- w = 7,
86
- M = 8,
87
- y = 9,
88
- B = 10
89
- }
4
+ import { type DdbDecimal128Value, type DdbDecimal128VectorValue } from './data-types/decimal-128.js';
5
+ import { BigInt128Array } from './shared/bigint-128-array.js';
6
+ import { DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
7
+ export * from './shared/constants.js';
8
+ export type { DdbDecimal128Value, DdbDecimal128VectorValue } from './data-types/decimal-128.js';
90
9
  export interface DdbFunctionDefValue {
91
10
  type: DdbFunctionType;
92
11
  name: string;
@@ -108,7 +27,6 @@ export interface DdbDecimal64Value {
108
27
  /** int64, 空值为 null empty value is null */
109
28
  data: bigint | null;
110
29
  }
111
- export type DdbDurationVectorValue = DdbDurationValue[];
112
30
  export interface DdbDecimal32VectorValue {
113
31
  scale: number;
114
32
  data: Int32Array;
@@ -117,6 +35,7 @@ export interface DdbDecimal64VectorValue {
117
35
  scale: number;
118
36
  data: BigInt64Array;
119
37
  }
38
+ export type DdbDurationVectorValue = DdbDurationValue[];
120
39
  export interface DdbSymbolExtendedValue {
121
40
  base_id: number;
122
41
  base: string[];
@@ -126,9 +45,9 @@ export interface DdbArrayVectorBlock {
126
45
  unit: 1 | 2 | 4;
127
46
  rows: number;
128
47
  lengths: Uint8Array | Uint16Array | Uint32Array;
129
- data: Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array;
48
+ data: Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | BigInt128Array;
130
49
  }
131
- export type DdbArrayVectorValue = DdbArrayVectorBlock[] & /* decimal32, decimal64 会有这个属性 */ {
50
+ export type DdbArrayVectorValue = DdbArrayVectorBlock[] & /* decimal 数据会有这个属性 */ {
132
51
  scale?: number;
133
52
  };
134
53
  export interface DdbMatrixValue {
@@ -137,17 +56,6 @@ export interface DdbMatrixValue {
137
56
  data: DdbVectorValue;
138
57
  }
139
58
  export type DdbDictValue = [DdbVectorObj, DdbVectorObj];
140
- export declare enum DdbChartType {
141
- area = 0,
142
- bar = 1,
143
- column = 2,
144
- histogram = 3,
145
- line = 4,
146
- pie = 5,
147
- scatter = 6,
148
- trend = 7,
149
- kline = 8
150
- }
151
59
  export interface DdbChartValue {
152
60
  /** 原属性 chartType original: chartType */
153
61
  type: DdbChartType;
@@ -176,11 +84,11 @@ export type DdbScalarValue = null | boolean | number | bigint | string | Uint8Ar
176
84
  number,
177
85
  number
178
86
  ] | // complex, point
179
- DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value;
180
- export type DdbVectorValue = null | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
87
+ DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal128Value;
88
+ export type DdbVectorValue = null | Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | BigInt128Array | string[] | // string[]
181
89
  Uint8Array[] | // blob
182
90
  DdbObj[] | // any
183
- DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDurationVectorValue;
91
+ DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue;
184
92
  export type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue;
185
93
  export type DdbStringObj = DdbObj<string>;
186
94
  export type DdbVectorObj<TValue extends DdbVectorValue = DdbVectorValue> = DdbObj<TValue>;
@@ -190,16 +98,6 @@ export type DdbTableObj<TColumns extends DdbVectorObj[] = DdbVectorObj[]> = DdbO
190
98
  export type DdbDictObj<TKeys extends DdbVectorObj = DdbVectorObj, TValues extends DdbVectorObj = DdbVectorObj> = DdbObj<[TKeys, TValues]>;
191
99
  export type DdbMatrixObj<TValue extends DdbMatrixValue = DdbMatrixValue> = DdbObj<TValue>;
192
100
  export type DdbChartObj = DdbObj<DdbChartValue>;
193
- export declare const nulls: {
194
- readonly int8: -128;
195
- readonly int16: -32768;
196
- readonly int32: -2147483648;
197
- readonly int64: -9223372036854775808n;
198
- readonly float32: -3.4028234663852886e+38;
199
- /** -Number.MAX_VALUE */
200
- readonly double: number;
201
- readonly bytes16: Uint8Array;
202
- };
203
101
  /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
204
102
  export declare class DdbObj<TValue extends DdbValue = DdbValue> {
205
103
  static dec: TextDecoder;
@@ -704,4 +602,3 @@ export interface DdbErrorMessage {
704
602
  data: DdbDatabaseError;
705
603
  }
706
604
  export type DdbMessage = DdbPrintMessage | DdbObjectMessage | DdbErrorMessage;
707
- export {};
package/browser.js CHANGED
@@ -8,118 +8,10 @@ import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
8
8
  import { concat, assert, Lock } from 'xshell/utils.browser.js';
9
9
  import { connect_websocket } from 'xshell/net.browser.js';
10
10
  import { t } from './i18n/index.js';
11
- export var DdbForm;
12
- (function (DdbForm) {
13
- DdbForm[DdbForm["scalar"] = 0] = "scalar";
14
- DdbForm[DdbForm["vector"] = 1] = "vector";
15
- DdbForm[DdbForm["pair"] = 2] = "pair";
16
- DdbForm[DdbForm["matrix"] = 3] = "matrix";
17
- DdbForm[DdbForm["set"] = 4] = "set";
18
- DdbForm[DdbForm["dict"] = 5] = "dict";
19
- DdbForm[DdbForm["table"] = 6] = "table";
20
- DdbForm[DdbForm["chart"] = 7] = "chart";
21
- /** 结点内部通信可能会使用,调用函数执行脚本一般不会返回这种类型
22
- Node internal communication may be used, calling function execution script generally does not return this type */
23
- DdbForm[DdbForm["chunk"] = 8] = "chunk";
24
- /** sysobj */
25
- DdbForm[DdbForm["object"] = 9] = "object";
26
- })(DdbForm = DdbForm || (DdbForm = {}));
27
- /** DolphinDB DataType
28
- 对应的 array vector 类型为 64 + 基本类型 The corresponding array vector type is 64 + base type
29
- 对应的 extended 类型为 128 + 基本类型 The corresponding extended type is 128 + base type
30
- */
31
- export var DdbType;
32
- (function (DdbType) {
33
- DdbType[DdbType["void"] = 0] = "void";
34
- DdbType[DdbType["bool"] = 1] = "bool";
35
- DdbType[DdbType["char"] = 2] = "char";
36
- DdbType[DdbType["short"] = 3] = "short";
37
- DdbType[DdbType["int"] = 4] = "int";
38
- DdbType[DdbType["long"] = 5] = "long";
39
- DdbType[DdbType["date"] = 6] = "date";
40
- DdbType[DdbType["month"] = 7] = "month";
41
- DdbType[DdbType["time"] = 8] = "time";
42
- DdbType[DdbType["minute"] = 9] = "minute";
43
- DdbType[DdbType["second"] = 10] = "second";
44
- DdbType[DdbType["datetime"] = 11] = "datetime";
45
- DdbType[DdbType["timestamp"] = 12] = "timestamp";
46
- DdbType[DdbType["nanotime"] = 13] = "nanotime";
47
- DdbType[DdbType["nanotimestamp"] = 14] = "nanotimestamp";
48
- DdbType[DdbType["float"] = 15] = "float";
49
- DdbType[DdbType["double"] = 16] = "double";
50
- DdbType[DdbType["symbol"] = 17] = "symbol";
51
- DdbType[DdbType["string"] = 18] = "string";
52
- DdbType[DdbType["uuid"] = 19] = "uuid";
53
- DdbType[DdbType["functiondef"] = 20] = "functiondef";
54
- DdbType[DdbType["handle"] = 21] = "handle";
55
- DdbType[DdbType["code"] = 22] = "code";
56
- DdbType[DdbType["datasource"] = 23] = "datasource";
57
- DdbType[DdbType["resource"] = 24] = "resource";
58
- DdbType[DdbType["any"] = 25] = "any";
59
- DdbType[DdbType["compress"] = 26] = "compress";
60
- DdbType[DdbType["dict"] = 27] = "dict";
61
- DdbType[DdbType["datehour"] = 28] = "datehour";
62
- DdbType[DdbType["ipaddr"] = 30] = "ipaddr";
63
- DdbType[DdbType["int128"] = 31] = "int128";
64
- DdbType[DdbType["blob"] = 32] = "blob";
65
- DdbType[DdbType["complex"] = 34] = "complex";
66
- DdbType[DdbType["point"] = 35] = "point";
67
- DdbType[DdbType["duration"] = 36] = "duration";
68
- DdbType[DdbType["decimal32"] = 37] = "decimal32";
69
- DdbType[DdbType["decimal64"] = 38] = "decimal64";
70
- DdbType[DdbType["decimal128"] = 39] = "decimal128";
71
- DdbType[DdbType["object"] = 40] = "object";
72
- DdbType[DdbType["pynone"] = 41] = "pynone";
73
- DdbType[DdbType["symbol_extended"] = 145] = "symbol_extended";
74
- })(DdbType = DdbType || (DdbType = {}));
75
- export var DdbFunctionType;
76
- (function (DdbFunctionType) {
77
- DdbFunctionType[DdbFunctionType["SystemFunc"] = 0] = "SystemFunc";
78
- DdbFunctionType[DdbFunctionType["SystemProc"] = 1] = "SystemProc";
79
- DdbFunctionType[DdbFunctionType["OperatorFunc"] = 2] = "OperatorFunc";
80
- DdbFunctionType[DdbFunctionType["UserDefinedFunc"] = 3] = "UserDefinedFunc";
81
- DdbFunctionType[DdbFunctionType["PartialFunc"] = 4] = "PartialFunc";
82
- DdbFunctionType[DdbFunctionType["DynamicFunc"] = 5] = "DynamicFunc";
83
- DdbFunctionType[DdbFunctionType["PiecewiseFunc"] = 6] = "PiecewiseFunc";
84
- DdbFunctionType[DdbFunctionType["JitFunc"] = 7] = "JitFunc";
85
- DdbFunctionType[DdbFunctionType["JitPartialFunc"] = 8] = "JitPartialFunc";
86
- })(DdbFunctionType = DdbFunctionType || (DdbFunctionType = {}));
87
- export var DdbDurationUnit;
88
- (function (DdbDurationUnit) {
89
- DdbDurationUnit[DdbDurationUnit["ns"] = 0] = "ns";
90
- DdbDurationUnit[DdbDurationUnit["us"] = 1] = "us";
91
- DdbDurationUnit[DdbDurationUnit["ms"] = 2] = "ms";
92
- DdbDurationUnit[DdbDurationUnit["s"] = 3] = "s";
93
- DdbDurationUnit[DdbDurationUnit["m"] = 4] = "m";
94
- DdbDurationUnit[DdbDurationUnit["H"] = 5] = "H";
95
- DdbDurationUnit[DdbDurationUnit["d"] = 6] = "d";
96
- DdbDurationUnit[DdbDurationUnit["w"] = 7] = "w";
97
- DdbDurationUnit[DdbDurationUnit["M"] = 8] = "M";
98
- DdbDurationUnit[DdbDurationUnit["y"] = 9] = "y";
99
- DdbDurationUnit[DdbDurationUnit["B"] = 10] = "B";
100
- })(DdbDurationUnit = DdbDurationUnit || (DdbDurationUnit = {}));
101
- export var DdbChartType;
102
- (function (DdbChartType) {
103
- DdbChartType[DdbChartType["area"] = 0] = "area";
104
- DdbChartType[DdbChartType["bar"] = 1] = "bar";
105
- DdbChartType[DdbChartType["column"] = 2] = "column";
106
- DdbChartType[DdbChartType["histogram"] = 3] = "histogram";
107
- DdbChartType[DdbChartType["line"] = 4] = "line";
108
- DdbChartType[DdbChartType["pie"] = 5] = "pie";
109
- DdbChartType[DdbChartType["scatter"] = 6] = "scatter";
110
- DdbChartType[DdbChartType["trend"] = 7] = "trend";
111
- DdbChartType[DdbChartType["kline"] = 8] = "kline";
112
- })(DdbChartType = DdbChartType || (DdbChartType = {}));
113
- export const nulls = {
114
- int8: -0x80,
115
- int16: -0x80_00,
116
- int32: -0x80_00_00_00,
117
- int64: -0x8000000000000000n,
118
- float32: -3.4028234663852886e+38,
119
- /** -Number.MAX_VALUE */
120
- double: -Number.MAX_VALUE,
121
- bytes16: Uint8Array.from(new Array(16).fill(0))
122
- };
11
+ import { DdbDecimal128Serializor } from './data-types/decimal-128.js';
12
+ import { is_decimal_type, is_decimal_null_value } from './shared/utils/decimal-type.js';
13
+ import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
14
+ export * from './shared/constants.js';
123
15
  /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
124
16
  class DdbObj {
125
17
  static dec = new TextDecoder('utf-8');
@@ -475,6 +367,9 @@ class DdbObj {
475
367
  const data = dv.getBigInt64(4, le);
476
368
  return [12, { scale: dv.getInt32(0, le), data: data === nulls.int64 ? null : data }];
477
369
  }
370
+ case DdbType.decimal128: {
371
+ return DdbDecimal128Serializor.parse_as_scalar(buf, le);
372
+ }
478
373
  default:
479
374
  throw new Error(String(DdbType[type] || type) + t(' 暂时不支持解析'));
480
375
  }
@@ -543,8 +438,8 @@ class DdbObj {
543
438
  const type_ = type - 64;
544
439
  const cols = dv.getUint32(4, le);
545
440
  let blocks = [];
546
- // decimal32/64 会在所有 blocks 之前多一个 scale
547
- if (type_ === DdbType.decimal32 || type_ === DdbType.decimal64) {
441
+ // decimal 会在所有 blocks 之前多一个 scale
442
+ if (is_decimal_type(type_)) {
548
443
  blocks.scale = dv.getInt32(i_items_start, le);
549
444
  i_items_start += 4;
550
445
  }
@@ -587,6 +482,9 @@ class DdbObj {
587
482
  len_items = total_length * 8;
588
483
  data = new BigInt64Array(buf.buffer.slice(buf.byteOffset + i_data_start, buf.byteOffset + i_data_start + len_items));
589
484
  break;
485
+ case DdbType.decimal128:
486
+ [len_items, data] = DdbDecimal128Serializor.parse_as_same_type_vector_values(buf, i_data_start, total_length);
487
+ break;
590
488
  default:
591
489
  [len_items, data] = this.parse_vector_items(buf.subarray(i_data_start), le, type - 64, total_length);
592
490
  }
@@ -779,6 +677,8 @@ class DdbObj {
779
677
  }
780
678
  ];
781
679
  }
680
+ case DdbType.decimal128:
681
+ return DdbDecimal128Serializor.parse_as_vector_items(buf, length, le);
782
682
  // 以下情况时, DdbType.duration 实际会返回一个 any vector
783
683
  // [2y, 1M, 3d, 7H, 11m, 12s, 15ms, 16us, 17ns]
784
684
  // <Buffer 19 01 type = any, form = vector
@@ -915,6 +815,8 @@ class DdbObj {
915
815
  const { scale, data } = this.value;
916
816
  return [Int32Array.of(scale), BigInt64Array.of(data === null ? nulls.int64 : data)];
917
817
  }
818
+ case DdbType.decimal128:
819
+ return DdbDecimal128Serializor.pack(this.value);
918
820
  default:
919
821
  throw new Error(String(DdbType[type] || type) + t(' 暂时不支持序列化'));
920
822
  }
@@ -924,7 +826,7 @@ class DdbObj {
924
826
  if (form === DdbForm.vector && 64 <= type && type < 128)
925
827
  return [
926
828
  Uint32Array.of(this.rows, this.cols),
927
- ...(type - 64 === DdbType.decimal32 || type - 64 === DdbType.decimal64) ?
829
+ ...(is_decimal_type(type - 64)) ?
928
830
  [Int32Array.of(this.value.scale)]
929
831
  :
930
832
  [],
@@ -1071,7 +973,8 @@ class DdbObj {
1071
973
  ];
1072
974
  }
1073
975
  case DdbType.decimal32:
1074
- case DdbType.decimal64: {
976
+ case DdbType.decimal64:
977
+ case DdbType.decimal128: {
1075
978
  const { scale, data } = value;
1076
979
  return [Int32Array.of(scale), data];
1077
980
  }
@@ -1118,9 +1021,9 @@ class DdbObj {
1118
1021
  switch (type_) {
1119
1022
  case DdbType.decimal32:
1120
1023
  case DdbType.decimal64:
1024
+ case DdbType.decimal128:
1121
1025
  const x = data[acc_len + i];
1122
- if (x === nulls.int64 /* && type_ === DdbType.decimal64 一定成立 */ ||
1123
- x === nulls.int32 && type_ === DdbType.decimal32)
1026
+ if (is_decimal_null_value(type_, x))
1124
1027
  return '';
1125
1028
  const { scale } = this.value;
1126
1029
  const s = String(x < 0 ? -x : x).padStart(scale, '0');
@@ -1185,7 +1088,8 @@ class DdbObj {
1185
1088
  return format_array(items, len_data > limit);
1186
1089
  }
1187
1090
  case DdbType.decimal32:
1188
- case DdbType.decimal64: {
1091
+ case DdbType.decimal64:
1092
+ case DdbType.decimal128: {
1189
1093
  const limit = 50;
1190
1094
  const { data } = this.value;
1191
1095
  let items = new Array(Math.min(limit, data.length));
@@ -1513,11 +1417,11 @@ export function format(type, value, le, options = {}) {
1513
1417
  return colors ? magenta(str) : str;
1514
1418
  }
1515
1419
  case DdbType.decimal32:
1516
- case DdbType.decimal64: {
1420
+ case DdbType.decimal64:
1421
+ case DdbType.decimal128: {
1517
1422
  const { scale, data } = value;
1518
1423
  if (data === null ||
1519
- (data === nulls.int64 && type === DdbType.decimal64) ||
1520
- (data === nulls.int32 && type === DdbType.decimal32))
1424
+ is_decimal_null_value(type, data))
1521
1425
  return get_nullstr();
1522
1426
  const s = String(data < 0 ? -data : data).padStart(scale, '0');
1523
1427
  const str = (data < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
@@ -1560,9 +1464,9 @@ export function formati(obj, index, options = {}) {
1560
1464
  switch (type_) {
1561
1465
  case DdbType.decimal32:
1562
1466
  case DdbType.decimal64:
1467
+ case DdbType.decimal128:
1563
1468
  const x = data[acc_len + i];
1564
- if (x === nulls.int64 /* && type_ === DdbType.decimal64 一定成立 */ ||
1565
- x === nulls.int32 && type_ === DdbType.decimal32)
1469
+ if (is_decimal_null_value(type_, x))
1566
1470
  return '';
1567
1471
  const { scale } = obj.value;
1568
1472
  const s = String(x < 0 ? -x : x).padStart(scale, '0');
@@ -1612,11 +1516,11 @@ export function formati(obj, index, options = {}) {
1612
1516
  case DdbType.point:
1613
1517
  return format(obj.type, obj.value.subarray(2 * index, 2 * (index + 1)), obj.le, options);
1614
1518
  case DdbType.decimal32:
1615
- case DdbType.decimal64: {
1519
+ case DdbType.decimal64:
1520
+ case DdbType.decimal128: {
1616
1521
  const { scale, data } = obj.value;
1617
1522
  const x = data[index];
1618
- if (x === nulls.int64 && obj.type === DdbType.decimal64 ||
1619
- x === nulls.int32 && obj.type === DdbType.decimal32)
1523
+ if (is_decimal_null_value(obj.type, x))
1620
1524
  return '';
1621
1525
  const s = String(x < 0 ? -x : x).padStart(scale, '0');
1622
1526
  const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);