Skip to content

Commit

Permalink
v12.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
h7lin committed Jan 8, 2020
1 parent 4647072 commit 95dcb8b
Show file tree
Hide file tree
Showing 34 changed files with 130 additions and 72 deletions.
2 changes: 1 addition & 1 deletion addons/void_atexit_callback_args.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ static void sanity_check(void*) {
}

void init(Local<Object> exports) {
AtExit(sanity_check);
AtExit(at_exit_cb2, cookie);
AtExit(at_exit_cb2, cookie);
AtExit(at_exit_cb1, exports->GetIsolate());
AtExit(sanity_check);
}

NODE_MODULE(NODE_GYP_MODULE_NAME, init)
Expand Down
2 changes: 2 additions & 0 deletions assert/assert_throws_fn_error_message.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ assert.throws(
function throwingFirst() {
throw new Error('错误一');
}
function throwingSecond() {
throw new Error('错误二');
}
function notThrowing() {}
// 第二个参数是一个字符串,输入函数抛出一个错误。
Expand Down
4 changes: 3 additions & 1 deletion assert/strict_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
// ]
```

要停用颜色,则使用 `NODE_DISABLE_COLORS` 环境变量。
要停用颜色,则使用 `NO_COLOR` `NODE_DISABLE_COLORS` 环境变量。
注意,这也将停用 REPL 中的颜色。

有关终端环境中颜色支持的更多信息,参阅 [getColorDepth()][_tty_writestream_getcolordepth] 文档。

5 changes: 4 additions & 1 deletion buffer/buf_buffer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

* {ArrayBuffer} 创建 `Buffer` 对象时基于的底层 `ArrayBuffer` 对象。
* {ArrayBuffer} 创建此 `Buffer` 对象时基于的底层 `ArrayBuffer` 对象。

不能保证此 `ArrayBuffer` 与原始的 `Buffer` 完全对应。
有关详细信息,参阅 `buf.byteOffset` 上的说明。

```js
const arrayBuffer = new ArrayBuffer(16);
Expand Down
2 changes: 2 additions & 0 deletions child_process/subprocess_kill_signal.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ added: v0.1.90
-->

* `signal` {number|string}
* 返回: {boolean}

`subprocess.kill()` 方法会向子进程发送一个信号。
如果没有给定参数,则进程将会发送 `'SIGTERM'` 信号。
参阅 signal(7) 了解可用的信号列表。
如果 kill(2) 成功,则此函数返回 `true`,否则返回 `false`

```js
const { spawn } = require('child_process');
Expand Down
2 changes: 2 additions & 0 deletions debugger/v8_inspector_integration_for_node_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ To start debugging, open the following URL in Chrome:

如果 Chrome 浏览器的版本低于 66.0.3345.0,请在上述网址中使用 `inspector.html` 而不是 `js_app.html`

Chrome DevTools 目前还不支持调试[工作线程][Worker Threads]
可以使用 [ndb] 调试它们。

7 changes: 3 additions & 4 deletions esm/commonjs_json_and_native_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ CommonJS, JSON, and Native modules can be used with
[`module.createRequire()`][].

```js
// cjs.js
// cjs.cjs
module.exports = 'cjs';
// esm.mjs
import { createRequire } from 'module';
import { fileURLToPath as fromURL } from 'url';
const require = createRequire(fromURL(import.meta.url));
const require = createRequire(import.meta.url);
const cjs = require('./cjs');
const cjs = require('./cjs.cjs');
cjs === 'cjs'; // true
```

1 change: 1 addition & 0 deletions http/http_request_url_options_callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ changes:
* `host` {string} 请求发送至的服务器的域名或 IP 地址。**默认值:** `'localhost'`
* `hostname` {string} `host` 的别名。为了支持 [`url.parse()`],如果同时指定 `host` `hostname`,则使用 `hostname`
* `localAddress` {string} 为网络连接绑定的本地接口。
* `lookup` {Function} 自定义的查找函数。 **默认值:** [`dns.lookup()`]
* `method` {string} 一个字符串,指定 HTTP 请求的方法。**默认值:** `'GET'`
* `path` {string} 请求的路径。应包括查询字符串(如果有)。例如 `'/index.html?page=12'`。当请求的路径包含非法的字符时,则抛出异常。目前只有空格被拒绝,但未来可能会有所变化。**默认值:** `'/'`
* `port` {number} 远程服务器的端口。**默认值:** `defaultPort`(如果有设置)或 `80`
Expand Down
5 changes: 3 additions & 2 deletions http/message_destroy_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ added: v0.3.0

* `error` {Error}

在接收 `IncomingMessage` 的套接字上调用 `destroy()`
如果提供了 `error`,则会触发 `'error'` 事件,并将 `error` 作为参数传递给事件上的任何监听器。
在接收到 `IncomingMessage` 的套接字上调用 `destroy()`

如果提供了 `error`,则会在套接字上触发 `'error'` 事件,并将 `error` 作为参数传给该事件上的所有监听器。

5 changes: 4 additions & 1 deletion modules/module_builtinmodules.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!-- YAML
added: v9.3.0
added:
- v9.3.0
- v8.10.0
- v6.13.0
-->

* {string[]}
Expand Down
1 change: 1 addition & 0 deletions n-api/napi_add_finalizer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

<!-- YAML
added: v8.0.0
napiVersion: 5
-->

```C
Expand Down
12 changes: 6 additions & 6 deletions n-api/napi_call_function.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ napiVersion: 1
-->

```C
napi_status napi_call_function(napi_env env,
napi_value recv,
napi_value func,
int argc,
const napi_value* argv,
napi_value* result)
NAPI_EXTERN napi_status napi_call_function(napi_env env,
napi_value recv,
napi_value func,
size_t argc,
const napi_value* argv,
napi_value* result);
```

* `[in] env`: The environment that the API is invoked under.
Expand Down
1 change: 1 addition & 0 deletions n-api/napi_create_date.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- YAML
added: v11.11.0
napiVersion: 5
-->

```C
Expand Down
2 changes: 1 addition & 1 deletion n-api/napi_create_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ napiVersion: 1
```C
NAPI_EXTERN napi_status napi_create_reference(napi_env env,
napi_value value,
int initial_refcount,
uint32_t initial_refcount,
napi_ref* result);
```

Expand Down
1 change: 1 addition & 0 deletions n-api/napi_get_date_value.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- YAML
added: v11.11.0
napiVersion: 5
-->

```C
Expand Down
1 change: 1 addition & 0 deletions n-api/napi_is_date.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- YAML
added: v11.11.0
napiVersion: 5
-->

```C
Expand Down
14 changes: 7 additions & 7 deletions n-api/napi_make_callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ changes:
-->

```C
napi_status napi_make_callback(napi_env env,
napi_async_context async_context,
napi_value recv,
napi_value func,
int argc,
const napi_value* argv,
napi_value* result)
NAPI_EXTERN napi_status napi_make_callback(napi_env env,
napi_async_context async_context,
napi_value recv,
napi_value func,
size_t argc,
const napi_value* argv,
napi_value* result);
```

* `[in] env`: The environment that the API is invoked under.
Expand Down
2 changes: 1 addition & 1 deletion n-api/napi_reference_ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ napiVersion: 1
```C
NAPI_EXTERN napi_status napi_reference_ref(napi_env env,
napi_ref ref,
int* result);
uint32_t* result);
```

* `[in] env`: The environment that the API is invoked under.
Expand Down
2 changes: 1 addition & 1 deletion n-api/napi_reference_unref.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ napiVersion: 1
```C
NAPI_EXTERN napi_status napi_reference_unref(napi_env env,
napi_ref ref,
int* result);
uint32_t* result););
```

* `[in] env`: The environment that the API is invoked under.
Expand Down
4 changes: 2 additions & 2 deletions n-api/return_values.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ is provided which returns a `napi_extended_error_info` structure.
The format of the `napi_extended_error_info` structure is as follows:

<!-- YAML
added: v10.6.0
napiVersion: 4
added: v8.0.0
napiVersion: 1
-->

```C
Expand Down
14 changes: 11 additions & 3 deletions net/socket_buffersize.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ added: v0.3.8

* {integer}

`net.Socket` 具有该属性,`socket.write()` 工作时需要。它可以帮助用户快速启动和运行。计算机(处理速度)不能总是跟上 socket 的写入速度。网络连接也可能太慢。 Node.js 内部将维护一个写入 socket 的数据队列,并在可能的时候将数据发送出去。(内部实现是对 socket 的文件描述符进行轮询其是否是可写状态。)
此属性显示为写入而缓冲的字符数。
缓冲器中可能包含字符串,其编码后的长度是未知的。
因此,此数字仅是缓冲器中字节数的近似值。

使用内部缓冲的结果是可能造成内存的增长。此属性显示当前即将被写入的缓冲的字符数。(字符串的数目大致等于即将被写入的字节,但缓冲可能包含字符串,而字符串是惰性编码的,所以实际的字节数是不知道的。)
`net.Socket` 具有该属性时,则 `socket.write()` 始终可用。
这是为了帮助用户快速启动并运行。
计算机不能总是跟上写入套接字的数据量。
网络连接也可能太慢。
Node.js 将会在内部将写入套接字的数据进行排队,并在可能的情况下将其发送出去。

这种内部缓冲的结果是内存可能会增加。
对于遇到 `bufferSize` 太大或不断增加的用户,应尝试使用 [`socket.pause()`] [`socket.resume()`] 来对其程序中的数据流进行节流。

对处理大量或持续增长的 `bufferSize` 有经验的用户应该注意使用 [`socket.pause()`][] [`socket.resume()`][] 对他们程序中的数据流进行节流。
4 changes: 3 additions & 1 deletion net/socket_connect_options_connectlistener.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ changes:
对于这两种类型,可用 `options` 包括:

* `onread` {Object} 如果指定,则传入的数据会存储在单个 `buffer` 中,并在数据到达套接字时传给提供的 `callback`
这将会导致流式的功能不会提供任何数据,但 `'error'``'end'` `'close'` 等事件仍将会被正常触发,且 `pause()` `resume()` 等方法也将会按预期运行。
这将会导致流式的功能不会提供任何数据。
该套接字将会正常触发 `'error'``'end'` `'close'` 之类的事件。
诸如 `pause()` `resume()` 之类的方法也将会按预期运行。
* `buffer` {Buffer|Uint8Array|Function} 用于存储传入数据的可复用的内存块、或返回此类数据的函数。
* `callback` {Function} 为每个传入的数据块调用此函数。有两个参数传给它:写入 `buffer` 的字节数和对 `buffer` 的引用。从此函数返回 `false` 可以隐式地 `pause()` 套接字。该函数将会在全局的上下文中执行。

Expand Down
2 changes: 1 addition & 1 deletion perf_hooks/measuring_the_duration_of_async_operations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

The following example uses the [Async Hooks][] and Performance APIs to measure
the actual duration of a Timeout operation (including the amount of time it
the actual duration of a Timeout operation (including the amount of time it took
to execute the callback).

```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ added: v0.5.9
如果 Node.js 是使用 IPC 通道衍生的,则可以使用 `process.send()` 方法将消息发送到父进程。
消息将会作为父进程的 [`ChildProcess`] 对象上的 [`'message'`] 事件被接收。

如果 Node.js 不是通过 IPC 通道衍生的,则 `process.send()` 将会是 `undefined`
如果 Node.js 不是通过 IPC 通道衍生的,则 `process.send` 将会是 `undefined`

消息会进行序列化和解析。
生成的消息可能与最初发送的消息不同。
Expand Down
18 changes: 10 additions & 8 deletions repl/global_uncaught_exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@ changes:
repl is used as standalone program.
-->

REPL使用 [`domain`] 模块来捕获会话期间的所有未捕获异常
REPL 使用 [`domain`] 模块来捕获该 REPL 会话的所有未捕获的异常

在REPL中使用 [`domain`] 模块有如下副作用
REPL 中对 [`domain`] 模块的这种使用具有以下的副作用

* 如果将 `repl` 用作独立程序,则未捕获的异常仅触发 [`'uncaughtException'`] 事件。
如果 `repl` 包含在另一个应用程序的任何位置,则为此事件添加监听器将会抛出 [`ERR_INVALID_REPL_INPUT`] 异常。
* 如果尝试使用 [`process.setUncaughtExceptionCaptureCallback()`] 将产生一个 [`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`] 错误。
* 未捕获的异常仅在独立的 REPL 中触发 [`'uncaughtException'`] 事件。
在另一个 Node.js 程序的 REPL 中添加此事件的监听器会抛出 [`ERR_INVALID_REPL_INPUT`]

* 尝试使用 [`process.setUncaughtExceptionCaptureCallback()`] 会抛出 [`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`] 错误。

作为独立程序:

```js
process.on('uncaughtException', () => console.log('未捕获的异常'));
throw new Error('foobar');
// 打印:未捕获的异常
// 未捕获的异常
```

当在其他应用程序中使用时
当在另一个应用程序中使用时

```js
process.on('uncaughtException', () => console.log('未捕获的异常'));
// 抛出 TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL
// TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException`
// cannot be used in the REPL
throw new Error('foobar');
// 抛出:
Expand Down
4 changes: 4 additions & 0 deletions stream/api_for_stream_implementers.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ class MyWritable extends Writable {
流的实现代码应永远不要调用旨在供消费者使用的公共方法(详见[用于消费流的API][API for Stream Consumers])。
这样做可能会导致消费流的应用程序代码产生不利的副作用。

避免重写诸如 `write()``end()``cork()``uncork()``read()` `destroy()` 之类的公共方法,或通过 `.emit()` 触发诸如 `'error'``'data'``'end'``'finish'` `'close'` 之类的内部事件。
这样做会破坏当前和未来的流的不变量,从而导致与其他流、流的实用工具、以及用户期望的行为和/或兼容性问题。


2 changes: 2 additions & 0 deletions stream/readable_read_size.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ added: v0.9.4

如果没有指定 `size` 参数,则返回内部缓冲中的所有数据。

`size` 参数必须小于或等于 1 GB。

`readable.read()` 应该只对处于暂停模式的可读流调用。
在流动模式中,`readable.read()` 会自动调用直到内部缓冲的数据完全耗尽。

Expand Down
5 changes: 5 additions & 0 deletions url/url_parse_urlstring_parsequerystring_slashesdenotehost.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<!-- YAML
added: v0.1.25
changes:
- version: v11.14.0
pr-url: https://github.com/nodejs/node/pull/26941
description: The `pathname` property on the returned URL object is now `/`
when there is no path and the protocol scheme is `ws:` or
`wss:`.
- version: v11.0.0
pr-url: https://github.com/nodejs/node/pull/22715
description: The Legacy URL API is deprecated. Use the WHATWG URL API.
Expand Down
4 changes: 2 additions & 2 deletions util/class_util_textdecoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
added: v8.3.0
-->

An implementation of the [WHATWG Encoding Standard][] `TextDecoder` API.
[WHATWG 编码标准][WHATWG Encoding Standard] `TextDecoder` API 的实现。

```js
const decoder = new TextDecoder('shift_jis');
Expand All @@ -11,6 +11,6 @@ let buffer;
while (buffer = getNextChunkSomehow()) {
string += decoder.decode(buffer, { stream: true });
}
string += decoder.decode(); // end-of-stream
string += decoder.decode(); // 流的末尾。
```

8 changes: 4 additions & 4 deletions util/class_util_textencoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ changes:
description: The class is now available on the global object.
-->

An implementation of the [WHATWG Encoding Standard][] `TextEncoder` API. All
instances of `TextEncoder` only support UTF-8 encoding.
[WHATWG 编码标准][WHATWG Encoding Standard] `TextEncoder` API 的实现。
`TextEncoder` 的所有实例仅支持 UTF-8 编码。

```js
const encoder = new TextEncoder();
const uint8array = encoder.encode('this is some data');
const uint8array = encoder.encode('这是一些数据');
```

The `TextEncoder` class is also available on the global object.
`TextEncoder` 类在全局对象上也可用。

Loading

0 comments on commit 95dcb8b

Please sign in to comment.