denostack / superserial

A comprehensive Serializer/Deserializer that can handle any data type.
MIT License
35 stars 3 forks source link

Complex Objects #7

Closed elarrat closed 1 year ago

elarrat commented 1 year ago

I tried to serialize/deserialize a @google-cloud/pubsub Topic class object and the library presented some unexpected behaviors.

When I tried to serialize, I had to change serialize.js, line 113 to:

        const name = value.constructor && value.constructor !== Object && value.constructor !== Function
            ? value.constructor.name
            : "";

This additional value.constructor check made sure that empty objects pass this validation.

And when I deserialize it, I get the error in deserialize.js, line 58: TypeError: Cannot read properties of undefined (reading 'projectId'). This one has been a little more trick to figure out and I haven't yet, maybe when you have some time to spare I'd very appreciate your support.

Awesome lib by the way, congratz on the great job!

wan2land commented 1 year ago

serialize is presumed to have occurred on an object whose prototype is null, such as Object.create(null). I fixed this right away.

but, I don't have a clue about deserialize, can you provide a deserialized string? (or a bit of code you wrote....)

elarrat commented 1 year ago

I couldn't get to any code. I can get you the serialized string. Is pretty big though. Give me a couple of days and I'll bring it here

elarrat commented 1 year ago

https://drive.google.com/file/d/1-yyjzLaFxYSaAJxj6aAYh-jdtsrRwQhh/view?usp=share_link

wan2land commented 1 year ago

Found and fixed a bug in the escape string. Please try v0.3.4.

AsyncFunction, AsyncGeneratorFunction, and Promise don't work properly, please note when using them.