Skip to content

Commit

Permalink
feat: 14.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
h7lin committed Jul 1, 2020
1 parent 46ade52 commit 962466f
Show file tree
Hide file tree
Showing 365 changed files with 1,563 additions and 741 deletions.
2 changes: 1 addition & 1 deletion addons/c_addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

当不使用 N-API 时,实现插件很复杂,涉及多个组件和 API 的知识:

- V8:Node.js 目前用于提供 JavaScript 实现的 C++ 库。
- V8:Node.js 用于提供 JavaScript 实现的 C++ 库。
V8 提供了用于创建对象、调用函数等的机制。
V8 API 文档主要在 `v8.h` 头文件中(Node.js 源代码树中的 `deps/v8/include/v8.h`),也可以在查看[在线文档][v8-docs]

Expand Down
2 changes: 1 addition & 1 deletion addons/context_aware_addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NODE_MODULE_INITIALIZER(Local<Object> exports,
可以通过执行以下步骤来构造上下文感知的插件以避免全局静态数据:

* 定义一个类,该类会保存每个插件实例的数据,并且具有以下形式的静态成员:
```C++
```cpp
static void DeleteInstance(void* data) {
// 将 `data` 转换为该类的实例并删除它。
}
Expand Down
2 changes: 1 addition & 1 deletion addons/native_abstractions_for_node_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
文档中所示的每个例子都直接使用 Node.js V8 API 来实现插件。
V8 API 可能并且已经与下一个 V8 的发行版本有显著的变化。
伴随着每次变化,插件为了能够继续工作,可能需要进行更新和重新编译。
Node.js 的发布计划会尽量减少这种变化的频率和影响,但 Node.js 目前可以确保 V8 API 的稳定性。
Node.js 的发布计划会尽量减少这种变化的频率和影响,但 Node.js 可以确保 V8 API 的稳定性。

[Node.js 的原生抽象][Native Abstractions for Node.js](或称为 `nan`)提供了一组工具,建议插件开发者使用这些工具来保持插件在过往与将来的 V8 Node.js 的版本之间的兼容性。
查看 `nan` [示例][examples]了解它是如何被使用的。
Expand Down
2 changes: 1 addition & 1 deletion addons/worker_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
为了支持 [`Worker`] 线程,插件需要清理可能分配的任何资源(当存在这样的线程时)。
这可以通过使用 `AddEnvironmentCleanupHook()` 函数来实现:

```c++
```cpp
void AddEnvironmentCleanupHook(v8::Isolate* isolate,
void (*fun)(void* arg),
void* arg);
Expand Down
2 changes: 1 addition & 1 deletion async_hooks/async_hooks_executionasyncresource.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ createHook({
}
}).enable();
const server = createServer(function(req, res) {
const server = createServer((req, res) => {
executionAsyncResource()[sym] = { state: req.url };
setTimeout(function() {
res.end(JSON.stringify(executionAsyncResource()[sym]));
Expand Down
24 changes: 24 additions & 0 deletions async_hooks/integrating_asyncresource_with_eventemitter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Event listeners triggered by an [`EventEmitter`][] may be run in a different
execution context than the one that was active when `eventEmitter.on()` was
called.

The following example shows how to use the `AsyncResource` class to properly
associate an event listener with the correct execution context. The same
approach can be applied to a [`Stream`][] or a similar event-driven class.

```js
const { createServer } = require('http');
const { AsyncResource, executionAsyncId } = require('async_hooks');
const server = createServer((req, res) => {
const asyncResource = new AsyncResource('request');
// The listener will always run in the execution context of `asyncResource`.
req.on('close', asyncResource.runInAsyncScope.bind(asyncResource, () => {
// Prints: true
console.log(asyncResource.asyncId() === executionAsyncId());
}));
res.end();
}).listen(3000);
```

2 changes: 2 additions & 0 deletions async_hooks/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ to associate the asynchronous operation with the correct execution context.





2 changes: 1 addition & 1 deletion buffer/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
支持许多涵盖其他用例的额外方法。
只要支持 `Buffer` 的地方,Node.js API 都可以接受普通的 [`Uint8Array`]

`Buffer` 类的实例,以及通常的 [`Uint8Array`],类似于从 `0` `255` 之间的整数数组,但对应于固定大小的内存块,并且不能包含任何其他值。
`Buffer` 的实例(通常是 [`Uint8Array`] 的实例),类似于从 `0` `255` 之间的整数数组,但对应于固定大小的内存块,并且不能包含任何其他值。
一个 `Buffer` 的大小在创建时确定,且无法更改。

`Buffer` 类在全局作用域中,因此无需使用 `require('buffer').Buffer`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ added: v8.2.0
-->

* `object` {Object} 支持 `Symbol.toPrimitive` `valueOf()` 的对象。
* `offsetOrEncoding` {integer|string} 字节偏移量或字符编码,取决于 `object.valueOf()` `object[Symbol.toPrimitive]()` 返回的值
* `length` {integer} 长度,取决于 `object.valueOf()` `object[Symbol.toPrimitive]()` 的返回值
* `offsetOrEncoding` {integer|string} 字节偏移量或字符编码。
* `length` {integer} 长度。

对于 `valueOf()` 返回值不严格等于 `object` 的对象,返回 `Buffer.from(object.valueOf(), offsetOrEncoding, length)`

Expand All @@ -13,7 +13,7 @@ const buf = Buffer.from(new String('this is a test'));
// 打印: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>
```

对于支持 `Symbol.toPrimitive` 的对象,会返回 `Buffer.from(object[Symbol.toPrimitive](), offsetOrEncoding, length)`
对于支持 `Symbol.toPrimitive` 的对象,会返回 `Buffer.from(object[Symbol.toPrimitive]('string'), offsetOrEncoding)`

```js
class Foo {
Expand Down
9 changes: 9 additions & 0 deletions cli/experimental_top_level_await.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- YAML
added: v14.3.0
-->

Enable experimental top-level `await` keyword support, available only in ES
module scripts.

(See also `--experimental-repl-await`.)

2 changes: 0 additions & 2 deletions cli/experimental_wasm_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
added: v12.3.0
-->

Enable experimental WebAssembly module support.

2 changes: 2 additions & 0 deletions cli/force_context_aware.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ added: v12.12.0

Disable loading native addons that are not [context-aware][].

Enable experimental WebAssembly module support.

3 changes: 2 additions & 1 deletion cli/node_options_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Node.js options that are allowed are:
* `--experimental-policy`
* `--experimental-repl-await`
* `--experimental-specifier-resolution`
* `--experimental-top-level-await`
* `--experimental-vm-modules`
* `--experimental-wasi-unstable-preview1`
* `--experimental-wasm-modules`
Expand Down Expand Up @@ -73,7 +74,7 @@ Node.js options that are allowed are:
* `--prof-process`
* `--redirect-warnings`
* `--report-compact`
* `--report-directory`
* `--report-dir`, `--report-directory`
* `--report-filename`
* `--report-on-fatalerror`
* `--report-on-signal`
Expand Down
8 changes: 8 additions & 0 deletions cli/node_skip_platform_check_value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- YAML
added: v14.5.0
-->

If `value` equals `'1'`, the check for a supported platform is skipped during
Node.js startup. Node.js might not execute correctly. Any issues encountered
on unsupported platforms will not be fixed.

File renamed without changes.
6 changes: 5 additions & 1 deletion cli/unhandled_rejections_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ for the very first unhandled rejection in case no [`unhandledRejection`][] hook
is used.

Using this flag allows to change what should happen when an unhandled rejection
occurs. One of three modes can be chosen:
occurs. One of the following modes can be chosen:

* `throw`: Emit [`unhandledRejection`][]. If this hook is not set, raise the
unhandled rejection as an uncaught exception.
* `strict`: Raise the unhandled rejection as an uncaught exception.
* `warn`: Always trigger a warning, no matter if the [`unhandledRejection`][]
hook is set or not but do not print the deprecation warning.
* `warn-with-error-code`: Emit [`unhandledRejection`][]. If this hook is not
set, trigger a warning, and set the process exit code to 1.
* `none`: Silence all warnings.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
added: v0.9.12
-->

* `signal` {string} 发送给工作进程的杀死信号的名称。
* `signal` {string} 发送给工作进程的杀死信号的名称。**默认值**: `'SIGTERM'`

这个方法将会杀死工作进程。
在主进程中,通过断开与 `worker.process` 的连接来实现,一旦断开连接后,通过 `signal` 来杀死工作进程。
Expand Down
7 changes: 6 additions & 1 deletion crypto/ccm_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ mode must adhere to certain restrictions when using the cipher API:
mode might fail as CCM cannot handle more than one chunk of data per instance.
* When passing additional authenticated data (AAD), the length of the actual
message in bytes must be passed to `setAAD()` via the `plaintextLength`
option. This is not necessary if no AAD is used.
option.
Many crypto libraries include the authentication tag in the ciphertext,
which means that they produce ciphertexts of the length
`plaintextLength + authTagLength`. Node.js does not include the authentication
tag, so the ciphertext length is always `plaintextLength`.
This is not necessary if no AAD is used.
* As CCM processes the whole message at once, `update()` can only be called
once.
* Even though calling `update()` is sufficient to encrypt/decrypt the message,
Expand Down
8 changes: 8 additions & 0 deletions crypto/class_keyobject.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<!-- YAML
added: v11.6.0
changes:
- version: v14.5.0
pr-url: https://github.com/nodejs/node/pull/33360
description: Instances of this class can now be passed to worker threads
using `postMessage`.
- version: v11.13.0
pr-url: https://github.com/nodejs/node/pull/26438
description: This class is now exported.
Expand All @@ -16,3 +20,7 @@ keyword.
Most applications should consider using the new `KeyObject` API instead of
passing keys as strings or `Buffer`s due to improved security features.
`KeyObject` instances can be passed to other threads via [`postMessage()`][].
The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to
be listed in the `transferList` argument.

2 changes: 1 addition & 1 deletion crypto/crypto_createsign_algorithm_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ added: v0.1.92
* `options` {Object} [`stream.Writable` options][]
* Returns: {Sign}

Creates and returns a `Sign` object that uses the given `algorithm`. Use
Creates and returns a `Sign` object that uses the given `algorithm`. Use
[`crypto.getHashes()`][] to obtain the names of the available digest algorithms.
Optional `options` argument controls the `stream.Writable` behavior.

Expand Down
2 changes: 1 addition & 1 deletion crypto/decipher_setaad_buffer_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _additional authenticated data_ (AAD) input parameter.

The `options` argument is optional for `GCM`. When using `CCM`, the
`plaintextLength` option must be specified and its value must match the length
of the plaintext in bytes. See [CCM mode][].
of the ciphertext in bytes. See [CCM mode][].

The `decipher.setAAD()` method must be called before [`decipher.update()`][].

1 change: 1 addition & 0 deletions crypto/node_js_crypto_constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@






5 changes: 2 additions & 3 deletions debugger/v8_inspector_integration_for_node_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ V8 检查器的集成允许将 Chrome 开发者工具附加到 Node.js 实例,

```console
$ node --inspect index.js
Debugger listening on 127.0.0.1:9229.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
Debugger listening on ws://127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
For help, see: https://nodejs.org/en/docs/inspector
```

(在上面的示例中,URL 末尾的 UUID dc9010dd-f8b8-4ac5-a510-c1a114ec7d29 是动态生成的,它在不同的调试会话中是不一样的。)
Expand Down
121 changes: 1 addition & 120 deletions deprecations/dep0142_repl_builtinlibs.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,123 +11,4 @@ The `repl` module exports a `_builtinLibs` property that contains an array with
native modules. It was incomplete so far and instead it's better to rely upon
`require('module').builtinModules`.

























































































































<a id="DEP0143"></a>
Loading

0 comments on commit 962466f

Please sign in to comment.