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
Browse files Browse the repository at this point in the history
Merge 7514eb3 as of 2018-02-20
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 Feb 20, 2018
2 parents 219bf8c + 7514eb3 commit 4f85fd0
Show file tree
Hide file tree
Showing 29 changed files with 252 additions and 308 deletions.
18 changes: 16 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2749,8 +2749,21 @@ changes:
* `callback` {Function}
* `err` {Error}

Asynchronous unlink(2). No arguments other than a possible exception are given
to the completion callback.
Asynchronously removes a file or symbolic link. No arguments other than a
possible exception are given to the completion callback.

```js
// Assuming that 'path/file.txt' is a regular file.
fs.unlink('path/file.txt', (err) => {
if (err) throw err;
console.log('path/file.txt was deleted');
});
```

`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
directory, use [`fs.rmdir()`][].

See also: unlink(2)

## fs.unlinkSync(path)
<!-- YAML
Expand Down Expand Up @@ -4472,6 +4485,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's
[`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback
[`fs.readFile()`]: #fs_fs_readfile_path_options_callback
[`fs.readFileSync()`]: #fs_fs_readfilesync_path_options
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
[`fs.stat()`]: #fs_fs_stat_path_callback
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
[`fs.watch()`]: #fs_fs_watch_filename_options_listener
Expand Down
10 changes: 10 additions & 0 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,16 @@ See [`request.socket`][]
### request.end([data[, encoding]][, callback])
<!-- YAML
added: v0.1.90
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18780
description: This method now returns a reference to `ClientRequest`.
-->

* `data` {string|Buffer}
* `encoding` {string}
* `callback` {Function}
* Returns: {this}

Finishes sending the request. If any parts of the body are
unsent, it will flush them to the stream. If the request is
Expand Down Expand Up @@ -1041,11 +1046,16 @@ See [`response.socket`][].
### response.end([data][, encoding][, callback])
<!-- YAML
added: v0.1.90
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18780
description: This method now returns a reference to `ServerResponse`.
-->

* `data` {string|Buffer}
* `encoding` {string}
* `callback` {Function}
* Returns: {this}

This method signals to the server that all of the response headers and body
have been sent; that server should consider this message complete.
Expand Down
7 changes: 6 additions & 1 deletion doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ changes:
Http2ServerRequest class to use.
Useful for extending the original `Http2ServerRequest`.
**Default:** `Http2ServerRequest`
* `Http2ServerResponse` {htt2.Http2ServerResponse} Specifies the
* `Http2ServerResponse` {http2.Http2ServerResponse} Specifies the
Http2ServerResponse class to use.
Useful for extending the original `Http2ServerResponse`.
**Default:** `Http2ServerResponse`
Expand Down Expand Up @@ -2624,11 +2624,16 @@ See [`response.socket`][].
#### response.end([data][, encoding][, callback])
<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18780
description: This method now returns a reference to `ServerResponse`.
-->

* `data` {string|Buffer}
* `encoding` {string}
* `callback` {Function}
* Returns: {this}

This method signals to the server that all of the response headers and body
have been sent; that server should consider this message complete.
Expand Down
4 changes: 4 additions & 0 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ See also: [`writable.uncork()`][].
<!-- YAML
added: v0.9.4
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18780
description: This method now returns a reference to `writable`.
- version: v8.0.0
pr-url: https://github.com/nodejs/node/pull/11608
description: The `chunk` argument can now be a `Uint8Array` instance.
Expand All @@ -366,6 +369,7 @@ changes:
other than `null`.
* `encoding` {string} The encoding, if `chunk` is a string
* `callback` {Function} Optional callback for when the stream is finished
* Returns: {this}

Calling the `writable.end()` method signals that no more data will be written
to the [Writable][]. The optional `chunk` and `encoding` arguments allow one
Expand Down
2 changes: 1 addition & 1 deletion doc/guides/contributing/pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,4 @@ you can take a look at the
[guide for writing tests in Node.js]: ../writing-tests.md
[https://ci.nodejs.org/]: https://ci.nodejs.org/
[IRC in the #node-dev channel]: https://webchat.freenode.net?channels=node-dev&uio=d4
[Onboarding guide]: ../onboarding.md
[Onboarding guide]: ../../onboarding.md
9 changes: 4 additions & 5 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
}

if (this.finished) {
return false;
return this;
}

var uncork;
Expand Down Expand Up @@ -766,12 +766,11 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {

var finish = onFinish.bind(undefined, this);

var ret;
if (this._hasBody && this.chunkedEncoding) {
ret = this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
} else {
// Force a flush, HACK.
ret = this._send('', 'latin1', finish);
this._send('', 'latin1', finish);
}

if (uncork)
Expand All @@ -788,7 +787,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
this._finish();
}

return ret;
return this;
};


Expand Down
2 changes: 2 additions & 0 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ Writable.prototype.end = function(chunk, encoding, cb) {
// ignore unnecessary end() calls.
if (!state.ending)
endWritable(this, state, cb);

return this;
};

Object.defineProperty(Writable.prototype, 'writableLength', {
Expand Down
12 changes: 6 additions & 6 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function readFileAfterStat(err) {
// our internal use.
var size;
if ((statValues[1/*mode*/] & S_IFMT) === S_IFREG)
size = context.size = statValues[8/*size*/];
size = context.size = statValues[8];
else
size = context.size = 0;

Expand Down Expand Up @@ -490,7 +490,7 @@ fs.readFileSync = function(path, options) {
// our internal use.
var size;
if ((statValues[1/*mode*/] & S_IFMT) === S_IFREG)
size = statValues[8/*size*/];
size = statValues[8];
else
size = 0;
var pos = 0;
Expand Down Expand Up @@ -1654,8 +1654,8 @@ fs.realpathSync = function realpathSync(p, options) {
var linkTarget = null;
var id;
if (!isWindows) {
var dev = statValues[0/*dev*/].toString(32);
var ino = statValues[7/*ino*/].toString(32);
var dev = statValues[0].toString(32);
var ino = statValues[7].toString(32);
id = `${dev}:${ino}`;
if (seenLinks[id]) {
linkTarget = seenLinks[id];
Expand Down Expand Up @@ -1793,8 +1793,8 @@ fs.realpath = function realpath(p, options, callback) {
// dev/ino always return 0 on windows, so skip the check.
let id;
if (!isWindows) {
var dev = statValues[0/*ino*/].toString(32);
var ino = statValues[7/*ino*/].toString(32);
var dev = statValues[0].toString(32);
var ino = statValues[7].toString(32);
id = `${dev}:${ino}`;
if (seenLinks[id]) {
return gotTarget(null, seenLinks[id], base);
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ class Http2ServerResponse extends Stream {
this[kFinish]();
else
stream.end();

return this;
}

destroy(err) {
Expand Down
18 changes: 10 additions & 8 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
async_id_symbol,
trigger_async_id_symbol,
Timeout,
initAsyncResource,
refreshFnSymbol,
setUnrefTimeout,
validateTimerDuration
Expand All @@ -37,6 +38,14 @@ function getTimers() {
return timers;
}

function initAsyncResource(resource, type) {
const asyncId = resource[async_id_symbol] = newAsyncId();
const triggerAsyncId =
resource[trigger_async_id_symbol] = getDefaultTriggerAsyncId();
if (initHooksExist())
emitInit(asyncId, type, triggerAsyncId, resource);
}

// Timer constructor function.
// The entire prototype is defined in lib/timers.js
function Timeout(callback, after, args, isRepeat, isUnrefed) {
Expand Down Expand Up @@ -66,14 +75,7 @@ function Timeout(callback, after, args, isRepeat, isUnrefed) {

this[unrefedSymbol] = isUnrefed;

this[async_id_symbol] = newAsyncId();
this[trigger_async_id_symbol] = getDefaultTriggerAsyncId();
if (initHooksExist()) {
emitInit(this[async_id_symbol],
'Timeout',
this[trigger_async_id_symbol],
this);
}
initAsyncResource(this, 'Timeout');
}

Timeout.prototype[refreshFnSymbol] = function refresh() {
Expand Down
23 changes: 3 additions & 20 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
async_id_symbol,
trigger_async_id_symbol,
Timeout,
initAsyncResource,
validateTimerDuration
} = require('internal/timers');
const internalUtil = require('internal/util');
Expand All @@ -39,12 +40,8 @@ const util = require('util');
const errors = require('internal/errors');
const debug = util.debuglog('timer');
const {
getDefaultTriggerAsyncId,
newAsyncId,
initHooksExist,
destroyHooksExist,
// The needed emit*() functions.
emitInit,
emitBefore,
emitAfter,
emitDestroy
Expand Down Expand Up @@ -188,14 +185,7 @@ function insert(item, unrefed, start) {

if (!item[async_id_symbol] || item._destroyed) {
item._destroyed = false;
item[async_id_symbol] = newAsyncId();
item[trigger_async_id_symbol] = getDefaultTriggerAsyncId();
if (initHooksExist()) {
emitInit(item[async_id_symbol],
'Timeout',
item[trigger_async_id_symbol],
item);
}
initAsyncResource(item, 'Timeout');
}

L.append(list, item);
Expand Down Expand Up @@ -720,14 +710,7 @@ const Immediate = class Immediate {
this._destroyed = false;
this[kRefed] = false;

this[async_id_symbol] = newAsyncId();
this[trigger_async_id_symbol] = getDefaultTriggerAsyncId();
if (initHooksExist()) {
emitInit(this[async_id_symbol],
'Immediate',
this[trigger_async_id_symbol],
this);
}
initAsyncResource(this, 'Immediate');

this.ref();
immediateInfo[kCount]++;
Expand Down
Loading

0 comments on commit 4f85fd0

Please sign in to comment.