diff --git a/doc/api/cli.md b/doc/api/cli.md index 52ea6f3f10e1..db5e90c28df2 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -867,9 +867,6 @@ in the `$schema` must be replaced with the version of Node.js you are using or }, "test": { "test-isolation": "process" - }, - "watch": { - "watch-preserve-output": true } } ``` @@ -964,7 +961,7 @@ For example, the configuration file above is equivalent to the following command-line arguments: ```bash -node --import amaro/strip --watch-path=src --watch-preserve-output --test-isolation=process +node --import amaro/strip --watch-path=src --watch-preserve-output --test --test-isolation=process ``` The priority in configuration is as follows: diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index b31bfffc11bc..36fa8a8bc78b 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1155,9 +1155,8 @@ Type: End-of-Life The `util.isDate()` API has been removed. Please use `arg instanceof Date` instead. -Also for stronger approaches, consider using: -`Date.prototype.toString.call(arg) === '[object Date]' && !isNaN(arg)`. -This can also be used in a `try/catch` block to handle invalid date objects. +For a check that also works across realms and rejects invalid dates, use: +`Object.prototype.toString.call(arg) === '[object Date]' && !isNaN(arg)`. An automated migration is available ([source](https://github.com/nodejs/userland-migrations/tree/main/recipes/util-is)): diff --git a/doc/api/esm.md b/doc/api/esm.md index bc4af89045f7..327a51f4e41d 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -813,7 +813,7 @@ the `wasm:js-string` `length` builtin: ) ;; Export the getLength function. - (export "getLength" (func $get_length)) + (export "getLength" (func $getLength)) ) ``` diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 6a435eb6f0ea..83bca22ad0b8 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2139,7 +2139,7 @@ for `NAPI_MODULE` and defining an `Init` function: ```c NAPI_MODULE_INIT(/* napi_env env, napi_value exports */) { napi_value answer; - napi_status result; + napi_status status; status = napi_create_int64(env, 42, &answer); if (status != napi_ok) return NULL; @@ -4563,7 +4563,7 @@ Object.defineProperties(obj, { The following is the approximate equivalent of the Node-API counterpart: ```c -napi_status status = napi_status_generic_failure; +napi_status status = napi_generic_failure; // const obj = {}; napi_value obj; @@ -4579,9 +4579,11 @@ if (status != napi_ok) return status; // Set the properties napi_property_descriptor descriptors[] = { - { "foo", NULL, NULL, NULL, NULL, fooValue, napi_writable | napi_configurable, NULL }, - { "bar", NULL, NULL, NULL, NULL, barValue, napi_writable | napi_configurable, NULL } -} + { "foo", NULL, NULL, NULL, NULL, fooValue, + napi_writable | napi_enumerable | napi_configurable, NULL }, + { "bar", NULL, NULL, NULL, NULL, barValue, + napi_writable | napi_enumerable | napi_configurable, NULL } +}; status = napi_define_properties(env, obj, sizeof(descriptors) / sizeof(descriptors[0]), diff --git a/doc/api/repl.md b/doc/api/repl.md index 7ce0951fcd04..0bd3fbb7fba3 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -1027,7 +1027,6 @@ sock.on('connect', () => { sock.on('close', () => { process.stdin.setRawMode(false); process.stdin.pause(); - sock.removeListener('close', done); }); process.stdin.on('end', () => { @@ -1059,7 +1058,6 @@ sock.on('connect', () => { sock.on('close', () => { process.stdin.setRawMode(false); process.stdin.pause(); - sock.removeListener('close', done); }); process.stdin.on('end', () => { diff --git a/doc/api/stream.md b/doc/api/stream.md index a676b98923df..b3634127c307 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1634,7 +1634,7 @@ readable.on('readable', () => { }); readable.on('end', () => { - const content = chunks.join(''); + const content = Buffer.concat(chunks).toString('utf8'); }); ``` @@ -2295,8 +2295,8 @@ const dnsResults = Readable.from([ 'openjsf.org', 'www.linuxfoundation.org', ]).filter(async (domain) => { - const { address } = await resolver.resolve4(domain, { ttl: true }); - return address.ttl > 60; + const records = await resolver.resolve4(domain, { ttl: true }); + return records.some(({ ttl }) => ttl > 60); }, { concurrency: 2 }); for await (const result of dnsResults) { // Logs domains with more than 60 seconds on the resolved dns record. @@ -2355,8 +2355,8 @@ const dnsResults = Readable.from([ 'openjsf.org', 'www.linuxfoundation.org', ]).map(async (domain) => { - const { address } = await resolver.resolve4(domain, { ttl: true }); - return address; + const records = await resolver.resolve4(domain, { ttl: true }); + return records.map(({ address }) => address); }, { concurrency: 2 }); await dnsResults.forEach((result) => { // Logs result, similar to `for await (const result of dnsResults)` @@ -2402,8 +2402,8 @@ const dnsResults = await Readable.from([ 'openjsf.org', 'www.linuxfoundation.org', ]).map(async (domain) => { - const { address } = await resolver.resolve4(domain, { ttl: true }); - return address; + const records = await resolver.resolve4(domain, { ttl: true }); + return records.map(({ address }) => address); }, { concurrency: 2 }).toArray(); ``` diff --git a/doc/api/test.md b/doc/api/test.md index d3badba70bdd..c31c0e4db49a 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1545,6 +1545,9 @@ const customReporter = new Transform({ callback(null, `total line count: ${totalLineCount}\n`); break; } + default: + callback(); + break; } }, }); @@ -1593,6 +1596,9 @@ const customReporter = new Transform({ callback(null, `total line count: ${totalLineCount}\n`); break; } + default: + callback(); + break; } }, }); @@ -3390,7 +3396,7 @@ is an `AsyncGenerator` and is also supported by this API: import assert from 'node:assert'; import { test } from 'node:test'; import nodeTimersPromises from 'node:timers/promises'; -test('should tick five times testing a real use case', async (context) => { +test('should tick three times testing a real use case', async (context) => { context.mock.timers.enable({ apis: ['setInterval'] }); const expectedIterations = 3; @@ -3412,9 +3418,8 @@ test('should tick five times testing a real use case', async (context) => { const timeResults = await r; assert.strictEqual(timeResults.length, expectedIterations); - for (let it = 1; it < expectedIterations; it++) { - assert.strictEqual(timeResults[it - 1], startedAt + (interval * it)); - } + // setInterval() yields its value argument on every tick. + assert.deepStrictEqual(timeResults, [startedAt, startedAt, startedAt]); }); ``` @@ -3422,7 +3427,7 @@ test('should tick five times testing a real use case', async (context) => { const assert = require('node:assert'); const { test } = require('node:test'); const nodeTimersPromises = require('node:timers/promises'); -test('should tick five times testing a real use case', async (context) => { +test('should tick three times testing a real use case', async (context) => { context.mock.timers.enable({ apis: ['setInterval'] }); const expectedIterations = 3; @@ -3444,9 +3449,8 @@ test('should tick five times testing a real use case', async (context) => { const timeResults = await r; assert.strictEqual(timeResults.length, expectedIterations); - for (let it = 1; it < expectedIterations; it++) { - assert.strictEqual(timeResults[it - 1], startedAt + (interval * it)); - } + // setInterval() yields its value argument on every tick. + assert.deepStrictEqual(timeResults, [startedAt, startedAt, startedAt]); }); ``` diff --git a/doc/api/tls.md b/doc/api/tls.md index 032aa4764175..48feff514b13 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1942,12 +1942,9 @@ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \ -keyout client-key.pem -out client-cert.pem ``` -Then, to generate the `server-cert.pem` certificate for this example, run: - -```bash -openssl pkcs12 -certpbe AES-256-CBC -export -out server-cert.pem \ - -inkey client-key.pem -in client-cert.pem -``` +`server-key.pem` and `server-cert.pem` are generated as shown for the echo +server in [`tls.createServer()`][]; the client trusts `server-cert.pem` as its +`ca`. ## `tls.connect(path[, options][, callback])` @@ -2374,12 +2371,8 @@ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \ -keyout server-key.pem -out server-cert.pem ``` -Then, to generate the `client-cert.pem` certificate for this example, run: - -```bash -openssl pkcs12 -certpbe AES-256-CBC -export -out client-cert.pem \ - -inkey server-key.pem -in server-cert.pem -``` +`client-key.pem` and `client-cert.pem` are generated as shown for the example +client in [`tls.connect()`][]; the server trusts `client-cert.pem` as its `ca`. The server can be tested by connecting to it using the example client from [`tls.connect()`][]. diff --git a/doc/api/webcrypto.md b/doc/api/webcrypto.md index 98df2850931f..64e02ce2de70 100644 --- a/doc/api/webcrypto.md +++ b/doc/api/webcrypto.md @@ -2446,7 +2446,7 @@ changes: description: Renamed `kmacParams.length` to `kmacParams.outputLength`. --> -#### `kmacParams.algorithm` +#### `kmacParams.name`