ipld / js-dag-cbor

dag-cbor codec for IPLD
Other
26 stars 17 forks source link

feat!: coerce undefined to null on decode #45

Closed rvagg closed 2 years ago

rvagg commented 2 years ago

Ref: https://github.com/ipld/js-dag-cbor/issues/44 (read this if you want the background) Ref: https://github.com/ipld/go-ipld-prime/pull/308

This is a WIP because I don't have the tools to easily perform a coercion yet; I need to do something in cborg so I don't have to get dirty with the token stream, which is currently the only way to do this here. It may be as simple as a coerceUndefinedToNull option or something like that, or there may be a straightforward way to have a type translation option like I have for the encoder side, which is quite a nice feature.

Currently tests are failing because it doesn't coerce, but lets the undefined through, but the tests are in place and they'll pass as soon as the rest is done.

Using the new coerceUndefinedToNull option in cborg to do the dirty work. See #44 for more info.

rvagg commented 2 years ago

Marking this as breaking since this changes an error behaviour that's been active since v3 of this library so it's possible that this strictness is being relied upon, somewhere, by someone.

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 7.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

oed commented 2 years ago

Thank you @rvagg!