Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for passing encoder/decoder #2

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

jacobheun
Copy link
Contributor

This adds the ability to pass the lengthEncoder and lengthDecoder options for it-length-prefixed. I included tests for fixed encoding/decoding.

It's possible that the encoder could be passed to each individual write, but decoding from a reader doesn't currently support changing the decoder, so I made this a one time configuration when creating the wrap.

Copy link
Owner

@mkg20001 mkg20001 left a comment

Choose a reason for hiding this comment

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

LGTM, just wondering if we should allow per-read options (or per-read to override global options)

Would be something like readLP (userOpts)

lpOpts = Object.assign(Object.assign({}, opts), userOpts || {})

@jacobheun
Copy link
Contributor Author

We had talked about adding a decode.single method to it-length-prefixed which would make this a lot easier. With how it's currently setup I think you'd need to construct a new it-length-prefixed to avoid using the global decoder.

Copy link
Owner

@mkg20001 mkg20001 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants