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