@dra2020/baseclient 1.0.133 → 1.0.135
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 +36 -16
- package/dist/baseclient.js.map +1 -1
- package/dist/detail/detail.d.ts +5 -1
- package/dist/util/util.d.ts +3 -0
- package/lib/detail/detail.ts +28 -16
- package/lib/util/util.ts +14 -0
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -1175,7 +1175,7 @@ __exportStar(__webpack_require__(/*! ./detail */ "./lib/detail/detail.ts"), expo
|
|
|
1175
1175
|
// The formatting string is a statement of the form:
|
|
1176
1176
|
// =expr
|
|
1177
1177
|
// Expr can be an arithmetic expression using +-/*()?: as operators and variables are the field
|
|
1178
|
-
// names of properties on the object passed in. The special field name
|
|
1178
|
+
// names of properties on the object passed in. The special field name Tot represents the
|
|
1179
1179
|
// total of all properties. The expression may also include double-quoted strings that are
|
|
1180
1180
|
// passed through (e.g. for use as labels = area" sqm")
|
|
1181
1181
|
//
|
|
@@ -1203,6 +1203,10 @@ exports.FormatDetail = void 0;
|
|
|
1203
1203
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1204
1204
|
const reIdentifier = /\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g;
|
|
1205
1205
|
const reParam = /^__\d+$/;
|
|
1206
|
+
function defaultNumberFormat(n) {
|
|
1207
|
+
return Util.precisionRound(n, 0).toLocaleString();
|
|
1208
|
+
}
|
|
1209
|
+
const DefaultDetailOptions = { numberFormat: defaultNumberFormat };
|
|
1206
1210
|
class Evaluator {
|
|
1207
1211
|
constructor(expr) {
|
|
1208
1212
|
this.expr = expr;
|
|
@@ -1255,7 +1259,8 @@ class Evaluator {
|
|
|
1255
1259
|
const reInvalidChars = /[\.\[\]\\]/;
|
|
1256
1260
|
const reExpr = /^=(.*)$/;
|
|
1257
1261
|
class FormatDetail {
|
|
1258
|
-
constructor(pattern) {
|
|
1262
|
+
constructor(pattern, options) {
|
|
1263
|
+
this.options = Util.shallowAssignImmutable(DefaultDetailOptions, options);
|
|
1259
1264
|
this._error = false;
|
|
1260
1265
|
this.pattern = pattern.trim();
|
|
1261
1266
|
let a = reExpr.exec(pattern);
|
|
@@ -1290,19 +1295,17 @@ class FormatDetail {
|
|
|
1290
1295
|
}
|
|
1291
1296
|
get error() { return this._error; }
|
|
1292
1297
|
static prepare(o) {
|
|
1293
|
-
if (o) {
|
|
1294
|
-
//
|
|
1298
|
+
if (o && o.Tot === undefined && o.Total === undefined) {
|
|
1299
|
+
// Add a total field
|
|
1300
|
+
let t = 0;
|
|
1301
|
+
Object.keys(o).forEach((k) => {
|
|
1302
|
+
let v = o[k];
|
|
1303
|
+
if (!isNaN(v) && typeof v === 'number')
|
|
1304
|
+
t += v;
|
|
1305
|
+
});
|
|
1295
1306
|
o = Util.deepCopy(o);
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
else {
|
|
1299
|
-
let t = 0;
|
|
1300
|
-
Object.values(o).forEach((v) => {
|
|
1301
|
-
if (!isNaN(v) && typeof v === 'number')
|
|
1302
|
-
t += v;
|
|
1303
|
-
});
|
|
1304
|
-
o['_tot'] = t;
|
|
1305
|
-
}
|
|
1307
|
+
o.Tot = t;
|
|
1308
|
+
o.Total = t;
|
|
1306
1309
|
}
|
|
1307
1310
|
return o;
|
|
1308
1311
|
}
|
|
@@ -1320,7 +1323,7 @@ class FormatDetail {
|
|
|
1320
1323
|
n = e.eval(o);
|
|
1321
1324
|
if (!this._error)
|
|
1322
1325
|
this._error = e.error;
|
|
1323
|
-
return
|
|
1326
|
+
return this.options.numberFormat(n);
|
|
1324
1327
|
}
|
|
1325
1328
|
});
|
|
1326
1329
|
return { n, v: av.join('') };
|
|
@@ -11677,7 +11680,7 @@ exports.IndexedArray = IndexedArray;
|
|
|
11677
11680
|
|
|
11678
11681
|
|
|
11679
11682
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11680
|
-
exports.wrapLon = exports.rad2deg = exports.deg2rad = exports.distance = exports.toRGBAIntensity = exports.toRGBA = exports.toHex = exports.hashObject = exports.hash = exports.percentString = exports.precisionRound = exports.deepAccum = exports.deepCopy = exports.shallowEqual = exports.shallowAssignImmutable = exports.shallowDelete = exports.shallowAssign = exports.shallowCopy = exports.textToHtml = exports.recentDate = exports.relativeDate = exports.prettyDate = exports.deepEqual = exports.partialEqual = exports.nthKey = exports.nthProperty = exports.countKeys = exports.isEmpty = exports.depthof = exports.sizeof = exports.guidKey = exports.createKeyedGuid = exports.createGuid = exports.Deadline = exports.MultiTimer = exports.Elapsed = exports.Now = void 0;
|
|
11683
|
+
exports.toSafeNumber = exports.toNumber = exports.isNumber = exports.wrapLon = exports.rad2deg = exports.deg2rad = exports.distance = exports.toRGBAIntensity = exports.toRGBA = exports.toHex = exports.hashObject = exports.hash = exports.percentString = exports.precisionRound = exports.deepAccum = exports.deepCopy = exports.shallowEqual = exports.shallowAssignImmutable = exports.shallowDelete = exports.shallowAssign = exports.shallowCopy = exports.textToHtml = exports.recentDate = exports.relativeDate = exports.prettyDate = exports.deepEqual = exports.partialEqual = exports.nthKey = exports.nthProperty = exports.countKeys = exports.isEmpty = exports.depthof = exports.sizeof = exports.guidKey = exports.createKeyedGuid = exports.createGuid = exports.Deadline = exports.MultiTimer = exports.Elapsed = exports.Now = void 0;
|
|
11681
11684
|
function Now() { return (new Date()).toJSON(); }
|
|
11682
11685
|
exports.Now = Now;
|
|
11683
11686
|
// polyfill
|
|
@@ -12296,6 +12299,23 @@ function wrapLon(lon) {
|
|
|
12296
12299
|
return lon - (worlds * 360);
|
|
12297
12300
|
}
|
|
12298
12301
|
exports.wrapLon = wrapLon;
|
|
12302
|
+
let reNumber = /^\s*-?\d+(\.\d+)?([eE][+-]?\d+)?\s*$/;
|
|
12303
|
+
function isNumber(s) { return !!s && reNumber.test(s); }
|
|
12304
|
+
exports.isNumber = isNumber;
|
|
12305
|
+
function toNumber(a) {
|
|
12306
|
+
if (typeof a === 'number')
|
|
12307
|
+
return a;
|
|
12308
|
+
if (typeof a === 'string' && !isNumber(a))
|
|
12309
|
+
return NaN;
|
|
12310
|
+
return Number(a);
|
|
12311
|
+
}
|
|
12312
|
+
exports.toNumber = toNumber;
|
|
12313
|
+
function toSafeNumber(a) {
|
|
12314
|
+
let n = toNumber(a);
|
|
12315
|
+
if (isNaN(n) || typeof n !== 'number')
|
|
12316
|
+
return 0;
|
|
12317
|
+
}
|
|
12318
|
+
exports.toSafeNumber = toSafeNumber;
|
|
12299
12319
|
|
|
12300
12320
|
|
|
12301
12321
|
/***/ }),
|