Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 038d65b

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge ca22c96 as of 2018-03-24 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: chakrabot <[email protected]>
2 parents 631b176 + ca22c96 commit 038d65b

File tree

426 files changed

+14870
-7544
lines changed

Some content is hidden

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

426 files changed

+14870
-7544
lines changed

Diff for: benchmark/buffers/buffer-write.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const INT32 = 0x7fffffff;
3434
const INT48 = 0x7fffffffffff;
3535
const UINT8 = 0xff;
3636
const UINT16 = 0xffff;
37+
const UINT32 = 0xffffffff;
3738

3839
const mod = {
3940
writeInt8: INT8,
@@ -44,8 +45,8 @@ const mod = {
4445
writeUInt8: UINT8,
4546
writeUInt16BE: UINT16,
4647
writeUInt16LE: UINT16,
47-
writeUInt32BE: INT32,
48-
writeUInt32LE: INT32,
48+
writeUInt32BE: UINT32,
49+
writeUInt32LE: UINT32,
4950
writeUIntLE: INT8,
5051
writeUIntBE: INT16,
5152
writeIntLE: INT32,

Diff for: doc/api/addons.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ napi_value Method(napi_env env, napi_callback_info args) {
246246
napi_value greeting;
247247
napi_status status;
248248

249-
status = napi_create_string_utf8(env, "hello", 6, &greeting);
249+
status = napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH, &greeting);
250250
if (status != napi_ok) return nullptr;
251251
return greeting;
252252
}

Diff for: doc/api/assert.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,16 @@ added: REPLACEME
321321
* `message` {any}
322322

323323
Awaits for the promise returned by function `block` to complete and not be
324-
rejected. See [`assert.rejects()`][] for more details.
324+
rejected.
325+
326+
Please note: Using `assert.doesNotReject()` is actually not useful because there
327+
is little benefit by catching a rejection and then rejecting it again. Instead,
328+
consider adding a comment next to the specific code path that should not reject
329+
and keep error messages as expressive as possible.
325330

326331
When `assert.doesNotReject()` is called, it will immediately call the `block`
327-
function, and awaits for completion.
332+
function, and awaits for completion. See [`assert.rejects()`][] for more
333+
details.
328334

329335
Besides the async nature to await the completion behaves identically to
330336
[`assert.doesNotThrow()`][].

Diff for: doc/api/buffer.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Buffer
22

3-
<!--introduced_in=v0.10.0-->
3+
<!--introduced_in=v0.1.90-->
44
<!--lint disable maximum-line-length-->
55

66
> Stability: 2 - Stable
@@ -18,9 +18,9 @@ use cases.
1818
Instances of the `Buffer` class are similar to arrays of integers but
1919
correspond to fixed-sized, raw memory allocations outside the V8 heap.
2020
The size of the `Buffer` is established when it is created and cannot be
21-
resized.
21+
changed.
2222

23-
The `Buffer` class is a global within Node.js, making it unlikely that one
23+
The `Buffer` class is within the global scope, making it unlikely that one
2424
would need to ever use `require('buffer').Buffer`.
2525

2626
```js

Diff for: doc/api/cluster.md

+3
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ values are `"rr"` and `"none"`.
698698
<!-- YAML
699699
added: v0.7.1
700700
changes:
701+
- version: v9.5.0
702+
pr-url: https://github.com/nodejs/node/pull/18399
703+
description: The `cwd` option is supported now.
701704
- version: 8.2.0
702705
pr-url: https://github.com/nodejs/node/pull/14140
703706
description: The `inspectPort` option is supported now.

Diff for: doc/api/crypto.md

+48
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,54 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
656656
// OK
657657
```
658658

659+
### ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])
660+
<!-- YAML
661+
added: REPLACEME
662+
-->
663+
664+
- `key` {string | Buffer | TypedArray | DataView}
665+
- `curve` {string}
666+
- `inputEncoding` {string}
667+
- `outputEncoding` {string}
668+
- `format` {string} Defaults to `uncompressed`.
669+
670+
Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the
671+
format specified by `format`. The `format` argument specifies point encoding
672+
and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is
673+
interpreted using the specified `inputEncoding`, and the returned key is encoded
674+
using the specified `outputEncoding`. Encodings can be `'latin1'`, `'hex'`,
675+
or `'base64'`.
676+
677+
Use [`crypto.getCurves()`][] to obtain a list of available curve names.
678+
On recent OpenSSL releases, `openssl ecparam -list_curves` will also display
679+
the name and description of each available elliptic curve.
680+
681+
If `format` is not specified the point will be returned in `'uncompressed'`
682+
format.
683+
684+
If the `inputEncoding` is not provided, `key` is expected to be a [`Buffer`][],
685+
`TypedArray`, or `DataView`.
686+
687+
Example (uncompressing a key):
688+
689+
```js
690+
const { ECDH } = require('crypto');
691+
692+
const ecdh = ECDH('secp256k1');
693+
ecdh.generateKeys();
694+
695+
const compressedKey = ecdh.getPublicKey('hex', 'compressed');
696+
697+
const uncompressedKey = ECDH.convertKey(compressedKey,
698+
'secp256k1',
699+
'hex',
700+
'hex',
701+
'uncompressed');
702+
703+
// the converted key and the uncompressed public key should be the same
704+
console.log(uncompressedKey === ecdh.getPublicKey('hex'));
705+
```
706+
659707
### ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])
660708
<!-- YAML
661709
added: v0.11.14

Diff for: doc/api/modules.md

+37
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,43 @@ filename scales linearly with the number of registered extensions.
600600
In other words, adding extensions slows down the module loader and
601601
should be discouraged.
602602

603+
#### require.main
604+
<!-- YAML
605+
added: v0.1.17
606+
-->
607+
608+
* {Object}
609+
610+
The `Module` object representing the entry script loaded when the Node.js
611+
process launched.
612+
See ["Accessing the main module"](#modules_accessing_the_main_module).
613+
614+
In `entry.js` script:
615+
616+
```js
617+
console.log(require.main);
618+
```
619+
620+
```sh
621+
node entry.js
622+
```
623+
624+
<!-- eslint-skip -->
625+
```js
626+
Module {
627+
id: '.',
628+
exports: {},
629+
parent: null,
630+
filename: '/absolute/path/to/entry.js',
631+
loaded: false,
632+
children: [],
633+
paths:
634+
[ '/absolute/path/to/node_modules',
635+
'/absolute/path/node_modules',
636+
'/absolute/node_modules',
637+
'/node_modules' ] }
638+
```
639+
603640
#### require.resolve(request[, options])
604641
<!-- YAML
605642
added: v0.3.0

Diff for: doc/api/n-api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ that has a loop which iterates through the elements in a large array:
610610
```C
611611
for (int i = 0; i < 1000000; i++) {
612612
napi_value result;
613-
napi_status status = napi_get_element(e object, i, &result);
613+
napi_status status = napi_get_element(e, object, i, &result);
614614
if (status != napi_ok) {
615615
break;
616616
}
@@ -647,7 +647,7 @@ for (int i = 0; i < 1000000; i++) {
647647
break;
648648
}
649649
napi_value result;
650-
status = napi_get_element(e object, i, &result);
650+
status = napi_get_element(e, object, i, &result);
651651
if (status != napi_ok) {
652652
break;
653653
}

Diff for: doc/api/process.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ $ bash -c 'exec -a customArgv0 ./node'
489489
added: v7.1.0
490490
-->
491491

492+
* {Object}
493+
492494
If the Node.js process was spawned with an IPC channel (see the
493495
[Child Process][] documentation), the `process.channel`
494496
property is a reference to the IPC channel. If no IPC channel exists, this
@@ -921,7 +923,7 @@ console.log(process.env.test);
921923
added: v0.7.7
922924
-->
923925

924-
* {Object}
926+
* {Array}
925927

926928
The `process.execArgv` property returns the set of Node.js-specific command-line
927929
options passed when the Node.js process was launched. These options do not
@@ -1250,6 +1252,8 @@ debugger, see [Signal Events][].
12501252
added: v0.1.17
12511253
-->
12521254

1255+
* {Object}
1256+
12531257
The `process.mainModule` property provides an alternative way of retrieving
12541258
[`require.main`][]. The difference is that if the main module changes at
12551259
runtime, [`require.main`][] may still refer to the original main module in
@@ -1479,6 +1483,8 @@ changes:
14791483
description: The `lts` property is now supported.
14801484
-->
14811485

1486+
* {Object}
1487+
14821488
The `process.release` property returns an Object containing metadata related to
14831489
the current release, including URLs for the source tarball and headers-only
14841490
tarball.

Diff for: lib/fs/promises.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ async function readFileHandle(filehandle, options) {
157157
chunks.push(buffer.slice(0, totalRead));
158158
} while (totalRead === chunkSize);
159159

160-
return Buffer.concat(chunks);
160+
const result = Buffer.concat(chunks);
161+
if (options.encoding) {
162+
return result.toString(options.encoding);
163+
} else {
164+
return result;
165+
}
161166
}
162167

163168
// All of the functions are defined as async in order to ensure that errors

Diff for: lib/internal/buffer.js

+52-30
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,12 @@ function writeU_Int48LE(buf, value, offset, min, max) {
481481

482482
const newVal = Math.floor(value * 2 ** -32);
483483
buf[offset++] = value;
484-
buf[offset++] = (value >>> 8);
485-
buf[offset++] = (value >>> 16);
486-
buf[offset++] = (value >>> 24);
484+
value = value >>> 8;
485+
buf[offset++] = value;
486+
value = value >>> 8;
487+
buf[offset++] = value;
488+
value = value >>> 8;
489+
buf[offset++] = value;
487490
buf[offset++] = newVal;
488491
buf[offset++] = (newVal >>> 8);
489492
return offset;
@@ -495,9 +498,12 @@ function writeU_Int40LE(buf, value, offset, min, max) {
495498

496499
const newVal = value;
497500
buf[offset++] = value;
498-
buf[offset++] = (value >>> 8);
499-
buf[offset++] = (value >>> 16);
500-
buf[offset++] = (value >>> 24);
501+
value = value >>> 8;
502+
buf[offset++] = value;
503+
value = value >>> 8;
504+
buf[offset++] = value;
505+
value = value >>> 8;
506+
buf[offset++] = value;
501507
buf[offset++] = Math.floor(newVal * 2 ** -32);
502508
return offset;
503509
}
@@ -507,9 +513,12 @@ function writeU_Int32LE(buf, value, offset, min, max) {
507513
checkInt(value, min, max, buf, offset, 3);
508514

509515
buf[offset++] = value;
510-
buf[offset++] = (value >>> 8);
511-
buf[offset++] = (value >>> 16);
512-
buf[offset++] = (value >>> 24);
516+
value = value >>> 8;
517+
buf[offset++] = value;
518+
value = value >>> 8;
519+
buf[offset++] = value;
520+
value = value >>> 8;
521+
buf[offset++] = value;
513522
return offset;
514523
}
515524

@@ -522,8 +531,10 @@ function writeU_Int24LE(buf, value, offset, min, max) {
522531
checkInt(value, min, max, buf, offset, 2);
523532

524533
buf[offset++] = value;
525-
buf[offset++] = (value >>> 8);
526-
buf[offset++] = (value >>> 16);
534+
value = value >>> 8;
535+
buf[offset++] = value;
536+
value = value >>> 8;
537+
buf[offset++] = value;
527538
return offset;
528539
}
529540

@@ -582,34 +593,43 @@ function writeU_Int48BE(buf, value, offset, min, max) {
582593
const newVal = Math.floor(value * 2 ** -32);
583594
buf[offset++] = (newVal >>> 8);
584595
buf[offset++] = newVal;
585-
buf[offset++] = (value >>> 24);
586-
buf[offset++] = (value >>> 16);
587-
buf[offset++] = (value >>> 8);
588-
buf[offset++] = value;
589-
return offset;
596+
buf[offset + 3] = value;
597+
value = value >>> 8;
598+
buf[offset + 2] = value;
599+
value = value >>> 8;
600+
buf[offset + 1] = value;
601+
value = value >>> 8;
602+
buf[offset] = value;
603+
return offset + 4;
590604
}
591605

592606
function writeU_Int40BE(buf, value, offset, min, max) {
593607
value = +value;
594608
checkInt(value, min, max, buf, offset, 4);
595609

596610
buf[offset++] = Math.floor(value * 2 ** -32);
597-
buf[offset++] = (value >>> 24);
598-
buf[offset++] = (value >>> 16);
599-
buf[offset++] = (value >>> 8);
600-
buf[offset++] = value;
601-
return offset;
611+
buf[offset + 3] = value;
612+
value = value >>> 8;
613+
buf[offset + 2] = value;
614+
value = value >>> 8;
615+
buf[offset + 1] = value;
616+
value = value >>> 8;
617+
buf[offset] = value;
618+
return offset + 4;
602619
}
603620

604621
function writeU_Int32BE(buf, value, offset, min, max) {
605622
value = +value;
606623
checkInt(value, min, max, buf, offset, 3);
607624

608-
buf[offset++] = (value >>> 24);
609-
buf[offset++] = (value >>> 16);
610-
buf[offset++] = (value >>> 8);
611-
buf[offset++] = value;
612-
return offset;
625+
buf[offset + 3] = value;
626+
value = value >>> 8;
627+
buf[offset + 2] = value;
628+
value = value >>> 8;
629+
buf[offset + 1] = value;
630+
value = value >>> 8;
631+
buf[offset] = value;
632+
return offset + 4;
613633
}
614634

615635
function writeUInt32BE(value, offset) {
@@ -620,10 +640,12 @@ function writeU_Int24BE(buf, value, offset, min, max) {
620640
value = +value;
621641
checkInt(value, min, max, buf, offset, 2);
622642

623-
buf[offset++] = (value >>> 16);
624-
buf[offset++] = (value >>> 8);
625-
buf[offset++] = value;
626-
return offset;
643+
buf[offset + 2] = value;
644+
value = value >>> 8;
645+
buf[offset + 1] = value;
646+
value = value >>> 8;
647+
buf[offset] = value;
648+
return offset + 3;
627649
}
628650

629651
function writeU_Int16BE(buf, value, offset, min, max) {

0 commit comments

Comments
 (0)