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

Commit

Permalink
meta: merge node/master into node-chakracore/master Merge 141be92 as …
Browse files Browse the repository at this point in the history
…of 2018-04-01 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
  • Loading branch information
chakrabot authored and kfarnung committed Apr 3, 2018
2 parents 96ed842 + 141be92 commit acbfb49
Show file tree
Hide file tree
Showing 72 changed files with 354 additions and 219 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ module.exports = {
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': ['error', 'always', {
'block': { 'balanced': true },
'exceptions': ['-']
}],
'strict': ['error', 'global'],
'symbol-description': 'error',
'template-curly-spacing': 'error',
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common.js');

const bench = common.createBenchmark(main, {
aligned: ['true', 'false'],
method: ['swap16', 'swap32', 'swap64'/*, 'htons', 'htonl', 'htonll'*/],
method: ['swap16', 'swap32', 'swap64'/* , 'htons', 'htonl', 'htonll' */],
len: [8, 64, 128, 256, 512, 768, 1024, 1536, 2056, 4096, 8192],
n: [5e7]
});
Expand Down
2 changes: 1 addition & 1 deletion doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ assert.equal(1, '1');
assert.equal(1, 2);
// AssertionError: 1 == 2
assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
// AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
```

If the values are not equal, an `AssertionError` is thrown with a `message`
Expand Down
6 changes: 3 additions & 3 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ directly by the shell and special characters (vary based on
need to be dealt with accordingly:
```js
exec('"/path/to/test file/test.sh" arg1 arg2');
//Double quotes are used so that the space in the path is not interpreted as
//multiple arguments
// Double quotes are used so that the space in the path is not interpreted as
// multiple arguments

exec('echo "The \\$HOME variable is $HOME"');
//The $HOME variable is escaped in the first instance, but not in the second
// The $HOME variable is escaped in the first instance, but not in the second
```

**Never pass unsanitized user input to this function. Any input containing shell
Expand Down
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3427,7 +3427,7 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
The `fs/promises` API provides an alternative set of asynchronous file system
methods that return `Promise` objects rather than using callbacks. The
API is accessible via `require('fs/promises)`.
API is accessible via `require('fs/promises')`.

### class: FileHandle
<!-- YAML
Expand Down
14 changes: 7 additions & 7 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ settings do not take effect until the `'localSettings'` event is emitted.
session.settings({ enablePush: false });

session.on('localSettings', (settings) => {
/** use the new settings **/
/* Use the new settings */
});
```

Expand All @@ -218,7 +218,7 @@ of the remote settings.

```js
session.on('remoteSettings', (settings) => {
/** use the new settings **/
/* Use the new settings */
});
```

Expand Down Expand Up @@ -280,7 +280,7 @@ activity on the `Http2Session` after the configured number of milliseconds.

```js
session.setTimeout(2000);
session.on('timeout', () => { /** .. **/ });
session.on('timeout', () => { /* .. */ });
```

#### http2session.alpnProtocol
Expand Down Expand Up @@ -439,7 +439,7 @@ payload.
session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {
if (!err) {
console.log(`Ping acknowledged in ${duration} milliseconds`);
console.log(`With payload '${payload.toString()}`);
console.log(`With payload '${payload.toString()}'`);
}
});
```
Expand Down Expand Up @@ -706,8 +706,8 @@ const {
const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
req.on('response', (headers) => {
console.log(headers[HTTP2_HEADER_STATUS]);
req.on('data', (chunk) => { /** .. **/ });
req.on('end', () => { /** .. **/ });
req.on('data', (chunk) => { /* .. */ });
req.on('end', () => { /* .. */ });
});
```

Expand Down Expand Up @@ -1928,7 +1928,7 @@ Returns a `ClientHttp2Session` instance.
const http2 = require('http2');
const client = http2.connect('https://localhost:1234');

/** use the client **/
/* Use the client */

client.close();
```
Expand Down
2 changes: 1 addition & 1 deletion doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ in the [`net.createServer()`][] section:
```js
const net = require('net');
const client = net.createConnection({ port: 8124 }, () => {
//'connect' listener
// 'connect' listener
console.log('connected to server!');
client.write('world!\r\n');
});
Expand Down
2 changes: 1 addition & 1 deletion doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ changes:
a process warning.
-->

The `'unhandledRejection`' event is emitted whenever a `Promise` is rejected and
The `'unhandledRejection'` event is emitted whenever a `Promise` is rejected and
no error handler is attached to the promise within a turn of the event loop.
When programming with Promises, exceptions are encapsulated as "rejected
promises". Rejections can be caught and handled using [`promise.catch()`][] and
Expand Down
44 changes: 42 additions & 2 deletions doc/api/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,49 @@ const contextifiedSandbox = vm.createContext({ secret: 42 });
in stack traces produced by this Module.
* `columnOffset` {integer} Spcifies the column number offset that is displayed
in stack traces produced by this Module.
* `initalizeImportMeta` {Function} Called during evaluation of this Module to
initialize the `import.meta`. This function has the signature `(meta,
module)`, where `meta` is the `import.meta` object in the Module, and
`module` is this `vm.Module` object.

Creates a new ES `Module` object.

*Note*: Properties assigned to the `import.meta` object that are objects may
allow the Module to access information outside the specified `context`, if the
object is created in the top level context. Use `vm.runInContext()` to create
objects in a specific context.

```js
const vm = require('vm');

const contextifiedSandbox = vm.createContext({ secret: 42 });

(async () => {
const module = new vm.Module(
'Object.getPrototypeOf(import.meta.prop).secret = secret;',
{
initializeImportMeta(meta) {
// Note: this object is created in the top context. As such,
// Object.getPrototypeOf(import.meta.prop) points to the
// Object.prototype in the top context rather than that in
// the sandbox.
meta.prop = {};
}
});
// Since module has no dependencies, the linker function will never be called.
await module.link(() => {});
module.initialize();
await module.evaluate();

// Now, Object.prototype.secret will be equal to 42.
//
// To fix this problem, replace
// meta.prop = {};
// above with
// meta.prop = vm.runInContext('{}', contextifiedSandbox);
})();
```

### module.dependencySpecifiers

* {string[]}
Expand Down Expand Up @@ -850,7 +890,7 @@ associating it with the `sandbox` object is what this document refers to as
[`eval()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
[`script.runInContext()`]: #vm_script_runincontext_contextifiedsandbox_options
[`script.runInThisContext()`]: #vm_script_runinthiscontext_options
[`url.origin`]: https://nodejs.org/api/url.html#url_url_origin
[`url.origin`]: url.html#url_url_origin
[`vm.createContext()`]: #vm_vm_createcontext_sandbox_options
[`vm.runInContext()`]: #vm_vm_runincontext_code_contextifiedsandbox_options
[`vm.runInThisContext()`]: #vm_vm_runinthiscontext_code_options
Expand All @@ -859,9 +899,9 @@ associating it with the `sandbox` object is what this document refers to as
[Evaluate() concrete method]: https://tc39.github.io/ecma262/#sec-moduleevaluation
[HostResolveImportedModule]: https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule
[Instantiate() concrete method]: https://tc39.github.io/ecma262/#sec-moduledeclarationinstantiation
[Source Text Module Record]: https://tc39.github.io/ecma262/#sec-source-text-module-records
[V8 Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide#contexts
[contextified]: #vm_what_does_it_mean_to_contextify_an_object
[global object]: https://es5.github.io/#x15.1
[indirect `eval()` call]: https://es5.github.io/#x10.4.2
[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin
[Source Text Module Record]: https://tc39.github.io/ecma262/#sec-source-text-module-records
4 changes: 2 additions & 2 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ Agent.prototype.getName = function getName(options) {
return name;
};

Agent.prototype.addRequest = function addRequest(req, options, port/*legacy*/,
localAddress/*legacy*/) {
Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
localAddress/* legacy */) {
// Legacy API: addRequest(req, host, port, localAddress)
if (typeof options === 'string') {
options = {
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function ClientRequest(options, cb) {
var posColon = hostHeader.indexOf(':');
if (posColon !== -1 &&
hostHeader.indexOf(':', posColon + 1) !== -1 &&
hostHeader.charCodeAt(0) !== 91/*'['*/) {
hostHeader.charCodeAt(0) !== 91/* '[' */) {
hostHeader = `[${hostHeader}]`;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
* Verifies that the given val is a valid HTTP token
* per the rules defined in RFC 7230
* See https://tools.ietf.org/html/rfc7230#section-3.2.6
**/
*/
function checkIsHttpToken(val) {
return tokenRegExp.test(val);
}
Expand All @@ -248,7 +248,7 @@ const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
* field-value = *( field-content / obs-fold )
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
* field-vchar = VCHAR / obs-text
**/
*/
function checkInvalidHeaderChar(val) {
return headerCharRegex.test(val);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const doFlaggedDeprecation =
* runtime deprecation would introduce too much breakage at this time. It's not
* likely that the Buffer constructors would ever actually be removed.
* Deprecation Code: DEP0005
**/
*/
function Buffer(arg, encodingOrOffset, length) {
doFlaggedDeprecation();
// Common case.
Expand All @@ -206,7 +206,7 @@ Object.defineProperty(Buffer, Symbol.species, {
* Buffer.from(array)
* Buffer.from(buffer)
* Buffer.from(arrayBuffer[, byteOffset[, length]])
**/
*/
Buffer.from = function from(value, encodingOrOffset, length) {
if (typeof value === 'string')
return fromString(value, encodingOrOffset);
Expand Down Expand Up @@ -271,7 +271,7 @@ function assertSize(size) {
/**
* Creates a new filled Buffer instance.
* alloc(size[, fill[, encoding]])
**/
*/
Buffer.alloc = function alloc(size, fill, encoding) {
assertSize(size);
if (fill !== undefined && size > 0) {
Expand All @@ -283,7 +283,7 @@ Buffer.alloc = function alloc(size, fill, encoding) {
/**
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer
* instance. If `--zero-fill-buffers` is set, will zero-fill the buffer.
**/
*/
Buffer.allocUnsafe = function allocUnsafe(size) {
assertSize(size);
return allocate(size);
Expand All @@ -293,7 +293,7 @@ Buffer.allocUnsafe = function allocUnsafe(size) {
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled
* Buffer instance that is not allocated off the pre-initialized pool.
* If `--zero-fill-buffers` is set, will zero-fill the buffer.
**/
*/
Buffer.allocUnsafeSlow = function allocUnsafeSlow(size) {
assertSize(size);
return createUnsafeBuffer(size);
Expand Down
14 changes: 7 additions & 7 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function stdioStringToArray(option) {
}
}

exports.fork = function(modulePath /*, args, options*/) {
exports.fork = function(modulePath /* , args, options */) {

// Get options and args arguments.
var execArgv;
Expand Down Expand Up @@ -143,7 +143,7 @@ function normalizeExecArgs(command, options, callback) {
}


exports.exec = function(command /*, options, callback*/) {
exports.exec = function(command /* , options, callback */) {
var opts = normalizeExecArgs.apply(null, arguments);
return exports.execFile(opts.file,
opts.options,
Expand Down Expand Up @@ -172,7 +172,7 @@ Object.defineProperty(exports.exec, util.promisify.custom, {
value: customPromiseExecFunction(exports.exec)
});

exports.execFile = function(file /*, args, options, callback*/) {
exports.execFile = function(file /* , args, options, callback */) {
var args = [];
var callback;
var options = {
Expand Down Expand Up @@ -511,7 +511,7 @@ function normalizeSpawnArguments(file, args, options) {
}


var spawn = exports.spawn = function(/*file, args, options*/) {
var spawn = exports.spawn = function(/* file, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
var options = opts.options;
var child = new ChildProcess();
Expand All @@ -534,7 +534,7 @@ var spawn = exports.spawn = function(/*file, args, options*/) {
return child;
};

function spawnSync(/*file, args, options*/) {
function spawnSync(/* file, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);

var options = opts.options;
Expand Down Expand Up @@ -602,7 +602,7 @@ function checkExecSyncError(ret, args, cmd) {
}


function execFileSync(/*command, args, options*/) {
function execFileSync(/* command, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
var inheritStderr = !opts.options.stdio;

Expand All @@ -621,7 +621,7 @@ function execFileSync(/*command, args, options*/) {
exports.execFileSync = execFileSync;


function execSync(command /*, options*/) {
function execSync(command /* , options */) {
var opts = normalizeExecArgs.apply(null, arguments);
var inheritStderr = !opts.options.stdio;

Expand Down
2 changes: 1 addition & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function bufferSize(self, size, buffer) {
return ret;
}

Socket.prototype.bind = function(port_, address_ /*, callback*/) {
Socket.prototype.bind = function(port_, address_ /* , callback */) {
let port = port_;

this._healthCheck();
Expand Down
4 changes: 2 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fs.Stats = Stats;
function isFileType(fileType) {
// Use stats array directly to avoid creating an fs.Stats instance just for
// our internal use.
return (statValues[1/*mode*/] & S_IFMT) === fileType;
return (statValues[1/* mode */] & S_IFMT) === fileType;
}

// Don't allow mode to accidentally be overwritten.
Expand Down Expand Up @@ -1442,7 +1442,7 @@ function StatWatcher() {
this._handle.onchange = function(newStatus) {
if (oldStatus === -1 &&
newStatus === -1 &&
statValues[2/*new nlink*/] === statValues[16/*old nlink*/]) return;
statValues[2/* new nlink */] === statValues[16/* old nlink */]) return;

oldStatus = newStatus;
self.emit('change', statsFromValues(), statsFromPrevValues());
Expand Down
4 changes: 2 additions & 2 deletions lib/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ async function readFileHandle(filehandle, options) {
const statFields = await binding.fstat(filehandle.fd, kUsePromises);

let size;
if ((statFields[1/*mode*/] & S_IFMT) === S_IFREG) {
size = statFields[8/*size*/];
if ((statFields[1/* mode */] & S_IFMT) === S_IFREG) {
size = statFields[8/* size */];
} else {
size = 0;
}
Expand Down
11 changes: 7 additions & 4 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@
'DeprecationWarning', 'DEP0062', startup, true);
}

if (process.binding('config').experimentalModules) {
process.emitWarning(
'The ESM module loader is experimental.',
'ExperimentalWarning', undefined);
if (process.binding('config').experimentalModules ||
process.binding('config').experimentalVMModules) {
if (process.binding('config').experimentalModules) {
process.emitWarning(
'The ESM module loader is experimental.',
'ExperimentalWarning', undefined);
}
NativeModule.require('internal/process/esm_loader').setup();
}

Expand Down
Loading

0 comments on commit acbfb49

Please sign in to comment.