@yuneta/gobj-js 7.26.6 → 7.26.8

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.
@@ -4065,6 +4065,10 @@ function strrchr_split(str, char) {
4065
4065
  function kw_delete(gobj, kw, path) {
4066
4066
  if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
4067
4067
  const prefix = gobj ? gobj_short_name(gobj) + ": " : "";
4068
+ if (!is_string(path)) {
4069
+ log_error(`${prefix}kw_delete(): path must be a string: ${String(path)}`);
4070
+ return -1;
4071
+ }
4068
4072
  let [path_, k] = strrchr_split(path, "`");
4069
4073
  let v = kw;
4070
4074
  if (!empty_string(k)) {
@@ -4431,6 +4435,10 @@ function kw_set_dict_value(gobj, kw, path, value) {
4431
4435
  log_error("kw is not an object");
4432
4436
  return -1;
4433
4437
  }
4438
+ if (!is_string(path)) {
4439
+ log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}kw_set_dict_value(): path must be a string: ${String(path)}`);
4440
+ return -1;
4441
+ }
4434
4442
  let ss = path.split("`");
4435
4443
  let len = ss.length;
4436
4444
  for (let i = 0; i < len; i++) {
@@ -4465,9 +4473,14 @@ function kw_set_subdict_value(gobj, kw, path, key, value) {
4465
4473
  log_error("kw is not an object");
4466
4474
  return -1;
4467
4475
  }
4468
- let subdict = kw_get_dict(gobj, kw, path, {}, kw_flag_t.KW_CREATE);
4476
+ let subdict = kw_find_path(gobj, kw, path, false);
4477
+ if (subdict === void 0) {
4478
+ if (!is_string(path)) return -1;
4479
+ subdict = {};
4480
+ if (kw_set_dict_value(gobj, kw, path, subdict) < 0) return -1;
4481
+ }
4469
4482
  if (!is_object(subdict)) {
4470
- log_error("subdict is not an object");
4483
+ log_error(`subdict is not an object: '${path}'`);
4471
4484
  return -1;
4472
4485
  }
4473
4486
  set_own_key(subdict, key, value);
@@ -5214,6 +5227,10 @@ function jdb_update(jdb, topic_name, path, kw) {
5214
5227
  trace_msg(kw);
5215
5228
  return null;
5216
5229
  }
5230
+ if (!is_string(path)) {
5231
+ log_error(`jdb_update: path must be a string: ${String(path)}`);
5232
+ return null;
5233
+ }
5217
5234
  let ids = path.split("`");
5218
5235
  let id;
5219
5236
  let v = topic;
@@ -5248,6 +5265,10 @@ function jdb_delete(jdb, topic_name, path, kw) {
5248
5265
  trace_msg(kw);
5249
5266
  return null;
5250
5267
  }
5268
+ if (!is_string(path)) {
5269
+ log_error(`jdb_delete: path must be a string: ${String(path)}`);
5270
+ return null;
5271
+ }
5251
5272
  let ids = path.split("`");
5252
5273
  let id;
5253
5274
  let v = topic;