@yuneta/gobj-js 7.26.14 → 7.26.15

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.
@@ -3280,13 +3280,20 @@ function set_remote_log_functions(remote_log_fn) {
3280
3280
  }
3281
3281
  /************************************************************
3282
3282
  * JSON.stringify for a log line: a circular object (a gobj,
3283
- * a DOM node) must not make the log call itself throw.
3283
+ * a DOM node), a BigInt or a toJSON() that throws must not make
3284
+ * the log call itself throw -- and neither must the fallback:
3285
+ * String() throws too, on an object with no prototype or with a
3286
+ * toString() that throws.
3284
3287
  ************************************************************/
3285
3288
  function log_stringify(v) {
3286
3289
  try {
3287
3290
  return JSON.stringify(v);
3288
3291
  } catch (e) {
3289
- return String(v);
3292
+ try {
3293
+ return String(v);
3294
+ } catch (e2) {
3295
+ return `<${typeof v}: not printable>`;
3296
+ }
3290
3297
  }
3291
3298
  }
3292
3299
  function format_log(format) {
@@ -5253,17 +5260,6 @@ function jdb_init(jdb, prefix, duplicate) {
5253
5260
  return jdb;
5254
5261
  }
5255
5262
  /********************************************
5256
- * A value as json text for a log line: the error path must not throw
5257
- * (a circular record, a BigInt).
5258
- ********************************************/
5259
- function safe_json_text(v) {
5260
- try {
5261
- return JSON.stringify(v);
5262
- } catch (e) {
5263
- return `<${typeof v}: not json (${e.message})>`;
5264
- }
5265
- }
5266
- /********************************************
5267
5263
  *
5268
5264
  ********************************************/
5269
5265
  function jdb_update(jdb, topic_name, path, kw) {
@@ -5273,7 +5269,7 @@ function jdb_update(jdb, topic_name, path, kw) {
5273
5269
  return null;
5274
5270
  }
5275
5271
  if (!is_object(kw) || empty_string(kw["id"])) {
5276
- log_error(`jdb_update: record without id: ${safe_json_text(kw)}`);
5272
+ log_error(`jdb_update: record without id: ${log_stringify(kw)}`);
5277
5273
  return null;
5278
5274
  }
5279
5275
  if (!is_string(path)) {
@@ -5326,7 +5322,7 @@ function jdb_delete(jdb, topic_name, path, kw) {
5326
5322
  return null;
5327
5323
  }
5328
5324
  if (!is_object(kw) || empty_string(kw["id"])) {
5329
- log_error(`jdb_delete: record without id: ${safe_json_text(kw)}`);
5325
+ log_error(`jdb_delete: record without id: ${log_stringify(kw)}`);
5330
5326
  return null;
5331
5327
  }
5332
5328
  if (!is_string(path)) {