@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.umd.js
CHANGED
|
@@ -4340,8 +4340,10 @@
|
|
|
4340
4340
|
/************************************************************
|
|
4341
4341
|
* As the C kw_get_dict(): a dict found is the answer, and
|
|
4342
4342
|
* anything else gives the default back AS GIVEN (null stays
|
|
4343
|
-
* null). KW_CREATE stores a dict default, never a null one
|
|
4344
|
-
*
|
|
4343
|
+
* null). KW_CREATE stores a dict default, never a null one, and
|
|
4344
|
+
* replaces a null at the path; over another type it logs and
|
|
4345
|
+
* gives the default back unwritten (C returns NULL there, SDK
|
|
4346
|
+
* 7.26.9). Before gobj-js 7.25.2 the answer went through Object(), so a
|
|
4345
4347
|
* null default came back as {} and a 0 as a Number object.
|
|
4346
4348
|
************************************************************/
|
|
4347
4349
|
function kw_get_dict(gobj, kw, path, default_value, flag) {
|
|
@@ -4362,8 +4364,12 @@
|
|
|
4362
4364
|
return default_value;
|
|
4363
4365
|
}
|
|
4364
4366
|
if (!is_object(v)) {
|
|
4365
|
-
if (
|
|
4366
|
-
|
|
4367
|
+
if (create && v === null && is_object(default_value)) {
|
|
4368
|
+
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4369
|
+
return default_value;
|
|
4370
|
+
}
|
|
4371
|
+
if (required || create) {
|
|
4372
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json dict: '${path}'` + (create ? ", cannot create" : ""));
|
|
4367
4373
|
trace_json_masked(kw);
|
|
4368
4374
|
}
|
|
4369
4375
|
return default_value;
|
|
@@ -4397,7 +4403,9 @@
|
|
|
4397
4403
|
/************************************************************
|
|
4398
4404
|
* As the C kw_get_list(): a list found is the answer, and
|
|
4399
4405
|
* anything else gives the default back AS GIVEN. KW_CREATE
|
|
4400
|
-
* stores a list default, never a null one
|
|
4406
|
+
* stores a list default, never a null one, and replaces a null
|
|
4407
|
+
* at the path; over another type it logs and gives the default
|
|
4408
|
+
* back unwritten (C returns NULL there, SDK 7.26.9). Before gobj-js
|
|
4401
4409
|
* 7.25.2 the answer went through Array(), which WRAPS its
|
|
4402
4410
|
* argument: a list found came back as [list], a default of []
|
|
4403
4411
|
* as [[]] and a null one as [null].
|
|
@@ -4420,8 +4428,12 @@
|
|
|
4420
4428
|
return default_value;
|
|
4421
4429
|
}
|
|
4422
4430
|
if (!is_array(v)) {
|
|
4423
|
-
if (
|
|
4424
|
-
|
|
4431
|
+
if (create && v === null && is_array(default_value)) {
|
|
4432
|
+
kw_set_dict_value(gobj, kw, path, default_value);
|
|
4433
|
+
return default_value;
|
|
4434
|
+
}
|
|
4435
|
+
if (required || create) {
|
|
4436
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json list: '${path}'` + (create ? ", cannot create" : ""));
|
|
4425
4437
|
trace_json_masked(kw);
|
|
4426
4438
|
}
|
|
4427
4439
|
return default_value;
|
|
@@ -5245,6 +5257,17 @@
|
|
|
5245
5257
|
return jdb;
|
|
5246
5258
|
}
|
|
5247
5259
|
/********************************************
|
|
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
|
+
/********************************************
|
|
5248
5271
|
*
|
|
5249
5272
|
********************************************/
|
|
5250
5273
|
function jdb_update(jdb, topic_name, path, kw) {
|
|
@@ -5254,7 +5277,7 @@
|
|
|
5254
5277
|
return null;
|
|
5255
5278
|
}
|
|
5256
5279
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5257
|
-
log_error(`jdb_update: record without id: ${
|
|
5280
|
+
log_error(`jdb_update: record without id: ${safe_json_text(kw)}`);
|
|
5258
5281
|
return null;
|
|
5259
5282
|
}
|
|
5260
5283
|
if (!is_string(path)) {
|
|
@@ -5307,7 +5330,7 @@
|
|
|
5307
5330
|
return null;
|
|
5308
5331
|
}
|
|
5309
5332
|
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5310
|
-
log_error(`jdb_delete: record without id: ${
|
|
5333
|
+
log_error(`jdb_delete: record without id: ${safe_json_text(kw)}`);
|
|
5311
5334
|
return null;
|
|
5312
5335
|
}
|
|
5313
5336
|
if (!is_string(path)) {
|