@yuneta/gobj-js 7.26.14 → 7.26.16
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/gobj-js.cjs.js +48 -24
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +889 -878
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +48 -24
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +928 -917
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +48 -24
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +889 -878
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +48 -24
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +889 -878
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.umd.js
CHANGED
|
@@ -3284,13 +3284,34 @@
|
|
|
3284
3284
|
}
|
|
3285
3285
|
/************************************************************
|
|
3286
3286
|
* JSON.stringify for a log line: a circular object (a gobj,
|
|
3287
|
-
* a DOM node)
|
|
3287
|
+
* a DOM node), a BigInt or a toJSON() that throws must not make
|
|
3288
|
+
* the log call itself throw -- and neither must the fallback:
|
|
3289
|
+
* String() throws too, on an object with no prototype or with a
|
|
3290
|
+
* toString() that throws.
|
|
3288
3291
|
************************************************************/
|
|
3289
3292
|
function log_stringify(v) {
|
|
3290
3293
|
try {
|
|
3291
3294
|
return JSON.stringify(v);
|
|
3292
3295
|
} catch (e) {
|
|
3296
|
+
try {
|
|
3297
|
+
return String(v);
|
|
3298
|
+
} catch (e2) {
|
|
3299
|
+
return `<${typeof v}: not printable>`;
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
function log_string(v) {
|
|
3304
|
+
try {
|
|
3293
3305
|
return String(v);
|
|
3306
|
+
} catch (e) {
|
|
3307
|
+
return log_stringify(v);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
function log_number(parse, v) {
|
|
3311
|
+
try {
|
|
3312
|
+
return parse(v);
|
|
3313
|
+
} catch (e) {
|
|
3314
|
+
return log_string(v);
|
|
3294
3315
|
}
|
|
3295
3316
|
}
|
|
3296
3317
|
function format_log(format) {
|
|
@@ -3302,18 +3323,18 @@
|
|
|
3302
3323
|
output = format.replace(/%[sdifoO]/g, (match) => {
|
|
3303
3324
|
const val = args[i++];
|
|
3304
3325
|
switch (match) {
|
|
3305
|
-
case "%s": return
|
|
3326
|
+
case "%s": return log_string(val);
|
|
3306
3327
|
case "%d":
|
|
3307
|
-
case "%i": return parseInt
|
|
3308
|
-
case "%f": return parseFloat
|
|
3328
|
+
case "%i": return log_number(parseInt, val);
|
|
3329
|
+
case "%f": return log_number(parseFloat, val);
|
|
3309
3330
|
case "%o":
|
|
3310
|
-
case "%O": return typeof val === "object" ? log_stringify(val) :
|
|
3331
|
+
case "%O": return typeof val === "object" ? log_stringify(val) : log_string(val);
|
|
3311
3332
|
default: return match;
|
|
3312
3333
|
}
|
|
3313
3334
|
});
|
|
3314
|
-
const rest = args.slice(i).map((arg) => typeof arg === "object" ? log_stringify(arg) :
|
|
3335
|
+
const rest = args.slice(i).map((arg) => typeof arg === "object" ? log_stringify(arg) : log_string(arg));
|
|
3315
3336
|
if (rest.length > 0) output += " " + rest.join(" ");
|
|
3316
|
-
} else output = args.map((arg) => typeof arg === "object" ? log_stringify(arg) :
|
|
3337
|
+
} else output = args.map((arg) => typeof arg === "object" ? log_stringify(arg) : log_string(arg)).join(" ");
|
|
3317
3338
|
return output;
|
|
3318
3339
|
}
|
|
3319
3340
|
function log_error(format, ...args) {
|
|
@@ -4368,6 +4389,13 @@
|
|
|
4368
4389
|
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4369
4390
|
return default_value;
|
|
4370
4391
|
}
|
|
4392
|
+
if (create && v === null) {
|
|
4393
|
+
if (required) {
|
|
4394
|
+
log_error(`path not found: '${path}'`);
|
|
4395
|
+
trace_json_masked(kw);
|
|
4396
|
+
}
|
|
4397
|
+
return default_value;
|
|
4398
|
+
}
|
|
4371
4399
|
if (required || create) {
|
|
4372
4400
|
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json dict: '${path}'` + (create ? ", cannot create" : ""));
|
|
4373
4401
|
trace_json_masked(kw);
|
|
@@ -4432,6 +4460,13 @@
|
|
|
4432
4460
|
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4433
4461
|
return default_value;
|
|
4434
4462
|
}
|
|
4463
|
+
if (create && v === null) {
|
|
4464
|
+
if (required) {
|
|
4465
|
+
log_error(`path not found: '${path}'`);
|
|
4466
|
+
trace_json_masked(kw);
|
|
4467
|
+
}
|
|
4468
|
+
return default_value;
|
|
4469
|
+
}
|
|
4435
4470
|
if (required || create) {
|
|
4436
4471
|
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json list: '${path}'` + (create ? ", cannot create" : ""));
|
|
4437
4472
|
trace_json_masked(kw);
|
|
@@ -4645,8 +4680,8 @@
|
|
|
4645
4680
|
["$key1", "$key2", ...]
|
|
4646
4681
|
{"$key1":*, "$key2":*, ...}
|
|
4647
4682
|
|
|
4648
|
-
It's not a deep copy,
|
|
4649
|
-
If
|
|
4683
|
+
It's not a deep copy. A key is a KEY, not a path (as C, SDK 7.26.9).
|
|
4684
|
+
If keys are empty return kw
|
|
4650
4685
|
*************************************************************/
|
|
4651
4686
|
function kw_clone_by_keys(gobj, kw, keys, verbose) {
|
|
4652
4687
|
if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
|
|
@@ -4673,8 +4708,8 @@
|
|
|
4673
4708
|
["$key1", "$key2", ...]
|
|
4674
4709
|
{"$key1":*, "$key2":*, ...}
|
|
4675
4710
|
|
|
4676
|
-
It's not a deep copy,
|
|
4677
|
-
If
|
|
4711
|
+
It's not a deep copy. A key is a KEY, not a path (as C, SDK 7.26.9).
|
|
4712
|
+
If keys are empty return empty
|
|
4678
4713
|
***************************************************************************/
|
|
4679
4714
|
function kw_clone_by_not_keys(gobj, kw, keys, verbose) {
|
|
4680
4715
|
let kw_clone = {};
|
|
@@ -5257,17 +5292,6 @@
|
|
|
5257
5292
|
return jdb;
|
|
5258
5293
|
}
|
|
5259
5294
|
/********************************************
|
|
5260
|
-
* A value as json text for a log line: the error path must not throw
|
|
5261
|
-
* (a circular record, a BigInt).
|
|
5262
|
-
********************************************/
|
|
5263
|
-
function safe_json_text(v) {
|
|
5264
|
-
try {
|
|
5265
|
-
return JSON.stringify(v);
|
|
5266
|
-
} catch (e) {
|
|
5267
|
-
return `<${typeof v}: not json (${e.message})>`;
|
|
5268
|
-
}
|
|
5269
|
-
}
|
|
5270
|
-
/********************************************
|
|
5271
5295
|
*
|
|
5272
5296
|
********************************************/
|
|
5273
5297
|
function jdb_update(jdb, topic_name, path, kw) {
|
|
@@ -5277,7 +5301,7 @@
|
|
|
5277
5301
|
return null;
|
|
5278
5302
|
}
|
|
5279
5303
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5280
|
-
log_error(`jdb_update: record without id: ${
|
|
5304
|
+
log_error(`jdb_update: record without id: ${log_stringify(kw)}`);
|
|
5281
5305
|
return null;
|
|
5282
5306
|
}
|
|
5283
5307
|
if (!is_string(path)) {
|
|
@@ -5330,7 +5354,7 @@
|
|
|
5330
5354
|
return null;
|
|
5331
5355
|
}
|
|
5332
5356
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5333
|
-
log_error(`jdb_delete: record without id: ${
|
|
5357
|
+
log_error(`jdb_delete: record without id: ${log_stringify(kw)}`);
|
|
5334
5358
|
return null;
|
|
5335
5359
|
}
|
|
5336
5360
|
if (!is_string(path)) {
|