@yuneta/gobj-js 7.26.15 → 7.26.17
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 +64 -25
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +903 -883
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +64 -25
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +943 -923
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +64 -25
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +903 -883
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +64 -25
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +903 -883
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.umd.js
CHANGED
|
@@ -3211,11 +3211,7 @@
|
|
|
3211
3211
|
var __log_backlog__ = [];
|
|
3212
3212
|
function keep_in_backlog(level, msg, hora) {
|
|
3213
3213
|
let m = msg;
|
|
3214
|
-
if (level === "json")
|
|
3215
|
-
m = JSON.stringify(msg);
|
|
3216
|
-
} catch (e) {
|
|
3217
|
-
m = String(msg);
|
|
3218
|
-
}
|
|
3214
|
+
if (level === "json") m = log_stringify(msg);
|
|
3219
3215
|
__log_backlog__.push([
|
|
3220
3216
|
level,
|
|
3221
3217
|
m,
|
|
@@ -3300,38 +3296,67 @@
|
|
|
3300
3296
|
}
|
|
3301
3297
|
}
|
|
3302
3298
|
}
|
|
3299
|
+
function log_string(v) {
|
|
3300
|
+
try {
|
|
3301
|
+
return String(v);
|
|
3302
|
+
} catch (e) {
|
|
3303
|
+
return log_stringify(v);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
function log_number(parse, v) {
|
|
3307
|
+
try {
|
|
3308
|
+
return parse(v);
|
|
3309
|
+
} catch (e) {
|
|
3310
|
+
return log_string(v);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3303
3313
|
function format_log(format) {
|
|
3304
3314
|
const args = Array.prototype.slice.call(arguments);
|
|
3305
3315
|
let output = "";
|
|
3306
3316
|
if (typeof format === "string") {
|
|
3307
3317
|
if (args.length === 1) return format;
|
|
3308
3318
|
let i = 1;
|
|
3309
|
-
output = format.replace(/%[
|
|
3319
|
+
output = format.replace(/%[sdifoOj%]/g, (match) => {
|
|
3320
|
+
if (match === "%%") return "%";
|
|
3310
3321
|
const val = args[i++];
|
|
3311
3322
|
switch (match) {
|
|
3312
|
-
case "%s": return
|
|
3323
|
+
case "%s": return log_string(val);
|
|
3313
3324
|
case "%d":
|
|
3314
|
-
case "%i":
|
|
3315
|
-
|
|
3325
|
+
case "%i":
|
|
3326
|
+
if (typeof val === "bigint") return val.toString();
|
|
3327
|
+
return log_number(parseInt, val);
|
|
3328
|
+
case "%f":
|
|
3329
|
+
if (typeof val === "bigint") return val.toString();
|
|
3330
|
+
return log_number(parseFloat, val);
|
|
3331
|
+
case "%j": return log_stringify(val);
|
|
3316
3332
|
case "%o":
|
|
3317
|
-
case "%O": return typeof val === "object" ? log_stringify(val) :
|
|
3333
|
+
case "%O": return typeof val === "object" ? log_stringify(val) : log_string(val);
|
|
3318
3334
|
default: return match;
|
|
3319
3335
|
}
|
|
3320
3336
|
});
|
|
3321
|
-
const rest = args.slice(i).map((arg) => typeof arg === "object" ? log_stringify(arg) :
|
|
3337
|
+
const rest = args.slice(i).map((arg) => typeof arg === "object" ? log_stringify(arg) : log_string(arg));
|
|
3322
3338
|
if (rest.length > 0) output += " " + rest.join(" ");
|
|
3323
|
-
} else output = args.map((arg) => typeof arg === "object" ? log_stringify(arg) :
|
|
3339
|
+
} else output = args.map((arg) => typeof arg === "object" ? log_stringify(arg) : log_string(arg)).join(" ");
|
|
3324
3340
|
return output;
|
|
3325
3341
|
}
|
|
3342
|
+
function call_log_function(fn, ...args) {
|
|
3343
|
+
try {
|
|
3344
|
+
fn(...args);
|
|
3345
|
+
} catch (e) {
|
|
3346
|
+
try {
|
|
3347
|
+
_console.error("a log function threw:", e);
|
|
3348
|
+
} catch (e2) {}
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3326
3351
|
function log_error(format, ...args) {
|
|
3327
3352
|
let msg = format_log(format, ...args);
|
|
3328
3353
|
let hora = current_timestamp();
|
|
3329
3354
|
if (f_error) {
|
|
3330
3355
|
if (f_error === _console.error) {
|
|
3331
|
-
if (console_wants("error", msg)) f_error
|
|
3356
|
+
if (console_wants("error", msg)) call_log_function(f_error, "%c" + hora + " ERROR: " + String(msg), "color:red");
|
|
3332
3357
|
} else {
|
|
3333
3358
|
if (console_wants("error", msg)) _console.error("%c" + hora + " ERROR: " + String(msg), "color:red");
|
|
3334
|
-
f_error
|
|
3359
|
+
call_log_function(f_error, `${hora} ERROR: ${String(msg)}`);
|
|
3335
3360
|
}
|
|
3336
3361
|
}
|
|
3337
3362
|
emit_log_callback("error", msg, hora);
|
|
@@ -3341,10 +3366,10 @@
|
|
|
3341
3366
|
let hora = current_timestamp();
|
|
3342
3367
|
if (f_warning) {
|
|
3343
3368
|
if (f_warning === _console.warn) {
|
|
3344
|
-
if (console_wants("warning", msg)) f_warning
|
|
3369
|
+
if (console_wants("warning", msg)) call_log_function(f_warning, "%c" + hora + " WARNING: " + String(msg), "color:yellow");
|
|
3345
3370
|
} else {
|
|
3346
3371
|
if (console_wants("warning", msg)) _console.warn("%c" + hora + " WARNING: " + String(msg), "color:yellow");
|
|
3347
|
-
f_warning
|
|
3372
|
+
call_log_function(f_warning, `${hora} WARNING: ${String(msg)}`);
|
|
3348
3373
|
}
|
|
3349
3374
|
}
|
|
3350
3375
|
emit_log_callback("warning", msg, hora);
|
|
@@ -3353,7 +3378,7 @@
|
|
|
3353
3378
|
let msg = format_log(format, ...args);
|
|
3354
3379
|
let hora = current_timestamp();
|
|
3355
3380
|
if (f_info) {
|
|
3356
|
-
if (console_wants("info", msg)) f_info
|
|
3381
|
+
if (console_wants("info", msg)) call_log_function(f_info, "%c" + hora + " INFO: " + String(msg), "color:cyan");
|
|
3357
3382
|
}
|
|
3358
3383
|
emit_log_callback("info", msg, hora);
|
|
3359
3384
|
}
|
|
@@ -3361,7 +3386,7 @@
|
|
|
3361
3386
|
let msg = format_log(format, ...args);
|
|
3362
3387
|
let hora = current_timestamp();
|
|
3363
3388
|
if (f_debug) {
|
|
3364
|
-
if (console_wants("debug", msg)) f_debug
|
|
3389
|
+
if (console_wants("debug", msg)) call_log_function(f_debug, "%c" + hora + " DEBUG: " + String(msg), "color:silver");
|
|
3365
3390
|
}
|
|
3366
3391
|
emit_log_callback("debug", msg, hora);
|
|
3367
3392
|
}
|
|
@@ -3369,14 +3394,14 @@
|
|
|
3369
3394
|
let msg = format_log(format, ...args);
|
|
3370
3395
|
let hora = current_timestamp();
|
|
3371
3396
|
if (f_debug) {
|
|
3372
|
-
if (console_wants("msg", msg)) f_debug
|
|
3397
|
+
if (console_wants("msg", msg)) call_log_function(f_debug, "%c" + hora + " MSG: " + String(msg), "color:cyan");
|
|
3373
3398
|
}
|
|
3374
3399
|
emit_log_callback("msg", msg, hora);
|
|
3375
3400
|
}
|
|
3376
3401
|
function trace_json(jn, msg) {
|
|
3377
3402
|
if (console_wants("json", msg)) {
|
|
3378
|
-
if (msg) _console.warn
|
|
3379
|
-
_console.dir
|
|
3403
|
+
if (msg) call_log_function(_console.warn, "=====> " + log_string(msg));
|
|
3404
|
+
call_log_function(_console.dir, jn);
|
|
3380
3405
|
}
|
|
3381
3406
|
emit_log_callback("json", jn, current_timestamp());
|
|
3382
3407
|
}
|
|
@@ -4375,6 +4400,13 @@
|
|
|
4375
4400
|
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4376
4401
|
return default_value;
|
|
4377
4402
|
}
|
|
4403
|
+
if (create && v === null) {
|
|
4404
|
+
if (required) {
|
|
4405
|
+
log_error(`path not found: '${path}'`);
|
|
4406
|
+
trace_json_masked(kw);
|
|
4407
|
+
}
|
|
4408
|
+
return default_value;
|
|
4409
|
+
}
|
|
4378
4410
|
if (required || create) {
|
|
4379
4411
|
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json dict: '${path}'` + (create ? ", cannot create" : ""));
|
|
4380
4412
|
trace_json_masked(kw);
|
|
@@ -4439,6 +4471,13 @@
|
|
|
4439
4471
|
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4440
4472
|
return default_value;
|
|
4441
4473
|
}
|
|
4474
|
+
if (create && v === null) {
|
|
4475
|
+
if (required) {
|
|
4476
|
+
log_error(`path not found: '${path}'`);
|
|
4477
|
+
trace_json_masked(kw);
|
|
4478
|
+
}
|
|
4479
|
+
return default_value;
|
|
4480
|
+
}
|
|
4442
4481
|
if (required || create) {
|
|
4443
4482
|
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json list: '${path}'` + (create ? ", cannot create" : ""));
|
|
4444
4483
|
trace_json_masked(kw);
|
|
@@ -4652,8 +4691,8 @@
|
|
|
4652
4691
|
["$key1", "$key2", ...]
|
|
4653
4692
|
{"$key1":*, "$key2":*, ...}
|
|
4654
4693
|
|
|
4655
|
-
It's not a deep copy,
|
|
4656
|
-
If
|
|
4694
|
+
It's not a deep copy. A key is a KEY, not a path (as C, SDK 7.26.9).
|
|
4695
|
+
If keys are empty return kw
|
|
4657
4696
|
*************************************************************/
|
|
4658
4697
|
function kw_clone_by_keys(gobj, kw, keys, verbose) {
|
|
4659
4698
|
if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
|
|
@@ -4680,8 +4719,8 @@
|
|
|
4680
4719
|
["$key1", "$key2", ...]
|
|
4681
4720
|
{"$key1":*, "$key2":*, ...}
|
|
4682
4721
|
|
|
4683
|
-
It's not a deep copy,
|
|
4684
|
-
If
|
|
4722
|
+
It's not a deep copy. A key is a KEY, not a path (as C, SDK 7.26.9).
|
|
4723
|
+
If keys are empty return empty
|
|
4685
4724
|
***************************************************************************/
|
|
4686
4725
|
function kw_clone_by_not_keys(gobj, kw, keys, verbose) {
|
|
4687
4726
|
let kw_clone = {};
|