-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Support []byte in Value #356
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent changes 👍 🚀
std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | ||
static_cast<void*>(const_cast<uint8_t*>(v)), len, | ||
[](void* data, size_t length, void *deleter_data) { | ||
free(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this seems to be the correct deallocator to use but I couldn't find a convincing example.
// Returns length of the array (number of elements, not number of bytes) | ||
uint64_t ValueToArrayLength(ValuePtr ptr) { | ||
LOCAL_VALUE(ptr); | ||
MaybeLocal<TypedArray> array = value.As<TypedArray>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check if this is empty?
uint64_t ValueToArrayLength(ValuePtr ptr) {
LOCAL_VALUE(ptr);
MaybeLocal<TypedArray> array = value.As<TypedArray>();
if (array.IsEmpty()) {
return 0;
}
return array.ToLocalChecked()->Length();
}
Same question above in ValueToUint8Array().
Codecov ReportBase: 95.28% // Head: 95.33% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #356 +/- ##
==========================================
+ Coverage 95.28% 95.33% +0.04%
==========================================
Files 17 17
Lines 594 600 +6
==========================================
+ Hits 566 572 +6
Misses 19 19
Partials 9 9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This is a reduction of the longstanding #143 to do the minimum I actually need: letting me put []byte's into and out of values.