@yuneta/gobj-js 7.26.13 → 7.26.14
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 +32 -9
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +191 -184
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +32 -9
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +215 -208
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +32 -9
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +191 -184
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +32 -9
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +191 -184
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.cjs.js
CHANGED
|
@@ -4337,8 +4337,10 @@ function kw_get_pointer(gobj, kw, path, default_value, flag) {
|
|
|
4337
4337
|
/************************************************************
|
|
4338
4338
|
* As the C kw_get_dict(): a dict found is the answer, and
|
|
4339
4339
|
* anything else gives the default back AS GIVEN (null stays
|
|
4340
|
-
* null). KW_CREATE stores a dict default, never a null one
|
|
4341
|
-
*
|
|
4340
|
+
* null). KW_CREATE stores a dict default, never a null one, and
|
|
4341
|
+
* replaces a null at the path; over another type it logs and
|
|
4342
|
+
* gives the default back unwritten (C returns NULL there, SDK
|
|
4343
|
+
* 7.26.9). Before gobj-js 7.25.2 the answer went through Object(), so a
|
|
4342
4344
|
* null default came back as {} and a 0 as a Number object.
|
|
4343
4345
|
************************************************************/
|
|
4344
4346
|
function kw_get_dict(gobj, kw, path, default_value, flag) {
|
|
@@ -4359,8 +4361,12 @@ function kw_get_dict(gobj, kw, path, default_value, flag) {
|
|
|
4359
4361
|
return default_value;
|
|
4360
4362
|
}
|
|
4361
4363
|
if (!is_object(v)) {
|
|
4362
|
-
if (
|
|
4363
|
-
|
|
4364
|
+
if (create && v === null && is_object(default_value)) {
|
|
4365
|
+
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4366
|
+
return default_value;
|
|
4367
|
+
}
|
|
4368
|
+
if (required || create) {
|
|
4369
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json dict: '${path}'` + (create ? ", cannot create" : ""));
|
|
4364
4370
|
trace_json_masked(kw);
|
|
4365
4371
|
}
|
|
4366
4372
|
return default_value;
|
|
@@ -4394,7 +4400,9 @@ function kw_get_dict_value(gobj, kw, path, default_value, flag) {
|
|
|
4394
4400
|
/************************************************************
|
|
4395
4401
|
* As the C kw_get_list(): a list found is the answer, and
|
|
4396
4402
|
* anything else gives the default back AS GIVEN. KW_CREATE
|
|
4397
|
-
* stores a list default, never a null one
|
|
4403
|
+
* stores a list default, never a null one, and replaces a null
|
|
4404
|
+
* at the path; over another type it logs and gives the default
|
|
4405
|
+
* back unwritten (C returns NULL there, SDK 7.26.9). Before gobj-js
|
|
4398
4406
|
* 7.25.2 the answer went through Array(), which WRAPS its
|
|
4399
4407
|
* argument: a list found came back as [list], a default of []
|
|
4400
4408
|
* as [[]] and a null one as [null].
|
|
@@ -4417,8 +4425,12 @@ function kw_get_list(gobj, kw, path, default_value, flag) {
|
|
|
4417
4425
|
return default_value;
|
|
4418
4426
|
}
|
|
4419
4427
|
if (!is_array(v)) {
|
|
4420
|
-
if (
|
|
4421
|
-
|
|
4428
|
+
if (create && v === null && is_array(default_value)) {
|
|
4429
|
+
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4430
|
+
return default_value;
|
|
4431
|
+
}
|
|
4432
|
+
if (required || create) {
|
|
4433
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json list: '${path}'` + (create ? ", cannot create" : ""));
|
|
4422
4434
|
trace_json_masked(kw);
|
|
4423
4435
|
}
|
|
4424
4436
|
return default_value;
|
|
@@ -5242,6 +5254,17 @@ function jdb_init(jdb, prefix, duplicate) {
|
|
|
5242
5254
|
return jdb;
|
|
5243
5255
|
}
|
|
5244
5256
|
/********************************************
|
|
5257
|
+
* A value as json text for a log line: the error path must not throw
|
|
5258
|
+
* (a circular record, a BigInt).
|
|
5259
|
+
********************************************/
|
|
5260
|
+
function safe_json_text(v) {
|
|
5261
|
+
try {
|
|
5262
|
+
return JSON.stringify(v);
|
|
5263
|
+
} catch (e) {
|
|
5264
|
+
return `<${typeof v}: not json (${e.message})>`;
|
|
5265
|
+
}
|
|
5266
|
+
}
|
|
5267
|
+
/********************************************
|
|
5245
5268
|
*
|
|
5246
5269
|
********************************************/
|
|
5247
5270
|
function jdb_update(jdb, topic_name, path, kw) {
|
|
@@ -5251,7 +5274,7 @@ function jdb_update(jdb, topic_name, path, kw) {
|
|
|
5251
5274
|
return null;
|
|
5252
5275
|
}
|
|
5253
5276
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5254
|
-
log_error(`jdb_update: record without id: ${
|
|
5277
|
+
log_error(`jdb_update: record without id: ${safe_json_text(kw)}`);
|
|
5255
5278
|
return null;
|
|
5256
5279
|
}
|
|
5257
5280
|
if (!is_string(path)) {
|
|
@@ -5304,7 +5327,7 @@ function jdb_delete(jdb, topic_name, path, kw) {
|
|
|
5304
5327
|
return null;
|
|
5305
5328
|
}
|
|
5306
5329
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5307
|
-
log_error(`jdb_delete: record without id: ${
|
|
5330
|
+
log_error(`jdb_delete: record without id: ${safe_json_text(kw)}`);
|
|
5308
5331
|
return null;
|
|
5309
5332
|
}
|
|
5310
5333
|
if (!is_string(path)) {
|