Skip to content

Commit

Permalink
Merge nodejs/master into xplat
Browse files Browse the repository at this point in the history
Merge 260cd41 as of 2017-05-24.
This is an automatically created merge. For any problems please
contact @kunalspathak.
  • Loading branch information
chakrabot committed May 25, 2017
2 parents 74474a1 + 260cd41 commit 1ef4c44
Show file tree
Hide file tree
Showing 54 changed files with 884 additions and 322 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,9 @@ ifeq ($(XZ), 0)
endif

doc-upload: doc
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/"
chmod -R ug=rw-x+X,o=r+X out/doc/
scp -pr out/doc/ $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/
scp -pr out/doc/* $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs.done"

$(TARBALL)-headers: release-only
Expand Down
12 changes: 7 additions & 5 deletions benchmark/streams/readable-boundaryread.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ const common = require('../common');
const Readable = require('stream').Readable;

const bench = common.createBenchmark(main, {
n: [200e1]
n: [200e1],
type: ['string', 'buffer']
});

function main(conf) {
const n = +conf.n;
const b = new Buffer(32);
const s = new Readable();
function noop() {}
s._read = noop;
var data = 'a'.repeat(32);
if (conf.type === 'buffer')
data = Buffer.from(data);
s._read = function() {};

bench.start();
for (var k = 0; k < n; ++k) {
for (var i = 0; i < 1e4; ++i)
s.push(b);
s.push(data);
while (s.read(32));
}
bench.end(n);
Expand Down
23 changes: 13 additions & 10 deletions doc/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# Style Guide

* Documents are written in markdown files.
* Those files should be written in **`lowercase-with-dashes.md`.**
* Those files should be written in **`lowercase-with-dashes.md`**.
* Underscores in filenames are allowed only when they are present in the
topic the document will describe (e.g., `child_process`.)
topic the document will describe (e.g., `child_process`).
* Filenames should be **lowercase**.
* Some files, such as top-level markdown files, are exceptions.
* Older files may use the `.markdown` extension. These may be ported to `.md`
at will. **Prefer `.md` for all new documents.**
* Documents should be word-wrapped at 80 characters.
* The formatting described in `.editorconfig` is preferred.
* A [plugin][] is available for some editors to automatically apply these rules.
* A [plugin][] is available for some editors to automatically apply these
rules.
* Mechanical issues, like spelling and grammar, should be identified by tools,
insofar as is possible. If not caught by a tool, they should be pointed out by
human reviewers.
* American English spelling is preferred. "Capitalize" vs. "Capitalise",
"color" vs. "colour", etc.
* Though controversial, the [Oxford comma][] is preferred for clarity's sake.
* Generally avoid personal pronouns in reference documentation ("I", "you",
"we".)
"we").
* Pronouns are acceptable in more colloquial documentation, like guides.
* Use **gender-neutral pronouns** and **mass nouns**. Non-comprehensive
examples:
* **OK**: "they", "their", "them", "folks", "people", "developers", "cats"
* **NOT OK**: "his", "hers", "him", "her", "guys", "dudes".
* **NOT OK**: "his", "hers", "him", "her", "guys", "dudes"
* When combining wrapping elements (parentheses and quotes), terminal
punctuation should be placed:
* Inside the wrapping element if the wrapping element contains a complete
Expand All @@ -39,7 +40,7 @@
* When documenting APIs, note the version the API was introduced in at
the end of the section. If an API has been deprecated, also note the first
version that the API appeared deprecated in.
* When using dashes, use emdashes ("—", Ctrl+Alt+"-" on macOS) surrounded by
* When using dashes, use emdashes ("—", Option+Shift+"-" on macOS) surrounded by
spaces, per the New York Times usage.
* Including assets:
* If you wish to add an illustration or full program, add it to the
Expand All @@ -54,10 +55,12 @@
your point, not as complete running programs. If a complete running program
is necessary, include it as an asset in `assets/code-examples` and link to
it.
* When using underscores, asterisks and backticks please use proper escaping (**\\\_**, **\\\*** and **\\\`** instead of **\_**, **\*** and **\`**)
* References to constructor functions should use PascalCase
* References to constructor instances should be camelCased
* References to methods should be used with parentheses: `socket.end()` instead of `socket.end`
* When using underscores, asterisks, and backticks, please use proper escaping
(**\\\_**, **\\\*** and **\\\`** instead of **\_**, **\*** and **\`**).
* References to constructor functions should use PascalCase.
* References to constructor instances should use camelCase.
* References to methods should be used with parentheses: for example,
`socket.end()` instead of `socket.end`.

[plugin]: http://editorconfig.org/#download
[Oxford comma]: https://en.wikipedia.org/wiki/Serial_comma
13 changes: 12 additions & 1 deletion doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To view this documentation as a manual page in a terminal, run `man node`.

## Synopsis

`node [options] [v8 options] [script.js | -e "script"] [--] [arguments]`
`node [options] [v8 options] [script.js | -e "script" | -] [--] [arguments]`

`node debug [script.js | -e "script" | <host>:<port>] …`

Expand Down Expand Up @@ -345,6 +345,17 @@ added: v0.11.15

Specify ICU data load path. (overrides `NODE_ICU_DATA`)


### `-`
<!-- YAML
added: REPLACEME
-->

Alias for stdin, analogous to the use of - in other command line utilities,
meaning that the script will be read from stdin, and the rest of the options
are passed to that script.


### `--`
<!-- YAML
added: v7.5.0
Expand Down
29 changes: 29 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,35 @@ in some cases may accept `func(undefined)` but not `func()`). In most native
Node.js APIs, `func(undefined)` and `func()` are treated identically, and the
[`ERR_INVALID_ARG_TYPE`][] error code may be used instead.

<a id="ERR_SOCKET_ALREADY_BOUND"></a>
### ERR_SOCKET_ALREADY_BOUND
An error using the `'ERR_SOCKET_ALREADY_BOUND'` code is thrown when an attempt
is made to bind a socket that has already been bound.

<a id="ERR_SOCKET_BAD_PORT"></a>
### ERR_SOCKET_BAD_PORT

An error using the `'ERR_SOCKET_BAD_PORT'` code is thrown when an API
function expecting a port > 0 and < 65536 receives an invalid value.

<a id="ERR_SOCKET_BAD_TYPE"></a>
### ERR_SOCKET_BAD_TYPE

An error using the `'ERR_SOCKET_BAD_TYPE'` code is thrown when an API
function expecting a socket type (`udp4` or `udp6`) receives an invalid value.

<a id="ERR_SOCKET_CANNOT_SEND"></a>
### ERR_SOCKET_CANNOT_SEND

An error using the `'ERR_SOCKET_CANNOT_SEND'` code is thrown when data
cannot be sent on a socket.

<a id="ERR_SOCKET_DGRAM_NOT_RUNNING"></a>
### ERR_SOCKET_DGRAM_NOT_RUNNING

An error using the `'ERR_SOCKET_DGRAM_NOT_RUNNING'` code is thrown
when a call is made and the UDP subsystem is not running.

<a id="ERR_STDERR_CLOSE"></a>
### ERR_STDERR_CLOSE

Expand Down
2 changes: 1 addition & 1 deletion doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ x is passed in it returns `napi_string_expected`.
This API returns the UTF8-encoded string corresponding the value passed in.
#### *napi_get_value_string_utf16_length*
#### *napi_get_value_string_utf16*
<!-- YAML
added: v8.0.0
-->
Expand Down
44 changes: 36 additions & 8 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const server = http.createServer((req, res) => {
res.write(typeof data);
res.end();
} catch (er) {
// uh oh! bad json!
// uh oh! bad json!
res.statusCode = 400;
return res.end(`error: ${er.message}`);
}
Expand All @@ -143,12 +143,12 @@ const server = http.createServer((req, res) => {

server.listen(1337);

// $ curl localhost:1337 -d '{}'
// $ curl localhost:1337 -d "{}"
// object
// $ curl localhost:1337 -d '"foo"'
// $ curl localhost:1337 -d "\"foo\""
// string
// $ curl localhost:1337 -d 'not json'
// error: Unexpected token o
// $ curl localhost:1337 -d "not json"
// error: Unexpected token o in JSON at position 1
```

[Writable][] streams (such as `res` in the example) expose methods such as
Expand Down Expand Up @@ -1157,6 +1157,7 @@ const Writable = require('stream').Writable;
class MyWritable extends Writable {
constructor(options) {
super(options);
// ...
}
}
```
Expand Down Expand Up @@ -1197,7 +1198,8 @@ on the type of stream being created, as detailed in the chart below:
<p>[Writable](#stream_class_stream_writable)</p>
</td>
<td>
<p><code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p>
<p><code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code>,
<code>[_final][stream-_final]</code></p>
</td>
</tr>
<tr>
Expand All @@ -1208,7 +1210,8 @@ on the type of stream being created, as detailed in the chart below:
<p>[Duplex](#stream_class_stream_duplex)</p>
</td>
<td>
<p><code>[_read][stream-_read]</code>, <code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p>
<p><code>[_read][stream-_read]</code>, <code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code>,
<code>[_final][stream-_final]</code></p>
</td>
</tr>
<tr>
Expand All @@ -1219,7 +1222,8 @@ on the type of stream being created, as detailed in the chart below:
<p>[Transform](#stream_class_stream_transform)</p>
</td>
<td>
<p><code>[_transform][stream-_transform]</code>, <code>[_flush][stream-_flush]</code></p>
<p><code>[_transform][stream-_transform]</code>, <code>[_flush][stream-_flush]</code>,
<code>[_final][stream-_final]</code></p>
</td>
</tr>
</table>
Expand Down Expand Up @@ -1278,6 +1282,8 @@ constructor and implement the `writable._write()` method. The
[`stream._writev()`][stream-_writev] method.
* `destroy` {Function} Implementation for the
[`stream._destroy()`][writable-_destroy] method.
* `final` {Function} Implementation for the
[`stream._final()`][stream-_final] method.

For example:

Expand All @@ -1288,6 +1294,7 @@ class MyWritable extends Writable {
constructor(options) {
// Calls the stream.Writable() constructor
super(options);
// ...
}
}
```
Expand Down Expand Up @@ -1396,6 +1403,22 @@ added: REPLACEME
* `callback` {Function} A callback function that takes an optional error argument
which is invoked when the writable is destroyed.

#### writable.\_final(callback)
<!-- YAML
added: REPLACEME
-->

* `callback` {Function} Call this function (optionally with an error
argument) when you are done writing any remaining data.

Note: `_final()` **must not** be called directly. It MAY be implemented
by child classes, and if so, will be called by the internal Writable
class methods only.

This optional function will be called before the stream closes, delaying the
`finish` event until `callback` is called. This is useful to close resources
or write buffered data before a stream ends.

#### Errors While Writing

It is recommended that errors occurring during the processing of the
Expand Down Expand Up @@ -1433,6 +1456,7 @@ const Writable = require('stream').Writable;
class MyWritable extends Writable {
constructor(options) {
super(options);
// ...
}

_write(chunk, encoding, callback) {
Expand Down Expand Up @@ -1477,6 +1501,7 @@ class MyReadable extends Readable {
constructor(options) {
// Calls the stream.Readable(options) constructor
super(options);
// ...
}
}
```
Expand Down Expand Up @@ -1690,6 +1715,7 @@ const Duplex = require('stream').Duplex;
class MyDuplex extends Duplex {
constructor(options) {
super(options);
// ...
}
}
```
Expand Down Expand Up @@ -1845,6 +1871,7 @@ const Transform = require('stream').Transform;
class MyTransform extends Transform {
constructor(options) {
super(options);
// ...
}
}
```
Expand Down Expand Up @@ -2109,6 +2136,7 @@ readable buffer so there is nothing for a user to consume.
[stream-_transform]: #stream_transform_transform_chunk_encoding_callback
[stream-_write]: #stream_writable_write_chunk_encoding_callback_1
[stream-_writev]: #stream_writable_writev_chunks_callback
[stream-_final]: #stream_writable_final_callback
[stream-end]: #stream_writable_end_chunk_encoding_callback
[stream-pause]: #stream_readable_pause
[stream-push]: #stream_readable_push_chunk_encoding
Expand Down
2 changes: 1 addition & 1 deletion doc/api/synopsis.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--type=misc-->

`node [options] [v8 options] [script.js | -e "script"] [arguments]`
`node [options] [v8 options] [script.js | -e "script" | - ] [arguments]`

Please see the [Command Line Options][] document for information about
different options and ways to run scripts with Node.js.
Expand Down
3 changes: 2 additions & 1 deletion doc/guides/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const common = require('../common');
The first line enables strict mode. All tests should be in strict mode unless
the nature of the test requires that the test run without it.

The second line loads the `common` module. The `common` module is a helper
The second line loads the `common` module. The [`common` module][] is a helper
module that provides useful tools for the tests.

Even if a test uses no functions or other properties exported by `common`,
Expand Down Expand Up @@ -340,3 +340,4 @@ will depend on what is being tested if this is required or not.
[Google Test]: https://github.com/google/googletest
[Test fixture]: https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#test-fixtures-using-the-same-data-configuration-for-multiple-tests
[`common` module]: https://github.com/nodejs/node/blob/master/test/common/README.md
11 changes: 10 additions & 1 deletion doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ node \- Server-side JavaScript runtime
.RI [ v8\ options ]
.RI [ script.js \ |
.B -e
.RI \&" script \&"]
.RI \&" script \&"
.R |
.B -
.R ]
.B [--]
.RI [ arguments ]
.br
Expand Down Expand Up @@ -225,6 +228,12 @@ See \fBSSL_CERT_DIR\fR and \fBSSL_CERT_FILE\fR.
.BR \-\-icu\-data\-dir =\fIfile\fR
Specify ICU data load path. (overrides \fBNODE_ICU_DATA\fR)

.TP
.BR \-\fR
Alias for stdin, analogous to the use of - in other command line utilities,
meaning that the script will be read from stdin, and the rest of the options
are passed to that script.

.TP
.BR \-\-\fR
Indicate the end of node options. Pass the rest of the arguments to the script.
Expand Down
Loading

0 comments on commit 1ef4c44

Please sign in to comment.