near / borsh-js

TypeScript/JavaScript implementation of Binary Object Representation Serializer for Hashing
Apache License 2.0
112 stars 38 forks source link

Deserializing Option type should return null in the None case #63

Closed cy6581 closed 10 months ago

cy6581 commented 1 year ago

Hello,

Based on what's documented in the README: A buffer containing an option type should deserialize to null if the value is of type None, or to the specific type if the value is Some https://github.com/near/borsh-js/blob/6db74764cedb88097bd6d5636407f0b3481fba4c/README.md?plain=1#L44

However, the implementation in deserializeField seems to be returning undefined instead of null. https://github.com/near/borsh-js/blob/6db74764cedb88097bd6d5636407f0b3481fba4c/borsh-ts/index.ts#L391

Is this an oversight? Be happy to put in a PR for a quick change.

Thanks!

cy6581 commented 1 year ago

Hi, wondering if there's anyone who could clarify on this?