msgpackr 1.9.4 → 1.9.5-debug.1
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.
- package/dist/index-no-eval.cjs +7 -2
- package/dist/index-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.min.js +1 -1
- package/dist/index-no-eval.min.js.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +17 -7
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +28 -7
- package/dist/test.js.map +1 -1
- package/pack.js +7 -2
- package/package.json +1 -1
- package/struct.js +10 -5
package/dist/index.js
CHANGED
|
@@ -1573,8 +1573,13 @@
|
|
|
1573
1573
|
if (Array.isArray(value)) {
|
|
1574
1574
|
packArray(value);
|
|
1575
1575
|
} else {
|
|
1576
|
-
|
|
1577
|
-
|
|
1576
|
+
// use this as an alternate mechanism for expressing how to serialize
|
|
1577
|
+
if (value.toJSON) {
|
|
1578
|
+
const json = value.toJSON();
|
|
1579
|
+
// if for some reason value.toJSON returns itself it'll loop forever
|
|
1580
|
+
if (json !== value)
|
|
1581
|
+
return pack(json)
|
|
1582
|
+
}
|
|
1578
1583
|
|
|
1579
1584
|
// if there is a writeFunction, use it, otherwise just encode as undefined
|
|
1580
1585
|
if (type === 'function')
|