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