@yuneta/gobj-js 7.26.13 → 7.26.15
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 +30 -11
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +9 -5
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +30 -11
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +9 -5
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +30 -11
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +9 -5
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +30 -11
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +9 -5
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.cjs.js
CHANGED
|
@@ -3281,13 +3281,20 @@ function set_remote_log_functions(remote_log_fn) {
|
|
|
3281
3281
|
}
|
|
3282
3282
|
/************************************************************
|
|
3283
3283
|
* JSON.stringify for a log line: a circular object (a gobj,
|
|
3284
|
-
* a DOM node)
|
|
3284
|
+
* a DOM node), a BigInt or a toJSON() that throws must not make
|
|
3285
|
+
* the log call itself throw -- and neither must the fallback:
|
|
3286
|
+
* String() throws too, on an object with no prototype or with a
|
|
3287
|
+
* toString() that throws.
|
|
3285
3288
|
************************************************************/
|
|
3286
3289
|
function log_stringify(v) {
|
|
3287
3290
|
try {
|
|
3288
3291
|
return JSON.stringify(v);
|
|
3289
3292
|
} catch (e) {
|
|
3290
|
-
|
|
3293
|
+
try {
|
|
3294
|
+
return String(v);
|
|
3295
|
+
} catch (e2) {
|
|
3296
|
+
return `<${typeof v}: not printable>`;
|
|
3297
|
+
}
|
|
3291
3298
|
}
|
|
3292
3299
|
}
|
|
3293
3300
|
function format_log(format) {
|
|
@@ -4337,8 +4344,10 @@ function kw_get_pointer(gobj, kw, path, default_value, flag) {
|
|
|
4337
4344
|
/************************************************************
|
|
4338
4345
|
* As the C kw_get_dict(): a dict found is the answer, and
|
|
4339
4346
|
* anything else gives the default back AS GIVEN (null stays
|
|
4340
|
-
* null). KW_CREATE stores a dict default, never a null one
|
|
4341
|
-
*
|
|
4347
|
+
* null). KW_CREATE stores a dict default, never a null one, and
|
|
4348
|
+
* replaces a null at the path; over another type it logs and
|
|
4349
|
+
* gives the default back unwritten (C returns NULL there, SDK
|
|
4350
|
+
* 7.26.9). Before gobj-js 7.25.2 the answer went through Object(), so a
|
|
4342
4351
|
* null default came back as {} and a 0 as a Number object.
|
|
4343
4352
|
************************************************************/
|
|
4344
4353
|
function kw_get_dict(gobj, kw, path, default_value, flag) {
|
|
@@ -4359,8 +4368,12 @@ function kw_get_dict(gobj, kw, path, default_value, flag) {
|
|
|
4359
4368
|
return default_value;
|
|
4360
4369
|
}
|
|
4361
4370
|
if (!is_object(v)) {
|
|
4362
|
-
if (
|
|
4363
|
-
|
|
4371
|
+
if (create && v === null && is_object(default_value)) {
|
|
4372
|
+
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4373
|
+
return default_value;
|
|
4374
|
+
}
|
|
4375
|
+
if (required || create) {
|
|
4376
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json dict: '${path}'` + (create ? ", cannot create" : ""));
|
|
4364
4377
|
trace_json_masked(kw);
|
|
4365
4378
|
}
|
|
4366
4379
|
return default_value;
|
|
@@ -4394,7 +4407,9 @@ function kw_get_dict_value(gobj, kw, path, default_value, flag) {
|
|
|
4394
4407
|
/************************************************************
|
|
4395
4408
|
* As the C kw_get_list(): a list found is the answer, and
|
|
4396
4409
|
* anything else gives the default back AS GIVEN. KW_CREATE
|
|
4397
|
-
* stores a list default, never a null one
|
|
4410
|
+
* stores a list default, never a null one, and replaces a null
|
|
4411
|
+
* at the path; over another type it logs and gives the default
|
|
4412
|
+
* back unwritten (C returns NULL there, SDK 7.26.9). Before gobj-js
|
|
4398
4413
|
* 7.25.2 the answer went through Array(), which WRAPS its
|
|
4399
4414
|
* argument: a list found came back as [list], a default of []
|
|
4400
4415
|
* as [[]] and a null one as [null].
|
|
@@ -4417,8 +4432,12 @@ function kw_get_list(gobj, kw, path, default_value, flag) {
|
|
|
4417
4432
|
return default_value;
|
|
4418
4433
|
}
|
|
4419
4434
|
if (!is_array(v)) {
|
|
4420
|
-
if (
|
|
4421
|
-
|
|
4435
|
+
if (create && v === null && is_array(default_value)) {
|
|
4436
|
+
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4437
|
+
return default_value;
|
|
4438
|
+
}
|
|
4439
|
+
if (required || create) {
|
|
4440
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json list: '${path}'` + (create ? ", cannot create" : ""));
|
|
4422
4441
|
trace_json_masked(kw);
|
|
4423
4442
|
}
|
|
4424
4443
|
return default_value;
|
|
@@ -5251,7 +5270,7 @@ function jdb_update(jdb, topic_name, path, kw) {
|
|
|
5251
5270
|
return null;
|
|
5252
5271
|
}
|
|
5253
5272
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5254
|
-
log_error(`jdb_update: record without id: ${
|
|
5273
|
+
log_error(`jdb_update: record without id: ${log_stringify(kw)}`);
|
|
5255
5274
|
return null;
|
|
5256
5275
|
}
|
|
5257
5276
|
if (!is_string(path)) {
|
|
@@ -5304,7 +5323,7 @@ function jdb_delete(jdb, topic_name, path, kw) {
|
|
|
5304
5323
|
return null;
|
|
5305
5324
|
}
|
|
5306
5325
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5307
|
-
log_error(`jdb_delete: record without id: ${
|
|
5326
|
+
log_error(`jdb_delete: record without id: ${log_stringify(kw)}`);
|
|
5308
5327
|
return null;
|
|
5309
5328
|
}
|
|
5310
5329
|
if (!is_string(path)) {
|