| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d78e317 commit 621eaf9
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -364,13 +364,12 @@ and load it instead. | |||
| 364 | 364 | ## Native Abstractions for Node.js | |
| 365 | 365 | ||
| 366 | 366 | Each of the examples illustrated in this document make direct use of the | |
| 367 | - Node.js and V8 APIs for implementing Addons. It is important to understand | ||
| 368 | - that the V8 API can, and has, changed dramatically from one V8 release to the | ||
| 369 | - next (and one major Node.js release to the next). With each change, Addons may | ||
| 370 | - need to be updated and recompiled in order to continue functioning. The Node.js | ||
| 371 | - release schedule is designed to minimize the frequency and impact of such | ||
| 372 | - changes but there is little that Node.js can do currently to ensure stability | ||
| 373 | - of the V8 APIs. | ||
| 367 | + Node.js and V8 APIs for implementing Addons. The V8 API can, and has, changed | ||
| 368 | + dramatically from one V8 release to the next (and one major Node.js release to | ||
| 369 | + the next). With each change, Addons may need to be updated and recompiled in | ||
| 370 | + order to continue functioning. The Node.js release schedule is designed to | ||
| 371 | + minimize the frequency and impact of such changes but there is little that | ||
| 372 | + Node.js can do currently to ensure stability of the V8 APIs. | ||
| 374 | 373 | ||
| 375 | 374 | The [Native Abstractions for Node.js][] (or `nan`) provide a set of tools that | |
| 376 | 375 | Addon developers are recommended to use to keep compatibility between past and | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -361,7 +361,7 @@ returned [`ChildProcess`][] will have an additional communication channel | |||
| 361 | 361 | built-in that allows messages to be passed back and forth between the parent and | |
| 362 | 362 | child. See [`subprocess.send()`][] for details. | |
| 363 | 363 | ||
| 364 | - It is important to keep in mind that spawned Node.js child processes are | ||
| 364 | + Keep in mind that spawned Node.js child processes are | ||
| 365 | 365 | independent of the parent with exception of the IPC communication channel | |
| 366 | 366 | that is established between the two. Each process has its own memory, with | |
| 367 | 367 | their own V8 instances. Because of the additional resource allocations | |
@@ -955,7 +955,7 @@ The `'error'` event is emitted whenever: | |||
| 955 | 955 | 3. Sending a message to the child process failed. | |
| 956 | 956 | ||
| 957 | 957 | The `'exit'` event may or may not fire after an error has occurred. When | |
| 958 | - listening to both the `'exit'` and `'error'` events, it is important to guard | ||
| 958 | + listening to both the `'exit'` and `'error'` events, guard | ||
| 959 | 959 | against accidentally invoking handler functions multiple times. | |
| 960 | 960 | ||
| 961 | 961 | See also [`subprocess.kill()`][] and [`subprocess.send()`][]. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1707,8 +1707,8 @@ Initialization vectors should be unpredictable and unique; ideally, they will be | |||
| 1707 | 1707 | cryptographically random. They do not have to be secret: IVs are typically just | |
| 1708 | 1708 | added to ciphertext messages unencrypted. It may sound contradictory that | |
| 1709 | 1709 | something has to be unpredictable and unique, but does not have to be secret; | |
| 1710 | - it is important to remember that an attacker must not be able to predict ahead | ||
| 1711 | - of time what a given IV will be. | ||
| 1710 | + remember that an attacker must not be able to predict ahead of time what a | ||
| 1711 | + given IV will be. | ||
| 1712 | 1712 | ||
| 1713 | 1713 | ### crypto.createDecipher(algorithm, password\[, options\]) | |
| 1714 | 1714 | <!-- YAML | |
@@ -1801,8 +1801,8 @@ Initialization vectors should be unpredictable and unique; ideally, they will be | |||
| 1801 | 1801 | cryptographically random. They do not have to be secret: IVs are typically just | |
| 1802 | 1802 | added to ciphertext messages unencrypted. It may sound contradictory that | |
| 1803 | 1803 | something has to be unpredictable and unique, but does not have to be secret; | |
| 1804 | - it is important to remember that an attacker must not be able to predict ahead | ||
| 1805 | - of time what a given IV will be. | ||
| 1804 | + remember that an attacker must not be able to predict ahead of time what a given | ||
| 1805 | + IV will be. | ||
| 1806 | 1806 | ||
| 1807 | 1807 | ### crypto.createDiffieHellman(prime\[, primeEncoding\]\[, generator\]\[, generatorEncoding\]) | |
| 1808 | 1808 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -466,7 +466,7 @@ client.send([buf1, buf2], 41234, (err) => { | |||
| 466 | 466 | ``` | |
| 467 | 467 | ||
| 468 | 468 | Sending multiple buffers might be faster or slower depending on the | |
| 469 | - application and operating system. It is important to run benchmarks to | ||
| 469 | + application and operating system. Run benchmarks to | ||
| 470 | 470 | determine the optimal strategy on a case-by-case basis. Generally speaking, | |
| 471 | 471 | however, sending multiple buffers is faster. | |
| 472 | 472 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,7 @@ myEmitter.emit('event'); | |||
| 43 | 43 | ## Passing arguments and `this` to listeners | |
| 44 | 44 | ||
| 45 | 45 | The `eventEmitter.emit()` method allows an arbitrary set of arguments to be | |
| 46 | - passed to the listener functions. It is important to keep in mind that when | ||
| 46 | + passed to the listener functions. Keep in mind that when | ||
| 47 | 47 | an ordinary listener function is called, the standard `this` keyword | |
| 48 | 48 | is intentionally set to reference the `EventEmitter` instance to which the | |
| 49 | 49 | listener is attached. | |
@@ -77,8 +77,8 @@ myEmitter.emit('event', 'a', 'b'); | |||
| 77 | 77 | ## Asynchronous vs. Synchronous | |
| 78 | 78 | ||
| 79 | 79 | The `EventEmitter` calls all listeners synchronously in the order in which | |
| 80 | - they were registered. This is important to ensure the proper sequencing of | ||
| 81 | - events and to avoid race conditions or logic errors. When appropriate, | ||
| 80 | + they were registered. This ensures the proper sequencing of | ||
| 81 | + events and helps avoid race conditions and logic errors. When appropriate, | ||
| 82 | 82 | listener functions can switch to an asynchronous mode of operation using | |
| 83 | 83 | the `setImmediate()` or `process.nextTick()` methods: | |
| 84 | 84 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -810,11 +810,11 @@ When an exception is pending one of two approaches can be employed. | |||
| 810 | 810 | ||
| 811 | 811 | The first approach is to do any appropriate cleanup and then return so that | |
| 812 | 812 | execution will return to JavaScript. As part of the transition back to | |
| 813 | - JavaScript the exception will be thrown at the point in the JavaScript | ||
| 813 | + JavaScript, the exception will be thrown at the point in the JavaScript | ||
| 814 | 814 | code where the native method was invoked. The behavior of most N-API calls | |
| 815 | 815 | is unspecified while an exception is pending, and many will simply return | |
| 816 | - `napi_pending_exception`, so it is important to do as little as possible | ||
| 817 | - and then return to JavaScript where the exception can be handled. | ||
| 816 | + `napi_pending_exception`, so do as little as possible and then return to | ||
| 817 | + JavaScript where the exception can be handled. | ||
| 818 | 818 | ||
| 819 | 819 | The second approach is to try to handle the exception. There will be cases | |
| 820 | 820 | where the native code can catch the exception, take the appropriate action, | |
@@ -4344,8 +4344,7 @@ required in order to enable correct disposal of the reference. | |||
| 4344 | 4344 | Addon modules often need to leverage async helpers from libuv as part of their | |
| 4345 | 4345 | implementation. This allows them to schedule work to be executed asynchronously | |
| 4346 | 4346 | so that their methods can return in advance of the work being completed. This | |
| 4347 | - is important in order to allow them to avoid blocking overall execution | ||
| 4348 | - of the Node.js application. | ||
| 4347 | + allows them to avoid blocking overall execution of the Node.js application. | ||
| 4349 | 4348 | ||
| 4350 | 4349 | N-API provides an ABI-stable interface for these | |
| 4351 | 4350 | supporting functions which covers the most common asynchronous use cases. | |
@@ -4948,9 +4947,9 @@ Upon creation of a `napi_threadsafe_function` a `napi_finalize` callback can be | |||
| 4948 | 4947 | provided. This callback will be invoked on the main thread when the thread-safe | |
| 4949 | 4948 | function is about to be destroyed. It receives the context and the finalize data | |
| 4950 | 4949 | given during construction, and provides an opportunity for cleaning up after the | |
| 4951 | - threads e.g. by calling `uv_thread_join()`. **It is important that, aside from | ||
| 4952 | - the main loop thread, there be no threads left using the thread-safe function | ||
| 4953 | - after the finalize callback completes.** | ||
| 4950 | + threads e.g. by calling `uv_thread_join()`. **Aside from the main loop thread, | ||
| 4951 | + no threads should be using the thread-safe function after the finalize callback | ||
| 4952 | + completes.** | ||
| 4954 | 4953 | ||
| 4955 | 4954 | The `context` given during the call to `napi_create_threadsafe_function()` can | |
| 4956 | 4955 | be retrieved from any thread with a call to | |
@@ -4995,13 +4994,13 @@ existing thread will stop making use of the thread-safe function. | |||
| 4995 | 4994 | the object has called `napi_release_threadsafe_function()` or has received a | |
| 4996 | 4995 | return status of `napi_closing` in response to a call to | |
| 4997 | 4996 | `napi_call_threadsafe_function`. The queue is emptied before the | |
| 4998 | - `napi_threadsafe_function` is destroyed. It is important that | ||
| 4999 | - `napi_release_threadsafe_function()` be the last API call made in conjunction | ||
| 5000 | - with a given `napi_threadsafe_function`, because after the call completes, there | ||
| 5001 | - is no guarantee that the `napi_threadsafe_function` is still allocated. For the | ||
| 5002 | - same reason it is also important that no more use be made of a thread-safe | ||
| 5003 | - function after receiving a return value of `napi_closing` in response to a call | ||
| 5004 | - to `napi_call_threadsafe_function`. Data associated with the | ||
| 4997 | + `napi_threadsafe_function` is destroyed. `napi_release_threadsafe_function()` | ||
| 4998 | + should be the last API call made in conjunction with a given | ||
| 4999 | + `napi_threadsafe_function`, because after the call completes, there is no | ||
| 5000 | + guarantee that the `napi_threadsafe_function` is still allocated. For the same | ||
| 5001 | + reason, do not make use of a thread-safe function | ||
| 5002 | + after receiving a return value of `napi_closing` in response to a call to | ||
| 5003 | + `napi_call_threadsafe_function`. Data associated with the | ||
| 5005 | 5004 | `napi_threadsafe_function` can be freed in its `napi_finalize` callback which | |
| 5006 | 5005 | was passed to `napi_create_threadsafe_function()`. | |
| 5007 | 5006 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,7 +100,7 @@ maintaining an appropriate and efficient flow of data. For example, | |||
| 100 | 100 | [`net.Socket`][] instances are [`Duplex`][] streams whose `Readable` side allows | |
| 101 | 101 | consumption of data received *from* the socket and whose `Writable` side allows | |
| 102 | 102 | writing data *to* the socket. Because data may be written to the socket at a | |
| 103 | - faster or slower rate than data is received, it is important for each side to | ||
| 103 | + faster or slower rate than data is received, each side should | ||
| 104 | 104 | operate (and buffer) independently of the other. | |
| 105 | 105 | ||
| 106 | 106 | ## API for Stream Consumers | |
@@ -1658,11 +1658,11 @@ class MyWritable extends Writable { | |||
| 1658 | 1658 | } | |
| 1659 | 1659 | ``` | |
| 1660 | 1660 | ||
| 1661 | - When extending streams, it is important to keep in mind what options the user | ||
| 1661 | + When extending streams, keep in mind what options the user | ||
| 1662 | 1662 | can and should provide before forwarding these to the base constructor. For | |
| 1663 | - example, if the implementation makes assumptions in regard to e.g. the | ||
| 1664 | - `autoDestroy` and `emitClose` options, it becomes important to not allow the | ||
| 1665 | - user to override these. It is therefore recommended to be explicit about what | ||
| 1663 | + example, if the implementation makes assumptions in regard to the | ||
| 1664 | + `autoDestroy` and `emitClose` options, do not allow the | ||
| 1665 | + user to override these. Be explicit about what | ||
| 1666 | 1666 | options are forwarded instead of implicitly forwarding all options. | |
| 1667 | 1667 | ||
| 1668 | 1668 | The new stream class must then implement one or more specific methods, depending | |
@@ -2609,8 +2609,8 @@ readable.on('data', (chunk) => { | |||
| 2609 | 2609 | ||
| 2610 | 2610 | #### Piping to Writable Streams from Async Iterators | |
| 2611 | 2611 | ||
| 2612 | - In the scenario of writing to a writable stream from an async iterator, | ||
| 2613 | - it is important to ensure the correct handling of backpressure and errors. | ||
| 2612 | + In the scenario of writing to a writable stream from an async iterator, ensure | ||
| 2613 | + the correct handling of backpressure and errors. | ||
| 2614 | 2614 | ||
| 2615 | 2615 | ```js | |
| 2616 | 2616 | const { once } = require('events'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -540,7 +540,7 @@ formatting passes the lint rules on `master`. | |||
| 540 | 540 | ||
| 541 | 541 | ### 13. Promote and Sign the Release Builds | |
| 542 | 542 | ||
| 543 | - **It is important that the same individual who signed the release tag be the one | ||
| 543 | + **The same individual who signed the release tag must be the one | ||
| 544 | 544 | to promote the builds as the SHASUMS256.txt file needs to be signed with the | |
| 545 | 545 | same GPG key!** | |
| 546 | 546 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,8 +100,7 @@ exports.createSecureContext = function createSecureContext(options) { | |||
| 100 | 100 | var i; | |
| 101 | 101 | var val; | |
| 102 | 102 | ||
| 103 | - // NOTE: It's important to add CA before the cert to be able to load | ||
| 104 | - // cert's issuer in C++ code. | ||
| 103 | + // Add CA before the cert to be able to load cert's issuer in C++ code. | ||
| 105 | 104 | const { ca } = options; | |
| 106 | 105 | if (ca) { | |
| 107 | 106 | if (Array.isArray(ca)) { | |
@@ -132,7 +131,7 @@ exports.createSecureContext = function createSecureContext(options) { | |||
| 132 | 131 | } | |
| 133 | 132 | } | |
| 134 | 133 | ||
| 135 | - // NOTE: It is important to set the key after the cert. | ||
| 134 | + // Set the key after the cert. | ||
| 136 | 135 | // `ssl_set_pkey` returns `0` when the key does not match the cert, but | |
| 137 | 136 | // `ssl_set_cert` returns `1` and nullifies the key in the SSL structure | |
| 138 | 137 | // which leads to the crash later on. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,10 +51,9 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) { | |||
| 51 | 51 | ||
| 52 | 52 | obj->env_ = env; | |
| 53 | 53 | ||
| 54 | - // It is important that the below call to napi_wrap() be such that we request | ||
| 55 | - // a reference to the wrapped object via the out-parameter, because this | ||
| 56 | - // ensures that we test the code path that deals with a reference that is | ||
| 57 | - // destroyed from its own finalizer. | ||
| 54 | + // The below call to napi_wrap() must request a reference to the wrapped | ||
| 55 | + // object via the out-parameter, because this ensures that we test the code | ||
| 56 | + // path that deals with a reference that is destroyed from its own finalizer. | ||
| 58 | 57 | NAPI_CALL(env, napi_wrap(env, | |
| 59 | 58 | _this, | |
| 60 | 59 | obj, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments