@yuneta/gobj-js 7.16.1 → 7.16.3

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.
@@ -3269,7 +3269,9 @@ function json_array_size(a) {
3269
3269
  return 0;
3270
3270
  }
3271
3271
  /************************************************************
3272
- * String element = 1 if not empty string
3272
+ * How much content a json carries: elements of a container,
3273
+ * 1 for a non-empty string, 0 for everything else
3274
+ * (null/undefined, scalars). C twin: json_size() in helpers.h.
3273
3275
  ************************************************************/
3274
3276
  function json_size(a) {
3275
3277
  if (is_object(a)) return Object.keys(a).length;
@@ -3278,6 +3280,22 @@ function json_size(a) {
3278
3280
  else return 0;
3279
3281
  }
3280
3282
  /************************************************************
3283
+ * "There is nothing usable here": null/undefined, {}, [],
3284
+ * "" and any scalar. C twin: empty_json() in helpers.h,
3285
+ * where it is the guard to write instead of `if(!jn)` --
3286
+ * there an absent DTP_JSON is json_null(), a valid pointer.
3287
+ * Here `if(!x)` happens to work, and that difference is what
3288
+ * a port across the two runtimes gets wrong: write the same
3289
+ * question in both.
3290
+ *
3291
+ * The other question -- "absent or explicitly null", C's
3292
+ * json_absent() -- is is_null() here, since javascript has
3293
+ * no second null to tell apart.
3294
+ ************************************************************/
3295
+ function empty_json(a) {
3296
+ return json_size(a) === 0;
3297
+ }
3298
+ /************************************************************
3281
3299
  * Return if a value is an object (excluding arrays & null)
3282
3300
  ************************************************************/
3283
3301
  function is_object(value) {
@@ -5631,6 +5649,7 @@ var treedb_field_types = [
5631
5649
  "date",
5632
5650
  "color",
5633
5651
  "image",
5652
+ "icon",
5634
5653
  "tel",
5635
5654
  "table",
5636
5655
  "id",
@@ -6913,6 +6932,7 @@ exports.db_save_persistent_attrs = db_save_persistent_attrs;
6913
6932
  exports.debounce = debounce;
6914
6933
  exports.delete_from_list = delete_from_list;
6915
6934
  exports.duplicate_objects = duplicate_objects;
6935
+ exports.empty_json = empty_json;
6916
6936
  exports.empty_string = empty_string;
6917
6937
  exports.escapeHtml = escapeHtml;
6918
6938
  exports.event_flag_t = event_flag_t;