lib: add support for JSTransferable as a mixin#38383
Closed
jasnell wants to merge 1 commit intonodejs:masterfrom
Closed
lib: add support for JSTransferable as a mixin#38383jasnell wants to merge 1 commit intonodejs:masterfrom
jasnell wants to merge 1 commit intonodejs:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@addaleax ... Very interested in what you think on this... the use case is that I want to define internal classes that are both transferable and extend
NodeEventTargetbut without forcing allNodeEventTargetinstances to be cloneable or incur the cost of extendingJSTransferable. Because we can't use multiple inheritance this usesJSTransferableas a kind of mixin.This is not a public facing API. It is inteded for internal use only for now.
Adds a new
makeTransferable()utility that can construct aJSTransferableobject that does not directly extend theJSTransferableJavaScript class.Because JavaScript does not support multiple inheritance, it is
not possible (without help) to implement a class that extends
both
JSTransferableand, for instance,EventTargetwithoutincurring a significant additional complexity and performance
cost by making all
EventTargetinstances extendJSTransferable...That is, we don't want:
The
makeTransferable()allows us to create objects that arebacked internally by
JSTransferablewithout having to actuallyextend it by leveraging the magic of
Reflect.construct().The additional
internal/test/transfer.jsfile is required for thetest because successfully deserializing transferable classes requires
that they be located in
lib/internalfor now.Signed-off-by: James M Snell jasnell@gmail.com