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

Add support for node::Encode/DecodeBytes/DecodeWrite. #251

Closed
wants to merge 5 commits into from
Closed

Conversation

kkoopa
Copy link
Collaborator

@kkoopa kkoopa commented Jan 19, 2015

Fixes #250.

@@ -1816,6 +1816,45 @@ namespace Nan {
enum Encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER};
}

NAN_INLINE v8::Local<v8::Value> NanEncode(const void *buf, size_t len, enum Nan::Encoding encoding = Nan::BINARY) {

This comment was marked as off-topic.

This comment was marked as off-topic.

@bnoordhuis
Copy link
Member

The DecodeBytes() and DecodeWrite() calls that transpose BUFFER to BINARY work but perhaps it's clearer to call the corresponding Buffer methods directly.

@kkoopa
Copy link
Collaborator Author

kkoopa commented Jan 19, 2015

I did that first, but changed to this after I noticed the code paths would become identical as it felt cleaner and does not perform the same sanity checks twice. Otherwise I need to replicate a bunch of error checking (val is not, array, because 'raw' encoding is no longer supported) and other edge cases, which makes it grow more than one might first think.

@kkoopa kkoopa force-pushed the nodestuff branch 2 times, most recently from 6caf664 to cfc4a08 Compare January 19, 2015 13:38
@kkoopa
Copy link
Collaborator Author

kkoopa commented Jan 19, 2015

Should be fixed now.

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