Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
```
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)):

Expand Down
2 changes: 1 addition & 1 deletion doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ the `wasm:js-string` `length` builtin:
)

;; Export the getLength function.
(export "getLength" (func $get_length))
(export "getLength" (func $getLength))
)
```

Expand Down
12 changes: 7 additions & 5 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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]),
Expand Down
2 changes: 0 additions & 2 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down
14 changes: 7 additions & 7 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ readable.on('readable', () => {
});

readable.on('end', () => {
const content = chunks.join('');
const content = Buffer.concat(chunks).toString('utf8');
});
```

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)`
Expand Down Expand Up @@ -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();
```

Expand Down
20 changes: 12 additions & 8 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,9 @@ const customReporter = new Transform({
callback(null, `total line count: ${totalLineCount}\n`);
break;
}
default:
callback();
break;
}
},
});
Expand Down Expand Up @@ -1593,6 +1596,9 @@ const customReporter = new Transform({
callback(null, `total line count: ${totalLineCount}\n`);
break;
}
default:
callback();
break;
}
},
});
Expand Down Expand Up @@ -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;
Expand All @@ -3412,17 +3418,16 @@ 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]);
});
```

```cjs
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;
Expand All @@ -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]);
});
```

Expand Down
17 changes: 5 additions & 12 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])`

Expand Down Expand Up @@ -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()`][].
Expand Down
2 changes: 1 addition & 1 deletion doc/api/webcrypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2446,7 +2446,7 @@ changes:
description: Renamed `kmacParams.length` to `kmacParams.outputLength`.
-->

#### `kmacParams.algorithm`
#### `kmacParams.name`

<!-- YAML
added: v24.8.0
Expand Down