Skip to content

Commit 14eca5f

Browse files
authored
Merge branch 'master' into refactor-to-use-validate-object
2 parents d777cbc + 8c9dc4e commit 14eca5f

File tree

114 files changed

+1847
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1847
-439
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ module.exports = {
258258
'no-void': 'error',
259259
'no-whitespace-before-property': 'error',
260260
'no-with': 'error',
261+
'object-curly-newline': 'error',
261262
'object-curly-spacing': ['error', 'always'],
262263
'one-var': ['error', { initialized: 'never' }],
263264
'one-var-declaration-per-line': 'error',

.github/workflows/test-asan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
- name: Build
3838
run: make build-ci -j2 V=1
3939
- name: Test
40-
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions"
40+
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions -t 300"

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ release.
3232
</tr>
3333
<tr>
3434
<td valign="top">
35-
<b><a href="doc/changelogs/CHANGELOG_V15.md#15.6.0">15.6.0</a></b><br/>
35+
<b><a href="doc/changelogs/CHANGELOG_V15.md#15.7.0">15.7.0</a></b><br/>
36+
<a href="doc/changelogs/CHANGELOG_V15.md#15.6.0">15.6.0</a><br/>
3637
<a href="doc/changelogs/CHANGELOG_V15.md#15.5.1">15.5.1</a><br/>
3738
<a href="doc/changelogs/CHANGELOG_V15.md#15.5.0">15.5.0</a><br/>
3839
<a href="doc/changelogs/CHANGELOG_V15.md#15.4.0">15.4.0</a><br/>
@@ -106,7 +107,8 @@ release.
106107
<a href="doc/changelogs/CHANGELOG_V12.md#12.0.0">12.0.0</a><br/>
107108
</td>
108109
<td valign="top">
109-
<b><a href="doc/changelogs/CHANGELOG_V10.md#10.23.1">10.23.1</a></b><br/>
110+
<b><a href="doc/changelogs/CHANGELOG_V10.md#10.23.2">10.23.2</a></b><br/>
111+
<a href="doc/changelogs/CHANGELOG_V10.md#10.23.1">10.23.1</a><br/>
110112
<a href="doc/changelogs/CHANGELOG_V10.md#10.23.0">10.23.0</a><br/>
111113
<a href="doc/changelogs/CHANGELOG_V10.md#10.22.1">10.22.1</a><br/>
112114
<a href="doc/changelogs/CHANGELOG_V10.md#10.22.0">10.22.0</a><br/>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ For information about the governance of the Node.js project, see
355355
**Luigi Pinca** &lt;luigipinca@gmail.com&gt; (he/him)
356356
* [lundibundi](https://github.com/lundibundi) -
357357
**Denys Otrishko** &lt;shishugi@gmail.com&gt; (he/him)
358+
* [Lxxyx](https://github.com/Lxxyx) -
359+
**Zijian Liu** &lt;lxxyxzj@gmail.com&gt; (he/him)
358360
* [mafintosh](https://github.com/mafintosh) -
359361
**Mathias Buus** &lt;mathiasbuus@gmail.com&gt; (he/him)
360362
* [mcollina](https://github.com/mcollina) -

benchmark/compare.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ for (const filename of benchmarks) {
5656
// queue.length = binary.length * runs * benchmarks.length
5757

5858
// Print csv header
59-
console.log('"binary", "filename", "configuration", "rate", "time"');
59+
console.log('"binary","filename","configuration","rate","time"');
6060

6161
const kStartOfQueue = 0;
6262

@@ -85,8 +85,8 @@ if (showProgress) {
8585
// Escape quotes (") for correct csv formatting
8686
conf = conf.replace(/"/g, '""');
8787

88-
console.log(`"${job.binary}", "${job.filename}", "${conf}", ` +
89-
`${data.rate}, ${data.time}`);
88+
console.log(`"${job.binary}","${job.filename}","${conf}",` +
89+
`${data.rate},${data.time}`);
9090
if (showProgress) {
9191
// One item in the subqueue has been completed.
9292
progress.completeConfig(data);
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
'use strict';
2+
3+
// Exercise coverage of a class. Note, this logic is silly and exists solely
4+
// to generate branch coverage code paths:
5+
class CoveredClass {
6+
constructor(x, y, opts) {
7+
this.x = x;
8+
this.y = y;
9+
// Exercise coverage of nullish coalescing:
10+
this.opts = opts ?? (Math.random() > 0.5 ? {} : undefined);
11+
}
12+
add() {
13+
return this.x + this.y;
14+
}
15+
addSpecial() {
16+
// Exercise coverage of optional chains:
17+
if (this.opts?.special && this.opts?.special?.x && this.opts?.special?.y) {
18+
return this.opts.special.x + this.opts.special.y;
19+
}
20+
return add();
21+
}
22+
mult() {
23+
return this.x * this.y;
24+
}
25+
multSpecial() {
26+
if (this.opts?.special && this.opts?.special?.x && this.opts?.special?.y) {
27+
return this.opts.special.x * this.opts.special.y;
28+
}
29+
return mult();
30+
}
31+
}
32+
33+
// Excercise coverage of functions:
34+
function add(x, y) {
35+
const mt = new CoveredClass(x, y);
36+
return mt.add();
37+
}
38+
39+
function addSpecial(x, y) {
40+
let mt;
41+
if (Math.random() > 0.5) {
42+
mt = new CoveredClass(x, y);
43+
} else {
44+
mt = new CoveredClass(x, y, {
45+
special: {
46+
x: Math.random() * x,
47+
y: Math.random() * y
48+
}
49+
});
50+
}
51+
return mt.addSpecial();
52+
}
53+
54+
function mult(x, y) {
55+
const mt = new CoveredClass(x, y);
56+
return mt.mult();
57+
}
58+
59+
function multSpecial(x, y) {
60+
let mt;
61+
if (Math.random() > 0.5) {
62+
mt = new CoveredClass(x, y);
63+
} else {
64+
mt = new CoveredClass(x, y, {
65+
special: {
66+
x: Math.random() * x,
67+
y: Math.random() * y
68+
}
69+
});
70+
}
71+
return mt.multSpecial();
72+
}
73+
74+
for (let i = 0; i < parseInt(process.env.N); i++) {
75+
const operations = ['add', 'addSpecial', 'mult', 'multSpecial'];
76+
for (const operation of operations) {
77+
// Exercise coverage of switch statements:
78+
switch (operation) {
79+
case 'add':
80+
if (add(Math.random() * 10, Math.random() * 10) > 10) {
81+
// Exercise coverage of ternary operations:
82+
let r = addSpecial(Math.random() * 10, Math.random() * 10) > 10 ?
83+
mult(Math.random() * 10, Math.random() * 10) :
84+
add(Math.random() * 10, Math.random() * 10);
85+
// Exercise && and ||
86+
if (r && Math.random() > 0.5 || Math.random() < 0.5) r++;
87+
}
88+
break;
89+
case 'addSpecial':
90+
if (addSpecial(Math.random() * 10, Math.random() * 10) > 10 &&
91+
add(Math.random() * 10, Math.random() * 10) > 10) {
92+
let r = mult(Math.random() * 10, Math.random() * 10) > 10 ?
93+
add(Math.random() * 10, Math.random() * 10) > 10 :
94+
mult(Math.random() * 10, Math.random() * 10);
95+
if (r && Math.random() > 0.5 || Math.random() < 0.5) r++;
96+
}
97+
break;
98+
case 'mult':
99+
if (mult(Math.random() * 10, Math.random() * 10) > 10) {
100+
let r = multSpecial(Math.random() * 10, Math.random() * 10) > 10 ?
101+
add(Math.random() * 10, Math.random() * 10) :
102+
mult(Math.random() * 10, Math.random() * 10);
103+
if (r && Math.random() > 0.5 || Math.random() < 0.5) r++;
104+
}
105+
break;
106+
case 'multSpecial':
107+
while (multSpecial(Math.random() * 10, Math.random() * 10) < 10) {
108+
mult(Math.random() * 10, Math.random() * 10);
109+
}
110+
break;
111+
default:
112+
break;
113+
}
114+
}
115+
}

benchmark/process/coverage.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This benchmark is meant to exercise a grab bag of code paths that would
2+
// be expected to run slower under coverage.
3+
'use strict';
4+
5+
const common = require('../common.js');
6+
const bench = common.createBenchmark(main, {
7+
n: [1e5]
8+
});
9+
const path = require('path');
10+
const { rmSync } = require('fs');
11+
const { spawnSync } = require('child_process');
12+
const tmpdir = require('../../test/common/tmpdir');
13+
14+
const coverageDir = path.join(tmpdir.path, `./cov-${Date.now()}`);
15+
16+
function main({ n }) {
17+
bench.start();
18+
const result = spawnSync(process.execPath, [
19+
require.resolve('../fixtures/coverage-many-branches'),
20+
], {
21+
env: {
22+
NODE_V8_COVERAGE: coverageDir,
23+
N: n,
24+
...process.env
25+
}
26+
});
27+
bench.end(n);
28+
rmSync(coverageDir, { recursive: true, force: true });
29+
if (result.status !== 0) {
30+
throw new Error(result.stderr.toString('utf8'));
31+
}
32+
}

doc/api/async_hooks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,11 @@ chains. It allows storing data throughout the lifetime of a web request
973973
or any other asynchronous duration. It is similar to thread-local storage
974974
in other languages.
975975

976+
While you can create your own implementation on top of the `async_hooks` module,
977+
`AsyncLocalStorage` should be preferred as it is a performant and memory safe
978+
implementation that involves significant optimizations that are non-obvious to
979+
implement.
980+
976981
The following example uses `AsyncLocalStorage` to build a simple logger
977982
that assigns IDs to incoming HTTP requests and includes them in messages
978983
logged within each request.

doc/api/buffer.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const buf7 = Buffer.from('tést', 'latin1');
5050
## Buffers and character encodings
5151
<!-- YAML
5252
changes:
53-
- version: REPLACEME
53+
- version: v15.7.0
5454
pr-url: https://github.com/nodejs/node/pull/36952
5555
description: Introduced `base64url` encoding.
5656
- version: v6.4.0
@@ -289,7 +289,7 @@ Additionally, the [`buf.values()`][], [`buf.keys()`][], and
289289

290290
## Class: `Blob`
291291
<!-- YAML
292-
added: REPLACEME
292+
added: v15.7.0
293293
-->
294294

295295
> Stability: 1 - Experimental
@@ -299,7 +299,7 @@ multiple worker threads.
299299

300300
### `new buffer.Blob([sources[, options]])`
301301
<!-- YAML
302-
added: REPLACEME
302+
added: v15.7.0
303303
-->
304304

305305
* `sources` {string[]|ArrayBuffer[]|TypedArray[]|DataView[]|Blob[]} An array
@@ -321,7 +321,7 @@ String sources are also copied into the `Blob`.
321321

322322
### `blob.arrayBuffer()`
323323
<!-- YAML
324-
added: REPLACEME
324+
added: v15.7.0
325325
-->
326326

327327
* Returns: {Promise}
@@ -331,14 +331,14 @@ the `Blob` data.
331331

332332
### `blob.size`
333333
<!-- YAML
334-
added: REPLACEME
334+
added: v15.7.0
335335
-->
336336

337337
The total size of the `Blob` in bytes.
338338

339339
### `blob.slice([start, [end, [type]]])`
340340
<!-- YAML
341-
added: REPLACEME
341+
added: v15.7.0
342342
-->
343343

344344
* `start` {number} The starting index.
@@ -350,7 +350,7 @@ data. The original `Blob` is not alterered.
350350

351351
### `blob.text()`
352352
<!-- YAML
353-
added: REPLACEME
353+
added: v15.7.0
354354
-->
355355

356356
* Returns: {Promise}
@@ -360,7 +360,7 @@ string.
360360

361361
### `blob.type`
362362
<!-- YAML
363-
added: REPLACEME
363+
added: v15.7.0
364364
-->
365365

366366
* Type: {string}

0 commit comments

Comments
 (0)