@dra2020/baseclient 1.0.133 → 1.0.134
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/baseclient.js +7 -2
- package/dist/baseclient.js.map +1 -1
- package/dist/detail/detail.d.ts +5 -1
- package/lib/detail/detail.ts +16 -2
- package/package.json +1 -1
package/dist/detail/detail.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export interface DetailOptions {
|
|
2
|
+
numberFormat?: (n: number) => string;
|
|
3
|
+
}
|
|
1
4
|
interface DetailItem {
|
|
2
5
|
expr?: string;
|
|
3
6
|
text?: string;
|
|
@@ -10,7 +13,8 @@ export declare class FormatDetail {
|
|
|
10
13
|
pattern: string;
|
|
11
14
|
items: DetailItem[];
|
|
12
15
|
_error: boolean;
|
|
13
|
-
|
|
16
|
+
options: DetailOptions;
|
|
17
|
+
constructor(pattern: string, options?: DetailOptions);
|
|
14
18
|
get error(): boolean;
|
|
15
19
|
static prepare(o: any): any;
|
|
16
20
|
format(o: any): DetailResult;
|
package/lib/detail/detail.ts
CHANGED
|
@@ -16,6 +16,18 @@ import * as Util from '../util/all';
|
|
|
16
16
|
const reIdentifier = /\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g;
|
|
17
17
|
const reParam = /^__\d+$/
|
|
18
18
|
|
|
19
|
+
function defaultNumberFormat(n: number): string
|
|
20
|
+
{
|
|
21
|
+
return Util.precisionRound(n, 0).toLocaleString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface DetailOptions
|
|
25
|
+
{
|
|
26
|
+
numberFormat?: (n: number) => string,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const DefaultDetailOptions: DetailOptions = { numberFormat: defaultNumberFormat };
|
|
30
|
+
|
|
19
31
|
class Evaluator
|
|
20
32
|
{
|
|
21
33
|
expr: string;
|
|
@@ -102,9 +114,11 @@ export class FormatDetail
|
|
|
102
114
|
pattern: string;
|
|
103
115
|
items: DetailItem[];
|
|
104
116
|
_error: boolean;
|
|
117
|
+
options: DetailOptions;
|
|
105
118
|
|
|
106
|
-
constructor(pattern: string)
|
|
119
|
+
constructor(pattern: string, options?: DetailOptions)
|
|
107
120
|
{
|
|
121
|
+
this.options = Util.shallowAssignImmutable(DefaultDetailOptions, options);
|
|
108
122
|
this._error = false;
|
|
109
123
|
this.pattern = pattern.trim();
|
|
110
124
|
let a = reExpr.exec(pattern);
|
|
@@ -182,7 +196,7 @@ export class FormatDetail
|
|
|
182
196
|
n = e.eval(o);
|
|
183
197
|
if (! this._error)
|
|
184
198
|
this._error = e.error;
|
|
185
|
-
return
|
|
199
|
+
return this.options.numberFormat(n);
|
|
186
200
|
}
|
|
187
201
|
});
|
|
188
202
|
return { n, v: av.join('') }
|