From 7588ceaf353af0f257d4d832bace4600edac704e Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 29 Apr 2018 20:46:41 +0300 Subject: doc: add more missing backticks Also, fix some other nits in passing (formatting, punctuation, typos, redundancy, obsoleteness). PR-URL: https://github.com/nodejs/node/pull/20438 Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Colin Ihrig --- doc/api/addons.md | 12 +- doc/api/assert.md | 51 ++++---- doc/api/async_hooks.md | 48 +++---- doc/api/buffer.md | 89 ++++++------- doc/api/child_process.md | 4 +- doc/api/cli.md | 12 +- doc/api/cluster.md | 20 +-- doc/api/crypto.md | 12 +- doc/api/debugger.md | 4 +- doc/api/deprecations.md | 8 +- doc/api/dgram.md | 4 +- doc/api/dns.md | 8 +- doc/api/domain.md | 28 ++-- doc/api/errors.md | 22 ++-- doc/api/esm.md | 4 +- doc/api/events.md | 8 +- doc/api/fs.md | 28 ++-- doc/api/http.md | 27 ++-- doc/api/http2.md | 125 +++++++++--------- doc/api/intl.md | 6 +- doc/api/modules.md | 22 ++-- doc/api/n-api.md | 34 ++--- doc/api/net.md | 29 ++--- doc/api/os.md | 4 +- doc/api/process.md | 30 ++--- doc/api/readline.md | 8 +- doc/api/repl.md | 16 +-- doc/api/stream.md | 328 ++++++++++++++++++++++++----------------------- doc/api/tls.md | 35 +++-- doc/api/tracing.md | 10 +- doc/api/tty.md | 10 +- doc/api/url.md | 38 +++--- doc/api/util.md | 41 +++--- doc/api/vm.md | 32 ++--- doc/api/zlib.md | 140 ++++++++++---------- 35 files changed, 649 insertions(+), 648 deletions(-) (limited to 'doc') diff --git a/doc/api/addons.md b/doc/api/addons.md index 46bc1e7522c..a207a71b717 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -9,7 +9,7 @@ just as if they were an ordinary Node.js module. They are used primarily to provide an interface between JavaScript running in Node.js and C/C++ libraries. At the moment, the method for implementing Addons is rather complicated, -involving knowledge of several components and APIs : +involving knowledge of several components and APIs: - V8: the C++ library Node.js currently uses to provide the JavaScript implementation. V8 provides the mechanisms for creating objects, @@ -93,7 +93,7 @@ There is no semi-colon after `NODE_MODULE` as it's not a function (see `node.h`). The `module_name` must match the filename of the final binary (excluding -the .node suffix). +the `.node` suffix). In the `hello.cc` example, then, the initialization function is `init` and the Addon module name is `addon`. @@ -1085,9 +1085,9 @@ console.log(result); ### AtExit hooks -An "AtExit" hook is a function that is invoked after the Node.js event loop +An `AtExit` hook is a function that is invoked after the Node.js event loop has ended but before the JavaScript VM is terminated and Node.js shuts down. -"AtExit" hooks are registered using the `node::AtExit` API. +`AtExit` hooks are registered using the `node::AtExit` API. #### void AtExit(callback, args) @@ -1099,12 +1099,12 @@ has ended but before the JavaScript VM is terminated and Node.js shuts down. Registers exit hooks that run after the event loop has ended but before the VM is killed. -AtExit takes two parameters: a pointer to a callback function to run at exit, +`AtExit` takes two parameters: a pointer to a callback function to run at exit, and a pointer to untyped context data to be passed to that callback. Callbacks are run in last-in first-out order. -The following `addon.cc` implements AtExit: +The following `addon.cc` implements `AtExit`: ```cpp // addon.cc diff --git a/doc/api/assert.md b/doc/api/assert.md index 468293b208a..43e5800ff03 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -165,10 +165,10 @@ added: v0.1.21 changes: - version: v9.0.0 pr-url: https://github.com/nodejs/node/pull/15001 - description: Error names and messages are now properly compared + description: The `Error` names and messages are now properly compared - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12142 - description: Set and Map content is also compared + description: The `Set` and `Map` content is also compared - version: v6.4.0, v4.7.1 pr-url: https://github.com/nodejs/node/pull/8002 description: Typed array slices are handled correctly now. @@ -208,7 +208,7 @@ the [`RegExp`][] object are not enumerable: assert.deepEqual(/a/gi, new Date()); ``` -An exception is made for [`Map`][] and [`Set`][]. Maps and Sets have their +An exception is made for [`Map`][] and [`Set`][]. `Map`s and `Set`s have their contained items compared too, as expected. "Deep" equality means that the enumerable "own" properties of child objects @@ -264,15 +264,15 @@ changes: description: Enumerable symbol properties are now compared. - version: v9.0.0 pr-url: https://github.com/nodejs/node/pull/15036 - description: NaN is now compared using the + description: The `NaN` is now compared using the [SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero) comparison. - version: v8.5.0 pr-url: https://github.com/nodejs/node/pull/15001 - description: Error names and messages are now properly compared + description: The `Error` names and messages are now properly compared - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12142 - description: Set and Map content is also compared + description: The `Set` and `Map` content is also compared - version: v6.4.0, v4.7.1 pr-url: https://github.com/nodejs/node/pull/8002 description: Typed array slices are handled correctly now. @@ -303,8 +303,8 @@ are recursively evaluated also by the following rules. enumerable properties. * Enumerable own [`Symbol`][] properties are compared as well. * [Object wrappers][] are compared both as objects and unwrapped values. -* Object properties are compared unordered. -* Map keys and Set items are compared unordered. +* `Object` properties are compared unordered. +* `Map` keys and `Set` items are compared unordered. * Recursion stops when both sides differ or both sides encounter a circular reference. * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. See @@ -413,10 +413,10 @@ function and awaits the returned promise to complete. It will then check that the promise is not rejected. If `block` is a function and it throws an error synchronously, -`assert.doesNotReject()` will return a rejected Promise with that error. If the -function does not return a promise, `assert.doesNotReject()` will return a -rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the -error handler is skipped. +`assert.doesNotReject()` will return a rejected `Promise` with that error. If +the function does not return a promise, `assert.doesNotReject()` will return a +rejected `Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases +the error handler is skipped. Please note: Using `assert.doesNotReject()` is actually not useful because there is little benefit by catching a rejection and then rejecting it again. Instead, @@ -494,7 +494,7 @@ assert.doesNotThrow( ``` However, the following will result in an `AssertionError` with the message -'Got unwanted exception (TypeError)..': +'Got unwanted exception...': ```js @@ -519,7 +519,7 @@ assert.doesNotThrow( /Wrong value/, 'Whoops' ); -// Throws: AssertionError: Got unwanted exception (TypeError). Whoops +// Throws: AssertionError: Got unwanted exception: Whoops ``` ## assert.equal(actual, expected[, message]) @@ -656,7 +656,7 @@ changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18247 description: Instead of throwing the original error it is now wrapped into - a AssertionError that contains the full stack trace. + an `AssertionError` that contains the full stack trace. - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18247 description: Value may now only be `undefined` or `null`. Before any truthy @@ -701,10 +701,10 @@ added: v0.1.21 changes: - version: v9.0.0 pr-url: https://github.com/nodejs/node/pull/15001 - description: Error names and messages are now properly compared + description: The `Error` names and messages are now properly compared - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12142 - description: Set and Map content is also compared + description: The `Set` and `Map` content is also compared - version: v6.4.0, v4.7.1 pr-url: https://github.com/nodejs/node/pull/8002 description: Typed array slices are handled correctly now. @@ -774,18 +774,18 @@ added: v1.2.0 changes: - version: v9.0.0 pr-url: https://github.com/nodejs/node/pull/15398 - description: -0 and +0 are not considered equal anymore. + description: The `-0` and `+0` are not considered equal anymore. - version: v9.0.0 pr-url: https://github.com/nodejs/node/pull/15036 - description: NaN is now compared using the + description: The `NaN` is now compared using the [SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero) comparison. - version: v9.0.0 pr-url: https://github.com/nodejs/node/pull/15001 - description: Error names and messages are now properly compared + description: The `Error` names and messages are now properly compared - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12142 - description: Set and Map content is also compared + description: The `Set` and `Map` content is also compared - version: v6.4.0, v4.7.1 pr-url: https://github.com/nodejs/node/pull/8002 description: Typed array slices are handled correctly now. @@ -893,7 +893,8 @@ added: v0.1.21 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18319 - description: assert.ok() (no arguments) will now use a predefined error msg. + description: The `assert.ok()` (no arguments) will now use a predefined + error message. --> * `value` {any} * `message` {any} @@ -907,7 +908,7 @@ parameter is `undefined`, a default error message is assigned. If the `message` parameter is an instance of an [`Error`][] then it will be thrown instead of the `AssertionError`. If no arguments are passed in at all `message` will be set to the string: -"No value argument passed to assert.ok". +``'No value argument passed to `assert.ok()`'``. Be aware that in the `repl` the error message will be different to the one thrown in a file! See below for further details. @@ -966,9 +967,9 @@ function and awaits the returned promise to complete. It will then check that the promise is rejected. If `block` is a function and it throws an error synchronously, -`assert.rejects()` will return a rejected Promise with that error. If the +`assert.rejects()` will return a rejected `Promise` with that error. If the function does not return a promise, `assert.rejects()` will return a rejected -Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error +`Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error handler is skipped. Besides the async nature to await the completion behaves identically to diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 601dad93e75..b97bc73304a 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -17,8 +17,8 @@ const async_hooks = require('async_hooks'); An asynchronous resource represents an object with an associated callback. This callback may be called multiple times, for example, the `'connection'` event in `net.createServer()`, or just a single time like in `fs.open()`. -A resource can also be closed before the callback is called. AsyncHook does not -explicitly distinguish between these different cases but will represent them +A resource can also be closed before the callback is called. `AsyncHook` does +not explicitly distinguish between these different cases but will represent them as the abstract concept that is a resource. ## Public API @@ -188,7 +188,7 @@ const hook = async_hooks.createHook(callbacks).enable(); * Returns: {AsyncHook} A reference to `asyncHook`. Disable the callbacks for a given `AsyncHook` instance from the global pool of -AsyncHook callbacks to be executed. Once a hook has been disabled it will not +`AsyncHook` callbacks to be executed. Once a hook has been disabled it will not be called again until enabled. For API consistency `disable()` also returns the `AsyncHook` instance. @@ -299,10 +299,10 @@ and document their own resource objects. For example, such a resource object could contain the SQL query being executed. In the case of Promises, the `resource` object will have `promise` property -that refers to the Promise that is being initialized, and a `isChainedPromise` -property, set to `true` if the promise has a parent promise, and `false` -otherwise. For example, in the case of `b = a.then(handler)`, `a` is considered -a parent Promise of `b`. Here, `b` is considered a chained promise. +that refers to the `Promise` that is being initialized, and an +`isChainedPromise` property, set to `true` if the promise has a parent promise, +and `false` otherwise. For example, in the case of `b = a.then(handler)`, `a` is +considered a parent `Promise` of `b`. Here, `b` is considered a chained promise. In some cases the resource object is reused for performance reasons, it is thus not safe to use it as a key in a `WeakMap` or add properties to it. @@ -466,7 +466,7 @@ added: v8.1.0 changes: - version: v8.2.0 pr-url: https://github.com/nodejs/node/pull/13490 - description: Renamed from currentId + description: Renamed from `currentId` --> * Returns: {number} The `asyncId` of the current execution context. Useful to @@ -498,7 +498,7 @@ const server = net.createServer(function onConnection(conn) { }); ``` -Note that promise contexts may not get precise executionAsyncIds by default. +Note that promise contexts may not get precise `executionAsyncIds` by default. See the section on [promise execution tracking][]. #### async_hooks.triggerAsyncId() @@ -521,12 +521,12 @@ const server = net.createServer((conn) => { }); ``` -Note that promise contexts may not get valid triggerAsyncIds by default. See +Note that promise contexts may not get valid `triggerAsyncId`s by default. See the section on [promise execution tracking][]. ## Promise execution tracking -By default, promise executions are not assigned asyncIds due to the relatively +By default, promise executions are not assigned `asyncId`s due to the relatively expensive nature of the [promise introspection API][PromiseHooks] provided by V8. This means that programs using promises or `async`/`await` will not get correct execution and trigger ids for promise callback contexts by default. @@ -542,10 +542,10 @@ Promise.resolve(1729).then(() => { // eid 1 tid 0 ``` -Observe that the `then` callback claims to have executed in the context of the +Observe that the `then()` callback claims to have executed in the context of the outer scope even though there was an asynchronous hop involved. Also note that -the triggerAsyncId value is 0, which means that we are missing context about the -resource that caused (triggered) the `then` callback to be executed. +the `triggerAsyncId` value is `0`, which means that we are missing context about +the resource that caused (triggered) the `then()` callback to be executed. Installing async hooks via `async_hooks.createHook` enables promise execution tracking. Example: @@ -562,15 +562,16 @@ Promise.resolve(1729).then(() => { In this example, adding any actual hook function enabled the tracking of promises. There are two promises in the example above; the promise created by -`Promise.resolve()` and the promise returned by the call to `then`. In the -example above, the first promise got the asyncId 6 and the latter got asyncId 7. -During the execution of the `then` callback, we are executing in the context of -promise with asyncId 7. This promise was triggered by async resource 6. +`Promise.resolve()` and the promise returned by the call to `then()`. In the +example above, the first promise got the `asyncId` `6` and the latter got +`asyncId` `7`. During the execution of the `then()` callback, we are executing +in the context of promise with `asyncId` `7`. This promise was triggered by +async resource `6`. Another subtlety with promises is that `before` and `after` callbacks are run -only on chained promises. That means promises not created by `then`/`catch` will -not have the `before` and `after` callbacks fired on them. For more details see -the details of the V8 [PromiseHooks][] API. +only on chained promises. That means promises not created by `then()`/`catch()` +will not have the `before` and `after` callbacks fired on them. For more details +see the details of the V8 [PromiseHooks][] API. ## JavaScript Embedder API @@ -632,8 +633,9 @@ asyncResource.emitAfter(); async event. **Default:** `executionAsyncId()`. * `requireManualDestroy` {boolean} Disables automatic `emitDestroy` when the object is garbage collected. This usually does not need to be set (even if - `emitDestroy` is called manually), unless the resource's asyncId is retrieved - and the sensitive API's `emitDestroy` is called with it. **Default:** `false`. + `emitDestroy` is called manually), unless the resource's `asyncId` is + retrieved and the sensitive API's `emitDestroy` is called with it. + **Default:** `false`. Example usage: diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 312b4f7c17f..c219f00e4a1 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -221,7 +221,7 @@ elements, and not as a byte array of the target type. That is, `[0x1020304]` or `[0x4030201]`. It is possible to create a new `Buffer` that shares the same allocated memory as -a [`TypedArray`] instance by using the TypeArray object's `.buffer` property. +a [`TypedArray`] instance by using the `TypeArray` object's `.buffer` property. ```js const arr = new Uint16Array(2); @@ -427,7 +427,8 @@ changes: run from code outside the `node_modules` directory. - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12141 - description: new Buffer(size) will return zero-filled memory by default. + description: The `new Buffer(size)` will return zero-filled memory by + default. - version: v7.2.1 pr-url: https://github.com/nodejs/node/pull/9529 description: Calling this constructor no longer emits a deprecation warning. @@ -980,8 +981,8 @@ console.log(buf.toString('ascii')); ### buf.buffer -The `buffer` property references the underlying `ArrayBuffer` object based on -which this Buffer object is created. +* {ArrayBuffer} The underlying `ArrayBuffer` object based on + which this `Buffer` object is created. ```js const arrayBuffer = new ArrayBuffer(16); @@ -1507,8 +1508,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1537,8 +1538,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1566,8 +1567,8 @@ added: v0.5.0 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1596,8 +1597,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1628,8 +1629,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1660,8 +1661,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset and - byteLength to uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + and `byteLength` to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1693,8 +1694,8 @@ added: v0.5.0 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1721,8 +1722,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1755,8 +1756,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -1785,8 +1786,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset and - byteLength to uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + and `byteLength` to `uint32` anymore. --> * `offset` {integer} Number of bytes to skip before starting to read. Must @@ -2102,8 +2103,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {number} Number to be written to `buf`. @@ -2137,8 +2138,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {number} Number to be written to `buf`. @@ -2171,8 +2172,8 @@ added: v0.5.0 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2203,8 +2204,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2236,8 +2237,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2269,8 +2270,8 @@ added: v0.11.15 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset and - byteLength to uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + and `byteLength` to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2304,8 +2305,8 @@ added: v0.5.0 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2336,8 +2337,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2373,8 +2374,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset to - uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. @@ -2408,8 +2409,8 @@ added: v0.5.5 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18395 - description: Removed noAssert and no implicit coercion of the offset and - byteLength to uint32 anymore. + description: Removed `noAssert` and no implicit coercion of the offset + and `byteLength` to `uint32` anymore. --> * `value` {integer} Number to be written to `buf`. diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 47d68928e46..1fc2855e4f6 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -211,7 +211,7 @@ Unlike the exec(3) POSIX system call, `child_process.exec()` does not replace the existing process and uses a shell to execute the command. If this method is invoked as its [`util.promisify()`][]ed version, it returns -a Promise for an object with `stdout` and `stderr` properties. In case of an +a `Promise` for an `Object` with `stdout` and `stderr` properties. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same `error` object given in the callback, but with an additional two properties `stdout` and `stderr`. @@ -290,7 +290,7 @@ stderr output. If `encoding` is `'buffer'`, or an unrecognized character encoding, `Buffer` objects will be passed to the callback instead. If this method is invoked as its [`util.promisify()`][]ed version, it returns -a Promise for an object with `stdout` and `stderr` properties. In case of an +a `Promise` for an `Object` with `stdout` and `stderr` properties. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same `error` object given in the callback, but with an additional two properties `stdout` and `stderr`. diff --git a/doc/api/cli.md b/doc/api/cli.md index 5bc673f5975..6d055d9d03a 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -101,25 +101,25 @@ Specify ICU data load path. (Overrides `NODE_ICU_DATA`.) added: v7.6.0 --> -Activate inspector on host:port and break at start of user script. -Default host:port is 127.0.0.1:9229. +Activate inspector on `host:port` and break at start of user script. +Default `host:port` is `127.0.0.1:9229`. ### `--inspect-port=[host:]port` -Set the host:port to be used when the inspector is activated. +Set the `host:port` to be used when the inspector is activated. Useful when activating the inspector by sending the `SIGUSR1` signal. -Default host is 127.0.0.1. +Default host is `127.0.0.1`. ### `--inspect[=[host:]port]` -Activate inspector on host:port. Default is 127.0.0.1:9229. +Activate inspector on `host:port`. Default is `127.0.0.1:9229`. V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug and profile Node.js instances. The tools attach to Node.js instances via a @@ -461,7 +461,7 @@ options property is explicitly specified for a TLS or HTTPS client or server. added: v0.11.15 --> -Data path for ICU (Intl object) data. Will extend linked-in data when compiled +Data path for ICU (`Intl` object) data. Will extend linked-in data when compiled with small-icu support. ### `NODE_NO_WARNINGS=1` diff --git a/doc/api/cluster.md b/doc/api/cluster.md index 7c0baa36ff5..b420645bb4d 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -117,7 +117,7 @@ also be used for other use cases requiring worker processes. added: v0.7.0 --> -A Worker object contains all public information and method about a worker. +A `Worker` object contains all public information and method about a worker. In the master it can be obtained using `cluster.workers`. In a worker it can be obtained using `cluster.worker`. @@ -497,7 +497,7 @@ cluster.on('exit', (worker, code, signal) => { }); ``` -See [child_process event: `'exit'`][]. +See [`child_process` event: `'exit'`][]. ## Event: 'fork' -If domains are in use, then all **new** EventEmitter objects (including +If domains are in use, then all **new** `EventEmitter` objects (including Stream objects, requests, responses, etc.) will be implicitly bound to the active domain at the time of their creation. Additionally, callbacks passed to lowlevel event loop requests (such as -to fs.open, or other callback-taking methods) will automatically be +to `fs.open()`, or other callback-taking methods) will automatically be bound to the active domain. If they throw, then the domain will catch the error. -In order to prevent excessive memory usage, Domain objects themselves +In order to prevent excessive memory usage, `Domain` objects themselves are not implicitly added as children of the active domain. If they were, then it would be too easy to prevent request and response objects from being properly garbage collected. -To nest Domain objects as children of a parent Domain they must be explicitly -added. +To nest `Domain` objects as children of a parent `Domain` they must be +explicitly added. Implicit binding routes thrown errors and `'error'` events to the -Domain's `'error'` event, but does not register the EventEmitter on the -Domain. +`Domain`'s `'error'` event, but does not register the `EventEmitter` on the +`Domain`. Implicit binding only takes care of thrown errors and `'error'` events. ## Explicit Binding @@ -271,14 +271,12 @@ serverDomain.run(() => { * Returns: {Domain} -Returns a new Domain object. - ## Class: Domain -The Domain class encapsulates the functionality of routing errors and -uncaught exceptions to the active Domain object. +The `Domain` class encapsulates the functionality of routing errors and +uncaught exceptions to the active `Domain` object. -Domain is a child class of [`EventEmitter`][]. To handle the errors that it +`Domain` is a child class of [`EventEmitter`][]. To handle the errors that it catches, listen to its `'error'` event. ### domain.members @@ -301,7 +299,7 @@ This also works with timers that are returned from [`setInterval()`][] and [`setTimeout()`][]. If their callback function throws, it will be caught by the domain `'error'` handler. -If the Timer or EventEmitter was already bound to a domain, it is removed +If the Timer or `EventEmitter` was already bound to a domain, it is removed from that one, and bound to this one instead. ### domain.bind(callback) @@ -444,7 +442,7 @@ than crashing the program. ## Domains and Promises As of Node.js 8.0.0, the handlers of Promises are run inside the domain in -which the call to `.then` or `.catch` itself was made: +which the call to `.then()` or `.catch()` itself was made: ```js const d1 = domain.create(); @@ -481,7 +479,7 @@ d2.run(() => { ``` Note that domains will not interfere with the error handling mechanisms for -Promises, i.e. no `'error'` event will be emitted for unhandled Promise +Promises, i.e. no `'error'` event will be emitted for unhandled `Promise` rejections. [`Error`]: errors.html#errors_class_error diff --git a/doc/api/errors.md b/doc/api/errors.md index c34559303ca..99c830b895c 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -18,7 +18,7 @@ errors: as attempting to open a file that does not exist, attempting to send data over a closed socket, etc; - And User-specified errors triggered by application code. -- Assertion Errors are a special class of error that can be triggered whenever +- `AssertionError`s are a special class of error that can be triggered whenever Node.js detects an exceptional logic violation that should never occur. These are raised typically by the `assert` module. @@ -32,7 +32,7 @@ to provide *at least* the properties available on that class. Node.js supports several mechanisms for propagating and handling errors that occur while an application is running. How these errors are reported and -handled depends entirely on the type of Error and the style of the API that is +handled depends entirely on the type of `Error` and the style of the API that is called. All JavaScript errors are handled as exceptions that *immediately* generate @@ -137,7 +137,7 @@ pattern referred to as an _error-first callback_ (sometimes referred to as a _Node.js style callback_). With this pattern, a callback function is passed to the method as an argument. When the operation either completes or an error is raised, the callback function is called with -the Error object (if any) passed as the first argument. If no error was +the `Error` object (if any) passed as the first argument. If no error was raised, the first argument will be passed as `null`. ```js @@ -422,7 +422,7 @@ they may only be caught by other contexts. A subclass of `Error` that indicates that a provided argument is not an allowable type. For example, passing a function to a parameter which expects a -string would be considered a TypeError. +string would be considered a `TypeError`. ```js require('url').parse(() => { }); @@ -440,7 +440,7 @@ A JavaScript exception is a value that is thrown as a result of an invalid operation or as the target of a `throw` statement. While it is not required that these values are instances of `Error` or classes which inherit from `Error`, all exceptions thrown by Node.js or the JavaScript runtime *will* be -instances of Error. +instances of `Error`. Some exceptions are *unrecoverable* at the JavaScript layer. Such exceptions will *always* cause the Node.js process to crash. Examples include `assert()` @@ -492,7 +492,7 @@ typically `E` followed by a sequence of capital letters. The `error.errno` property is a number or a string. The number is a **negative** value which corresponds to the error code defined -in [`libuv Error handling`]. See uv-errno.h header file +in [`libuv Error handling`]. See `uv-errno.h` header file (`deps/uv/include/uv-errno.h` in the Node.js source tree) for details. In case of a string, it is the same as `error.code`. @@ -1081,7 +1081,7 @@ An invalid or unsupported value was passed for a given argument. ### ERR_INVALID_ARRAY_LENGTH -An Array was not of the expected length or in a valid range. +An array was not of the expected length or in a valid range. ### ERR_INVALID_ASYNC_ID @@ -1515,7 +1515,7 @@ length. ### ERR_TLS_CERT_ALTNAME_INVALID While using TLS, the hostname/IP of the peer did not match any of the -subjectAltNames in its certificate. +`subjectAltNames` in its certificate. ### ERR_TLS_DH_PARAM_SIZE @@ -1569,12 +1569,12 @@ the `--without-v8-platform` flag. ### ERR_TRANSFORM_ALREADY_TRANSFORMING -A Transform stream finished while it was still transforming. +A `Transform` stream finished while it was still transforming. ### ERR_TRANSFORM_WITH_LENGTH_0 -A Transform stream finished with data still in the write buffer. +A `Transform` stream finished with data still in the write buffer. ### ERR_TTY_INIT_FAILED @@ -1649,7 +1649,7 @@ itself, although it is possible for user code to trigger it. ### ERR_V8BREAKITERATOR -The V8 BreakIterator API was used but the full ICU data set is not installed. +The V8 `BreakIterator` API was used but the full ICU data set is not installed. ### ERR_VALID_PERFORMANCE_ENTRY_TYPE diff --git a/doc/api/esm.md b/doc/api/esm.md index 4090e545fdb..a1e3cb149ab 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -134,8 +134,8 @@ export async function resolve(specifier, } ``` -The parentURL is provided as `undefined` when performing main Node.js load -itself. +The `parentModuleURL` is provided as `undefined` when performing main Node.js +load itself. The default Node.js ES module resolution function is provided as a third argument to the resolver for easy compatibility workflows. diff --git a/doc/api/events.md b/doc/api/events.md index e5ae1e3fe7b..536a87d1b46 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -8,7 +8,7 @@ Much of the Node.js core API is built around an idiomatic asynchronous event-driven architecture in which certain kinds of objects (called "emitters") -periodically emit named events that cause Function objects ("listeners") to be +periodically emit named events that cause `Function` objects ("listeners") to be called. For instance: a [`net.Server`][] object emits an event each time a peer @@ -167,7 +167,7 @@ The `EventEmitter` class is defined and exposed by the `events` module: const EventEmitter = require('events'); ``` -All EventEmitters emit the event `'newListener'` when new listeners are +All `EventEmitter`s emit the event `'newListener'` when new listeners are added and `'removeListener'` when existing listeners are removed. ### Event: 'newListener' @@ -314,7 +314,7 @@ added: v6.0.0 - Returns: {Array} Returns an array listing the events for which the emitter has registered -listeners. The values in the array will be strings or Symbols. +listeners. The values in the array will be strings or `Symbol`s. ```js const EventEmitter = require('events'); @@ -589,7 +589,7 @@ added: v0.3.5 - `n` {integer} - Returns: {EventEmitter} -By default EventEmitters will print a warning if more than `10` listeners are +By default `EventEmitter`s will print a warning if more than `10` listeners are added for a particular event. This is a useful default that helps finding memory leaks. Obviously, not all events should be limited to just 10 listeners. The `emitter.setMaxListeners()` method allows the limit to be modified for this diff --git a/doc/api/fs.md b/doc/api/fs.md index 6e3628c8fbb..8ac0cf4833c 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -177,7 +177,7 @@ Using WHATWG [`URL`][] objects might introduce platform-specific behaviors. On Windows, `file:` URLs with a hostname convert to UNC paths, while `file:` URLs with drive letters convert to local absolute paths. `file:` URLs without a -hostname nor a drive letter will result in a throw : +hostname nor a drive letter will result in a throw: ```js // On Windows : @@ -1730,7 +1730,7 @@ fs.ftruncate(fd, 4, (err) => { ``` If the file previously was shorter than `len` bytes, it is extended, and the -extended part is filled with null bytes ('\0'). For example, +extended part is filled with null bytes (`'\0'`). For example, ```js console.log(fs.readFileSync('temp.txt', 'utf8')); @@ -1748,7 +1748,7 @@ fs.ftruncate(fd, 10, (err) => { // ('Node.js\0\0\0' in UTF8) ``` -The last three bytes are null bytes ('\0'), to compensate the over-truncation. +The last three bytes are null bytes (`'\0'`), to compensate the over-truncation. ## fs.ftruncateSync(fd[, len]) * `atime` {number|string|Date} -* `mtime` {number|string|Date}` +* `mtime` {number|string|Date} * Returns: {Promise} Change the file system timestamps of the object referenced by the `FileHandle` @@ -3878,7 +3878,7 @@ doTruncate().catch(console.error); ``` If the file previously was shorter than `len` bytes, it is extended, and the -extended part is filled with null bytes ('\0'). For example, +extended part is filled with null bytes (`'\0'`). For example, ```js console.log(fs.readFileSync('temp.txt', 'utf8')); @@ -3893,7 +3893,7 @@ async function doTruncate() { doTruncate().catch(console.error); ``` -The last three bytes are null bytes ('\0'), to compensate the over-truncation. +The last three bytes are null bytes (`'\0'`), to compensate the over-truncation. ### fsPromises.futimes(filehandle, atime, mtime) @@ -924,10 +924,7 @@ This method is identical to [`server.listen()`][] from [`net.Server`][]. added: v5.7.0 --> -* {boolean} - -A Boolean indicating whether or not the server is listening for -connections. +* {boolean} Indicates whether or not the server is listening for connections. ### server.maxHeadersCount - `options` {Object} - * `IncomingMessage` {http.IncomingMessage} Specifies the IncomingMessage class - to be used. Useful for extending the original `IncomingMessage`. + * `IncomingMessage` {http.IncomingMessage} Specifies the `IncomingMessage` + class to be used. Useful for extending the original `IncomingMessage`. **Default:** `IncomingMessage`. - * `ServerResponse` {http.ServerResponse} Specifies the ServerResponse class to - be used. Useful for extending the original `ServerResponse`. **Default:** + * `ServerResponse` {http.ServerResponse} Specifies the `ServerResponse` class + to be used. Useful for extending the original `ServerResponse`. **Default:** `ServerResponse`. - `requestListener` {Function} @@ -1868,8 +1865,8 @@ changes: v6 will be used. * `port` {number} Port of remote server. **Default:** `80`. * `localAddress` {string} Local interface to bind for network connections. - * `socketPath` {string} Unix Domain Socket (use one of host:port or - socketPath). + * `socketPath` {string} Unix Domain Socket (use one of `host:port` or + `socketPath`). * `method` {string} A string specifying the HTTP request method. **Default:** `'GET'`. * `path` {string} Request path. Should include query string if any. @@ -2073,7 +2070,7 @@ not abort the request or do anything besides add a `'timeout'` event. [`socket.setKeepAlive()`]: net.html#net_socket_setkeepalive_enable_initialdelay [`socket.setNoDelay()`]: net.html#net_socket_setnodelay_nodelay [`socket.setTimeout()`]: net.html#net_socket_settimeout_timeout_callback +[`socket.unref()`]: net.html#net_socket_unref [`url.parse()`]: url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost [Readable Stream]: stream.html#stream_class_stream_readable [Writable Stream]: stream.html#stream_class_stream_writable -[socket.unref()]: net.html#net_socket_unref diff --git a/doc/api/http2.md b/doc/api/http2.md index b3aac4741ee..566cdc065e1 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -108,7 +108,7 @@ have occasion to work with the `Http2Session` object directly, with most actions typically taken through interactions with either the `Http2Server` or `Http2Stream` objects. -#### Http2Session and Sockets +#### `Http2Session` and Sockets Every `Http2Session` instance is associated with exactly one [`net.Socket`][] or [`tls.TLSSocket`][] when it is created. When either the `Socket` or the @@ -410,7 +410,7 @@ added: v9.4.0 * {string[]|undefined} If the `Http2Session` is connected to a `TLSSocket`, the `originSet` property -will return an Array of origins for which the `Http2Session` may be +will return an `Array` of origins for which the `Http2Session` may be considered authoritative. #### http2session.pendingSettingsAck @@ -500,12 +500,12 @@ added: v8.4.0 * {net.Socket|tls.TLSSocket} -Returns a Proxy object that acts as a `net.Socket` (or `tls.TLSSocket`) but +Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but limits available methods to ones safe to use with HTTP/2. `destroy`, `emit`, `end`, `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See -[Http2Session and Sockets][] for more information. +[`Http2Session` and Sockets][] for more information. `setTimeout` method will be called on this `Http2Session`. @@ -592,8 +592,9 @@ added: v9.4.0 * `alt` {string} A description of the alternative service configuration as defined by [RFC 7838][]. * `originOrStream` {number|string|URL|Object} Either a URL string specifying - the origin (or an Object with an `origin` property) or the numeric identifier - of an active `Http2Stream` as given by the `http2stream.id` property. + the origin (or an `Object` with an `origin` property) or the numeric + identifier of an active `Http2Stream` as given by the `http2stream.id` + property. Submits an `ALTSVC` frame (as defined by [RFC 7838][]) to the connected client. @@ -1041,7 +1042,7 @@ Provides miscellaneous information about the current state of the * `localWindowSize` {number} The number of bytes the connected peer may send for this `Http2Stream` without receiving a `WINDOW_UPDATE`. * `state` {number} A flag indicating the low-level current state of the - `Http2Stream` as determined by nghttp2. + `Http2Stream` as determined by `nghttp2`. * `localClose` {number} `true` if this `Http2Stream` has been closed locally. * `remoteClose` {number} `true` if this `Http2Stream` has been closed remotely. @@ -1140,7 +1141,7 @@ added: v8.4.0 The `'response'` event is emitted when a response `HEADERS` frame has been received for this stream from the connected HTTP/2 server. The listener is -invoked with two arguments: an Object containing the received +invoked with two arguments: an `Object` containing the received [HTTP/2 Headers Object][], and flags associated with the headers. ```js @@ -1180,7 +1181,7 @@ added: v8.4.0 * {boolean} -Boolean (read-only). True if headers were sent, false otherwise. +True if headers were sent, false otherwise (read-only). #### http2stream.pushAllowed -* {Object} Module object +* {module} The module that first required this one. diff --git a/doc/api/n-api.md b/doc/api/n-api.md index fcbd4decb35..3ba902f1df5 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -43,7 +43,7 @@ part of N-API, nor will they be maintained as part of Node.js. One such example is: [node-api](https://github.com/nodejs/node-api). In order to use the N-API functions, include the file -[node_api.h](https://github.com/nodejs/node/blob/master/src/node_api.h) +[`node_api.h`](https://github.com/nodejs/node/blob/master/src/node_api.h) which is located in the src directory in the node development tree: ```C @@ -434,7 +434,7 @@ NODE_EXTERN napi_status napi_create_error(napi_env env, ``` - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional `napi_value` with the string for the error code to - be associated with the error. +be associated with the error. - `[in] msg`: `napi_value` that references a JavaScript `String` to be used as the message for the `Error`. - `[out] result`: `napi_value` representing the error created. @@ -455,7 +455,7 @@ NODE_EXTERN napi_status napi_create_type_error(napi_env env, ``` - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional `napi_value` with the string for the error code to - be associated with the error. +be associated with the error. - `[in] msg`: `napi_value` that references a JavaScript `String` to be used as the message for the `Error`. - `[out] result`: `napi_value` representing the error created. @@ -476,7 +476,7 @@ NODE_EXTERN napi_status napi_create_range_error(napi_env env, ``` - `[in] env`: The environment that the API is invoked under. - `[in] code`: Optional `napi_value` with the string for the error code to - be associated with the error. +be associated with the error. - `[in] msg`: `napi_value` that references a JavaScript `String` to be used as the message for the `Error`. - `[out] result`: `napi_value` representing the error created. @@ -1275,7 +1275,7 @@ This API allocates a `node::Buffer` object and initializes it with data backed by the passed in buffer. While this is still a fully-supported data structure, in most cases using a `TypedArray` will suffice. -For Node.js >=4 `Buffers` are Uint8Arrays. +For Node.js >=4 `Buffers` are `Uint8Array`s. #### napi_create_function -A Boolean indicating whether or not the server is listening for -connections. +* {boolean} Indicates whether or not the server is listening for connections. ### server.maxConnections @@ -234,7 +234,7 @@ process.on('unhandledRejection', (reason, p) => { somePromise.then((res) => { return reportToUser(JSON.pasre(res)); // note the typo (`pasre`) -}); // no `.catch` or `.then` +}); // no `.catch()` or `.then()` ``` The following will also trigger the `'unhandledRejection'` event to be @@ -524,7 +524,7 @@ added: v0.7.7 * {Object} -The `process.config` property returns an Object containing the JavaScript +The `process.config` property returns an `Object` containing the JavaScript representation of the configure options used to compile the current Node.js executable. This is the same as the `config.gypi` file that was produced when running the `./configure` script. @@ -699,10 +699,10 @@ added: v8.0.0 * `warning` {string|Error} The warning to emit. * `options` {Object} - * `type` {string} When `warning` is a String, `type` is the name to use + * `type` {string} When `warning` is a `String`, `type` is the name to use for the *type* of warning being emitted. **Default:** `'Warning'`. * `code` {string} A unique identifier for the warning instance being emitted. - * `ctor` {Function} When `warning` is a String, `ctor` is an optional + * `ctor` {Function} When `warning` is a `String`, `ctor` is an optional function used to limit the generated stack trace. **Default:** `process.emitWarning`. * `detail` {string} Additional text to include with the error. @@ -744,10 +744,10 @@ added: v6.0.0 --> * `warning` {string|Error} The warning to emit. -* `type` {string} When `warning` is a String, `type` is the name to use +* `type` {string} When `warning` is a `String`, `type` is the name to use for the *type* of warning being emitted. **Default:** `'Warning'`. * `code` {string} A unique identifier for the warning instance being emitted. -* `ctor` {Function} When `warning` is a String, `ctor` is an optional +* `ctor` {Function} When `warning` is a `String`, `ctor` is an optional function used to limit the generated stack trace. **Default:** `process.emitWarning`. @@ -1151,12 +1151,12 @@ added: v0.7.6 * Returns: {integer[]} The `process.hrtime()` method returns the current high-resolution real time -in a `[seconds, nanoseconds]` tuple Array, where `nanoseconds` is the +in a `[seconds, nanoseconds]` tuple `Array`, where `nanoseconds` is the remaining part of the real time that can't be represented in second precision. `time` is an optional parameter that must be the result of a previous `process.hrtime()` call to diff with the current time. If the parameter -passed in is not a tuple Array, a `TypeError` will be thrown. Passing in a +passed in is not a tuple `Array`, a `TypeError` will be thrown. Passing in a user-defined array instead of the result of a previous call to `process.hrtime()` will lead to undefined behavior. @@ -1401,7 +1401,7 @@ function definitelyAsync(arg, cb) { The next tick queue is completely drained on each pass of the event loop **before** additional I/O is processed. As a result, recursively setting -nextTick callbacks will block any I/O from happening, just like a +`nextTick()` callbacks will block any I/O from happening, just like a `while(true);` loop. ## process.noDeprecation @@ -1482,8 +1482,8 @@ changes: * {Object} -The `process.release` property returns an Object containing metadata related to -the current release, including URLs for the source tarball and headers-only +The `process.release` property returns an `Object` containing metadata related +to the current release, including URLs for the source tarball and headers-only tarball. `process.release` contains the following properties: @@ -1741,7 +1741,7 @@ The `process.stdout` property returns a stream connected to stream) unless fd `1` refers to a file, in which case it is a [Writable][] stream. -For example, to copy process.stdin to process.stdout: +For example, to copy `process.stdin` to `process.stdout`: ```js process.stdin.pipe(process.stdout); @@ -1961,7 +1961,7 @@ cases: * `7` **Internal Exception Handler Run-Time Failure** - There was an uncaught exception, and the internal fatal exception handler function itself threw an error while attempting to handle it. This - can happen, for example, if a [`'uncaughtException'`][] or + can happen, for example, if an [`'uncaughtException'`][] or `domain.on('error')` handler throws an error. * `8` - Unused. In previous versions of Node.js, exit code 8 sometimes indicated an uncaught exception. diff --git a/doc/api/readline.md b/doc/api/readline.md index ead469e97c9..a2a4adf3093 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -303,7 +303,7 @@ rl.write('Delete this!'); rl.write(null, { ctrl: true, name: 'u' }); ``` -The `rl.write()` method will write the data to the `readline` Interface's +The `rl.write()` method will write the data to the `readline` `Interface`'s `input` *as if it were provided by the user*. ## readline.clearLine(stream, dir) @@ -401,9 +401,9 @@ a `'resize'` event on the `output` if or when the columns ever change ### Use of the `completer` Function The `completer` function takes the current line entered by the user -as an argument, and returns an Array with 2 entries: +as an argument, and returns an `Array` with 2 entries: -* An Array with matching entries for the completion. +* An `Array` with matching entries for the completion. * The substring that was used for the matching. For instance: `[[substr1, substr2, ...], originalsubstring]`. @@ -447,7 +447,7 @@ added: v0.7.7 * `interface` {readline.Interface} The `readline.emitKeypressEvents()` method causes the given [Readable][] -`stream` to begin emitting `'keypress'` events corresponding to received input. +stream to begin emitting `'keypress'` events corresponding to received input. Optionally, `interface` specifies a `readline.Interface` instance for which autocompletion is disabled when copy-pasted input is detected. diff --git a/doc/api/repl.md b/doc/api/repl.md index 995dabaa5d8..b751472049a 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -63,7 +63,7 @@ The following key combinations in the REPL have these special effects: When pressed twice on a blank line, has the same effect as the `.exit` command. * `-D` - Has the same effect as the `.exit` command. -* `` - When pressed on a blank line, displays global and local(scope) +* `` - When pressed on a blank line, displays global and local (scope) variables. When pressed while entering other input, displays relevant autocompletion options. @@ -251,7 +251,7 @@ function isRecoverableError(error) { ### Customizing REPL Output By default, `repl.REPLServer` instances format output using the -[`util.inspect()`][] method before writing the output to the provided Writable +[`util.inspect()`][] method before writing the output to the provided `Writable` stream (`process.stdout` by default). The `useColors` boolean option can be specified at construction to instruct the default writer to use ANSI style codes to colorize the output from the `util.inspect()` method. @@ -356,7 +356,7 @@ added: v0.3.0 The `replServer.defineCommand()` method is used to add new `.`-prefixed commands to the REPL instance. Such commands are invoked by typing a `.` followed by the -`keyword`. The `cmd` is either a Function or an object with the following +`keyword`. The `cmd` is either a `Function` or an `Object` with the following properties: * `help` {string} Help text to be displayed when `.help` is entered (Optional). @@ -443,7 +443,7 @@ added: v0.1.91 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/v10.0.0 - description: The `REPL_MAGIC_MODE` replMode was removed. + description: The `REPL_MAGIC_MODE` `replMode` was removed. - version: v5.8.0 pr-url: https://github.com/nodejs/node/pull/5388 description: The `options` parameter is optional now. @@ -452,10 +452,10 @@ changes: * `options` {Object|string} * `prompt` {string} The input prompt to display. **Default:** `'> '` (with a trailing space). - * `input` {stream.Readable} The Readable stream from which REPL input will be - read. **Default:** `process.stdin`. - * `output` {stream.Writable} The Writable stream to which REPL output will be - written. **Default:** `process.stdout`. + * `input` {stream.Readable} The `Readable` stream from which REPL input will + be read. **Default:** `process.stdin`. + * `output` {stream.Writable} The `Writable` stream to which REPL output will + be written. **Default:** `process.stdout`. * `terminal` {boolean} If `true`, specifies that the `output` should be treated as a TTY terminal, and have ANSI/VT100 escape codes written to it. **Default:** checking the value of the `isTTY` property on the `output` diff --git a/doc/api/stream.md b/doc/api/stream.md index 8af12d12bf0..483aec1b700 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -37,13 +37,13 @@ the elements of the API that are required to *implement* new types of streams. There are four fundamental stream types within Node.js: -* [Readable][] - streams from which data can be read (for example +* [`Readable`][] - streams from which data can be read (for example [`fs.createReadStream()`][]). -* [Writable][] - streams to which data can be written (for example +* [`Writable`][] - streams to which data can be written (for example [`fs.createWriteStream()`][]). -* [Duplex][] - streams that are both Readable and Writable (for example +* [`Duplex`][] - streams that are both `Readable` and `Writable` (for example [`net.Socket`][]). -* [Transform][] - Duplex streams that can modify or transform the data as it +* [`Transform`][] - `Duplex` streams that can modify or transform the data as it is written and read (for example [`zlib.createDeflate()`][]). Additionally this module includes the utility functions [pipeline][] and @@ -65,7 +65,7 @@ object mode is not safe. -Both [Writable][] and [Readable][] streams will store data in an internal +Both [`Writable`][] and [`Readable`][] streams will store data in an internal buffer that can be retrieved using `writable.writableBuffer` or `readable.readableBuffer`, respectively. @@ -74,7 +74,7 @@ passed into the streams constructor. For normal streams, the `highWaterMark` option specifies a [total number of bytes][hwm-gotcha]. For streams operating in object mode, the `highWaterMark` specifies a total number of objects. -Data is buffered in Readable streams when the implementation calls +Data is buffered in `Readable` streams when the implementation calls [`stream.push(chunk)`][stream-push]. If the consumer of the Stream does not call [`stream.read()`][stream-read], the data will sit in the internal queue until it is consumed. @@ -85,7 +85,7 @@ underlying resource until the data currently buffered can be consumed (that is, the stream will stop calling the internal `readable._read()` method that is used to fill the read buffer). -Data is buffered in Writable streams when the +Data is buffered in `Writable` streams when the [`writable.write(chunk)`][stream-write] method is called repeatedly. While the total size of the internal write buffer is below the threshold set by `highWaterMark`, calls to `writable.write()` will return `true`. Once @@ -96,15 +96,15 @@ A key goal of the `stream` API, particularly the [`stream.pipe()`] method, is to limit the buffering of data to acceptable levels such that sources and destinations of differing speeds will not overwhelm the available memory. -Because [Duplex][] and [Transform][] streams are both Readable and Writable, -each maintain *two* separate internal buffers used for reading and writing, -allowing each side to operate independently of the other while maintaining an -appropriate and efficient flow of data. For example, [`net.Socket`][] instances -are [Duplex][] streams whose Readable side allows consumption of data received -*from* the socket and whose Writable side allows writing data *to* the socket. -Because data may be written to the socket at a faster or slower rate than data -is received, it is important for each side to operate (and buffer) independently -of the other. +Because [`Duplex`][] and [`Transform`][] streams are both `Readable` and +`Writable`, each maintain *two* separate internal buffers used for reading and +writing, allowing each side to operate independently of the other while +maintaining an appropriate and efficient flow of data. For example, +[`net.Socket`][] instances are [`Duplex`][] streams whose `Readable` side allows +consumption of data received *from* the socket and whose `Writable` side allows +writing data *to* the socket. Because data may be written to the socket at a +faster or slower rate than data is received, it is important for each side to +operate (and buffer) independently of the other. ## API for Stream Consumers @@ -156,17 +156,18 @@ server.listen(1337); // error: Unexpected token o in JSON at position 1 ``` -[Writable][] streams (such as `res` in the example) expose methods such as +[`Writable`][] streams (such as `res` in the example) expose methods such as `write()` and `end()` that are used to write data onto the stream. -[Readable][] streams use the [`EventEmitter`][] API for notifying application +[`Readable`][] streams use the [`EventEmitter`][] API for notifying application code when data is available to be read off the stream. That available data can be read from the stream in multiple ways. -Both [Writable][] and [Readable][] streams use the [`EventEmitter`][] API in +Both [`Writable`][] and [`Readable`][] streams use the [`EventEmitter`][] API in various ways to communicate the current state of the stream. -[Duplex][] and [Transform][] streams are both [Writable][] and [Readable][]. +[`Duplex`][] and [`Transform`][] streams are both [`Writable`][] and +[`Readable`][]. Applications that are either writing data to or consuming data from a stream are not required to implement the stream interfaces directly and will generally @@ -180,7 +181,7 @@ section [API for Stream Implementers][]. Writable streams are an abstraction for a *destination* to which data is written. -Examples of [Writable][] streams include: +Examples of [`Writable`][] streams include: * [HTTP requests, on the client][] * [HTTP responses, on the server][] @@ -191,14 +192,14 @@ Examples of [Writable][] streams include: * [child process stdin][] * [`process.stdout`][], [`process.stderr`][] -Some of these examples are actually [Duplex][] streams that implement the -[Writable][] interface. +Some of these examples are actually [`Duplex`][] streams that implement the +[`Writable`][] interface. -All [Writable][] streams implement the interface defined by the +All [`Writable`][] streams implement the interface defined by the `stream.Writable` class. -While specific instances of [Writable][] streams may differ in various ways, -all Writable streams follow the same fundamental usage pattern as illustrated +While specific instances of [`Writable`][] streams may differ in various ways, +all `Writable` streams follow the same fundamental usage pattern as illustrated in the example below: ```js @@ -224,7 +225,7 @@ The `'close'` event is emitted when the stream and any of its underlying resources (a file descriptor, for example) have been closed. The event indicates that no more events will be emitted, and no further computation will occur. -Not all Writable streams will emit the `'close'` event. +Not all `Writable` streams will emit the `'close'` event. ##### Event: 'drain' -Duplex streams are streams that implement both the [Readable][] and -[Writable][] interfaces. +Duplex streams are streams that implement both the [`Readable`][] and +[`Writable`][] interfaces. -Examples of Duplex streams include: +Examples of `Duplex` streams include: * [TCP sockets][] * [zlib streams][zlib] @@ -1270,11 +1272,11 @@ added: v0.9.4 -Transform streams are [Duplex][] streams where the output is in some way -related to the input. Like all [Duplex][] streams, Transform streams -implement both the [Readable][] and [Writable][] interfaces. +Transform streams are [`Duplex`][] streams where the output is in some way +related to the input. Like all [`Duplex`][] streams, `Transform` streams +implement both the [`Readable`][] and [`Writable`][] interfaces. -Examples of Transform streams include: +Examples of `Transform` streams include: * [zlib streams][zlib] * [crypto streams][crypto] @@ -1436,7 +1438,7 @@ on the type of stream being created, as detailed in the chart below:

Reading only

-

[Readable](#stream_class_stream_readable)

+

[`Readable`](#stream_class_stream_readable)

[_read][stream-_read]

@@ -1447,7 +1449,7 @@ on the type of stream being created, as detailed in the chart below:

Writing only

-

[Writable](#stream_class_stream_writable)

+

[`Writable`](#stream_class_stream_writable)

@@ -1462,7 +1464,7 @@ on the type of stream being created, as detailed in the chart below:

Reading and writing

-

[Duplex](#stream_class_stream_duplex)

+

[`Duplex`](#stream_class_stream_duplex)

@@ -1477,7 +1479,7 @@ on the type of stream being created, as detailed in the chart below:

Operate on written data, then read the result

-

[Transform](#stream_class_stream_transform)

+

[`Transform`](#stream_class_stream_transform)

@@ -1516,9 +1518,9 @@ const myWritable = new Writable({ ### Implementing a Writable Stream -The `stream.Writable` class is extended to implement a [Writable][] stream. +The `stream.Writable` class is extended to implement a [`Writable`][] stream. -Custom Writable streams *must* call the `new stream.Writable([options])` +Custom `Writable` streams *must* call the `new stream.Writable([options])` constructor and implement the `writable._write()` method. The `writable._writev()` method *may* also be implemented. @@ -1536,7 +1538,7 @@ changes: [`stream.write()`][stream-write] starts returning `false`. **Default:** `16384` (16kb), or `16` for `objectMode` streams. * `decodeStrings` {boolean} Whether or not to decode strings into - Buffers before passing them to [`stream._write()`][stream-_write]. + `Buffer`s before passing them to [`stream._write()`][stream-_write]. **Default:** `true`. * `objectMode` {boolean} Whether or not the [`stream.write(anyObj)`][stream-write] is a valid operation. When set, @@ -1606,16 +1608,16 @@ const myWritable = new Writable({ * `callback` {Function} Call this function (optionally with an error argument) when processing is complete for the supplied chunk. -All Writable stream implementations must provide a +All `Writable` stream implementations must provide a [`writable._write()`][stream-_write] method to send data to the underlying resource. -[Transform][] streams provide their own implementation of the +[`Transform`][] streams provide their own implementation of the [`writable._write()`][stream-_write]. This function MUST NOT be called by application code directly. It should be -implemented by child classes, and called by the internal Writable class methods -only. +implemented by child classes, and called by the internal `Writable` class +methods only. The `callback` method must be called to signal either that the write completed successfully or failed with an error. The first argument passed to the @@ -1647,8 +1649,8 @@ user programs. argument) to be invoked when processing is complete for the supplied chunks. This function MUST NOT be called by application code directly. It should be -implemented by child classes, and called by the internal Writable class methods -only. +implemented by child classes, and called by the internal `Writable` class +methods only. The `writable._writev()` method may be implemented in addition to `writable._write()` in stream implementations that are capable of processing @@ -1680,7 +1682,7 @@ added: v8.0.0 argument) when finished writing any remaining data. The `_final()` method **must not** be called directly. It may be implemented -by child classes, and if so, will be called by the internal Writable +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 @@ -1692,13 +1694,13 @@ or write buffered data before a stream ends. It is recommended that errors occurring during the processing of the `writable._write()` and `writable._writev()` methods are reported by invoking the callback and passing the error as the first argument. This will cause an -`'error'` event to be emitted by the Writable. Throwing an Error from within +`'error'` event to be emitted by the `Writable`. Throwing an `Error` from within `writable._write()` can result in unexpected and inconsistent behavior depending on how the stream is being used. Using the callback ensures consistent and predictable handling of errors. -If a Readable stream pipes into a Writable stream when Writable emits an -error, the Readable stream will be unpiped. +If a `Readable` stream pipes into a `Writable` stream when `Writable` emits an +error, the `Readable` stream will be unpiped. ```js const { Writable } = require('stream'); @@ -1717,9 +1719,9 @@ const myWritable = new Writable({ #### An Example Writable Stream The following illustrates a rather simplistic (and somewhat pointless) custom -Writable stream implementation. While this specific Writable stream instance +`Writable` stream implementation. While this specific `Writable` stream instance is not of any real particular usefulness, the example illustrates each of the -required elements of a custom [Writable][] stream instance: +required elements of a custom [`Writable`][] stream instance: ```js const { Writable } = require('stream'); @@ -1745,7 +1747,7 @@ class MyWritable extends Writable { Decoding buffers is a common task, for instance, when using transformers whose input is a string. This is not a trivial process when using multi-byte characters encoding, such as UTF-8. The following example shows how to decode -multi-byte strings using `StringDecoder` and [Writable][]. +multi-byte strings using `StringDecoder` and [`Writable`][]. ```js const { Writable } = require('stream'); @@ -1782,9 +1784,9 @@ console.log(w.data); // currency: € ### Implementing a Readable Stream -The `stream.Readable` class is extended to implement a [Readable][] stream. +The `stream.Readable` class is extended to implement a [`Readable`][] stream. -Custom Readable streams *must* call the `new stream.Readable([options])` +Custom `Readable` streams *must* call the `new stream.Readable([options])` constructor and implement the `readable._read()` method. #### new stream.Readable([options]) @@ -1797,7 +1799,7 @@ constructor and implement the `readable._read()` method. strings using the specified encoding. **Default:** `null`. * `objectMode` {boolean} Whether this stream should behave as a stream of objects. Meaning that [`stream.read(n)`][stream-read] returns - a single value instead of a Buffer of size n. **Default:** `false`. + a single value instead of a `Buffer` of size `n`. **Default:** `false`. * `read` {Function} Implementation for the [`stream._read()`][stream-_read] method. * `destroy` {Function} Implementation for the @@ -1847,16 +1849,16 @@ added: v0.9.4 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/17979 - description: call _read() only once per microtick + description: call `_read()` only once per microtick --> * `size` {number} Number of bytes to read asynchronously This function MUST NOT be called by application code directly. It should be -implemented by child classes, and called by the internal Readable class methods -only. +implemented by child classes, and called by the internal `Readable` class +methods only. -All Readable stream implementations must provide an implementation of the +All `Readable` stream implementations must provide an implementation of the `readable._read()` method to fetch data from the underlying resource. When `readable._read()` is called, if data is available from the resource, the @@ -1906,7 +1908,7 @@ changes: string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any JavaScript value. * `encoding` {string} Encoding of string chunks. Must be a valid - Buffer encoding, such as `'utf8'` or `'ascii'` + `Buffer` encoding, such as `'utf8'` or `'ascii'`. * Returns: {boolean} `true` if additional chunks of data may continued to be pushed; `false` otherwise. @@ -1915,18 +1917,18 @@ be added to the internal queue for users of the stream to consume. Passing `chunk` as `null` signals the end of the stream (EOF), after which no more data can be written. -When the Readable is operating in paused mode, the data added with +When the `Readable` is operating in paused mode, the data added with `readable.push()` can be read out by calling the [`readable.read()`][stream-read] method when the [`'readable'`][] event is emitted. -When the Readable is operating in flowing mode, the data added with +When the `Readable` is operating in flowing mode, the data added with `readable.push()` will be delivered by emitting a `'data'` event. The `readable.push()` method is designed to be as flexible as possible. For example, when wrapping a lower-level source that provides some form of pause/resume mechanism, and a data callback, the low-level source can be wrapped -by the custom Readable instance as illustrated in the following example: +by the custom `Readable` instance as illustrated in the following example: ```js // source is an object with readStop() and readStart() methods, @@ -1959,8 +1961,8 @@ class SourceWrapper extends Readable { } ``` -The `readable.push()` method is intended be called only by Readable -Implementers, and only from within the `readable._read()` method. +The `readable.push()` method is intended be called only by `Readable` +implementers, and only from within the `readable._read()` method. For streams not operating in object mode, if the `chunk` parameter of `readable.push()` is `undefined`, it will be treated as empty string or @@ -1970,7 +1972,7 @@ buffer. See [`readable.push('')`][] for more information. It is recommended that errors occurring during the processing of the `readable._read()` method are emitted using the `'error'` event rather than -being thrown. Throwing an Error from within `readable._read()` can result in +being thrown. Throwing an `Error` from within `readable._read()` can result in unexpected and inconsistent behavior depending on whether the stream is operating in flowing or paused mode. Using the `'error'` event ensures consistent and predictable handling of errors. @@ -1994,7 +1996,7 @@ const myReadable = new Readable({ -The following is a basic example of a Readable stream that emits the numerals +The following is a basic example of a `Readable` stream that emits the numerals from 1 to 1,000,000 in ascending order, and then ends. ```js @@ -2022,11 +2024,11 @@ class Counter extends Readable { ### Implementing a Duplex Stream -A [Duplex][] stream is one that implements both [Readable][] and [Writable][], -such as a TCP socket connection. +A [`Duplex`][] stream is one that implements both [`Readable`][] and +[`Writable`][], such as a TCP socket connection. Because JavaScript does not have support for multiple inheritance, the -`stream.Duplex` class is extended to implement a [Duplex][] stream (as opposed +`stream.Duplex` class is extended to implement a [`Duplex`][] stream (as opposed to extending the `stream.Readable` *and* `stream.Writable` classes). The `stream.Duplex` class prototypically inherits from `stream.Readable` and @@ -2034,7 +2036,7 @@ parasitically from `stream.Writable`, but `instanceof` will work properly for both base classes due to overriding [`Symbol.hasInstance`][] on `stream.Writable`. -Custom Duplex streams *must* call the `new stream.Duplex([options])` +Custom `Duplex` streams *must* call the `new stream.Duplex([options])` constructor and implement *both* the `readable._read()` and `writable._write()` methods. @@ -2047,7 +2049,7 @@ changes: are supported now. --> -* `options` {Object} Passed to both Writable and Readable +* `options` {Object} Passed to both `Writable` and `Readable` constructors. Also has the following fields: * `allowHalfOpen` {boolean} If set to `false`, then the stream will automatically end the writable side when the readable side ends. @@ -2103,13 +2105,13 @@ const myDuplex = new Duplex({ #### An Example Duplex Stream -The following illustrates a simple example of a Duplex stream that wraps a +The following illustrates a simple example of a `Duplex` stream that wraps a hypothetical lower-level source object to which data can be written, and from which data can be read, albeit using an API that is not compatible with Node.js streams. -The following illustrates a simple example of a Duplex stream that buffers -incoming written data via the [Writable][] interface that is read back out -via the [Readable][] interface. +The following illustrates a simple example of a `Duplex` stream that buffers +incoming written data via the [`Writable`][] interface that is read back out +via the [`Readable`][] interface. ```js const { Duplex } = require('stream'); @@ -2137,20 +2139,20 @@ class MyDuplex extends Duplex { } ``` -The most important aspect of a Duplex stream is that the Readable and Writable -sides operate independently of one another despite co-existing within a single -object instance. +The most important aspect of a `Duplex` stream is that the `Readable` and +`Writable` sides operate independently of one another despite co-existing within +a single object instance. #### Object Mode Duplex Streams -For Duplex streams, `objectMode` can be set exclusively for either the Readable -or Writable side using the `readableObjectMode` and `writableObjectMode` options -respectively. +For `Duplex` streams, `objectMode` can be set exclusively for either the +`Readable` or `Writable` side using the `readableObjectMode` and +`writableObjectMode` options respectively. -In the following example, for instance, a new Transform stream (which is a -type of [Duplex][] stream) is created that has an object mode Writable side +In the following example, for instance, a new `Transform` stream (which is a +type of [`Duplex`][] stream) is created that has an object mode `Writable` side that accepts JavaScript numbers that are converted to hexadecimal strings on -the Readable side. +the `Readable` side. ```js const { Transform } = require('stream'); @@ -2184,31 +2186,31 @@ myTransform.write(100); ### Implementing a Transform Stream -A [Transform][] stream is a [Duplex][] stream where the output is computed +A [`Transform`][] stream is a [`Duplex`][] stream where the output is computed in some way from the input. Examples include [zlib][] streams or [crypto][] streams that compress, encrypt, or decrypt data. There is no requirement that the output be the same size as the input, the same -number of chunks, or arrive at the same time. For example, a Hash stream will +number of chunks, or arrive at the same time. For example, a `Hash` stream will only ever have a single chunk of output which is provided when the input is ended. A `zlib` stream will produce output that is either much smaller or much larger than its input. -The `stream.Transform` class is extended to implement a [Transform][] stream. +The `stream.Transform` class is extended to implement a [`Transform`][] stream. The `stream.Transform` class prototypically inherits from `stream.Duplex` and implements its own versions of the `writable._write()` and `readable._read()` -methods. Custom Transform implementations *must* implement the +methods. Custom `Transform` implementations *must* implement the [`transform._transform()`][stream-_transform] method and *may* also implement the [`transform._flush()`][stream-_flush] method. -Care must be taken when using Transform streams in that data written to the -stream can cause the Writable side of the stream to become paused if the output -on the Readable side is not consumed. +Care must be taken when using `Transform` streams in that data written to the +stream can cause the `Writable` side of the stream to become paused if the +output on the `Readable` side is not consumed. #### new stream.Transform([options]) -* `options` {Object} Passed to both Writable and Readable +* `options` {Object} Passed to both `Writable` and `Readable` constructors. Also has the following fields: * `transform` {Function} Implementation for the [`stream._transform()`][stream-_transform] method. @@ -2267,8 +2269,8 @@ after all data has been output, which occurs after the callback in argument and data) to be called when remaining data has been flushed. This function MUST NOT be called by application code directly. It should be -implemented by child classes, and called by the internal Readable class methods -only. +implemented by child classes, and called by the internal `Readable` class +methods only. In some cases, a transform operation may need to emit an additional bit of data at the end of the stream. For example, a `zlib` compression stream will @@ -2276,10 +2278,10 @@ store an amount of internal state used to optimally compress the output. When the stream ends, however, that additional data needs to be flushed so that the compressed data will be complete. -Custom [Transform][] implementations *may* implement the `transform._flush()` +Custom [`Transform`][] implementations *may* implement the `transform._flush()` method. This will be called when there is no more written data to be consumed, but before the [`'end'`][] event is emitted signaling the end of the -[Readable][] stream. +[`Readable`][] stream. Within the `transform._flush()` implementation, the `readable.push()` method may be called zero or more times, as appropriate. The `callback` function must @@ -2302,10 +2304,10 @@ user programs. processed. This function MUST NOT be called by application code directly. It should be -implemented by child classes, and called by the internal Readable class methods -only. +implemented by child classes, and called by the internal `Readable` class +methods only. -All Transform stream implementations must provide a `_transform()` +All `Transform` stream implementations must provide a `_transform()` method to accept input and produce output. The `transform._transform()` implementation handles the bytes being written, computes an output, then passes that output off to the readable portion using the `readable.push()` method. @@ -2343,7 +2345,7 @@ called, either synchronously or asynchronously. #### Class: stream.PassThrough -The `stream.PassThrough` class is a trivial implementation of a [Transform][] +The `stream.PassThrough` class is a trivial implementation of a [`Transform`][] stream that simply passes the input bytes across to the output. Its purpose is primarily for examples and testing, but there are some use cases where `stream.PassThrough` is useful as a building block for novel sorts of streams. @@ -2356,7 +2358,7 @@ primarily for examples and testing, but there are some use cases where -In versions of Node.js prior to v0.10, the Readable stream interface was +In versions of Node.js prior to v0.10, the `Readable` stream interface was simpler, but also less powerful and less useful. * Rather than waiting for calls the [`stream.read()`][stream-read] method, @@ -2367,9 +2369,9 @@ simpler, but also less powerful and less useful. guaranteed. This meant that it was still necessary to be prepared to receive [`'data'`][] events *even when the stream was in a paused state*. -In Node.js v0.10, the [Readable][] class was added. For backwards compatibility -with older Node.js programs, Readable streams switch into "flowing mode" when a -[`'data'`][] event handler is added, or when the +In Node.js v0.10, the [`Readable`][] class was added. For backwards +compatibility with older Node.js programs, `Readable` streams switch into +"flowing mode" when a [`'data'`][] event handler is added, or when the [`stream.resume()`][stream-resume] method is called. The effect is that, even when not using the new [`stream.read()`][stream-read] method and [`'readable'`][] event, it is no longer necessary to worry about losing @@ -2416,8 +2418,8 @@ net.createServer((socket) => { }).listen(1337); ``` -In addition to new Readable streams switching into flowing mode, -pre-v0.10 style streams can be wrapped in a Readable class using the +In addition to new `Readable` streams switching into flowing mode, +pre-v0.10 style streams can be wrapped in a `Readable` class using the [`readable.wrap()`][`stream.wrap()`] method. ### `readable.read(0)` @@ -2433,7 +2435,7 @@ a low-level [`stream._read()`][stream-_read] call. While most applications will almost never need to do this, there are situations within Node.js where this is done, particularly in the -Readable stream class internals. +`Readable` stream class internals. ### `readable.push('')` @@ -2483,13 +2485,13 @@ contain multi-byte characters. [API for Stream Consumers]: #stream_api_for_stream_consumers [API for Stream Implementers]: #stream_api_for_stream_implementers [Compatibility]: #stream_compatibility_with_older_node_js_versions -[Duplex]: #stream_class_stream_duplex +[`Duplex`]: #stream_class_stream_duplex [HTTP requests, on the client]: http.html#http_class_http_clientrequest [HTTP responses, on the server]: http.html#http_class_http_serverresponse -[Readable]: #stream_class_stream_readable +[`Readable`]: #stream_class_stream_readable [TCP sockets]: net.html#net_class_net_socket -[Transform]: #stream_class_stream_transform -[Writable]: #stream_class_stream_writable +[`Transform`]: #stream_class_stream_transform +[`Writable`]: #stream_class_stream_writable [child process stdin]: child_process.html#child_process_subprocess_stdin [child process stdout and stderr]: child_process.html#child_process_subprocess_stdout [crypto]: crypto.html diff --git a/doc/api/tls.md b/doc/api/tls.md index bdda8bd7343..e22286adb45 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -422,8 +422,7 @@ added: v3.0.0 Updates the keys for encryption/decryption of the [TLS Session Tickets][]. The key's `Buffer` should be 48 bytes long. See `ticketKeys` option in -[tls.createServer](#tls_tls_createserver_options_secureconnectionlistener) for -more information on how it is used. +[`tls.createServer()`] for more information on how it is used. Changes to the ticket keys are effective only for future server connections. Existing or currently pending server connections will use the previous keys. @@ -582,7 +581,7 @@ an ephemeral key exchange in [Perfect Forward Secrecy][] on a client connection. It returns an empty object when the key exchange is not ephemeral. As this is only supported on a client socket; `null` is returned if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The -`name` property is available only when type is 'ECDH'. +`name` property is available only when type is `'ECDH'`. For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`. @@ -615,7 +614,7 @@ added: v0.11.4 Returns an object representing the peer's certificate. The returned object has some properties corresponding to the fields of the certificate. -If the full certificate chain was requested, each certificate will include a +If the full certificate chain was requested, each certificate will include an `issuerCertificate` property containing an object representing its issuer's certificate. @@ -637,7 +636,7 @@ For example: OU: 'Test TLS Certificate', CN: 'localhost' }, issuerCertificate: - { ... another certificate, possibly with a .issuerCertificate ... }, + { ... another certificate, possibly with an .issuerCertificate ... }, raw: < RAW DER buffer >, pubkey: < RAW DER buffer >, valid_from: 'Nov 11 09:52:22 2009 GMT', @@ -1016,7 +1015,7 @@ changes: - version: v7.3.0 pr-url: https://github.com/nodejs/node/pull/10294 description: If the `key` option is an array, individual entries do not - need a `passphrase` property anymore. Array entries can also + need a `passphrase` property anymore. `Array` entries can also just be `string`s or `Buffer`s now. - version: v5.2.0 pr-url: https://github.com/nodejs/node/pull/4099 @@ -1056,9 +1055,9 @@ changes: * `ca` {string|string[]|Buffer|Buffer[]} Optionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly specified - using this option. The value can be a string or Buffer, or an Array of - strings and/or Buffers. Any string or Buffer can contain multiple PEM CAs - concatenated together. The peer's certificate must be chainable to a CA + using this option. The value can be a string or `Buffer`, or an `Array` of + strings and/or `Buffer`s. Any string or `Buffer` can contain multiple PEM + CAs concatenated together. The peer's certificate must be chainable to a CA trusted by the server for the connection to be authenticated. When using certificates that are not chainable to a well-known CA, the certificate's CA must be explicitly specified as a trusted or the connection will fail to @@ -1156,12 +1155,12 @@ changes: * `SNICallback(servername, cb)` {Function} A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `cb`. `SNICallback` should invoke `cb(null, ctx)`, - where `ctx` is a SecureContext instance. (`tls.createSecureContext(...)` can - be used to get a proper SecureContext.) If `SNICallback` wasn't provided the - default callback with high-level API will be used (see below). + where `ctx` is a `SecureContext` instance. (`tls.createSecureContext(...)` + can be used to get a proper `SecureContext`.) If `SNICallback` wasn't + provided the default callback with high-level API will be used (see below). * `sessionTimeout` {number} An integer specifying the number of seconds after which the TLS session identifiers and TLS session tickets created by the - server will time out. See [SSL_CTX_set_timeout] for more details. + server will time out. See [`SSL_CTX_set_timeout`] for more details. * `ticketKeys`: A 48-byte `Buffer` instance consisting of a 16-byte prefix, a 16-byte HMAC key, and a 16-byte AES key. This can be used to accept TLS session tickets on multiple instances of the TLS server. @@ -1169,7 +1168,7 @@ changes: servers, the identity options (`pfx` or `key`/`cert`) are usually required. * `secureConnectionListener` {Function} -Creates a new [tls.Server][]. The `secureConnectionListener`, if provided, is +Creates a new [`tls.Server`][]. The `secureConnectionListener`, if provided, is automatically set as a listener for the [`'secureConnection'`][] event. The `ticketKeys` options is automatically shared between `cluster` module @@ -1371,13 +1370,16 @@ where `secureSocket` has the same API as `pair.cleartext`. [`'secureConnect'`]: #tls_event_secureconnect [`'secureConnection'`]: #tls_event_secureconnection +[`SSL_CTX_set_timeout`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set_timeout.html [`crypto.getCurves()`]: crypto.html#crypto_crypto_getcurves +[`dns.lookup()`]: dns.html#dns_dns_lookup_hostname_options_callback [`net.Server.address()`]: net.html#net_server_address [`net.Server`]: net.html#net_class_net_server [`net.Socket`]: net.html#net_class_net_socket [`server.getConnections()`]: net.html#net_server_getconnections_callback [`server.listen()`]: net.html#net_server_listen [`tls.DEFAULT_ECDH_CURVE`]: #tls_tls_default_ecdh_curve +[`tls.Server`]: #tls_class_tls_server [`tls.TLSSocket.getPeerCertificate()`]: #tls_tlssocket_getpeercertificate_detailed [`tls.TLSSocket`]: #tls_class_tls_tlssocket [`tls.connect()`]: #tls_tls_connect_options_callback @@ -1392,7 +1394,7 @@ where `secureSocket` has the same API as `pair.cleartext`. [OpenSSL Options]: crypto.html#crypto_openssl_options [OpenSSL cipher list format documentation]: https://www.openssl.org/docs/man1.1.0/apps/ciphers.html#CIPHER-LIST-FORMAT [Perfect Forward Secrecy]: #tls_perfect_forward_secrecy -[SSL_CTX_set_timeout]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set_timeout.html +[RFC 5929]: https://tools.ietf.org/html/rfc5929 [SSL_METHODS]: https://www.openssl.org/docs/man1.1.0/ssl/ssl.html#Dealing-with-Protocol-Methods [Stream]: stream.html#stream_stream [TLS Session Tickets]: https://www.ietf.org/rfc/rfc5077.txt @@ -1400,6 +1402,3 @@ where `secureSocket` has the same API as `pair.cleartext`. [asn1.js]: https://npmjs.org/package/asn1.js [modifying the default cipher suite]: #tls_modifying_the_default_tls_cipher_suite [specific attacks affecting larger AES key sizes]: https://www.schneier.com/blog/archives/2009/07/another_new_aes.html -[tls.Server]: #tls_class_tls_server -[`dns.lookup()`]: dns.html#dns_dns_lookup_hostname_options_callback -[RFC 5929]: https://tools.ietf.org/html/rfc5929 diff --git a/doc/api/tracing.md b/doc/api/tracing.md index f83e808dc89..7b30672ecce 100644 --- a/doc/api/tracing.md +++ b/doc/api/tracing.md @@ -8,14 +8,14 @@ Trace Event provides a mechanism to centralize tracing information generated by V8, Node.js core, and userspace code. Tracing can be enabled with the `--trace-event-categories` command-line flag -or by using the trace_events module. The `--trace-event-categories` flag accepts -a list of comma-separated category names. +or by using the `trace_events` module. The `--trace-event-categories` flag +accepts a list of comma-separated category names. The available categories are: * `node` - An empty placeholder. -* `node.async_hooks` - Enables capture of detailed [async_hooks] trace data. - The [async_hooks] events have a unique `asyncId` and a special triggerId +* `node.async_hooks` - Enables capture of detailed [`async_hooks`] trace data. + The [`async_hooks`] events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property. * `node.bootstrap` - Enables capture of Node.js bootstrap milestones. * `node.perf` - Enables capture of [Performance API] measurements. @@ -196,4 +196,4 @@ console.log(trace_events.getEnabledCategories()); [Performance API]: perf_hooks.html [V8]: v8.html -[async_hooks]: async_hooks.html +[`async_hooks`]: async_hooks.html diff --git a/doc/api/tty.md b/doc/api/tty.md index f8bc4feec3e..91bca8284d9 100644 --- a/doc/api/tty.md +++ b/doc/api/tty.md @@ -126,15 +126,15 @@ is updated whenever the `'resize'` event is emitted. added: v9.9.0 --> -* `env` {Object} A object containing the environment variables to check. +* `env` {Object} An object containing the environment variables to check. **Default:** `process.env`. * Returns: {number} Returns: -* 1 for 2, -* 4 for 16, -* 8 for 256, -* 24 for 16,777,216 +* `1` for 2, +* `4` for 16, +* `8` for 256, +* `24` for 16,777,216 colors supported. Use this to determine what colors the terminal supports. Due to the nature of diff --git a/doc/api/url.md b/doc/api/url.md index a7add464e8b..64b7b444c54 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -86,8 +86,8 @@ The `URL` class is also available on the global object. In accordance with browser conventions, all properties of `URL` objects are implemented as getters and setters on the class prototype, rather than as -data properties on the object itself. Thus, unlike [legacy urlObject][]s, using -the `delete` keyword on any properties of `URL` objects (e.g. `delete +data properties on the object itself. Thus, unlike [legacy `urlObject`][]s, +using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still return `true`. @@ -346,7 +346,7 @@ console.log(myURL.port); // Prints 1234 ``` -The port value may be set as either a number or as a String containing a number +The port value may be set as either a number or as a string containing a number in the range `0` to `65535` (inclusive). Setting the value to the default port of the `URL` objects given `protocol` will result in the `port` value becoming the empty string (`''`). @@ -581,7 +581,7 @@ added: v7.10.0 * `iterable` {Iterable} An iterable object whose elements are key-value pairs Instantiate a new `URLSearchParams` object with an iterable map in a way that -is similar to [`Map`][]'s constructor. `iterable` can be an Array or any +is similar to [`Map`][]'s constructor. `iterable` can be an `Array` or any iterable object. That means `iterable` can be another `URLSearchParams`, in which case the constructor will simply create a clone of the provided `URLSearchParams`. Elements of `iterable` are key-value pairs, and can @@ -644,16 +644,16 @@ Remove all name-value pairs whose name is `name`. * Returns: {Iterator} -Returns an ES6 Iterator over each of the name-value pairs in the query. -Each item of the iterator is a JavaScript Array. The first item of the Array -is the `name`, the second item of the Array is the `value`. +Returns an ES6 `Iterator` over each of the name-value pairs in the query. +Each item of the iterator is a JavaScript `Array`. The first item of the `Array` +is the `name`, the second item of the `Array` is the `value`. Alias for [`urlSearchParams[@@iterator]()`][`urlSearchParams@@iterator()`]. #### urlSearchParams.forEach(fn[, thisArg]) -* `fn` {Function} Function invoked for each name-value pair in the query. -* `thisArg` {Object} Object to be used as `this` value for when `fn` is called +* `fn` {Function} Invoked for each name-value pair in the query +* `thisArg` {Object} To be used as `this` value for when `fn` is called Iterates over each name-value pair in the query and invokes the given function. @@ -695,7 +695,7 @@ Returns `true` if there is at least one name-value pair whose name is `name`. * Returns: {Iterator} -Returns an ES6 Iterator over the names of each name-value pair. +Returns an ES6 `Iterator` over the names of each name-value pair. ```js const params = new URLSearchParams('foo=bar&foo=baz'); @@ -760,15 +760,15 @@ percent-encoded where necessary. * Returns: {Iterator} -Returns an ES6 Iterator over the values of each name-value pair. +Returns an ES6 `Iterator` over the values of each name-value pair. #### urlSearchParams\[Symbol.iterator\]() * Returns: {Iterator} -Returns an ES6 Iterator over each of the name-value pairs in the query string. -Each item of the iterator is a JavaScript Array. The first item of the Array -is the `name`, the second item of the Array is the `value`. +Returns an ES6 `Iterator` over each of the name-value pairs in the query string. +Each item of the iterator is a JavaScript `Array`. The first item of the `Array` +is the `name`, the second item of the `Array` is the `value`. Alias for [`urlSearchParams.entries()`][]. @@ -846,7 +846,7 @@ added: v7.6.0 Punycode encoded. **Default:** `false`. * Returns: {string} -Returns a customizable serialization of a URL String representation of a +Returns a customizable serialization of a URL `String` representation of a [WHATWG URL][] object. The URL object has both a `toString()` method and `href` property that return @@ -871,9 +871,9 @@ console.log(url.format(myURL, { fragment: false, unicode: true, auth: false })); ## Legacy URL API -### Legacy urlObject +### Legacy `urlObject` -The legacy urlObject (`require('url').Url`) is created and returned by the +The legacy `urlObject` (`require('url').Url`) is created and returned by the `url.parse()` function. #### urlObject.auth @@ -1039,7 +1039,7 @@ The formatting process operates as follows: `urlObject.host` is coerced to a string and appended to `result`. * If the `urlObject.pathname` property is a string that is not an empty string: * If the `urlObject.pathname` *does not start* with an ASCII forward slash - (`/`), then the literal string '/' is appended to `result`. + (`/`), then the literal string `'/'` is appended to `result`. * The value of `urlObject.pathname` is appended to `result`. * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an [`Error`][] is thrown. @@ -1205,6 +1205,6 @@ console.log(myURL.origin); [WHATWG URL Standard]: https://url.spec.whatwg.org/ [WHATWG URL]: #url_the_whatwg_url_api [examples of parsed URLs]: https://url.spec.whatwg.org/#example-url-parsing -[legacy urlObject]: #url_legacy_urlobject +[legacy `urlObject`]: #url_legacy_urlobject [percent-encoded]: #whatwg-percent-encoding [stable sorting algorithm]: https://en.wikipedia.org/wiki/Sorting_algorithm#Stability diff --git a/doc/api/util.md b/doc/api/util.md index 8ed8c0b2c9a..529f7b6fc7e 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -20,10 +20,10 @@ added: v8.2.0 * `original` {Function} An `async` function * Returns: {Function} a callback style function -Takes an `async` function (or a function that returns a Promise) and returns a +Takes an `async` function (or a function that returns a `Promise`) and returns a function following the error-first callback style, i.e. taking -a `(err, value) => ...` callback as the last argument. In the callback, the -first argument will be the rejection reason (or `null` if the Promise +an `(err, value) => ...` callback as the last argument. In the callback, the +first argument will be the rejection reason (or `null` if the `Promise` resolved), and the second argument will be the resolved value. ```js @@ -185,7 +185,7 @@ added: v0.5.3 changes: - version: REPLACEME pr-url: https://github.com/nodejs/node/pull/17907 - description: The `%o` specifiers `depth` option is now set to Infinity. + description: The `%o` specifiers `depth` option is now set to `Infinity`. - version: v8.4.0 pr-url: https://github.com/nodejs/node/pull/14558 description: The `%o` and `%O` specifiers are supported now. @@ -200,18 +200,18 @@ The first argument is a string containing zero or more *placeholder* tokens. Each placeholder token is replaced with the converted value from the corresponding argument. Supported placeholders are: -* `%s` - String. -* `%d` - Number (integer or floating point value). +* `%s` - `String`. +* `%d` - `Number` (integer or floating point value). * `%i` - Integer. * `%f` - Floating point value. * `%j` - JSON. Replaced with the string `'[Circular]'` if the argument contains circular references. -* `%o` - Object. A string representation of an object +* `%o` - `Object`. A string representation of an object with generic JavaScript object formatting. Similar to `util.inspect()` with options `{ showHidden: true, showProxy: true }`. This will show the full object including non-enumerable properties and proxies. -* `%O` - Object. A string representation of an object with generic JavaScript +* `%O` - `Object`. A string representation of an object with generic JavaScript object formatting. Similar to `util.inspect()` without options. This will show the full object not including non-enumerable properties and proxies. * `%%` - single percent sign (`'%'`). This does not consume an argument. @@ -365,10 +365,11 @@ added: v0.3.0 changes: - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/19259 - description: WeakMap and WeakSet entries can now be inspected as well. + description: The `WeakMap` and `WeakSet` entries can now be inspected + as well. - version: REPLACEME pr-url: https://github.com/nodejs/node/pull/17907 - description: The `depth` default changed to Infinity. + description: The `depth` default changed to `Infinity`. - version: v9.9.0 pr-url: https://github.com/nodejs/node/pull/17576 description: The `compact` option is supported now. @@ -387,7 +388,7 @@ changes: description: The `showProxy` option is supported now. --> -* `object` {any} Any JavaScript primitive or Object. +* `object` {any} Any JavaScript primitive or `Object`. * `options` {Object} * `showHidden` {boolean} If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result as well as [`WeakMap`][] @@ -418,10 +419,10 @@ changes: objects the same as arrays. Note that no text will be reduced below 16 characters, no matter the `breakLength` size. For more information, see the example below. **Default:** `true`. - * `depth` {number} Specifies the number visible nested Objects in an `object`. - This is useful to minimize the inspection output for large complicated - objects. To make it recurse indefinitely pass `null` or `Infinity`. - **Default:** `Infinity`. + * `depth` {number} Specifies the number of visible nested `Object`s in an + `object`. This is useful to minimize the inspection output for large + complicated objects. To make it recurse indefinitely pass `null` or + `Infinity`. **Default:** `Infinity`. * Returns: {string} The representation of passed object The `util.inspect()` method returns a string representation of `object` that is @@ -640,7 +641,7 @@ util.inspect(obj); added: v6.6.0 --> -A Symbol that can be used to declare custom inspect functions, see +* {symbol} that can be used to declare custom inspect functions, see [Custom inspection functions on Objects][]. ### util.inspect.defaultOptions @@ -687,7 +688,7 @@ added: v8.0.0 * Returns: {Function} Takes a function following the common error-first callback style, i.e. taking -a `(err, value) => ...` callback as the last argument, and returns a version +an `(err, value) => ...` callback as the last argument, and returns a version that returns promises. ```js @@ -767,9 +768,7 @@ throw an error. added: v8.0.0 --> -* {symbol} - -A Symbol that can be used to declare custom promisified variants of functions, +* {symbol} that can be used to declare custom promisified variants of functions, see [Custom promisified functions][]. ## Class: util.TextDecoder @@ -876,7 +875,7 @@ supported encodings or an alias. ### textDecoder.decode([input[, options]]) * `input` {ArrayBuffer|DataView|TypedArray} An `ArrayBuffer`, `DataView` or - Typed Array instance containing the encoded data. + `TypedArray` instance containing the encoded data. * `options` {Object} * `stream` {boolean} `true` if additional chunks of data are expected. **Default:** `false`. diff --git a/doc/api/vm.md b/doc/api/vm.md index 68b25b6aa32..9e1249dc4ed 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -162,20 +162,20 @@ const contextifiedSandbox = vm.createContext({ secret: 42 }); * `url` {string} URL used in module resolution and stack traces. **Default:** `'vm:module(i)'` where `i` is a context-specific ascending index. * `context` {Object} The [contextified][] object as returned by the - `vm.createContext()` method, to compile and evaluate this Module in. + `vm.createContext()` method, to compile and evaluate this `Module` in. * `lineOffset` {integer} Specifies the line number offset that is displayed - 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 + in stack traces produced by this `Module`. + * `columnOffset` {integer} Specifies 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 +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. @@ -217,8 +217,8 @@ const contextifiedSandbox = vm.createContext({ secret: 42 }); The specifiers of all dependencies of this module. The returned array is frozen to disallow any changes to it. -Corresponds to the [[RequestedModules]] field of [Source Text Module Record][]s -in the ECMAScript specification. +Corresponds to the `[[RequestedModules]]` field of +[Source Text Module Record][]s in the ECMAScript specification. ### module.error @@ -231,7 +231,7 @@ accessing this property will result in a thrown exception. The value `undefined` cannot be used for cases where there is not a thrown exception due to possible ambiguity with `throw undefined;`. -Corresponds to the [[EvaluationError]] field of [Source Text Module Record][]s +Corresponds to the `[[EvaluationError]]` field of [Source Text Module Record][]s in the ECMAScript specification. ### module.linkingStatus @@ -246,8 +246,8 @@ The current linking status of `module`. It will be one of the following values: - `'linked'`: `module.link()` has been called, and all its dependencies have been successfully linked. - `'errored'`: `module.link()` has been called, but at least one of its - dependencies failed to link, either because the callback returned a Promise - that is rejected, or because the Module the callback returned is invalid. + dependencies failed to link, either because the callback returned a `Promise` + that is rejected, or because the `Module` the callback returned is invalid. ### module.namespace @@ -289,9 +289,9 @@ The current status of the module. Will be one of: - `'errored'`: The module has been evaluated, but an exception was thrown. Other than `'errored'`, this status string corresponds to the specification's -[Source Text Module Record][]'s [[Status]] field. `'errored'` corresponds to -`'evaluated'` in the specification, but with [[EvaluationError]] set to a value -that is not `undefined`. +[Source Text Module Record][]'s `[[Status]]` field. `'errored'` corresponds to +`'evaluated'` in the specification, but with `[[EvaluationError]]` set to a +value that is not `undefined`. ### module.url diff --git a/doc/api/zlib.md b/doc/api/zlib.md index 33dbdbef1d7..0e66abdcfb0 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -165,7 +165,7 @@ The memory requirements for deflate are (in bytes): (1 << (windowBits + 2)) + (1 << (memLevel + 9)) ``` -That is: 128K for windowBits = 15 + 128K for memLevel = 8 +That is: 128K for `windowBits` = 15 + 128K for `memLevel` = 8 (default values) plus a few kilobytes for small objects. For example, to reduce the default memory requirements from 256K to 128K, the @@ -178,7 +178,7 @@ const options = { windowBits: 14, memLevel: 7 }; This will, however, generally degrade compression. The memory requirements for inflate are (in bytes) `1 << windowBits`. -That is, 32K for windowBits = 15 (default value) plus a few kilobytes +That is, 32K for `windowBits` = 15 (default value) plus a few kilobytes for small objects. This is in addition to a single internal output slab buffer of size @@ -287,10 +287,10 @@ added: v0.11.1 changes: - version: v9.4.0 pr-url: https://github.com/nodejs/node/pull/16042 - description: The `dictionary` option can be an ArrayBuffer. + description: The `dictionary` option can be an `ArrayBuffer`. - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12001 - description: The `dictionary` option can be an Uint8Array now. + description: The `dictionary` option can be an `Uint8Array` now. - version: v5.11.0 pr-url: https://github.com/nodejs/node/pull/6069 description: The `finishFlush` option is supported now. @@ -473,17 +473,17 @@ Provides an object enumerating Zlib-related constants. added: v0.5.8 --> -Creates and returns a new [Deflate][] object with the given [`options`][]. +Creates and returns a new [`Deflate`][] object with the given [`options`][]. ## zlib.createDeflateRaw([options]) -Creates and returns a new [DeflateRaw][] object with the given [`options`][]. +Creates and returns a new [`DeflateRaw`][] object with the given [`options`][]. -An upgrade of zlib from 1.2.8 to 1.2.11 changed behavior when windowBits -is set to 8 for raw deflate streams. zlib would automatically set windowBits +An upgrade of zlib from 1.2.8 to 1.2.11 changed behavior when `windowBits` +is set to 8 for raw deflate streams. zlib would automatically set `windowBits` to 9 if was initially set to 8. Newer versions of zlib will throw an exception, so Node.js restored the original behavior of upgrading a value of 8 to 9, since passing `windowBits = 9` to zlib actually results in a compressed stream @@ -494,35 +494,35 @@ that effectively uses an 8-bit window only. added: v0.5.8 --> -Creates and returns a new [Gunzip][] object with the given [`options`][]. +Creates and returns a new [`Gunzip`][] object with the given [`options`][]. ## zlib.createGzip([options]) -Creates and returns a new [Gzip][] object with the given [`options`][]. +Creates and returns a new [`Gzip`][] object with the given [`options`][]. ## zlib.createInflate([options]) -Creates and returns a new [Inflate][] object with the given [`options`][]. +Creates and returns a new [`Inflate`][] object with the given [`options`][]. ## zlib.createInflateRaw([options]) -Creates and returns a new [InflateRaw][] object with the given [`options`][]. +Creates and returns a new [`InflateRaw`][] object with the given [`options`][]. ## zlib.createUnzip([options]) -Creates and returns a new [Unzip][] object with the given [`options`][]. +Creates and returns a new [`Unzip`][] object with the given [`options`][]. ## Convenience Methods @@ -542,13 +542,13 @@ added: v0.6.0 changes: - version: v9.4.0 pr-url: https://github.com/nodejs/node/pull/16042 - description: The `buffer` parameter can be an ArrayBuffer. + description: The `buffer` parameter can be an `ArrayBuffer`. - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12223 - description: The `buffer` parameter can be any TypedArray or DataView now. + description: The `buffer` parameter can be any `TypedArray` or `DataView`. - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/12001 - description: The `buffer` parameter can be an Uint8Array now. + description: The `buffer` parameter can be an `Uint8Array` now. --> ### zlib.deflateSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Compress a chunk of data with [Deflate][]. +Compress a chunk of data with [`Deflate`][]. ### zlib.deflateRaw(buffer[, options], callback) ### zlib.deflateRawSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Compress a chunk of data with [DeflateRaw][]. +Compress a chunk of data with [`DeflateRaw`][]. ### zlib.gunzip(buffer[, options], callback) ### zlib.gunzipSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Decompress a chunk of data with [Gunzip][]. +Decompress a chunk of data with [`Gunzip`][]. ### zlib.gzip(buffer[, options], callback) ### zlib.gzipSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Compress a chunk of data with [Gzip][]. +Compress a chunk of data with [`Gzip`][]. ### zlib.inflate(buffer[, options], callback) ### zlib.inflateSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Decompress a chunk of data with [Inflate][]. +Decompress a chunk of data with [`Inflate`][]. ### zlib.inflateRaw(buffer[, options], callback) ### zlib.inflateRawSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Decompress a chunk of data with [InflateRaw][]. +Decompress a chunk of data with [`InflateRaw`][]. ### zlib.unzip(buffer[, options], callback) ### zlib.unzipSync(buffer[, options]) - `buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string} -Decompress a chunk of data with [Unzip][]. +Decompress a chunk of data with [`Unzip`][]. [`.flush()`]: #zlib_zlib_flush_kind_callback [`Accept-Encoding`]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 @@ -770,16 +770,16 @@ Decompress a chunk of data with [Unzip][]. [`Buffer`]: buffer.html#buffer_class_buffer [`Content-Encoding`]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 [`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView +[`Deflate`]: #zlib_class_zlib_deflate +[`DeflateRaw`]: #zlib_class_zlib_deflateraw +[`Gunzip`]: #zlib_class_zlib_gunzip +[`Gzip`]: #zlib_class_zlib_gzip +[`Inflate`]: #zlib_class_zlib_inflate +[`InflateRaw`]: #zlib_class_zlib_inflateraw [`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[`options`]: #zlib_class_options -[DeflateRaw]: #zlib_class_zlib_deflateraw -[Deflate]: #zlib_class_zlib_deflate -[Gunzip]: #zlib_class_zlib_gunzip -[Gzip]: #zlib_class_zlib_gzip -[InflateRaw]: #zlib_class_zlib_inflateraw -[Inflate]: #zlib_class_zlib_inflate -[Memory Usage Tuning]: #zlib_memory_usage_tuning -[Unzip]: #zlib_class_zlib_unzip [`UV_THREADPOOL_SIZE`]: cli.html#cli_uv_threadpool_size_size +[`Unzip`]: #zlib_class_zlib_unzip +[`options`]: #zlib_class_options [`zlib.bytesWritten`]: #zlib_zlib_byteswritten +[Memory Usage Tuning]: #zlib_memory_usage_tuning [zlib documentation]: https://zlib.net/manual.html#Constants -- cgit v1.2.3