@yuneta/gobj-js 7.26.5 → 7.26.7
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 +22 -7
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +8 -9
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +22 -7
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +77 -78
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +22 -7
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +8 -9
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +22 -7
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +8 -9
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.cjs.js
CHANGED
|
@@ -4064,15 +4064,26 @@ function strrchr_split(str, char) {
|
|
|
4064
4064
|
************************************************************/
|
|
4065
4065
|
function kw_delete(gobj, kw, path) {
|
|
4066
4066
|
if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
|
|
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
|
+
}
|
|
4067
4072
|
let [path_, k] = strrchr_split(path, "`");
|
|
4073
|
+
let v = kw;
|
|
4068
4074
|
if (!empty_string(k)) {
|
|
4069
|
-
|
|
4070
|
-
if (
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
}
|
|
4074
|
-
|
|
4075
|
-
}
|
|
4075
|
+
v = kw_find_path(gobj, kw, path_, true);
|
|
4076
|
+
if (v === void 0) return -1;
|
|
4077
|
+
} else k = path;
|
|
4078
|
+
if (is_array(v)) {
|
|
4079
|
+
log_error(`${prefix}kw_delete(): cannot delete an item of a list: '${path}'`);
|
|
4080
|
+
return -1;
|
|
4081
|
+
}
|
|
4082
|
+
if (!is_object(v) || !Object.prototype.hasOwnProperty.call(v, k)) {
|
|
4083
|
+
log_error(`${prefix}kw_delete(): path not found: '${path}'`);
|
|
4084
|
+
return -1;
|
|
4085
|
+
}
|
|
4086
|
+
delete v[k];
|
|
4076
4087
|
return 0;
|
|
4077
4088
|
}
|
|
4078
4089
|
/************************************************************
|
|
@@ -4424,6 +4435,10 @@ function kw_set_dict_value(gobj, kw, path, value) {
|
|
|
4424
4435
|
log_error("kw is not an object");
|
|
4425
4436
|
return -1;
|
|
4426
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
|
+
}
|
|
4427
4442
|
let ss = path.split("`");
|
|
4428
4443
|
let len = ss.length;
|
|
4429
4444
|
for (let i = 0; i < len; i++) {
|