Skip to content

Conversation

@PSanetra
Copy link
Contributor

Proposed Changes

  • CloudEvent class:
    • Make data field immutable like the other fields in the class
    • Make data field enumerable via Object.keys() and Object.entries()
    • toJSON() does not return a data field anymore if data_base64 is set to comply with the JSON format spec 3.1.1 Out of this follows that the presence of the data and data_base64 members is mutually exclusive in a JSON serialized CloudEvent.

Fixes #515

@PSanetra PSanetra force-pushed the make-cloudevent-comparable branch from 684e5cf to 02e8229 Compare October 31, 2022 14:48
Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PSanetra thanks for this contribution! The atob function does not exist in Node.js LTS prior to version 16. Could you please add atob to dependencies and @types/atob to the dev-dependencies section, and add an import statement in validation.ts? This should get CI passing.

@PSanetra PSanetra force-pushed the make-cloudevent-comparable branch from 02e8229 to 69b2c6e Compare November 1, 2022 10:04
@PSanetra
Copy link
Contributor Author

PSanetra commented Nov 1, 2022

@lance I have changed the code to support node.js runtime and browser runtime without a additional dependency.

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition. Thank you.

@lance lance merged commit 2d5fab1 into cloudevents:main Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid jest#13535 and planttheidea/fast-equals#91

3 participants