msgpackr 1.11.5 → 1.11.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.
@@ -1277,9 +1277,13 @@
1277
1277
  hasSharedUpdate = false;
1278
1278
  let encodingError;
1279
1279
  try {
1280
- if (packr.randomAccessStructure && value && value.constructor && value.constructor === Object)
1281
- writeStruct(value);
1282
- else
1280
+ if (packr.randomAccessStructure && value && value.constructor) {
1281
+ if (value.constructor === Object) writeStruct(value); // simple object
1282
+ else if (value.constructor !== Map && !Array.isArray(value) && !extensionClasses.some(extClass => value instanceof extClass)) {
1283
+ // allow user classes, if they don't need special handling (but do use toJSON if available)
1284
+ writeStruct(value.toJSON ? value.toJSON() : value);
1285
+ } else pack(value);
1286
+ } else
1283
1287
  pack(value);
1284
1288
  let lastBundle = bundledStrings;
1285
1289
  if (bundledStrings)