Skip to content

Commit

Permalink
feat: 14.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
h7lin committed Sep 30, 2020
1 parent 0e01c4b commit 3e71cd2
Show file tree
Hide file tree
Showing 94 changed files with 715 additions and 380 deletions.
4 changes: 2 additions & 2 deletions child_process/subprocess_signalcode.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

* {integer}
* {string|null}

The `subprocess.signalCode` property indicates the signal number received by
The `subprocess.signalCode` property indicates the signal received by
the child process if any, else `null`.

2 changes: 1 addition & 1 deletion crypto/class_hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const fs = require('fs');
const hash = crypto.createHash('sha256');
const input = fs.createReadStream('要创建哈希摘要的数据.txt');
input.pipe(hash).pipe(process.stdout);
input.pipe(hash).setEncoding('hex').pipe(process.stdout);
```

示例,使用 [`hash.update()`] [`hash.digest()`] 方法:
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto_createsecretkey_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
added: v11.6.0
-->

* `key` {Buffer}
* `key` {Buffer | TypedArray | DataView}
* Returns: {KeyObject}

Creates and returns a new key object containing a secret key for symmetric
Expand Down
2 changes: 1 addition & 1 deletion errors/err_console_writable_stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
`Console` was instantiated without `stdout` stream, or `Console` has a
non-writable `stdout` or `stderr` stream.

<a id="ERR_CONTEXT_NOT_INITIALIZED"></a>
<a id="ERR_CONSTRUCT_CALL_INVALID"></a>
2 changes: 1 addition & 1 deletion errors/err_construct_call_invalid.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ added: v12.5.0

A class constructor was called that is not callable.

<a id="ERR_CPU_USAGE"></a>
<a id="ERR_CONSTRUCT_CALL_REQUIRED"></a>
2 changes: 1 addition & 1 deletion errors/err_construct_call_required.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

A constructor for a class was called without `new`.

<a id="ERR_CONSTRUCT_CALL_INVALID"></a>
<a id="ERR_CONTEXT_NOT_INITIALIZED"></a>
2 changes: 1 addition & 1 deletion errors/err_context_not_initialized.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ when an error occurs (and is caught) during the creation of the
context, for example, when the allocation fails or the maximum call stack
size is reached when the context is created.

<a id="ERR_CONSTRUCT_CALL_REQUIRED"></a>
<a id="ERR_CPU_USAGE"></a>
2 changes: 1 addition & 1 deletion errors/err_fs_invalid_symlink_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
An invalid symlink type was passed to the [`fs.symlink()`][] or
[`fs.symlinkSync()`][] methods.

<a id="ERR_HTTP_REQUEST_TIMEOUT"></a>
<a id="ERR_HTTP_HEADERS_SENT"></a>
2 changes: 1 addition & 1 deletion errors/err_http2_goaway_session.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
New HTTP/2 Streams may not be opened after the `Http2Session` has received a
`GOAWAY` frame from the connected peer.

<a id="ERR_HTTP2_HEADERS_AFTER_RESPOND"></a>
<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
2 changes: 1 addition & 1 deletion errors/err_http2_headers_sent.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

An attempt was made to send multiple response headers.

<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
<a id="ERR_HTTP2_INFO_STATUS_NOT_ALLOWED"></a>
2 changes: 1 addition & 1 deletion errors/err_http2_unsupported_protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
`http2.connect()` was passed a URL that uses any protocol other than `http:` or
`https:`.

<a id="ERR_INTERNAL_ASSERTION"></a>
<a id="ERR_INCOMPATIBLE_OPTION_PAIR"></a>
2 changes: 1 addition & 1 deletion errors/err_http_invalid_char.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ removed: v10.0.0

HTTP 响应的状态信息中存在非法字符(原因短语)。

<a id="ERR_INDEX_OUT_OF_RANGE"></a>
<a id="ERR_HTTP_REQUEST_TIMEOUT"></a>
2 changes: 1 addition & 1 deletion errors/err_http_request_timeout.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

The client has not sent the entire request within the allowed time.

<a id="ERR_HTTP_HEADERS_SENT"></a>
<a id="ERR_INDEX_OUT_OF_RANGE"></a>
2 changes: 1 addition & 1 deletion errors/err_inspector_not_worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
An API was called on the main thread that can only be used from
the worker thread.

<a id="ERR_INVALID_ADDRESS_FAMILY"></a>
<a id="ERR_INTERNAL_ASSERTION"></a>
2 changes: 1 addition & 1 deletion errors/err_internal_assertion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
There was a bug in Node.js or incorrect usage of Node.js internals.
To fix the error, open an issue at <https://github.com/nodejs/node/issues>.

<a id="ERR_INCOMPATIBLE_OPTION_PAIR"></a>
<a id="ERR_INVALID_ADDRESS_FAMILY"></a>
2 changes: 1 addition & 1 deletion errors/err_invalid_package_config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

An invalid `package.json` file failed parsing.
An invalid [`package.json`][] file was found which failed parsing.

<a id="ERR_INVALID_PACKAGE_TARGET"></a>
4 changes: 2 additions & 2 deletions errors/err_invalid_package_target.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

The `package.json` [exports][] field contains an invalid target mapping value
for the attempted module resolution.
The `package.json` [`"exports"`][] field contains an invalid target mapping
value for the attempted module resolution.

<a id="ERR_INVALID_PERFORMANCE_MARK"></a>
2 changes: 1 addition & 1 deletion errors/err_missing_args.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ strict compliance with the API specification (which in some cases may accept
`func(undefined)` and `func()` are treated identically, and the
[`ERR_INVALID_ARG_TYPE`][] error code may be used instead.

<a id="ERR_MISSING_OPTION"></a>
<a id="ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST"></a>
2 changes: 1 addition & 1 deletion errors/err_missing_message_port_in_transfer_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ An object that needs to be explicitly listed in the `transferList` argument
is in the object passed to a `postMessage()` call, but is not provided
in the `transferList` for that call. Usually, this is a `MessagePort`.

<a id="ERR_MISSING_PASSPHRASE"></a>
<a id="ERR_MISSING_OPTION"></a>
2 changes: 1 addition & 1 deletion errors/err_missing_option.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
For APIs that accept options objects, some options might be mandatory. This code
is thrown if a required option is missing.

<a id="ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST"></a>
<a id="ERR_MISSING_PASSPHRASE"></a>
2 changes: 1 addition & 1 deletion errors/err_package_import_not_defined.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

The `package.json` ["imports" field][] does not define the given internal
The `package.json` [`"imports"`][] field does not define the given internal
package specifier mapping.

<a id="ERR_PACKAGE_PATH_NOT_EXPORTED"></a>
2 changes: 1 addition & 1 deletion errors/err_package_path_not_exported.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

The `package.json` [exports][] field does not export the requested subpath.
The `package.json` [`"exports"`][] field does not export the requested subpath.
Because exports are encapsulated, private internal modules that are not exported
cannot be imported through the package resolution, unless using an absolute URL.

Expand Down
2 changes: 1 addition & 1 deletion errors/err_sri_parse.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ A string was provided for a Subresource Integrity check, but was unable to be
parsed. Check the format of integrity attributes by looking at the
[Subresource Integrity specification][].

<a id="ERR_STREAM_CANNOT_PIPE"></a>
<a id="ERR_STREAM_ALREADY_FINISHED"></a>
2 changes: 1 addition & 1 deletion errors/err_stream_already_finished.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
A stream method was called that cannot complete because the stream was
finished.

<a id="ERR_STREAM_NULL_VALUES"></a>
<a id="ERR_STREAM_CANNOT_PIPE"></a>
2 changes: 1 addition & 1 deletion errors/err_stream_destroyed.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
A stream method was called that cannot complete because the stream was
destroyed using `stream.destroy()`.

<a id="ERR_STREAM_ALREADY_FINISHED"></a>
<a id="ERR_STREAM_NULL_VALUES"></a>
2 changes: 1 addition & 1 deletion errors/err_tls_invalid_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ added: v13.3.0

The context must be a `SecureContext`.

<a id="ERR_TLS_INVALID_STATE"></a>
<a id="ERR_TLS_INVALID_PROTOCOL_METHOD"></a>
2 changes: 1 addition & 1 deletion errors/err_tls_invalid_protocol_version.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Valid TLS protocol versions are `'TLSv1'`, `'TLSv1.1'`, or `'TLSv1.2'`.

<a id="ERR_TLS_PROTOCOL_VERSION_CONFLICT"></a>
<a id="ERR_TLS_INVALID_STATE"></a>
6 changes: 4 additions & 2 deletions errors/err_tls_invalid_state.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<!-- YAML
added: v13.10.0
added:
- v13.10.0
- v12.17.0
-->

The TLS socket must be connected and securily established. Ensure the 'secure'
event is emitted before continuing.

<a id="ERR_TLS_INVALID_PROTOCOL_METHOD"></a>
<a id="ERR_TLS_PROTOCOL_VERSION_CONFLICT"></a>
2 changes: 1 addition & 1 deletion errors/err_tls_protocol_version_conflict.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Attempting to set a TLS protocol `minVersion` or `maxVersion` conflicts with an
attempt to set the `secureProtocol` explicitly. Use one mechanism or the other.

<a id="ERR_TLS_RENEGOTIATION_DISABLED"></a>
<a id="ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED"></a>
2 changes: 1 addition & 1 deletion errors/err_tls_psk_set_identiy_hint_failed.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Failed to set PSK identity hint. Hint may be too long.

<a id="ERR_TRACE_EVENTS_CATEGORY_REQUIRED"></a>
<a id="ERR_TLS_RENEGOTIATION_DISABLED"></a>
2 changes: 1 addition & 1 deletion errors/err_tls_sni_from_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
An attempt was made to issue Server Name Indication from a TLS server-side
socket, which is only valid from a client.

<a id="ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED"></a>
<a id="ERR_TRACE_EVENTS_CATEGORY_REQUIRED"></a>
2 changes: 1 addition & 1 deletion errors/err_unsupported_dir_import.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

`import` a directory URL is unsupported. Instead,
[self-reference a package using its name][] and [define a custom subpath][] in
the `"exports"` field of the `package.json` file.
the [`"exports"`][] field of the [`package.json`][] file.

<!-- eslint-skip -->
```js
Expand Down
1 change: 1 addition & 0 deletions errors/err_zlib_binding_closed.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ closed.






2 changes: 1 addition & 1 deletion esm/builtin_modules.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Builtin modules will provide named exports of their public API. A
[Core modules][] will provide named exports of their public API. A
default export is also provided which is the value of the CommonJS exports.
The default export can be used for, among other things, modifying the named
exports. Named exports of builtin modules are updated only by calling
Expand Down
82 changes: 82 additions & 0 deletions esm/commonjs_namespaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

CommonJS modules consist of a `module.exports` object which can be of any type.

When importing a CommonJS module, it can be reliably imported using the ES
module default import or its corresponding sugar syntax:

<!-- eslint-disable no-duplicate-imports -->
```js
import { default as cjs } from 'cjs';
// The following import statement is "syntax sugar" (equivalent but sweeter)
// for `{ default as cjsSugar }` in the above import statement:
import cjsSugar from 'cjs';
console.log(cjs);
console.log(cjs === cjsSugar);
// Prints:
// <module.exports>
// true
```

The ECMAScript Module Namespace representation of a CommonJS module will always
be a namespace with a `default` export key pointing to the CommonJS
`module.exports` value.

This Module Namespace Exotic Object can be directly observed either when using
`import * as m from 'cjs'` or a dynamic import:

<!-- eslint-skip -->
```js
import * as m from 'cjs';
console.log(m);
console.log(m === await import('cjs'));
// Prints:
// [Module] { default: <module.exports> }
// true
```

For better compatibility with existing usage in the JS ecosystem, Node.js will
in addition attempt to determine the CommonJS named exports of every imported
CommonJS module to provide them as separate ES module exports using a static
analysis process.

For example, a CommonJS module written:

```js
// cjs.cjs
exports.name = 'exported';
```

will support named imports in ES modules:

<!-- eslint-disable no-duplicate-imports -->
```js
import { name } from './cjs.cjs';
console.log(name);
// Prints: 'exported'
import cjs from './cjs.cjs';
console.log(cjs);
// Prints: { name: 'exported' }
import * as m from './cjs.cjs';
console.log(m);
// Prints: [Module] { default: { name: 'exported' }, name: 'exported' }
```

As can be seen from the last example of the Module Namespace Exotic Object being
logged, the `name` export is copied off of the `module.exports` object and set
directly on the ES module namespace when the module is imported.

Live binding updates or new exports added to `module.exports` are not detected
for these named exports.

The detection of named exports is based on common syntax patterns but will not
always correctly detect named exports, in these cases using the default
import form described above can be a better option.

Named exports detection covers many common export patterns, reexport patterns
and build tool and transpiler outputs. See [cjs-module-lexer][] for the exact
semantics implemented.

1 change: 1 addition & 0 deletions esm/customizing_esm_specifier_resolution_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $ node --experimental-specifier-resolution=node index
success!
```

<!-- Note: The cjs-module-lexer link should be kept in-sync with the deps version -->



Expand Down
49 changes: 22 additions & 27 deletions esm/enabling.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@

<!-- type=misc -->

Experimental support for ECMAScript modules is enabled by default.
Node.js will treat the following as ES modules when passed to `node` as the
initial input, or when referenced by `import` statements within ES module code:

* Files ending in `.mjs`.

* Files ending in `.js` when the nearest parent `package.json` file contains a
top-level field `"type"` with a value of `"module"`.

* Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`,
with the flag `--input-type=module`.

Node.js will treat as CommonJS all other forms of input, such as `.js` files
where the nearest parent `package.json` file contains no top-level `"type"`
field, or string input without the flag `--input-type`. This behavior is to
preserve backward compatibility. However, now that Node.js supports both
CommonJS and ES modules, it is best to be explicit whenever possible. Node.js
will treat the following as CommonJS when passed to `node` as the initial input,
or when referenced by `import` statements within ES module code:

* Files ending in `.cjs`.

* Files ending in `.js` when the nearest parent `package.json` file contains a
top-level field `"type"` with a value of `"commonjs"`.

* Strings passed in as an argument to `--eval` or `--print`, or piped to `node`
via `STDIN`, with the flag `--input-type=commonjs`.
Node.js treats JavaScript code as CommonJS modules by default.
Authors can tell Node.js to treat JavaScript code as ECMAScript modules
via the `.mjs` file extension, the `package.json` [`"type"`][] field, or the
`--input-type` flag. See
[Modules: Packages](packages.html#packages_determining_module_system) for more
details.

<!-- Anchors to make sure old links find a target -->
<i id="esm_package_entry_points"></i>
<i id="esm_main_entry_point_export"></i>
<i id="esm_subpath_exports"></i>
<i id="esm_package_exports_fallbacks"></i>
<i id="esm_exports_sugar"></i>
<i id="esm_conditional_exports"></i>
<i id="esm_nested_conditions"></i>
<i id="esm_self_referencing_a_package_using_its_name"></i>
<i id="esm_internal_package_imports"></i>
<i id="esm_dual_commonjs_es_module_packages"></i>
<i id="esm_dual_package_hazard"></i>
<i id="esm_writing_dual_packages_while_avoiding_or_minimizing_hazards"></i>
<i id="esm_approach_1_use_an_es_module_wrapper"></i>
<i id="esm_approach_2_isolate_state"></i>

25 changes: 0 additions & 25 deletions esm/exports_sugar.md

This file was deleted.

Loading

0 comments on commit 3e71cd2

Please sign in to comment.