diff --git a/assert/class_assert_assertionerror.md b/assert/class_assert_assertionerror.md index d8af2d43..54498091 100644 --- a/assert/class_assert_assertionerror.md +++ b/assert/class_assert_assertionerror.md @@ -1,4 +1,6 @@ -`Error` 的子类,表明断言的失败。 -`assert` 模块抛出的所有错误都是 `AssertionError` 类的实例。 +* 继承自: {errors.Error} + +表明断言的失败。 +`assert` 模块抛出的所有错误都将是 `AssertionError` 类的实例。 diff --git a/child_process/class_childprocess.md b/child_process/class_childprocess.md index 3dbd3fee..db661166 100644 --- a/child_process/class_childprocess.md +++ b/child_process/class_childprocess.md @@ -2,7 +2,10 @@ added: v2.2.0 --> -`ChildProcess` 类的实例都是 [`EventEmitter`],表示衍生的子进程。 +* 继承自: {EventEmitter} -`ChildProcess` 的实例不是直接创建的,而是使用 [`child_process.spawn()`]、[`child_process.exec()`]、[`child_process.execFile()`] 或 [`child_process.fork()`] 方法来创建 `ChildProcess` 的实例。 +`ChildProcess` 的实例代表衍生的子进程。 + +`ChildProcess` 的实例不是直接创建的。 +而是,使用 [`child_process.spawn()`]、[`child_process.exec()`]、[`child_process.execFile()`] 或 [`child_process.fork()`] 方法来创建 `ChildProcess` 的实例。 diff --git a/cli/completion_bash.md b/cli/completion_bash.md index b33280ae..97aa00fd 100644 --- a/cli/completion_bash.md +++ b/cli/completion_bash.md @@ -3,6 +3,7 @@ added: v10.12.0 --> Print source-able bash completion script for Node.js. + ```console $ node --completion-bash > node_bash_completion $ source node_bash_completion diff --git a/cli/frozen_intrinsics.md b/cli/frozen_intrinsics.md index accf6d05..5b8677e1 100644 --- a/cli/frozen_intrinsics.md +++ b/cli/frozen_intrinsics.md @@ -10,3 +10,6 @@ Support is currently only provided for the root context and no guarantees are currently provided that `global.Array` is indeed the default intrinsic reference. Code may break under this flag. +`--require` runs prior to freezing intrinsics in order to allow polyfills to +be added. + diff --git a/cli/node_options_options.md b/cli/node_options_options.md index 30020ec1..12569081 100644 --- a/cli/node_options_options.md +++ b/cli/node_options_options.md @@ -102,6 +102,7 @@ Node.js options that are allowed are: V8 options that are allowed are: - `--abort-on-uncaught-exception` +- `--interpreted-frames-native-stack` - `--max-old-space-size` - `--perf-basic-prof-only-functions` - `--perf-basic-prof` diff --git a/cluster/class_worker.md b/cluster/class_worker.md index 9151eed7..b8dfeff3 100644 --- a/cluster/class_worker.md +++ b/cluster/class_worker.md @@ -2,7 +2,9 @@ added: v0.7.0 --> -`Worker` 对象包含了关于工作进程的所有公共信息和方法。 -在主进程里,可以使用 `cluster.workers` 来获取它。 -在工作进程里,可以使用 `cluster.worker` 来获取它。 +* 继承自: {EventEmitter} + +`Worker` 对象包含了关于工作进程的所有的公共的信息和方法。 +在主进程中,可以使用 `cluster.workers` 来获取它。 +在工作进程中,可以使用 `cluster.worker` 来获取它。 diff --git a/crypto/class_cipher.md b/crypto/class_cipher.md index 173b5e81..15ce1899 100644 --- a/crypto/class_cipher.md +++ b/crypto/class_cipher.md @@ -2,27 +2,29 @@ added: v0.1.94 --> +* 继承自: {stream.Transform} + `Cipher` 类的实例用于加密数据。 -这个类可以用在以下两种方法中的一种: +该类可以通过以下两种方式之一使用: -- 作为[流][stream],既可读又可写,未加密数据的编写是为了在可读的方面生成加密的数据。 -- 使用 [`cipher.update()`][] 和 [`cipher.final()`][] 方法产生加密的数据。 +- 作为可读写的[流][stream],其中写入未加密的数据以在可读侧生成加密的数据。 +- 使用 [`cipher.update()`] 和 [`cipher.final()`] 方法生成加密的数据。 -[`crypto.createCipher()`][] 或 [`crypto.createCipheriv()`][] 方法用于创建 `Cipher` 实例。 -`Cipher` 对象不能直接使用 `new` 关键字创建。 +[`crypto.createCipher()`] 或 [`crypto.createCipheriv()`] 方法用于创建 `Cipher` 实例。 +不能使用 `new` 关键字直接地创建 `Cipher` 对象。 -示例,使用` Cipher` 对象作为流: +示例,使用 `Cipher` 对象作为流: ```js const crypto = require('crypto'); const algorithm = 'aes-192-cbc'; -const password = 'Password used to generate key'; +const password = '用于生成密钥的密码'; // 密钥长度取决于算法。 -// 在这种情况下,对于 aes192,它是 24 字节(192 位)。 +// 在此示例中,对于 aes192,它是 24 个字节(192 位)。 // 改为使用异步的 `crypto.scrypt()`。 const key = crypto.scryptSync(password, 'salt', 24); -// 使用 `crypto.randomBytes()` 生成随机 iv 而不是此处显示的静态 iv。 +// 使用 `crypto.randomBytes()` 生成随机的 iv 而不是此处显示的静态的 iv。 const iv = Buffer.alloc(16, 0); // 初始化向量。 const cipher = crypto.createCipheriv(algorithm, key, iv); @@ -36,51 +38,51 @@ cipher.on('readable', () => { }); cipher.on('end', () => { console.log(encrypted); - // 打印: e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa + // 打印: 3accbdcaf5574941a9c879da51711ffc2a5a017757fa736eacc579b9088ba712 }); -cipher.write('some clear text data'); +cipher.write('要加密的数据'); cipher.end(); ``` -示例,使用 `Cipher` 和管道流: +示例,使用 `Cipher` 和管道流: ```js const crypto = require('crypto'); const fs = require('fs'); const algorithm = 'aes-192-cbc'; -const password = 'Password used to generate key'; +const password = '用于生成密钥的密码'; // 改为使用异步的 `crypto.scrypt()`。 const key = crypto.scryptSync(password, 'salt', 24); -// 使用 `crypto.randomBytes()` 生成随机 iv 而不是此处显示的静态 iv。 +// 使用 `crypto.randomBytes()` 生成随机的 iv 而不是此处显示的静态的 iv。 const iv = Buffer.alloc(16, 0); // 初始化向量。 const cipher = crypto.createCipheriv(algorithm, key, iv); -const input = fs.createReadStream('test.js'); -const output = fs.createWriteStream('test.enc'); +const input = fs.createReadStream('要加密的数据.txt'); +const output = fs.createWriteStream('加密后的数据.enc'); input.pipe(cipher).pipe(output); ``` -示例,使用 [`cipher.update()`][] 和 [`cipher.final()`][] 方法: +示例,使用 [`cipher.update()`] 和 [`cipher.final()`] 方法: ```js const crypto = require('crypto'); const algorithm = 'aes-192-cbc'; -const password = 'Password used to generate key'; +const password = '用于生成密钥的密码'; // 改为使用异步的 `crypto.scrypt()`。 const key = crypto.scryptSync(password, 'salt', 24); -// 使用 `crypto.randomBytes()` 生成随机 iv 而不是此处显示的静态 iv。 +// 使用 `crypto.randomBytes()` 生成随机的 iv 而不是此处显示的静态的 iv。 const iv = Buffer.alloc(16, 0); // 初始化向量。 const cipher = crypto.createCipheriv(algorithm, key, iv); -let encrypted = cipher.update('some clear text data', 'utf8', 'hex'); +let encrypted = cipher.update('要加密的数据', 'utf8', 'hex'); encrypted += cipher.final('hex'); console.log(encrypted); -// 打印: e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa +// 打印: 3accbdcaf5574941a9c879da51711ffc2a5a017757fa736eacc579b9088ba712 ``` diff --git a/crypto/class_decipher.md b/crypto/class_decipher.md index 2e48e4eb..caf4bdee 100644 --- a/crypto/class_decipher.md +++ b/crypto/class_decipher.md @@ -2,13 +2,16 @@ added: v0.1.94 --> -`Decipher` 类的实例用于解密数据。这个类可以用在以下两种方法中的一种: +* 继承自: {stream.Transform} -- 作为[流][stream],既可读又可写,加密数据的编写是为了在可读的方面生成未加密的数据。 -- 使用 [`decipher.update()`][] 和 [`decipher.final()`][] 方法产生未加密的数据。 +`Decipher` 类的实例用于解密数据。 +该类可以通过以下两种方式之一使用: -[`crypto.createDecipher()`][] 或 [`crypto.createDecipheriv()`][] 的方法用于创建`Decipher`实例。 -`Decipher` 对象不能直接使用 `new` 关键字创建。 +- 作为可读写的[流][stream],其中写入加密的数据以在可读侧生成未加密的数据。 +- 使用 [`decipher.update()`] 和 [`decipher.final()`] 方法生成未加密的数据。 + +[`crypto.createDecipher()`] 或 [`crypto.createDecipheriv()`] 方法用于创建 `Decipher` 实例。 +不能使用 `new` 关键字直接地创建 `Decipher` 对象。 示例,使用 `Decipher` 对象作为流: @@ -16,9 +19,9 @@ added: v0.1.94 const crypto = require('crypto'); const algorithm = 'aes-192-cbc'; -const password = 'Password used to generate key'; +const password = '用于生成密钥的密码'; // 密钥长度取决于算法。 -// 在这种情况下,对于 aes192,它是 24 字节(192 位)。 +// 在此示例中,对于 aes192,它是 24 个字节(192 位)。 // 改为使用异步的 `crypto.scrypt()`。 const key = crypto.scryptSync(password, 'salt', 24); // IV 通常与密文一起传递。 @@ -34,12 +37,12 @@ decipher.on('readable', () => { }); decipher.on('end', () => { console.log(decrypted); - // 打印: some clear text data + // 打印: 要加密的数据 }); -// 使用相同的算法,密钥和 iv 加密。 +// 使用相同的算法、密钥和 iv 进行加密。 const encrypted = - 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; + '3accbdcaf5574941a9c879da51711ffc2a5a017757fa736eacc579b9088ba712'; decipher.write(encrypted, 'hex'); decipher.end(); ``` @@ -51,7 +54,7 @@ const crypto = require('crypto'); const fs = require('fs'); const algorithm = 'aes-192-cbc'; -const password = 'Password used to generate key'; +const password = '用于生成密钥的密码'; // 改为使用异步的 `crypto.scrypt()`。 const key = crypto.scryptSync(password, 'salt', 24); // IV 通常与密文一起传递。 @@ -59,19 +62,19 @@ const iv = Buffer.alloc(16, 0); // 初始化向量。 const decipher = crypto.createDecipheriv(algorithm, key, iv); -const input = fs.createReadStream('test.enc'); -const output = fs.createWriteStream('test.js'); +const input = fs.createReadStream('要解密的数据.enc'); +const output = fs.createWriteStream('解密后的数据.js'); input.pipe(decipher).pipe(output); ``` -示例,使用 [`decipher.update()`][] 和 [`decipher.final()`][] 方法: +示例,使用 [`decipher.update()`] 和 [`decipher.final()`] 方法: ```js const crypto = require('crypto'); const algorithm = 'aes-192-cbc'; -const password = 'Password used to generate key'; +const password = '用于生成密钥的密码'; // 改为使用异步的 `crypto.scrypt()`。 const key = crypto.scryptSync(password, 'salt', 24); // IV 通常与密文一起传递。 @@ -79,12 +82,12 @@ const iv = Buffer.alloc(16, 0); // 初始化向量。 const decipher = crypto.createDecipheriv(algorithm, key, iv); -// 使用相同的算法,密钥和 iv 加密。 +// 使用相同的算法、密钥和 iv 进行加密。 const encrypted = - 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; + '3accbdcaf5574941a9c879da51711ffc2a5a017757fa736eacc579b9088ba712'; let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); console.log(decrypted); -// 打印: some clear text data +// 打印: 要加密的数据 ``` diff --git a/crypto/class_diffiehellmangroup.md b/crypto/class_diffiehellmangroup.md index 8f36d99f..b3b9fa7c 100644 --- a/crypto/class_diffiehellmangroup.md +++ b/crypto/class_diffiehellmangroup.md @@ -11,6 +11,7 @@ const dh = crypto.createDiffieHellmanGroup(name); ``` `name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]: + ```console $ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h modp1 # 768 bits diff --git a/crypto/class_hash.md b/crypto/class_hash.md index 073202ab..422b5b14 100644 --- a/crypto/class_hash.md +++ b/crypto/class_hash.md @@ -1,13 +1,17 @@ -`Hash` 类是用于创建数据哈希值的工具类。它能用以下方法使用: -- 作为[流][stream],既可读又可写,数据被写入要在可读的方面生成一个计算散列摘要。 -- 使用 [`hash.update()`][] 和 [`hash.digest()`][] 方法产生计算后的哈希。 +* 继承自: {stream.Transform} -[`crypto.createHash()`][] 方法用于创建 `Hash` 实例。 -`Hash` 不能直接使用 `new` 关键字创建对象。 +`Hash` 类是一个实用工具,用于创建数据的哈希摘要。 +它可以通过以下两种方式之一使用: + +- 作为可读写的[流][stream],其中写入数据以在可读侧生成计算后的哈希摘要。 +- 使用 [`hash.update()`] 和 [`hash.digest()`] 方法生成计算后的哈希。 + +[`crypto.createHash()`] 方法用于创建 `Hash` 实例。 +不能使用 `new` 关键字直接地创建 `Hash` 对象。 示例,使用 `Hash` 对象作为流: @@ -21,11 +25,11 @@ hash.on('readable', () => { if (data) { console.log(data.toString('hex')); // 打印: - // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 + // 164345eba9bccbafb94b27b8299d49cc2d80627fc9995b03230965e6d8bcbf56 } }); -hash.write('some data to hash'); +hash.write('要创建哈希摘要的数据'); hash.end(); ``` @@ -36,19 +40,19 @@ const crypto = require('crypto'); const fs = require('fs'); const hash = crypto.createHash('sha256'); -const input = fs.createReadStream('test.js'); +const input = fs.createReadStream('要创建哈希摘要的数据.txt'); input.pipe(hash).pipe(process.stdout); ``` -示例,使用 [`hash.update()`][] 和 [`hash.digest()`][] 方法: +示例,使用 [`hash.update()`] 和 [`hash.digest()`] 方法: ```js const crypto = require('crypto'); const hash = crypto.createHash('sha256'); -hash.update('some data to hash'); +hash.update('要创建哈希摘要的数据'); console.log(hash.digest('hex')); // 打印: -// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 +// 164345eba9bccbafb94b27b8299d49cc2d80627fc9995b03230965e6d8bcbf56 ``` diff --git a/crypto/class_hmac.md b/crypto/class_hmac.md index 315ea382..852fb366 100644 --- a/crypto/class_hmac.md +++ b/crypto/class_hmac.md @@ -1,19 +1,24 @@ -`Hmac` 类是用于创建加密 Hmac 摘要的工具。它可以有两种用法: -- 作为[流][stream],它既可读又可写,数据被写入要在可读的方面生成一个经过计算的 HMAC 摘要。 -- 使 用[`hmac.update()`][] 和 [`hmac.digest()`][] 方法产生计算后的 HMAC 摘要。 +* 继承自: {stream.Transform} -[`crypto.createHmac()`][] 方法用来创建 `Hmac` 实例。 -`Hmac` 不能直接使用 `new` 关键字创建对象。 +`Hmac` 类是一个实用工具,用于创建加密的 HMAC 摘要。 +它可以通过以下两种方式之一使用: + + +- 作为可读写的[流][stream],其中写入数据以在可读侧生成计算后的 HMAC 摘要。 +- 使用 [`hmac.update()`] 和 [`hmac.digest()`] 方法生成计算后的 HMAC 摘要。 + +[`crypto.createHmac()`] 方法用于创建 `Hmac` 实例。 +不能使用 `new` 关键字直接地创建 `Hmac` 对象。 示例,使用 `Hmac` 对象作为流: ```js const crypto = require('crypto'); -const hmac = crypto.createHmac('sha256', 'a secret'); +const hmac = crypto.createHmac('sha256', '密钥'); hmac.on('readable', () => { // 哈希流只会生成一个元素。 @@ -21,11 +26,11 @@ hmac.on('readable', () => { if (data) { console.log(data.toString('hex')); // 打印: - // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e + // d0b5490ab4beb8e6545fe284f484d0d595e46086cb8e6ef2291af12ac684102f } }); -hmac.write('some data to hash'); +hmac.write('要创建哈希的数据'); hmac.end(); ``` @@ -34,21 +39,21 @@ hmac.end(); ```js const crypto = require('crypto'); const fs = require('fs'); -const hmac = crypto.createHmac('sha256', 'a secret'); +const hmac = crypto.createHmac('sha256', '密钥'); -const input = fs.createReadStream('test.js'); +const input = fs.createReadStream('要创建哈希的数据.txt'); input.pipe(hmac).pipe(process.stdout); ``` -示例,使用 [`hmac.update()`][] 和 [`hmac.digest()`][] 方法: +示例,使用 [`hmac.update()`] 和 [`hmac.digest()`] 方法: ```js const crypto = require('crypto'); -const hmac = crypto.createHmac('sha256', 'a secret'); +const hmac = crypto.createHmac('sha256', '密钥'); -hmac.update('some data to hash'); +hmac.update('要创建哈希的数据'); console.log(hmac.digest('hex')); // 打印: -// 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e +// d0b5490ab4beb8e6545fe284f484d0d595e46086cb8e6ef2291af12ac684102f ``` diff --git a/crypto/class_sign.md b/crypto/class_sign.md index 0bb9006f..08952469 100644 --- a/crypto/class_sign.md +++ b/crypto/class_sign.md @@ -2,15 +2,19 @@ added: v0.1.92 --> -`Sign` 类是生成签名的实用工具。它有两种使用方式: +* 继承自: {stream.Writable} -- 作为一个[可写流][stream],写入要签名的数据,并使用 [`sign.sign()`][] 方法生成并返回签名。 -- 使用 [`sign.update()`][] 和 [`sign.sign()`][] 方法生产签名。 +`Sign` 类是一个实用工具,用于生成签名。 +它可以通过以下两种方式之一使用: -[`crypto.createSign()`][] 方法用于创建 `Sign` 实例,参数为即将用来生成 hash 值的函数名。 -`Sign` 实例不能直接使用 `new` 关键字创建。 +- 作为可写的[流][stream],其中写入要签名的数据,并使用 [`sign.sign()`] 方法生成和返回签名。 +- 使用 [`sign.update()`] 和 [`sign.sign()`] 方法生成签名。 -示例,像使用流对象一样使用 `Sign` 和 [`Verify`] 对象: +[`crypto.createSign()`] 方法用于创建 `Sign` 实例。 +参数是要使用的哈希函数的字符串名称。 +不能使用 `new` 关键字直接地创建 `Sign` 对象。 + +示例,使用 `Sign` 和 [`Verify`] 对象作为流: ```js const crypto = require('crypto'); @@ -20,18 +24,18 @@ const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', { }); const sign = crypto.createSign('SHA256'); -sign.write('some data to sign'); +sign.write('要生成签名的数据'); sign.end(); const signature = sign.sign(privateKey, 'hex'); const verify = crypto.createVerify('SHA256'); -verify.write('some data to sign'); +verify.write('要生成签名的数据'); verify.end(); console.log(verify.verify(publicKey, signature)); // 打印 true 或 false。 ``` -示例,使用 [`sign.update()`][] 和 [`sign.sign()`][] 方法: +示例,使用 [`sign.update()`] 和 [`verify.update()`] 方法: ```js const crypto = require('crypto'); @@ -41,12 +45,12 @@ const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', { }); const sign = crypto.createSign('SHA256'); -sign.update('some data to sign'); +sign.update('要生成签名的数据'); sign.end(); const signature = sign.sign(privateKey); const verify = crypto.createVerify('SHA256'); -verify.update('some data to sign'); +verify.update('要生成签名的数据'); verify.end(); console.log(verify.verify(publicKey, signature)); // 打印: true diff --git a/crypto/class_verify.md b/crypto/class_verify.md index eef3be15..d5184e96 100644 --- a/crypto/class_verify.md +++ b/crypto/class_verify.md @@ -2,13 +2,16 @@ added: v0.1.92 --> -`Verify` 类是验证签名的工具。它可以两种方式使用: +* 继承自: {stream.Writable} -- 作为[可写流][stream],使用书面数据来验证提供的签名。 -- 使用 [`verify.update()`][] 和 [`verify.verify()`][] 的方法来验证签名。 +`Verify` 类是一个实用工具,用于验证签名。 +它可以通过以下两种方式之一使用: -[`crypto.createVerify()`][] 方法用于创建 `Verify` 实例。 -`Verify` 对象不能直接使用 `new` 关键字创建。 +- 作为可写的[流][stream],其中使用写入的数据来验证提供的签名。 +- 使用 [`verify.update()`] 和 [`verify.verify()`] 方法来验证签名。 + +[`crypto.createVerify()`] 方法用于创建 `Verify` 实例。 +不能使用 `new` 关键字直接地创建 `Verify` 对象。 有关示例,请参阅 [`Sign`]。 diff --git a/dgram/class_dgram_socket.md b/dgram/class_dgram_socket.md index a64f4054..d0f3c0f0 100644 --- a/dgram/class_dgram_socket.md +++ b/dgram/class_dgram_socket.md @@ -2,8 +2,10 @@ added: v0.1.99 --> -`dgram.Socket` 对象是一个封装了数据包函数功能的 [`EventEmitter`]。 +* 继承自: {EventEmitter} -`dgram.Socket` 实例是由 [`dgram.createSocket()`] 创建的。 -创建 `dgram.Socket` 实例不需要使用 `new` 关键字。 +封装了数据报的功能。 + +使用 [`dgram.createSocket()`] 创建 `dgram.Socket` 的新实例。 +不能使用 `new` 关键字创建 `dgram.Socket` 实例。 diff --git a/dgram/example_ipv4_outgoing_multicast_interface.md b/dgram/example_ipv4_outgoing_multicast_interface.md index 8c3f2b2d..158bfd3d 100644 --- a/dgram/example_ipv4_outgoing_multicast_interface.md +++ b/dgram/example_ipv4_outgoing_multicast_interface.md @@ -1,4 +1,5 @@ All systems use an IP of the host on the desired physical interface: + ```js const socket = dgram.createSocket('udp4'); diff --git a/domain/class_domain.md b/domain/class_domain.md index 0b3fea4c..be517535 100644 --- a/domain/class_domain.md +++ b/domain/class_domain.md @@ -1,7 +1,8 @@ +* Extends: {EventEmitter} + The `Domain` class encapsulates the functionality of routing errors and uncaught exceptions to the active `Domain` object. -`Domain` is a child class of [`EventEmitter`][]. To handle the errors that it -catches, listen to its `'error'` event. +To handle the errors that it catches, listen to its `'error'` event. diff --git a/domain/domains_and_promises.md b/domain/domains_and_promises.md index c116de88..70cc4f74 100644 --- a/domain/domains_and_promises.md +++ b/domain/domains_and_promises.md @@ -47,4 +47,3 @@ Promises. In other words, no `'error'` event will be emitted for unhandled - diff --git a/errors/class_assertionerror.md b/errors/class_assertionerror.md index 1d53d5b7..0089b295 100644 --- a/errors/class_assertionerror.md +++ b/errors/class_assertionerror.md @@ -1,4 +1,7 @@ -`Error` 的子类,表示断言失败。 + +* 继承自: {errors.Error} + +表明断言的失败。 详见 [`assert.AssertionError` 类][`Class: assert.AssertionError`]。 diff --git a/errors/class_error.md b/errors/class_error.md index 3912278f..7d60f1ee 100644 --- a/errors/class_error.md +++ b/errors/class_error.md @@ -1,9 +1,8 @@ -一个通用的 JavaScript `Error` 对象,它不表示错误发生的具体情况。 -`Error` 对象会捕捉一个“堆栈跟踪”,详细说明被实例化的 `Error` 对象在代码中的位置,并可能提供错误的文字描述。 +通用的 JavaScript {Error} 对象,不表明错误发生的具体情况。 +`Error` 对象会捕获堆栈跟踪,详细说明实例化 `Error` 的代码点,并可能提供错误的文本描述。 - -所有由 Node.js 产生的错误,包括所有系统的和 JavaScript 的错误都实例化自或继承自 `Error` 类。 +Node.js 产生的所有错误(包括所有的系统错误和 JavaScript 错误),都实例化自或继承自 `Error` 类。 diff --git a/errors/class_rangeerror.md b/errors/class_rangeerror.md index 90b423eb..cae22bcb 100644 --- a/errors/class_rangeerror.md +++ b/errors/class_rangeerror.md @@ -1,11 +1,12 @@ -`Error` 的一个子类,表明一个函数的一个给定的参数的值不在可接受的集合或范围内; -无论是一个数字范围还是给定函数参数的选项的集合。 +* 继承自: {errors.Error} + +表明提供的参数不在函数的可接受值的集合或范围内;无论是一个数字范围,还是在给定的函数参数的选项的集合之外。 ```js require('net').connect(-1); // 抛出 "RangeError: "port" option should be >= 0 and < 65536: -1" ``` -Node.js 会生成并以参数校验的形式立即抛出 `RangeError` 实例。 +Node.js 将会以参数验证的形式立即地生成并抛出 `RangeError` 实例。 diff --git a/errors/class_referenceerror.md b/errors/class_referenceerror.md index 4e831cc1..f2a573b9 100644 --- a/errors/class_referenceerror.md +++ b/errors/class_referenceerror.md @@ -1,6 +1,8 @@ -`Error` 的一个子类,表明试图访问一个未定义的变量。 -这些错误通常表明代码有拼写错误或程序已损坏。 +* 继承自: {errors.Error} + +表明试图访问一个未定义的变量。 +此类错误通常表明代码有拼写错误或程序已损坏。 虽然客户端代码可能产生和传播这些错误,但在实践中,只有 V8 引擎会这么做。 @@ -9,5 +11,5 @@ doesNotExist; // 抛出 ReferenceError,在这个程序中 doesNotExist 不是一个变量。 ``` -除非应用程序是动态生成并运行的代码,否则 `ReferenceError` 实例应该始终被视为代码中或其依赖中的错误。 +除非应用程序是动态地生成并运行代码,否则 `ReferenceError` 实例应该始终被视为代码中或其依赖中的错误。 diff --git a/errors/class_syntaxerror.md b/errors/class_syntaxerror.md index 5f5d5658..6b8afbf5 100644 --- a/errors/class_syntaxerror.md +++ b/errors/class_syntaxerror.md @@ -1,18 +1,19 @@ -`Error` 的一个子类,表明程序不是有效的 JavaScript 代码。 -这些错误是代码执行的结果产生和传播的。 -代码执行可能产生自 `eval`、`Function`、`require` 或 [vm]。 -这些错误几乎都表明程序已损坏。 +* 继承自: {errors.Error} + +表明程序不是有效的 JavaScript。 +这些错误可能仅在代码评估的结果中产生和传播。 +代码评估可能产生自 `eval`、`Function`、`require` 或 [vm]。 +这些错误几乎总是表明程序已损坏。 ```js try { - require('vm').runInThisContext('binary ! isNotOk'); + require('vm').runInThisContext('nodejs.cn ! 中文网'); } catch (err) { // `err` 是一个 SyntaxError。 } ``` -`SyntaxError` 实例在创建它们的上下文中是不可恢复的。 -它们只可被其他上下文捕获。 +`SyntaxError` 实例在创建它们的上下文中是不可恢复的,它们只可能被其他上下文捕获。 diff --git a/errors/class_systemerror.md b/errors/class_systemerror.md index a5732116..6080896b 100644 --- a/errors/class_systemerror.md +++ b/errors/class_systemerror.md @@ -1,4 +1,6 @@ +* Extends: {errors.Error} + Node.js generates system errors when exceptions occur within its runtime environment. These usually occur when an application violates an operating system constraint. For example, a system error will occur if an application diff --git a/errors/class_typeerror.md b/errors/class_typeerror.md index 61792789..e4e675c1 100644 --- a/errors/class_typeerror.md +++ b/errors/class_typeerror.md @@ -1,11 +1,13 @@ -`Error` 的一个子类,表明提供的参数不是一个被允许的类型。 -例如,将一个函数传给一个期望字符串的参数会被视为一个 `TypeError`。 +* 继承自 {errors.Error} + +表明提供的参数不是被允许的类型。 +例如,将函数传给期望字符串的参数,将会被视为 `TypeError`。 ```js require('url').parse(() => { }); -// 抛出 TypeError,因为它期望的是一个字符串 +// 抛出 TypeError,因为它期望的是字符串。 ``` -Node.js 会生成并以参数校验的形式立即抛出 `TypeError` 实例。 +Node.js 将会以参数验证的形式立即地生成并抛出 `TypeError` 实例。 diff --git a/errors/err_parse_history_data.md b/errors/err_parse_history_data.md index 9aba643b..75e4bd18 100644 --- a/errors/err_parse_history_data.md +++ b/errors/err_parse_history_data.md @@ -5,5 +5,4 @@ removed: v10.0.0 The `repl` module was unable to parse data from the REPL history file. - diff --git a/errors/error_reason.md b/errors/error_reason.md index b5b68ecd..f328c4dc 100644 --- a/errors/error_reason.md +++ b/errors/error_reason.md @@ -1,5 +1,4 @@ A human-readable string describing the reason for the error. - diff --git a/esm/customizing_esm_specifier_resolution_algorithm.md b/esm/customizing_esm_specifier_resolution_algorithm.md index 8fe203ae..af60efb2 100644 --- a/esm/customizing_esm_specifier_resolution_algorithm.md +++ b/esm/customizing_esm_specifier_resolution_algorithm.md @@ -31,3 +31,6 @@ success! + + + diff --git a/esm/data_imports.md b/esm/data_imports.md new file mode 100644 index 00000000..d9955d6b --- /dev/null +++ b/esm/data_imports.md @@ -0,0 +1,24 @@ + + + + + +* `text/javascript` for ES Modules +* `application/json` for JSON +* `application/wasm` for WASM. + +`data:` URLs only resolve [_Bare specifiers_][Terminology] for builtin modules +and [_Absolute specifiers_][Terminology]. Resolving + +[special scheme][]. For example, attempting to load `./foo` +from `data:text/javascript,import "./foo";` will fail to resolve since there +is no concept of relative resolution for `data:` URLs. An example of a `data:` +URLs being used is: + +```js +import 'data:text/javascript,console.log("hello!");'; +import _ from 'data:application/json,"world!"'; +``` + diff --git a/esm/package_entry_points.md b/esm/package_entry_points.md index 5637b060..0d62a1d1 100644 --- a/esm/package_entry_points.md +++ b/esm/package_entry_points.md @@ -11,6 +11,7 @@ module via `import`. "main": "./src/index.js" } ``` + ```js // ./my-app.mjs diff --git a/esm/terminology.md b/esm/terminology.md index 4b5c7bb5..0963a5f9 100644 --- a/esm/terminology.md +++ b/esm/terminology.md @@ -20,7 +20,7 @@ There are four types of specifiers: Bare specifiers, and the bare specifier portion of deep import specifiers, are strings; but everything else in a specifier is a URL. -Only `file://` URLs are supported. A specifier like +Only `file:` and `data:` URLs are supported. A specifier like `'https://example.com/app.js'` may be supported by browsers but it is not supported in Node.js. diff --git a/fs/class_fs_fswatcher.md b/fs/class_fs_fswatcher.md index 9d164765..19164c75 100644 --- a/fs/class_fs_fswatcher.md +++ b/fs/class_fs_fswatcher.md @@ -2,7 +2,9 @@ added: v0.5.8 --> -成功调用 [`fs.watch()`] 方法将返回一个新的 `fs.FSWatcher` 对象。 +* 继承自 {EventEmitter} -所有 `fs.FSWatcher` 对象都是 [`EventEmitter`] 的实例,每当修改指定监视的文件,就会触发 `'change'` 事件。 +成功调用 [`fs.watch()`] 方法将会返回一个新的 `fs.FSWatcher` 对象。 + +每当指定监视的文件被修改时,所有的 `fs.FSWatcher` 对象都会触发 `'change'` 事件。 diff --git a/fs/class_fs_readstream.md b/fs/class_fs_readstream.md index 41cd5a4c..ee02542f 100644 --- a/fs/class_fs_readstream.md +++ b/fs/class_fs_readstream.md @@ -2,7 +2,8 @@ added: v0.1.93 --> -成功调用 `fs.createReadStream()` 将返回一个新的 `fs.ReadStream` 对象。 +* 继承自: {stream.Readable} + +成功调用 `fs.createReadStream()` 将会返回一个新的 `fs.ReadStream` 对象。 -所有 `fs.ReadStream` 对象都是[可读流][Readable Streams]。 diff --git a/fs/class_fs_stats.md b/fs/class_fs_stats.md index 644a0c80..da3b4f4c 100644 --- a/fs/class_fs_stats.md +++ b/fs/class_fs_stats.md @@ -6,10 +6,10 @@ changes: description: Added times as numbers. --> -`fs.Stats` 对象提供有关文件的信息。 +`fs.Stats` 对象提供了关于文件的信息。 -从 [`fs.stat()`]、[`fs.lstat()`] 和 [`fs.fstat()`] 及其同步方法返回的对象都属于此类型。 -如果传给这些方法的 `options` 中的 `bigint` 为 true,则数值将为 `bigint` 型而不是 `number` 型。 +从 [`fs.stat()`]、[`fs.lstat()`] 和 [`fs.fstat()`] 及其同步的方法返回的对象都属于此类型。 +如果传给这些方法的 `options` 中的 `bigint` 为 true,则数值将会为 `bigint` 型而不是 `number` 型,并且该对象将会包含额外的以 `Ns` 为后缀的纳秒精度的属性。 ```console Stats { @@ -36,7 +36,7 @@ Stats { `bigint` 的版本: ```console -Stats { +BigIntStats { dev: 2114n, ino: 48064969n, mode: 33188n, @@ -51,6 +51,10 @@ Stats { mtimeMs: 1318289051000n, ctimeMs: 1318289051000n, birthtimeMs: 1318289051000n, + atimeNs: 1318289051000000000n, + mtimeNs: 1318289051000000000n, + ctimeNs: 1318289051000000000n, + birthtimeNs: 1318289051000000000n, atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, diff --git a/fs/class_fs_writestream.md b/fs/class_fs_writestream.md index c816a24b..86429796 100644 --- a/fs/class_fs_writestream.md +++ b/fs/class_fs_writestream.md @@ -2,5 +2,5 @@ added: v0.1.93 --> -`WriteStream` 是一个[可写流][Writable Stream]。 +* 继承自 {stream.Writable} diff --git a/fs/fs_createreadstream_path_options.md b/fs/fs_createreadstream_path_options.md index 71d797ca..abcd59fc 100644 --- a/fs/fs_createreadstream_path_options.md +++ b/fs/fs_createreadstream_path_options.md @@ -1,6 +1,9 @@ - -* `path` {string|Buffer|URL} -* `callback` {Function} - * `err` {Error} - -异步的 rmdir(2)。 -除了可能的异常,完成回调没有其他参数。 - -在文件(而不是目录)上使用 `fs.rmdir()` 会导致在 Windows 上出现 `ENOENT` 错误、在 POSIX 上出现 `ENOTDIR` 错误。 - diff --git a/fs/fs_rmdir_path_options_callback.md b/fs/fs_rmdir_path_options_callback.md new file mode 100644 index 00000000..a0e4180c --- /dev/null +++ b/fs/fs_rmdir_path_options_callback.md @@ -0,0 +1,38 @@ + + +> 稳定性: 1 - 递归的删除是实验性的。 + +* `path` {string|Buffer|URL} +* `options` {Object} + * `emfileWait` {integer} 如果遇到 `EMFILE` 错误,则 Node.js 将会在每次尝试时以 1 毫秒的线性回退重试该操作,直到超时持续时间超过此限制。 + 如果 `recursive` 选项不为 `true`,则忽略此选项。**默认值:** `1000`。 + * `maxBusyTries` {integer} 如果遇到 `EBUSY`、`ENOTEMPTY` 或 `EPERM` 错误,则 Node.js 将会在每次尝试时以 100 毫秒的线性回退等待重试该操作。 + 此选项代表重试的次数。如果 `recursive` 选项不为 `true`,则忽略此选项。**默认值:** `3`。 + * `recursive` {boolean} 如果为 `true`,则执行递归的目录删除。在递归模式中,如果 `path` 不存在则不报告错误,并且在失败时重试操作。**默认值:** `false`。 +* `callback` {Function} + * `err` {Error} + +异步的 rmdir(2)。 +除了可能的异常,完成回调没有其他参数。 + +在文件(而不是目录)上使用 `fs.rmdir()` 会导致在 Windows 上出现 `ENOENT` 错误、在 POSIX 上出现 `ENOTDIR` 错误。 + diff --git a/fs/fs_rmdirsync_path.md b/fs/fs_rmdirsync_path.md deleted file mode 100644 index 6d44eccc..00000000 --- a/fs/fs_rmdirsync_path.md +++ /dev/null @@ -1,15 +0,0 @@ - - -* `path` {string|Buffer|URL} - -同步的 rmdir(2)。返回 `undefined`。 - -在文件(而不是目录)上使用 `fs.rmdirSync()` 会导致在 Windows 上出现 `ENOENT` 错误、在 POSIX 上出现 `ENOTDIR` 错误。 - diff --git a/fs/fs_rmdirsync_path_options.md b/fs/fs_rmdirsync_path_options.md new file mode 100644 index 00000000..66641888 --- /dev/null +++ b/fs/fs_rmdirsync_path_options.md @@ -0,0 +1,24 @@ + + +> 稳定性: 1 - 递归的删除是实验性的。 + +* `path` {string|Buffer|URL} +* `options` {Object} + * `recursive` {boolean} 如果为 `true`,则执行递归的目录删除。在递归模式中,如果 `path` 不存在则不报告错误,并且在失败时重试操作。**默认值:** `false`。 + +同步的 rmdir(2)。 +返回 `undefined`。 + +在文件(而不是目录)上使用 `fs.rmdirSync()` 会导致在 Windows 上出现 `ENOENT` 错误、在 POSIX 上出现 `ENOTDIR` 错误。 + diff --git a/fs/fspromises_open_path_flags_mode.md b/fs/fspromises_open_path_flags_mode.md index 804930b2..bf7e2348 100644 --- a/fs/fspromises_open_path_flags_mode.md +++ b/fs/fspromises_open_path_flags_mode.md @@ -14,7 +14,7 @@ changes: 异步地打开文件并返回一个 `Promise`,当解决时会带上一个 `FileHandle` 对象。 参阅 open(2)。 -`mode` 设置文件模式(权限和粘滞位),但仅限于创建文件的情况。 +`mode` 用于设置文件模式(权限和粘滞位),但仅限于创建文件时。 有些字符 (`< > : " / \ | ? *`) 在 Windows 上是预留的,参阅[命名文件、路径以及命名空间][Naming Files, Paths, and Namespaces]。 在 NTFS 上,如果文件名包含冒号,则 Node.js 将打开文件系统流,参阅[此 MSDN 页面][MSDN-Using-Streams]。 diff --git a/fs/fspromises_rmdir_path.md b/fs/fspromises_rmdir_path.md deleted file mode 100644 index 147b190d..00000000 --- a/fs/fspromises_rmdir_path.md +++ /dev/null @@ -1,11 +0,0 @@ - - -* `path` {string|Buffer|URL} -* 返回: {Promise} - -删除 `path` 指定的目录,然后在成功时解决 `Promise` 且不带参数。 - -在文件(而不是目录)上使用 `fsPromises.rmdir()` 会导致 `Promise` 被拒绝,在 Windows 上会带上 `ENOENT` 错误,而在 POSIX 上则会带上 `ENOTDIR` 错误。 - diff --git a/fs/fspromises_rmdir_path_options.md b/fs/fspromises_rmdir_path_options.md new file mode 100644 index 00000000..c5189c76 --- /dev/null +++ b/fs/fspromises_rmdir_path_options.md @@ -0,0 +1,24 @@ + + +> 稳定性: 1 - 递归的删除是实验性的。 + +* `path` {string|Buffer|URL} +* `options` {Object} + * `emfileWait` {integer} 如果遇到 `EMFILE` 错误,则 Node.js 将会在每次尝试时以 1 毫秒的线性回退重试该操作,直到超时持续时间超过此限制。 + 如果 `recursive` 选项不为 `true`,则忽略此选项。**默认值:** `1000`。 + * `maxBusyTries` {integer} 如果遇到 `EBUSY`、`ENOTEMPTY` 或 `EPERM` 错误,则 Node.js 将会在每次尝试时以 100 毫秒的线性回退等待重试该操作。 + 此选项代表重试的次数。如果 `recursive` 选项不为 `true`,则忽略此选项。**默认值:** `3`。 + * `recursive` {boolean} 如果为 `true`,则执行递归的目录删除。在递归模式中,如果 `path` 不存在则不报告错误,并且在失败时重试操作。**默认值:** `false`。 +* 返回: {Promise} + +删除 `path` 指定的目录,然后在成功时解决 `Promise` 且不带参数。 + +在文件(而不是目录)上使用 `fsPromises.rmdir()` 会导致 `Promise` 被拒绝,在 Windows 上会带上 `ENOENT` 错误、在 POSIX 上会带上 `ENOTDIR` 错误。 + diff --git a/fs/stat_time_values.md b/fs/stat_time_values.md index a821bfe3..cf254b2a 100644 --- a/fs/stat_time_values.md +++ b/fs/stat_time_values.md @@ -1,9 +1,15 @@ `atimeMs`、`mtimeMs`、`ctimeMs` 和 `birthtimeMs` 属性是保存相应时间(以毫秒为单位)的[数值][MDN-Number]。 它们的精度取决于平台。 +当将 `bigint: true` 传给生成该对象的方法时,属性将会是 [bigint][bigints] 型,否则它们将会是[数字型][MDN-Number]。 + +`atimeNs`、`mtimeNs`、`ctimeNs` 和 `birthtimeNs` 属性是保存相应时间(以纳秒为单位)的 [bigint][bigints]。 +仅当将 `bigint: true` 传给生成该对象的方法时,它们才会出现。 +它们的精度取决于平台。 + `atime`、`mtime`、`ctime` 和 `birthtime` 是对应时间的 [`Date`][MDN-Date] 对象。 `Date` 值和数值没有关联性。 -赋值新的数值、或者改变 `Date` 值,都不会影响到对应的属性。 +赋值新的数值、或者改变 `Date` 的值,都将不会影响到对应的属性。 stat 对象中的时间具有以下语义: @@ -15,6 +21,6 @@ stat 对象中的时间具有以下语义: 在这种情况下,该值可能大于 `atime` 或 `mtime`。 在 Darwin 和其他的 FreeBSD 衍生系统上,也可能使用 utimes(2) 系统调用将 `atime` 显式地设置为比 `birthtime` 更早的值。 -在 Node.js 0.12 之前,`ctime` 在 Windows 上保存 `birthtime`。 +在 Node.js 0.12 之前,在 Windows 系统上 `ctime` 保存 `birthtime`。 从 0.12 开始,`ctime` 不再是“创建时间”,而在 Unix 系统上则从来都不是。 diff --git a/fs/stats_atimens.md b/fs/stats_atimens.md new file mode 100644 index 00000000..ae6c1c88 --- /dev/null +++ b/fs/stats_atimens.md @@ -0,0 +1,11 @@ + + +* {bigint} + +Only present when `bigint: true` is passed into the method that generates +the object. +The timestamp indicating the last time this file was accessed expressed in +nanoseconds since the POSIX Epoch. + diff --git a/fs/stats_birthtimens.md b/fs/stats_birthtimens.md new file mode 100644 index 00000000..1b0e3937 --- /dev/null +++ b/fs/stats_birthtimens.md @@ -0,0 +1,11 @@ + + +* {bigint} + +Only present when `bigint: true` is passed into the method that generates +the object. +The timestamp indicating the creation time of this file expressed in +nanoseconds since the POSIX Epoch. + diff --git a/fs/stats_ctimens.md b/fs/stats_ctimens.md new file mode 100644 index 00000000..2e91185f --- /dev/null +++ b/fs/stats_ctimens.md @@ -0,0 +1,11 @@ + + +* {bigint} + +Only present when `bigint: true` is passed into the method that generates +the object. +The timestamp indicating the last time the file status was changed expressed +in nanoseconds since the POSIX Epoch. + diff --git a/fs/stats_mtimens.md b/fs/stats_mtimens.md new file mode 100644 index 00000000..4ad1e287 --- /dev/null +++ b/fs/stats_mtimens.md @@ -0,0 +1,11 @@ + + +* {bigint} + +Only present when `bigint: true` is passed into the method that generates +the object. +The timestamp indicating the last time this file was modified expressed in +nanoseconds since the POSIX Epoch. + diff --git a/http/class_http_clientrequest.md b/http/class_http_clientrequest.md index 342f3655..debff3f1 100644 --- a/http/class_http_clientrequest.md +++ b/http/class_http_clientrequest.md @@ -2,25 +2,26 @@ added: v0.1.17 --> +* 继承自: {Stream} + 此对象由 [`http.request()`] 内部创建并返回。 -它表示正在进行的请求,且其请求头已进入队列。 -请求头仍然可以使用 [`setHeader(name, value)`]、[`getHeader(name)`] 或 [`removeHeader(name)`] 改变。 -实际的请求头将与第一个数据块一起发送,或者当调用 [`request.end()`] 时发送。 +它代表正在进行中的请求,其请求头已进入队列。 +请求头仍然可以使用 [`setHeader(name, value)`]、[`getHeader(name)`] 或 [`removeHeader(name)`] API 进行改变。 +实际的请求头将会与第一个数据块一起发送,或者当调用 [`request.end()`] 时发送。 要获得响应,则为请求对象添加 [`'response'`] 事件监听器。 -当接收到响应头时,将、则会从请求对象触发 [`'response'`] 事件。 -[`'response'`] 事件执行时有一个参数,该参数是 [`http.IncomingMessage`] 的实例。 +当接收到响应头时,会从请求对象中触发 [`'response'`] 事件。 +[`'response'`] 事件执行时具有一个参数,该参数是 [`http.IncomingMessage`] 的实例。 在 [`'response'`] 事件期间,可以添加监听器到响应对象,比如监听 `'data'` 事件。 -如果没有添加 [`'response'`] 事件处理函数,则响应将被完全丢弃。 +如果没有添加 [`'response'`] 事件处理函数,则响应将会被完全地丢弃。 如果添加了 [`'response'`] 事件处理函数,则必须消费完响应对象中的数据,每当有 `'readable'` 事件时调用 `response.read()`、或添加 `'data'` 事件处理函数、或通过调用 `.resume()` 方法。 在消费完数据之前,不会触发 `'end'` 事件。 -此外,在读取数据之前,它将占用内存,最终可能导致进程内存不足的错误。 +此外,在读取数据之前,它将会占用内存,这最终可能导致进程内存不足的错误。 -与 `request` 对象不同,如果响应过早关闭,则 `response` 对象不会触发 `'error'` 事件而是触发 `'aborted'` 事件。 +与 `request` 对象不同,如果响应过早地关闭,则 `response` 对象不会触发 `'error'` 事件而是触发 `'aborted'` 事件。 -Node.js 不检查 Content-Length 和已传输的主体的长度是否相等。 +Node.js 不会检查 Content-Length 和已传输的请求体的长度是否相等。 -请求继承自[流][Stream],且额外实现以下内容: diff --git a/http/class_http_incomingmessage.md b/http/class_http_incomingmessage.md index 55cd1b7f..f91bf17e 100644 --- a/http/class_http_incomingmessage.md +++ b/http/class_http_incomingmessage.md @@ -2,8 +2,8 @@ added: v0.1.17 --> +* 继承自: {stream.Readable} + `IncomingMessage` 对象由 [`http.Server`] 或 [`http.ClientRequest`] 创建,并分别作为第一个参数传给 [`'request'`] 和 [`'response'`] 事件。 它可用于访问响应状态、消息头、以及数据。 -它实现了[可读流][Readable Stream]接口,还有以下额外的事件、方法、以及属性。 - diff --git a/http/class_http_server.md b/http/class_http_server.md index f7a2ead4..97d0cfc8 100644 --- a/http/class_http_server.md +++ b/http/class_http_server.md @@ -2,5 +2,5 @@ added: v0.1.17 --> -此类继承自 [`net.Server`] 并具有以下额外的事件: +* 继承自: {net.Server} diff --git a/http/class_http_serverresponse.md b/http/class_http_serverresponse.md index 3452a94f..e1cedf09 100644 --- a/http/class_http_serverresponse.md +++ b/http/class_http_serverresponse.md @@ -2,8 +2,8 @@ added: v0.1.17 --> +* 继承自: {Stream} + 此对象由 HTTP 服务器在内部创建,而不是由用户创建。 它作为第二个参数传给 [`'request'`] 事件。 -响应继承自[流][Stream],并额外实现以下内容: - diff --git a/http2/class_clienthttp2session.md b/http2/class_clienthttp2session.md index 538121c0..d0f8790b 100644 --- a/http2/class_clienthttp2session.md +++ b/http2/class_clienthttp2session.md @@ -2,3 +2,5 @@ added: v8.4.0 --> +* Extends: {Http2Session} + diff --git a/http2/class_http2_http2serverrequest.md b/http2/class_http2_http2serverrequest.md index a744c571..b0d1a814 100644 --- a/http2/class_http2_http2serverrequest.md +++ b/http2/class_http2_http2serverrequest.md @@ -2,11 +2,10 @@ added: v8.4.0 --> +* Extends: {stream.Readable} + A `Http2ServerRequest` object is created by [`http2.Server`][] or [`http2.SecureServer`][] and passed as the first argument to the [`'request'`][] event. It may be used to access a request status, headers, and data. -It implements the [Readable Stream][] interface, as well as the -following additional events, methods, and properties. - diff --git a/http2/class_http2_http2serverresponse.md b/http2/class_http2_http2serverresponse.md index 4fd07320..24308c76 100644 --- a/http2/class_http2_http2serverresponse.md +++ b/http2/class_http2_http2serverresponse.md @@ -2,9 +2,8 @@ added: v8.4.0 --> +* Extends: {Stream} + This object is created internally by an HTTP server — not by the user. It is passed as the second parameter to the [`'request'`][] event. -The response inherits from [Stream][], and additionally implements the -following: - diff --git a/http2/class_serverhttp2session.md b/http2/class_serverhttp2session.md index 538121c0..d0f8790b 100644 --- a/http2/class_serverhttp2session.md +++ b/http2/class_serverhttp2session.md @@ -2,3 +2,5 @@ added: v8.4.0 --> +* Extends: {Http2Session} + diff --git a/http2/collecting_http_2_performance_metrics.md b/http2/collecting_http_2_performance_metrics.md index 2801c9bc..b50d542c 100644 --- a/http2/collecting_http_2_performance_metrics.md +++ b/http2/collecting_http_2_performance_metrics.md @@ -109,6 +109,5 @@ following additional properties: - diff --git a/http2/compatibility_api.md b/http2/compatibility_api.md index 6cdc39b8..3649c1f7 100644 --- a/http2/compatibility_api.md +++ b/http2/compatibility_api.md @@ -23,8 +23,8 @@ In order to create a mixed [HTTPS][] and HTTP/2 server, refer to the [ALPN negotiation][] section. Upgrading from non-tls HTTP/1 servers is not supported. -The HTTP/2 compatibility API is composed of [`Http2ServerRequest`]() and -[`Http2ServerResponse`](). They aim at API compatibility with HTTP/1, but +The HTTP/2 compatibility API is composed of [`Http2ServerRequest`][] and +[`Http2ServerResponse`][]. They aim at API compatibility with HTTP/1, but they do not hide the differences between the protocols. As an example, the status message for HTTP codes is ignored. diff --git a/http2/event_close_3.md b/http2/event_close_3.md index 3ebaf931..7a156c37 100644 --- a/http2/event_close_3.md +++ b/http2/event_close_3.md @@ -2,6 +2,6 @@ added: v8.4.0 --> -Indicates that the underlying [`Http2Stream`]() was terminated before +Indicates that the underlying [`Http2Stream`][] was terminated before [`response.end()`][] was called or able to flush. diff --git a/http2/request_settimeout_msecs_callback.md b/http2/request_settimeout_msecs_callback.md index ca5720ff..61841d7c 100644 --- a/http2/request_settimeout_msecs_callback.md +++ b/http2/request_settimeout_msecs_callback.md @@ -6,12 +6,12 @@ added: v8.4.0 * `callback` {Function} * Returns: {http2.Http2ServerRequest} -Sets the [`Http2Stream`]()'s timeout value to `msecs`. If a callback is +Sets the [`Http2Stream`][]'s timeout value to `msecs`. If a callback is provided, then it is added as a listener on the `'timeout'` event on the response object. If no `'timeout'` listener is added to the request, the response, or -the server, then [`Http2Stream`]()s are destroyed when they time out. If a +the server, then [`Http2Stream`][]s are destroyed when they time out. If a handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly. diff --git a/http2/response_settimeout_msecs_callback.md b/http2/response_settimeout_msecs_callback.md index 77f1c60d..0909687f 100644 --- a/http2/response_settimeout_msecs_callback.md +++ b/http2/response_settimeout_msecs_callback.md @@ -6,12 +6,12 @@ added: v8.4.0 * `callback` {Function} * Returns: {http2.Http2ServerResponse} -Sets the [`Http2Stream`]()'s timeout value to `msecs`. If a callback is +Sets the [`Http2Stream`][]'s timeout value to `msecs`. If a callback is provided, then it is added as a listener on the `'timeout'` event on the response object. If no `'timeout'` listener is added to the request, the response, or -the server, then [`Http2Stream`]()s are destroyed when they time out. If a +the server, then [`Http2Stream`][]s are destroyed when they time out. If a handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly. diff --git a/http2/supporting_the_connect_method.md b/http2/supporting_the_connect_method.md index 2c88d826..45dd393a 100644 --- a/http2/supporting_the_connect_method.md +++ b/http2/supporting_the_connect_method.md @@ -3,6 +3,7 @@ The `CONNECT` method is used to allow an HTTP/2 server to be used as a proxy for TCP/IP connections. A simple TCP Server: + ```js const net = require('net'); diff --git a/https/class_https_server.md b/https/class_https_server.md index 30ac5e69..da199672 100644 --- a/https/class_https_server.md +++ b/https/class_https_server.md @@ -2,6 +2,7 @@ added: v0.3.4 --> -此类是 `tls.Server` 的子类,并触发与 [`http.Server`] 相同的事件。 +* 继承自: {tls.Server} + 有关更多信息,请参阅 [`http.Server`]。 diff --git a/inspector/class_inspector_session.md b/inspector/class_inspector_session.md index 756f0e9c..c3492d59 100644 --- a/inspector/class_inspector_session.md +++ b/inspector/class_inspector_session.md @@ -1,4 +1,6 @@ +* Extends: {EventEmitter} + The `inspector.Session` is used for dispatching messages to the V8 inspector back-end and receiving message responses and notifications. diff --git a/inspector/constructor_new_inspector_session.md b/inspector/constructor_new_inspector_session.md index b84b4948..9bfad3f7 100644 --- a/inspector/constructor_new_inspector_session.md +++ b/inspector/constructor_new_inspector_session.md @@ -6,5 +6,3 @@ Create a new instance of the `inspector.Session` class. The inspector session needs to be connected through [`session.connect()`][] before the messages can be dispatched to the inspector backend. -`inspector.Session` is an [`EventEmitter`][] with the following events: - diff --git a/inspector/heap_profiler.md b/inspector/heap_profiler.md index 6abba380..cd21ff3e 100644 --- a/inspector/heap_profiler.md +++ b/inspector/heap_profiler.md @@ -26,4 +26,3 @@ session.post('HeapProfiler.takeHeapSnapshot', null, (err, r) => { - diff --git a/n-api/implications_of_abi_stability.md b/n-api/implications_of_abi_stability.md index 87711308..b5bc0477 100644 --- a/n-api/implications_of_abi_stability.md +++ b/n-api/implications_of_abi_stability.md @@ -4,26 +4,33 @@ not, and any external libraries used from the addon may not. In particular, none of the following APIs provide an ABI stability guarantee across major versions: * the Node.js C++ APIs available via any of + ```C++ #include #include #include #include ``` + * the libuv APIs which are also included with Node.js and available via + ```C++ #include ``` + * the V8 API available via + ```C++ #include ``` Thus, for an addon to remain ABI-compatible across Node.js major versions, it must make use exclusively of N-API by restricting itself to using + ```C #include ``` + and by checking, for all external libraries that it uses, that the external library makes ABI stability guarantees similar to N-API. diff --git a/n-api/napi_acquire_threadsafe_function.md b/n-api/napi_acquire_threadsafe_function.md index 9bc03e4e..4f5dcf3e 100644 --- a/n-api/napi_acquire_threadsafe_function.md +++ b/n-api/napi_acquire_threadsafe_function.md @@ -3,6 +3,7 @@ added: v10.6.0 napiVersion: 4 --> + ```C NAPI_EXTERN napi_status napi_acquire_threadsafe_function(napi_threadsafe_function func); diff --git a/n-api/napi_add_finalizer.md b/n-api/napi_add_finalizer.md index 9fdf8fa4..22e71f4f 100644 --- a/n-api/napi_add_finalizer.md +++ b/n-api/napi_add_finalizer.md @@ -4,6 +4,7 @@ + ```C napi_status napi_add_finalizer(napi_env env, napi_value js_object, diff --git a/n-api/napi_adjust_external_memory.md b/n-api/napi_adjust_external_memory.md index d3af7033..6c3f6beb 100644 --- a/n-api/napi_adjust_external_memory.md +++ b/n-api/napi_adjust_external_memory.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env, int64_t change_in_bytes, diff --git a/n-api/napi_async_destroy.md b/n-api/napi_async_destroy.md index e8646d03..c996bb73 100644 --- a/n-api/napi_async_destroy.md +++ b/n-api/napi_async_destroy.md @@ -2,6 +2,7 @@ added: v8.6.0 napiVersion: 1 --> + ```C napi_status napi_async_destroy(napi_env env, napi_async_context async_context); diff --git a/n-api/napi_async_init.md b/n-api/napi_async_init.md index 04d951cf..dc509c82 100644 --- a/n-api/napi_async_init.md +++ b/n-api/napi_async_init.md @@ -2,6 +2,7 @@ added: v8.6.0 napiVersion: 1 --> + ```C napi_status napi_async_init(napi_env env, napi_value async_resource, diff --git a/n-api/napi_call_function.md b/n-api/napi_call_function.md index b34b3fd7..f5e7735e 100644 --- a/n-api/napi_call_function.md +++ b/n-api/napi_call_function.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_call_function(napi_env env, napi_value recv, @@ -29,6 +30,7 @@ after an async operation, see [`napi_make_callback`][]. A sample use case might look as follows. Consider the following JavaScript snippet: + ```js function AddTwo(num) { return num + 2; @@ -37,6 +39,7 @@ function AddTwo(num) { Then, the above function can be invoked from a native add-on using the following code: + ```C // Get the function named "AddTwo" on the global object napi_value global, add_two, arg; diff --git a/n-api/napi_call_threadsafe_function.md b/n-api/napi_call_threadsafe_function.md index d759c830..e1d1d0ef 100644 --- a/n-api/napi_call_threadsafe_function.md +++ b/n-api/napi_call_threadsafe_function.md @@ -3,6 +3,7 @@ added: v10.6.0 napiVersion: 4 --> + ```C NAPI_EXTERN napi_status napi_call_threadsafe_function(napi_threadsafe_function func, diff --git a/n-api/napi_callback.md b/n-api/napi_callback.md index 9a0f50c0..317117d2 100644 --- a/n-api/napi_callback.md +++ b/n-api/napi_callback.md @@ -5,6 +5,7 @@ napiVersion: 1 Function pointer type for user-provided native functions which are to be exposed to JavaScript via N-API. Callback functions should satisfy the following signature: + ```C typedef napi_value (*napi_callback)(napi_env, napi_callback_info); ``` diff --git a/n-api/napi_cancel_async_work.md b/n-api/napi_cancel_async_work.md index ef7f3706..b2531058 100644 --- a/n-api/napi_cancel_async_work.md +++ b/n-api/napi_cancel_async_work.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_cancel_async_work(napi_env env, napi_async_work work); diff --git a/n-api/napi_close_callback_scope.md b/n-api/napi_close_callback_scope.md index 9099429b..0ff8a346 100644 --- a/n-api/napi_close_callback_scope.md +++ b/n-api/napi_close_callback_scope.md @@ -2,10 +2,12 @@ added: v9.6.0 napiVersion: 3 --> + ```C NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, napi_callback_scope scope) ``` + - `[in] env`: The environment that the API is invoked under. - `[in] scope`: The scope to be closed. diff --git a/n-api/napi_close_escapable_handle_scope.md b/n-api/napi_close_escapable_handle_scope.md index 917cedf8..8bd71aa2 100644 --- a/n-api/napi_close_escapable_handle_scope.md +++ b/n-api/napi_close_escapable_handle_scope.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_close_escapable_handle_scope(napi_env env, napi_handle_scope scope); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] scope`: `napi_value` representing the scope to be closed. diff --git a/n-api/napi_close_handle_scope.md b/n-api/napi_close_handle_scope.md index 4f968df6..c648ddfa 100644 --- a/n-api/napi_close_handle_scope.md +++ b/n-api/napi_close_handle_scope.md @@ -2,10 +2,12 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, napi_handle_scope scope); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] scope`: `napi_value` representing the scope to be closed. diff --git a/n-api/napi_coerce_to_bool.md b/n-api/napi_coerce_to_bool.md index 981cce9f..6f03ebf6 100644 --- a/n-api/napi_coerce_to_bool.md +++ b/n-api/napi_coerce_to_bool.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_coerce_to_bool(napi_env env, napi_value value, diff --git a/n-api/napi_coerce_to_number.md b/n-api/napi_coerce_to_number.md index 8fa47a34..6b2d7e9f 100644 --- a/n-api/napi_coerce_to_number.md +++ b/n-api/napi_coerce_to_number.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_coerce_to_number(napi_env env, napi_value value, diff --git a/n-api/napi_coerce_to_object.md b/n-api/napi_coerce_to_object.md index 4f3d8a63..ee3397e7 100644 --- a/n-api/napi_coerce_to_object.md +++ b/n-api/napi_coerce_to_object.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_coerce_to_object(napi_env env, napi_value value, diff --git a/n-api/napi_coerce_to_string.md b/n-api/napi_coerce_to_string.md index d35bc403..a9693747 100644 --- a/n-api/napi_coerce_to_string.md +++ b/n-api/napi_coerce_to_string.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_coerce_to_string(napi_env env, napi_value value, diff --git a/n-api/napi_create_array.md b/n-api/napi_create_array.md index b70ef9eb..64d7310e 100644 --- a/n-api/napi_create_array.md +++ b/n-api/napi_create_array.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_array(napi_env env, napi_value* result) ``` diff --git a/n-api/napi_create_array_with_length.md b/n-api/napi_create_array_with_length.md index 07ab7d93..d4b3a75a 100644 --- a/n-api/napi_create_array_with_length.md +++ b/n-api/napi_create_array_with_length.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_array_with_length(napi_env env, size_t length, diff --git a/n-api/napi_create_arraybuffer.md b/n-api/napi_create_arraybuffer.md index d2abd2b8..35d99bb0 100644 --- a/n-api/napi_create_arraybuffer.md +++ b/n-api/napi_create_arraybuffer.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_arraybuffer(napi_env env, size_t byte_length, diff --git a/n-api/napi_create_async_work.md b/n-api/napi_create_async_work.md index 5d5f4e0c..110aa2f8 100644 --- a/n-api/napi_create_async_work.md +++ b/n-api/napi_create_async_work.md @@ -6,6 +6,7 @@ changes: pr-url: https://github.com/nodejs/node/pull/14697 description: Added `async_resource` and `async_resource_name` parameters. --> + ```C napi_status napi_create_async_work(napi_env env, napi_value async_resource, diff --git a/n-api/napi_create_buffer.md b/n-api/napi_create_buffer.md index 5202d3d9..1a96cd53 100644 --- a/n-api/napi_create_buffer.md +++ b/n-api/napi_create_buffer.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_buffer(napi_env env, size_t size, diff --git a/n-api/napi_create_buffer_copy.md b/n-api/napi_create_buffer_copy.md index 169b5712..c8ed286e 100644 --- a/n-api/napi_create_buffer_copy.md +++ b/n-api/napi_create_buffer_copy.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_buffer_copy(napi_env env, size_t length, diff --git a/n-api/napi_create_double.md b/n-api/napi_create_double.md index 0b5d2e72..97802953 100644 --- a/n-api/napi_create_double.md +++ b/n-api/napi_create_double.md @@ -2,6 +2,7 @@ added: v8.4.0 napiVersion: 1 --> + ```C napi_status napi_create_double(napi_env env, double value, napi_value* result) ``` diff --git a/n-api/napi_create_error.md b/n-api/napi_create_error.md index 679be2a8..69d8b2e7 100644 --- a/n-api/napi_create_error.md +++ b/n-api/napi_create_error.md @@ -2,12 +2,14 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_create_error(napi_env env, napi_value code, napi_value msg, napi_value* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional `napi_value` with the string for the error code to be associated with the error. diff --git a/n-api/napi_create_external.md b/n-api/napi_create_external.md index 3d892489..2ffc7322 100644 --- a/n-api/napi_create_external.md +++ b/n-api/napi_create_external.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_external(napi_env env, void* data, diff --git a/n-api/napi_create_external_arraybuffer.md b/n-api/napi_create_external_arraybuffer.md index 8a8a14d7..21a500b6 100644 --- a/n-api/napi_create_external_arraybuffer.md +++ b/n-api/napi_create_external_arraybuffer.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_external_arraybuffer(napi_env env, diff --git a/n-api/napi_create_external_buffer.md b/n-api/napi_create_external_buffer.md index d45e1469..96862529 100644 --- a/n-api/napi_create_external_buffer.md +++ b/n-api/napi_create_external_buffer.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_external_buffer(napi_env env, size_t length, diff --git a/n-api/napi_create_function.md b/n-api/napi_create_function.md index 1e727d3a..27b7c020 100644 --- a/n-api/napi_create_function.md +++ b/n-api/napi_create_function.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_function(napi_env env, const char* utf8name, @@ -36,6 +37,7 @@ to JavaScript, in order for the function to be accessible from script. In order to expose a function as part of the add-on's module exports, set the newly created function on the exports object. A sample module might look as follows: + ```C napi_value SayHello(napi_env env, napi_callback_info info) { printf("Hello\n"); @@ -59,6 +61,7 @@ NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) ``` Given the above code, the add-on can be used from JavaScript as follows: + ```js const myaddon = require('./addon'); myaddon.sayHello(); diff --git a/n-api/napi_create_int32.md b/n-api/napi_create_int32.md index deb4d2c9..dbc3d5a9 100644 --- a/n-api/napi_create_int32.md +++ b/n-api/napi_create_int32.md @@ -2,6 +2,7 @@ added: v8.4.0 napiVersion: 1 --> + ```C napi_status napi_create_int32(napi_env env, int32_t value, napi_value* result) ``` diff --git a/n-api/napi_create_int64.md b/n-api/napi_create_int64.md index b549bfa6..8b966b87 100644 --- a/n-api/napi_create_int64.md +++ b/n-api/napi_create_int64.md @@ -2,6 +2,7 @@ added: v8.4.0 napiVersion: 1 --> + ```C napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result) ``` diff --git a/n-api/napi_create_object.md b/n-api/napi_create_object.md index 993d1196..1941b23b 100644 --- a/n-api/napi_create_object.md +++ b/n-api/napi_create_object.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_object(napi_env env, napi_value* result) ``` diff --git a/n-api/napi_create_promise.md b/n-api/napi_create_promise.md index f71e20cd..50c808c9 100644 --- a/n-api/napi_create_promise.md +++ b/n-api/napi_create_promise.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C napi_status napi_create_promise(napi_env env, napi_deferred* deferred, diff --git a/n-api/napi_create_range_error.md b/n-api/napi_create_range_error.md index 67312443..bc2307ed 100644 --- a/n-api/napi_create_range_error.md +++ b/n-api/napi_create_range_error.md @@ -2,12 +2,14 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_create_range_error(napi_env env, napi_value code, napi_value msg, napi_value* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional `napi_value` with the string for the error code to be associated with the error. diff --git a/n-api/napi_create_reference.md b/n-api/napi_create_reference.md index ad07d1cc..0560054b 100644 --- a/n-api/napi_create_reference.md +++ b/n-api/napi_create_reference.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_create_reference(napi_env env, napi_value value, diff --git a/n-api/napi_create_string_latin1.md b/n-api/napi_create_string_latin1.md index e20f9963..5b6e1949 100644 --- a/n-api/napi_create_string_latin1.md +++ b/n-api/napi_create_string_latin1.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_string_latin1(napi_env env, const char* str, diff --git a/n-api/napi_create_string_utf16.md b/n-api/napi_create_string_utf16.md index d3cd0ecb..56544a52 100644 --- a/n-api/napi_create_string_utf16.md +++ b/n-api/napi_create_string_utf16.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_string_utf16(napi_env env, const char16_t* str, diff --git a/n-api/napi_create_string_utf8.md b/n-api/napi_create_string_utf8.md index 292f8416..ed2744a2 100644 --- a/n-api/napi_create_string_utf8.md +++ b/n-api/napi_create_string_utf8.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_string_utf8(napi_env env, const char* str, diff --git a/n-api/napi_create_symbol.md b/n-api/napi_create_symbol.md index 8978b6d2..6ea89fcd 100644 --- a/n-api/napi_create_symbol.md +++ b/n-api/napi_create_symbol.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_symbol(napi_env env, napi_value description, diff --git a/n-api/napi_create_threadsafe_function.md b/n-api/napi_create_threadsafe_function.md index 0e1ad94e..140a2dca 100644 --- a/n-api/napi_create_threadsafe_function.md +++ b/n-api/napi_create_threadsafe_function.md @@ -7,6 +7,7 @@ changes: pr-url: https://github.com/nodejs/node/pull/27791 description: Made `func` parameter optional with custom `call_js_cb`. --> + ```C NAPI_EXTERN napi_status napi_create_threadsafe_function(napi_env env, diff --git a/n-api/napi_create_type_error.md b/n-api/napi_create_type_error.md index 5daaa9a4..63070401 100644 --- a/n-api/napi_create_type_error.md +++ b/n-api/napi_create_type_error.md @@ -2,12 +2,14 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_create_type_error(napi_env env, napi_value code, napi_value msg, napi_value* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional `napi_value` with the string for the error code to be associated with the error. diff --git a/n-api/napi_create_typedarray.md b/n-api/napi_create_typedarray.md index a99ac537..48503903 100644 --- a/n-api/napi_create_typedarray.md +++ b/n-api/napi_create_typedarray.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_create_typedarray(napi_env env, napi_typedarray_type type, diff --git a/n-api/napi_create_uint32.md b/n-api/napi_create_uint32.md index a9f7d5d2..c4166aaf 100644 --- a/n-api/napi_create_uint32.md +++ b/n-api/napi_create_uint32.md @@ -2,6 +2,7 @@ added: v8.4.0 napiVersion: 1 --> + ```C napi_status napi_create_uint32(napi_env env, uint32_t value, napi_value* result) ``` diff --git a/n-api/napi_define_class.md b/n-api/napi_define_class.md index f6c95007..06135250 100644 --- a/n-api/napi_define_class.md +++ b/n-api/napi_define_class.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_define_class(napi_env env, const char* utf8name, diff --git a/n-api/napi_define_properties.md b/n-api/napi_define_properties.md index 344ffdce..8943d353 100644 --- a/n-api/napi_define_properties.md +++ b/n-api/napi_define_properties.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_define_properties(napi_env env, napi_value object, diff --git a/n-api/napi_delete_async_work.md b/n-api/napi_delete_async_work.md index 770446bb..57b3b4e9 100644 --- a/n-api/napi_delete_async_work.md +++ b/n-api/napi_delete_async_work.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_delete_async_work(napi_env env, napi_async_work work); diff --git a/n-api/napi_delete_element.md b/n-api/napi_delete_element.md index 199ebbc0..132cb817 100644 --- a/n-api/napi_delete_element.md +++ b/n-api/napi_delete_element.md @@ -2,6 +2,7 @@ added: v8.2.0 napiVersion: 1 --> + ```C napi_status napi_delete_element(napi_env env, napi_value object, diff --git a/n-api/napi_delete_property.md b/n-api/napi_delete_property.md index 12f70b9c..8c9d996a 100644 --- a/n-api/napi_delete_property.md +++ b/n-api/napi_delete_property.md @@ -2,6 +2,7 @@ added: v8.2.0 napiVersion: 1 --> + ```C napi_status napi_delete_property(napi_env env, napi_value object, diff --git a/n-api/napi_delete_reference.md b/n-api/napi_delete_reference.md index b5229c31..3b551a9a 100644 --- a/n-api/napi_delete_reference.md +++ b/n-api/napi_delete_reference.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_delete_reference(napi_env env, napi_ref ref); ``` diff --git a/n-api/napi_escape_handle.md b/n-api/napi_escape_handle.md index 4bd13b14..b948fc33 100644 --- a/n-api/napi_escape_handle.md +++ b/n-api/napi_escape_handle.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_escape_handle(napi_env env, napi_escapable_handle_scope scope, diff --git a/n-api/napi_extended_error_info.md b/n-api/napi_extended_error_info.md index b4735313..24f40d16 100644 --- a/n-api/napi_extended_error_info.md +++ b/n-api/napi_extended_error_info.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C typedef struct { const char* error_message; diff --git a/n-api/napi_fatal_error.md b/n-api/napi_fatal_error.md index e84c9de1..5a20e0df 100644 --- a/n-api/napi_fatal_error.md +++ b/n-api/napi_fatal_error.md @@ -2,6 +2,7 @@ added: v8.2.0 napiVersion: 1 --> + ```C NAPI_NO_RETURN void napi_fatal_error(const char* location, size_t location_len, diff --git a/n-api/napi_get_and_clear_last_exception.md b/n-api/napi_get_and_clear_last_exception.md index 711159c7..e968c174 100644 --- a/n-api/napi_get_and_clear_last_exception.md +++ b/n-api/napi_get_and_clear_last_exception.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_and_clear_last_exception(napi_env env, napi_value* result); diff --git a/n-api/napi_get_array_length.md b/n-api/napi_get_array_length.md index 2cb3526f..200207f9 100644 --- a/n-api/napi_get_array_length.md +++ b/n-api/napi_get_array_length.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_array_length(napi_env env, napi_value value, diff --git a/n-api/napi_get_arraybuffer_info.md b/n-api/napi_get_arraybuffer_info.md index e1d143d4..62300533 100644 --- a/n-api/napi_get_arraybuffer_info.md +++ b/n-api/napi_get_arraybuffer_info.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_arraybuffer_info(napi_env env, napi_value arraybuffer, diff --git a/n-api/napi_get_boolean.md b/n-api/napi_get_boolean.md index ea626c19..a2bf9b32 100644 --- a/n-api/napi_get_boolean.md +++ b/n-api/napi_get_boolean.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_boolean(napi_env env, bool value, napi_value* result) ``` diff --git a/n-api/napi_get_buffer_info.md b/n-api/napi_get_buffer_info.md index 3ba59184..e78dacc3 100644 --- a/n-api/napi_get_buffer_info.md +++ b/n-api/napi_get_buffer_info.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_buffer_info(napi_env env, napi_value value, diff --git a/n-api/napi_get_cb_info.md b/n-api/napi_get_cb_info.md index 9cfe8db5..de3ed0d9 100644 --- a/n-api/napi_get_cb_info.md +++ b/n-api/napi_get_cb_info.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_cb_info(napi_env env, napi_callback_info cbinfo, diff --git a/n-api/napi_get_element.md b/n-api/napi_get_element.md index 744958dd..8623f2f5 100644 --- a/n-api/napi_get_element.md +++ b/n-api/napi_get_element.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_element(napi_env env, napi_value object, diff --git a/n-api/napi_get_global.md b/n-api/napi_get_global.md index 8d6487d4..17241b12 100644 --- a/n-api/napi_get_global.md +++ b/n-api/napi_get_global.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_global(napi_env env, napi_value* result) ``` diff --git a/n-api/napi_get_last_error_info.md b/n-api/napi_get_last_error_info.md index d5a53de9..915216d6 100644 --- a/n-api/napi_get_last_error_info.md +++ b/n-api/napi_get_last_error_info.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_last_error_info(napi_env env, const napi_extended_error_info** result); ``` + - `[in] env`: The environment that the API is invoked under. - `[out] result`: The `napi_extended_error_info` structure with more information about the error. diff --git a/n-api/napi_get_named_property.md b/n-api/napi_get_named_property.md index 9cbb6b56..7b027032 100644 --- a/n-api/napi_get_named_property.md +++ b/n-api/napi_get_named_property.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_named_property(napi_env env, napi_value object, diff --git a/n-api/napi_get_new_target.md b/n-api/napi_get_new_target.md index 2925bb04..34d0e803 100644 --- a/n-api/napi_get_new_target.md +++ b/n-api/napi_get_new_target.md @@ -2,6 +2,7 @@ added: v8.6.0 napiVersion: 1 --> + ```C napi_status napi_get_new_target(napi_env env, napi_callback_info cbinfo, diff --git a/n-api/napi_get_null.md b/n-api/napi_get_null.md index 708b8568..798b9792 100644 --- a/n-api/napi_get_null.md +++ b/n-api/napi_get_null.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_null(napi_env env, napi_value* result) ``` diff --git a/n-api/napi_get_property.md b/n-api/napi_get_property.md index 14775834..b91e7a6f 100644 --- a/n-api/napi_get_property.md +++ b/n-api/napi_get_property.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_property(napi_env env, napi_value object, diff --git a/n-api/napi_get_property_names.md b/n-api/napi_get_property_names.md index 634cc132..641691a4 100644 --- a/n-api/napi_get_property_names.md +++ b/n-api/napi_get_property_names.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_property_names(napi_env env, napi_value object, diff --git a/n-api/napi_get_prototype.md b/n-api/napi_get_prototype.md index 1f84643e..295133ac 100644 --- a/n-api/napi_get_prototype.md +++ b/n-api/napi_get_prototype.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_prototype(napi_env env, napi_value object, diff --git a/n-api/napi_get_reference_value.md b/n-api/napi_get_reference_value.md index 7e284989..44327c61 100644 --- a/n-api/napi_get_reference_value.md +++ b/n-api/napi_get_reference_value.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_get_reference_value(napi_env env, napi_ref ref, diff --git a/n-api/napi_get_threadsafe_function_context.md b/n-api/napi_get_threadsafe_function_context.md index 59be8c00..1d855d83 100644 --- a/n-api/napi_get_threadsafe_function_context.md +++ b/n-api/napi_get_threadsafe_function_context.md @@ -3,6 +3,7 @@ added: v10.6.0 napiVersion: 4 --> + ```C NAPI_EXTERN napi_status napi_get_threadsafe_function_context(napi_threadsafe_function func, diff --git a/n-api/napi_get_typedarray_info.md b/n-api/napi_get_typedarray_info.md index 908dc41a..2cf66891 100644 --- a/n-api/napi_get_typedarray_info.md +++ b/n-api/napi_get_typedarray_info.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_typedarray_info(napi_env env, napi_value typedarray, diff --git a/n-api/napi_get_undefined.md b/n-api/napi_get_undefined.md index 95513167..d004b31b 100644 --- a/n-api/napi_get_undefined.md +++ b/n-api/napi_get_undefined.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_undefined(napi_env env, napi_value* result) ``` diff --git a/n-api/napi_get_uv_event_loop.md b/n-api/napi_get_uv_event_loop.md index 705950d6..38c23cc7 100644 --- a/n-api/napi_get_uv_event_loop.md +++ b/n-api/napi_get_uv_event_loop.md @@ -4,6 +4,7 @@ added: - v9.3.0 napiVersion: 2 --> + ```C NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env, uv_loop_t** loop); diff --git a/n-api/napi_get_value_bigint_int64.md b/n-api/napi_get_value_bigint_int64.md index 50f541c4..dc9755ce 100644 --- a/n-api/napi_get_value_bigint_int64.md +++ b/n-api/napi_get_value_bigint_int64.md @@ -24,4 +24,3 @@ returns `napi_bigint_expected`. This API returns the C `int64_t` primitive equivalent of the given JavaScript `BigInt`. If needed it will truncate the value, setting `lossless` to `false`. - diff --git a/n-api/napi_get_value_bigint_uint64.md b/n-api/napi_get_value_bigint_uint64.md index 3c3779f9..43cb60d1 100644 --- a/n-api/napi_get_value_bigint_uint64.md +++ b/n-api/napi_get_value_bigint_uint64.md @@ -24,4 +24,3 @@ returns `napi_bigint_expected`. This API returns the C `uint64_t` primitive equivalent of the given JavaScript `BigInt`. If needed it will truncate the value, setting `lossless` to `false`. - diff --git a/n-api/napi_get_value_bool.md b/n-api/napi_get_value_bool.md index 755289be..53492002 100644 --- a/n-api/napi_get_value_bool.md +++ b/n-api/napi_get_value_bool.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_bool(napi_env env, napi_value value, bool* result) ``` diff --git a/n-api/napi_get_value_double.md b/n-api/napi_get_value_double.md index 425b0040..b420f39e 100644 --- a/n-api/napi_get_value_double.md +++ b/n-api/napi_get_value_double.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_double(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_external.md b/n-api/napi_get_value_external.md index 6a0f2b40..082b71f8 100644 --- a/n-api/napi_get_value_external.md +++ b/n-api/napi_get_value_external.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_external(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_int32.md b/n-api/napi_get_value_int32.md index 0651c504..23aa6fff 100644 --- a/n-api/napi_get_value_int32.md +++ b/n-api/napi_get_value_int32.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_int32(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_int64.md b/n-api/napi_get_value_int64.md index 6592a643..b25f9619 100644 --- a/n-api/napi_get_value_int64.md +++ b/n-api/napi_get_value_int64.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_int64(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_string_latin1.md b/n-api/napi_get_value_string_latin1.md index 3650331d..cdbd84ee 100644 --- a/n-api/napi_get_value_string_latin1.md +++ b/n-api/napi_get_value_string_latin1.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_string_latin1(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_string_utf16.md b/n-api/napi_get_value_string_utf16.md index 656292ac..2483f4e8 100644 --- a/n-api/napi_get_value_string_utf16.md +++ b/n-api/napi_get_value_string_utf16.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_string_utf16(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_string_utf8.md b/n-api/napi_get_value_string_utf8.md index 8a8310ad..9753e627 100644 --- a/n-api/napi_get_value_string_utf8.md +++ b/n-api/napi_get_value_string_utf8.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_string_utf8(napi_env env, napi_value value, diff --git a/n-api/napi_get_value_uint32.md b/n-api/napi_get_value_uint32.md index b48a1f07..c446f8d6 100644 --- a/n-api/napi_get_value_uint32.md +++ b/n-api/napi_get_value_uint32.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_value_uint32(napi_env env, napi_value value, diff --git a/n-api/napi_get_version.md b/n-api/napi_get_version.md index c24df088..0af1ffe4 100644 --- a/n-api/napi_get_version.md +++ b/n-api/napi_get_version.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_get_version(napi_env env, uint32_t* result); diff --git a/n-api/napi_has_element.md b/n-api/napi_has_element.md index 54951796..5f97131d 100644 --- a/n-api/napi_has_element.md +++ b/n-api/napi_has_element.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_has_element(napi_env env, napi_value object, diff --git a/n-api/napi_has_named_property.md b/n-api/napi_has_named_property.md index 84c9ba1e..4d18ce5e 100644 --- a/n-api/napi_has_named_property.md +++ b/n-api/napi_has_named_property.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_has_named_property(napi_env env, napi_value object, diff --git a/n-api/napi_has_own_property.md b/n-api/napi_has_own_property.md index e9c91f51..48c5ba6d 100644 --- a/n-api/napi_has_own_property.md +++ b/n-api/napi_has_own_property.md @@ -2,6 +2,7 @@ added: v8.2.0 napiVersion: 1 --> + ```C napi_status napi_has_own_property(napi_env env, napi_value object, diff --git a/n-api/napi_has_property.md b/n-api/napi_has_property.md index 1eb5ae5f..5fb63b3c 100644 --- a/n-api/napi_has_property.md +++ b/n-api/napi_has_property.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_has_property(napi_env env, napi_value object, diff --git a/n-api/napi_instanceof.md b/n-api/napi_instanceof.md index f8cdd5d1..d56fce36 100644 --- a/n-api/napi_instanceof.md +++ b/n-api/napi_instanceof.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_instanceof(napi_env env, napi_value object, diff --git a/n-api/napi_is_array.md b/n-api/napi_is_array.md index d30d89b3..b408753a 100644 --- a/n-api/napi_is_array.md +++ b/n-api/napi_is_array.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_is_array(napi_env env, napi_value value, bool* result) ``` diff --git a/n-api/napi_is_arraybuffer.md b/n-api/napi_is_arraybuffer.md index 293db4d9..bf61712b 100644 --- a/n-api/napi_is_arraybuffer.md +++ b/n-api/napi_is_arraybuffer.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_is_arraybuffer(napi_env env, napi_value value, bool* result) ``` diff --git a/n-api/napi_is_buffer.md b/n-api/napi_is_buffer.md index 3e04938a..78275b9c 100644 --- a/n-api/napi_is_buffer.md +++ b/n-api/napi_is_buffer.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) ``` diff --git a/n-api/napi_is_error.md b/n-api/napi_is_error.md index 528ae009..e23efd87 100644 --- a/n-api/napi_is_error.md +++ b/n-api/napi_is_error.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_is_error(napi_env env, napi_value value, bool* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] value`: The `napi_value` to be checked. - `[out] result`: Boolean value that is set to true if `napi_value` represents diff --git a/n-api/napi_is_error_1.md b/n-api/napi_is_error_1.md index fd737082..0b2f3079 100644 --- a/n-api/napi_is_error_1.md +++ b/n-api/napi_is_error_1.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_is_error(napi_env env, napi_value value, bool* result) ``` diff --git a/n-api/napi_is_exception_pending.md b/n-api/napi_is_exception_pending.md index 8d0e1621..e4114a49 100644 --- a/n-api/napi_is_exception_pending.md +++ b/n-api/napi_is_exception_pending.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_is_exception_pending(napi_env env, bool* result); ``` diff --git a/n-api/napi_is_promise.md b/n-api/napi_is_promise.md index cec74b38..f2839d50 100644 --- a/n-api/napi_is_promise.md +++ b/n-api/napi_is_promise.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C napi_status napi_is_promise(napi_env env, napi_value promise, diff --git a/n-api/napi_is_typedarray.md b/n-api/napi_is_typedarray.md index 7ee3e0c3..2effe38e 100644 --- a/n-api/napi_is_typedarray.md +++ b/n-api/napi_is_typedarray.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_is_typedarray(napi_env env, napi_value value, bool* result) ``` diff --git a/n-api/napi_make_callback.md b/n-api/napi_make_callback.md index 22b6e0fe..fa4de144 100644 --- a/n-api/napi_make_callback.md +++ b/n-api/napi_make_callback.md @@ -5,6 +5,7 @@ changes: - version: v8.6.0 description: Added `async_context` parameter. --> + ```C napi_status napi_make_callback(napi_env env, napi_async_context async_context, diff --git a/n-api/napi_new_instance.md b/n-api/napi_new_instance.md index ab459e9b..68d05fc7 100644 --- a/n-api/napi_new_instance.md +++ b/n-api/napi_new_instance.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_new_instance(napi_env env, napi_value cons, @@ -22,6 +23,7 @@ which in this case is the constructed object. This method is used to instantiate a new JavaScript value using a given `napi_value` that represents the constructor for the object. For example, consider the following snippet: + ```js function MyObject(param) { this.param = param; @@ -32,6 +34,7 @@ const value = new MyObject(arg); ``` The following can be approximated in N-API using the following snippet: + ```C // Get the constructor function MyObject napi_value global, constructor, arg, value; diff --git a/n-api/napi_open_callback_scope.md b/n-api/napi_open_callback_scope.md index e10cd143..9154908a 100644 --- a/n-api/napi_open_callback_scope.md +++ b/n-api/napi_open_callback_scope.md @@ -2,12 +2,14 @@ added: v9.6.0 napiVersion: 3 --> + ```C NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env, napi_value resource_object, napi_async_context context, napi_callback_scope* result) ``` + - `[in] env`: The environment that the API is invoked under. - `[in] resource_object`: An object associated with the async work that will be passed to possible `async_hooks` [`init` hooks][]. diff --git a/n-api/napi_open_escapable_handle_scope.md b/n-api/napi_open_escapable_handle_scope.md index 0dbe31a8..8ce067ac 100644 --- a/n-api/napi_open_escapable_handle_scope.md +++ b/n-api/napi_open_escapable_handle_scope.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_open_escapable_handle_scope(napi_env env, napi_handle_scope* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[out] result`: `napi_value` representing the new scope. diff --git a/n-api/napi_open_handle_scope.md b/n-api/napi_open_handle_scope.md index b45e5873..f5787cc8 100644 --- a/n-api/napi_open_handle_scope.md +++ b/n-api/napi_open_handle_scope.md @@ -2,10 +2,12 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, napi_handle_scope* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[out] result`: `napi_value` representing the new scope. diff --git a/n-api/napi_property_attributes.md b/n-api/napi_property_attributes.md index a2281bbf..c4d86a73 100644 --- a/n-api/napi_property_attributes.md +++ b/n-api/napi_property_attributes.md @@ -1,3 +1,4 @@ + ```C typedef enum { napi_default = 0, diff --git a/n-api/napi_property_descriptor.md b/n-api/napi_property_descriptor.md index 446735aa..47c4d64e 100644 --- a/n-api/napi_property_descriptor.md +++ b/n-api/napi_property_descriptor.md @@ -1,3 +1,4 @@ + ```C typedef struct { // One of utf8name or name should be NULL. diff --git a/n-api/napi_queue_async_work.md b/n-api/napi_queue_async_work.md index 6f06d14c..6e956fd5 100644 --- a/n-api/napi_queue_async_work.md +++ b/n-api/napi_queue_async_work.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_queue_async_work(napi_env env, napi_async_work work); diff --git a/n-api/napi_ref_threadsafe_function.md b/n-api/napi_ref_threadsafe_function.md index f7d7eb6f..ddc931cd 100644 --- a/n-api/napi_ref_threadsafe_function.md +++ b/n-api/napi_ref_threadsafe_function.md @@ -3,6 +3,7 @@ added: v10.6.0 napiVersion: 4 --> + ```C NAPI_EXTERN napi_status napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); diff --git a/n-api/napi_reference_ref.md b/n-api/napi_reference_ref.md index 4da6ed75..e4a5ba1c 100644 --- a/n-api/napi_reference_ref.md +++ b/n-api/napi_reference_ref.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_reference_ref(napi_env env, napi_ref ref, int* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] ref`: `napi_ref` for which the reference count will be incremented. - `[out] result`: The new reference count. diff --git a/n-api/napi_reference_unref.md b/n-api/napi_reference_unref.md index b0013d82..a95d123a 100644 --- a/n-api/napi_reference_unref.md +++ b/n-api/napi_reference_unref.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_reference_unref(napi_env env, napi_ref ref, int* result); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] ref`: `napi_ref` for which the reference count will be decremented. - `[out] result`: The new reference count. diff --git a/n-api/napi_reject_deferred.md b/n-api/napi_reject_deferred.md index 7220c680..e83e1675 100644 --- a/n-api/napi_reject_deferred.md +++ b/n-api/napi_reject_deferred.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C napi_status napi_reject_deferred(napi_env env, napi_deferred deferred, diff --git a/n-api/napi_release_threadsafe_function.md b/n-api/napi_release_threadsafe_function.md index 3e5ce3b8..55d16669 100644 --- a/n-api/napi_release_threadsafe_function.md +++ b/n-api/napi_release_threadsafe_function.md @@ -3,6 +3,7 @@ added: v10.6.0 napiVersion: 4 --> + ```C NAPI_EXTERN napi_status napi_release_threadsafe_function(napi_threadsafe_function func, diff --git a/n-api/napi_remove_wrap.md b/n-api/napi_remove_wrap.md index 8ceeb3fb..c0f70468 100644 --- a/n-api/napi_remove_wrap.md +++ b/n-api/napi_remove_wrap.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C napi_status napi_remove_wrap(napi_env env, napi_value js_object, diff --git a/n-api/napi_resolve_deferred.md b/n-api/napi_resolve_deferred.md index fb30ca42..46f658d3 100644 --- a/n-api/napi_resolve_deferred.md +++ b/n-api/napi_resolve_deferred.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C napi_status napi_resolve_deferred(napi_env env, napi_deferred deferred, diff --git a/n-api/napi_run_script.md b/n-api/napi_run_script.md index ff6a6af9..caa78813 100644 --- a/n-api/napi_run_script.md +++ b/n-api/napi_run_script.md @@ -2,6 +2,7 @@ added: v8.5.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_run_script(napi_env env, napi_value script, diff --git a/n-api/napi_set_element.md b/n-api/napi_set_element.md index 4d8ca37e..46d71a73 100644 --- a/n-api/napi_set_element.md +++ b/n-api/napi_set_element.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_set_element(napi_env env, napi_value object, diff --git a/n-api/napi_set_named_property.md b/n-api/napi_set_named_property.md index fa6d8003..921e8076 100644 --- a/n-api/napi_set_named_property.md +++ b/n-api/napi_set_named_property.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_set_named_property(napi_env env, napi_value object, diff --git a/n-api/napi_set_property.md b/n-api/napi_set_property.md index 0e70d917..8c0eb3e6 100644 --- a/n-api/napi_set_property.md +++ b/n-api/napi_set_property.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_set_property(napi_env env, napi_value object, diff --git a/n-api/napi_status.md b/n-api/napi_status.md index 645daef4..89bc7a8e 100644 --- a/n-api/napi_status.md +++ b/n-api/napi_status.md @@ -4,6 +4,7 @@ napiVersion: 1 --> Integral status code indicating the success or failure of a N-API call. Currently, the following status codes are supported. + ```C typedef enum { napi_ok, @@ -27,6 +28,7 @@ typedef enum { napi_date_expected, } napi_status; ``` + If additional information is required upon an API returning a failed status, it can be obtained by calling `napi_get_last_error_info`. diff --git a/n-api/napi_strict_equals.md b/n-api/napi_strict_equals.md index 32665a90..63efd83d 100644 --- a/n-api/napi_strict_equals.md +++ b/n-api/napi_strict_equals.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_strict_equals(napi_env env, napi_value lhs, diff --git a/n-api/napi_threadsafe_function_call_js.md b/n-api/napi_threadsafe_function_call_js.md index 565b6461..cae034f5 100644 --- a/n-api/napi_threadsafe_function_call_js.md +++ b/n-api/napi_threadsafe_function_call_js.md @@ -18,12 +18,14 @@ sufficient to call the JavaScript function via `napi_call_function` rather than via `napi_make_callback`. Callback functions must satisfy the following signature: + ```C typedef void (*napi_threadsafe_function_call_js)(napi_env env, napi_value js_callback, void* context, void* data); ``` + - `[in] env`: The environment to use for API calls, or `NULL` if the thread-safe function is being torn down and `data` may need to be freed. - `[in] js_callback`: The JavaScript function to call, or `NULL` if the diff --git a/n-api/napi_threadsafe_function_call_mode.md b/n-api/napi_threadsafe_function_call_mode.md index 34f9e4a2..1ef7c581 100644 --- a/n-api/napi_threadsafe_function_call_mode.md +++ b/n-api/napi_threadsafe_function_call_mode.md @@ -6,6 +6,7 @@ napiVersion: 4 A value to be given to `napi_call_threadsafe_function()` to indicate whether the call should block whenever the queue associated with the thread-safe function is full. + ```C typedef enum { napi_tsfn_nonblocking, diff --git a/n-api/napi_threadsafe_function_release_mode.md b/n-api/napi_threadsafe_function_release_mode.md index ab016285..181463ad 100644 --- a/n-api/napi_threadsafe_function_release_mode.md +++ b/n-api/napi_threadsafe_function_release_mode.md @@ -7,6 +7,7 @@ A value to be given to `napi_release_threadsafe_function()` to indicate whether the thread-safe function is to be closed immediately (`napi_tsfn_abort`) or merely released (`napi_tsfn_release`) and thus available for subsequent use via `napi_acquire_threadsafe_function()` and `napi_call_threadsafe_function()`. + ```C typedef enum { napi_tsfn_release, diff --git a/n-api/napi_throw.md b/n-api/napi_throw.md index 912f1b38..675320f5 100644 --- a/n-api/napi_throw.md +++ b/n-api/napi_throw.md @@ -2,9 +2,11 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_throw(napi_env env, napi_value error); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] error`: The JavaScript value to be thrown. diff --git a/n-api/napi_throw_error.md b/n-api/napi_throw_error.md index 07c740ee..8f71d334 100644 --- a/n-api/napi_throw_error.md +++ b/n-api/napi_throw_error.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_throw_error(napi_env env, const char* code, const char* msg); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional error code to be set on the error. - `[in] msg`: C string representing the text to be associated with diff --git a/n-api/napi_throw_range_error.md b/n-api/napi_throw_range_error.md index 97dc9eee..2f94c3a0 100644 --- a/n-api/napi_throw_range_error.md +++ b/n-api/napi_throw_range_error.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, const char* code, const char* msg); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional error code to be set on the error. - `[in] msg`: C string representing the text to be associated with diff --git a/n-api/napi_throw_type_error.md b/n-api/napi_throw_type_error.md index 3fdb23e5..6b4fc977 100644 --- a/n-api/napi_throw_type_error.md +++ b/n-api/napi_throw_type_error.md @@ -2,11 +2,13 @@ added: v8.0.0 napiVersion: 1 --> + ```C NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, const char* code, const char* msg); ``` + - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional error code to be set on the error. - `[in] msg`: C string representing the text to be associated with diff --git a/n-api/napi_typedarray_type.md b/n-api/napi_typedarray_type.md index 6a931dcc..ac53753b 100644 --- a/n-api/napi_typedarray_type.md +++ b/n-api/napi_typedarray_type.md @@ -1,3 +1,4 @@ + ```C typedef enum { napi_int8_array, diff --git a/n-api/napi_typeof.md b/n-api/napi_typeof.md index 3cbbc80b..e6d5a584 100644 --- a/n-api/napi_typeof.md +++ b/n-api/napi_typeof.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_typeof(napi_env env, napi_value value, napi_valuetype* result) ``` diff --git a/n-api/napi_unref_threadsafe_function.md b/n-api/napi_unref_threadsafe_function.md index 91e3da10..5abd863e 100644 --- a/n-api/napi_unref_threadsafe_function.md +++ b/n-api/napi_unref_threadsafe_function.md @@ -3,6 +3,7 @@ added: v10.6.0 napiVersion: 4 --> + ```C NAPI_EXTERN napi_status napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); diff --git a/n-api/napi_unwrap.md b/n-api/napi_unwrap.md index 59b107a3..f3b8a2c7 100644 --- a/n-api/napi_unwrap.md +++ b/n-api/napi_unwrap.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_unwrap(napi_env env, napi_value js_object, diff --git a/n-api/napi_valuetype.md b/n-api/napi_valuetype.md index ab07090a..dc05063b 100644 --- a/n-api/napi_valuetype.md +++ b/n-api/napi_valuetype.md @@ -1,3 +1,4 @@ + ```C typedef enum { // ES6 types (corresponds to typeof) diff --git a/n-api/napi_wrap.md b/n-api/napi_wrap.md index 8e396e8d..ca6c606f 100644 --- a/n-api/napi_wrap.md +++ b/n-api/napi_wrap.md @@ -2,6 +2,7 @@ added: v8.0.0 napiVersion: 1 --> + ```C napi_status napi_wrap(napi_env env, napi_value js_object, diff --git a/n-api/promises.md b/n-api/promises.md index 012fa843..601a925e 100644 --- a/n-api/promises.md +++ b/n-api/promises.md @@ -10,6 +10,7 @@ deferred object that is created by `napi_create_promise()` is freed by be returned to JavaScript where it can be used in the usual fashion. For example, to create a promise and pass it to an asynchronous worker: + ```c napi_deferred deferred; napi_value promise; @@ -29,6 +30,7 @@ return promise; The above function `do_something_asynchronous()` would perform its asynchronous action and then it would resolve or reject the deferred, thereby concluding the promise and freeing the deferred: + ```c napi_deferred deferred; napi_value undefined; diff --git a/n-api/return_values.md b/n-api/return_values.md index 4aa5c1cd..cd702750 100644 --- a/n-api/return_values.md +++ b/n-api/return_values.md @@ -28,6 +28,7 @@ The format of the `napi_extended_error_info` structure is as follows: added: v10.6.0 napiVersion: 4 --> + ```C typedef struct napi_extended_error_info { const char* error_message; @@ -36,6 +37,7 @@ typedef struct napi_extended_error_info { napi_status error_code; }; ``` + - `error_message`: Textual representation of the error that occurred. - `engine_reserved`: Opaque handle reserved for engine use only. - `engine_error_code`: VM specific error code. diff --git a/n-api/working_with_javascript_properties.md b/n-api/working_with_javascript_properties.md index 1a35e508..ef7f79db 100644 --- a/n-api/working_with_javascript_properties.md +++ b/n-api/working_with_javascript_properties.md @@ -22,11 +22,14 @@ get and set properties on arbitrary JavaScript objects represented by `napi_value`. For instance, consider the following JavaScript code snippet: + ```js const obj = {}; obj.myProp = 123; ``` + The equivalent can be done using N-API values with the following snippet: + ```C napi_status status = napi_generic_failure; @@ -46,11 +49,14 @@ if (status != napi_ok) return status; Indexed properties can be set in a similar manner. Consider the following JavaScript snippet: + ```js const arr = []; arr[123] = 'hello'; ``` + The equivalent can be done using N-API values with the following snippet: + ```C napi_status status = napi_generic_failure; @@ -70,12 +76,14 @@ if (status != napi_ok) return status; Properties can be retrieved using the APIs described in this section. Consider the following JavaScript snippet: + ```js const arr = []; const value = arr[123]; ``` The following is the approximate equivalent of the N-API counterpart: + ```C napi_status status = napi_generic_failure; @@ -91,6 +99,7 @@ if (status != napi_ok) return status; Finally, multiple properties can also be defined on an object for performance reasons. Consider the following JavaScript: + ```js const obj = {}; Object.defineProperties(obj, { @@ -100,6 +109,7 @@ Object.defineProperties(obj, { ``` The following is the approximate equivalent of the N-API counterpart: + ```C napi_status status = napi_status_generic_failure; diff --git a/net/class_net_server.md b/net/class_net_server.md index 69bc709f..2cf44281 100644 --- a/net/class_net_server.md +++ b/net/class_net_server.md @@ -1,5 +1,8 @@ -这个类用于创建 TCP 或 [IPC][] server。 + +* 继承自: {EventEmitter} + +此类用于创建 TCP 或 [IPC] 服务器。 diff --git a/net/class_net_socket.md b/net/class_net_socket.md index f8f4fe09..f1381b10 100644 --- a/net/class_net_socket.md +++ b/net/class_net_socket.md @@ -2,13 +2,15 @@ added: v0.3.4 --> +* 继承自: {stream.Duplex} + 此类是 TCP 套接字或流式 [IPC] 端点的抽象(在 Windows 上使用命名管道,否则使用 Unix 域套接字)。 -`net.Socket` 也是[双工流][duplex stream],因此它既可读也可写,也是一个 [`EventEmitter`]。 +它也是一个 [`EventEmitter`]。 -`net.Socket` 可以由用户创建并直接用于与服务器交互。 -例如,它由 [`net.createConnection()`] 返回,因此用户可以使用它与服务器通信。 +`net.Socket` 可以由用户创建并且直接地与服务器进行交互。 +例如,它由 [`net.createConnection()`] 返回,因此用户可以使用它与服务器进行通信。 它也可以由 Node.js 创建,并在收到连接时传给用户。 -例如,它被传给 [`net.Server`] 上触发的 [`'connection'`] 事件的监听器,因此用户可以使用它与客户端进行交互。 +例如,将它传给 [`net.Server`] 上触发的 [`'connection'`] 事件的监听器,因此用户可以使用它与客户端进行交互。 diff --git a/net/socket_connect_options_connectlistener.md b/net/socket_connect_options_connectlistener.md index 45e6126c..237dcacd 100644 --- a/net/socket_connect_options_connectlistener.md +++ b/net/socket_connect_options_connectlistener.md @@ -1,6 +1,9 @@ * `options` {Object} -* `connectListener` {Function} [`socket.connect()`][] 的通用参数。将会被添加为 [`'connect'`][] 事件的监听器。 -* 返回: {net.Socket} Socket 自身。 +* `connectListener` {Function} [`socket.connect()`] 方法的通用参数。将会作为 [`'connect'`] 事件的监听器被添加一次。 +* 返回: {net.Socket} 套接字自身。 -在给定的 socket 上初始化一个连接。通常该方法是不需要的,应该使用 [`net.createConnection()`][] 来创建和打开 socket。一般只在实现一个自定义的 Socket 的时候使用该方法。 +在给定的套接字上启动连接。 +通常不需要此方法,应该使用 [`net.createConnection()`] 来创建和打开套接字。 +仅在实现自定义的套接字时才使用此方法。 +对于 TCP 连接,可用的 `options` 有: -对于 TCP 连接可能的 `options` 有: - -* `port` {number} 必须。Socket 连接的端口。 -* `host` {string} Socket 连接的主机。**默认值:** `'localhost'`。 -* `localAddress` {string} Socket 连接的本地地址。 -* `localPort` {number} Socket 连接的本地端口。 -* `family` {number} IP 栈的版本。 必须为 `4`、`6` 或 `0`。`0` 值表示允许 IPv4 和 IPv6 地址。**默认值:** `0`。 +* `port` {number} 必须。套接字要连接的端口。 +* `host` {string} 套接字要连接的主机。**默认值:** `'localhost'`。 +* `localAddress` {string} 套接字要连接的本地地址。 +* `localPort` {number} 套接字要连接的本地端口。 +* `family` {number} IP 栈的版本。必须为 `4`、`6` 或 `0`。`0` 值表示允许 IPv4 和 IPv6 地址。**默认值:** `0`。 * `hints` {number} 可选的 [`dns.lookup()` 提示][`dns.lookup()` hints]。 -* `lookup` {Function} 自定义的 lookup 方法。**默认值:** [`dns.lookup()`]。 - -对于 [IPC][] 连接可能的 `options` 有: - -* `path` {string} 必须。客户端连接的路径。查看[识别IPC连接的路径][Identifying paths for IPC connections]。如果提供了,则以上的 TCP 选项都会被忽略。 +* `lookup` {Function} 自定义的查找函数。**默认值:** [`dns.lookup()`]。 + +对于 [IPC] 连接,可用的 `options` 有: + +* `path` {string} 必须。客户端要连接的路径。参阅[识别 IPC 连接的路径][Identifying paths for IPC connections]。如果提供了,则忽略上面的 TCP 特定的选项。 + +对于这两种类型,可用 `options` 包括: + +* `onread` {Object} - 如果指定,则传入的数据会存储在单个 `buffer` 中,并在数据到达套接字时传给提供的 `callback`。 + 这将会导致流式的功能不会提供任何数据,但 `'error'`、`'end'` 和 `'close'` 等事件仍将会被正常触发,且 `pause()` 和 `resume()` 等方法也将会按预期运行。 + * `buffer` {Buffer|Uint8Array|Function} - 用于存储传入数据的可复用的内存块、或返回此类数据的函数。 + * `callback` {Function} 为每个传入的数据块调用此函数。有两个参数传给它:写入 `buffer` 的字节数和对 `buffer` 的引用。从此函数返回 `false` 可以隐式地 `pause()` 套接字。该函数将会在全局的上下文中执行。 + +以下是使用 `onread` 选项的客户端的示例: + +```js +const net = require('net'); +net.connect({ + port: 80, + onread: { + // 为套接字的每次读取复用 4KiB 的 Buffer。 + buffer: Buffer.alloc(4 * 1024), + callback: function(nread, buf) { + // 收到的数据在 `buf` 中可用,从 0 到 'nread`。 + console.log(buf.toString('utf8', 0, nread)); + } + } +}); +``` diff --git a/net/socket_connect_path_connectlistener.md b/net/socket_connect_path_connectlistener.md index cef46dc2..e217486b 100644 --- a/net/socket_connect_path_connectlistener.md +++ b/net/socket_connect_path_connectlistener.md @@ -1,10 +1,12 @@ -* `path` {string} 客户端连接的路径。查看[识别 IPC 连接的路径][Identifying paths for IPC connections]。 -* `connectListener` {Function} [`socket.connect()`][] 方法的通用参数。将被添加为 [`'connect'`][] 事件的监听器。 -* 返回: {net.Socket} Socket 自身。 +* `path` {string} 客户端要连接的路径。参阅[识别 IPC 连接的路径][Identifying paths for IPC connections]。 +* `connectListener` {Function} [`socket.connect()`] 方法的通用参数。将会作为 [`'connect'`] 事件的监听器被添加一次。 +* 返回: {net.Socket} 套接字自身。 -在给定的 socket 上初始化 [IPC] 连接。 -相当使用 `{ path: path }` 作为 `options` 调用 [`socket.connect(options[, connectListener])`][`socket.connect(options)`] 方法的别名。 +在给定的套接字上启动 [IPC] 连接。 + + +使用 `{ path: path }` 作为 `options` 调用 [`socket.connect(options[, connectListener])`][`socket.connect(options)`] 的别名。 diff --git a/net/socket_connect_port_host_connectlistener.md b/net/socket_connect_port_host_connectlistener.md index 336e41de..156e1cf1 100644 --- a/net/socket_connect_port_host_connectlistener.md +++ b/net/socket_connect_port_host_connectlistener.md @@ -2,12 +2,13 @@ added: v0.1.90 --> -* `port` {number} 客户端连接的端口。 -* `host` {string} 客户端连接的主机。 -* `connectListener` {Function} [`socket.connect()`][] 方法的通用参数。将会被添加为 [`'connect'`][] 事件的监听器。 -* 返回: {net.Socket} Socket 本身。 +* `port` {number} 客户端要连接的端口。 +* `host` {string} 客户端要连接的主机。 +* `connectListener` {Function} [`socket.connect()`] 方法的通用参数。将会作为 [`'connect'`] 事件的监听器被添加一次。 +* 返回: {net.Socket} 套接字自身。 -在给定的 socket 上初始化一个 TCP 连接。 -使用 `{port: port, host: host}` 作为 `options` 调用 [`socket.connect(options[, connectListener])`][`socket.connect(options)`] 方法的别名。 +在给定的套接字上启动 TCP 连接。 + +使用 `{port: port, host: host}` 作为 `options` 调用 [`socket.connect(options[, connectListener])`][`socket.connect(options)`] 的别名。 diff --git a/perf_hooks/new_performanceobserver_callback.md b/perf_hooks/new_performanceobserver_callback.md index 2799a0c7..0578b197 100644 --- a/perf_hooks/new_performanceobserver_callback.md +++ b/perf_hooks/new_performanceobserver_callback.md @@ -23,6 +23,7 @@ obs.observe({ entryTypes: ['mark'], buffered: true }); performance.mark('test'); ``` + Because `PerformanceObserver` instances introduce their own additional performance overhead, instances should not be left subscribed to notifications indefinitely. Users should disconnect observers as soon as they are no diff --git a/policy/example_patched_dependency.md b/policy/example_patched_dependency.md index 35d96fdb..538c8d15 100644 --- a/policy/example_patched_dependency.md +++ b/policy/example_patched_dependency.md @@ -18,4 +18,3 @@ module.exports = function fn(...args) { ``` - diff --git a/readline/class_interface.md b/readline/class_interface.md index 476c4a63..70800182 100644 --- a/readline/class_interface.md +++ b/readline/class_interface.md @@ -2,6 +2,8 @@ added: v0.1.104 --> +* 继承自: {EventEmitter} + `readline.Interface` 类的实例是使用 `readline.createInterface()` 方法构造的。 每个实例都关联一个 `input` [可读流][Readable]和一个 `output` [可写流][Writable]。 `output` 流用于为到达的用户输入打印提示,并从 `input` 流读取。 diff --git a/repl/class_replserver.md b/repl/class_replserver.md index 5a642dab..477d4233 100644 --- a/repl/class_replserver.md +++ b/repl/class_replserver.md @@ -2,6 +2,7 @@ added: v0.1.91 --> -`repl.REPLServer` 类继承自 [`readline.Interface`] 类。 -`repl.REPLServer` 的实例由 `repl.start()` 方法创建,不能直接使用 JavaScript 的 `new` 关键字创建。 +* 继承自: {readline.Interface} + +`repl.REPLServer` 的实例是使用 `repl.start()` 方法创建的,不能直接地使用 JavaScript 的 `new` 关键字创建。 diff --git a/tls/certificate_object.md b/tls/certificate_object.md index 33f79140..49b2770c 100644 --- a/tls/certificate_object.md +++ b/tls/certificate_object.md @@ -56,6 +56,7 @@ For EC keys, the following properties may be defined: `'P-256'`. Example certificate: + ```text { subject: { OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ], diff --git a/tls/class_tls_server.md b/tls/class_tls_server.md index 984e95b2..d6ea5f16 100644 --- a/tls/class_tls_server.md +++ b/tls/class_tls_server.md @@ -2,5 +2,7 @@ added: v0.3.2 --> -`tls.Server` 类是 `net.Server` 的子类,接受使用 TLS 或者 SSL 的加密连接。 +* 继承自: {net.Server} + +接受使用 TLS 或 SSL 的加密连接。 diff --git a/tls/class_tls_tlssocket.md b/tls/class_tls_tlssocket.md index cd364098..dd3956e6 100644 --- a/tls/class_tls_tlssocket.md +++ b/tls/class_tls_tlssocket.md @@ -2,8 +2,10 @@ added: v0.11.4 --> -The `tls.TLSSocket` is a subclass of [`net.Socket`][] that performs transparent -encryption of written data and all required TLS negotiation. +* Extends: {net.Socket} + +Performs transparent encryption of written data and all required TLS +negotiation. Instances of `tls.TLSSocket` implement the duplex [Stream][] interface. diff --git a/tls/tls_createsecurecontext_options.md b/tls/tls_createsecurecontext_options.md index 625eeccb..b8c86a70 100644 --- a/tls/tls_createsecurecontext_options.md +++ b/tls/tls_createsecurecontext_options.md @@ -90,10 +90,11 @@ changes: PEM allows the option of private keys being encrypted. Encrypted keys will be decrypted with `options.passphrase`. Multiple keys using different algorithms can be provided either as an array of unencrypted key strings or - buffers, or an array of objects in the form `{pem: [, - passphrase: ]}`. The object form can only occur in an array. - `object.passphrase` is optional. Encrypted keys will be decrypted with - `object.passphrase` if provided, or `options.passphrase` if it is not. + buffers, or an array of objects in the form + `{pem: [, passphrase: ]}`. The object form can only + occur in an array. `object.passphrase` is optional. Encrypted keys will be + decrypted with `object.passphrase` if provided, or `options.passphrase` if + it is not. * `maxVersion` {string} Optionally set the maximum TLS version to allow. One of `TLSv1.3`, `TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option, use one or the other. diff --git a/tls/tls_default_max_version.md b/tls/tls_default_max_version.md index abd7c1b9..24fc53fb 100644 --- a/tls/tls_default_max_version.md +++ b/tls/tls_default_max_version.md @@ -10,4 +10,3 @@ added: v11.4.0 the default to `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used. - diff --git a/tls/tls_default_min_version.md b/tls/tls_default_min_version.md index 78805183..63a10d7e 100644 --- a/tls/tls_default_min_version.md +++ b/tls/tls_default_min_version.md @@ -11,4 +11,3 @@ added: v11.4.0 `'TLSv1.3'`. If multiple of the options are provided, the lowest minimum is used. - diff --git a/tty/class_tty_readstream.md b/tty/class_tty_readstream.md index c1586a79..e346c064 100644 --- a/tty/class_tty_readstream.md +++ b/tty/class_tty_readstream.md @@ -2,6 +2,8 @@ added: v0.5.8 --> -`tty.ReadStream` 类是 [`net.Socket`] 的子类,表示 TTY 的可读端。 -在正常情况下,[`process.stdin`] 将是 Node.js 进程中唯一的 `tty.ReadStream` 实例,并且没有理由创建其他实例。 +* 继承自: {net.Socket} + +代表 TTY 的可读端。 +在正常情况中,[`process.stdin`] 将会是 Node.js 进程中唯一的 `tty.ReadStream` 实例,并且没有理由创建其他的实例。 diff --git a/tty/class_tty_writestream.md b/tty/class_tty_writestream.md index fd23afbb..dc5e33fb 100644 --- a/tty/class_tty_writestream.md +++ b/tty/class_tty_writestream.md @@ -2,6 +2,8 @@ added: v0.5.8 --> -`tty.WriteStream` 类是 [`net.Socket`] 的子类,表示 TTY 的可写端。 -在正常情况下,[`process.stdout`] 和 [`process.stderr`] 将是为 Node.js 进程创建的唯一 `tty.WriteStream` 实例,并且没有理由创建其他实例。 +* 继承自: {net.Socket} + +代表 TTY 的可写端。 +在正常情况中,[`process.stdout`] 和 [`process.stderr`] 将会是为 Node.js 进程创建的唯一的 `tty.WriteStream` 实例,并且没有理由创建其他的实例。 diff --git a/util/custom_promisified_functions.md b/util/custom_promisified_functions.md index c678042f..bc20389b 100644 --- a/util/custom_promisified_functions.md +++ b/util/custom_promisified_functions.md @@ -31,6 +31,7 @@ doSomething[util.promisify.custom] = (foo) => { }); }; ``` + If `promisify.custom` is defined but is not a function, `promisify()` will throw an error. diff --git a/vm/module_link_linker.md b/vm/module_link_linker.md index 59593286..69c86438 100644 --- a/vm/module_link_linker.md +++ b/vm/module_link_linker.md @@ -6,6 +6,7 @@ import foo from 'foo'; // ^^^^^ the module specifier ``` + * `referencingModule` {vm.SourceTextModule} The `Module` object `link()` is called on. * Returns: {vm.SourceTextModule|Promise}