@yuneta/gobj-js 7.16.1 → 7.16.2

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