fix exercise 2 and add exercise 3 in chapter 8#3
Open
kimamula wants to merge 1 commit intobcherny:masterfrom
Open
fix exercise 2 and add exercise 3 in chapter 8#3kimamula wants to merge 1 commit intobcherny:masterfrom
kimamula wants to merge 1 commit intobcherny:masterfrom
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Thanks for the great book.
I fixed 2 problems in the answers of the exercises of chapter 8.
1. Fix
onmessagecompilation errorThe current
onmessageimplementation in the answer of the exercise 2 does not compile.I implemented
handlemethod in whichswitchis used for type refinement and createdDatatype which takes advantage of distributive conditional type to declare more appropriate type than{command: C; args: MatrixProtocol[C]['in']}fordata.2. Add an answer for the exercise 3
Added code similar to the worker thread example.
By the way, though it is described that
child_processis the way to do multithreading in Node.js, it is actually for multi processing.Node.js provides
worker_threadsmodule for multithreading.Other thing to note
This is not a problem in exercises, but the
SafeEmitterimplementation in chapter 8 does not compile.What about using interface instead of class?
Not only does this compile, but also this is more lightweight as this is a type-level wrapper and does not emit any JavaScript code.